monobill-mintui 0.2.91 → 0.2.93
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 +12 -5
- 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;;IAM5F,iBAAiB,IAAI,IAAI;IAiCzB,oBAAoB,IAAI,IAAI;IAU5B;;;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,EAsBzC;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;YAoEb,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;IAiBpB,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IA8BtB,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;
|
|
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;;IAM5F,iBAAiB,IAAI,IAAI;IAiCzB,oBAAoB,IAAI,IAAI;IAU5B;;;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,EAsBzC;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;YAoEb,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;IAiBpB,OAAO,CAAC,cAAc;IAyBtB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IA8BtB,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;CA6C7B;AAsCD,eAAe,QAAQ,CAAA"}
|
package/dist/index.cjs
CHANGED
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
background: rgba(255, 255, 255, 0.2);
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
`,g.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 C=document.createElement("div");C.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",E.appendChild(C);const A=document.createElement("div");A.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",E.appendChild(A);const T=document.createElement("div");T.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",E.appendChild(T);const S=document.createElement("div");S.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",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=g.scrollTop,I=g.scrollHeight,N=g.clientHeight;D>0?T.style.opacity="1":T.style.opacity="0",D+N<I-1?S.style.opacity="1":S.style.opacity="0",C.style.opacity="0",A.style.opacity="0"}else{const D=g.scrollLeft,I=g.scrollWidth,N=g.clientWidth;D>0?C.style.opacity="1":C.style.opacity="0",D+N<I-1?A.style.opacity="1":A.style.opacity="0",T.style.opacity="0",S.style.opacity="0"}};g.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),r.forEach(L=>{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=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const I=L.action();if(I){if(this._isRange&&"start"in I&&"end"in I){this._selectedStartDate=I.start,this._selectedEndDate=I.end;const N=this.getFormat(),M=this._formatDate(I.start,N),ae=this._formatDate(I.end,N),oe=`${M} - ${ae}`;this.setValue(oe),this._currentMonth=I.start.getMonth(),this._currentYear=I.start.getFullYear()}else if(I instanceof Date){this._selectedStartDate=I,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(I,N);this.setValue(M),this._currentMonth=I.getMonth(),this._currentYear=I.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}))}}),g.appendChild(D)}),E.appendChild(g),k.appendChild(E),a.appendChild(k)}l.appendChild(o),l.appendChild(_),l.appendChild(b),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.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()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.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",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.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",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,d)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentMonth===d;c.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 ${m?"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"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=d,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=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 r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);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 l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",a.appendChild(l),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2";for(let d=e;d<=t;d++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentYear===d;c.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 ${m?"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"}`,c.textContent=String(d),c.addEventListener("click",()=>{this._currentYear=d,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),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}))}_updateDisplayText(){if(!this._displayEl)return;const e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,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 e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.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(e){let t=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let r=t.querySelector(".mint-date-picker-skeleton");r||(r=document.createElement("div"),r.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",r.style.height="2.25rem",t.appendChild(r)),t.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 t&&(t.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 e=["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(e)).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 e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[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",K);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=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()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="loading"){this.render();return}if(e==="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(e){const t=e||"";this.setAttribute("value",t),this._select&&(this._select.value=t)}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 e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"pr-10",t?"py-2":"py-1.5",t?"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",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"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,...r].filter(Boolean).join(" ")}render(){const e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&t.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(),r=this.getInfo(),n=this.getId(),a=this.getName(),l=this.getValue(),o=this.isDisabled(),d=this.isMultiple(),c=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",n&&h.setAttribute("for",n);const f=document.createTextNode(s);h.appendChild(f),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(),n&&(this._select.id=n),a&&(this._select.name=a),o&&(this._select.disabled=!0),d&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",c?"true":"false");const m=t.length>0?t:i;if(m.length>0&&m.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=l||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const u=h.target.value;u?this.setAttribute("value",u):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:u},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),d)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(r){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=r,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(e){t||(t=document.createElement("div"),t.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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 r=this.isMultiple();s.style.height=r?"6rem":"2.25rem",t.appendChild(s)}t.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else t&&(t.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q 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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e==="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(e){let t=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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%",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),l=this._fileInput;if(r){const o=r;o.style.visibility="hidden",o.style.pointerEvents="none"}if(n){const o=n;o.style.visibility="hidden",o.style.pointerEvents="none"}if(a){const o=a;o.style.visibility="hidden",o.style.pointerEvents="none"}l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(t&&(t.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),n=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const l=s;l.style.visibility="visible",l.style.pointerEvents="auto"}if(r){const l=r;l.style.visibility="visible",l.style.pointerEvents="auto"}if(n){const l=n;l.style.visibility="visible",l.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 e=this.isLoading(),t=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),r=this.isDisabled(),n=this.getWidth(),a=this.getHeight(),l=this.getName(),o=this.hasError(),d=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",o?"true":"false"),r?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",t||"File upload dropzone")),this._dropzone.style.width=n,this._dropzone.style.height=a,this._dropzone.style.minWidth=n,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=r,l?this._fileInput.name=l:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",o?"true":"false");const c=this._dropzone.querySelector(".mint-dropzone-icon"),m=this._dropzone.querySelector(".mint-dropzone-label");c&&c.remove(),m&&m.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const f=document.createElement("mint-icon");if(f.setAttribute("name","upload"),f.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(f),this._dropzone.appendChild(h),t){const u=document.createElement("div");u.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",u.textContent=t,this._dropzone.appendChild(u)}this.setupEventListeners(),this._renderErrorState(o,d),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(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=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`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`,n=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=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"",o="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=`${r} ${t?a:n} ${l} ${o}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onKeyDown||(this._onKeyDown=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onFocus||(this._onFocus=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=e=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.splice(1)),a.length>0){const l=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(l)}n.length>0&&this._applyValidFiles(n)}}),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(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.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 e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.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((o,d)=>{const c=document.createElement("div");if(c.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",o.type.startsWith("image/")){const u=document.createElement("img");u.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const p=URL.createObjectURL(o);this._previewUrls.push(p),u.src=p,c.appendChild(u)}else{const u=document.createElement("mint-icon");u.setAttribute("name","attach"),u.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(u)}const m=document.createElement("div");m.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",m.textContent=o.name,c.appendChild(m);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 f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",h.appendChild(f),h.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this._removeFileAt(d)}),c.appendChild(h),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);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 ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,d=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<d-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[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(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class ee 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}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const e=this.getAttribute("headers");e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._applyFormData();else{const t=this.getAttribute("data-form-data");t&&(this._parseFormData(t),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()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){e==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e==="headers"?this._parseHeaders(i):e==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){e&&typeof e=="object"&&!Array.isArray(e)?this._formData=e:e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e=="object"&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e=="string")try{this._headers=JSON.parse(e)}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=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const a=this.getAttribute("action"),l=this.getAttribute("method");if(!(!a||!l)){this._setButtonsSubmitting();try{const o=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:o,bubbles:!0,cancelable:!0}))}catch(o){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:o},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){var c,m,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(f=>f instanceof File);let a=null;const l={};let o=i;if(typeof window<"u"&&((h=(m=(c=window.mintForm)==null?void 0:c.defaults)==null?void 0:m.headers)!=null&&h.common)&&Object.assign(l,window.mintForm.defaults.headers.common),this._headers&&Object.assign(l,this._headers),s==="GET"){const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),o+=(i.includes("?")?"&":"?")+f.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),a=f,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const f=await fetch(o,{method:s||"POST",body:s==="GET"?null:a,headers:l}),u=await f.text().catch(()=>"");let p=u;try{p=JSON.parse(u)}catch{}if(!f.ok){const b={status:f.status,data:p,response:{status:f.status,data:p}};throw await this._applyErrorInterceptors(b)}const _={status:f.status,ok:f.ok,data:p};return await this._applySuccessInterceptors(_)}catch(f){if(f.response)throw f;const u={status:f.status||0,data:f.data||f.message||"Network error",response:{status:f.status||0,data:f.data||f.message||"Network error"}};throw await this._applyErrorInterceptors(u)}const d=this;return await new Promise(async(f,u)=>{const p=new XMLHttpRequest;p.open(s||"POST",o,!0),Object.entries(l).forEach(([_,b])=>p.setRequestHeader(_,b)),p.onload=async function(){const{status:_,responseText:b}=p;if(_>=200&&_<300){let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,ok:!0,data:y},k=await d._applySuccessInterceptors(x);f(k)}catch(x){u(x)}}else{let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,data:y,response:{status:_,data:y}},k=await d._applyErrorInterceptors(x);u(k)}catch(x){u(x)}}},p.onerror=async function(){try{const _={status:p.status||0,data:p.responseText||"Network error",response:{status:p.status||0,data:p.responseText||"Network error"}},b=await d._applyErrorInterceptors(_);u(b)}catch(_){u(_)}},p.send(s==="GET"?null:a)})}async _applySuccessInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return e;let t=e;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(t=await a.fulfilled(t));return t}async _applyErrorInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return Promise.reject(e);let t=e;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const l=i[a];if(l.rejected)try{if(t=await l.rejected(t),t!==void 0)return t}catch(o){t=o}}return Promise.reject(t)}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(n=>{const a=n.getAttribute("name");if(a&&typeof n.files<"u"&&n.files){const l=n.files;if(l.length>0){const o=Array.from(l);t[a]&&Array.isArray(t[a])?o.forEach(d=>{t[a].some(m=>m.name===d.name&&m.size===d.size&&m.lastModified===d.lastModified)||t[a].push(d)}):t[a]=o}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(n=>{const a=n.name;if(a&&n.files&&n.files.length>0){const l=Array.from(n.files);t[a]&&Array.isArray(t[a])?l.forEach(o=>{t[a].some(c=>c.name===o.name&&c.size===o.size&&c.lastModified===o.lastModified)||t[a].push(o)}):t[a]=l}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(n=>{const a=n.getAttribute("name");if(a){let l=[];if(typeof n.tags<"u"?l=n.tags:typeof n.getTags=="function"&&(l=n.getTags()),Array.isArray(l)&&l.length>0){const o=l.map(d=>typeof d=="string"?d:(d==null?void 0:d.value)||(d==null?void 0:d.label)||"").filter(d=>d.trim()!=="");t[a]=o}else t[a]=[]}})),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(n=>n.tagName==="MINT-SELECT");if(i.length>0){const n=[];return i.forEach(a=>{const l=a.querySelector('select[name="'+e+'"]');l&&n.push(l)}),t.filter(a=>a.tagName!=="MINT-SELECT").concat(n)}if(t.filter(n=>n.tagName==="MINT-TAGS").length>0)return t.filter(n=>n.tagName!=="INPUT"||!n.closest("mint-tags"));const r=t.filter(n=>n.tagName==="INPUT"&&n.closest("mint-tags"));if(r.length>0){const n=[];return r.forEach(a=>{const l=a.closest("mint-tags");l&&!n.includes(l)&&n.push(l)}),t.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(n)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===e.length){const a=s.filter(l=>l.checked);if(s.every(l=>l.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(l=>l.type==="checkbox"))return a.map(l=>l.value||"on")}const r=e.filter(a=>a.tagName==="MINT-CHOICE");if(r.length>0&&r.length===e.length){const a=r.find(l=>typeof l.getValue=="function"?l.getValue()!=="":l.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const l=a.querySelector("mint-choice-option[checked]");if(l)return l.getAttribute("value")||""}return""}const n=e.filter(a=>a.tagName==="MINT-CHECKBOX");if(n.length>0&&n.length===e.length)return n.filter(l=>typeof l.checked<"u"?l.checked:l.hasAttribute("checked")).map(l=>l.getAttribute("value")||"on")}const i=e[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 n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}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(n=>typeof n=="string"?n:(n==null?void 0:n.value)||(n==null?void 0:n.label)||"").filter(n=>n.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(e,t){e.length!==0&&e.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",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e=="object"&&!Array.isArray(e)){this._formData=e;return}if(typeof e=="string")try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const e=()=>{Object.entries(this._formData).forEach(([t,i])=>{const s=this._getFieldElements(t);if(s.length===0){setTimeout(()=>{const r=this._getFieldElements(t);r.length>0&&this._applyValueToField(r,t,i)},300);return}this._applyValueToField(s,t,i)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(e,t,i){e.forEach(s=>{var n;const r=s.tagName;try{if(r==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(r==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-SELECT"||r==="SELECT")r==="SELECT"?(n=s.closest("mint-select"))==null||n.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(l=>{l.checked=l.getAttribute("value")===i});else if(r==="MINT-CHECKBOX"||r==="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 r==="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 ${t}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof t.checked<"u")t.checked=!1;else{t.removeAttribute("checked");const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof t.setValue=="function"?t.setValue(""):t.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{t.tags=[]}catch{}})}_resolveHost(e){if(e.tagName==="MINT-CHOICE-OPTION"){const i=e.closest("mint-choice");if(i)return i}const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),d=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),c=!!r.closest("mint-tags"),m=r.tagName==="MINT-CHECKBOX"||r.tagName==="MINT-SWITCH"||r.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=r.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(o||d||c||m||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}const a=this._findFieldElement(s);if(!a)return;const l=this._getFieldName(a);!l||!this._collectValidationRules()[l]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(l)},0)};this._form.addEventListener("change",t,!0),this._form.addEventListener("tags-change",t,!0),this._form.addEventListener("choice-change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener("change",e,!0),this._form.removeEventListener("tags-change",e,!0),this._form.removeEventListener("choice-change",e,!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(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const e=this.getAttribute("loading"),t=e!==null&&e!=="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=>{t?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const e=Array.from(this._form.querySelectorAll("mint-button")),t=Array.from(this._form.querySelectorAll("button"));e.forEach(i=>{const s=i.hasAttribute("disabled"),r=i.hasAttribute("loading");this._buttonStates.set(i,{disabled:s,loading:r});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled",""),a&&i.setAttribute("loading",""),typeof i.render=="function"&&i.render()}),t.forEach(i=>{const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){this._form&&(this._buttonStates.forEach((e,t)=>{var i;(i=this._form)!=null&&i.contains(t)&&(t.tagName==="MINT-BUTTON"?(e.disabled?t.setAttribute("disabled",""):t.removeAttribute("disabled"),e.loading?t.setAttribute("loading",""):t.removeAttribute("loading"),typeof t.render=="function"&&t.render()):t instanceof HTMLButtonElement&&(t.disabled=e.disabled))}),this._buttonStates.clear())}}customElements.get("mint-form")||customElements.define("mint-form",ee);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,e){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:e}),window.mintForm.interceptors.response.handlers.length-1}));class te 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","border","border-gray-200","rounded-lg","dark:border-gray-700"),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 e=this.querySelector("table");if(!e){this._observer&&this._observeChanges();return}const t=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],r=e.querySelector("thead tr");r&&r.querySelectorAll("th").forEach(d=>s.push((d.textContent||"").trim())),this._setClasses(e,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","rounded-lg","border-2","border-gray-200","dark:border-gray-700","overflow-hidden"]);const n=e.querySelector("thead");n&&(this._setClasses(n,["bg-[#F7F7F7]","dark:bg-gray-800"]),n.querySelectorAll("th").forEach(d=>{this._setClasses(d,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"])}));const a=e.querySelector("tbody");if(a){const o=Array.from(a.querySelectorAll("tr"));o.forEach((d,c)=>{this._setClasses(d,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),c===o.length-1&&d.classList.remove("border-b"),d.querySelectorAll("td").forEach(h=>{this._setClasses(h,["text-gray-900","dark:text-gray-100","px-3","py-2"]),t?this._applyMobileCell(h,s):this._restoreCell(h)})})}const l=e.querySelector("tfoot");l&&(this._setClasses(l,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(d=>{this._setClasses(d,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(d)})),this._observer&&this._observeChanges()}_applyMobileCell(e,t){if(e.closest("tfoot")||e.dataset.mtProcessed==="true")return;const i=t[e.cellIndex]||"",s=e.getAttribute("data-original"),r=s!==null?s:e.innerHTML;e.setAttribute("data-original",r),e.dataset.mtProcessed="true",e.innerHTML="";const n=document.createElement("span");n.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",n.textContent=i;const a=document.createElement("span");a.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",a.innerHTML=r,e.appendChild(n),e.appendChild(a)}_restoreCell(e){if(e.dataset.mtProcessed!=="true")return;const t=e.getAttribute("data-original")||"";e.dataset.mtProcessed="",e.innerHTML=t}_setClasses(e,t){e.className="",t.filter(Boolean).forEach(i=>e.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const e=document.createElement("style");e.id="mint-table-responsive-style",e.textContent=`
|
|
68
|
+
`,g.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 C=document.createElement("div");C.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",E.appendChild(C);const A=document.createElement("div");A.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",E.appendChild(A);const T=document.createElement("div");T.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",E.appendChild(T);const S=document.createElement("div");S.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",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=g.scrollTop,I=g.scrollHeight,N=g.clientHeight;D>0?T.style.opacity="1":T.style.opacity="0",D+N<I-1?S.style.opacity="1":S.style.opacity="0",C.style.opacity="0",A.style.opacity="0"}else{const D=g.scrollLeft,I=g.scrollWidth,N=g.clientWidth;D>0?C.style.opacity="1":C.style.opacity="0",D+N<I-1?A.style.opacity="1":A.style.opacity="0",T.style.opacity="0",S.style.opacity="0"}};g.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),r.forEach(L=>{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=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const I=L.action();if(I){if(this._isRange&&"start"in I&&"end"in I){this._selectedStartDate=I.start,this._selectedEndDate=I.end;const N=this.getFormat(),M=this._formatDate(I.start,N),ae=this._formatDate(I.end,N),oe=`${M} - ${ae}`;this.setValue(oe),this._currentMonth=I.start.getMonth(),this._currentYear=I.start.getFullYear()}else if(I instanceof Date){this._selectedStartDate=I,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(I,N);this.setValue(M),this._currentMonth=I.getMonth(),this._currentYear=I.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}))}}),g.appendChild(D)}),E.appendChild(g),k.appendChild(E),a.appendChild(k)}l.appendChild(o),l.appendChild(_),l.appendChild(b),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.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()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.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",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.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",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,d)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentMonth===d;c.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 ${m?"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"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=d,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=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 r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);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 l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",a.appendChild(l),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2";for(let d=e;d<=t;d++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentYear===d;c.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 ${m?"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"}`,c.textContent=String(d),c.addEventListener("click",()=>{this._currentYear=d,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),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}))}_updateDisplayText(){if(!this._displayEl)return;const e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,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 e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.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(e){let t=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let r=t.querySelector(".mint-date-picker-skeleton");r||(r=document.createElement("div"),r.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",r.style.height="2.25rem",t.appendChild(r)),t.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 t&&(t.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 e=["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(e)).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 e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[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",K);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=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()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="loading"){this.render();return}if(e==="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(e){const t=e||"";this.setAttribute("value",t),this._select&&(this._select.value=t)}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 e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"pr-10",t?"py-2":"py-1.5",t?"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",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"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,...r].filter(Boolean).join(" ")}render(){const e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&t.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(),r=this.getInfo(),n=this.getId(),a=this.getName(),l=this.getValue(),o=this.isDisabled(),d=this.isMultiple(),c=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",n&&h.setAttribute("for",n);const f=document.createTextNode(s);h.appendChild(f),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(),n&&(this._select.id=n),a&&(this._select.name=a),o&&(this._select.disabled=!0),d&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",c?"true":"false");const m=t.length>0?t:i;if(m.length>0&&m.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=l||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const u=h.target.value;u?this.setAttribute("value",u):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:u},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),d)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(r){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=r,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(e){t||(t=document.createElement("div"),t.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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 r=this.isMultiple();s.style.height=r?"6rem":"2.25rem",t.appendChild(s)}t.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else t&&(t.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q 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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e==="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(e){let t=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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%",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),l=this._fileInput;if(r){const o=r;o.style.visibility="hidden",o.style.pointerEvents="none"}if(n){const o=n;o.style.visibility="hidden",o.style.pointerEvents="none"}if(a){const o=a;o.style.visibility="hidden",o.style.pointerEvents="none"}l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(t&&(t.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),n=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const l=s;l.style.visibility="visible",l.style.pointerEvents="auto"}if(r){const l=r;l.style.visibility="visible",l.style.pointerEvents="auto"}if(n){const l=n;l.style.visibility="visible",l.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 e=this.isLoading(),t=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),r=this.isDisabled(),n=this.getWidth(),a=this.getHeight(),l=this.getName(),o=this.hasError(),d=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",o?"true":"false"),r?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",t||"File upload dropzone")),this._dropzone.style.width=n,this._dropzone.style.height=a,this._dropzone.style.minWidth=n,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=r,l?this._fileInput.name=l:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",o?"true":"false");const c=this._dropzone.querySelector(".mint-dropzone-icon"),m=this._dropzone.querySelector(".mint-dropzone-label");c&&c.remove(),m&&m.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const f=document.createElement("mint-icon");if(f.setAttribute("name","upload"),f.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(f),this._dropzone.appendChild(h),t){const u=document.createElement("div");u.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",u.textContent=t,this._dropzone.appendChild(u)}this.setupEventListeners(),this._renderErrorState(o,d),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(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=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`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`,n=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=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"",o="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=`${r} ${t?a:n} ${l} ${o}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onKeyDown||(this._onKeyDown=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onFocus||(this._onFocus=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=e=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.splice(1)),a.length>0){const l=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(l)}n.length>0&&this._applyValidFiles(n)}}),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(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.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 e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.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((o,d)=>{const c=document.createElement("div");if(c.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",o.type.startsWith("image/")){const u=document.createElement("img");u.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const p=URL.createObjectURL(o);this._previewUrls.push(p),u.src=p,c.appendChild(u)}else{const u=document.createElement("mint-icon");u.setAttribute("name","attach"),u.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(u)}const m=document.createElement("div");m.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",m.textContent=o.name,c.appendChild(m);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 f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",h.appendChild(f),h.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this._removeFileAt(d)}),c.appendChild(h),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);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 ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,d=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<d-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[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(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class ee 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}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const e=this.getAttribute("headers");e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._applyFormData();else{const t=this.getAttribute("data-form-data");t&&(this._parseFormData(t),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()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){e==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e==="headers"?this._parseHeaders(i):e==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){e&&typeof e=="object"&&!Array.isArray(e)?this._formData=e:e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e=="object"&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e=="string")try{this._headers=JSON.parse(e)}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=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const a=this.getAttribute("action"),l=this.getAttribute("method");if(!(!a||!l)){this._setButtonsSubmitting();try{const o=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:o,bubbles:!0,cancelable:!0}))}catch(o){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:o},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){var c,m,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(f=>f instanceof File);let a=null;const l={};let o=i;if(typeof window<"u"&&((h=(m=(c=window.mintForm)==null?void 0:c.defaults)==null?void 0:m.headers)!=null&&h.common)&&Object.assign(l,window.mintForm.defaults.headers.common),this._headers&&Object.assign(l,this._headers),s==="GET"){const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),o+=(i.includes("?")?"&":"?")+f.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),a=f,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const f=await fetch(o,{method:s||"POST",body:s==="GET"?null:a,headers:l}),u=await f.text().catch(()=>"");let p=u;try{p=JSON.parse(u)}catch{}if(!f.ok){const b={status:f.status,data:p,response:{status:f.status,data:p}};throw await this._applyErrorInterceptors(b)}const _={status:f.status,ok:f.ok,data:p};return await this._applySuccessInterceptors(_)}catch(f){if(f.response)throw f;const u={status:f.status||0,data:f.data||f.message||"Network error",response:{status:f.status||0,data:f.data||f.message||"Network error"}};throw await this._applyErrorInterceptors(u)}const d=this;return await new Promise(async(f,u)=>{const p=new XMLHttpRequest;p.open(s||"POST",o,!0),Object.entries(l).forEach(([_,b])=>p.setRequestHeader(_,b)),p.onload=async function(){const{status:_,responseText:b}=p;if(_>=200&&_<300){let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,ok:!0,data:y},k=await d._applySuccessInterceptors(x);f(k)}catch(x){u(x)}}else{let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,data:y,response:{status:_,data:y}},k=await d._applyErrorInterceptors(x);u(k)}catch(x){u(x)}}},p.onerror=async function(){try{const _={status:p.status||0,data:p.responseText||"Network error",response:{status:p.status||0,data:p.responseText||"Network error"}},b=await d._applyErrorInterceptors(_);u(b)}catch(_){u(_)}},p.send(s==="GET"?null:a)})}async _applySuccessInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return e;let t=e;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(t=await a.fulfilled(t));return t}async _applyErrorInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return Promise.reject(e);let t=e;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const l=i[a];if(l.rejected)try{if(t=await l.rejected(t),t!==void 0)return t}catch(o){t=o}}return Promise.reject(t)}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(n=>{const a=n.getAttribute("name");if(a&&typeof n.files<"u"&&n.files){const l=n.files;if(l.length>0){const o=Array.from(l);t[a]&&Array.isArray(t[a])?o.forEach(d=>{t[a].some(m=>m.name===d.name&&m.size===d.size&&m.lastModified===d.lastModified)||t[a].push(d)}):t[a]=o}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(n=>{const a=n.name;if(a&&n.files&&n.files.length>0){const l=Array.from(n.files);t[a]&&Array.isArray(t[a])?l.forEach(o=>{t[a].some(c=>c.name===o.name&&c.size===o.size&&c.lastModified===o.lastModified)||t[a].push(o)}):t[a]=l}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(n=>{const a=n.getAttribute("name");if(a){let l=[];if(typeof n.tags<"u"?l=n.tags:typeof n.getTags=="function"&&(l=n.getTags()),Array.isArray(l)&&l.length>0){const o=l.map(d=>typeof d=="string"?d:(d==null?void 0:d.value)||(d==null?void 0:d.label)||"").filter(d=>d.trim()!=="");t[a]=o}else t[a]=[]}})),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(n=>n.tagName==="MINT-SELECT");if(i.length>0){const n=[];return i.forEach(a=>{const l=a.querySelector('select[name="'+e+'"]');l&&n.push(l)}),t.filter(a=>a.tagName!=="MINT-SELECT").concat(n)}if(t.filter(n=>n.tagName==="MINT-TAGS").length>0)return t.filter(n=>n.tagName!=="INPUT"||!n.closest("mint-tags"));const r=t.filter(n=>n.tagName==="INPUT"&&n.closest("mint-tags"));if(r.length>0){const n=[];return r.forEach(a=>{const l=a.closest("mint-tags");l&&!n.includes(l)&&n.push(l)}),t.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(n)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===e.length){const a=s.filter(l=>l.checked);if(s.every(l=>l.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(l=>l.type==="checkbox"))return a.map(l=>l.value||"on")}const r=e.filter(a=>a.tagName==="MINT-CHOICE");if(r.length>0&&r.length===e.length){const a=r.find(l=>typeof l.getValue=="function"?l.getValue()!=="":l.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const l=a.querySelector("mint-choice-option[checked]");if(l)return l.getAttribute("value")||""}return""}const n=e.filter(a=>a.tagName==="MINT-CHECKBOX");if(n.length>0&&n.length===e.length)return n.filter(l=>typeof l.checked<"u"?l.checked:l.hasAttribute("checked")).map(l=>l.getAttribute("value")||"on")}const i=e[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 n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}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(n=>typeof n=="string"?n:(n==null?void 0:n.value)||(n==null?void 0:n.label)||"").filter(n=>n.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(e,t){e.length!==0&&e.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",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e=="object"&&!Array.isArray(e)){this._formData=e;return}if(typeof e=="string")try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const e=()=>{Object.entries(this._formData).forEach(([t,i])=>{const s=this._getFieldElements(t);if(s.length===0){setTimeout(()=>{const r=this._getFieldElements(t);r.length>0&&this._applyValueToField(r,t,i)},300);return}this._applyValueToField(s,t,i)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(e,t,i){e.forEach(s=>{var n;const r=s.tagName;try{if(r==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(r==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-SELECT"||r==="SELECT")r==="SELECT"?(n=s.closest("mint-select"))==null||n.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(l=>{l.checked=l.getAttribute("value")===i});else if(r==="MINT-CHECKBOX"||r==="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 r==="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 ${t}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof t.checked<"u")t.checked=!1;else{t.removeAttribute("checked");const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof t.setValue=="function"?t.setValue(""):t.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{t.tags=[]}catch{}})}_resolveHost(e){if(e.tagName==="MINT-CHOICE-OPTION"){const i=e.closest("mint-choice");if(i)return i}const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),d=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),c=!!r.closest("mint-tags"),m=r.tagName==="MINT-CHECKBOX"||r.tagName==="MINT-SWITCH"||r.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=r.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(o||d||c||m||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}const a=this._findFieldElement(s);if(!a)return;const l=this._getFieldName(a);!l||!this._collectValidationRules()[l]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(l)},0)};this._form.addEventListener("change",t,!0),this._form.addEventListener("tags-change",t,!0),this._form.addEventListener("choice-change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener("change",e,!0),this._form.removeEventListener("tags-change",e,!0),this._form.removeEventListener("choice-change",e,!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(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const e=this.getAttribute("loading"),t=e!==null&&e!=="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=>{t?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=i.hasAttribute("disabled"),r=i.hasAttribute("loading");this._buttonStates.set(i,{disabled:s,loading:r});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled",""),a&&i.setAttribute("loading",""),typeof i.render=="function"&&i.render()}),t.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 e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled",""):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading",""):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),t.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}}customElements.get("mint-form")||customElements.define("mint-form",ee);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,e){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:e}),window.mintForm.interceptors.response.handlers.length-1}));class te 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","border","border-gray-200","rounded-lg","dark:border-gray-700"),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 e=this.querySelector("table");if(!e){this._observer&&this._observeChanges();return}const t=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],r=e.querySelector("thead tr");r&&r.querySelectorAll("th").forEach(d=>s.push((d.textContent||"").trim())),this._setClasses(e,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","rounded-lg","border-2","border-gray-200","dark:border-gray-700","overflow-hidden"]);const n=e.querySelector("thead");n&&(this._setClasses(n,["bg-[#F7F7F7]","dark:bg-gray-800"]),n.querySelectorAll("th").forEach(d=>{this._setClasses(d,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"])}));const a=e.querySelector("tbody");if(a){const o=Array.from(a.querySelectorAll("tr"));o.forEach((d,c)=>{this._setClasses(d,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),c===o.length-1&&d.classList.remove("border-b"),d.querySelectorAll("td").forEach(h=>{this._setClasses(h,["text-gray-900","dark:text-gray-100","px-3","py-2"]),t?this._applyMobileCell(h,s):this._restoreCell(h)})})}const l=e.querySelector("tfoot");l&&(this._setClasses(l,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(d=>{this._setClasses(d,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(d)})),this._observer&&this._observeChanges()}_applyMobileCell(e,t){if(e.closest("tfoot")||e.dataset.mtProcessed==="true")return;const i=t[e.cellIndex]||"",s=e.getAttribute("data-original"),r=s!==null?s:e.innerHTML;e.setAttribute("data-original",r),e.dataset.mtProcessed="true",e.innerHTML="";const n=document.createElement("span");n.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",n.textContent=i;const a=document.createElement("span");a.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",a.innerHTML=r,e.appendChild(n),e.appendChild(a)}_restoreCell(e){if(e.dataset.mtProcessed!=="true")return;const t=e.getAttribute("data-original")||"";e.dataset.mtProcessed="",e.innerHTML=t}_setClasses(e,t){e.className="",t.filter(Boolean).forEach(i=>e.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const e=document.createElement("style");e.id="mint-table-responsive-style",e.textContent=`
|
|
69
69
|
@media (max-width: 640px) {
|
|
70
70
|
mint-table[collapse] {
|
|
71
71
|
display: block;
|
package/dist/index.js
CHANGED
|
@@ -4652,22 +4652,29 @@ class re extends HTMLElement {
|
|
|
4652
4652
|
_setButtonsSubmitting() {
|
|
4653
4653
|
if (!this._form) return;
|
|
4654
4654
|
this._buttonStates.clear();
|
|
4655
|
-
const e = Array.from(this.
|
|
4655
|
+
const e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
|
|
4656
4656
|
e.forEach((i) => {
|
|
4657
4657
|
const s = i.hasAttribute("disabled"), r = i.hasAttribute("loading");
|
|
4658
4658
|
this._buttonStates.set(i, { disabled: s, loading: r });
|
|
4659
4659
|
const a = (i.getAttribute("type") || i.getAttribute("button-type") || "default") === "submit";
|
|
4660
4660
|
s || i.setAttribute("disabled", ""), a && i.setAttribute("loading", ""), typeof i.render == "function" && i.render();
|
|
4661
4661
|
}), t.forEach((i) => {
|
|
4662
|
+
if (i.closest("mint-button")) return;
|
|
4662
4663
|
const s = i.disabled;
|
|
4663
4664
|
this._buttonStates.set(i, { disabled: s, loading: !1 }), s || (i.disabled = !0);
|
|
4664
4665
|
});
|
|
4665
4666
|
}
|
|
4666
4667
|
_restoreButtonsState() {
|
|
4667
|
-
|
|
4668
|
-
|
|
4669
|
-
|
|
4670
|
-
|
|
4668
|
+
if (!this._form) return;
|
|
4669
|
+
const e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
|
|
4670
|
+
e.forEach((i) => {
|
|
4671
|
+
const s = this._buttonStates.get(i);
|
|
4672
|
+
s && (s.disabled ? i.setAttribute("disabled", "") : i.removeAttribute("disabled"), s.loading ? i.setAttribute("loading", "") : i.removeAttribute("loading"), typeof i.render == "function" && i.render());
|
|
4673
|
+
}), t.forEach((i) => {
|
|
4674
|
+
if (i.closest("mint-button")) return;
|
|
4675
|
+
const s = this._buttonStates.get(i);
|
|
4676
|
+
s && (i.disabled = s.disabled);
|
|
4677
|
+
}), this._buttonStates.clear();
|
|
4671
4678
|
}
|
|
4672
4679
|
}
|
|
4673
4680
|
customElements.get("mint-form") || customElements.define("mint-form", re);
|