zidan-select 2.3.1 → 2.4.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm File-only v2.3.1
2
+ * ZidanForm File-only v2.4.1
3
3
  * Zero-dependency drag & drop file upload with variants, previews, limits and progress.
4
4
  * Pairs with plugin-file-core.css and plugin-file-theme.css.
5
5
  *
@@ -8,4 +8,4 @@
8
8
  * MIT License © akhtar1985
9
9
  *
10
10
  * Classic <script> adds window.ZidanForm plus window.zidanField / initZidanForms.
11
- */(function(p,T){"use strict";var l=T(p);typeof window!="undefined"&&(window.ZidanForm=l.ZidanForm,l.ZidanSelect&&(window.ZidanSelect=l.ZidanSelect,window.zidanSelect=l.zidanSelect,window.initZidanSelects=l.initZidanSelects),l.zidanField&&(window.zidanField=l.zidanField),l.initZidanForms&&(window.initZidanForms=l.initZidanForms),l.registerIcon&&(window.registerZidanIcon=l.registerIcon)),typeof module!="undefined"&&module.exports&&(module.exports=l)})(typeof window!="undefined"?window:this,function(p){"use strict";var T="2.3.1";if(p&&p.ZidanForm&&p.ZidanForm.__zidanFormGuard===T)return p.ZidanForm.api;var l=typeof document!="undefined"?document:null,zt=["classic-clean","floating-label","soft-pill","bordered-brutalist","glass-elevated"],H=["auto","none","vanilla","bootstrap","tailwind","bulma","foundation"],W=["default","modern","minimal","dark","glass"],J=["stacked","inline","card","compact","floating","outlined"],Ct=["checkbox","radio","radio-group","file","input","textarea"],at="[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",Q="[data-zidan-select], .zidan-select",wt="[data-zidan-form], .zidan-form",xt=["default","thin","fancy","hover","hidden"],Ft="zidan:",nt=0;function Tt(t){return nt+=1,(t||"zs")+"-"+nt.toString(36)+Math.random().toString(36).slice(2,6)}function Mt(t,e){return!!(t&&t.classList&&t.classList.contains(e))}function st(t,e){return!t||!e||e.split(/\s+/).forEach(function(i){i&&t.classList.add(i)}),t}function v(t,e,i,r){var a=l.createElement(t);return e&&(a.className=e),i&&Object.keys(i).forEach(function(n){var s=i[n];s==null||s===!1||(n==="text"?a.textContent=String(s):a.setAttribute(n,s===!0?"":String(s)))}),r!=null&&(a.textContent=String(r)),a}function $(t){return t==null||t===""?[]:Array.isArray(t)?t.slice():[t]}function tt(t){return!!(t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function")}function Lt(t){if(!t)return!1;var e=t.closest?t.closest("[dir]"):null,i=e?e.getAttribute("dir"):"";if(!i&&l&&l.documentElement&&(i=l.documentElement.getAttribute("dir")||""),i)return String(i).toLowerCase()==="rtl";try{return!!(p.getComputedStyle&&p.getComputedStyle(t).direction==="rtl")}catch{return!1}}function y(t){return!!(t&&typeof t=="object"&&t.nodeType===1)}function kt(t,e){if(t==null||t==="")return e;var i=String(t).toLowerCase();return!(i==="false"||i==="0"||i==="no"||i==="off")}function I(){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 Zt(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 Ot(t,e,i){return Math.min(i,Math.max(e,t))}function N(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 ot={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"/>'},O={};Object.keys(ot).forEach(function(t){O[t]=ot[t]});var Ut="http://www.w3.org/2000/svg",Vt={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 It(t){if(typeof t!="string"||!t.trim())return"";var e;try{if(typeof p.DOMParser=="undefined")return"";e=new p.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(a){Array.prototype.slice.call(a.children||[]).forEach(function(n){var s=String(n.nodeName);if(s!==s.toLowerCase()&&(s=s.toLowerCase()),!Vt[s]){n.parentNode.removeChild(n);return}Array.prototype.slice.call(n.attributes||[]).forEach(function(o){var u=String(o.name).toLowerCase();u.indexOf("on")===0&&n.removeAttribute(o.name),(u==="href"||u==="xlink:href")&&!/^#/.test(o.value)&&n.removeAttribute(o.name),/url\s*\(\s*['"]?\s*(?:https?:|\/\/)/i.test(o.value)&&n.removeAttribute(o.name)}),r(n)})};return r(i),i.outerHTML}function j(t){var e=t;return/^\s*</.test(e)&&!/^\s*<svg/i.test(e)?e='<svg xmlns="'+Ut+'" 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=""),It(e)}function Nt(t,e){var i="",r="";if(typeof t=="string"&&t?(r=t,/^\s*</.test(t)?i=j(t)||j('<path d="M4 12h16"/>'):O[t]&&(i=j(O[t])||"")):t&&typeof t=="object"&&t.name&&(r=t.name,i=j(O[t.name]||"")),!i)return null;var a=l.createElement("span");e&&(a.className=e),a.setAttribute("data-zs-icon",r||"custom");try{a.innerHTML=i}catch{return null}var n=a.firstChild;return n&&(n.setAttribute("focusable","false"),n.setAttribute("aria-hidden","true"),n.setAttribute("width","18"),n.setAttribute("height","18")),a}var Pt={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 Jt(t){return Pt[t]||""}function lt(t,e){return typeof ZidanSelect!="undefined"&&(!t||typeof e!="string")?ZidanSelect:(t&&typeof e=="string"&&(O[String(t)]=e),typeof ZidanSelect!="undefined"?ZidanSelect:h)}function C(t,e,i,r,a){if(e&&e[i]!==void 0&&e[i]!==null)return e[i];if(t&&r&&t.getAttribute){var n=t.getAttribute("data-zidan-"+r);if(n!==null&&n!=="")return n}return a}function P(t,e,i,r,a){if(e&&e[i]!==void 0&&e[i]!==null)return!!e[i];if(t&&r&&t.getAttribute){var n=t.getAttribute("data-zidan-"+r);if(n!==null)return kt(n,a)}return a}function Rt(t,e,i,r,a){var n=C(t,e,i,r,a);if(n==null||n==="")return a;var s=parseFloat(n);return isFinite(s)?s:a}function Qt(t,e,i,r,a){var n=C(t,e,i,r,null);return n==null||n===""?a:Array.isArray(n)?n.slice():String(n).split(",").map(function(s){return s.trim()}).filter(Boolean)}var M={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 Dt(t,e){if(!t||!t.validity||t.validity.valid)return"";var i=t.validity,r=e||M,a=String(t.type||"").toLowerCase(),n="",s={min:t.getAttribute("min"),max:t.getAttribute("max"),step:t.getAttribute("step")};return i.valueMissing?n="required":i.typeMismatch?n=a==="email"?"email":a==="url"?"url":"generic":i.patternMismatch?n="pattern":i.rangeUnderflow?n="min":i.rangeOverflow?n="max":i.stepMismatch?n="step":i.tooShort?(n="minlength",s.minlength=t.getAttribute("minlength")):i.tooLong?(n="maxlength",s.maxlength=t.getAttribute("maxlength")):(i.badInput||i.customError)&&(n="badInput"),n?N(r[n]||M[n]||r.generic,s):t.validationMessage||r.generic}var dt=["valueMissing","typeMismatch","patternMismatch","rangeUnderflow","rangeOverflow","stepMismatch","tooShort","tooLong","badInput","fileMissing"];function Bt(t){var e=t&&t.validity;if(!e)return!1;for(var i=0;i<dt.length;i+=1)if(e[dt[i]])return!0;return!1}function et(t,e){for(var i=t;i&&i.nodeType===1;){for(var r=0;r<e.length;r+=1){var a=i.getAttribute(e[r]);if(a)return a}i=i.parentElement}return""}function L(t,e,i){var r=String(t||"").toLowerCase();return e.indexOf(r)===-1?i:r}function $t(t){if(Array.isArray(t))return t.slice();if(typeof t=="string"){var e=t.trim();if(e.charAt(0)==="[")try{var i=JSON.parse(e);if(Array.isArray(i))return i}catch{}else if(e.indexOf(",")!==-1)return e.split(",").map(function(r){return Number(r.trim())}).filter(function(r){return isFinite(r)})}return t}function qt(t,e){var i=e||{},r=i.theme||et(t,["data-zidan-theme","data-zs-theme"]);!r&&l&&(r=l.documentElement.getAttribute("data-zs-theme")||"");var a=i.framework||et(t,["data-zidan-framework","data-zs-framework"]);!a&&l&&(a=l.documentElement.getAttribute("data-zs-framework")||"");var n=i.layout||et(t,["data-zidan-layout","data-zs-layout"]);return{theme:L(r,W,"default"),framework:L(a,H,"none"),layout:n?String(n).toLowerCase():""}}function te(t,e){var i=null;function r(){var a=arguments;clearTimeout(i),i=setTimeout(function(){i=null,t.apply(null,a)},e)}return r.cancel=function(){clearTimeout(i),i=null},r}var Ht=["valid","invalid"],ut=["default","switch","card","button","minimal"],ft=["ios","material","square","labeled","icon"],ct=["stacked","inline","card","button","tile"],R=["dropzone","button","avatar","gallery","compact"],ht=["default","gradient","stepped","minimal"],ee=["always","active","never"],ie=["top","bottom"];function re(t,e){var i="";return Array.prototype.slice.call(t.childNodes).forEach(function(r){r===e||r.nodeType!==3||(i+=r.nodeValue)}),i.replace(/\s+/g," ").trim()}function ae(t,e){return Array.prototype.slice.call(t.childNodes).forEach(function(i){i.nodeType===3&&i.nodeValue.trim()&&e.appendChild(i)}),e}function f(t,e,i){if(!l)throw new Error("ZidanForm requires a DOM environment.");if(!y(t))throw new Error("ZidanForm: target element not found.");this.el=t,this.kind=i,this.opts=e||{},this.opts.messages=Object.assign({},M,this.opts.messages||{}),this.id=t.id||(t.id=Tt("zf")),this.root=null,this.touched=!1,this.validation=null,this.errorMessage=null,this.errorEl=null,this.pending=!1,this._asyncToken=0,this._asyncController=null,this.destroyed=!1,this._listeners=[],this._cleanups=[],this._describedByBefore=[],this.formEl=t.form||(t.closest?t.closest("form"):null);var r=qt(t,this.opts);this.theme=r.theme,this.framework=r.framework,this.layout=this.opts.layout||r.layout}f.prototype.on=function(t,e,i,r){return!t||!t.addEventListener?this:(t.addEventListener(e,i,r),this._listeners.push([t,e,i,r]),this)},f.prototype.emit=function(t,e){if(!this.root)return this;var i=e||{};i.instance=this,i.kind=this.kind;try{this.root.dispatchEvent(new CustomEvent(Ft+t,{detail:i,bubbles:!0}))}catch{}return this},f.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,callback:t})}},f.prototype._scope=function(t){var e=v("div","zs-field");return e.id=this.id+"-field",e.setAttribute("data-zs-kind",t),e.classList.add("zs-field--"+t),Lt(this.el)&&e.setAttribute("dir","rtl"),this._applyScope(e),this.root=e,e},f.prototype._applyScope=function(t){return t.setAttribute("data-zs-theme",this.theme),t.setAttribute("data-zs-framework",this.framework),this.layout&&t.setAttribute("data-zs-layout",this.layout),t},f.prototype.setTheme=function(t){return this.theme=L(t,W,this.theme),this.root&&this.root.setAttribute("data-zs-theme",this.theme),this},f.prototype.setFramework=function(t){return this.framework=L(t,H,this.framework),this.root&&this.root.setAttribute("data-zs-framework",this.framework),this},f.prototype.setLayout=function(t){return this.layout=L(t,J,this.layout||"stacked"),this.root&&this.root.setAttribute("data-zs-layout",this.layout),this},f.prototype.validationTargets=function(){return[this.el]},f.prototype._customError=function(){return""},f.prototype._messageFor=function(t){var e=Dt(t,this.opts.messages);return e||(t&&t.validationMessage?t.validationMessage:this.opts.messages.generic||M.generic)},f.prototype._nativeError=function(){for(var t=this.validationTargets(),e=0;e<t.length;e+=1){var i=t[e];if(Bt(i))return this._messageFor(i)}return""},f.prototype._asyncSignal=function(){return this._asyncController?this._asyncController.signal:void 0},f.prototype._asyncContext=function(){return{signal:this._asyncSignal(),field:this,instance:this}},f.prototype._setCustomValidity=function(){},f.prototype._abortAsync=function(){if(this._asyncToken+=1,this._asyncController){try{this._asyncController.abort()}catch{}this._asyncController=null}},f.prototype._evaluate=function(){this._abortAsync(),typeof AbortController!="undefined"&&(this._asyncController=new AbortController);var t=this._customError?this._customError():"";if(tt(t))return{pending:t};if(this._asyncController=null,t)return{error:typeof t=="string"?t:this.opts.messages.generic,custom:!0};var e=this._nativeError();return e?{error:e,custom:!1}:{}},f.prototype._applyValidity=function(t,e,i){return this._setCustomValidity(t&&i?t:""),t?(e?this.setError(t):this.setValidation("invalid",!0),this):(this.errorMessage&&this.setError(null),this.validation==="invalid"&&!this._presetValidation&&this.setValidation(null,!0),this)},f.prototype._setPending=function(t){return t=!!t,this.pending=t,this.root&&(this.root.classList.toggle("zs-field--pending",t),t?this.root.setAttribute("data-zs-validation","pending"):this.root.getAttribute("data-zs-validation")==="pending"&&this.root.removeAttribute("data-zs-validation")),this.validationTargets().forEach(function(e){!e||!e.setAttribute||(t?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"))},this),t?(this.errorMessage&&this.setError(null),this._setCustomValidity(this.opts.messages.pending||M.pending)):this._setCustomValidity(""),this},f.prototype._runAsync=function(t){var e=this;if(e.destroyed)return Promise.resolve(!1);var i=e._asyncToken;return e._setPending(!0),Promise.resolve(t).then(function(r){if(e.destroyed||i!==e._asyncToken)return!1;e._asyncController=null,e._setPending(!1);var a="";return r===!1?a=e.opts.messages.generic:typeof r=="string"?a=r:r instanceof Error&&(a=r.message||e.opts.messages.generic),e._applyValidity(a,e.touched||e.opts.alwaysValidate||!!a,!0),!a&&e.opts.showValidState&&e.setValidation("valid"),e.emit("async-validation",{valid:!a,message:a}),!a},function(r){if(e.destroyed||i!==e._asyncToken||r&&r.name==="AbortError")return!1;e._asyncController=null,e._setPending(!1);var a=r&&(r.message||r.error)||e.opts.messages.generic;return typeof a!="string"&&(a=e.opts.messages.generic),e._applyValidity(a,!0,!0),e.emit("async-validation",{valid:!1,message:a,error:r}),!1})},f.prototype.checkAsync=function(){var t=this._evaluate();return t.pending?this._runAsync(t.pending):Promise.resolve(!t.error)},f.prototype._trackDescribedBy=function(t){if(!(!t||!t.getAttribute)){for(var e=0;e<this._describedByBefore.length;e+=1)if(this._describedByBefore[e][0]===t)return;this._describedByBefore.push([t,t.getAttribute("aria-describedby")])}},f.prototype._addDescribedBy=function(t,e){if(!(!t||!t.getAttribute||!e)){this._trackDescribedBy(t);var i=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);i.indexOf(e)===-1&&i.push(e),t.setAttribute("aria-describedby",i.join(" "))}},f.prototype._syncDescribedBy=function(){if(!(!this.el||!this.el.getAttribute)){var t=this.id+"-error",e=this.root&&this.root.querySelector?this.root.querySelector(".zs-field__hint[id]"):null,i=e?e.id:"",r=this.validationTargets();r.forEach(function(a){if(!(!a||!a.getAttribute)){this._trackDescribedBy(a);var n=(a.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean),s=n.filter(function(o){return o!==t&&o!==i});i&&s.push(i),this.errorMessage&&s.push(t),s.length?a.setAttribute("aria-describedby",s.join(" ")):a.removeAttribute("aria-describedby")}},this)}},f.prototype._renderError=function(){this.root&&(this.errorEl||(this.errorEl=v("p","zs-field__error",{id:this.id+"-error",role:"status","aria-live":"polite"}),this.root.appendChild(this.errorEl)),this.errorEl.textContent=this.errorMessage||"",this.errorEl.hidden=!this.errorMessage,this._syncDescribedBy())},f.prototype.setError=function(t){this.errorMessage=t||null,this.errorMessage?this.validation="invalid":this.validation==="invalid"&&(this.validation=null);var e=!!this.errorMessage||this.validation==="invalid";return this.root&&(this.root.classList.toggle("zs-field--invalid",e),this.root.classList.toggle("zs-field--valid",this.validation==="valid"&&!this.errorMessage),e||this.validation?this.root.setAttribute("data-zs-validation",e?"invalid":this.validation):this.root.removeAttribute("data-zs-validation")),this._renderError(),this.validationTargets().forEach(function(i){!i||!i.setAttribute||(e?i.setAttribute("aria-invalid","true"):this.validation==="valid"?i.setAttribute("aria-invalid","false"):i.removeAttribute("aria-invalid"))},this),this.emit("validation",{state:e?"invalid":this.validation,message:this.errorMessage}),this.call("onValidation",{state:e?"invalid":this.validation,message:this.errorMessage,instance:this}),this},f.prototype.clearError=function(){return this.setError(null)},f.prototype._bindValidity=function(){var t=this;this.validationTargets().forEach(function(i){t.on(i,"invalid",function(){t.touched=!0;var r=t._evaluate();if(r.pending){t._runAsync(r.pending);return}r.error?t.setError(r.error):t.setValidation("invalid")}),t.on(i,"blur",function(){t.touched=!0,t._presetValidation=!1,t._mirrorValidity()}),t.on(i,"input",function(){t._presetValidation=!1,t._mirrorValidity()}),t.on(i,"change",function(){t._presetValidation=!1,t._mirrorValidity()})}),this.on(this.formEl,"reset",function(){p.setTimeout(function(){t.destroyed||(t._abortAsync(),t.touched=!1,t.errorMessage=null,t._setPending(!1),t.errorEl&&(t.errorEl.textContent="",t.errorEl.hidden=!0),t.setValidation(null),t.update())},0)});var e=this.opts.validation||this.el.getAttribute("data-zidan-validation")||this.el.getAttribute("data-zs-validation");(e==="valid"||e==="invalid")&&this.setValidation(e),this._syncDescribedBy()},f.prototype._mirrorValidity=function(){var t=this._evaluate();return t.pending?(this._runAsync(t.pending),this):(this.pending&&this._setPending(!1),this._applyValidity(t.error||"",this.touched||this.opts.alwaysValidate,t.custom),this)},f.prototype.validate=function(){this.touched=!0;var t=this._evaluate();return t.pending?this._runAsync(t.pending):(this.pending&&this._setPending(!1),t.error?(this._applyValidity(t.error,!0,t.custom),!1):(this._applyValidity("",!0,!1),this.opts.showValidState&&this.setValidation("valid"),!0))},f.prototype.setValidation=function(t,e){this.validation=Ht.indexOf(t)===-1?null:t,e||(this._presetValidation=this.validation==="invalid");var i=this.validation==="invalid"||!!this.errorMessage;return this.root&&(this.root.classList.toggle("zs-field--invalid",i),this.root.classList.toggle("zs-field--valid",this.validation==="valid"&&!this.errorMessage),i?this.root.setAttribute("data-zs-validation","invalid"):this.validation?this.root.setAttribute("data-zs-validation",this.validation):this.root.removeAttribute("data-zs-validation")),this.validationTargets().forEach(function(r){!r||!r.setAttribute||(i?r.setAttribute("aria-invalid","true"):this.validation==="valid"?r.setAttribute("aria-invalid","false"):r.removeAttribute("aria-invalid"))},this),this.emit("validation",{state:i?"invalid":this.validation,message:this.errorMessage}),this.call("onValidation",{state:i?"invalid":this.validation,message:this.errorMessage,instance:this}),this},f.prototype.getValidation=function(){return this.validation},f.prototype.isPending=function(){return this.pending},f.prototype.getValue=function(){var t=this.el;return t?this.kind==="file"?this.getFiles?this.getFiles():Array.prototype.slice.call(t.files||[]):t.type==="checkbox"?!!t.checked:t.multiple&&t.options?Array.prototype.filter.call(t.options,function(e){return e.selected}).map(function(e){return e.value}):t.value:null},f.prototype.setValue=function(t){var e=this.el;if(!e)return this;if(this.kind==="file"){var i=t==null?[]:Array.isArray(t)?t:[t];return i.length?(this.addFiles&&this.addFiles(i),this):this.clear?this.clear():this}if(e.type==="checkbox")return this.setChecked?this.setChecked(!!t):(e.checked=!!t,e.dispatchEvent(new Event("change",{bubbles:!0})),this.update());if(e.multiple&&e.options){var r=(Array.isArray(t)?t:[t]).map(String);Array.prototype.forEach.call(e.options,function(a){a.selected=r.indexOf(a.value)!==-1})}else e.value=t==null?"":String(t);return e.dispatchEvent(new Event("change",{bubbles:!0})),this.update()},f.prototype.update=function(){return this._sync&&this._sync(),this._mirrorValidity(),this},f.prototype.refresh=function(){return this.update()},f.prototype.destroy=function(){return this.destroyed?this:(this.destroyed=!0,this._abortAsync(),this._listeners.forEach(function(t){t[0].removeEventListener(t[1],t[2],t[3])}),this._listeners.length=0,this._teardown&&this._teardown(),this._cleanups.forEach(function(t){t()}),this._cleanups.length=0,this.emit("destroy",{}),this.root&&this.root!==this.el&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this._describedByBefore.forEach(function(t){var e=t[0];!e||!e.getAttribute||(t[1]===null||t[1]===void 0?e.removeAttribute("aria-describedby"):e.setAttribute("aria-describedby",t[1]))}),this._describedByBefore=[],this.el.__zidanField===this&&delete this.el.__zidanField,h._unregister(this),this)};function G(t){return!t&&t!==0?"":t<1024?t+" B":t<1024*1024?(t/1024).toFixed(t<10240?1:0)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function pt(t){var e=/\.([a-z0-9]+)$/i.exec(String(t||""));return e?"."+e[1].toLowerCase():""}function jt(t,e){return e?String(e).split(",").some(function(i){var r=i.trim().toLowerCase();return r?r.indexOf(".")===0?pt(t.name)===r:r.indexOf("/*")!==-1?String(t.type).toLowerCase().indexOf(r.split("/")[0]+"/")===0:String(t.type).toLowerCase()===r:!1}):!0}function w(t){return[t.name,t.size,t.lastModified||0,t.type||""].join("|")}function Gt(t,e){return t&&typeof t=="string"?t:t&&t.message?t.message:t&&t.status?"Upload failed (HTTP "+t.status+").":e||"Upload failed."}function d(t,e){if(!(this instanceof d))return new d(t,e);if(!/^file$/i.test(t.type))throw new Error('ZidanFileUpload: expected an <input type="file">.');f.call(this,t,e,"file");var i=this,r=t,a=this.opts,n=L(C(r,a,"fileVariant","file-variant",C(r,a,"variant","variant","dropzone")),R,"dropzone"),s=r.parentNode,o=this._scope("file");o.setAttribute("data-zs-file-variant",n),s.insertBefore(o,r);var u=v("label","zs-file-drop zs-file-drop--"+n);u.setAttribute("for",this.id);var _=v("span","zs-file-avatar",{hidden:!0}),E=l.createElement("img");E.alt="",_.appendChild(E);var z=v("span","zs-file-icon",{"aria-hidden":"true"}),c=C(r,a,"uploadIcon","upload-icon",C(r,a,"icon","icon","upload")),D=Nt(c,"zs-file-icon-svg");D&&z.appendChild(D);var X=a.title||r.getAttribute("data-zidan-title")||(n==="avatar"?"Upload an image":n==="gallery"?"Add images":"Choose a file"),S=v("span","zs-file-drop-title",null,X),b=v("span","zs-file-drop-hint",null,a.dropHint||r.getAttribute("data-zidan-drop-hint")||(r.multiple?"or drop files here \u2014 multiple allowed":"or drop it here"));u.appendChild(_),u.appendChild(z),u.appendChild(S),u.appendChild(b),u.appendChild(r),o.appendChild(u);var k=v("ul","zs-file-list");o.appendChild(k);var x=v("div","zs-file-meta-row"),B=v("span","zs-file-status",{role:"status","aria-live":"polite"}),F=v("button","zs-file-clear",{type:"button"});F.textContent=a.clearLabel||"Clear all",F.hidden=!0,x.appendChild(B),x.appendChild(F),o.appendChild(x);var q=a.accept||r.accept;q&&(b.textContent=b.textContent+" \xB7 "+q),this.variant=n,this.drop=u,this.list=k,this.status=B,this.clearBtn=F,this.titleEl=S,this.hintEl=b,this._fallbackTitle=X,this.avatarEl=_,this.avatarImg=E,this.uploadHandler=typeof a.upload=="function"?a.upload:typeof a.uploadHandler=="function"?a.uploadHandler:null,this.uploadUrl=C(r,a,"uploadUrl","upload-url",""),this.uploadField=C(r,a,"uploadField","upload-field","file"),this.withCredentials=P(r,a,"withCredentials","with-credentials",!1),this.uploadHeaders=a.uploadHeaders||a.headers||null,this.simulateUpload=P(r,a,"simulateUpload","simulate-upload",!1),this.simulateDuration=Math.max(120,Rt(r,a,"simulateDuration","simulate-duration",900)),this.autoUpload=P(r,a,"autoUpload","auto-upload",!0),this.showFileMeta=P(r,a,"showFileMeta","show-file-meta",!0),this.showPreview=P(r,a,"showPreview","preview",!0),this.hasUploader=!!(this.uploadHandler||this.uploadUrl||this.simulateUpload),o.setAttribute("data-zs-upload",this.hasUploader?"true":"false"),this._uploads=Object.create(null),this._active=Object.create(null),this._urls=[],this._renderQueued=!1,this.fileError="",this._restoreInput=function(){var m=o.parentNode||s;m.insertBefore(r,o.parentNode?o:null),r.classList.remove("zs-native-input","zs-file-input")},st(r,"zs-native-input"),st(r,"zs-file-input"),this.on(r,"change",function(){var m=i._validate();i._render(),i.emit("change",{files:i.getFiles()}),i.call("onChange",{files:i.getFiles(),instance:i}),m&&i.autoUpload&&i.hasUploader&&i.uploadAll()});var Z=0;["dragenter","dragover"].forEach(function(m){i.on(u,m,function(A){A.preventDefault(),m==="dragenter"&&(Z+=1),u.classList.add("zs-file-drop--over")})}),i.on(u,"dragleave",function(){Z=Math.max(0,Z-1),Z||u.classList.remove("zs-file-drop--over")}),i.on(u,"drop",function(m){if(m.preventDefault(),Z=0,u.classList.remove("zs-file-drop--over"),!(!m.dataTransfer||!m.dataTransfer.files||!m.dataTransfer.files.length)){var A=Array.prototype.slice.call(m.dataTransfer.files);r.multiple||(A=A.slice(0,1)),i.addFiles(A)}}),i.on(F,"click",function(){i.clear()}),i.on(k,"click",function(m){var A=m.target&&m.target.closest?m.target.closest("button"):null;if(!(!A||!k.contains(A))){var Et=A.closest(".zs-file-item"),St=Et?parseInt(Et.getAttribute("data-zs-file-index"),10):-1,K=St>=0?i.getFiles()[St]:null;K&&(m.preventDefault(),m.stopPropagation(),A.classList.contains("zs-file-cancel")?i.cancelUpload(K):A.classList.contains("zs-file-retry")?i.retryUpload(K):A.classList.contains("zs-file-remove")&&i.removeFile(K))}}),this._bindValidity(),this.on(this.formEl,"reset",function(){p.setTimeout(function(){i.destroyed||(i.cancelAll(),i._uploads=Object.create(null),i.fileError="",r.setCustomValidity&&r.setCustomValidity(""),i._render())},0)}),r.__zidanField=this,this._render(),this.emit("init",{}),h._register(this)}d.prototype=Object.create(f.prototype),d.prototype.constructor=d,d.prototype.getFiles=function(){return this.el.files?Array.prototype.slice.call(this.el.files):[]},d.prototype.getUploadState=function(){var t=this;return this.getFiles().map(function(e){var i=t._stateFor(e,!1)||{status:"idle",progress:0,error:"",result:null};return{file:e,name:e.name,size:e.size,status:i.status,progress:i.progress,error:i.error,result:i.result}})},d.prototype._stateFor=function(t,e){var i=w(t),r=this._uploads[i];return!r&&e&&(r=this._uploads[i]={status:"idle",progress:0,error:"",result:null}),r},d.prototype._setFiles=function(t){try{var e=typeof DataTransfer!="undefined"?DataTransfer:p.DataTransfer;if(!e)return!1;var i=new e;return t.forEach(function(r){i.items.add(r)}),this.el.files=i.files,!0}catch{return!1}},d.prototype._applyFiles=function(t,e){if(!this._setFiles(t))return this.emit("error",{error:new Error("This browser cannot assign files programmatically."),action:"setFiles"}),this;if(e)try{this.el.dispatchEvent(new Event("change",{bubbles:!0}))}catch{}else this._validate(),this._render();return this},d.prototype.addFiles=function(t){var e=t&&t.length!==void 0?Array.prototype.slice.call(t):$(t);if(!e.length)return this;var i=this.el.multiple?this.getFiles():[],r=Object.create(null),a=i.concat(e).filter(function(n){var s=w(n);return r[s]?!1:(r[s]=!0,!0)});if(this.el.multiple||(a=a.slice(0,1)),!this._setFiles(a))return this.emit("error",{error:new Error("This browser cannot assign files programmatically."),action:"addFiles"}),this;try{this.el.dispatchEvent(new Event("change",{bubbles:!0}))}catch{}return this},d.prototype.replaceFiles=function(t){return this._applyFiles(t&&t.length!==void 0?Array.prototype.slice.call(t):$(t),!0)},d.prototype.removeFile=function(t){var e=this.getFiles(),i=typeof t=="number"?t:e.indexOf(t);if(i===-1||!e[i])return this;var r=e[i];this.cancelUpload(r),delete this._uploads[w(r)];var a=e.slice();return a.splice(i,1),this._setFiles(a),this._validate(),this._render(),this.emit("change",{files:a}),this.emit("remove",{file:r,index:i}),this.call("onChange",{files:a,instance:this}),this.call("onRemove",{file:r,index:i,instance:this}),this},d.prototype.clear=function(){return this.cancelAll(),this._uploads=Object.create(null),this.fileError="",this.el.value="",this.el.setCustomValidity&&this.el.setCustomValidity(""),this._validate(),this._render(),this.emit("change",{files:[]}),this.emit("clear",{}),this.call("onChange",{files:[],instance:this}),this},d.prototype._limits=function(){var t=this.el,e=this.opts,i=parseInt(e.maxFiles||t.getAttribute("data-zidan-max-files"),10),r=parseInt(e.maxSize||t.getAttribute("data-zidan-max-size"),10);if(!(r>0)){var a=e.maxSizeMB;if((a==null||a==="")&&(a=t.getAttribute("data-zidan-max-size-mb")),a!=null&&a!==""){var n=parseFloat(a);n>0&&(r=Math.round(n*1024*1024))}}return{maxFiles:i>0?i:0,maxSize:r>0?r:0,accept:e.accept||t.accept||""}},d.prototype._setCustomValidity=function(t){this.el&&this.el.setCustomValidity&&this.el.setCustomValidity(t||"")},d.prototype._customError=function(){if(this.fileError)return this.fileError;if(typeof this.opts.validate=="function"){var t=this.opts.validate(this.getFiles(),this,this._asyncContext());if(t===!1)return this.opts.messages.generic;if(typeof t=="string"&&t||tt(t))return t}return""},d.prototype._validate=function(){var t=this.el,e=this.opts.messages,i=this._limits(),r=this.getFiles(),a="";if(i.maxFiles&&r.length>i.maxFiles&&(a=N(e.fileCount,{max:i.maxFiles}),r=r.slice(0,i.maxFiles),this._setFiles(r)),!a&&i.maxSize){for(var n=0;n<r.length;n+=1)if(r[n].size>i.maxSize){a=N(e.fileSize,{name:r[n].name,size:G(r[n].size),limit:G(i.maxSize)});break}}if(!a&&i.accept){for(var s=0;s<r.length;s+=1)if(!jt(r[s],i.accept)){a=N(e.fileType,{name:r[s].name,accept:i.accept});break}}this.fileError=a,t.setCustomValidity&&t.setCustomValidity(this.pending?e.pending||M.pending:a||"");var o=a||this._nativeError();return o?this.setError(o):this.errorMessage&&this.setError(null),this.root.classList.toggle("zs-field--filled",r.length>0),this.drop.classList.toggle("zs-file-drop--invalid",!!o),this._renderStatus(),!o},d.prototype._sync=function(){this._render()},d.prototype._queueRender=function(){var t=this;if(!(this._renderQueued||this.destroyed)){this._renderQueued=!0;var e=function(){t._renderQueued=!1,t.destroyed||t._render()};p.requestAnimationFrame?p.requestAnimationFrame(e):p.setTimeout(e,32)}},d.prototype._renderStatus=function(){var t=this.getFiles(),e=this.getUploadState(),i=t.reduce(function(u,_){return u+_.size},0),r=e.filter(function(u){return u.status==="uploading"}),a=e.filter(function(u){return u.status==="error"}),n=e.filter(function(u){return u.status==="done"}),s="";if(this.fileError)s=this.fileError;else if(t.length)if(s=t.length+(t.length===1?" file selected":" files selected")+" \xB7 "+G(i),r.length){var o=Math.round(r.reduce(function(u,_){return u+_.progress},0)/r.length);s+=" \xB7 Uploading "+o+"%"}else a.length?s+=" \xB7 "+a.length+" failed":n.length===t.length&&this.hasUploader&&(s+=" \xB7 Uploaded");this.status.textContent=s,this.status.classList.toggle("zs-file-status--error",!!this.fileError),this.status.classList.toggle("zs-file-status--success",!this.fileError&&t.length>0&&n.length===t.length&&this.hasUploader)},d.prototype._render=function(){var t=this,e=this.getFiles(),i=this.opts;this.list.textContent="",this._revokeLater(this._urls),this._urls=[],this.list.hidden=e.length===0,this.clearBtn.hidden=e.length===0,this.root.classList.toggle("zs-field--filled",e.length>0),this.drop.classList.toggle("zs-file-drop--has-files",e.length>0);var r=this.showPreview?e.filter(function(n){return/^image\//.test(n.type)})[0]:null;if(r){var a=URL.createObjectURL(r);this._urls.push(a),this.avatarImg.src=a,this.avatarEl.hidden=!1,this.drop.classList.add("zs-file-drop--has-preview"),this.titleEl.textContent=i.replaceTitle||"Change image"}else this.avatarImg.removeAttribute("src"),this.avatarEl.hidden=!0,this.drop.classList.remove("zs-file-drop--has-preview"),this.titleEl.textContent=this._fallbackTitle;e.forEach(function(n,s){var o=t._stateFor(n,!1)||{status:"idle",progress:0,error:"",result:null},u=v("li","zs-file-item");u.setAttribute("data-zs-upload-state",o.status),u.setAttribute("data-zs-file-index",String(s));var _=v("span","zs-file-thumb");if(/^image\//.test(n.type)){var E=URL.createObjectURL(n);t._urls.push(E);var z=l.createElement("img");z.src=E,z.alt="",_.appendChild(z)}else _.textContent=(pt(n.name)||"file").replace(".","").slice(0,4).toUpperCase();var c=v("span","zs-file-info"),D=v("span","zs-file-name",null,n.name);if(c.appendChild(D),t.showFileMeta){var X=G(n.size)+(n.type?" \xB7 "+n.type:"");c.appendChild(v("span","zs-file-size",null,X))}if(t.hasUploader){var S=v("span","zs-file-upload-state");if(o.status==="uploading"){S.textContent=N(i.progressTemplate||"Uploading {percent}%",{percent:o.progress});var b=v("span","zs-file-progress");b.setAttribute("role","progressbar"),b.setAttribute("aria-valuemin","0"),b.setAttribute("aria-valuemax","100"),b.setAttribute("aria-valuenow",String(o.progress)),b.setAttribute("aria-label","Upload progress for "+n.name);var k=v("span","zs-file-progress-bar");k.style.width=o.progress+"%",b.appendChild(k),S.appendChild(b)}else o.status==="done"?S.textContent=i.uploadedLabel||"Uploaded":o.status==="error"?S.textContent=(i.failedLabel||"Upload failed")+(o.error?" \u2014 "+o.error:""):o.status==="canceled"&&(S.textContent=i.canceledLabel||"Upload canceled");S.textContent&&c.appendChild(S)}var x=v("span","zs-file-actions");if(o.status==="uploading"){var B=v("button","zs-file-cancel",{type:"button","aria-label":"Cancel upload of "+n.name});B.textContent=i.cancelLabel||"Cancel",x.appendChild(B)}else if(o.status==="error"||o.status==="canceled"){var F=v("button","zs-file-retry",{type:"button","aria-label":"Retry upload of "+n.name});F.textContent=i.retryLabel||"Retry",x.appendChild(F)}var q=v("button","zs-file-remove",{type:"button","aria-label":"Remove "+n.name});if(q.textContent="\xD7",x.appendChild(q),u.appendChild(_),u.appendChild(c),u.appendChild(x),t.list.appendChild(u),typeof i.renderFile=="function")try{i.renderFile(u,{file:n,index:s,state:o,field:t})}catch(Z){t.emit("error",{error:Z,callback:"renderFile"})}}),this._renderStatus()},d.prototype.setVariant=function(t){var e=L(t,R,this.variant);return e===this.variant?this:(this.variant=e,R.forEach(function(i){this.drop.classList.remove("zs-file-drop--"+i)},this),this.drop.classList.add("zs-file-drop--"+e),this.root.setAttribute("data-zs-file-variant",e),this._render(),this)},d.prototype.setUploader=function(t){return typeof t=="function"?(this.uploadHandler=t,this.uploadUrl=""):(this.uploadHandler=null,this.uploadUrl=t?String(t):""),this.hasUploader=!!(this.uploadHandler||this.uploadUrl||this.simulateUpload),this.root.setAttribute("data-zs-upload",this.hasUploader?"true":"false"),this._render(),this},d.prototype._formData=function(t){var e=new FormData;e.append(this.uploadField,t,t.name);var i=typeof this.opts.uploadData=="function"?this.opts.uploadData(t,this):this.opts.uploadData;return i&&typeof i=="object"&&Object.keys(i).forEach(function(r){var a=i[r];a!=null&&e.append(r,a)}),e},d.prototype.uploadAll=function(){var t=this;if(!this.hasUploader)return this;if(!this._validate())return this;var e=this.validate();return tt(e)?e.then(function(i){return i&&!t.destroyed&&t.getFiles().forEach(function(r){t.uploadFile(r)}),i}):e?(this.getFiles().forEach(function(i){t.uploadFile(i)}),this):this},d.prototype.uploadFile=function(t){var e=this,i=w(t),r=this._stateFor(t,!0);if(r.status==="uploading"||r.status==="done")return this;if(r.status="uploading",r.progress=0,r.error="",r.result=null,this._queueRender(),this.emit("upload-start",{file:t,name:t.name,size:t.size}),this.call("onUploadStart",{file:t,name:t.name,size:t.size,instance:this}),this.uploadHandler){var a=typeof AbortController!="undefined"?new AbortController:null;this._active[i]={type:"handler",abort:function(){a&&a.abort()}};var n={file:t,field:this,formData:this._formData(t),signal:a?a.signal:null,onProgress:function(c){e._setProgress(t,c)},complete:function(c){e._finish(t,c)},fail:function(c){e._fail(t,c)}},s;try{s=this.uploadHandler(t,n)}catch(c){return this._fail(t,c),this}return s&&typeof s.then=="function"?s.then(function(c){e._finish(t,c)},function(c){c&&(c.name==="AbortError"||c.aborted)?e._canceledUpload(t):e._fail(t,c)}):s!==void 0&&this._finish(t,s),this}if(this.uploadUrl){var o=new p.XMLHttpRequest;this._active[i]={type:"xhr",abort:function(){try{o.abort()}catch{}}},o.open("POST",this.uploadUrl,!0),this.withCredentials&&(o.withCredentials=!0);var u=typeof this.uploadHeaders=="function"?this.uploadHeaders(t,this):this.uploadHeaders;return u&&typeof u=="object"&&Object.keys(u).forEach(function(c){o.setRequestHeader(c,u[c])}),o.upload.onprogress=function(c){c.lengthComputable&&e._setProgress(t,Math.min(99,Math.round(c.loaded/c.total*100)))},o.onload=function(){if(o.status>=200&&o.status<300){var c=o.responseText;try{c=JSON.parse(c)}catch{}e._finish(t,c)}else e._fail(t,{status:o.status,message:"Upload failed (HTTP "+o.status+")."})},o.onerror=function(){e._fail(t,{message:"Network error while uploading."})},o.onabort=function(){e._canceledUpload(t)},o.send(this._formData(t)),this}if(this.simulateUpload){var _=Date.now(),E=null,z=function(){if(!(!e._uploads[i]||r.status!=="uploading")){var c=Math.min(99,Math.round((Date.now()-_)/e.simulateDuration*100));e._setProgress(t,c),c>=99?(delete e._active[i],e._finish(t,{simulated:!0})):E=p.setTimeout(z,40)}};return this._active[i]={type:"simulation",abort:function(){E&&p.clearTimeout(E)}},E=p.setTimeout(z,40),this}return r.status="idle",this._queueRender(),this},d.prototype._setProgress=function(t,e){var i=this._stateFor(t,!1);if(!(!i||i.status!=="uploading")){var r=Ot(Math.round(Number(e)||0),0,99);r!==i.progress&&(i.progress=r,this._queueRender(),this.emit("upload-progress",{file:t,progress:r,name:t.name}),this.call("onUploadProgress",{file:t,progress:r,name:t.name,instance:this}))}},d.prototype._finish=function(t,e){var i=this._stateFor(t,!1);!i||i.status!=="uploading"||(delete this._active[w(t)],i.status="done",i.progress=100,i.result=e===void 0?null:e,this._queueRender(),this.emit("upload-success",{file:t,name:t.name,result:i.result}),this.call("onUploadSuccess",{file:t,name:t.name,result:i.result,instance:this}),this.call("onUpload",{file:t,name:t.name,result:i.result,instance:this}))},d.prototype._fail=function(t,e){var i=this._stateFor(t,!1);!i||i.status!=="uploading"||(delete this._active[w(t)],i.status="error",i.error=Gt(e,this.opts.messages.upload||"Upload failed."),this._queueRender(),this.emit("upload-error",{file:t,name:t.name,error:e,message:i.error}),this.call("onUploadError",{file:t,name:t.name,error:e,message:i.error,instance:this}))},d.prototype._canceledUpload=function(t){var e=this._stateFor(t,!1);!e||e.status!=="uploading"||(delete this._active[w(t)],e.status="canceled",e.progress=0,e.error="",this._queueRender(),this.emit("upload-cancel",{file:t,name:t.name}),this.call("onUploadCancel",{file:t,name:t.name,instance:this}))},d.prototype.cancelUpload=function(t){var e=w(t),i=this._active[e];if(i){try{i.abort()}catch{}delete this._active[e]}return this._canceledUpload(t),this},d.prototype.cancelAll=function(){var t=this;return Object.keys(this._active).forEach(function(e){try{t._active[e].abort()}catch{}delete t._active[e]}),this},d.prototype.retryUpload=function(t){var e=this._stateFor(t,!1);return e?(e.status="idle",e.progress=0,e.error="",this.uploadFile(t)):this},d.prototype._revokeLater=function(t){!t||!t.length||p.setTimeout(function(){t.forEach(function(e){try{URL.revokeObjectURL(e)}catch{}})},800)},d.prototype._teardown=function(){this.cancelAll(),this._uploads=Object.create(null),this._revokeLater(this._urls),this._urls=[],this._restoreInput&&this._restoreInput()};function U(t){if(!y(t))return null;var e=String(t.getAttribute("data-zidan")||"").toLowerCase();if(Ct.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(Mt(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 Y(t,e,i){var r=I(Zt(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 d!="undefined"?new d(t,r):null;case"input":case"textarea":return typeof ZidanTextField!="undefined"?new ZidanTextField(t,r):null;default:return null}}function vt(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(l.querySelectorAll(t)):y(t)?i=[t]:t&&typeof t.length=="number"&&(i=Array.prototype.slice.call(t));var r=[];return i.forEach(function(a){if(!a.__zidanField){var n=U(a)||_t(a);if(n){if(n==="radio"||n==="radio-group"){if(/^INPUT$/i.test(a.tagName)&&(a=a.closest?a.closest("fieldset, [data-zidan-radio-group]"):null,!a))return;n="radio-group"}var s=Y(a,n,e||{});s&&r.push(s)}}}),r.length===1?r[0]:r}function mt(t,e){var i=[];return t.forEach(function(r){if(!(!y(r)||r.__zidanField)){var a=U(r);if(a){if(a==="radio"||a==="radio-group"){if(/^INPUT$/i.test(r.tagName)&&(r=r.closest?r.closest("fieldset, [data-zidan-radio-group]"):null,!r))return;a="radio-group"}var n=Y(r,a,e||{});n&&i.push(n)}}}),i}function V(t,e){var i=t||l;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(at));return y(i)&&i.matches&&i.matches(at)&&r.unshift(i),mt(r,e)}var h={version:T,__zidanFormGuard:T,themes:W,frameworks:H.slice(),fieldLayouts:J,fields:[],_register:function(t){h.fields.indexOf(t)===-1&&h.fields.push(t)},_unregister:function(t){var e=h.fields.indexOf(t);e!==-1&&h.fields.splice(e,1)},get:function(t){var e=typeof t=="string"?l.querySelector(t):t;return y(e)&&e.__zidanField||null},init:function(t,e){return V(t||l,e||{})},field:vt,refresh:function(t){return V(t||l,{}),h.fields.slice().forEach(function(e){e.update()}),h.fields.slice()},destroyAll:function(){return h.fields.slice().forEach(function(t){t.destroy()}),h.fields=[],typeof ZidanSelect!="undefined"&&ZidanSelect.destroyAll&&ZidanSelect.destroyAll(),h},observe:function(t,e){var i=t||l.body;if(!i||!p.MutationObserver)return null;var r=new p.MutationObserver(function(a){a.forEach(function(n){Array.prototype.slice.call(n.addedNodes).forEach(function(s){y(s)&&(U(s)&&Y(s,U(s)==="radio"?"radio-group":U(s),e||{}),s.querySelectorAll&&V(s,e||{}))})}),h.fields.slice().forEach(function(n){n.el.isConnected||n.destroy()}),typeof ZidanSelect!="undefined"&&ZidanSelect.instances.slice().forEach(function(n){n.el.isConnected||n.destroy()})});return r.observe(i,{childList:!0,subtree:!0}),r}};h.api=null,h.registerIcon=lt,h.icons=O,typeof PHONE_COUNTRIES!="undefined"&&(h.phoneCountries=PHONE_COUNTRIES,h.phoneFormats=PHONE_FORMATS.slice(),h.formatPhone=formatPhone,h.detectPhoneCountry=detectPhoneCountry),h.messages=M,h.variants={},typeof ut!="undefined"&&(h.variants.checkbox=ut.slice()),typeof ft!="undefined"&&(h.variants.switch=ft.slice()),typeof ct!="undefined"&&(h.variants.radio=ct.slice()),typeof R!="undefined"&&(h.variants.file=R.slice()),typeof ht!="undefined"&&(h.variants.range=ht.slice()),typeof STEPPER_MODES!="undefined"&&(h.stepperModes=STEPPER_MODES.slice()),h.fieldLayouts=J.slice(),typeof ZidanSelect!="undefined"&&(ZidanSelect.version=T,ZidanSelect.__zidanSelectGuard=T,ZidanSelect.layouts=zt.slice(),ZidanSelect.frameworks=H.slice(),ZidanSelect.scrollbars=xt.slice(),ZidanSelect.defaults=DEFAULTS,ZidanSelect.cacheLimit=50,ZidanSelect.get=function(t){var e=typeof t=="string"?l.querySelector(t):t;return y(e)&&e.__zidanSelect||null},ZidanSelect.instances=[],ZidanSelect.destroyAll=function(){ZidanSelect.instances.slice().forEach(function(t){t.destroy()}),ZidanSelect.instances=[]});function Yt(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(l.querySelectorAll(t)):t&&typeof t.length=="number"&&!y(t)&&t!==p?i=Array.prototype.slice.call(t):y(t)&&(i=[t]);var r=i.map(function(a){var n=new ZidanSelect(a,e||{});return ZidanSelect.instances.push(n),n});return r.length===1?r[0]:r}function it(t,e){return t.filter(function(i){return y(i)&&!i.__zidanSelect}).map(function(i){return ZidanSelect.instances.push(new ZidanSelect(i,e||{})),i.__zidanSelect})}function yt(t,e){var i=t||l;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(Q));return y(i)&&i.matches&&i.matches(Q)&&r.unshift(i),it(r,e)}function rt(t,e){$(t).forEach(function(i){i&&(typeof i=="string"?e(i,null):i.selector&&e(String(i.selector),i.options||null))})}function gt(t,e){rt(t,function(i,r){it(Array.prototype.slice.call(l.querySelectorAll(i)),I(e,r))})}function Xt(t,e){rt(t,function(i,r){var a=I(e,r);Array.prototype.slice.call(l.querySelectorAll(i)).forEach(function(n){if(!(!y(n)||n.__zidanField)){var s=U(n)||_t(n);s&&(s==="radio"&&(s="radio-group"),Y(n,s,a))}})})}function _t(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 Kt(t,e){if(typeof ZidanSelect=="undefined")return[];var i=Q+", select",r=Array.prototype.slice.call(t.querySelectorAll(i));return y(t)&&t.matches&&t.matches(i)&&r.unshift(t),it(r,e)}function bt(t,e,i){y(t)&&(Kt(t,e),typeof d!="undefined"&&mt(Array.prototype.slice.call(t.querySelectorAll('input[type="file"]')),i),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined")&&V(t,i))}function Wt(t,e,i){Array.prototype.slice.call(l.querySelectorAll(wt)).forEach(function(r){bt(r,e,i)}),rt(t,function(r,a){Array.prototype.slice.call(l.querySelectorAll(r)).forEach(function(n){bt(n,I(e,a),I(i,a))})})}function At(){if(l){var t=p.ZIDAN_FORM_CONFIG||p.ZIDAN_SELECT_CONFIG||{};if(t.autoInit!==!1&&!(p.ZidanSelect&&p.ZidanSelect.autoInit===!1)&&l.documentElement.getAttribute("data-zidan-auto-init")!=="false"){var e=typeof ZidanSelect!="undefined",i=typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined",r=t.options||{},a=t.fieldOptions||t.fields||{};e&&(t.selector?gt(t.selector,r):gt(t.targets||t.selectors,r)),i&&Xt(t.fieldTargets,a),Wt(t.formTargets,r,a),e&&!t.selector&&yt(l,r),i&&V(l,a)}}}l&&(l.readyState==="loading"?l.addEventListener("DOMContentLoaded",At):setTimeout(At,0));var g={ZidanForm:h,registerIcon:lt};return typeof ZidanSelect!="undefined"&&(g.ZidanSelect=ZidanSelect,g.zidanSelect=Yt,g.initZidanSelects=yt),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined")&&(g.zidanField=vt,g.initZidanForms=V),typeof ZidanCheckbox!="undefined"&&(g.ZidanCheckbox=ZidanCheckbox),typeof ZidanRadioGroup!="undefined"&&(g.ZidanRadioGroup=ZidanRadioGroup),typeof d!="undefined"&&(g.ZidanFileUpload=d),typeof ZidanTextField!="undefined"&&(g.ZidanTextField=ZidanTextField),typeof formatPhone=="function"&&(g.formatPhone=formatPhone,g.detectPhoneCountry=detectPhoneCountry),h.api=g,g});
11
+ */(function(p,T){"use strict";var l=T(p);typeof window!="undefined"&&(window.ZidanForm=l.ZidanForm,l.ZidanSelect&&(window.ZidanSelect=l.ZidanSelect,window.zidanSelect=l.zidanSelect,window.initZidanSelects=l.initZidanSelects),l.zidanField&&(window.zidanField=l.zidanField),l.initZidanForms&&(window.initZidanForms=l.initZidanForms),l.registerIcon&&(window.registerZidanIcon=l.registerIcon)),typeof module!="undefined"&&module.exports&&(module.exports=l)})(typeof window!="undefined"?window:this,function(p){"use strict";var T="2.4.1";if(p&&p.ZidanForm&&p.ZidanForm.__zidanFormGuard===T)return p.ZidanForm.api;var l=typeof document!="undefined"?document:null,zt=["classic-clean","floating-label","soft-pill","bordered-brutalist","glass-elevated"],H=["auto","none","vanilla","bootstrap","tailwind","bulma","foundation"],W=["default","modern","minimal","dark","glass"],J=["stacked","inline","card","compact","floating","outlined"],Ct=["checkbox","radio","radio-group","file","input","textarea"],at="[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",Q="[data-zidan-select], .zidan-select",wt="[data-zidan-form], .zidan-form",xt=["default","thin","fancy","hover","hidden"],Ft="zidan:",nt=0;function Tt(t){return nt+=1,(t||"zs")+"-"+nt.toString(36)+Math.random().toString(36).slice(2,6)}function Mt(t,e){return!!(t&&t.classList&&t.classList.contains(e))}function st(t,e){return!t||!e||e.split(/\s+/).forEach(function(i){i&&t.classList.add(i)}),t}function v(t,e,i,r){var a=l.createElement(t);return e&&(a.className=e),i&&Object.keys(i).forEach(function(n){var s=i[n];s==null||s===!1||(n==="text"?a.textContent=String(s):a.setAttribute(n,s===!0?"":String(s)))}),r!=null&&(a.textContent=String(r)),a}function $(t){return t==null||t===""?[]:Array.isArray(t)?t.slice():[t]}function tt(t){return!!(t&&(typeof t=="object"||typeof t=="function")&&typeof t.then=="function")}function Lt(t){if(!t)return!1;var e=t.closest?t.closest("[dir]"):null,i=e?e.getAttribute("dir"):"";if(!i&&l&&l.documentElement&&(i=l.documentElement.getAttribute("dir")||""),i)return String(i).toLowerCase()==="rtl";try{return!!(p.getComputedStyle&&p.getComputedStyle(t).direction==="rtl")}catch{return!1}}function y(t){return!!(t&&typeof t=="object"&&t.nodeType===1)}function kt(t,e){if(t==null||t==="")return e;var i=String(t).toLowerCase();return!(i==="false"||i==="0"||i==="no"||i==="off")}function I(){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 Zt(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 Ot(t,e,i){return Math.min(i,Math.max(e,t))}function N(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 ot={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"/>'},O={};Object.keys(ot).forEach(function(t){O[t]=ot[t]});var Ut="http://www.w3.org/2000/svg",Vt={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 It(t){if(typeof t!="string"||!t.trim())return"";var e;try{if(typeof p.DOMParser=="undefined")return"";e=new p.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(a){Array.prototype.slice.call(a.children||[]).forEach(function(n){var s=String(n.nodeName);if(s!==s.toLowerCase()&&(s=s.toLowerCase()),!Vt[s]){n.parentNode.removeChild(n);return}Array.prototype.slice.call(n.attributes||[]).forEach(function(o){var u=String(o.name).toLowerCase();u.indexOf("on")===0&&n.removeAttribute(o.name),(u==="href"||u==="xlink:href")&&!/^#/.test(o.value)&&n.removeAttribute(o.name),/url\s*\(\s*['"]?\s*(?:https?:|\/\/)/i.test(o.value)&&n.removeAttribute(o.name)}),r(n)})};return r(i),i.outerHTML}function j(t){var e=t;return/^\s*</.test(e)&&!/^\s*<svg/i.test(e)?e='<svg xmlns="'+Ut+'" 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=""),It(e)}function Nt(t,e){var i="",r="";if(typeof t=="string"&&t?(r=t,/^\s*</.test(t)?i=j(t)||j('<path d="M4 12h16"/>'):O[t]&&(i=j(O[t])||"")):t&&typeof t=="object"&&t.name&&(r=t.name,i=j(O[t.name]||"")),!i)return null;var a=l.createElement("span");e&&(a.className=e),a.setAttribute("data-zs-icon",r||"custom");try{a.innerHTML=i}catch{return null}var n=a.firstChild;return n&&(n.setAttribute("focusable","false"),n.setAttribute("aria-hidden","true"),n.setAttribute("width","18"),n.setAttribute("height","18")),a}var Pt={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 Jt(t){return Pt[t]||""}function lt(t,e){return typeof ZidanSelect!="undefined"&&(!t||typeof e!="string")?ZidanSelect:(t&&typeof e=="string"&&(O[String(t)]=e),typeof ZidanSelect!="undefined"?ZidanSelect:h)}function C(t,e,i,r,a){if(e&&e[i]!==void 0&&e[i]!==null)return e[i];if(t&&r&&t.getAttribute){var n=t.getAttribute("data-zidan-"+r);if(n!==null&&n!=="")return n}return a}function P(t,e,i,r,a){if(e&&e[i]!==void 0&&e[i]!==null)return!!e[i];if(t&&r&&t.getAttribute){var n=t.getAttribute("data-zidan-"+r);if(n!==null)return kt(n,a)}return a}function Rt(t,e,i,r,a){var n=C(t,e,i,r,a);if(n==null||n==="")return a;var s=parseFloat(n);return isFinite(s)?s:a}function Qt(t,e,i,r,a){var n=C(t,e,i,r,null);return n==null||n===""?a:Array.isArray(n)?n.slice():String(n).split(",").map(function(s){return s.trim()}).filter(Boolean)}var M={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 Dt(t,e){if(!t||!t.validity||t.validity.valid)return"";var i=t.validity,r=e||M,a=String(t.type||"").toLowerCase(),n="",s={min:t.getAttribute("min"),max:t.getAttribute("max"),step:t.getAttribute("step")};return i.valueMissing?n="required":i.typeMismatch?n=a==="email"?"email":a==="url"?"url":"generic":i.patternMismatch?n="pattern":i.rangeUnderflow?n="min":i.rangeOverflow?n="max":i.stepMismatch?n="step":i.tooShort?(n="minlength",s.minlength=t.getAttribute("minlength")):i.tooLong?(n="maxlength",s.maxlength=t.getAttribute("maxlength")):(i.badInput||i.customError)&&(n="badInput"),n?N(r[n]||M[n]||r.generic,s):t.validationMessage||r.generic}var dt=["valueMissing","typeMismatch","patternMismatch","rangeUnderflow","rangeOverflow","stepMismatch","tooShort","tooLong","badInput","fileMissing"];function Bt(t){var e=t&&t.validity;if(!e)return!1;for(var i=0;i<dt.length;i+=1)if(e[dt[i]])return!0;return!1}function et(t,e){for(var i=t;i&&i.nodeType===1;){for(var r=0;r<e.length;r+=1){var a=i.getAttribute(e[r]);if(a)return a}i=i.parentElement}return""}function L(t,e,i){var r=String(t||"").toLowerCase();return e.indexOf(r)===-1?i:r}function $t(t){if(Array.isArray(t))return t.slice();if(typeof t=="string"){var e=t.trim();if(e.charAt(0)==="[")try{var i=JSON.parse(e);if(Array.isArray(i))return i}catch{}else if(e.indexOf(",")!==-1)return e.split(",").map(function(r){return Number(r.trim())}).filter(function(r){return isFinite(r)})}return t}function qt(t,e){var i=e||{},r=i.theme||et(t,["data-zidan-theme","data-zs-theme"]);!r&&l&&(r=l.documentElement.getAttribute("data-zs-theme")||"");var a=i.framework||et(t,["data-zidan-framework","data-zs-framework"]);!a&&l&&(a=l.documentElement.getAttribute("data-zs-framework")||"");var n=i.layout||et(t,["data-zidan-layout","data-zs-layout"]);return{theme:L(r,W,"default"),framework:L(a,H,"none"),layout:n?String(n).toLowerCase():""}}function te(t,e){var i=null;function r(){var a=arguments;clearTimeout(i),i=setTimeout(function(){i=null,t.apply(null,a)},e)}return r.cancel=function(){clearTimeout(i),i=null},r}var Ht=["valid","invalid"],ut=["default","switch","card","button","minimal"],ft=["ios","material","square","labeled","icon"],ct=["stacked","inline","card","button","tile"],R=["dropzone","button","avatar","gallery","compact"],ht=["default","gradient","stepped","minimal"],ee=["always","active","never"],ie=["top","bottom"];function re(t,e){var i="";return Array.prototype.slice.call(t.childNodes).forEach(function(r){r===e||r.nodeType!==3||(i+=r.nodeValue)}),i.replace(/\s+/g," ").trim()}function ae(t,e){return Array.prototype.slice.call(t.childNodes).forEach(function(i){i.nodeType===3&&i.nodeValue.trim()&&e.appendChild(i)}),e}function f(t,e,i){if(!l)throw new Error("ZidanForm requires a DOM environment.");if(!y(t))throw new Error("ZidanForm: target element not found.");this.el=t,this.kind=i,this.opts=e||{},this.opts.messages=Object.assign({},M,this.opts.messages||{}),this.id=t.id||(t.id=Tt("zf")),this.root=null,this.touched=!1,this.validation=null,this.errorMessage=null,this.errorEl=null,this.pending=!1,this._asyncToken=0,this._asyncController=null,this.destroyed=!1,this._listeners=[],this._cleanups=[],this._describedByBefore=[],this.formEl=t.form||(t.closest?t.closest("form"):null);var r=qt(t,this.opts);this.theme=r.theme,this.framework=r.framework,this.layout=this.opts.layout||r.layout}f.prototype.on=function(t,e,i,r){return!t||!t.addEventListener?this:(t.addEventListener(e,i,r),this._listeners.push([t,e,i,r]),this)},f.prototype.emit=function(t,e){if(!this.root)return this;var i=e||{};i.instance=this,i.kind=this.kind;try{this.root.dispatchEvent(new CustomEvent(Ft+t,{detail:i,bubbles:!0}))}catch{}return this},f.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,callback:t})}},f.prototype._scope=function(t){var e=v("div","zs-field");return e.id=this.id+"-field",e.setAttribute("data-zs-kind",t),e.classList.add("zs-field--"+t),Lt(this.el)&&e.setAttribute("dir","rtl"),this._applyScope(e),this.root=e,e},f.prototype._applyScope=function(t){return t.setAttribute("data-zs-theme",this.theme),t.setAttribute("data-zs-framework",this.framework),this.layout&&t.setAttribute("data-zs-layout",this.layout),t},f.prototype.setTheme=function(t){return this.theme=L(t,W,this.theme),this.root&&this.root.setAttribute("data-zs-theme",this.theme),this},f.prototype.setFramework=function(t){return this.framework=L(t,H,this.framework),this.root&&this.root.setAttribute("data-zs-framework",this.framework),this},f.prototype.setLayout=function(t){return this.layout=L(t,J,this.layout||"stacked"),this.root&&this.root.setAttribute("data-zs-layout",this.layout),this},f.prototype.validationTargets=function(){return[this.el]},f.prototype._customError=function(){return""},f.prototype._messageFor=function(t){var e=Dt(t,this.opts.messages);return e||(t&&t.validationMessage?t.validationMessage:this.opts.messages.generic||M.generic)},f.prototype._nativeError=function(){for(var t=this.validationTargets(),e=0;e<t.length;e+=1){var i=t[e];if(Bt(i))return this._messageFor(i)}return""},f.prototype._asyncSignal=function(){return this._asyncController?this._asyncController.signal:void 0},f.prototype._asyncContext=function(){return{signal:this._asyncSignal(),field:this,instance:this}},f.prototype._setCustomValidity=function(){},f.prototype._abortAsync=function(){if(this._asyncToken+=1,this._asyncController){try{this._asyncController.abort()}catch{}this._asyncController=null}},f.prototype._evaluate=function(){this._abortAsync(),typeof AbortController!="undefined"&&(this._asyncController=new AbortController);var t=this._customError?this._customError():"";if(tt(t))return{pending:t};if(this._asyncController=null,t)return{error:typeof t=="string"?t:this.opts.messages.generic,custom:!0};var e=this._nativeError();return e?{error:e,custom:!1}:{}},f.prototype._applyValidity=function(t,e,i){return this._setCustomValidity(t&&i?t:""),t?(e?this.setError(t):this.setValidation("invalid",!0),this):(this.errorMessage&&this.setError(null),this.validation==="invalid"&&!this._presetValidation&&this.setValidation(null,!0),this)},f.prototype._setPending=function(t){return t=!!t,this.pending=t,this.root&&(this.root.classList.toggle("zs-field--pending",t),t?this.root.setAttribute("data-zs-validation","pending"):this.root.getAttribute("data-zs-validation")==="pending"&&this.root.removeAttribute("data-zs-validation")),this.validationTargets().forEach(function(e){!e||!e.setAttribute||(t?e.setAttribute("aria-busy","true"):e.removeAttribute("aria-busy"))},this),t?(this.errorMessage&&this.setError(null),this._setCustomValidity(this.opts.messages.pending||M.pending)):this._setCustomValidity(""),this},f.prototype._runAsync=function(t){var e=this;if(e.destroyed)return Promise.resolve(!1);var i=e._asyncToken;return e._setPending(!0),Promise.resolve(t).then(function(r){if(e.destroyed||i!==e._asyncToken)return!1;e._asyncController=null,e._setPending(!1);var a="";return r===!1?a=e.opts.messages.generic:typeof r=="string"?a=r:r instanceof Error&&(a=r.message||e.opts.messages.generic),e._applyValidity(a,e.touched||e.opts.alwaysValidate||!!a,!0),!a&&e.opts.showValidState&&e.setValidation("valid"),e.emit("async-validation",{valid:!a,message:a}),!a},function(r){if(e.destroyed||i!==e._asyncToken||r&&r.name==="AbortError")return!1;e._asyncController=null,e._setPending(!1);var a=r&&(r.message||r.error)||e.opts.messages.generic;return typeof a!="string"&&(a=e.opts.messages.generic),e._applyValidity(a,!0,!0),e.emit("async-validation",{valid:!1,message:a,error:r}),!1})},f.prototype.checkAsync=function(){var t=this._evaluate();return t.pending?this._runAsync(t.pending):Promise.resolve(!t.error)},f.prototype._trackDescribedBy=function(t){if(!(!t||!t.getAttribute)){for(var e=0;e<this._describedByBefore.length;e+=1)if(this._describedByBefore[e][0]===t)return;this._describedByBefore.push([t,t.getAttribute("aria-describedby")])}},f.prototype._addDescribedBy=function(t,e){if(!(!t||!t.getAttribute||!e)){this._trackDescribedBy(t);var i=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean);i.indexOf(e)===-1&&i.push(e),t.setAttribute("aria-describedby",i.join(" "))}},f.prototype._syncDescribedBy=function(){if(!(!this.el||!this.el.getAttribute)){var t=this.id+"-error",e=this.root&&this.root.querySelector?this.root.querySelector(".zs-field__hint[id]"):null,i=e?e.id:"",r=this.validationTargets();r.forEach(function(a){if(!(!a||!a.getAttribute)){this._trackDescribedBy(a);var n=(a.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean),s=n.filter(function(o){return o!==t&&o!==i});i&&s.push(i),this.errorMessage&&s.push(t),s.length?a.setAttribute("aria-describedby",s.join(" ")):a.removeAttribute("aria-describedby")}},this)}},f.prototype._renderError=function(){this.root&&(this.errorEl||(this.errorEl=v("p","zs-field__error",{id:this.id+"-error",role:"status","aria-live":"polite"}),this.root.appendChild(this.errorEl)),this.errorEl.textContent=this.errorMessage||"",this.errorEl.hidden=!this.errorMessage,this._syncDescribedBy())},f.prototype.setError=function(t){this.errorMessage=t||null,this.errorMessage?this.validation="invalid":this.validation==="invalid"&&(this.validation=null);var e=!!this.errorMessage||this.validation==="invalid";return this.root&&(this.root.classList.toggle("zs-field--invalid",e),this.root.classList.toggle("zs-field--valid",this.validation==="valid"&&!this.errorMessage),e||this.validation?this.root.setAttribute("data-zs-validation",e?"invalid":this.validation):this.root.removeAttribute("data-zs-validation")),this._renderError(),this.validationTargets().forEach(function(i){!i||!i.setAttribute||(e?i.setAttribute("aria-invalid","true"):this.validation==="valid"?i.setAttribute("aria-invalid","false"):i.removeAttribute("aria-invalid"))},this),this.emit("validation",{state:e?"invalid":this.validation,message:this.errorMessage}),this.call("onValidation",{state:e?"invalid":this.validation,message:this.errorMessage,instance:this}),this},f.prototype.clearError=function(){return this.setError(null)},f.prototype._bindValidity=function(){var t=this;this.validationTargets().forEach(function(i){t.on(i,"invalid",function(){t.touched=!0;var r=t._evaluate();if(r.pending){t._runAsync(r.pending);return}r.error?t.setError(r.error):t.setValidation("invalid")}),t.on(i,"blur",function(){t.touched=!0,t._presetValidation=!1,t._mirrorValidity()}),t.on(i,"input",function(){t._presetValidation=!1,t._mirrorValidity()}),t.on(i,"change",function(){t._presetValidation=!1,t._mirrorValidity()})}),this.on(this.formEl,"reset",function(){p.setTimeout(function(){t.destroyed||(t._abortAsync(),t.touched=!1,t.errorMessage=null,t._setPending(!1),t.errorEl&&(t.errorEl.textContent="",t.errorEl.hidden=!0),t.setValidation(null),t.update())},0)});var e=this.opts.validation||this.el.getAttribute("data-zidan-validation")||this.el.getAttribute("data-zs-validation");(e==="valid"||e==="invalid")&&this.setValidation(e),this._syncDescribedBy()},f.prototype._mirrorValidity=function(){var t=this._evaluate();return t.pending?(this._runAsync(t.pending),this):(this.pending&&this._setPending(!1),this._applyValidity(t.error||"",this.touched||this.opts.alwaysValidate,t.custom),this)},f.prototype.validate=function(){this.touched=!0;var t=this._evaluate();return t.pending?this._runAsync(t.pending):(this.pending&&this._setPending(!1),t.error?(this._applyValidity(t.error,!0,t.custom),!1):(this._applyValidity("",!0,!1),this.opts.showValidState&&this.setValidation("valid"),!0))},f.prototype.setValidation=function(t,e){this.validation=Ht.indexOf(t)===-1?null:t,e||(this._presetValidation=this.validation==="invalid");var i=this.validation==="invalid"||!!this.errorMessage;return this.root&&(this.root.classList.toggle("zs-field--invalid",i),this.root.classList.toggle("zs-field--valid",this.validation==="valid"&&!this.errorMessage),i?this.root.setAttribute("data-zs-validation","invalid"):this.validation?this.root.setAttribute("data-zs-validation",this.validation):this.root.removeAttribute("data-zs-validation")),this.validationTargets().forEach(function(r){!r||!r.setAttribute||(i?r.setAttribute("aria-invalid","true"):this.validation==="valid"?r.setAttribute("aria-invalid","false"):r.removeAttribute("aria-invalid"))},this),this.emit("validation",{state:i?"invalid":this.validation,message:this.errorMessage}),this.call("onValidation",{state:i?"invalid":this.validation,message:this.errorMessage,instance:this}),this},f.prototype.getValidation=function(){return this.validation},f.prototype.isPending=function(){return this.pending},f.prototype.getValue=function(){var t=this.el;return t?this.kind==="file"?this.getFiles?this.getFiles():Array.prototype.slice.call(t.files||[]):t.type==="checkbox"?!!t.checked:t.multiple&&t.options?Array.prototype.filter.call(t.options,function(e){return e.selected}).map(function(e){return e.value}):t.value:null},f.prototype.setValue=function(t){var e=this.el;if(!e)return this;if(this.kind==="file"){var i=t==null?[]:Array.isArray(t)?t:[t];return i.length?(this.addFiles&&this.addFiles(i),this):this.clear?this.clear():this}if(e.type==="checkbox")return this.setChecked?this.setChecked(!!t):(e.checked=!!t,e.dispatchEvent(new Event("change",{bubbles:!0})),this.update());if(e.multiple&&e.options){var r=(Array.isArray(t)?t:[t]).map(String);Array.prototype.forEach.call(e.options,function(a){a.selected=r.indexOf(a.value)!==-1})}else e.value=t==null?"":String(t);return e.dispatchEvent(new Event("change",{bubbles:!0})),this.update()},f.prototype.update=function(){return this._sync&&this._sync(),this._mirrorValidity(),this},f.prototype.refresh=function(){return this.update()},f.prototype.destroy=function(){return this.destroyed?this:(this.destroyed=!0,this._abortAsync(),this._listeners.forEach(function(t){t[0].removeEventListener(t[1],t[2],t[3])}),this._listeners.length=0,this._teardown&&this._teardown(),this._cleanups.forEach(function(t){t()}),this._cleanups.length=0,this.emit("destroy",{}),this.root&&this.root!==this.el&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this._describedByBefore.forEach(function(t){var e=t[0];!e||!e.getAttribute||(t[1]===null||t[1]===void 0?e.removeAttribute("aria-describedby"):e.setAttribute("aria-describedby",t[1]))}),this._describedByBefore=[],this.el.__zidanField===this&&delete this.el.__zidanField,h._unregister(this),this)};function G(t){return!t&&t!==0?"":t<1024?t+" B":t<1024*1024?(t/1024).toFixed(t<10240?1:0)+" KB":(t/(1024*1024)).toFixed(1)+" MB"}function pt(t){var e=/\.([a-z0-9]+)$/i.exec(String(t||""));return e?"."+e[1].toLowerCase():""}function jt(t,e){return e?String(e).split(",").some(function(i){var r=i.trim().toLowerCase();return r?r.indexOf(".")===0?pt(t.name)===r:r.indexOf("/*")!==-1?String(t.type).toLowerCase().indexOf(r.split("/")[0]+"/")===0:String(t.type).toLowerCase()===r:!1}):!0}function w(t){return[t.name,t.size,t.lastModified||0,t.type||""].join("|")}function Gt(t,e){return t&&typeof t=="string"?t:t&&t.message?t.message:t&&t.status?"Upload failed (HTTP "+t.status+").":e||"Upload failed."}function d(t,e){if(!(this instanceof d))return new d(t,e);if(!/^file$/i.test(t.type))throw new Error('ZidanFileUpload: expected an <input type="file">.');f.call(this,t,e,"file");var i=this,r=t,a=this.opts,n=L(C(r,a,"fileVariant","file-variant",C(r,a,"variant","variant","dropzone")),R,"dropzone"),s=r.parentNode,o=this._scope("file");o.setAttribute("data-zs-file-variant",n),s.insertBefore(o,r);var u=v("label","zs-file-drop zs-file-drop--"+n);u.setAttribute("for",this.id);var _=v("span","zs-file-avatar",{hidden:!0}),E=l.createElement("img");E.alt="",_.appendChild(E);var z=v("span","zs-file-icon",{"aria-hidden":"true"}),c=C(r,a,"uploadIcon","upload-icon",C(r,a,"icon","icon","upload")),D=Nt(c,"zs-file-icon-svg");D&&z.appendChild(D);var X=a.title||r.getAttribute("data-zidan-title")||(n==="avatar"?"Upload an image":n==="gallery"?"Add images":"Choose a file"),S=v("span","zs-file-drop-title",null,X),b=v("span","zs-file-drop-hint",null,a.dropHint||r.getAttribute("data-zidan-drop-hint")||(r.multiple?"or drop files here \u2014 multiple allowed":"or drop it here"));u.appendChild(_),u.appendChild(z),u.appendChild(S),u.appendChild(b),u.appendChild(r),o.appendChild(u);var k=v("ul","zs-file-list");o.appendChild(k);var x=v("div","zs-file-meta-row"),B=v("span","zs-file-status",{role:"status","aria-live":"polite"}),F=v("button","zs-file-clear",{type:"button"});F.textContent=a.clearLabel||"Clear all",F.hidden=!0,x.appendChild(B),x.appendChild(F),o.appendChild(x);var q=a.accept||r.accept;q&&(b.textContent=b.textContent+" \xB7 "+q),this.variant=n,this.drop=u,this.list=k,this.status=B,this.clearBtn=F,this.titleEl=S,this.hintEl=b,this._fallbackTitle=X,this.avatarEl=_,this.avatarImg=E,this.uploadHandler=typeof a.upload=="function"?a.upload:typeof a.uploadHandler=="function"?a.uploadHandler:null,this.uploadUrl=C(r,a,"uploadUrl","upload-url",""),this.uploadField=C(r,a,"uploadField","upload-field","file"),this.withCredentials=P(r,a,"withCredentials","with-credentials",!1),this.uploadHeaders=a.uploadHeaders||a.headers||null,this.simulateUpload=P(r,a,"simulateUpload","simulate-upload",!1),this.simulateDuration=Math.max(120,Rt(r,a,"simulateDuration","simulate-duration",900)),this.autoUpload=P(r,a,"autoUpload","auto-upload",!0),this.showFileMeta=P(r,a,"showFileMeta","show-file-meta",!0),this.showPreview=P(r,a,"showPreview","preview",!0),this.hasUploader=!!(this.uploadHandler||this.uploadUrl||this.simulateUpload),o.setAttribute("data-zs-upload",this.hasUploader?"true":"false"),this._uploads=Object.create(null),this._active=Object.create(null),this._urls=[],this._renderQueued=!1,this.fileError="",this._restoreInput=function(){var m=o.parentNode||s;m.insertBefore(r,o.parentNode?o:null),r.classList.remove("zs-native-input","zs-file-input")},st(r,"zs-native-input"),st(r,"zs-file-input"),this.on(r,"change",function(){var m=i._validate();i._render(),i.emit("change",{files:i.getFiles()}),i.call("onChange",{files:i.getFiles(),instance:i}),m&&i.autoUpload&&i.hasUploader&&i.uploadAll()});var Z=0;["dragenter","dragover"].forEach(function(m){i.on(u,m,function(A){A.preventDefault(),m==="dragenter"&&(Z+=1),u.classList.add("zs-file-drop--over")})}),i.on(u,"dragleave",function(){Z=Math.max(0,Z-1),Z||u.classList.remove("zs-file-drop--over")}),i.on(u,"drop",function(m){if(m.preventDefault(),Z=0,u.classList.remove("zs-file-drop--over"),!(!m.dataTransfer||!m.dataTransfer.files||!m.dataTransfer.files.length)){var A=Array.prototype.slice.call(m.dataTransfer.files);r.multiple||(A=A.slice(0,1)),i.addFiles(A)}}),i.on(F,"click",function(){i.clear()}),i.on(k,"click",function(m){var A=m.target&&m.target.closest?m.target.closest("button"):null;if(!(!A||!k.contains(A))){var Et=A.closest(".zs-file-item"),St=Et?parseInt(Et.getAttribute("data-zs-file-index"),10):-1,K=St>=0?i.getFiles()[St]:null;K&&(m.preventDefault(),m.stopPropagation(),A.classList.contains("zs-file-cancel")?i.cancelUpload(K):A.classList.contains("zs-file-retry")?i.retryUpload(K):A.classList.contains("zs-file-remove")&&i.removeFile(K))}}),this._bindValidity(),this.on(this.formEl,"reset",function(){p.setTimeout(function(){i.destroyed||(i.cancelAll(),i._uploads=Object.create(null),i.fileError="",r.setCustomValidity&&r.setCustomValidity(""),i._render())},0)}),r.__zidanField=this,this._render(),this.emit("init",{}),h._register(this)}d.prototype=Object.create(f.prototype),d.prototype.constructor=d,d.prototype.getFiles=function(){return this.el.files?Array.prototype.slice.call(this.el.files):[]},d.prototype.getUploadState=function(){var t=this;return this.getFiles().map(function(e){var i=t._stateFor(e,!1)||{status:"idle",progress:0,error:"",result:null};return{file:e,name:e.name,size:e.size,status:i.status,progress:i.progress,error:i.error,result:i.result}})},d.prototype._stateFor=function(t,e){var i=w(t),r=this._uploads[i];return!r&&e&&(r=this._uploads[i]={status:"idle",progress:0,error:"",result:null}),r},d.prototype._setFiles=function(t){try{var e=typeof DataTransfer!="undefined"?DataTransfer:p.DataTransfer;if(!e)return!1;var i=new e;return t.forEach(function(r){i.items.add(r)}),this.el.files=i.files,!0}catch{return!1}},d.prototype._applyFiles=function(t,e){if(!this._setFiles(t))return this.emit("error",{error:new Error("This browser cannot assign files programmatically."),action:"setFiles"}),this;if(e)try{this.el.dispatchEvent(new Event("change",{bubbles:!0}))}catch{}else this._validate(),this._render();return this},d.prototype.addFiles=function(t){var e=t&&t.length!==void 0?Array.prototype.slice.call(t):$(t);if(!e.length)return this;var i=this.el.multiple?this.getFiles():[],r=Object.create(null),a=i.concat(e).filter(function(n){var s=w(n);return r[s]?!1:(r[s]=!0,!0)});if(this.el.multiple||(a=a.slice(0,1)),!this._setFiles(a))return this.emit("error",{error:new Error("This browser cannot assign files programmatically."),action:"addFiles"}),this;try{this.el.dispatchEvent(new Event("change",{bubbles:!0}))}catch{}return this},d.prototype.replaceFiles=function(t){return this._applyFiles(t&&t.length!==void 0?Array.prototype.slice.call(t):$(t),!0)},d.prototype.removeFile=function(t){var e=this.getFiles(),i=typeof t=="number"?t:e.indexOf(t);if(i===-1||!e[i])return this;var r=e[i];this.cancelUpload(r),delete this._uploads[w(r)];var a=e.slice();return a.splice(i,1),this._setFiles(a),this._validate(),this._render(),this.emit("change",{files:a}),this.emit("remove",{file:r,index:i}),this.call("onChange",{files:a,instance:this}),this.call("onRemove",{file:r,index:i,instance:this}),this},d.prototype.clear=function(){return this.cancelAll(),this._uploads=Object.create(null),this.fileError="",this.el.value="",this.el.setCustomValidity&&this.el.setCustomValidity(""),this._validate(),this._render(),this.emit("change",{files:[]}),this.emit("clear",{}),this.call("onChange",{files:[],instance:this}),this},d.prototype._limits=function(){var t=this.el,e=this.opts,i=parseInt(e.maxFiles||t.getAttribute("data-zidan-max-files"),10),r=parseInt(e.maxSize||t.getAttribute("data-zidan-max-size"),10);if(!(r>0)){var a=e.maxSizeMB;if((a==null||a==="")&&(a=t.getAttribute("data-zidan-max-size-mb")),a!=null&&a!==""){var n=parseFloat(a);n>0&&(r=Math.round(n*1024*1024))}}return{maxFiles:i>0?i:0,maxSize:r>0?r:0,accept:e.accept||t.accept||""}},d.prototype._setCustomValidity=function(t){this.el&&this.el.setCustomValidity&&this.el.setCustomValidity(t||"")},d.prototype._customError=function(){if(this.fileError)return this.fileError;if(typeof this.opts.validate=="function"){var t=this.opts.validate(this.getFiles(),this,this._asyncContext());if(t===!1)return this.opts.messages.generic;if(typeof t=="string"&&t||tt(t))return t}return""},d.prototype._validate=function(){var t=this.el,e=this.opts.messages,i=this._limits(),r=this.getFiles(),a="";if(i.maxFiles&&r.length>i.maxFiles&&(a=N(e.fileCount,{max:i.maxFiles}),r=r.slice(0,i.maxFiles),this._setFiles(r)),!a&&i.maxSize){for(var n=0;n<r.length;n+=1)if(r[n].size>i.maxSize){a=N(e.fileSize,{name:r[n].name,size:G(r[n].size),limit:G(i.maxSize)});break}}if(!a&&i.accept){for(var s=0;s<r.length;s+=1)if(!jt(r[s],i.accept)){a=N(e.fileType,{name:r[s].name,accept:i.accept});break}}this.fileError=a,t.setCustomValidity&&t.setCustomValidity(this.pending?e.pending||M.pending:a||"");var o=a||this._nativeError();return o?this.setError(o):this.errorMessage&&this.setError(null),this.root.classList.toggle("zs-field--filled",r.length>0),this.drop.classList.toggle("zs-file-drop--invalid",!!o),this._renderStatus(),!o},d.prototype._sync=function(){this._render()},d.prototype._queueRender=function(){var t=this;if(!(this._renderQueued||this.destroyed)){this._renderQueued=!0;var e=function(){t._renderQueued=!1,t.destroyed||t._render()};p.requestAnimationFrame?p.requestAnimationFrame(e):p.setTimeout(e,32)}},d.prototype._renderStatus=function(){var t=this.getFiles(),e=this.getUploadState(),i=t.reduce(function(u,_){return u+_.size},0),r=e.filter(function(u){return u.status==="uploading"}),a=e.filter(function(u){return u.status==="error"}),n=e.filter(function(u){return u.status==="done"}),s="";if(this.fileError)s=this.fileError;else if(t.length)if(s=t.length+(t.length===1?" file selected":" files selected")+" \xB7 "+G(i),r.length){var o=Math.round(r.reduce(function(u,_){return u+_.progress},0)/r.length);s+=" \xB7 Uploading "+o+"%"}else a.length?s+=" \xB7 "+a.length+" failed":n.length===t.length&&this.hasUploader&&(s+=" \xB7 Uploaded");this.status.textContent=s,this.status.classList.toggle("zs-file-status--error",!!this.fileError),this.status.classList.toggle("zs-file-status--success",!this.fileError&&t.length>0&&n.length===t.length&&this.hasUploader)},d.prototype._render=function(){var t=this,e=this.getFiles(),i=this.opts;this.list.textContent="",this._revokeLater(this._urls),this._urls=[],this.list.hidden=e.length===0,this.clearBtn.hidden=e.length===0,this.root.classList.toggle("zs-field--filled",e.length>0),this.drop.classList.toggle("zs-file-drop--has-files",e.length>0);var r=this.showPreview?e.filter(function(n){return/^image\//.test(n.type)})[0]:null;if(r){var a=URL.createObjectURL(r);this._urls.push(a),this.avatarImg.src=a,this.avatarEl.hidden=!1,this.drop.classList.add("zs-file-drop--has-preview"),this.titleEl.textContent=i.replaceTitle||"Change image"}else this.avatarImg.removeAttribute("src"),this.avatarEl.hidden=!0,this.drop.classList.remove("zs-file-drop--has-preview"),this.titleEl.textContent=this._fallbackTitle;e.forEach(function(n,s){var o=t._stateFor(n,!1)||{status:"idle",progress:0,error:"",result:null},u=v("li","zs-file-item");u.setAttribute("data-zs-upload-state",o.status),u.setAttribute("data-zs-file-index",String(s));var _=v("span","zs-file-thumb");if(/^image\//.test(n.type)){var E=URL.createObjectURL(n);t._urls.push(E);var z=l.createElement("img");z.src=E,z.alt="",_.appendChild(z)}else _.textContent=(pt(n.name)||"file").replace(".","").slice(0,4).toUpperCase();var c=v("span","zs-file-info"),D=v("span","zs-file-name",null,n.name);if(c.appendChild(D),t.showFileMeta){var X=G(n.size)+(n.type?" \xB7 "+n.type:"");c.appendChild(v("span","zs-file-size",null,X))}if(t.hasUploader){var S=v("span","zs-file-upload-state");if(o.status==="uploading"){S.textContent=N(i.progressTemplate||"Uploading {percent}%",{percent:o.progress});var b=v("span","zs-file-progress");b.setAttribute("role","progressbar"),b.setAttribute("aria-valuemin","0"),b.setAttribute("aria-valuemax","100"),b.setAttribute("aria-valuenow",String(o.progress)),b.setAttribute("aria-label","Upload progress for "+n.name);var k=v("span","zs-file-progress-bar");k.style.width=o.progress+"%",b.appendChild(k),S.appendChild(b)}else o.status==="done"?S.textContent=i.uploadedLabel||"Uploaded":o.status==="error"?S.textContent=(i.failedLabel||"Upload failed")+(o.error?" \u2014 "+o.error:""):o.status==="canceled"&&(S.textContent=i.canceledLabel||"Upload canceled");S.textContent&&c.appendChild(S)}var x=v("span","zs-file-actions");if(o.status==="uploading"){var B=v("button","zs-file-cancel",{type:"button","aria-label":"Cancel upload of "+n.name});B.textContent=i.cancelLabel||"Cancel",x.appendChild(B)}else if(o.status==="error"||o.status==="canceled"){var F=v("button","zs-file-retry",{type:"button","aria-label":"Retry upload of "+n.name});F.textContent=i.retryLabel||"Retry",x.appendChild(F)}var q=v("button","zs-file-remove",{type:"button","aria-label":"Remove "+n.name});if(q.textContent="\xD7",x.appendChild(q),u.appendChild(_),u.appendChild(c),u.appendChild(x),t.list.appendChild(u),typeof i.renderFile=="function")try{i.renderFile(u,{file:n,index:s,state:o,field:t})}catch(Z){t.emit("error",{error:Z,callback:"renderFile"})}}),this._renderStatus()},d.prototype.setVariant=function(t){var e=L(t,R,this.variant);return e===this.variant?this:(this.variant=e,R.forEach(function(i){this.drop.classList.remove("zs-file-drop--"+i)},this),this.drop.classList.add("zs-file-drop--"+e),this.root.setAttribute("data-zs-file-variant",e),this._render(),this)},d.prototype.setUploader=function(t){return typeof t=="function"?(this.uploadHandler=t,this.uploadUrl=""):(this.uploadHandler=null,this.uploadUrl=t?String(t):""),this.hasUploader=!!(this.uploadHandler||this.uploadUrl||this.simulateUpload),this.root.setAttribute("data-zs-upload",this.hasUploader?"true":"false"),this._render(),this},d.prototype._formData=function(t){var e=new FormData;e.append(this.uploadField,t,t.name);var i=typeof this.opts.uploadData=="function"?this.opts.uploadData(t,this):this.opts.uploadData;return i&&typeof i=="object"&&Object.keys(i).forEach(function(r){var a=i[r];a!=null&&e.append(r,a)}),e},d.prototype.uploadAll=function(){var t=this;if(!this.hasUploader)return this;if(!this._validate())return this;var e=this.validate();return tt(e)?e.then(function(i){return i&&!t.destroyed&&t.getFiles().forEach(function(r){t.uploadFile(r)}),i}):e?(this.getFiles().forEach(function(i){t.uploadFile(i)}),this):this},d.prototype.uploadFile=function(t){var e=this,i=w(t),r=this._stateFor(t,!0);if(r.status==="uploading"||r.status==="done")return this;if(r.status="uploading",r.progress=0,r.error="",r.result=null,this._queueRender(),this.emit("upload-start",{file:t,name:t.name,size:t.size}),this.call("onUploadStart",{file:t,name:t.name,size:t.size,instance:this}),this.uploadHandler){var a=typeof AbortController!="undefined"?new AbortController:null;this._active[i]={type:"handler",abort:function(){a&&a.abort()}};var n={file:t,field:this,formData:this._formData(t),signal:a?a.signal:null,onProgress:function(c){e._setProgress(t,c)},complete:function(c){e._finish(t,c)},fail:function(c){e._fail(t,c)}},s;try{s=this.uploadHandler(t,n)}catch(c){return this._fail(t,c),this}return s&&typeof s.then=="function"?s.then(function(c){e._finish(t,c)},function(c){c&&(c.name==="AbortError"||c.aborted)?e._canceledUpload(t):e._fail(t,c)}):s!==void 0&&this._finish(t,s),this}if(this.uploadUrl){var o=new p.XMLHttpRequest;this._active[i]={type:"xhr",abort:function(){try{o.abort()}catch{}}},o.open("POST",this.uploadUrl,!0),this.withCredentials&&(o.withCredentials=!0);var u=typeof this.uploadHeaders=="function"?this.uploadHeaders(t,this):this.uploadHeaders;return u&&typeof u=="object"&&Object.keys(u).forEach(function(c){o.setRequestHeader(c,u[c])}),o.upload.onprogress=function(c){c.lengthComputable&&e._setProgress(t,Math.min(99,Math.round(c.loaded/c.total*100)))},o.onload=function(){if(o.status>=200&&o.status<300){var c=o.responseText;try{c=JSON.parse(c)}catch{}e._finish(t,c)}else e._fail(t,{status:o.status,message:"Upload failed (HTTP "+o.status+")."})},o.onerror=function(){e._fail(t,{message:"Network error while uploading."})},o.onabort=function(){e._canceledUpload(t)},o.send(this._formData(t)),this}if(this.simulateUpload){var _=Date.now(),E=null,z=function(){if(!(!e._uploads[i]||r.status!=="uploading")){var c=Math.min(99,Math.round((Date.now()-_)/e.simulateDuration*100));e._setProgress(t,c),c>=99?(delete e._active[i],e._finish(t,{simulated:!0})):E=p.setTimeout(z,40)}};return this._active[i]={type:"simulation",abort:function(){E&&p.clearTimeout(E)}},E=p.setTimeout(z,40),this}return r.status="idle",this._queueRender(),this},d.prototype._setProgress=function(t,e){var i=this._stateFor(t,!1);if(!(!i||i.status!=="uploading")){var r=Ot(Math.round(Number(e)||0),0,99);r!==i.progress&&(i.progress=r,this._queueRender(),this.emit("upload-progress",{file:t,progress:r,name:t.name}),this.call("onUploadProgress",{file:t,progress:r,name:t.name,instance:this}))}},d.prototype._finish=function(t,e){var i=this._stateFor(t,!1);!i||i.status!=="uploading"||(delete this._active[w(t)],i.status="done",i.progress=100,i.result=e===void 0?null:e,this._queueRender(),this.emit("upload-success",{file:t,name:t.name,result:i.result}),this.call("onUploadSuccess",{file:t,name:t.name,result:i.result,instance:this}),this.call("onUpload",{file:t,name:t.name,result:i.result,instance:this}))},d.prototype._fail=function(t,e){var i=this._stateFor(t,!1);!i||i.status!=="uploading"||(delete this._active[w(t)],i.status="error",i.error=Gt(e,this.opts.messages.upload||"Upload failed."),this._queueRender(),this.emit("upload-error",{file:t,name:t.name,error:e,message:i.error}),this.call("onUploadError",{file:t,name:t.name,error:e,message:i.error,instance:this}))},d.prototype._canceledUpload=function(t){var e=this._stateFor(t,!1);!e||e.status!=="uploading"||(delete this._active[w(t)],e.status="canceled",e.progress=0,e.error="",this._queueRender(),this.emit("upload-cancel",{file:t,name:t.name}),this.call("onUploadCancel",{file:t,name:t.name,instance:this}))},d.prototype.cancelUpload=function(t){var e=w(t),i=this._active[e];if(i){try{i.abort()}catch{}delete this._active[e]}return this._canceledUpload(t),this},d.prototype.cancelAll=function(){var t=this;return Object.keys(this._active).forEach(function(e){try{t._active[e].abort()}catch{}delete t._active[e]}),this},d.prototype.retryUpload=function(t){var e=this._stateFor(t,!1);return e?(e.status="idle",e.progress=0,e.error="",this.uploadFile(t)):this},d.prototype._revokeLater=function(t){!t||!t.length||p.setTimeout(function(){t.forEach(function(e){try{URL.revokeObjectURL(e)}catch{}})},800)},d.prototype._teardown=function(){this.cancelAll(),this._uploads=Object.create(null),this._revokeLater(this._urls),this._urls=[],this._restoreInput&&this._restoreInput()};function U(t){if(!y(t))return null;var e=String(t.getAttribute("data-zidan")||"").toLowerCase();if(Ct.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(Mt(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 Y(t,e,i){var r=I(Zt(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 d!="undefined"?new d(t,r):null;case"input":case"textarea":return typeof ZidanTextField!="undefined"?new ZidanTextField(t,r):null;default:return null}}function vt(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(l.querySelectorAll(t)):y(t)?i=[t]:t&&typeof t.length=="number"&&(i=Array.prototype.slice.call(t));var r=[];return i.forEach(function(a){if(!a.__zidanField){var n=U(a)||_t(a);if(n){if(n==="radio"||n==="radio-group"){if(/^INPUT$/i.test(a.tagName)&&(a=a.closest?a.closest("fieldset, [data-zidan-radio-group]"):null,!a))return;n="radio-group"}var s=Y(a,n,e||{});s&&r.push(s)}}}),r.length===1?r[0]:r}function mt(t,e){var i=[];return t.forEach(function(r){if(!(!y(r)||r.__zidanField)){var a=U(r);if(a){if(a==="radio"||a==="radio-group"){if(/^INPUT$/i.test(r.tagName)&&(r=r.closest?r.closest("fieldset, [data-zidan-radio-group]"):null,!r))return;a="radio-group"}var n=Y(r,a,e||{});n&&i.push(n)}}}),i}function V(t,e){var i=t||l;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(at));return y(i)&&i.matches&&i.matches(at)&&r.unshift(i),mt(r,e)}var h={version:T,__zidanFormGuard:T,themes:W,frameworks:H.slice(),fieldLayouts:J,fields:[],_register:function(t){h.fields.indexOf(t)===-1&&h.fields.push(t)},_unregister:function(t){var e=h.fields.indexOf(t);e!==-1&&h.fields.splice(e,1)},get:function(t){var e=typeof t=="string"?l.querySelector(t):t;return y(e)&&e.__zidanField||null},init:function(t,e){return V(t||l,e||{})},field:vt,refresh:function(t){return V(t||l,{}),h.fields.slice().forEach(function(e){e.update()}),h.fields.slice()},destroyAll:function(){return h.fields.slice().forEach(function(t){t.destroy()}),h.fields=[],typeof ZidanSelect!="undefined"&&ZidanSelect.destroyAll&&ZidanSelect.destroyAll(),h},observe:function(t,e){var i=t||l.body;if(!i||!p.MutationObserver)return null;var r=new p.MutationObserver(function(a){a.forEach(function(n){Array.prototype.slice.call(n.addedNodes).forEach(function(s){y(s)&&(U(s)&&Y(s,U(s)==="radio"?"radio-group":U(s),e||{}),s.querySelectorAll&&V(s,e||{}))})}),h.fields.slice().forEach(function(n){n.el.isConnected||n.destroy()}),typeof ZidanSelect!="undefined"&&ZidanSelect.instances.slice().forEach(function(n){n.el.isConnected||n.destroy()})});return r.observe(i,{childList:!0,subtree:!0}),r}};h.api=null,h.registerIcon=lt,h.icons=O,typeof PHONE_COUNTRIES!="undefined"&&(h.phoneCountries=PHONE_COUNTRIES,h.phoneFormats=PHONE_FORMATS.slice(),h.formatPhone=formatPhone,h.detectPhoneCountry=detectPhoneCountry),h.messages=M,h.variants={},typeof ut!="undefined"&&(h.variants.checkbox=ut.slice()),typeof ft!="undefined"&&(h.variants.switch=ft.slice()),typeof ct!="undefined"&&(h.variants.radio=ct.slice()),typeof R!="undefined"&&(h.variants.file=R.slice()),typeof ht!="undefined"&&(h.variants.range=ht.slice()),typeof STEPPER_MODES!="undefined"&&(h.stepperModes=STEPPER_MODES.slice()),h.fieldLayouts=J.slice(),typeof ZidanSelect!="undefined"&&(ZidanSelect.version=T,ZidanSelect.__zidanSelectGuard=T,ZidanSelect.layouts=zt.slice(),ZidanSelect.frameworks=H.slice(),ZidanSelect.scrollbars=xt.slice(),ZidanSelect.defaults=DEFAULTS,ZidanSelect.cacheLimit=50,ZidanSelect.get=function(t){var e=typeof t=="string"?l.querySelector(t):t;return y(e)&&e.__zidanSelect||null},ZidanSelect.instances=[],ZidanSelect.destroyAll=function(){ZidanSelect.instances.slice().forEach(function(t){t.destroy()}),ZidanSelect.instances=[]});function Yt(t,e){var i=[];typeof t=="string"?i=Array.prototype.slice.call(l.querySelectorAll(t)):t&&typeof t.length=="number"&&!y(t)&&t!==p?i=Array.prototype.slice.call(t):y(t)&&(i=[t]);var r=i.map(function(a){var n=new ZidanSelect(a,e||{});return ZidanSelect.instances.push(n),n});return r.length===1?r[0]:r}function it(t,e){return t.filter(function(i){return y(i)&&!i.__zidanSelect}).map(function(i){return ZidanSelect.instances.push(new ZidanSelect(i,e||{})),i.__zidanSelect})}function yt(t,e){var i=t||l;if(!i||!i.querySelectorAll)return[];var r=Array.prototype.slice.call(i.querySelectorAll(Q));return y(i)&&i.matches&&i.matches(Q)&&r.unshift(i),it(r,e)}function rt(t,e){$(t).forEach(function(i){i&&(typeof i=="string"?e(i,null):i.selector&&e(String(i.selector),i.options||null))})}function gt(t,e){rt(t,function(i,r){it(Array.prototype.slice.call(l.querySelectorAll(i)),I(e,r))})}function Xt(t,e){rt(t,function(i,r){var a=I(e,r);Array.prototype.slice.call(l.querySelectorAll(i)).forEach(function(n){if(!(!y(n)||n.__zidanField)){var s=U(n)||_t(n);s&&(s==="radio"&&(s="radio-group"),Y(n,s,a))}})})}function _t(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 Kt(t,e){if(typeof ZidanSelect=="undefined")return[];var i=Q+", select",r=Array.prototype.slice.call(t.querySelectorAll(i));return y(t)&&t.matches&&t.matches(i)&&r.unshift(t),it(r,e)}function bt(t,e,i){y(t)&&(Kt(t,e),typeof d!="undefined"&&mt(Array.prototype.slice.call(t.querySelectorAll('input[type="file"]')),i),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined")&&V(t,i))}function Wt(t,e,i){Array.prototype.slice.call(l.querySelectorAll(wt)).forEach(function(r){bt(r,e,i)}),rt(t,function(r,a){Array.prototype.slice.call(l.querySelectorAll(r)).forEach(function(n){bt(n,I(e,a),I(i,a))})})}function At(){if(l){var t=p.ZIDAN_FORM_CONFIG||p.ZIDAN_SELECT_CONFIG||{};if(t.autoInit!==!1&&!(p.ZidanSelect&&p.ZidanSelect.autoInit===!1)&&l.documentElement.getAttribute("data-zidan-auto-init")!=="false"){var e=typeof ZidanSelect!="undefined",i=typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined",r=t.options||{},a=t.fieldOptions||t.fields||{};e&&(t.selector?gt(t.selector,r):gt(t.targets||t.selectors,r)),i&&Xt(t.fieldTargets,a),Wt(t.formTargets,r,a),e&&!t.selector&&yt(l,r),i&&V(l,a)}}}l&&(l.readyState==="loading"?l.addEventListener("DOMContentLoaded",At):setTimeout(At,0));var g={ZidanForm:h,registerIcon:lt};return typeof ZidanSelect!="undefined"&&(g.ZidanSelect=ZidanSelect,g.zidanSelect=Yt,g.initZidanSelects=yt),(typeof ZidanCheckbox!="undefined"||typeof ZidanRadioGroup!="undefined"||typeof d!="undefined"||typeof ZidanTextField!="undefined")&&(g.zidanField=vt,g.initZidanForms=V),typeof ZidanCheckbox!="undefined"&&(g.ZidanCheckbox=ZidanCheckbox),typeof ZidanRadioGroup!="undefined"&&(g.ZidanRadioGroup=ZidanRadioGroup),typeof d!="undefined"&&(g.ZidanFileUpload=d),typeof ZidanTextField!="undefined"&&(g.ZidanTextField=ZidanTextField),typeof formatPhone=="function"&&(g.formatPhone=formatPhone,g.detectPhoneCountry=detectPhoneCountry),h.api=g,g});
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.3.1 — plugin-core.css
2
+ * ZidanForm v2.4.1 — plugin-core.css
3
3
  * Structure and mechanics only: layout, positioning, visibility, focus
4
4
  * plumbing and accessible native-input handling. No colours, borders colours,
5
5
  * shadows or decorative skin — load plugin-theme.css (or your own theme) for
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.3.1 — plugin-core.css
2
+ * ZidanForm v2.4.1 — plugin-core.css
3
3
  * Structure and mechanics only: layout, positioning, visibility, focus
4
4
  * plumbing and accessible native-input handling. No colours, borders colours,
5
5
  * shadows or decorative skin — load plugin-theme.css (or your own theme) for
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.3.1 — plugin-theme.css
2
+ * ZidanForm v2.4.1 — plugin-theme.css
3
3
  * Design tokens, paint, state colours, preset themes (default, modern,
4
4
  * minimal, dark, glass), the five select layouts and framework adapters
5
5
  * (bootstrap, tailwind, bulma, foundation).
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm v2.3.1 — plugin-theme.css
2
+ * ZidanForm v2.4.1 — plugin-theme.css
3
3
  * Design tokens, paint, state colours, preset themes (default, modern,
4
4
  * minimal, dark, glass), the five select layouts and framework adapters
5
5
  * (bootstrap, tailwind, bulma, foundation).
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.3.1 — plugin-select-core.css
2
+ * ZidanForm Select-only v2.4.1 — plugin-select-core.css
3
3
  * Structure for the select / combobox / tags control only.
4
4
  * Pairs with zidan-select.js and plugin-select-theme.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.3.1 — plugin-select-core.css
2
+ * ZidanForm Select-only v2.4.1 — plugin-select-core.css
3
3
  * Structure for the select / combobox / tags control only.
4
4
  * Pairs with zidan-select.js and plugin-select-theme.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.3.1 — plugin-select-theme.css
2
+ * ZidanForm Select-only v2.4.1 — plugin-select-theme.css
3
3
  * Tokens, 5 preset themes, select layouts, scrollbars and framework adapters.
4
4
  * Pairs with zidan-select.js and plugin-select-core.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.3.1 — plugin-select-theme.css
2
+ * ZidanForm Select-only v2.4.1 — plugin-select-theme.css
3
3
  * Tokens, 5 preset themes, select layouts, scrollbars and framework adapters.
4
4
  * Pairs with zidan-select.js and plugin-select-core.css.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ZidanForm Select-only v2.3.1 — type definitions.
2
+ * ZidanForm Select-only v2.4.1 — type definitions.
3
3
  * https://github.com/akhtar1985/zidan-select
4
4
  */
5
5
  export {
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * ZidanForm Select-only v2.3.1
2
+ * ZidanForm Select-only v2.4.1
3
3
  * Zero-dependency select / combobox / tags enhancement. Every other control family is omitted.
4
4
  * Pairs with plugin-select-core.css and plugin-select-theme.css.
5
5
  *
@@ -29,7 +29,7 @@
29
29
  })(typeof window !== 'undefined' ? window : this, function (global) {
30
30
  'use strict';
31
31
 
32
- var VERSION = '2.3.1';
32
+ var VERSION = '2.4.1';
33
33
 
34
34
  // Loading the file twice (classic script + module wrapper, or two bundles)
35
35
  // must not replace the classes and orphan the live instances.
@@ -514,6 +514,17 @@
514
514
  autoLoadMore: true,
515
515
  cacheResults: true,
516
516
  loadMoreText: 'Load more',
517
+ fetchUrl: null, // declarative AJAX: GET this endpoint instead of writing fetchOptions
518
+ fetchMethod: 'GET',
519
+ fetchQueryParam: 'q',
520
+ fetchPageParam: 'page', // 1-based page number sent with every request
521
+ fetchSkipParam: null, // when set, send skip = page * pageSize instead of fetchPageParam
522
+ fetchPageSizeParam: 'limit',
523
+ fetchItemsPath: null, // dot path to the array in the JSON body ('data.items')
524
+ fetchTotalPath: null, // dot path to the number of rows available
525
+ fetchHasMorePath: null, // dot path to a boolean
526
+ fetchHeaders: null,
527
+ fetchCredentials: 'same-origin',
517
528
  /* tags */
518
529
  maxTags: Infinity,
519
530
  minTagLength: 1,
@@ -550,6 +561,112 @@
550
561
  * ZidanSelect
551
562
  * ------------------------------------------------------------------ */
552
563
 
564
+ /* ---------------- declarative AJAX (fetchUrl) ---------------- */
565
+
566
+ function readDotPath(source, path) {
567
+ if (!path) return undefined;
568
+ return String(path).split('.').reduce(function (node, key) {
569
+ return node === null || node === undefined ? undefined : node[key];
570
+ }, source);
571
+ }
572
+
573
+ function firstRemoteArray(body) {
574
+ if (Array.isArray(body)) return body;
575
+ if (!body || typeof body !== 'object') return [];
576
+ var keys = ['items', 'data', 'results', 'options', 'rows', 'products', 'records'];
577
+ for (var i = 0; i < keys.length; i++) {
578
+ if (Array.isArray(body[keys[i]])) return body[keys[i]];
579
+ }
580
+ return [];
581
+ }
582
+
583
+ /* Map common API shapes ({id,title}, {value,label}, plain strings) to select items. */
584
+ function remoteItem(raw) {
585
+ if (raw === null || raw === undefined) return null;
586
+ if (typeof raw !== 'object') {
587
+ var text = String(raw);
588
+ return { value: text, label: text };
589
+ }
590
+ var value = raw.value !== undefined ? raw.value
591
+ : raw.id !== undefined ? raw.id
592
+ : raw.slug !== undefined ? raw.slug
593
+ : raw.code !== undefined ? raw.code
594
+ : raw.key !== undefined ? raw.key : undefined;
595
+ var label = raw.label !== undefined ? raw.label
596
+ : raw.name !== undefined ? raw.name
597
+ : raw.title !== undefined ? raw.title
598
+ : raw.full_name !== undefined ? raw.full_name
599
+ : raw.text !== undefined ? raw.text : undefined;
600
+ if (label === undefined) label = value === undefined ? '' : value;
601
+ if (value === undefined) value = label;
602
+ return { value: value, label: label, disabled: !!raw.disabled };
603
+ }
604
+
605
+ /*
606
+ * Turns fetchUrl + fetch* options into the same promise fetchOptions would return:
607
+ * { items, hasMore, total }. Honours AbortSignal and the paging context the
608
+ * select passes in, so caching, debounce and "Load more" work unchanged.
609
+ */
610
+ function createRemoteFetcher(opts) {
611
+ return function (query, signal, context) {
612
+ if (typeof fetch !== 'function') {
613
+ return Promise.reject(new Error('This environment has no fetch().'));
614
+ }
615
+ var page = context && context.page ? context.page : 0;
616
+ var pageSize = opts.fetchPageSize > 0 ? opts.fetchPageSize : 0;
617
+ var url;
618
+ try {
619
+ url = new URL(opts.fetchUrl, (typeof location !== 'undefined' && location.href) || undefined);
620
+ } catch (error) {
621
+ return Promise.reject(new Error('Invalid fetchUrl: ' + opts.fetchUrl));
622
+ }
623
+ if (opts.fetchQueryParam) url.searchParams.set(opts.fetchQueryParam, query || '');
624
+ if (pageSize > 0 && opts.fetchPageSizeParam) {
625
+ url.searchParams.set(opts.fetchPageSizeParam, String(pageSize));
626
+ }
627
+ if (opts.fetchSkipParam) {
628
+ if (pageSize > 0) url.searchParams.set(opts.fetchSkipParam, String(page * pageSize));
629
+ } else if (opts.fetchPageParam) {
630
+ url.searchParams.set(opts.fetchPageParam, String(page + 1));
631
+ }
632
+
633
+ var headers = { Accept: 'application/json' };
634
+ if (opts.fetchHeaders && typeof opts.fetchHeaders === 'object') {
635
+ Object.keys(opts.fetchHeaders).forEach(function (key) {
636
+ headers[key] = opts.fetchHeaders[key];
637
+ });
638
+ }
639
+
640
+ return fetch(url.toString(), {
641
+ method: opts.fetchMethod || 'GET',
642
+ headers: headers,
643
+ signal: signal,
644
+ credentials: opts.fetchCredentials || 'same-origin'
645
+ }).then(function (response) {
646
+ if (!response.ok) {
647
+ throw new Error('Request failed (' + response.status + ' ' + (response.statusText || 'error') + ')');
648
+ }
649
+ return response.json();
650
+ }).then(function (body) {
651
+ var rows = opts.fetchItemsPath ? readDotPath(body, opts.fetchItemsPath) : firstRemoteArray(body);
652
+ if (!Array.isArray(rows)) rows = rows === undefined || rows === null ? [] : [rows];
653
+ var items = rows.map(remoteItem).filter(Boolean);
654
+
655
+ var hasMore;
656
+ if (opts.fetchHasMorePath) hasMore = !!readDotPath(body, opts.fetchHasMorePath);
657
+ var rawTotal = opts.fetchTotalPath ? readDotPath(body, opts.fetchTotalPath)
658
+ : (body && typeof body === 'object' ? body.total : undefined);
659
+ var total = rawTotal === undefined || rawTotal === null ? NaN : Number(rawTotal);
660
+ if (hasMore === undefined && isFinite(total) && pageSize > 0) {
661
+ hasMore = (page + 1) * pageSize < total;
662
+ }
663
+ if (hasMore === undefined) hasMore = pageSize > 0 && items.length >= pageSize;
664
+
665
+ return { items: items, hasMore: hasMore, total: isFinite(total) ? total : undefined };
666
+ });
667
+ };
668
+ }
669
+
553
670
  function ZidanSelect(target, options) {
554
671
  if (!(this instanceof ZidanSelect)) return new ZidanSelect(target, options);
555
672
  if (!doc) throw new Error('ZidanSelect requires a DOM environment.');
@@ -670,6 +787,15 @@
670
787
  merged.autoLoadMore = pick('autoLoadMore', readBoolAttr(d.zidanAutoLoadMore, DEFAULTS.autoLoadMore));
671
788
  merged.cacheResults = pick('cacheResults', readBoolAttr(d.zidanCacheResults, DEFAULTS.cacheResults));
672
789
  merged.loadMoreText = pick('loadMoreText', d.zidanLoadMoreText || DEFAULTS.loadMoreText);
790
+ merged.fetchUrl = pick('fetchUrl', d.zidanFetchUrl || null);
791
+ merged.fetchMethod = pick('fetchMethod', d.zidanFetchMethod || DEFAULTS.fetchMethod);
792
+ merged.fetchQueryParam = pick('fetchQueryParam', d.zidanFetchQueryParam !== undefined ? d.zidanFetchQueryParam : DEFAULTS.fetchQueryParam);
793
+ merged.fetchPageParam = pick('fetchPageParam', d.zidanFetchPageParam !== undefined ? d.zidanFetchPageParam : DEFAULTS.fetchPageParam);
794
+ merged.fetchSkipParam = pick('fetchSkipParam', d.zidanFetchSkipParam || null);
795
+ merged.fetchPageSizeParam = pick('fetchPageSizeParam', d.zidanFetchPageSizeParam !== undefined ? d.zidanFetchPageSizeParam : DEFAULTS.fetchPageSizeParam);
796
+ merged.fetchItemsPath = pick('fetchItemsPath', d.zidanFetchItemsPath || null);
797
+ merged.fetchTotalPath = pick('fetchTotalPath', d.zidanFetchTotalPath || null);
798
+ merged.fetchHasMorePath = pick('fetchHasMorePath', d.zidanFetchHasMorePath || null);
673
799
 
674
800
  // carry over every explicitly-passed option (callbacks, custom classes, ...)
675
801
  Object.keys(options).forEach(function (key) {
@@ -685,6 +811,11 @@
685
811
  if (mode === 'combobox') merged.searchable = true;
686
812
  if (mode === 'tags' && merged.searchable === false) merged.searchable = true;
687
813
  if (mode === 'tags') merged.multiple = true;
814
+
815
+ // declarative AJAX: one URL is enough to opt into remote loading
816
+ if (merged.fetchUrl && typeof merged.fetchOptions !== 'function') {
817
+ merged.fetchOptions = createRemoteFetcher(merged);
818
+ }
688
819
  return merged;
689
820
  };
690
821