monobill-mintui 0.3.41 → 0.3.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/form/Form.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +6 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;;IAM5D,iBAAiB,IAAI,IAAI;IAwCzB,oBAAoB,IAAI,IAAI;IAW5B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAWb;;;OAGG;IACH,KAAK,IAAI,IAAI;IAQb,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IA6B9F,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAErC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAqCzC;IAGD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE3C;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAgB/C;IAED,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,oBAAoB;YAYd,aAAa;
|
|
1
|
+
{"version":3,"file":"Form.d.ts","sourceRoot":"","sources":["../../../src/components/form/Form.ts"],"names":[],"mappings":"AAOA,cAAM,QAAS,SAAQ,WAAW;IAChC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,cAAc,CAAoC;IAC1D,OAAO,CAAC,kBAAkB,CAAoC;IAC9D,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,kBAAkB,CAAkD;IAC5E,OAAO,CAAC,oBAAoB,CAAkD;IAC9E,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,SAAS,CAAmC;IACpD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,aAAa,CAAuE;IAC5F,OAAO,CAAC,kBAAkB,CAAY;IACtC,OAAO,CAAC,qBAAqB,CAAsB;IACnD,OAAO,CAAC,iBAAiB,CAAmC;;IAM5D,iBAAiB,IAAI,IAAI;IAwCzB,oBAAoB,IAAI,IAAI;IAW5B;;;OAGG;IACH,KAAK,IAAI,IAAI;IAWb;;;OAGG;IACH,KAAK,IAAI,IAAI;IAQb,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IA6B9F,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAErC;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAqCzC;IAGD,IAAI,OAAO,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAE3C;IAED,IAAI,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,EAgB/C;IAED,OAAO,CAAC,OAAO;IAkBf,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,oBAAoB;YAYd,aAAa;YAwFb,WAAW;YAkJX,yBAAyB;YAiBzB,uBAAuB;IA2BrC,OAAO,CAAC,iBAAiB;IA+GzB,OAAO,CAAC,uBAAuB;IAkB/B,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,SAAS;IAuBjB,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,cAAc;IAqDtB,OAAO,CAAC,iBAAiB;IAgDzB,OAAO,CAAC,kBAAkB;IAqI1B,OAAO,CAAC,eAAe;IAgBvB,OAAO,CAAC,gBAAgB;IAgBxB,OAAO,CAAC,YAAY;IAoBpB,OAAO,CAAC,kBAAkB;IAuB1B,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAoCtB,OAAO,CAAC,kBAAkB;IAwE1B,OAAO,CAAC,kBAAkB;IAmD1B,OAAO,CAAC,YAAY;IAWpB,OAAO,CAAC,oBAAoB;IA8J5B,OAAO,CAAC,iBAAiB;IAoCzB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,sBAAsB;IA4B9B,OAAO,CAAC,kBAAkB;IAa1B,OAAO,CAAC,sBAAsB;IAyB9B,OAAO,CAAC,qBAAqB;IAoD7B,OAAO,CAAC,oBAAoB;IA6C5B;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IA0CzB;;;OAGG;IACH,OAAO,CAAC,mBAAmB;IAa3B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IA2B5B;;OAEG;IACH,OAAO,CAAC,eAAe;IASvB;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAoCzB;;;OAGG;IACH,OAAO,CAAC,0BAA0B;IAyDlC;;OAEG;IACH,OAAO,CAAC,yBAAyB;CASlC;AAsCD,eAAe,QAAQ,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
background: rgba(255, 255, 255, 0.2);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
`,S.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(V.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(V));const O=document.createElement("div");O.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",I.appendChild(O);const q=document.createElement("div");q.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",I.appendChild(q);const F=document.createElement("div");F.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",I.appendChild(F);const M=document.createElement("div");M.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",I.appendChild(M);const N=()=>{if(window.innerWidth>=768){const D=S.scrollTop,L=S.scrollHeight,z=S.clientHeight;D>0?F.style.opacity="1":F.style.opacity="0",D+z<L-1?M.style.opacity="1":M.style.opacity="0",O.style.opacity="0",q.style.opacity="0"}else{const D=S.scrollLeft,L=S.scrollWidth,z=S.clientWidth;D>0?O.style.opacity="1":O.style.opacity="0",D+z<L-1?q.style.opacity="1":q.style.opacity="0",F.style.opacity="0",M.style.opacity="0"}};S.addEventListener("scroll",N),window.addEventListener("resize",N),setTimeout(N,0),a.forEach(B=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=B.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const L=B.action();if(L){if(this._isRange&&"start"in L&&"end"in L){this._selectedStartDate=L.start,this._selectedEndDate=L.end;const z=this.getFormat(),U=this._formatDate(L.start,z),kt=this._formatDate(L.end,z),Et=`${U} - ${kt}`;this.setValue(Et),this._currentMonth=L.start.getMonth(),this._currentYear=L.start.getFullYear()}else if(L instanceof Date){this._selectedStartDate=L,this._selectedEndDate=null;const z=this.getFormat(),U=this._formatDate(L,z);this.setValue(U),this._currentMonth=L.getMonth(),this._currentYear=L.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),S.appendChild(D)}),I.appendChild(S),C.appendChild(I),l.appendChild(C)}c.appendChild(d),c.appendChild(b),c.appendChild(v),l.appendChild(c),this._calendarContainer.appendChild(l)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2",t.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentMonth===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=l,d.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(d)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(o)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const o=document.createElement("mint-icon");o.setAttribute("name","caret-right"),o.className="w-4 h-4",a.appendChild(o),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentYear===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(c),d.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(l)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){const i=this.getWeekStartDay(),s=new Date(e,t,1).getDay();return s>=i?s-i:7-(i-s)}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){const e=this.getSelectionMode();return this._isRange||e==="week"||e==="month"?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(t,this._selectedStartDate)||this._isSameDate(t,this._selectedEndDate):!1:this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){const e=this.getSelectionMode();return(this._isRange||e==="week"||e==="month")&&this._selectedStartDate&&this._selectedEndDate?t>=this._selectedStartDate&&t<=this._selectedEndDate:!1}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_getWeekStart(t){const e=this.getWeekStartDay(),i=t.getDay();let s;i>=e?s=i-e:s=7-(e-i);const n=new Date(t);return n.setDate(t.getDate()-s),n.setHours(0,0,0,0),n}_getWeekEnd(t){const e=this._getWeekStart(t),i=new Date(e);return i.setDate(e.getDate()+6),i.setHours(23,59,59,999),i}_getMonthStart(t){const e=new Date(t.getFullYear(),t.getMonth(),1);return e.setHours(0,0,0,0),e}_getMonthEnd(t){const e=new Date(t.getFullYear(),t.getMonth()+1,0);return e.setHours(23,59,59,999),e}_handleDateClick(t){const e=this.getFormat(),i=this.getSelectionMode();let s,n;if(i==="week"?(s=this._getWeekStart(t),n=this._getWeekEnd(t)):i==="month"?(s=this._getMonthStart(t),n=this._getMonthEnd(t)):(s=t,n=t),this.isRange()||i==="week"||i==="month"){this._selectedStartDate=s,this._selectedEndDate=n;const o=this._formatDate(this._selectedStartDate,e),l=this._formatDate(this._selectedEndDate,e),c=`${o} - ${l}`;this.setValue(c),this._textInput&&(this._textInput.value=c),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else{this._selectedStartDate=s,this._selectedEndDate=null;const o=this._formatDate(s,e);this.setValue(o),this._textInput&&(this._textInput.value=o),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();const a=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat(),e=this.getSelectionMode(),i=this._isRange||e==="week"||e==="month";let s="";i?this._selectedStartDate&&this._selectedEndDate?s=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)),s?(this._displayEl.textContent=s,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",ct);class ht extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(s=>{const n=Array.from(s.addedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP"))||Array.from(s.removedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP")),r=s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE&&(s.target.tagName==="OPTION"||s.target.tagName==="OPTGROUP");return n||r})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled"]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._optionObserver&&(this._optionObserver.disconnect(),this._optionObserver=null),this._childrenObserver&&(this._childrenObserver.disconnect(),this._childrenObserver=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{const e=t||"";(this.getAttribute("value")||"")!==e&&this.setAttribute("value",e),this._select&&requestAnimationFrame(()=>{this._select&&(e===""||Array.from(this._select.options).some(n=>n.value===e))&&this._select.value!==e&&(this._select.value=e)})}catch{}}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&e.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),d=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&h.setAttribute("for",r);const u=document.createTextNode(s);h.appendChild(u),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",d?"true":"false");const p=i.length>0?i:e;if(p.length>0&&p.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const _=h.target.value;(this.getAttribute("value")||"")!==_&&(_?this.setAttribute("value",_):this.removeAttribute("value"));const m=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(m),this.dispatchEvent(new CustomEvent("input",{detail:{value:_},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:_},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{const h=this.getAttribute("value")||this.value||"";this._select&&h&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(_=>_.value===h)&&this._select.value!==h&&(this._select.value=h)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(n){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=n,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ht);class dt extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const d=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");d&&d.remove(),p&&p.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const u=document.createElement("mint-icon");if(u.setAttribute("name","upload"),u.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(u),this._dropzone.appendChild(h),e){const _=document.createElement("div");_.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",_.textContent=e,this._dropzone.appendChild(_)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const d=document.createElement("div");if(d.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",l.type.startsWith("image/")){const _=document.createElement("img");_.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const f=URL.createObjectURL(l);this._previewUrls.push(f),_.src=f,d.appendChild(_)}else{const _=document.createElement("mint-icon");_.setAttribute("name","attach"),_.className="w-5 h-5 text-gray-500 dark:text-gray-300",d.appendChild(_)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=l.name,d.appendChild(p);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const u=document.createElement("mint-icon");u.setAttribute("name","close"),u.className="w-4 h-4",h.appendChild(u),h.addEventListener("click",_=>{_.preventDefault(),_.stopPropagation(),this._removeFileAt(c)}),d.appendChild(h),e.appendChild(d)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,d=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+d<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",dt);class ut extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||(this._lastDataSnapshot=this._createDataSnapshot(this._formData)),this._applyFormData();else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)?this._setupReactiveDataObserver(t):this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){var l;if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),o=this.getAttribute("method");if(!(!a||!o)){this._setButtonsSubmitting();try{const c=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:c,bubbles:!0,cancelable:!0}))}catch(c){(c==null?void 0:c.status)===422&&((l=c==null?void 0:c.data)!=null&&l.errors)&&this._applyServerErrors(c.data.errors),this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:c},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var d,p,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(u=>u instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((h=(p=(d=window.mintForm)==null?void 0:d.defaults)==null?void 0:p.headers)!=null&&h.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const u=new URLSearchParams;t.forEach((_,f)=>{_ instanceof File||u.append(f,String(_))}),l+=(i.includes("?")?"&":"?")+u.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const u=new URLSearchParams;t.forEach((_,f)=>{_ instanceof File||u.append(f,String(_))}),a=u,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const u=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),_=await u.text().catch(()=>"");let f=_;try{f=JSON.parse(_)}catch{}if(!u.ok){const g={status:u.status,data:f,response:{status:u.status,data:f}};throw await this._applyErrorInterceptors(g)}const m={status:u.status,ok:u.ok,data:f};return await this._applySuccessInterceptors(m)}catch(u){if(u.response)throw u;const _={status:u.status||0,data:u.data||u.message||"Network error",response:{status:u.status||0,data:u.data||u.message||"Network error"}};throw await this._applyErrorInterceptors(_)}const c=this;return await new Promise(async(u,_)=>{const f=new XMLHttpRequest;f.open(s||"POST",l,!0),Object.entries(o).forEach(([m,g])=>f.setRequestHeader(m,g)),f.onload=async function(){const{status:m,responseText:g}=f;if(m>=200&&m<300){let b=g;try{b=JSON.parse(g)}catch{}try{const v={status:m,ok:!0,data:b},k=await c._applySuccessInterceptors(v);u(k)}catch(v){_(v)}}else{let b=g;try{b=JSON.parse(g)}catch{}try{const v={status:m,data:b,response:{status:m,data:b}},k=await c._applyErrorInterceptors(v);_(k)}catch(v){_(v)}}},f.onerror=async function(){try{const m={status:f.status||0,data:f.responseText||"Network error",response:{status:f.status||0,data:f.responseText||"Network error"}},g=await c._applyErrorInterceptors(m);_(g)}catch(m){_(m)}},f.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(d=>d.name===l.name&&d.size===l.size&&d.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")}),this._errors={}}_applyServerErrors(t){this._clearErrors(),Object.entries(t).forEach(([e,i])=>{const s=Array.isArray(i)?i[0]||"Validation error":i||"Validation error",n=this._getFieldElements(e);n.length>0&&(this._errors[e]=s,this._flagFieldError(n,s))})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),d=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||d||p||h)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t)return!0;try{const e=t.toString();if(e==="[object Object]"||e.includes("Proxy")){const i=Object.keys(t)[0];if(i){const s=Object.getOwnPropertyDescriptor(t,i);if(s&&(s.get||s.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(t){try{const e=this._extractReactiveData(t);return JSON.parse(JSON.stringify(e))}catch{return{...this._extractReactiveData(t)}}}_extractReactiveData(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>this._extractReactiveData(i));const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=this._extractReactiveData(e[s]));return i}return e}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupReactiveDataObserver(t){if(this._stopReactiveDataObserver(),!this.isConnected)return;const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e))this._lastDataSnapshot=this._createDataSnapshot(e);else{this._lastDataSnapshot=null;return}const i=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const s=this._getReactiveValue(this._formData);if(s&&typeof s=="object"&&!Array.isArray(s)){const n=this._createDataSnapshot(s);this._hasDataChanged(n,this._lastDataSnapshot)&&(this._lastDataSnapshot=n,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(i):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(i)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",ut);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(w,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class pt extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,d)=>{const p=c.querySelector("mint-icon"),h=(p==null?void 0:p.getAttribute("name"))||"",u=p!==null&&h!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","bg-[#F7F7F7]","dark:bg-gray-800","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),d===0&&c.classList.add("pl-6"),d===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,d)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),d===l.length-1&&c.classList.remove("border-b");const h=c.querySelectorAll("td");h.forEach((u,_)=>{this._setClasses(u,["text-gray-900","dark:text-gray-100","px-3","py-2"]),_===0&&u.classList.add("pl-6"),_===h.length-1&&u.classList.add("pr-6"),e?this._applyMobileCell(u,s):this._restoreCell(u)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
89
|
+
`,S.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(V.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(V));const O=document.createElement("div");O.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",I.appendChild(O);const q=document.createElement("div");q.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",I.appendChild(q);const F=document.createElement("div");F.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",I.appendChild(F);const M=document.createElement("div");M.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",I.appendChild(M);const N=()=>{if(window.innerWidth>=768){const D=S.scrollTop,L=S.scrollHeight,z=S.clientHeight;D>0?F.style.opacity="1":F.style.opacity="0",D+z<L-1?M.style.opacity="1":M.style.opacity="0",O.style.opacity="0",q.style.opacity="0"}else{const D=S.scrollLeft,L=S.scrollWidth,z=S.clientWidth;D>0?O.style.opacity="1":O.style.opacity="0",D+z<L-1?q.style.opacity="1":q.style.opacity="0",F.style.opacity="0",M.style.opacity="0"}};S.addEventListener("scroll",N),window.addEventListener("resize",N),setTimeout(N,0),a.forEach(B=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=B.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const L=B.action();if(L){if(this._isRange&&"start"in L&&"end"in L){this._selectedStartDate=L.start,this._selectedEndDate=L.end;const z=this.getFormat(),U=this._formatDate(L.start,z),kt=this._formatDate(L.end,z),Et=`${U} - ${kt}`;this.setValue(Et),this._currentMonth=L.start.getMonth(),this._currentYear=L.start.getFullYear()}else if(L instanceof Date){this._selectedStartDate=L,this._selectedEndDate=null;const z=this.getFormat(),U=this._formatDate(L,z);this.setValue(U),this._currentMonth=L.getMonth(),this._currentYear=L.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),S.appendChild(D)}),I.appendChild(S),C.appendChild(I),l.appendChild(C)}c.appendChild(d),c.appendChild(b),c.appendChild(v),l.appendChild(c),this._calendarContainer.appendChild(l)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2",t.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentMonth===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=l,d.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(d)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(o)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const o=document.createElement("mint-icon");o.setAttribute("name","caret-right"),o.className="w-4 h-4",a.appendChild(o),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentYear===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(c),d.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(l)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){const i=this.getWeekStartDay(),s=new Date(e,t,1).getDay();return s>=i?s-i:7-(i-s)}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){const e=this.getSelectionMode();return this._isRange||e==="week"||e==="month"?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(t,this._selectedStartDate)||this._isSameDate(t,this._selectedEndDate):!1:this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){const e=this.getSelectionMode();return(this._isRange||e==="week"||e==="month")&&this._selectedStartDate&&this._selectedEndDate?t>=this._selectedStartDate&&t<=this._selectedEndDate:!1}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_getWeekStart(t){const e=this.getWeekStartDay(),i=t.getDay();let s;i>=e?s=i-e:s=7-(e-i);const n=new Date(t);return n.setDate(t.getDate()-s),n.setHours(0,0,0,0),n}_getWeekEnd(t){const e=this._getWeekStart(t),i=new Date(e);return i.setDate(e.getDate()+6),i.setHours(23,59,59,999),i}_getMonthStart(t){const e=new Date(t.getFullYear(),t.getMonth(),1);return e.setHours(0,0,0,0),e}_getMonthEnd(t){const e=new Date(t.getFullYear(),t.getMonth()+1,0);return e.setHours(23,59,59,999),e}_handleDateClick(t){const e=this.getFormat(),i=this.getSelectionMode();let s,n;if(i==="week"?(s=this._getWeekStart(t),n=this._getWeekEnd(t)):i==="month"?(s=this._getMonthStart(t),n=this._getMonthEnd(t)):(s=t,n=t),this.isRange()||i==="week"||i==="month"){this._selectedStartDate=s,this._selectedEndDate=n;const o=this._formatDate(this._selectedStartDate,e),l=this._formatDate(this._selectedEndDate,e),c=`${o} - ${l}`;this.setValue(c),this._textInput&&(this._textInput.value=c),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else{this._selectedStartDate=s,this._selectedEndDate=null;const o=this._formatDate(s,e);this.setValue(o),this._textInput&&(this._textInput.value=o),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();const a=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat(),e=this.getSelectionMode(),i=this._isRange||e==="week"||e==="month";let s="";i?this._selectedStartDate&&this._selectedEndDate?s=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)),s?(this._displayEl.textContent=s,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",ct);class ht extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(s=>{const n=Array.from(s.addedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP"))||Array.from(s.removedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP")),r=s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE&&(s.target.tagName==="OPTION"||s.target.tagName==="OPTGROUP");return n||r})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled"]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._optionObserver&&(this._optionObserver.disconnect(),this._optionObserver=null),this._childrenObserver&&(this._childrenObserver.disconnect(),this._childrenObserver=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{const e=t||"";(this.getAttribute("value")||"")!==e&&this.setAttribute("value",e),this._select&&requestAnimationFrame(()=>{this._select&&(e===""||Array.from(this._select.options).some(n=>n.value===e))&&this._select.value!==e&&(this._select.value=e)})}catch{}}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&e.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),d=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&h.setAttribute("for",r);const u=document.createTextNode(s);h.appendChild(u),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",d?"true":"false");const p=i.length>0?i:e;if(p.length>0&&p.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const _=h.target.value;(this.getAttribute("value")||"")!==_&&(_?this.setAttribute("value",_):this.removeAttribute("value"));const m=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(m),this.dispatchEvent(new CustomEvent("input",{detail:{value:_},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:_},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{const h=this.getAttribute("value")||this.value||"";this._select&&h&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(_=>_.value===h)&&this._select.value!==h&&(this._select.value=h)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(n){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=n,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ht);class dt extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const d=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");d&&d.remove(),p&&p.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const u=document.createElement("mint-icon");if(u.setAttribute("name","upload"),u.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(u),this._dropzone.appendChild(h),e){const _=document.createElement("div");_.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",_.textContent=e,this._dropzone.appendChild(_)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const d=document.createElement("div");if(d.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",l.type.startsWith("image/")){const _=document.createElement("img");_.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const f=URL.createObjectURL(l);this._previewUrls.push(f),_.src=f,d.appendChild(_)}else{const _=document.createElement("mint-icon");_.setAttribute("name","attach"),_.className="w-5 h-5 text-gray-500 dark:text-gray-300",d.appendChild(_)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=l.name,d.appendChild(p);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const u=document.createElement("mint-icon");u.setAttribute("name","close"),u.className="w-4 h-4",h.appendChild(u),h.addEventListener("click",_=>{_.preventDefault(),_.stopPropagation(),this._removeFileAt(c)}),d.appendChild(h),e.appendChild(d)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,d=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+d<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",dt);class ut extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||(this._lastDataSnapshot=this._createDataSnapshot(this._formData)),this._applyFormData();else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)?this._setupReactiveDataObserver(t):this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){var l;if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form);let s=this._formDataToValues(i);if(this._formData){const c=this._getReactiveValue(this._formData);c&&typeof c=="object"&&!Array.isArray(c)&&(s={...this._extractReactiveData(c),...s})}if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),o=this.getAttribute("method");if(!(!a||!o)){this._setButtonsSubmitting();try{const c=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:c,bubbles:!0,cancelable:!0}))}catch(c){(c==null?void 0:c.status)===422&&((l=c==null?void 0:c.data)!=null&&l.errors)&&this._applyServerErrors(c.data.errors),this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:c},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var d,p,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(u=>u instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((h=(p=(d=window.mintForm)==null?void 0:d.defaults)==null?void 0:p.headers)!=null&&h.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const u=new URLSearchParams;t.forEach((_,f)=>{_ instanceof File||u.append(f,String(_))}),l+=(i.includes("?")?"&":"?")+u.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const u=new URLSearchParams;t.forEach((_,f)=>{_ instanceof File||u.append(f,String(_))}),a=u,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const u=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),_=await u.text().catch(()=>"");let f=_;try{f=JSON.parse(_)}catch{}if(!u.ok){const g={status:u.status,data:f,response:{status:u.status,data:f}};throw await this._applyErrorInterceptors(g)}const m={status:u.status,ok:u.ok,data:f};return await this._applySuccessInterceptors(m)}catch(u){if(u.response)throw u;const _={status:u.status||0,data:u.data||u.message||"Network error",response:{status:u.status||0,data:u.data||u.message||"Network error"}};throw await this._applyErrorInterceptors(_)}const c=this;return await new Promise(async(u,_)=>{const f=new XMLHttpRequest;f.open(s||"POST",l,!0),Object.entries(o).forEach(([m,g])=>f.setRequestHeader(m,g)),f.onload=async function(){const{status:m,responseText:g}=f;if(m>=200&&m<300){let b=g;try{b=JSON.parse(g)}catch{}try{const v={status:m,ok:!0,data:b},k=await c._applySuccessInterceptors(v);u(k)}catch(v){_(v)}}else{let b=g;try{b=JSON.parse(g)}catch{}try{const v={status:m,data:b,response:{status:m,data:b}},k=await c._applyErrorInterceptors(v);_(k)}catch(v){_(v)}}},f.onerror=async function(){try{const m={status:f.status||0,data:f.responseText||"Network error",response:{status:f.status||0,data:f.responseText||"Network error"}},g=await c._applyErrorInterceptors(m);_(g)}catch(m){_(m)}},f.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(d=>d.name===l.name&&d.size===l.size&&d.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")}),this._errors={}}_applyServerErrors(t){this._clearErrors(),Object.entries(t).forEach(([e,i])=>{const s=Array.isArray(i)?i[0]||"Validation error":i||"Validation error",n=this._getFieldElements(e);n.length>0&&(this._errors[e]=s,this._flagFieldError(n,s))})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),d=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||d||p||h)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t)return!0;try{const e=t.toString();if(e==="[object Object]"||e.includes("Proxy")){const i=Object.keys(t)[0];if(i){const s=Object.getOwnPropertyDescriptor(t,i);if(s&&(s.get||s.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(t){try{const e=this._extractReactiveData(t);return JSON.parse(JSON.stringify(e))}catch{return{...this._extractReactiveData(t)}}}_extractReactiveData(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>this._extractReactiveData(i));const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=this._extractReactiveData(e[s]));return i}return e}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupReactiveDataObserver(t){if(this._stopReactiveDataObserver(),!this.isConnected)return;const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e))this._lastDataSnapshot=this._createDataSnapshot(e);else{this._lastDataSnapshot=null;return}const i=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const s=this._getReactiveValue(this._formData);if(s&&typeof s=="object"&&!Array.isArray(s)){const n=this._createDataSnapshot(s);this._hasDataChanged(n,this._lastDataSnapshot)&&(this._lastDataSnapshot=n,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(i):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(i)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",ut);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(w,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class pt extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,d)=>{const p=c.querySelector("mint-icon"),h=(p==null?void 0:p.getAttribute("name"))||"",u=p!==null&&h!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","bg-[#F7F7F7]","dark:bg-gray-800","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),d===0&&c.classList.add("pl-6"),d===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,d)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),d===l.length-1&&c.classList.remove("border-b");const h=c.querySelectorAll("td");h.forEach((u,_)=>{this._setClasses(u,["text-gray-900","dark:text-gray-100","px-3","py-2"]),_===0&&u.classList.add("pl-6"),_===h.length-1&&u.classList.add("pr-6"),e?this._applyMobileCell(u,s):this._restoreCell(u)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
90
90
|
@media (max-width: 640px) {
|
|
91
91
|
mint-table[collapse] {
|
|
92
92
|
display: block;
|
package/dist/index.js
CHANGED
|
@@ -4533,7 +4533,12 @@ class _t extends HTMLElement {
|
|
|
4533
4533
|
var l;
|
|
4534
4534
|
if (t.preventDefault(), !this._form) return;
|
|
4535
4535
|
this._clearErrors(), this._syncDropzoneFiles();
|
|
4536
|
-
const e = this._collectValidationRules(), i = new FormData(this._form)
|
|
4536
|
+
const e = this._collectValidationRules(), i = new FormData(this._form);
|
|
4537
|
+
let s = this._formDataToValues(i);
|
|
4538
|
+
if (this._formData) {
|
|
4539
|
+
const c = this._getReactiveValue(this._formData);
|
|
4540
|
+
c && typeof c == "object" && !Array.isArray(c) && (s = { ...this._extractReactiveData(c), ...s });
|
|
4541
|
+
}
|
|
4537
4542
|
if (!this._validate(s, e)) {
|
|
4538
4543
|
this.dispatchEvent(new CustomEvent("invalid", {
|
|
4539
4544
|
detail: { errors: this._errors },
|