monobill-mintui 0.3.38 → 0.3.39
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/index.cjs +6 -6
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +376 -227
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const xt=require("./caret-right-BsS-59-c.cjs");class G extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["size","data-button-variant","data-button-tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getSize(){const t=this.getAttribute("size")||"default",e={default:"w-4 h-4",large:"w-16 h-16"};return e[t]||e.default}render(){const t=this.getSize(),e=this.getAttribute("size")||"default",i=!!(this.style.width&&this.style.height),s=this.getAttribute("data-button-variant"),n=document.documentElement.classList.contains("dark");let r;if(i){const c=this.getAttribute("data-button-tone")||"neutral";s==="solid"?c==="neutral"?r=n?"#ffffff":"#0f172a":r="#ffffff":r=n?"#ffffff":"#0f172a"}else r=n?"#e2e8f0":"#0f172a";const a=e==="large"?"2":"4",o=!!(this.style.width&&this.style.height),l=`
|
|
2
2
|
<svg
|
|
3
3
|
xmlns="http://www.w3.org/2000/svg"
|
|
4
4
|
fill="none"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
<path d="${t.path}" />
|
|
52
52
|
</svg>`:e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="none" stroke="currentColor" stroke-width="${t.strokeWidth||"2"}" stroke-linecap="${t.strokeLinecap||"round"}" stroke-linejoin="${t.strokeLinejoin||"round"}">
|
|
53
53
|
<path d="${t.path}" />
|
|
54
|
-
</svg>`,e}render(){var l,c,d;const t=this.getName();if(!t){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const e=
|
|
54
|
+
</svg>`,e}render(){var l,c,d;const t=this.getName();if(!t){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const e=xt.getIcon(t);if(!e){console.warn(`Icon "${t}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${t}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const i=this.closest("mint-button")||((l=this.parentElement)==null?void 0:l.closest("mint-button")),s=this.closest("mint-switch")||((c=this.parentElement)==null?void 0:c.closest("mint-switch")),n=this.closest("mint-select")||((d=this.parentElement)==null?void 0:d.closest("mint-select"));if(!Array.from(this.classList).some(p=>p.startsWith("w-")||p.startsWith("h-"))&&!n){let p;s?p="w-3 h-3":i?p="w-5 h-5":p="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]","w-[1.3em]","h-[1.3em]","w-3","h-3"),p.split(" ").forEach(h=>{h&&this.classList.add(h)})}const a=this.generateSVGMarkup(e);this.innerHTML=a,this.style.maskImage="",this.style.webkitMaskImage="",this.style.maskSize="",this.style.webkitMaskSize="",this.style.maskRepeat="",this.style.webkitMaskRepeat="",this.style.maskPosition="",this.style.webkitMaskPosition="",this.style.backgroundColor="",this.style.aspectRatio="1 / 1";const o=this.querySelector("svg");if(o&&(o.style.width="100%",o.style.height="100%"),s)this.classList.remove("text-gray-100","text-gray-900"),this.classList.add("text-gray-900");else if(i)this.classList.remove("text-gray-100","text-gray-900");else{const h=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(h)}}}customElements.get("mint-icon")||customElements.define("mint-icon",J);const W=class W extends HTMLElement{constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleMouseUp=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleMouseLeave=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleTouchEnd=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleTouchCancel=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon","active"]}connectedCallback(){if(!W._activeShadowStyleInjected){const t=document.createElement("style");t.textContent=`
|
|
55
55
|
mint-button .mint-button-active {
|
|
56
56
|
box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3) !important;
|
|
57
57
|
}
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
mint-button[data-variant="link"] .mint-button-active {
|
|
63
63
|
box-shadow: none !important;
|
|
64
64
|
}
|
|
65
|
-
`,document.head.appendChild(t),W._activeShadowStyleInjected=!0}this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add("w-full")}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}getType(){const t=this.getAttribute("type"),e=this.getAttribute("button-type");return(t||e||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}isActive(){const t=this.getAttribute("active");return!(t===null||t==="false"||t==="0")}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.removeAttribute("active")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,n,r,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const e=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(e&&((n=e.textContent)!=null&&n.trim()))return!1;if(this._button)for(let o=this._button.firstChild;o;o=o.nextSibling){if(o.nodeType===Node.TEXT_NODE&&((r=o.textContent)!=null&&r.trim()))return!1;if(o.nodeType===Node.ELEMENT_NODE){const l=o;if(l.tagName!=="MINT-ICON"&&l.tagName!=="MINT-SPINNER"&&!l.querySelector("mint-spinner")&&!l.hasAttribute("slot")&&l.className!=="mint-button-icon"&&!(l.className==="mr-2"&&l.querySelector("mint-spinner"))&&(a=l.textContent)!=null&&a.trim())return!1}}return!0}getActiveStateClasses(){const t=this.getVariant(),e=this.getTone(),i=`${t}-${e}`;return{"solid-action":["!bg-slate-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-slate-700","hover:!bg-slate-900","dark:hover:!bg-slate-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-neutral":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"solid-info":["!bg-blue-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-blue-700","hover:!bg-blue-900","dark:hover:!bg-blue-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-warning":["!bg-amber-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-amber-700","hover:!bg-amber-900","dark:hover:!bg-amber-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-danger":["!bg-red-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-red-700","hover:!bg-red-900","dark:hover:!bg-red-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"ghost-action":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-neutral":["!bg-gray-50","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","!text-gray-900","dark:!text-white","hover:!bg-gray-50","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","hover:!text-gray-900","dark:hover:!text-white"],"ghost-info":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-warning":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-danger":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"link-action":["!text-slate-900","dark:!text-slate-300","hover:!text-slate-900","dark:hover:!text-slate-300"],"link-neutral":["!text-gray-950","dark:!text-gray-200","hover:!text-gray-950","dark:hover:!text-gray-200"],"link-info":["!text-blue-900","dark:!text-blue-200","hover:!text-blue-900","dark:hover:!text-blue-200"],"link-warning":["!text-amber-900","dark:!text-amber-200","hover:!text-amber-900","dark:hover:!text-amber-200"],"link-danger":["!text-red-900","dark:!text-red-200","hover:!text-red-900","dark:hover:!text-red-200"]}[i]||[]}getButtonClasses(){const t=this.isIconOnly(),e=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...t?["p-1.5","aspect-square","w-[2.25rem]","h-[2.25rem]"]:["px-3.5","py-1.5","min-h-[2.25rem]"],"text-sm","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","[&.mint-button-active>*]:scale-95","[&>*]:transition-transform","[&>*]:duration-100","disabled:opacity-50","disabled:cursor-not-allowed"],s=this.getTone(),n={"solid-action":["bg-slate-800","dark:bg-slate-600","text-white","hover:bg-slate-950","dark:hover:bg-slate-700","active:bg-slate-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-slate-700","disabled:active:bg-slate-800","dark:disabled:active:bg-slate-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-neutral":["bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","hover:bg-gray-50","dark:hover:bg-gray-600","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-white","dark:disabled:active:bg-gray-700","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-gray-200","dark:border-gray-600"],"solid-info":["bg-blue-800","dark:bg-blue-600","text-white","hover:bg-blue-950","dark:hover:bg-blue-700","active:bg-blue-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-blue-700","disabled:active:bg-blue-800","dark:disabled:active:bg-blue-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-warning":["bg-amber-800","dark:bg-amber-600","text-white","hover:bg-amber-950","dark:hover:bg-amber-700","active:bg-amber-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-amber-700","disabled:active:bg-amber-800","dark:disabled:active:bg-amber-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-danger":["bg-red-800","dark:bg-red-600","text-white","hover:bg-red-950","dark:hover:bg-red-700","active:bg-red-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-red-700","disabled:active:bg-red-800","dark:disabled:active:bg-red-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"ghost-action":["bg-transparent","text-slate-800","dark:text-slate-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-neutral":["bg-transparent","text-gray-700","dark:text-gray-200","active:bg-gray-50","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","active:text-gray-900","dark:active:text-white","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-info":["bg-transparent","text-blue-800","dark:text-blue-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-warning":["bg-transparent","text-amber-800","dark:text-amber-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-danger":["bg-transparent","text-red-800","dark:text-red-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-action":["bg-transparent","text-slate-800","dark:text-slate-400","hover:text-slate-950","dark:hover:text-slate-200","active:text-slate-900","dark:active:text-slate-300","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-neutral":["bg-transparent","text-gray-700","dark:text-gray-300","hover:text-gray-900","dark:hover:text-gray-100","active:text-gray-950","dark:active:text-gray-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-info":["bg-transparent","text-blue-800","dark:text-blue-400","hover:text-blue-950","dark:hover:text-blue-300","active:text-blue-900","dark:active:text-blue-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-warning":["bg-transparent","text-amber-800","dark:text-amber-400","hover:text-amber-950","dark:hover:text-amber-300","active:text-amber-900","dark:active:text-amber-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-danger":["bg-transparent","text-red-800","dark:text-red-400","hover:text-red-950","dark:hover:text-red-300","active:text-red-900","dark:active:text-red-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"]},r=`${e}-${s}`,a=n[r]||n["solid-neutral"],o=[...i,...a];if(this.isActive()){const l=this.getActiveStateClasses();o.push(...l),o.push("[&>*]:scale-95")}return this.isFullWidth()&&o.push("w-full"),o.join(" ")}render(){var d,u,h,f,p,m;const t=this.isDisabled()||this.isLoading(),e=this.getType();if(!this._button){for(this._button=document.createElement("button");this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=e,this._button.disabled=t;let i=this._button.querySelector("mint-spinner");const s=this.isLoading();if(s)if(i)i.setAttribute("data-button-variant",this.getVariant()),i.setAttribute("data-button-tone",this.getTone()),"render"in i&&typeof i.render=="function"&&i.render();else{const _=document.createElement("span");_.className="mr-2 inline-flex items-center";const g=document.createElement("mint-spinner");g.setAttribute("size","default"),g.setAttribute("data-button-variant",this.getVariant()),g.setAttribute("data-button-tone",this.getTone()),g.style.width="0.875rem",g.style.height="0.875rem",_.appendChild(g),this._button.insertBefore(_,this._button.firstChild)}else i&&((d=i.parentElement)==null||d.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const n=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');n?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",n),r.className="mint-button-icon"):r.setAttribute("name",n)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const a=this.getIconPosition();let o=this._button.querySelector(".mint-button-content");if(o){const _=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const g=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;_||a==="left"?g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o):o.insertAdjacentElement("afterend",r)}else if(r&&(_||a==="left")&&r.nextSibling!==o){r.remove();const g=(p=this._button.querySelector("mint-spinner"))==null?void 0:p.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o)}else r&&!_&&a==="right"&&r.previousSibling!==o&&(r.remove(),o.insertAdjacentElement("afterend",r))}else{const _=[];for(let g=this._button.firstChild;g;g=g.nextSibling){if(g.nodeType!==Node.ELEMENT_NODE){_.push(g);continue}const v=g;v.tagName!=="MINT-SPINNER"&&!v.querySelector("mint-spinner")&&g!==r&&!v.hasAttribute("slot")&&!(v.className==="mr-2"&&v.querySelector("mint-spinner"))&&_.push(g)}if(_.length>0){o=document.createElement("span"),o.className="mint-button-content inline-flex items-center",_.forEach(v=>{o.appendChild(v)});const g=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;r&&a==="left"?g?(g.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",o)):r&&a==="right"?g?(g.insertAdjacentElement("afterend",o),o.insertAdjacentElement("afterend",r)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement("afterend",r)):g?g.insertAdjacentElement("afterend",o):this._button.insertBefore(o,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const g=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();if(r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),s?r.style.display="none":r.style.display="",r.classList.remove("mr-1.5","ml-1.5"),l?r.tagName==="MINT-ICON"?(r.style.width="1rem",r.style.height="1rem",r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0"):(r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0",r.tagName==="svg"&&(r.style.width="1rem",r.style.height="1rem")):a==="left"?r.classList.add("mr-1.5"):r.classList.add("ml-1.5")),s){const _=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;_&&(l?(_.classList.remove("mr-2"),_.classList.add("mr-0")):_.classList.contains("mr-2")||(_.classList.remove("mr-0"),_.classList.add("mr-2")))}const c=this.getButtonClasses();this._button.className=c,this.setAttribute("data-variant",this.getVariant()),this.setAttribute("data-tone",this.getTone()),this.isActive()?this._button.classList.add("mint-button-active"):this._button.classList.remove("mint-button-active")}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener("click",this._clickHandler,!0),this._button.addEventListener("mousedown",this._handleMouseDown),this._button.addEventListener("mouseup",this._handleMouseUp),this._button.addEventListener("mouseleave",this._handleMouseLeave),this._button.addEventListener("touchstart",this._handleTouchStart),this._button.addEventListener("touchend",this._handleTouchEnd),this._button.addEventListener("touchcancel",this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&(this._button.removeEventListener("click",this._clickHandler,!0),this._clickHandler=null),this._button.removeEventListener("mousedown",this._handleMouseDown),this._button.removeEventListener("mouseup",this._handleMouseUp),this._button.removeEventListener("mouseleave",this._handleMouseLeave),this._button.removeEventListener("touchstart",this._handleTouchStart),this._button.removeEventListener("touchend",this._handleTouchEnd),this._button.removeEventListener("touchcancel",this._handleTouchCancel))}handleClick(t){if(this.isDisabled()||this.isLoading()){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0}));return}if(t.stopPropagation(),t.stopImmediatePropagation(),this._isHandlingClick){t.preventDefault();return}this._isHandlingClick=!0,t.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};W._activeShadowStyleInjected=!1;let j=W;customElements.get("mint-button")||customElements.define("mint-button",j);class K extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._checked=this.hasAttribute("checked"),this.render()}_getSwitchContainer(){let t=this.querySelector(".mint-switch-container");return t||(t=document.createElement("div"),t.className="mint-switch-container flex items-center gap-2",this.insertBefore(t,this.firstChild)),t}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this.render()}catch{}}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getSwitchClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","rounded-full","h-5","w-10","border","transition-colors","duration-200","ease-in-out","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","disabled:opacity-50","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-950","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",t?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...e,...i].join(" ")}getThumbClasses(){const t=["relative","inline-block","rounded-full","bg-white","dark:bg-gray-50","h-4","w-4","shadow-lg","transform","transition-transform","duration-200","ease-in-out","pointer-events-none","overflow-hidden"],e=this._checked?"translate-x-5":"translate-x-0.5";return[...t,e].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const t=this.isLoading(),e=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),n=this.getInfo(),r=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const o=this._getSwitchContainer();this._button?this._button.parentElement!==o&&o.appendChild(this._button):(this._button=document.createElement("button"),o.appendChild(this._button),this.setupEventListeners());let l=o.querySelector(".mint-switch-label");s?(l||(l=document.createElement("label"),l.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===o?o.insertBefore(l,this._button.nextSibling):o.appendChild(l)),l.textContent=s,l.setAttribute("for",a),this.isDisabled()?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove(),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.id=a,this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",s||"Toggle switch"),this._button.setAttribute("role","switch"),this._button.type="button";let c=this._button.querySelector("span");c||(c=document.createElement("span"),this._button.appendChild(c)),c.className=i;const d=c.querySelector("span");if(r){let h=d;h||(h=document.createElement("span"),h.className=this.getIconClasses(),c.appendChild(h));let f=h.querySelector("mint-icon");f||(f=document.createElement("mint-icon"),h.appendChild(f)),f.setAttribute("name",r)}else d&&d.remove();let u=this.querySelector(".mint-switch-info");n?(u||(u=document.createElement("span"),u.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",o&&o.parentElement===this?this.insertBefore(u,o.nextSibling):this.appendChild(u)),u.textContent=n,this.isDisabled()?u.classList.add("opacity-40"):u.classList.remove("opacity-40")):u&&u.remove(),this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(t){if(!this.isDisabled()){this.checked=!this._checked;const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("toggle",{detail:{checked:this._checked},bubbles:!0,cancelable:!0}))}}_renderSkeleton(t){const e=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let n=e.querySelector(".mint-switch-skeleton-container"),r=this.querySelector(".mint-switch-info-skeleton");if(t){e.classList.contains("relative")||e.classList.add("relative"),n||(n=document.createElement("div"),n.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",e.appendChild(n));let a=n.querySelector(".mint-switch-skeleton-box");if(a||(a=document.createElement("div"),a.className="mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(a)),i){let l=n.querySelector(".mint-switch-skeleton-label");l||(l=document.createElement("div"),l.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(l))}else{const l=n.querySelector(".mint-switch-skeleton-label");l&&l.remove()}n.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const o=e.querySelector(".mint-switch-label");if(o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),s){r||(r=document.createElement("div"),r.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",e&&e.parentElement===this?this.insertBefore(r,e.nextSibling):this.appendChild(r)),r.style.display="block";const l=this.querySelector(".mint-switch-info");l&&(l.style.display="none")}else r&&(r.style.display="none")}else{n&&(n.style.display="none"),r&&(r.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=e.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const o=this.querySelector(".mint-switch-info");o&&(o.style.display="")}}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",K);class X extends HTMLElement{constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}static get observedAttributes(){return["variant","size","bold","underline","strike","italic","display"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline"),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getVariant(){return this.getAttribute("variant")||"default"}getSize(){return this.getAttribute("size")||"regular"}isBold(){return this.hasAttribute("bold")}isUnderline(){return this.hasAttribute("underline")}isStrike(){return this.hasAttribute("strike")}isItalic(){return this.hasAttribute("italic")}getDisplay(){return this.hasAttribute("display")?this.getAttribute("display"):this.getSize()==="regular"?"inline-block":"block"}getTextClasses(){const t=this.getSize(),e=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},n={default:i?["text-gray-100"]:["text-gray-900"],muted:i?["text-gray-400"]:["text-gray-400"],danger:i?["text-red-400"]:["text-red-600"],success:i?["text-green-400"]:["text-green-600"]},r=[];this.isBold()&&r.push("font-bold"),this.isUnderline()&&r.push("underline"),this.isStrike()&&r.push("line-through"),this.isItalic()&&r.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[t]||s.regular,...n[e]||n.default,...r].join(" ")}render(){const t=this.getSize(),e=["text-gray-100","text-gray-900","text-gray-400","text-red-400","text-red-600","text-green-400","text-green-600"],i=["text-2xl","text-lg","text-sm"];i.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)}),e.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)});const s=this.getTextClasses().split(" ").filter(l=>l.trim());Array.from(this.classList).forEach(l=>{!e.includes(l)&&!i.includes(l)&&this._userClasses.add(l)});const r=[...new Set([...s,...Array.from(this._userClasses)])];this.className=r.join(" ");const a={heading:"clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)","sub-heading":"clamp(1rem, 1.5vw + 0.5rem, 1.125rem)",regular:"clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"},o=a[t]||a.regular;this.style.setProperty("font-size",o)}}customElements.get("mint-text")||customElements.define("mint-text",X);class Z extends HTMLElement{constructor(){super(),this._childObserver=null}static get observedAttributes(){return["direction","text-align","gap"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(t,e,i){e!==i&&(this.render(),t==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const t=this.getTextAlign();t&&this._applyTextAlignToChildren(t)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&(this._childObserver.disconnect(),this._childObserver=null)}getDirection(){return(this.getAttribute("direction")||"vertical")==="horizontal"?"horizontal":"vertical"}getGap(){const t=this.getAttribute("gap")||"3";return parseFloat(t)}getTextAlign(){const t=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(t)?t:""}getStackClasses(){const t=this.getDirection(),e=this.getTextAlign(),i=this.getGap(),s=["flex",t==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return e&&(s.push(`text-${e}`),s.push(`[&>*]:text-${e}`),s.push(`[&>*_.mint-button-content]:text-${e}`),e==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):e==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):e==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const t=this.getStackClasses(),e=this.getTextAlign();["flex","flex-row","flex-col","gap-1","gap-2","gap-3","text-left","text-center","text-right","text-justify","[&>*]:text-left","[&>*]:text-center","[&>*]:text-right","[&>*]:text-justify","[&>*_.mint-button-content]:text-left","[&>*_.mint-button-content]:text-center","[&>*_.mint-button-content]:text-right","[&>*_.mint-button-content]:text-justify","[&>mint-button]:!justify-start","[&>mint-button]:!justify-center","[&>mint-button]:!justify-end","[&>mint-button>button]:!justify-start","[&>mint-button>button]:!justify-center","[&>mint-button>button]:!justify-end"].forEach(n=>this.classList.remove(n)),t.split(" ").forEach(n=>{n&&this.classList.add(n)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(n=>{this.classList.contains(n)||this.classList.add(n)}),e?this._applyTextAlignToChildren(e):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(t){Array.from(this.children).forEach(i=>{if(i.tagName==="MINT-BUTTON"){const s=i.querySelector("button");if(s){s.classList.remove("justify-start","justify-center","justify-end"),t==="left"?s.classList.add("justify-start"):t==="right"?s.classList.add("justify-end"):t==="center"&&s.classList.add("justify-center");const n=s.querySelector(".mint-button-content");n&&(n.classList.remove("text-left","text-center","text-right","text-justify"),n.classList.add(`text-${t}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${t}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName==="MINT-BUTTON"){const i=e.querySelector("button");if(i){i.classList.remove("justify-start","justify-end"),i.classList.add("justify-center");const s=i.querySelector(".mint-button-content");s&&s.classList.remove("text-left","text-center","text-right","text-justify")}}else e.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",Z);class Q extends HTMLElement{constructor(){super(),this._headingElement=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add("rounded-lg","shadow","bg-white","dark:bg-gray-800","border","border-gray-200","dark:border-gray-700","overflow-hidden","transition-colors","duration-200","mb-6"),this.hasPaddingClass()||this.classList.add("p-4");const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",Q);class tt extends HTMLElement{constructor(){super(),this._link=null,this._contentObserver=null}static get observedAttributes(){return["href","target"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&(this._contentObserver.disconnect(),this._contentObserver=null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll("mint-text").forEach(e=>{e.classList.contains("underline")||e.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var t;return!!(this.querySelector("mint-icon")||(t=this._link)!=null&&t.querySelector("mint-icon"))}render(){const t=this.getHref(),e=this.getTarget();if(!this._link){for(this._link=document.createElement("a");this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=t,e?(this._link.target=e,e==="_blank"&&(this._link.rel="noopener noreferrer")):(this._link.removeAttribute("target"),this._link.removeAttribute("rel"));const i=this.hasIcon(),s=["text-slate-800","dark:text-slate-200","underline","hover:text-slate-950","dark:hover:text-slate-100","transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"];i&&s.push("inline-flex","items-center","gap-2"),this._link.className=s.join(" "),this._link.querySelectorAll("mint-text").forEach(a=>{a.classList.contains("underline")||a.classList.add("underline")}),["box-border","m-0","p-0","border-0","align-baseline","inline-block"].forEach(a=>{this.classList.contains(a)||this.classList.add(a)})}}customElements.get("mint-link")||customElements.define("mint-link",tt);class et extends HTMLElement{constructor(){super(),this._button=null}static get observedAttributes(){return["href","fallback-href"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center","justify-center"),this.render()}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const t=document.referrer,e=window.location.origin;if(t)try{const i=new URL(t);if(i.origin===e)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(t){t.preventDefault(),t.stopPropagation();const e=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),n=new CustomEvent("back",{detail:{url:e,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",t=>this.handleClick(t)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",et);class it extends HTMLElement{constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._backButton=null,this._backButtonHandler=null}static get observedAttributes(){return["heading","fallback-href","show-back-button","containered"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode(),this._setupBackButtonListener()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._removeBackButtonListener()}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const t=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this.appendChild(this._pageContainer)),this._applyContainerClasses(),this._header||(this._header=document.createElement("div"),this._header.className="flex justify-between mb-8",this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement("div"),this._titleElement.className="flex gap-4 min-w-0 flex-1",this._header.appendChild(this._titleElement));let e=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){e||(e=document.createElement("mint-back-button"),this._titleElement.insertBefore(e,this._titleElement.firstChild));const r=this.getFallbackHref();e.setAttribute("fallback-href",r),this._backButton=e}else e&&(e.remove(),e=null,this._backButton=null);t?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._headingText.previousSibling!==e&&this._titleElement.insertBefore(this._headingText,e.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement("mint-text"),this._headingText.setAttribute("size","heading"),this._headingText.setAttribute("bold",""),this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,e.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=t):this._headingText&&(this._headingText.remove(),this._headingText=null),this._actionsSlot?this._actionsSlot.classList.contains("ml-4")||this._actionsSlot.classList.add("ml-4"):(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="flex gap-2 items-center ml-4",this._actionsSlot.setAttribute("slot","actions"),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(r=>r!==this._pageContainer&&r!==this._actionsSlot&&r.getAttribute("slot")==="actions").forEach(r=>{this._actionsSlot&&r.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(r)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(r=>{r!==this._pageContainer&&r.getAttribute("slot")!=="actions"&&r!==this._actionsSlot&&r!==this._header&&r!==this._bodySlot&&r!==this._headingText&&r.parentElement!==this._bodySlot&&r.parentElement!==this._pageContainer&&this._bodySlot.appendChild(r)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add("min-h-screen","p-8","transition-colors","duration-200"),this.hasAttribute("containered")?this._pageContainer.classList.add("max-w-6xl","mx-auto","w-full"):this._pageContainer.classList.remove("max-w-6xl","mx-auto"))}_updateBackgroundColor(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-20"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-20"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_setupBackButtonListener(){this._backButtonHandler||(this._backButtonHandler=t=>{const e=t.target;if(e&&e.tagName==="MINT-BACK-BUTTON"){t.stopPropagation();const i=new CustomEvent("back",{detail:t.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}}),this.addEventListener("back",this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&(this.removeEventListener("back",this._backButtonHandler,!0),this._backButtonHandler=null)}}customElements.get("mint-page")||customElements.define("mint-page",it);class st extends HTMLElement{static get observedAttributes(){return["columns","sm","md","lg","xl","gap"]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getColumns(){return this.getAttribute("columns")||"1"}getSm(){return this.getAttribute("sm")}getMd(){return this.getAttribute("md")}getLg(){return this.getAttribute("lg")}getXl(){return this.getAttribute("xl")}getGap(){return"3"}getGridClasses(){const t=["grid"],e=this.getColumns();t.push(`grid-cols-${e}`);const i=this.getSm();i&&t.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&t.push(`md:grid-cols-${s}`);const n=this.getLg();n&&t.push(`lg:grid-cols-${n}`);const r=this.getXl();r&&t.push(`xl:grid-cols-${r}`);const a=this.getGap();return t.push(`gap-${a}`),t}render(){Array.from(this.classList).filter(i=>i.startsWith("grid-cols-")||i.startsWith("sm:grid-cols-")||i.startsWith("md:grid-cols-")||i.startsWith("lg:grid-cols-")||i.startsWith("xl:grid-cols-")||i.startsWith("gap-")).forEach(i=>this.classList.remove(i)),this.classList.contains("grid")||this.classList.add("grid"),this.getGridClasses().forEach(i=>{i&&i!=="grid"&&this.classList.add(i)})}}customElements.get("mint-grid")||customElements.define("mint-grid",st);class rt extends HTMLElement{constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen();if(t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement("div"),this._modal.className="fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50",this.appendChild(this._modal)),i){let d=this._modal.querySelector(".modal-content");d||(d=document.createElement("div"),d.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(d)),this._animateEnter()}else this._animateExit();let s=this._modal.querySelector(".modal-content");s||(s=document.createElement("div"),s.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(s)),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let n=this._headingSlot.querySelector("mint-text");e?(n||(n=document.createElement("mint-text"),n.setAttribute("size","sub-heading"),n.setAttribute("bold",""),this._headingSlot.appendChild(n)),n.textContent=e):n&&n.remove(),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._headingSlot&&d.getAttribute("slot")==="heading").forEach(d=>{this._headingSlot&&d.parentElement!==this._headingSlot&&this._headingSlot.appendChild(d)}),this._closeButton||(this._closeButton=document.createElement("mint-button"),this._closeButton.setAttribute("variant","ghost"),this._closeButton.setAttribute("icon","close"),this._closeButton.addEventListener("click",()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement("div"),this._bodySlot.className="flex-1 overflow-y-auto p-4",this._bodySlot.setAttribute("slot","body"),s.appendChild(this._bodySlot)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._bodySlot&&d.getAttribute("slot")==="body").forEach(d=>{this._bodySlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700",this._actionsSlot.setAttribute("slot","actions"),s.appendChild(this._actionsSlot));let o=this._actionsSlot.querySelector("mint-stack");o||(o=document.createElement("mint-stack"),o.setAttribute("direction","horizontal"),o.className="justify-end",this._actionsSlot.appendChild(o)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._actionsSlot&&d.getAttribute("slot")==="actions").forEach(d=>{Array.from(d.children).forEach(h=>{h.parentElement!==o&&o.appendChild(h)}),d.parentElement&&d.remove()}),Array.from(this.children).forEach(d=>{d!==this._overlay&&d!==this._modal&&d.getAttribute("slot")!=="heading"&&d.getAttribute("slot")!=="body"&&d.getAttribute("slot")!=="actions"&&d!==this._headingSlot&&d!==this._bodySlot&&d!==this._actionsSlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const t=document.documentElement.classList.contains("dark"),e=this._modal.querySelector(".modal-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");t&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})}))}_animateExit(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");if(!t){this.classList.add("hidden");return}t.style.transition="all 200ms ease-in",t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.opacity="",t.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",rt);class nt extends HTMLElement{constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._hoverCloseTimeout=null,this._scrollHandler=null,this._resizeHandler=null}static get observedAttributes(){return["id","direction","open","trigger-id","padding","hover"]}connectedCallback(){const t=this._isInsideModal()?"z-[60]":"z-50";this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0",t,"pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}_isInsideModal(){let t=this;for(;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}if(this._triggerElement)for(t=this._triggerElement;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}return!1}disconnectedCallback(){this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&this._triggerElement.removeAttribute("active"),this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler),this._clickOutsideHandler=null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}attributeChangedCallback(t,e,i){if(e!==i){if(this.isConnected){const s=this._isInsideModal()?"z-[60]":"z-50";this.classList.remove("z-50","z-[60]"),this.classList.add(s)}this.render(),(t==="trigger-id"||t==="hover")&&this._setupTrigger(),t==="open"&&this.isOpen()&&this._closeOtherPopovers()}}getId(){return this.getAttribute("id")||""}getPadding(){const t=this.getAttribute("padding")||"4";return{0:"p-0","0.5":"p-0.5",1:"p-1","1.5":"p-1.5",2:"p-2","2.5":"p-2.5",3:"p-3","3.5":"p-3.5",4:"p-4",5:"p-5",6:"p-6",8:"p-8",10:"p-10",12:"p-12",16:"p-16",20:"p-20",24:"p-24"}[t]||"p-4"}getDirection(){return this.getAttribute("direction")||"down"}getTriggerId(){return this.getAttribute("trigger-id")||""}isHoverEnabled(){return this.hasAttribute("hover")}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}_setupTrigger(){const t=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),t&&(this._triggerElement=document.getElementById(t),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(t),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const t=this;this._triggerClickHandler=function(e){e.stopImmediatePropagation(),e.preventDefault(),t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const t=this;this._triggerHoverEnterHandler=function(){t._cancelHoverClose(),t.open()},this._triggerHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){t._cancelHoverClose()},this._popoverHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._popover.addEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover.addEventListener("mouseleave",this._popoverHoverLeaveHandler))}_removeHoverListeners(){this._triggerElement&&this._triggerHoverEnterHandler&&this._triggerElement.removeEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement&&this._triggerHoverLeaveHandler&&this._triggerElement.removeEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&this._popoverHoverEnterHandler&&this._popover.removeEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover&&this._popoverHoverLeaveHandler&&this._popover.removeEventListener("mouseleave",this._popoverHoverLeaveHandler),this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._cancelHoverClose()}_scheduleHoverClose(){this._cancelHoverClose(),this._hoverCloseTimeout=window.setTimeout(()=>{this._isHovering()||this.close()},120)}_cancelHoverClose(){this._hoverCloseTimeout!==null&&(clearTimeout(this._hoverCloseTimeout),this._hoverCloseTimeout=null)}_isHovering(){const t=this._triggerElement?this._triggerElement.matches(":hover"):!1,e=this._popover?this._popover.matches(":hover"):!1;return t||e}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const t=this._triggerElement.getBoundingClientRect(),e=this._popover.querySelector(".popover-content");if(!e)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,a=8;let o=this.getDirection(),l=0,c=0;switch(o){case"down":if(l=t.bottom+a,c=t.left+t.width/2-s.width/2,l+s.height>r){const d=t.top-s.height-a;d>=0?(o="up",l=d):(l=Math.max(0,r-s.height-a),l+s.height>r&&(l=0))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"up":if(l=t.top-s.height-a,c=t.left+t.width/2-s.width/2,l<0){const d=t.bottom+a;d+s.height<=r?(o="down",l=d):(l=Math.min(r-s.height-a,r-s.height),l<0&&(l=r-s.height))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"right":if(l=t.top+t.height/2-s.height/2,c=t.right+a,c+s.width>n){const d=t.left-s.width-a;d>=0?(o="left",c=d):(c=Math.max(0,n-s.width-a),c+s.width>n&&(c=n-s.width))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break;case"left":if(l=t.top+t.height/2-s.height/2,c=t.left-s.width-a,c<0){const d=t.right+a;d+s.width<=n?(o="right",c=d):(c=Math.min(n-s.width-a,n-s.width),c<0&&(c=0))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break}return{top:l,left:c,direction:o}}render(){const t=this.getId(),e=this.isOpen(),i=this.getPadding();if(t&&(this.id=t),e){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.setAttribute("active","true");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),!this._clickOutsideHandler){const r=this;this._clickOutsideHandler=function(a){const o=a.composedPath(),l=o.includes(r);if(!(r._triggerElement&&o.includes(r._triggerElement))&&!l){r.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.removeAttribute("active");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);if(this._overlay){const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`}else{this._overlay=document.createElement("div");const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`,this.appendChild(this._overlay)}if(this._popover){const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`}else{this._popover=document.createElement("div");const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`,this.appendChild(this._popover)}this.isHoverEnabled()&&this._attachHoverListeners();let s=this._popover.querySelector(".popover-content");if(!s)s=document.createElement("div"),s.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`,this._popover.appendChild(s);else{const r=s.className.split(" "),a=["p-0","p-0.5","p-1","p-1.5","p-2","p-2.5","p-3","p-3.5","p-4","p-5","p-6","p-8","p-10","p-12","p-16","p-20","p-24"],o=r.filter(l=>!a.includes(l));s.className=[...o,i].join(" ")}Array.from(this.children).forEach(r=>{r!==this._overlay&&r!==this._popover&&r.parentElement===this&&s.appendChild(r)}),e?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(s):(this._popover.style.top="50%",this._popover.style.left="50%",this._popover.style.transform="translate(-50%, -50%)",this._popover.style.visibility="visible",this._popover.style.display="block",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",s.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.style.transform="scale(1) translateY(0)",s.style.opacity="1"})}))):!e&&s&&(this._removePositionListeners(),s.style.opacity!=="0"&&s.style.opacity!==""&&(s.style.transition="all 200ms ease-in",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",setTimeout(()=>{s.style.transform="",s.style.opacity="",s.style.transition="",this._popover.style.visibility="",this._popover.style.display=""},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;const t=document.documentElement.classList.contains("dark"),e=this._popover.querySelector(".popover-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(t){if(!this._triggerElement||!this._popover)return;const e=this._popover.style.visibility!=="hidden";e||(this._popover.style.visibility="hidden",this._popover.style.display="block",this._popover.style.top="0",this._popover.style.left="0"),this._popover.offsetHeight;const i=this._calculatePosition();this._popover.style.top=`${i.top}px`,this._popover.style.left=`${i.left}px`,e||(this._popover.style.visibility="visible",t&&(!t.style.opacity||t.style.opacity==="")&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const t=this;this._scrollHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const t=this;this._resizeHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("resize",this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_closeOtherPopovers(){Array.from(document.querySelectorAll("mint-popover[open]")).forEach(e=>{if(e!==this){const i=e;typeof i.close=="function"?i.close():e.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",nt);class at extends HTMLElement{constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null,this._changeHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._touchstartHandler=null,this._touchendHandler=null,this._focusHandler=null,this._blurHandler=null}static get observedAttributes(){return["checked","disabled","label","info","id","name","value","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render(),t==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}catch{}}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getCheckboxClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-800","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",t?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...e,...i].join(" ")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let n=this.querySelector(".mint-checkbox-container");n||(n=document.createElement("div"),n.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(n,this.firstChild));let r=this.querySelector(".mint-checkbox-wrapper");r?r.parentElement!==n&&n.appendChild(r):(r=document.createElement("div"),r.className="mint-checkbox-wrapper",n.appendChild(r)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._checkbox.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;",this._checkbox.checked=this._checked,this._checkbox.disabled=s,this._changeHandler||this.setupEventListeners();const a=this.getId();a?this._checkbox.id=a:this._checkbox.removeAttribute("id");const o=this.getName();o?this._checkbox.name=o:this._checkbox.removeAttribute("name");const l=this.getValue();l?this._checkbox.value=l:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.cursor="pointer",r.style.pointerEvents="auto",this._checkbox.style.pointerEvents="auto";const c=r;c._wrapperClickHandler||(c._wrapperClickHandler=f=>{f.target===r&&!s&&(f.preventDefault(),f.stopPropagation(),this.toggle())},r.addEventListener("click",c._wrapperClickHandler));let d=r.querySelector("mint-icon");d||(d=document.createElement("mint-icon"),d.setAttribute("name","check"),d.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",d.style.transition="opacity 200ms ease-out, transform 200ms ease-out",d.style.zIndex="1",r.appendChild(d)),this.updateVisualState();let u=this.querySelector(".mint-checkbox-label-container");const h=this.querySelector(".mint-checkbox-container");if(e||i){u?h&&u.parentElement!==h&&h.appendChild(u):(u=document.createElement("div"),u.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",h?h.appendChild(u):this.appendChild(u));let f=u.querySelector(".mint-checkbox-label");e?(f||(f=document.createElement("span"),f.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",u.insertBefore(f,u.firstChild)),f.textContent=e,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove();let p=u.querySelector(".mint-checkbox-info");if(i?(p||(p=document.createElement("span"),p.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",u.appendChild(p)),p.textContent=i,s?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove(),s)u.style.cursor="default",u._clickHandler&&(u.removeEventListener("click",u._clickHandler),u._clickHandler=null);else{u.style.cursor="pointer";const m=u._clickHandler;m&&u.removeEventListener("click",m),u._clickHandler=_=>{this._checkbox&&(_.target===this._checkbox||this._checkbox.contains(_.target)||_.composedPath().includes(this._checkbox))||this.toggle()},u.addEventListener("click",u._clickHandler)}}else u&&u.remove();this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=t=>{t.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}));const i=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(i)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._mouseleaveHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(e==null||e.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&t.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._checkbox.addEventListener("focus",this._focusHandler),this._checkbox.addEventListener("blur",this._blurHandler),this._touchstartHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("touchstart",this._touchstartHandler),this._checkbox.addEventListener("touchend",this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&(this._checkbox.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._mousedownHandler&&(this._checkbox.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._checkbox.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._checkbox.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._checkbox.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._checkbox.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._checkbox.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._checkbox.removeEventListener("blur",this._blurHandler),this._blurHandler=null));const t=this.querySelector(".mint-checkbox-wrapper");if(t){const e=t;e._wrapperClickHandler&&(t.removeEventListener("click",e._wrapperClickHandler),e._wrapperClickHandler=null)}}updateVisualState(){const t=this.querySelector(".mint-checkbox-wrapper"),e=t==null?void 0:t.querySelector("mint-icon");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0.8)"),t&&(t.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,t.classList.contains("mint-checkbox-active")||(t.style.backgroundColor="",t.style.boxShadow=""))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState(),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0}));const t=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}_renderSkeleton(t){let e=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),n=this.querySelector(".mint-checkbox-label-container");if(t){e||(e=document.createElement("div"),e.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e)));let r=e.querySelector(".mint-checkbox-skeleton-box");if(r||(r=document.createElement("div"),r.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(r)),n){let a=e.querySelector(".mint-checkbox-skeleton-label");a||(a=document.createElement("div"),a.className="mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(a))}e.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),n&&(n.style.visibility="hidden",n.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),n&&(n.style.visibility="visible",n.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&t&&e&&(i=document.createElement("div"),i.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(i));let s=this.querySelector(".mint-checkbox-error");t&&e?(s?(s.classList.add("block","w-full"),s.style.display="block",(i&&s.parentElement!==i||i&&s.parentElement===i)&&i.appendChild(s)):(s=document.createElement("div"),s.className="mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full",s.style.display="block",i?i.appendChild(s):this.appendChild(s)),s.textContent=e):s&&s.remove();const n=this.querySelector(".mint-checkbox-wrapper");n&&(n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",at);class xt extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}static get observedAttributes(){return["value","checked","disabled","loading"]}connectedCallback(){this.classList.add("inline-flex","items-center","gap-2","cursor-pointer","select-none");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null),this._keydownHandler&&(this._radio.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null))}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),e!==i){if(t==="loading"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{this._checked=!!t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}catch{}}getValue(){return this.getAttribute("value")||""}isDisabled(){const t=this.closest("mint-choice");return this.hasAttribute("disabled")||((t==null?void 0:t.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=t=>{t.target!==this._radio&&(this.isDisabled()||this._radio&&(this._radio.click(),requestAnimationFrame(()=>{if(this._radio&&this._radio.checked!==this._checked){this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const e=this.closest("mint-choice");e&&e.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener("click",this._clickHandler))}render(){var f;const t=this.isLoading(),e=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),n=(s==null?void 0:s.getAttribute("name"))||"";let r="";const a=this.querySelector(".mint-choice-option-label");a?r=((f=a.textContent)==null?void 0:f.trim())||"":Array.from(this.childNodes).forEach(p=>{var m;if(p.nodeType===Node.TEXT_NODE){const _=(m=p.textContent)==null?void 0:m.trim();_&&(r+=_)}});const o=this.querySelectorAll(".mint-choice-option-wrapper");let l=null;if(o.length>0&&(this._radio&&(l=Array.from(o).find(p=>p.contains(this._radio))),l||(l=o[0]),o.forEach((p,m)=>{p!==l&&p.remove()})),l||(l=document.createElement("div"),l.className="mint-choice-option-wrapper",l.style.position="relative",this.insertBefore(l,this.firstChild)),l.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,l.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(p=>{p!==this._radio&&p.remove()}),this._radio)this._radio.parentElement!==l&&l.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._radio.addEventListener("change",this._changeHandler)),this._radio&&(this._focusHandler||(this._focusHandler=p=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&!this.isDisabled()&&m.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const p=this.querySelector(".mint-choice-option-wrapper");p&&p.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=p=>{this.isDisabled()||(p.key==="ArrowDown"||p.key==="ArrowRight"?(p.preventDefault(),this._focusNextOption()):(p.key==="ArrowUp"||p.key==="ArrowLeft")&&(p.preventDefault(),this._focusPreviousOption()))}),this._radio.removeEventListener("focus",this._focusHandler),this._radio.removeEventListener("blur",this._blurHandler),this._radio.removeEventListener("keydown",this._keydownHandler),this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler),this._radio.addEventListener("keydown",this._keydownHandler));else{this._radio=document.createElement("input"),this._radio.type="radio",this._radio.className="sr-only",this._radio.style.position="absolute",this._radio.style.width="1px",this._radio.style.height="1px",this._radio.style.padding="0",this._radio.style.margin="-1px",this._radio.style.overflow="hidden",this._radio.style.clip="rect(0, 0, 0, 0)",this._radio.style.whiteSpace="nowrap",this._radio.style.border="0",l.appendChild(this._radio),this._changeHandler=m=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const g=this.closest("mint-choice");_!==this._checked&&g&&setTimeout(()=>{g.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const p=()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState())};this._radio.addEventListener("click",p),this._focusHandler=m=>{const _=this.querySelector(".mint-choice-option-wrapper");_&&!this.isDisabled()&&_.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._blurHandler=()=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&m.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),this._keydownHandler=m=>{this.isDisabled()||(m.key==="ArrowDown"||m.key==="ArrowRight"?(m.preventDefault(),this._focusNextOption()):(m.key==="ArrowUp"||m.key==="ArrowLeft")&&(m.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener("keydown",this._keydownHandler)}this._radio.name=n,this._radio.value=i,this._radio.checked!==this._checked?(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked")):this._radio.checked=this._checked,this._radio.disabled=e,e?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),r?this._radio.setAttribute("aria-label",r):this._radio.removeAttribute("aria-label"),l.querySelectorAll(".mint-choice-option-indicator").forEach((p,m)=>{m>0&&p.remove()});let u=l.querySelector(".mint-choice-option-indicator");u||(u=document.createElement("div"),u.className="mint-choice-option-indicator",l.appendChild(u)),u.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",u.style.position="absolute",u.style.top="50%",u.style.left="50%",u.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",u.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(t);let h=this.querySelector(".mint-choice-option-label");r&&(h||(h=document.createElement("span"),h.className="mint-choice-option-label",this.appendChild(h),Array.from(this.childNodes).forEach(p=>{var m;p.nodeType===Node.TEXT_NODE&&((m=p.textContent)!=null&&m.trim())&&(p.textContent="")})),h.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e?"opacity-40":""}`,h.textContent=r),e?(this.classList.add("cursor-not-allowed"),this.classList.remove("cursor-pointer")):(this.classList.add("cursor-pointer"),this.classList.remove("cursor-not-allowed")),this._updateVisualState()}_getWrapperClasses(){const t=this.isDisabled(),e=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return t&&e.push("opacity-40","cursor-not-allowed"),this._checked?e.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):e.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),e.join(" ")}_updateVisualState(){const t=this.querySelector(".mint-choice-option-wrapper");t&&(t.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const e=this.querySelector(".mint-choice-option-indicator");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(t){let e=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(t){e||(e=document.createElement("div"),e.className="mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-choice-option-skeleton-radio");if(s||(s=document.createElement("div"),s.className="mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="hidden"),r&&(r.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(e&&(e.style.display="none"),i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="visible"),r&&(r.style.visibility="visible"),i.style.pointerEvents="auto"}const s=this.querySelector(".mint-choice-option-label");s&&!(i!=null&&i.contains(s))&&(s.style.visibility="visible",s.style.pointerEvents="auto")}}_updateGroupState(){var e;if(!((e=this._radio)!=null&&e.name))return;document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(i=>{if(i===this._radio)return;const s=i.closest("mint-choice-option");s&&s!==this&&(s._checked=i.checked,i.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),s._updateVisualState())})}_focusNextOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>=0&&e<t.length-1?i=t[e+1]:t.length>0&&(i=t[0]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}_focusPreviousOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>0?i=t[e-1]:t.length>0&&(i=t[t.length-1]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}customElements.get("mint-choice-option")||customElements.define("mint-choice-option",xt);class ot extends HTMLElement{constructor(){super(),this._optionsContainer=null}static get observedAttributes(){return["label","name","info","error","error-message","id","disabled","required","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","block","w-full"),this.render(),this.addEventListener("choice-change",t=>{var r;const i=((r=t.detail)==null?void 0:r.value)||this.getValue();(this.getAttribute("value")||"")!==i&&(i?this.setAttribute("value",i):this.removeAttribute("value"));const n=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent("input",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0}))})}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){e!==i&&(t==="error"||t==="error-message"?this._renderErrorState():t==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(n=>{this.isLoading()?n.setAttribute("loading",""):n.removeAttribute("loading")})):(this.render(),t==="name"&&this.querySelectorAll("mint-choice-option").forEach(n=>{typeof n.render=="function"&&n.render()})))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}isDisabled(){return this.hasAttribute("disabled")}isRequired(){return this.hasAttribute("required")}getValue(){const t=this.querySelector('input[type="radio"]:checked');return(t==null?void 0:t.value)||""}setValue(t){const e=this.querySelectorAll("mint-choice-option");e.forEach(i=>{if((i.getAttribute("value")||"")===t){const n=i;n.checked=!0;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}else{const n=i;n.checked=!1;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!1)}}),requestAnimationFrame(()=>{e.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const n=i;s.checked!==n.checked&&(s.checked=n.checked)}})})}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const n=this.isDisabled();let r=this.querySelector(".mint-choice-label-container");if(e||i){r||(r=document.createElement("div"),r.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-choice-label");e?(l||(l=document.createElement("label"),l.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.insertBefore(l,r.firstChild)),l.textContent=e,l.setAttribute("for",s),n?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove();let c=r.querySelector(".mint-choice-info");i?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",r.appendChild(c)),c.textContent=i,n?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove()}else r&&r.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const l=this.querySelector(".mint-choice-label-container");l&&l.parentElement===this?this.insertBefore(a,l.nextSibling):this.insertBefore(a,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==a&&a.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement("div"),this._optionsContainer.className="mint-choice-options-container flex flex-col gap-3",a.appendChild(this._optionsContainer)),Array.from(this.children).filter(l=>l.tagName==="MINT-CHOICE-OPTION"&&l.parentElement!==this._optionsContainer).forEach(l=>{this._optionsContainer.appendChild(l)}),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(t){if(e||(e=document.createElement("div"),e.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e))),e.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let r=0;r<3;r++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const o=document.createElement("div");o.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o);const l=document.createElement("div");l.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l),e.appendChild(a)}e.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",ot);class lt extends HTMLElement{constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null}static get observedAttributes(){return["type","placeholder","value","disabled","id","name","required","readonly","rows","icon","label","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(t==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const t=this.getAttribute("rows");return t?parseInt(t,10):3}_getNormalizedType(){const t=this.getType();return t==="datetime"?"datetime-local":t==="money"?"text":t==="textarea"?"textarea":t}_isTextarea(){return this.getType()==="textarea"}_isMoney(){return this.getType()==="money"}_isColor(){return this.getType()==="color"}_isNumber(){return this.getType()==="number"}getPlaceholder(){return this.getAttribute("placeholder")||""}getValue(){var t,e,i;return this._isColor()?((t=this._colorPicker)==null?void 0:t.value)||((e=this._colorTextInput)==null?void 0:e.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(t){try{this._isColor()?(this._colorPicker&&(this._colorPicker.value=t||"#000000"),this._colorTextInput&&(this._colorTextInput.value=t||"#000000")):this._element&&(this._element.value=t),t?this.setAttribute("value",t):this.removeAttribute("value")}catch{}}get value(){try{return this.getValue()||""}catch{return""}}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getIcon(){return this.getAttribute("icon")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getInputClasses(){const t=this._isTextarea(),e=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),n=this.hasError(),r=["w-full",e||i?"pl-10":"px-3.5",e||i?"pr-3.5":s?"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",t?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",t?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",n?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],o=["focus-visible:ring-2","focus-visible:ring-offset-1",n?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...r,...a,...o].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var v,b,k,A;this.getType();const t=this._getNormalizedType(),e=this._isTextarea(),i=this._isMoney(),s=this._isColor(),n=this.getPlaceholder(),r=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),l=this.getId(),c=this.getName(),d=this.getAttribute("value")||(s?"#000000":""),u=this.getRows(),h=this.getIcon(),f=this.getLabel(),p=this.getInfo(),m=this.isLoading();if(this._renderSkeleton(m),s){this._input&&(this._input.remove(),this._input=null),this._textarea&&(this._textarea.remove(),this._textarea=null),this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement("div"),this._colorPickerWrapper.className="mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",this._colorPickerWrapper.style.backgroundColor=d||"#000000",this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement("input"),this._colorPicker.type="color",this._colorPicker.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._colorPicker.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;",this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=y=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var x;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((x=this._colorPickerWrapper)==null||x.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._colorPicker.addEventListener("focus",this._focusHandler),this._colorPicker.addEventListener("blur",this._blurHandler),this._colorPicker.addEventListener("input",()=>{var x;const y=((x=this._colorPicker)==null?void 0:x.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this._colorTextInput&&(this._colorTextInput.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var x;const y=((x=this._colorPicker)==null?void 0:x.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("change",{detail:{value:y},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=n||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var x;const y=((x=this._colorTextInput)==null?void 0:x.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)&&(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var x,T;const y=((x=this._colorTextInput)==null?void 0:x.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)?(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((T=this._colorPicker)==null?void 0:T.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const E=d||"#000000";if(this._colorPicker&&this._colorPicker.value!==E&&(this._colorPicker.value=E),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=E),this._colorTextInput&&this._colorTextInput.value!==E&&(this._colorTextInput.value=E),this._colorPicker&&(this._colorPicker.disabled=r),this._colorPickerWrapper&&(r?(this._colorPickerWrapper.classList.add("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.remove("cursor-pointer")):(this._colorPickerWrapper.classList.remove("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.add("cursor-pointer"))),this._colorTextInput&&(this._colorTextInput.disabled=r,this._colorTextInput.readOnly=a,this._colorTextInput.required=o),this._colorTextInput){const y=this._colorTextInput;l?y.id=l:y.removeAttribute("id"),c?y.name=c:y.removeAttribute("name"),y.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=y}this._renderErrorState();return}if(this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),h&&!e?this._icon?this._icon.setAttribute("name",h):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",h),this._icon.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",this._wrapper.appendChild(this._icon)):this._icon&&(this._icon.remove(),this._icon=null),this._isNumber()&&!e){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement("div"),this._numberSpinnerContainer.className="absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none",this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement("button"),this._numberIncrementButton.type="button",this._numberIncrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const E=document.createElement("mint-icon");E.setAttribute("name","caret-up"),E.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(E),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement("button"),this._numberDecrementButton.type="button",this._numberDecrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const y=document.createElement("mint-icon");y.setAttribute("name","caret-down"),y.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(y),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",x=>{if(x.preventDefault(),x.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const T=parseFloat(this._input.value)||0,R=parseFloat(this._input.step)||1,P=this._input.min?parseFloat(this._input.min):void 0,q=this._input.max?parseFloat(this._input.max):void 0;let H=T+R;q!==void 0&&H>q&&(H=q),P!==void 0&&H<P&&(H=P),this._input.value=H.toString(),this.setAttribute("value",H.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",x=>{if(x.preventDefault(),x.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const T=parseFloat(this._input.value)||0,R=parseFloat(this._input.step)||1,P=this._input.min?parseFloat(this._input.min):void 0,q=this._input.max?parseFloat(this._input.max):void 0;let H=T-R;P!==void 0&&H<P&&(H=P),q!==void 0&&H>q&&(H=q),this._input.value=H.toString(),this.setAttribute("value",H.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=r||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=r||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(e){if(this._input&&(this._input.remove(),this._input=null),this._textarea||(this._textarea=document.createElement("textarea"),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=n,this._textarea.disabled=r,this._textarea.readOnly=a,this._textarea.required=o,this._textarea.rows=u,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),d!==this._textarea.value&&(this._textarea.value=d),l?this._textarea.id=l:this._textarea.removeAttribute("id"),c?this._textarea.name=c:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const E=this.firstChild.textContent;E&&!this._textarea.value&&(this._textarea.value=E.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&(this._textarea.remove(),this._textarea=null),this._input||(this._input=document.createElement("input"),this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=t,this._input.placeholder=n,this._input.disabled=r,this._input.readOnly=a,this._input.required=o,this._input.setAttribute("aria-invalid",this.hasError()?"true":"false"),i?(this._input.inputMode="decimal",this._input.pattern="[0-9]*\\.?[0-9]*"):(this._input.removeAttribute("inputmode"),this._input.removeAttribute("pattern")),d!==this._input.value&&(this._input.value=d),l?this._input.id=l:this._input.removeAttribute("id"),c?this._input.name=c:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const E=this.firstChild.textContent;E&&!this._input.value&&(this._input.value=E.trim()),this.removeChild(this.firstChild)}let g=this.querySelector(".mint-input-label-container");if(f||p){g||(g=document.createElement("div"),g.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let E=g.querySelector(".mint-input-label");if(f){E||(E=document.createElement("label"),E.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",g.insertBefore(E,g.firstChild)),E.textContent=f;const x=l||((v=this._element)==null?void 0:v.id)||((b=this._colorTextInput)==null?void 0:b.id)||((k=this._input)==null?void 0:k.id)||((A=this._textarea)==null?void 0:A.id);if(x)E.setAttribute("for",x);else{const T=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=T:this._colorTextInput?this._colorTextInput.id=T:this._input?this._input.id=T:this._textarea&&(this._textarea.id=T),E.setAttribute("for",T)}r?E.classList.add("opacity-40"):E.classList.remove("opacity-40")}else E&&E.remove();let y=g.querySelector(".mint-input-info");p?(y||(y=document.createElement("span"),y.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",g.appendChild(y)),y.textContent=p,r?y.classList.add("opacity-40"):y.classList.remove("opacity-40")):y&&y.remove()}else g&&g.remove();this._renderErrorState(),this._renderSkeleton(m)}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-input-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-input-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var i;const t=((i=this._element)==null?void 0:i.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value");const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener("blur",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&(this._colorPicker.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._colorPicker.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}focus(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(t=this._element)==null||t.focus()}blur(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(t=this._element)==null||t.blur()}_renderSkeleton(t){let e=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(t){e||(e=document.createElement("div"),e.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-input-skeleton");if(!s){s=document.createElement("div"),s.className="mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this._isTextarea(),r=this.getRows();if(n){const a=r*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";e.appendChild(s)}e.style.display="block",this._element&&(this._element.style.opacity="0",this._element.style.pointerEvents="none"),this._colorTextInput&&(this._colorTextInput.style.opacity="0",this._colorTextInput.style.pointerEvents="none")}else e&&(e.style.display="none"),this._element&&(this._element.style.opacity="1",this._element.style.pointerEvents="auto"),this._colorTextInput&&(this._colorTextInput.style.opacity="1",this._colorTextInput.style.pointerEvents="auto")}}customElements.get("mint-input")||customElements.define("mint-input",lt);class ct extends HTMLElement{constructor(){super(),this._input=null,this._textInput=null,this._popover=null,this._calendarContainer=null,this._iconButton=null,this._hiddenInput=null,this._startPartInputs=[],this._endPartInputs=[],this._displayEl=null,this._inputsWrapperEl=null,this._fieldsContainer=null,this._resetHandler=null,this._isInputMode=!1,this._currentMonth=new Date().getMonth(),this._currentYear=new Date().getFullYear(),this._viewMode="calendar",this._selectedStartDate=null,this._selectedEndDate=null,this._isRange=!1,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}static get observedAttributes(){return["value","label","info","disabled","id","name","required","readonly","format","min","max","range","shortcuts","display-format","error","error-message","loading","selection-mode","week-start-day"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._setupPopoverWithRetry(),this._attachFormResetListener()}disconnectedCallback(){if(this._popoverObserver&&(this._popoverObserver.disconnect(),this._popoverObserver=null),this._removeFocusTrap(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){const s=this.hasError(),n=this.getErrorMessage();this._applyErrorVisuals(s,n,this.isDisabled());return}if(t==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(t){t?(this.setAttribute("value",t),this._textInput&&(this._textInput.value=t),this._parseValue(t)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}getFormat(){return this.getAttribute("format")||"mm/dd/yyyy"}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isRange(){return this.hasAttribute("range")}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getMin(){return this.getAttribute("min")||""}getMax(){return this.getAttribute("max")||""}getSelectionMode(){const t=this.getAttribute("selection-mode");return t==="week"||t==="month"?t:"day"}getWeekStartDay(){var i;const t=(i=this.getAttribute("week-start-day"))==null?void 0:i.toLowerCase();return{sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6}[t||"sunday"]??0}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const t=this.getAttribute("shortcuts");if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=t.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(n=>({label:n.label,action:typeof n.action=="function"?n.action:this._createShortcutAction(n.action)}))}}return[]}_createShortcutAction(t){return typeof t=="function"?t:typeof t=="string"&&typeof window[t]=="function"?window[t]:()=>null}_getDefaultShortcuts(){const t=[{label:"Today",action:()=>new Date}];return this._isRange&&t.push({label:"This Week",action:()=>{const e=new Date,i=e.getDay(),s=new Date(e);s.setDate(e.getDate()-i),s.setHours(0,0,0,0);const n=new Date(s);return n.setDate(s.getDate()+6),n.setHours(23,59,59,999),{start:s,end:n}}},{label:"This Month",action:()=>{const e=new Date,i=new Date(e.getFullYear(),e.getMonth(),1),s=new Date(e.getFullYear(),e.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),t}_getFormatTokens(t){const e=[];let i=0;const s=t.toLowerCase();for(;i<s.length;){const n=s[i];if(n==="d"||n==="m"||n==="y"){let r=1,a=i+1;for(;a<s.length&&s[a]===n;)r++,a++;e.push({type:"part",part:n,len:r}),i=a}else e.push({type:"sep",value:t[i]}),i++}return e}_createPartInput(t,e,i,s,n){const r=document.createElement("input");return r.type="text",r.inputMode="numeric",r.pattern="\\d*",r.maxLength=t,r.placeholder=e,r.className="bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed",r.disabled=i||s,r.readOnly=s,r.required=n,t===4?r.className+=" w-[40px]":t===2&&(r.className+=" w-[30px]"),r}_buildValueFromParts(t,e){let i=0;return e.map(s=>{var r;if(s.type==="sep")return s.value;const n=((r=t[i])==null?void 0:r.value)||"";return i++,n}).join("")}_applyDateToParts(t,e,i,s){if(!e.length)return;if(!t){e.forEach(o=>o.value="");return}const n=this._formatDate(t,s);let r=0,a=0;i.forEach(o=>{if(o.type==="sep")r+=o.value.length;else{const l=n.substr(r,o.len);e[a]&&(e[a].value=l),a++,r+=o.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const t=this.getFormat(),e=this._getFormatTokens(t),i=this._buildValueFromParts(this._startPartInputs,e);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,e);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(t,e){if(e+1<t.length){const i=t[e+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(t,e){if(e-1>=0){const i=t[e-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(t,e,i){t.forEach((s,n)=>{const r=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,r),s.value.length>=r&&this._focusNext(t,n),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(t,n),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(t,n),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(t,n),a.preventDefault())}),s.addEventListener("blur",a=>{var c,d;this._syncHiddenInput();const o=a.relatedTarget;o&&(this.contains(o)||(c=this._popover)!=null&&c.contains(o)||this._calendarContainer&&this._calendarContainer.contains(o))||(this._handleBlur(((d=this._hiddenInput)==null?void 0:d.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const u=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(u)}},0))})})}_splitRangeInput(t,e){const i=t.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[t]}_parseValue(t){const e=this.getFormat(),i=this._getFormatTokens(e),s=this.getSelectionMode();if(this._isRange||s==="week"||s==="month"){const[r,a]=this._splitRangeInput(t,e),o=r?this._parseDateString(r,e):null,l=a?this._parseDateString(a,e):null;if(o&&l){const[c,d]=o<=l?[o,l]:[l,o];this._selectedStartDate=c,this._selectedEndDate=d,this._currentMonth=c.getMonth(),this._currentYear=c.getFullYear()}else o&&(this._selectedStartDate=o,this._selectedEndDate=null,this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,e),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,e)}else{const r=this._parseDateString(t,e);r&&!isNaN(r.getTime())?(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear(),this._applyDateToParts(r,this._startPartInputs,i,e)):this._applyDateToParts(null,this._startPartInputs,i,e)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(t,e){const i=/[\/\-\.\s]+/;if(i.test(t)){const m=t.split(i).filter(g=>g.length>0),_=e.split(/[\/\-\.\s]+/).filter(g=>g.length>0);if(m.length===_.length){let g=0,v=0,b=0;for(let k=0;k<_.length;k++){const A=_[k].toLowerCase(),E=m[k];if(A.includes("d"))g=parseInt(E,10);else if(A.includes("m"))v=parseInt(E,10)-1;else if(A.includes("y")){let y=parseInt(E,10);const x=A.length,T=E.length;T===2&&x===4?y=Math.floor(new Date().getFullYear()/100)*100+y:T===2&&x===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),b=y}}if(g&&v>=0&&v<=11&&b){const k=new Date(b,v,g);if(!isNaN(k.getTime())&&k.getDate()===g&&k.getMonth()===v&&k.getFullYear()===b)return k}}}const n=t.replace(/[\/\-\.]/g,""),r=e.replace(/[\/\-\.]/g,"").toLowerCase();let a=r.indexOf("d"),o=r.indexOf("m"),l=r.indexOf("y");const c=[{char:"d",index:a},{char:"m",index:o},{char:"y",index:l}].sort((m,_)=>m.index-_.index);let d=0,u=0,h=0,f=0;r.length,n.length;for(const m of c)if(m.char==="d"){const _=r.lastIndexOf("d")-r.indexOf("d")+1,g=n.substr(f,_);if(g.length===0)return null;d=parseInt(g,10),f+=g.length}else if(m.char==="m"){const _=r.lastIndexOf("m")-r.indexOf("m")+1,g=n.substr(f,_);if(g.length===0)return null;u=parseInt(g,10)-1,f+=g.length}else if(m.char==="y"){const _=r.lastIndexOf("y")-r.indexOf("y")+1,g=n.substr(f),v=Math.min(_,g.length),b=g.substr(0,v);if(b.length===0)return null;let k=parseInt(b,10);v===2&&_===4?k=Math.floor(new Date().getFullYear()/100)*100+k:v===2&&_===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),h=k,f+=v}if(!d||u<0||u>11||!h)return null;const p=new Date(h,u,d);return isNaN(p.getTime())||p.getDate()!==d||p.getMonth()!==u||p.getFullYear()!==h?null:p}_formatDate(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=e.toLowerCase();let a=e;return r.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):r.includes("d")&&(a=a.replace(/d/gi,String(i))),r.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):r.includes("m")&&(a=a.replace(/m/gi,String(s))),r.includes("yyyy")?a=a.replace(/yyyy/gi,String(n)):r.includes("yy")&&(a=a.replace(/yy/gi,String(n).substr(2))),a}_formatDatePhp(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=(h,f=2)=>h.toString().padStart(f,"0"),d=h=>{const f=h%10,p=h%100;return f===1&&p!==11?"st":f===2&&p!==12?"nd":f===3&&p!==13?"rd":"th"};let u="";for(let h=0;h<e.length;h++){const f=e[h];if(f==="\\"&&h+1<e.length){u+=e[h+1],h++;continue}switch(f){case"Y":u+=n.toString();break;case"y":u+=n.toString().slice(-2);break;case"m":u+=c(s);break;case"n":u+=s.toString();break;case"M":u+=l[s-1];break;case"F":u+=o[s-1];break;case"d":u+=c(i);break;case"j":u+=i.toString();break;case"D":u+=a[t.getDay()];break;case"l":u+=r[t.getDay()];break;case"S":u+=d(i);break;default:u+=f;break}}return u}_validateDateString(t,e){const i=this._parseDateString(t,e);return i!==null&&!isNaN(i.getTime())}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getValue(),n=this.isDisabled(),r=this.isReadonly(),a=this.isRequired(),o=this.getId(),l=this.getName(),c=this.getFormat(),d=this.hasError(),u=this.getErrorMessage(),h=this.getSelectionMode();this._isRange=this.isRange()||h==="week"||h==="month",this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let f=this.querySelector(".mint-date-picker-label-container");if(e||i){f||(f=document.createElement("div"),f.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(f,this._input):this.appendChild(f));let b=f.querySelector(".mint-date-picker-label");e?(b||(b=document.createElement("label"),b.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",f.insertBefore(b,f.firstChild)),b.textContent=e,o&&this._textInput&&b.setAttribute("for",o)):b&&b.remove();let k=f.querySelector(".mint-date-picker-info");i?(k||(k=document.createElement("span"),k.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",f.appendChild(k)),k.textContent=i):k&&k.remove()}else f&&f.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=s||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),o&&(this._hiddenInput.id=o),l&&(this._hiddenInput.name=l),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",d?"true":"false");let p=this._input.querySelector(".mint-date-fields");p||(p=document.createElement("div"),this._input.appendChild(p)),this._fieldsContainer=p,this._applyErrorVisuals(d,u,n),p.innerHTML="",this._displayEl=document.createElement("div");const m=r?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${r?"cursor-default":"cursor-text"} ${m} focus:outline-none`,this._displayEl.tabIndex=n||r?-1:0,this._displayEl.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",b=>{n||r||(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const _=this._getFormatTokens(c);this._startPartInputs=[],this._endPartInputs=[];const g=b=>{const k=document.createDocumentFragment();return _.forEach(A=>{if(A.type==="sep"){const E=document.createElement("span");E.textContent=A.value,E.className="text-gray-400 dark:text-gray-500 select-none",k.appendChild(E)}else{const E=A.part==="d"?"dd":A.part==="m"?"mm":A.len===2?"yy":"yyyy",y=this._createPartInput(A.len,E,n,r,a);b==="start"?this._startPartInputs.push(y):this._endPartInputs.push(y),k.appendChild(y)}}),k};if(this._inputsWrapperEl.appendChild(g("start")),this._isRange){const b=document.createElement("span");b.textContent=" - ",b.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(b),this._inputsWrapperEl.appendChild(g("end"))}const v=document.createElement("div");if(v.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",v.appendChild(this._displayEl),v.appendChild(this._inputsWrapperEl),p.appendChild(v),p.addEventListener("click",()=>{this._isInputMode||n||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,_,p),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,_,p),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=n||r,!n&&!r?this._iconButton.tabIndex=0:this._iconButton.tabIndex=-1;else{this._iconButton=document.createElement("button"),this._iconButton.type="button",this._iconButton.tabIndex=0,this._iconButton.className="absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";const b=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=b;const k=document.createElement("mint-icon");k.setAttribute("name","calendar"),k.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(k),this._iconButton.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=n||r}this._renderErrorState(d,u),this._renderSkeleton(t)}_renderErrorState(t,e){let i=this.querySelector(".mint-date-picker-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_applyErrorVisuals(t,e,i){if(this._renderErrorState(t,e),this._fieldsContainer){const s=this._getFieldContainerClass(t,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",t?"true":"false")}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},t.addEventListener("reset",this._resetHandler))}_clearPartInputs(t){t.forEach(e=>{e.value=""})}_getFieldContainerClass(t,e){return["mint-date-fields relative w-full pl-10 pr-3.5 py-1.5 min-h-[2rem] text-sm font-medium rounded-lg box-border bg-white dark:bg-gray-700 text-gray-900 dark:text-white","border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600","transition-all duration-200 outline-none focus-within:ring-2 focus-within:ring-offset-1",t?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","flex items-center gap-1"].join(" ")+(e?" opacity-40 cursor-not-allowed":"")}_handleInputChange(t){}_cleanInputValue(t,e){return t}_handleBlur(t){const e=this.getFormat(),i=this.getSelectionMode(),s=this._isRange||i==="week"||i==="month";if(!t){this.setValue(""),this._updateDisplayText();return}if(s){const[n,r]=this._splitRangeInput(t,e),a=n?this._parseDateString(n,e):null,o=r?this._parseDateString(r,e):null;if(a&&o){const[l,c]=a<=o?[a,o]:[o,a],d=this._formatDate(l,e),u=this._formatDate(c,e),h=`${d} - ${u}`;this.setValue(h),this._applyDateToParts(l,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(c,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=l,this._selectedEndDate=c,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else if(a){const l=this._formatDate(a,e);this.setValue(l),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=a,this._selectedEndDate=null,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(t,e)){const n=this._parseDateString(t,e);if(n){const r=this._formatDate(n,e);this.setValue(r),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(t=0){if(!this._iconButton){t<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)});return}const e=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)}):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)})}_createPopover(t){if(!t)return;if(!document.getElementById(t)){setTimeout(()=>{this._createPopover(t)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),this.closest("mint-modal")?document.body.appendChild(this._popover):this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute("trigger-id",t),this._popoverObserver||(this._popoverObserver=new MutationObserver(s=>{s.forEach(n=>{var r;if(n.type==="attributes"&&n.attributeName==="open")if((r=this._popover)==null?void 0:r.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const o=this._popover;typeof o.render=="function"&&o.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var o;(o=this._iconButton)==null||o.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const o=new Date;this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var l;const o=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(l=this._hiddenInput)==null||l.dispatchEvent(o)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==t){this._popover.setAttribute("trigger-id",t);const s=this._popover;typeof s._setupTrigger=="function"&&s._setupTrigger()}this._buildCalendar()}}_buildCalendar(){if(!this._popover)return;this._calendarContainer&&this._calendarContainer.parentNode&&this._calendarContainer.remove(),this._calendarContainer=document.createElement("div"),this._calendarContainer.className="mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]",this._viewMode==="calendar"?this._buildCalendarView():this._viewMode==="month"?this._buildMonthView():this._viewMode==="year"&&this._buildYearView();const t=this._popover.querySelector(".popover-content");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const t=this._getDaysInMonth(this._currentMonth,this._currentYear),e=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=this.getWeekStartDay(),n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=[...n.slice(s),...n.slice(0,s)],a=this.getShortcuts(),o=a.length>0;this._calendarContainer.className=o?"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]":"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";const l=document.createElement("div");l.className="flex flex-col md:flex-row md:gap-6 md:items-start";const c=document.createElement("div");c.className="flex-1 min-w-0";const d=document.createElement("div");d.className="flex items-center justify-between mb-4";const u=document.createElement("button");u.type="button",u.tabIndex=0,u.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",u.setAttribute("data-keep-popover-open","true");const h=document.createElement("mint-icon");h.setAttribute("name","caret-left"),h.className="w-4 h-4",u.appendChild(h),u.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),d.appendChild(u);const f=document.createElement("div");f.className="flex items-center gap-2";const p=document.createElement("button");p.type="button",p.tabIndex=0,p.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",p.setAttribute("data-keep-popover-open","true"),p.textContent=i[this._currentMonth],p.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),f.appendChild(p);const m=document.createElement("button");m.type="button",m.tabIndex=0,m.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",m.setAttribute("data-keep-popover-open","true"),m.textContent=String(this._currentYear),m.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),f.appendChild(m),d.appendChild(f);const _=document.createElement("button");_.type="button",_.tabIndex=0,_.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",_.setAttribute("data-keep-popover-open","true");const g=document.createElement("mint-icon");g.setAttribute("name","caret-right"),g.className="w-4 h-4",_.appendChild(g),_.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),d.appendChild(_);const v=document.createElement("div");v.className="grid grid-cols-7 mb-2",r.forEach(w=>{const I=document.createElement("div");I.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",I.textContent=w,v.appendChild(I)});const b=document.createElement("div");b.className="grid grid-cols-7";const k=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,A=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null,E=this._currentMonth===0?11:this._currentMonth-1,y=this._currentMonth===0?this._currentYear-1:this._currentYear,x=this._getDaysInMonth(E,y),T=this._currentMonth===11?0:this._currentMonth+1,R=this._currentMonth===11?this._currentYear+1:this._currentYear,P=e+t,vt=Math.ceil(P/7)*7-P,Y=(w,I,S)=>{const V=this._isToday(w),O=this._isDateSelected(w),$=this._isDateInRange(w),F=k&&w<k||A&&w>A;let M="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const D=this._isSameDate(w,this._selectedStartDate),L=this._isSameDate(w,this._selectedEndDate);D&&L?M="rounded-md":D?M="rounded-l-md":L?M="rounded-r-md":$&&(M="rounded-none")}else O&&!this._isRange&&(M="rounded-md");const N=document.createElement("button");N.type="button",N.disabled=!!F,N.tabIndex=F?-1:0;let B=`w-full h-8 ${M} border-0 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`;return S?B+=O?" bg-slate-800 dark:bg-slate-600 text-white":$?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":V?" text-gray-900 dark:text-gray-100 font-semibold":" text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700":B+=O?" bg-slate-800 dark:bg-slate-600 text-white":$?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":" text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700",B+=F?" opacity-40 cursor-not-allowed":"",N.className=B,N.textContent=I.toString(),F||N.addEventListener("click",()=>{this._handleDateClick(w)}),N};for(let w=e-1;w>=0;w--){const I=x-w,S=new Date(y,E,I),V=Y(S,I,!1);b.appendChild(V)}for(let w=1;w<=t;w++){const I=new Date(this._currentYear,this._currentMonth,w),S=Y(I,w,!0);b.appendChild(S)}for(let w=1;w<=vt;w++){const I=new Date(R,T,w),S=Y(I,w,!1);b.appendChild(S)}if(o){const w=document.createElement("div");w.className="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";const I=document.createElement("div");I.className="relative md:relative md:flex-1 md:min-h-0";const S=document.createElement("div");S.className="flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2",S.style.scrollbarWidth="none",S.style.msOverflowStyle="none",S.style.setProperty("-webkit-overflow-scrolling","touch");const V=document.createElement("style");V.textContent=`
|
|
65
|
+
`,document.head.appendChild(t),W._activeShadowStyleInjected=!0}this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add("w-full")}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}getType(){const t=this.getAttribute("type"),e=this.getAttribute("button-type");return(t||e||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}isActive(){const t=this.getAttribute("active");return!(t===null||t==="false"||t==="0")}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.removeAttribute("active")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,n,r,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const e=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(e&&((n=e.textContent)!=null&&n.trim()))return!1;if(this._button)for(let o=this._button.firstChild;o;o=o.nextSibling){if(o.nodeType===Node.TEXT_NODE&&((r=o.textContent)!=null&&r.trim()))return!1;if(o.nodeType===Node.ELEMENT_NODE){const l=o;if(l.tagName!=="MINT-ICON"&&l.tagName!=="MINT-SPINNER"&&!l.querySelector("mint-spinner")&&!l.hasAttribute("slot")&&l.className!=="mint-button-icon"&&!(l.className==="mr-2"&&l.querySelector("mint-spinner"))&&(a=l.textContent)!=null&&a.trim())return!1}}return!0}getActiveStateClasses(){const t=this.getVariant(),e=this.getTone(),i=`${t}-${e}`;return{"solid-action":["!bg-slate-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-slate-700","hover:!bg-slate-900","dark:hover:!bg-slate-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-neutral":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"solid-info":["!bg-blue-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-blue-700","hover:!bg-blue-900","dark:hover:!bg-blue-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-warning":["!bg-amber-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-amber-700","hover:!bg-amber-900","dark:hover:!bg-amber-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"solid-danger":["!bg-red-900","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:!bg-red-700","hover:!bg-red-900","dark:hover:!bg-red-700","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]"],"ghost-action":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-neutral":["!bg-gray-50","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","!text-gray-900","dark:!text-white","hover:!bg-gray-50","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","hover:!text-gray-900","dark:hover:!text-white"],"ghost-info":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-warning":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-danger":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"link-action":["!text-slate-900","dark:!text-slate-300","hover:!text-slate-900","dark:hover:!text-slate-300"],"link-neutral":["!text-gray-950","dark:!text-gray-200","hover:!text-gray-950","dark:hover:!text-gray-200"],"link-info":["!text-blue-900","dark:!text-blue-200","hover:!text-blue-900","dark:hover:!text-blue-200"],"link-warning":["!text-amber-900","dark:!text-amber-200","hover:!text-amber-900","dark:hover:!text-amber-200"],"link-danger":["!text-red-900","dark:!text-red-200","hover:!text-red-900","dark:hover:!text-red-200"]}[i]||[]}getButtonClasses(){const t=this.isIconOnly(),e=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...t?["p-1.5","aspect-square","w-[2.25rem]","h-[2.25rem]"]:["px-3.5","py-1.5","min-h-[2.25rem]"],"text-sm","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","[&.mint-button-active>*]:scale-95","[&>*]:transition-transform","[&>*]:duration-100","disabled:opacity-50","disabled:cursor-not-allowed"],s=this.getTone(),n={"solid-action":["bg-slate-800","dark:bg-slate-600","text-white","hover:bg-slate-950","dark:hover:bg-slate-700","active:bg-slate-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-slate-700","disabled:active:bg-slate-800","dark:disabled:active:bg-slate-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-neutral":["bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","hover:bg-gray-50","dark:hover:bg-gray-600","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-white","dark:disabled:active:bg-gray-700","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-gray-200","dark:border-gray-600"],"solid-info":["bg-blue-800","dark:bg-blue-600","text-white","hover:bg-blue-950","dark:hover:bg-blue-700","active:bg-blue-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-blue-700","disabled:active:bg-blue-800","dark:disabled:active:bg-blue-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-warning":["bg-amber-800","dark:bg-amber-600","text-white","hover:bg-amber-950","dark:hover:bg-amber-700","active:bg-amber-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-amber-700","disabled:active:bg-amber-800","dark:disabled:active:bg-amber-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"solid-danger":["bg-red-800","dark:bg-red-600","text-white","hover:bg-red-950","dark:hover:bg-red-700","active:bg-red-900","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","dark:active:bg-red-700","disabled:active:bg-red-800","dark:disabled:active:bg-red-600","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-sm","hover:shadow","dark:shadow-gray-900/50","border-2","border-transparent"],"ghost-action":["bg-transparent","text-slate-800","dark:text-slate-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-neutral":["bg-transparent","text-gray-700","dark:text-gray-200","active:bg-gray-50","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","active:text-gray-900","dark:active:text-white","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-info":["bg-transparent","text-blue-800","dark:text-blue-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-warning":["bg-transparent","text-amber-800","dark:text-amber-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-danger":["bg-transparent","text-red-800","dark:text-red-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-action":["bg-transparent","text-slate-800","dark:text-slate-400","hover:text-slate-950","dark:hover:text-slate-200","active:text-slate-900","dark:active:text-slate-300","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-neutral":["bg-transparent","text-gray-700","dark:text-gray-300","hover:text-gray-900","dark:hover:text-gray-100","active:text-gray-950","dark:active:text-gray-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-info":["bg-transparent","text-blue-800","dark:text-blue-400","hover:text-blue-950","dark:hover:text-blue-300","active:text-blue-900","dark:active:text-blue-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-warning":["bg-transparent","text-amber-800","dark:text-amber-400","hover:text-amber-950","dark:hover:text-amber-300","active:text-amber-900","dark:active:text-amber-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-danger":["bg-transparent","text-red-800","dark:text-red-400","hover:text-red-950","dark:hover:text-red-300","active:text-red-900","dark:active:text-red-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"]},r=`${e}-${s}`,a=n[r]||n["solid-neutral"],o=[...i,...a];if(this.isActive()){const l=this.getActiveStateClasses();o.push(...l),o.push("[&>*]:scale-95")}return this.isFullWidth()&&o.push("w-full"),o.join(" ")}render(){var d,p,h,u,f,m;const t=this.isDisabled()||this.isLoading(),e=this.getType();if(!this._button){for(this._button=document.createElement("button");this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=e,this._button.disabled=t;let i=this._button.querySelector("mint-spinner");const s=this.isLoading();if(s)if(i)i.setAttribute("data-button-variant",this.getVariant()),i.setAttribute("data-button-tone",this.getTone()),"render"in i&&typeof i.render=="function"&&i.render();else{const _=document.createElement("span");_.className="mr-2 inline-flex items-center";const g=document.createElement("mint-spinner");g.setAttribute("size","default"),g.setAttribute("data-button-variant",this.getVariant()),g.setAttribute("data-button-tone",this.getTone()),g.style.width="0.875rem",g.style.height="0.875rem",_.appendChild(g),this._button.insertBefore(_,this._button.firstChild)}else i&&((d=i.parentElement)==null||d.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const n=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');n?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",n),r.className="mint-button-icon"):r.setAttribute("name",n)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const a=this.getIconPosition();let o=this._button.querySelector(".mint-button-content");if(o){const _=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const g=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;_||a==="left"?g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o):o.insertAdjacentElement("afterend",r)}else if(r&&(_||a==="left")&&r.nextSibling!==o){r.remove();const g=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o)}else r&&!_&&a==="right"&&r.previousSibling!==o&&(r.remove(),o.insertAdjacentElement("afterend",r))}else{const _=[];for(let g=this._button.firstChild;g;g=g.nextSibling){if(g.nodeType!==Node.ELEMENT_NODE){_.push(g);continue}const v=g;v.tagName!=="MINT-SPINNER"&&!v.querySelector("mint-spinner")&&g!==r&&!v.hasAttribute("slot")&&!(v.className==="mr-2"&&v.querySelector("mint-spinner"))&&_.push(g)}if(_.length>0){o=document.createElement("span"),o.className="mint-button-content inline-flex items-center",_.forEach(v=>{o.appendChild(v)});const g=(p=this._button.querySelector("mint-spinner"))==null?void 0:p.parentElement;r&&a==="left"?g?(g.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",o)):r&&a==="right"?g?(g.insertAdjacentElement("afterend",o),o.insertAdjacentElement("afterend",r)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement("afterend",r)):g?g.insertAdjacentElement("afterend",o):this._button.insertBefore(o,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const g=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;g?g.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();if(r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),s?r.style.display="none":r.style.display="",r.classList.remove("mr-1.5","ml-1.5"),l?r.tagName==="MINT-ICON"?(r.style.width="1rem",r.style.height="1rem",r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0"):(r.style.maxWidth="1rem",r.style.maxHeight="1rem",r.style.flexShrink="0",r.tagName==="svg"&&(r.style.width="1rem",r.style.height="1rem")):a==="left"?r.classList.add("mr-1.5"):r.classList.add("ml-1.5")),s){const _=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;_&&(l?(_.classList.remove("mr-2"),_.classList.add("mr-0")):_.classList.contains("mr-2")||(_.classList.remove("mr-0"),_.classList.add("mr-2")))}const c=this.getButtonClasses();this._button.className=c,this.setAttribute("data-variant",this.getVariant()),this.setAttribute("data-tone",this.getTone()),this.isActive()?this._button.classList.add("mint-button-active"):this._button.classList.remove("mint-button-active")}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener("click",this._clickHandler,!0),this._button.addEventListener("mousedown",this._handleMouseDown),this._button.addEventListener("mouseup",this._handleMouseUp),this._button.addEventListener("mouseleave",this._handleMouseLeave),this._button.addEventListener("touchstart",this._handleTouchStart),this._button.addEventListener("touchend",this._handleTouchEnd),this._button.addEventListener("touchcancel",this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&(this._button.removeEventListener("click",this._clickHandler,!0),this._clickHandler=null),this._button.removeEventListener("mousedown",this._handleMouseDown),this._button.removeEventListener("mouseup",this._handleMouseUp),this._button.removeEventListener("mouseleave",this._handleMouseLeave),this._button.removeEventListener("touchstart",this._handleTouchStart),this._button.removeEventListener("touchend",this._handleTouchEnd),this._button.removeEventListener("touchcancel",this._handleTouchCancel))}handleClick(t){if(this.isDisabled()||this.isLoading()){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0}));return}if(t.stopPropagation(),t.stopImmediatePropagation(),this._isHandlingClick){t.preventDefault();return}this._isHandlingClick=!0,t.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};W._activeShadowStyleInjected=!1;let j=W;customElements.get("mint-button")||customElements.define("mint-button",j);class X extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._checked=this.hasAttribute("checked"),this.render()}_getSwitchContainer(){let t=this.querySelector(".mint-switch-container");return t||(t=document.createElement("div"),t.className="mint-switch-container flex items-center gap-2",this.insertBefore(t,this.firstChild)),t}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this.render()}catch{}}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getIcon(){return this.getAttribute("icon")||""}hasIcon(){return!!this.getIcon()}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getSwitchClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","rounded-full","h-5","w-10","border","transition-colors","duration-200","ease-in-out","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","disabled:opacity-50","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-950","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",t?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...e,...i].join(" ")}getThumbClasses(){const t=["relative","inline-block","rounded-full","bg-white","dark:bg-gray-50","h-4","w-4","shadow-lg","transform","transition-transform","duration-200","ease-in-out","pointer-events-none","overflow-hidden"],e=this._checked?"translate-x-5":"translate-x-0.5";return[...t,e].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const t=this.isLoading(),e=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),n=this.getInfo(),r=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const o=this._getSwitchContainer();this._button?this._button.parentElement!==o&&o.appendChild(this._button):(this._button=document.createElement("button"),o.appendChild(this._button),this.setupEventListeners());let l=o.querySelector(".mint-switch-label");s?(l||(l=document.createElement("label"),l.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===o?o.insertBefore(l,this._button.nextSibling):o.appendChild(l)),l.textContent=s,l.setAttribute("for",a),this.isDisabled()?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove(),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.id=a,this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",s||"Toggle switch"),this._button.setAttribute("role","switch"),this._button.type="button";let c=this._button.querySelector("span");c||(c=document.createElement("span"),this._button.appendChild(c)),c.className=i;const d=c.querySelector("span");if(r){let h=d;h||(h=document.createElement("span"),h.className=this.getIconClasses(),c.appendChild(h));let u=h.querySelector("mint-icon");u||(u=document.createElement("mint-icon"),h.appendChild(u)),u.setAttribute("name",r)}else d&&d.remove();let p=this.querySelector(".mint-switch-info");n?(p||(p=document.createElement("span"),p.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",o&&o.parentElement===this?this.insertBefore(p,o.nextSibling):this.appendChild(p)),p.textContent=n,this.isDisabled()?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove(),this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(t){if(!this.isDisabled()){this.checked=!this._checked;const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("toggle",{detail:{checked:this._checked},bubbles:!0,cancelable:!0}))}}_renderSkeleton(t){const e=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let n=e.querySelector(".mint-switch-skeleton-container"),r=this.querySelector(".mint-switch-info-skeleton");if(t){e.classList.contains("relative")||e.classList.add("relative"),n||(n=document.createElement("div"),n.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",e.appendChild(n));let a=n.querySelector(".mint-switch-skeleton-box");if(a||(a=document.createElement("div"),a.className="mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(a)),i){let l=n.querySelector(".mint-switch-skeleton-label");l||(l=document.createElement("div"),l.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(l))}else{const l=n.querySelector(".mint-switch-skeleton-label");l&&l.remove()}n.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const o=e.querySelector(".mint-switch-label");if(o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),s){r||(r=document.createElement("div"),r.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",e&&e.parentElement===this?this.insertBefore(r,e.nextSibling):this.appendChild(r)),r.style.display="block";const l=this.querySelector(".mint-switch-info");l&&(l.style.display="none")}else r&&(r.style.display="none")}else{n&&(n.style.display="none"),r&&(r.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=e.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const o=this.querySelector(".mint-switch-info");o&&(o.style.display="")}}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",X);class K extends HTMLElement{constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}static get observedAttributes(){return["variant","size","bold","underline","strike","italic","display"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline"),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getVariant(){return this.getAttribute("variant")||"default"}getSize(){return this.getAttribute("size")||"regular"}isBold(){return this.hasAttribute("bold")}isUnderline(){return this.hasAttribute("underline")}isStrike(){return this.hasAttribute("strike")}isItalic(){return this.hasAttribute("italic")}getDisplay(){return this.hasAttribute("display")?this.getAttribute("display"):this.getSize()==="regular"?"inline-block":"block"}getTextClasses(){const t=this.getSize(),e=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},n={default:i?["text-gray-100"]:["text-gray-900"],muted:i?["text-gray-400"]:["text-gray-400"],danger:i?["text-red-400"]:["text-red-600"],success:i?["text-green-400"]:["text-green-600"]},r=[];this.isBold()&&r.push("font-bold"),this.isUnderline()&&r.push("underline"),this.isStrike()&&r.push("line-through"),this.isItalic()&&r.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[t]||s.regular,...n[e]||n.default,...r].join(" ")}render(){const t=this.getSize(),e=["text-gray-100","text-gray-900","text-gray-400","text-red-400","text-red-600","text-green-400","text-green-600"],i=["text-2xl","text-lg","text-sm"];i.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)}),e.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)});const s=this.getTextClasses().split(" ").filter(l=>l.trim());Array.from(this.classList).forEach(l=>{!e.includes(l)&&!i.includes(l)&&this._userClasses.add(l)});const r=[...new Set([...s,...Array.from(this._userClasses)])];this.className=r.join(" ");const a={heading:"clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)","sub-heading":"clamp(1rem, 1.5vw + 0.5rem, 1.125rem)",regular:"clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"},o=a[t]||a.regular;this.style.setProperty("font-size",o)}}customElements.get("mint-text")||customElements.define("mint-text",K);class Z extends HTMLElement{constructor(){super(),this._childObserver=null}static get observedAttributes(){return["direction","text-align","gap"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(t,e,i){e!==i&&(this.render(),t==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const t=this.getTextAlign();t&&this._applyTextAlignToChildren(t)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&(this._childObserver.disconnect(),this._childObserver=null)}getDirection(){return(this.getAttribute("direction")||"vertical")==="horizontal"?"horizontal":"vertical"}getGap(){const t=this.getAttribute("gap")||"3";return parseFloat(t)}getTextAlign(){const t=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(t)?t:""}getStackClasses(){const t=this.getDirection(),e=this.getTextAlign(),i=this.getGap(),s=["flex",t==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return e&&(s.push(`text-${e}`),s.push(`[&>*]:text-${e}`),s.push(`[&>*_.mint-button-content]:text-${e}`),e==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):e==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):e==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const t=this.getStackClasses(),e=this.getTextAlign();["flex","flex-row","flex-col","gap-1","gap-2","gap-3","text-left","text-center","text-right","text-justify","[&>*]:text-left","[&>*]:text-center","[&>*]:text-right","[&>*]:text-justify","[&>*_.mint-button-content]:text-left","[&>*_.mint-button-content]:text-center","[&>*_.mint-button-content]:text-right","[&>*_.mint-button-content]:text-justify","[&>mint-button]:!justify-start","[&>mint-button]:!justify-center","[&>mint-button]:!justify-end","[&>mint-button>button]:!justify-start","[&>mint-button>button]:!justify-center","[&>mint-button>button]:!justify-end"].forEach(n=>this.classList.remove(n)),t.split(" ").forEach(n=>{n&&this.classList.add(n)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(n=>{this.classList.contains(n)||this.classList.add(n)}),e?this._applyTextAlignToChildren(e):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(t){Array.from(this.children).forEach(i=>{if(i.tagName==="MINT-BUTTON"){const s=i.querySelector("button");if(s){s.classList.remove("justify-start","justify-center","justify-end"),t==="left"?s.classList.add("justify-start"):t==="right"?s.classList.add("justify-end"):t==="center"&&s.classList.add("justify-center");const n=s.querySelector(".mint-button-content");n&&(n.classList.remove("text-left","text-center","text-right","text-justify"),n.classList.add(`text-${t}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${t}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName==="MINT-BUTTON"){const i=e.querySelector("button");if(i){i.classList.remove("justify-start","justify-end"),i.classList.add("justify-center");const s=i.querySelector(".mint-button-content");s&&s.classList.remove("text-left","text-center","text-right","text-justify")}}else e.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",Z);class Q extends HTMLElement{constructor(){super(),this._headingElement=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add("rounded-lg","shadow","bg-white","dark:bg-gray-800","border","border-gray-200","dark:border-gray-700","overflow-hidden","transition-colors","duration-200","mb-6"),this.hasPaddingClass()||this.classList.add("p-4");const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",Q);class tt extends HTMLElement{constructor(){super(),this._link=null,this._contentObserver=null}static get observedAttributes(){return["href","target"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&(this._contentObserver.disconnect(),this._contentObserver=null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll("mint-text").forEach(e=>{e.classList.contains("underline")||e.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var t;return!!(this.querySelector("mint-icon")||(t=this._link)!=null&&t.querySelector("mint-icon"))}render(){const t=this.getHref(),e=this.getTarget();if(!this._link){for(this._link=document.createElement("a");this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=t,e?(this._link.target=e,e==="_blank"&&(this._link.rel="noopener noreferrer")):(this._link.removeAttribute("target"),this._link.removeAttribute("rel"));const i=this.hasIcon(),s=["text-slate-800","dark:text-slate-200","underline","hover:text-slate-950","dark:hover:text-slate-100","transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"];i&&s.push("inline-flex","items-center","gap-2"),this._link.className=s.join(" "),this._link.querySelectorAll("mint-text").forEach(a=>{a.classList.contains("underline")||a.classList.add("underline")}),["box-border","m-0","p-0","border-0","align-baseline","inline-block"].forEach(a=>{this.classList.contains(a)||this.classList.add(a)})}}customElements.get("mint-link")||customElements.define("mint-link",tt);class et extends HTMLElement{constructor(){super(),this._button=null}static get observedAttributes(){return["href","fallback-href"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center","justify-center"),this.render()}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const t=document.referrer,e=window.location.origin;if(t)try{const i=new URL(t);if(i.origin===e)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(t){t.preventDefault(),t.stopPropagation();const e=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),n=new CustomEvent("back",{detail:{url:e,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",t=>this.handleClick(t)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",et);class it extends HTMLElement{constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._backButton=null,this._backButtonHandler=null}static get observedAttributes(){return["heading","fallback-href","show-back-button","containered"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode(),this._setupBackButtonListener()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._removeBackButtonListener()}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.hasAttribute("show-back-button")}render(){const t=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this.appendChild(this._pageContainer)),this._applyContainerClasses(),this._header||(this._header=document.createElement("div"),this._header.className="flex justify-between mb-8",this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement("div"),this._titleElement.className="flex gap-4 min-w-0 flex-1",this._header.appendChild(this._titleElement));let e=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){e||(e=document.createElement("mint-back-button"),this._titleElement.insertBefore(e,this._titleElement.firstChild));const r=this.getFallbackHref();e.setAttribute("fallback-href",r),this._backButton=e}else e&&(e.remove(),e=null,this._backButton=null);t?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._headingText.previousSibling!==e&&this._titleElement.insertBefore(this._headingText,e.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement("mint-text"),this._headingText.setAttribute("size","heading"),this._headingText.setAttribute("bold",""),this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,e.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=t):this._headingText&&(this._headingText.remove(),this._headingText=null),this._actionsSlot?this._actionsSlot.classList.contains("ml-4")||this._actionsSlot.classList.add("ml-4"):(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="flex gap-2 items-center ml-4",this._actionsSlot.setAttribute("slot","actions"),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(r=>r!==this._pageContainer&&r!==this._actionsSlot&&r.getAttribute("slot")==="actions").forEach(r=>{this._actionsSlot&&r.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(r)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(r=>{r!==this._pageContainer&&r.getAttribute("slot")!=="actions"&&r!==this._actionsSlot&&r!==this._header&&r!==this._bodySlot&&r!==this._headingText&&r.parentElement!==this._bodySlot&&r.parentElement!==this._pageContainer&&this._bodySlot.appendChild(r)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add("min-h-screen","p-8","transition-colors","duration-200"),this.hasAttribute("containered")?this._pageContainer.classList.add("max-w-6xl","mx-auto","w-full"):this._pageContainer.classList.remove("max-w-6xl","mx-auto"))}_updateBackgroundColor(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-20"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-20"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_setupBackButtonListener(){this._backButtonHandler||(this._backButtonHandler=t=>{const e=t.target;if(e&&e.tagName==="MINT-BACK-BUTTON"){t.stopPropagation();const i=new CustomEvent("back",{detail:t.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}}),this.addEventListener("back",this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&(this.removeEventListener("back",this._backButtonHandler,!0),this._backButtonHandler=null)}}customElements.get("mint-page")||customElements.define("mint-page",it);class st extends HTMLElement{static get observedAttributes(){return["columns","sm","md","lg","xl","gap"]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getColumns(){return this.getAttribute("columns")||"1"}getSm(){return this.getAttribute("sm")}getMd(){return this.getAttribute("md")}getLg(){return this.getAttribute("lg")}getXl(){return this.getAttribute("xl")}getGap(){return"3"}getGridClasses(){const t=["grid"],e=this.getColumns();t.push(`grid-cols-${e}`);const i=this.getSm();i&&t.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&t.push(`md:grid-cols-${s}`);const n=this.getLg();n&&t.push(`lg:grid-cols-${n}`);const r=this.getXl();r&&t.push(`xl:grid-cols-${r}`);const a=this.getGap();return t.push(`gap-${a}`),t}render(){Array.from(this.classList).filter(i=>i.startsWith("grid-cols-")||i.startsWith("sm:grid-cols-")||i.startsWith("md:grid-cols-")||i.startsWith("lg:grid-cols-")||i.startsWith("xl:grid-cols-")||i.startsWith("gap-")).forEach(i=>this.classList.remove(i)),this.classList.contains("grid")||this.classList.add("grid"),this.getGridClasses().forEach(i=>{i&&i!=="grid"&&this.classList.add(i)})}}customElements.get("mint-grid")||customElements.define("mint-grid",st);class rt extends HTMLElement{constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen();if(t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement("div"),this._modal.className="fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50",this.appendChild(this._modal)),i){let d=this._modal.querySelector(".modal-content");d||(d=document.createElement("div"),d.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(d)),this._animateEnter()}else this._animateExit();let s=this._modal.querySelector(".modal-content");s||(s=document.createElement("div"),s.className="modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(s)),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let n=this._headingSlot.querySelector("mint-text");e?(n||(n=document.createElement("mint-text"),n.setAttribute("size","sub-heading"),n.setAttribute("bold",""),this._headingSlot.appendChild(n)),n.textContent=e):n&&n.remove(),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._headingSlot&&d.getAttribute("slot")==="heading").forEach(d=>{this._headingSlot&&d.parentElement!==this._headingSlot&&this._headingSlot.appendChild(d)}),this._closeButton||(this._closeButton=document.createElement("mint-button"),this._closeButton.setAttribute("variant","ghost"),this._closeButton.setAttribute("icon","close"),this._closeButton.addEventListener("click",()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement("div"),this._bodySlot.className="flex-1 overflow-y-auto p-4",this._bodySlot.setAttribute("slot","body"),s.appendChild(this._bodySlot)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._bodySlot&&d.getAttribute("slot")==="body").forEach(d=>{this._bodySlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700",this._actionsSlot.setAttribute("slot","actions"),s.appendChild(this._actionsSlot));let o=this._actionsSlot.querySelector("mint-stack");o||(o=document.createElement("mint-stack"),o.setAttribute("direction","horizontal"),o.className="justify-end",this._actionsSlot.appendChild(o)),Array.from(this.children).filter(d=>d!==this._overlay&&d!==this._modal&&d!==this._actionsSlot&&d.getAttribute("slot")==="actions").forEach(d=>{Array.from(d.children).forEach(h=>{h.parentElement!==o&&o.appendChild(h)}),d.parentElement&&d.remove()}),Array.from(this.children).forEach(d=>{d!==this._overlay&&d!==this._modal&&d.getAttribute("slot")!=="heading"&&d.getAttribute("slot")!=="body"&&d.getAttribute("slot")!=="actions"&&d!==this._headingSlot&&d!==this._bodySlot&&d!==this._actionsSlot&&d.parentElement!==this._bodySlot&&this._bodySlot.appendChild(d)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const t=document.documentElement.classList.contains("dark"),e=this._modal.querySelector(".modal-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");t&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})}))}_animateExit(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");if(!t){this.classList.add("hidden");return}t.style.transition="all 200ms ease-in",t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.opacity="",t.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",rt);class nt extends HTMLElement{constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._hoverCloseTimeout=null,this._scrollHandler=null,this._resizeHandler=null}static get observedAttributes(){return["id","direction","open","trigger-id","padding","hover"]}connectedCallback(){const t=this._isInsideModal()?"z-[60]":"z-50";this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0",t,"pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}_isInsideModal(){let t=this;for(;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}if(this._triggerElement)for(t=this._triggerElement;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}return!1}disconnectedCallback(){this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&this._triggerElement.removeAttribute("active"),this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler),this._clickOutsideHandler=null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}attributeChangedCallback(t,e,i){if(e!==i){if(this.isConnected){const s=this._isInsideModal()?"z-[60]":"z-50";this.classList.remove("z-50","z-[60]"),this.classList.add(s)}this.render(),(t==="trigger-id"||t==="hover")&&this._setupTrigger(),t==="open"&&this.isOpen()&&this._closeOtherPopovers()}}getId(){return this.getAttribute("id")||""}getPadding(){const t=this.getAttribute("padding")||"4";return{0:"p-0","0.5":"p-0.5",1:"p-1","1.5":"p-1.5",2:"p-2","2.5":"p-2.5",3:"p-3","3.5":"p-3.5",4:"p-4",5:"p-5",6:"p-6",8:"p-8",10:"p-10",12:"p-12",16:"p-16",20:"p-20",24:"p-24"}[t]||"p-4"}getDirection(){return this.getAttribute("direction")||"down"}getTriggerId(){return this.getAttribute("trigger-id")||""}isHoverEnabled(){return this.hasAttribute("hover")}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}_setupTrigger(){const t=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),t&&(this._triggerElement=document.getElementById(t),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(t),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const t=this;this._triggerClickHandler=function(e){e.stopImmediatePropagation(),e.preventDefault(),t.hasAttribute("open")?t.removeAttribute("open"):t.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const t=this;this._triggerHoverEnterHandler=function(){t._cancelHoverClose(),t.open()},this._triggerHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){t._cancelHoverClose()},this._popoverHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._popover.addEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover.addEventListener("mouseleave",this._popoverHoverLeaveHandler))}_removeHoverListeners(){this._triggerElement&&this._triggerHoverEnterHandler&&this._triggerElement.removeEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement&&this._triggerHoverLeaveHandler&&this._triggerElement.removeEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&this._popoverHoverEnterHandler&&this._popover.removeEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover&&this._popoverHoverLeaveHandler&&this._popover.removeEventListener("mouseleave",this._popoverHoverLeaveHandler),this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._cancelHoverClose()}_scheduleHoverClose(){this._cancelHoverClose(),this._hoverCloseTimeout=window.setTimeout(()=>{this._isHovering()||this.close()},120)}_cancelHoverClose(){this._hoverCloseTimeout!==null&&(clearTimeout(this._hoverCloseTimeout),this._hoverCloseTimeout=null)}_isHovering(){const t=this._triggerElement?this._triggerElement.matches(":hover"):!1,e=this._popover?this._popover.matches(":hover"):!1;return t||e}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const t=this._triggerElement.getBoundingClientRect(),e=this._popover.querySelector(".popover-content");if(!e)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,a=8;let o=this.getDirection(),l=0,c=0;switch(o){case"down":if(l=t.bottom+a,c=t.left+t.width/2-s.width/2,l+s.height>r){const d=t.top-s.height-a;d>=0?(o="up",l=d):(l=Math.max(0,r-s.height-a),l+s.height>r&&(l=0))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"up":if(l=t.top-s.height-a,c=t.left+t.width/2-s.width/2,l<0){const d=t.bottom+a;d+s.height<=r?(o="down",l=d):(l=Math.min(r-s.height-a,r-s.height),l<0&&(l=r-s.height))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"right":if(l=t.top+t.height/2-s.height/2,c=t.right+a,c+s.width>n){const d=t.left-s.width-a;d>=0?(o="left",c=d):(c=Math.max(0,n-s.width-a),c+s.width>n&&(c=n-s.width))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break;case"left":if(l=t.top+t.height/2-s.height/2,c=t.left-s.width-a,c<0){const d=t.right+a;d+s.width<=n?(o="right",c=d):(c=Math.min(n-s.width-a,n-s.width),c<0&&(c=0))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break}return{top:l,left:c,direction:o}}render(){const t=this.getId(),e=this.isOpen(),i=this.getPadding();if(t&&(this.id=t),e){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.setAttribute("active","true");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),!this._clickOutsideHandler){const r=this;this._clickOutsideHandler=function(a){const o=a.composedPath(),l=o.includes(r);if(!(r._triggerElement&&o.includes(r._triggerElement))&&!l){r.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.removeAttribute("active");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);if(this._overlay){const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`}else{this._overlay=document.createElement("div");const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`,this.appendChild(this._overlay)}if(this._popover){const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`}else{this._popover=document.createElement("div");const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`,this.appendChild(this._popover)}this.isHoverEnabled()&&this._attachHoverListeners();let s=this._popover.querySelector(".popover-content");if(!s)s=document.createElement("div"),s.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`,this._popover.appendChild(s);else{const r=s.className.split(" "),a=["p-0","p-0.5","p-1","p-1.5","p-2","p-2.5","p-3","p-3.5","p-4","p-5","p-6","p-8","p-10","p-12","p-16","p-20","p-24"],o=r.filter(l=>!a.includes(l));s.className=[...o,i].join(" ")}Array.from(this.children).forEach(r=>{r!==this._overlay&&r!==this._popover&&r.parentElement===this&&s.appendChild(r)}),e?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(s):(this._popover.style.top="50%",this._popover.style.left="50%",this._popover.style.transform="translate(-50%, -50%)",this._popover.style.visibility="visible",this._popover.style.display="block",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",s.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.style.transform="scale(1) translateY(0)",s.style.opacity="1"})}))):!e&&s&&(this._removePositionListeners(),s.style.opacity!=="0"&&s.style.opacity!==""&&(s.style.transition="all 200ms ease-in",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",setTimeout(()=>{s.style.transform="",s.style.opacity="",s.style.transition="",this._popover.style.visibility="",this._popover.style.display=""},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;const t=document.documentElement.classList.contains("dark"),e=this._popover.querySelector(".popover-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(t){if(!this._triggerElement||!this._popover)return;const e=this._popover.style.visibility!=="hidden";e||(this._popover.style.visibility="hidden",this._popover.style.display="block",this._popover.style.top="0",this._popover.style.left="0"),this._popover.offsetHeight;const i=this._calculatePosition();this._popover.style.top=`${i.top}px`,this._popover.style.left=`${i.left}px`,e||(this._popover.style.visibility="visible",t&&(!t.style.opacity||t.style.opacity==="")&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const t=this;this._scrollHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const t=this;this._resizeHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("resize",this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_closeOtherPopovers(){Array.from(document.querySelectorAll("mint-popover[open]")).forEach(e=>{if(e!==this){const i=e;typeof i.close=="function"?i.close():e.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",nt);class at extends HTMLElement{constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null,this._changeHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._touchstartHandler=null,this._touchendHandler=null,this._focusHandler=null,this._blurHandler=null}static get observedAttributes(){return["checked","disabled","label","info","id","name","value","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render(),t==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!t,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}catch{}}isDisabled(){return this.hasAttribute("disabled")}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getValue(){return this.getAttribute("value")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getCheckboxClasses(){const t=this.hasError(),e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-800","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",t?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...e,...i].join(" ")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let n=this.querySelector(".mint-checkbox-container");n||(n=document.createElement("div"),n.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(n,this.firstChild));let r=this.querySelector(".mint-checkbox-wrapper");r?r.parentElement!==n&&n.appendChild(r):(r=document.createElement("div"),r.className="mint-checkbox-wrapper",n.appendChild(r)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._checkbox.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;",this._checkbox.checked=this._checked,this._checkbox.disabled=s,this._changeHandler||this.setupEventListeners();const a=this.getId();a?this._checkbox.id=a:this._checkbox.removeAttribute("id");const o=this.getName();o?this._checkbox.name=o:this._checkbox.removeAttribute("name");const l=this.getValue();l?this._checkbox.value=l:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.cursor="pointer",r.style.pointerEvents="auto",this._checkbox.style.pointerEvents="auto";const c=r;c._wrapperClickHandler||(c._wrapperClickHandler=u=>{u.target===r&&!s&&(u.preventDefault(),u.stopPropagation(),this.toggle())},r.addEventListener("click",c._wrapperClickHandler));let d=r.querySelector("mint-icon");d||(d=document.createElement("mint-icon"),d.setAttribute("name","check"),d.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",d.style.transition="opacity 200ms ease-out, transform 200ms ease-out",d.style.zIndex="1",r.appendChild(d)),this.updateVisualState();let p=this.querySelector(".mint-checkbox-label-container");const h=this.querySelector(".mint-checkbox-container");if(e||i){p?h&&p.parentElement!==h&&h.appendChild(p):(p=document.createElement("div"),p.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",h?h.appendChild(p):this.appendChild(p));let u=p.querySelector(".mint-checkbox-label");e?(u||(u=document.createElement("span"),u.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",p.insertBefore(u,p.firstChild)),u.textContent=e,s?u.classList.add("opacity-40"):u.classList.remove("opacity-40")):u&&u.remove();let f=p.querySelector(".mint-checkbox-info");if(i?(f||(f=document.createElement("span"),f.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",p.appendChild(f)),f.textContent=i,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove(),s)p.style.cursor="default",p._clickHandler&&(p.removeEventListener("click",p._clickHandler),p._clickHandler=null);else{p.style.cursor="pointer";const m=p._clickHandler;m&&p.removeEventListener("click",m),p._clickHandler=_=>{this._checkbox&&(_.target===this._checkbox||this._checkbox.contains(_.target)||_.composedPath().includes(this._checkbox))||this.toggle()},p.addEventListener("click",p._clickHandler)}}else p&&p.remove();this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=t=>{t.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}));const i=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(i)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._mouseleaveHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(e==null||e.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&t.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._checkbox.addEventListener("focus",this._focusHandler),this._checkbox.addEventListener("blur",this._blurHandler),this._touchstartHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("touchstart",this._touchstartHandler),this._checkbox.addEventListener("touchend",this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&(this._checkbox.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._mousedownHandler&&(this._checkbox.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._checkbox.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._checkbox.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._checkbox.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._checkbox.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._checkbox.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._checkbox.removeEventListener("blur",this._blurHandler),this._blurHandler=null));const t=this.querySelector(".mint-checkbox-wrapper");if(t){const e=t;e._wrapperClickHandler&&(t.removeEventListener("click",e._wrapperClickHandler),e._wrapperClickHandler=null)}}updateVisualState(){const t=this.querySelector(".mint-checkbox-wrapper"),e=t==null?void 0:t.querySelector("mint-icon");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0.8)"),t&&(t.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,t.classList.contains("mint-checkbox-active")||(t.style.backgroundColor="",t.style.boxShadow=""))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState(),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0}));const t=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}_renderSkeleton(t){let e=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),n=this.querySelector(".mint-checkbox-label-container");if(t){e||(e=document.createElement("div"),e.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e)));let r=e.querySelector(".mint-checkbox-skeleton-box");if(r||(r=document.createElement("div"),r.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(r)),n){let a=e.querySelector(".mint-checkbox-skeleton-label");a||(a=document.createElement("div"),a.className="mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(a))}e.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),n&&(n.style.visibility="hidden",n.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),n&&(n.style.visibility="visible",n.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&t&&e&&(i=document.createElement("div"),i.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(i));let s=this.querySelector(".mint-checkbox-error");t&&e?(s?(s.classList.add("block","w-full"),s.style.display="block",(i&&s.parentElement!==i||i&&s.parentElement===i)&&i.appendChild(s)):(s=document.createElement("div"),s.className="mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full",s.style.display="block",i?i.appendChild(s):this.appendChild(s)),s.textContent=e):s&&s.remove();const n=this.querySelector(".mint-checkbox-wrapper");n&&(n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",at);class wt extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}static get observedAttributes(){return["value","checked","disabled","loading"]}connectedCallback(){this.classList.add("inline-flex","items-center","gap-2","cursor-pointer","select-none");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null),this._keydownHandler&&(this._radio.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null))}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),e!==i){if(t==="loading"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{this._checked=!!t,t?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}catch{}}getValue(){return this.getAttribute("value")||""}isDisabled(){const t=this.closest("mint-choice");return this.hasAttribute("disabled")||((t==null?void 0:t.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=t=>{t.target!==this._radio&&(this.isDisabled()||this._radio&&(this._radio.click(),requestAnimationFrame(()=>{if(this._radio&&this._radio.checked!==this._checked){this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const e=this.closest("mint-choice");e&&e.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener("click",this._clickHandler))}render(){var u;const t=this.isLoading(),e=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),n=(s==null?void 0:s.getAttribute("name"))||"";let r="";const a=this.querySelector(".mint-choice-option-label");a?r=((u=a.textContent)==null?void 0:u.trim())||"":Array.from(this.childNodes).forEach(f=>{var m;if(f.nodeType===Node.TEXT_NODE){const _=(m=f.textContent)==null?void 0:m.trim();_&&(r+=_)}});const o=this.querySelectorAll(".mint-choice-option-wrapper");let l=null;if(o.length>0&&(this._radio&&(l=Array.from(o).find(f=>f.contains(this._radio))),l||(l=o[0]),o.forEach((f,m)=>{f!==l&&f.remove()})),l||(l=document.createElement("div"),l.className="mint-choice-option-wrapper",l.style.position="relative",this.insertBefore(l,this.firstChild)),l.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,l.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(f=>{f!==this._radio&&f.remove()}),this._radio)this._radio.parentElement!==l&&l.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._radio.addEventListener("change",this._changeHandler)),this._radio&&(this._focusHandler||(this._focusHandler=f=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&!this.isDisabled()&&m.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const f=this.querySelector(".mint-choice-option-wrapper");f&&f.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=f=>{this.isDisabled()||(f.key==="ArrowDown"||f.key==="ArrowRight"?(f.preventDefault(),this._focusNextOption()):(f.key==="ArrowUp"||f.key==="ArrowLeft")&&(f.preventDefault(),this._focusPreviousOption()))}),this._radio.removeEventListener("focus",this._focusHandler),this._radio.removeEventListener("blur",this._blurHandler),this._radio.removeEventListener("keydown",this._keydownHandler),this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler),this._radio.addEventListener("keydown",this._keydownHandler));else{this._radio=document.createElement("input"),this._radio.type="radio",this._radio.className="sr-only",this._radio.style.position="absolute",this._radio.style.width="1px",this._radio.style.height="1px",this._radio.style.padding="0",this._radio.style.margin="-1px",this._radio.style.overflow="hidden",this._radio.style.clip="rect(0, 0, 0, 0)",this._radio.style.whiteSpace="nowrap",this._radio.style.border="0",l.appendChild(this._radio),this._changeHandler=m=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const g=this.closest("mint-choice");_!==this._checked&&g&&setTimeout(()=>{g.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const f=()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState())};this._radio.addEventListener("click",f),this._focusHandler=m=>{const _=this.querySelector(".mint-choice-option-wrapper");_&&!this.isDisabled()&&_.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._blurHandler=()=>{const m=this.querySelector(".mint-choice-option-wrapper");m&&m.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),this._keydownHandler=m=>{this.isDisabled()||(m.key==="ArrowDown"||m.key==="ArrowRight"?(m.preventDefault(),this._focusNextOption()):(m.key==="ArrowUp"||m.key==="ArrowLeft")&&(m.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener("keydown",this._keydownHandler)}this._radio.name=n,this._radio.value=i,this._radio.checked!==this._checked?(this._checked=this._radio.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked")):this._radio.checked=this._checked,this._radio.disabled=e,e?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),r?this._radio.setAttribute("aria-label",r):this._radio.removeAttribute("aria-label"),l.querySelectorAll(".mint-choice-option-indicator").forEach((f,m)=>{m>0&&f.remove()});let p=l.querySelector(".mint-choice-option-indicator");p||(p=document.createElement("div"),p.className="mint-choice-option-indicator",l.appendChild(p)),p.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",p.style.position="absolute",p.style.top="50%",p.style.left="50%",p.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",p.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(t);let h=this.querySelector(".mint-choice-option-label");r&&(h||(h=document.createElement("span"),h.className="mint-choice-option-label",this.appendChild(h),Array.from(this.childNodes).forEach(f=>{var m;f.nodeType===Node.TEXT_NODE&&((m=f.textContent)!=null&&m.trim())&&(f.textContent="")})),h.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e?"opacity-40":""}`,h.textContent=r),e?(this.classList.add("cursor-not-allowed"),this.classList.remove("cursor-pointer")):(this.classList.add("cursor-pointer"),this.classList.remove("cursor-not-allowed")),this._updateVisualState()}_getWrapperClasses(){const t=this.isDisabled(),e=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return t&&e.push("opacity-40","cursor-not-allowed"),this._checked?e.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):e.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),e.join(" ")}_updateVisualState(){const t=this.querySelector(".mint-choice-option-wrapper");t&&(t.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const e=this.querySelector(".mint-choice-option-indicator");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(t){let e=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(t){e||(e=document.createElement("div"),e.className="mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-choice-option-skeleton-radio");if(s||(s=document.createElement("div"),s.className="mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="hidden"),r&&(r.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(e&&(e.style.display="none"),i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="visible"),r&&(r.style.visibility="visible"),i.style.pointerEvents="auto"}const s=this.querySelector(".mint-choice-option-label");s&&!(i!=null&&i.contains(s))&&(s.style.visibility="visible",s.style.pointerEvents="auto")}}_updateGroupState(){var e;if(!((e=this._radio)!=null&&e.name))return;document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(i=>{if(i===this._radio)return;const s=i.closest("mint-choice-option");s&&s!==this&&(s._checked=i.checked,i.checked?s.setAttribute("checked",""):s.removeAttribute("checked"),s._updateVisualState())})}_focusNextOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>=0&&e<t.length-1?i=t[e+1]:t.length>0&&(i=t[0]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}_focusPreviousOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>0?i=t[e-1]:t.length>0&&(i=t[t.length-1]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked",""),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}customElements.get("mint-choice-option")||customElements.define("mint-choice-option",wt);class ot extends HTMLElement{constructor(){super(),this._optionsContainer=null}static get observedAttributes(){return["label","name","info","error","error-message","id","disabled","required","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","block","w-full"),this.render(),this.addEventListener("choice-change",t=>{var r;const i=((r=t.detail)==null?void 0:r.value)||this.getValue();(this.getAttribute("value")||"")!==i&&(i?this.setAttribute("value",i):this.removeAttribute("value"));const n=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent("input",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0}))})}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){e!==i&&(t==="error"||t==="error-message"?this._renderErrorState():t==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(n=>{this.isLoading()?n.setAttribute("loading",""):n.removeAttribute("loading")})):(this.render(),t==="name"&&this.querySelectorAll("mint-choice-option").forEach(n=>{typeof n.render=="function"&&n.render()})))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}isDisabled(){return this.hasAttribute("disabled")}isRequired(){return this.hasAttribute("required")}getValue(){const t=this.querySelector('input[type="radio"]:checked');return(t==null?void 0:t.value)||""}setValue(t){const e=this.querySelectorAll("mint-choice-option");e.forEach(i=>{if((i.getAttribute("value")||"")===t){const n=i;n.checked=!0;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}else{const n=i;n.checked=!1;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!1)}}),requestAnimationFrame(()=>{e.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const n=i;s.checked!==n.checked&&(s.checked=n.checked)}})})}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const n=this.isDisabled();let r=this.querySelector(".mint-choice-label-container");if(e||i){r||(r=document.createElement("div"),r.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-choice-label");e?(l||(l=document.createElement("label"),l.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.insertBefore(l,r.firstChild)),l.textContent=e,l.setAttribute("for",s),n?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove();let c=r.querySelector(".mint-choice-info");i?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",r.appendChild(c)),c.textContent=i,n?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove()}else r&&r.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const l=this.querySelector(".mint-choice-label-container");l&&l.parentElement===this?this.insertBefore(a,l.nextSibling):this.insertBefore(a,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==a&&a.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement("div"),this._optionsContainer.className="mint-choice-options-container flex flex-col gap-3",a.appendChild(this._optionsContainer)),Array.from(this.children).filter(l=>l.tagName==="MINT-CHOICE-OPTION"&&l.parentElement!==this._optionsContainer).forEach(l=>{this._optionsContainer.appendChild(l)}),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(t){if(e||(e=document.createElement("div"),e.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e))),e.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let r=0;r<3;r++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const o=document.createElement("div");o.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o);const l=document.createElement("div");l.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l),e.appendChild(a)}e.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",ot);class lt extends HTMLElement{constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null}static get observedAttributes(){return["type","placeholder","value","disabled","id","name","required","readonly","rows","icon","label","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(t==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const t=this.getAttribute("rows");return t?parseInt(t,10):3}_getNormalizedType(){const t=this.getType();return t==="datetime"?"datetime-local":t==="money"?"text":t==="textarea"?"textarea":t}_isTextarea(){return this.getType()==="textarea"}_isMoney(){return this.getType()==="money"}_isColor(){return this.getType()==="color"}_isNumber(){return this.getType()==="number"}getPlaceholder(){return this.getAttribute("placeholder")||""}getValue(){var t,e,i;return this._isColor()?((t=this._colorPicker)==null?void 0:t.value)||((e=this._colorTextInput)==null?void 0:e.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(t){try{this._isColor()?(this._colorPicker&&(this._colorPicker.value=t||"#000000"),this._colorTextInput&&(this._colorTextInput.value=t||"#000000")):this._element&&(this._element.value=t),t?this.setAttribute("value",t):this.removeAttribute("value")}catch{}}get value(){try{return this.getValue()||""}catch{return""}}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getIcon(){return this.getAttribute("icon")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getInputClasses(){const t=this._isTextarea(),e=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),n=this.hasError(),r=["w-full",e||i?"pl-10":"px-3.5",e||i?"pr-3.5":s?"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",t?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",t?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",n?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],o=["focus-visible:ring-2","focus-visible:ring-offset-1",n?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...r,...a,...o].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var v,b,k,A;this.getType();const t=this._getNormalizedType(),e=this._isTextarea(),i=this._isMoney(),s=this._isColor(),n=this.getPlaceholder(),r=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),l=this.getId(),c=this.getName(),d=this.getAttribute("value")||(s?"#000000":""),p=this.getRows(),h=this.getIcon(),u=this.getLabel(),f=this.getInfo(),m=this.isLoading();if(this._renderSkeleton(m),s){this._input&&(this._input.remove(),this._input=null),this._textarea&&(this._textarea.remove(),this._textarea=null),this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement("div"),this._colorPickerWrapper.className="mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",this._colorPickerWrapper.style.backgroundColor=d||"#000000",this._wrapper.appendChild(this._colorPickerWrapper),this._colorPicker=document.createElement("input"),this._colorPicker.type="color",this._colorPicker.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._colorPicker.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0; border: none;",this._colorPickerWrapper.appendChild(this._colorPicker),this._focusHandler=y=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var x;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((x=this._colorPickerWrapper)==null||x.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._colorPicker.addEventListener("focus",this._focusHandler),this._colorPicker.addEventListener("blur",this._blurHandler),this._colorPicker.addEventListener("input",()=>{var x;const y=((x=this._colorPicker)==null?void 0:x.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this._colorTextInput&&(this._colorTextInput.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var x;const y=((x=this._colorPicker)==null?void 0:x.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("change",{detail:{value:y},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=n||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var x;const y=((x=this._colorTextInput)==null?void 0:x.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)&&(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y),this.dispatchEvent(new CustomEvent("input",{detail:{value:y},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var x,T;const y=((x=this._colorTextInput)==null?void 0:x.value)||"";/^#[0-9A-Fa-f]{6}$/.test(y)?(this._colorPicker&&(this._colorPicker.value=y),this.setAttribute("value",y)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((T=this._colorPicker)==null?void 0:T.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const E=d||"#000000";if(this._colorPicker&&this._colorPicker.value!==E&&(this._colorPicker.value=E),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=E),this._colorTextInput&&this._colorTextInput.value!==E&&(this._colorTextInput.value=E),this._colorPicker&&(this._colorPicker.disabled=r),this._colorPickerWrapper&&(r?(this._colorPickerWrapper.classList.add("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.remove("cursor-pointer")):(this._colorPickerWrapper.classList.remove("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.add("cursor-pointer"))),this._colorTextInput&&(this._colorTextInput.disabled=r,this._colorTextInput.readOnly=a,this._colorTextInput.required=o),this._colorTextInput){const y=this._colorTextInput;l?y.id=l:y.removeAttribute("id"),c?y.name=c:y.removeAttribute("name"),y.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=y}this._renderErrorState();return}if(this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null,this._colorPicker=null,this._colorTextInput=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),h&&!e?this._icon?this._icon.setAttribute("name",h):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",h),this._icon.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",this._wrapper.appendChild(this._icon)):this._icon&&(this._icon.remove(),this._icon=null),this._isNumber()&&!e){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement("div"),this._numberSpinnerContainer.className="absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none",this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement("button"),this._numberIncrementButton.type="button",this._numberIncrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const E=document.createElement("mint-icon");E.setAttribute("name","caret-up"),E.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(E),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement("button"),this._numberDecrementButton.type="button",this._numberDecrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const y=document.createElement("mint-icon");y.setAttribute("name","caret-down"),y.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(y),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",x=>{if(x.preventDefault(),x.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const T=parseFloat(this._input.value)||0,R=parseFloat(this._input.step)||1,P=this._input.min?parseFloat(this._input.min):void 0,q=this._input.max?parseFloat(this._input.max):void 0;let H=T+R;q!==void 0&&H>q&&(H=q),P!==void 0&&H<P&&(H=P),this._input.value=H.toString(),this.setAttribute("value",H.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",x=>{if(x.preventDefault(),x.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const T=parseFloat(this._input.value)||0,R=parseFloat(this._input.step)||1,P=this._input.min?parseFloat(this._input.min):void 0,q=this._input.max?parseFloat(this._input.max):void 0;let H=T-R;P!==void 0&&H<P&&(H=P),q!==void 0&&H>q&&(H=q),this._input.value=H.toString(),this.setAttribute("value",H.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=r||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=r||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(e){if(this._input&&(this._input.remove(),this._input=null),this._textarea||(this._textarea=document.createElement("textarea"),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=n,this._textarea.disabled=r,this._textarea.readOnly=a,this._textarea.required=o,this._textarea.rows=p,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),d!==this._textarea.value&&(this._textarea.value=d),l?this._textarea.id=l:this._textarea.removeAttribute("id"),c?this._textarea.name=c:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const E=this.firstChild.textContent;E&&!this._textarea.value&&(this._textarea.value=E.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&(this._textarea.remove(),this._textarea=null),this._input||(this._input=document.createElement("input"),this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=t,this._input.placeholder=n,this._input.disabled=r,this._input.readOnly=a,this._input.required=o,this._input.setAttribute("aria-invalid",this.hasError()?"true":"false"),i?(this._input.inputMode="decimal",this._input.pattern="[0-9]*\\.?[0-9]*"):(this._input.removeAttribute("inputmode"),this._input.removeAttribute("pattern")),d!==this._input.value&&(this._input.value=d),l?this._input.id=l:this._input.removeAttribute("id"),c?this._input.name=c:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const E=this.firstChild.textContent;E&&!this._input.value&&(this._input.value=E.trim()),this.removeChild(this.firstChild)}let g=this.querySelector(".mint-input-label-container");if(u||f){g||(g=document.createElement("div"),g.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let E=g.querySelector(".mint-input-label");if(u){E||(E=document.createElement("label"),E.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",g.insertBefore(E,g.firstChild)),E.textContent=u;const x=l||((v=this._element)==null?void 0:v.id)||((b=this._colorTextInput)==null?void 0:b.id)||((k=this._input)==null?void 0:k.id)||((A=this._textarea)==null?void 0:A.id);if(x)E.setAttribute("for",x);else{const T=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=T:this._colorTextInput?this._colorTextInput.id=T:this._input?this._input.id=T:this._textarea&&(this._textarea.id=T),E.setAttribute("for",T)}r?E.classList.add("opacity-40"):E.classList.remove("opacity-40")}else E&&E.remove();let y=g.querySelector(".mint-input-info");f?(y||(y=document.createElement("span"),y.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",g.appendChild(y)),y.textContent=f,r?y.classList.add("opacity-40"):y.classList.remove("opacity-40")):y&&y.remove()}else g&&g.remove();this._renderErrorState(),this._renderSkeleton(m)}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-input-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-input-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var i;const t=((i=this._element)==null?void 0:i.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value");const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener("blur",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&(this._colorPicker.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._colorPicker.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}focus(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(t=this._element)==null||t.focus()}blur(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(t=this._element)==null||t.blur()}_renderSkeleton(t){let e=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(t){e||(e=document.createElement("div"),e.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-input-skeleton");if(!s){s=document.createElement("div"),s.className="mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this._isTextarea(),r=this.getRows();if(n){const a=r*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";e.appendChild(s)}e.style.display="block",this._element&&(this._element.style.opacity="0",this._element.style.pointerEvents="none"),this._colorTextInput&&(this._colorTextInput.style.opacity="0",this._colorTextInput.style.pointerEvents="none")}else e&&(e.style.display="none"),this._element&&(this._element.style.opacity="1",this._element.style.pointerEvents="auto"),this._colorTextInput&&(this._colorTextInput.style.opacity="1",this._colorTextInput.style.pointerEvents="auto")}}customElements.get("mint-input")||customElements.define("mint-input",lt);class ct extends HTMLElement{constructor(){super(),this._input=null,this._textInput=null,this._popover=null,this._calendarContainer=null,this._iconButton=null,this._hiddenInput=null,this._startPartInputs=[],this._endPartInputs=[],this._displayEl=null,this._inputsWrapperEl=null,this._fieldsContainer=null,this._resetHandler=null,this._isInputMode=!1,this._currentMonth=new Date().getMonth(),this._currentYear=new Date().getFullYear(),this._viewMode="calendar",this._selectedStartDate=null,this._selectedEndDate=null,this._isRange=!1,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}static get observedAttributes(){return["value","label","info","disabled","id","name","required","readonly","format","min","max","range","shortcuts","display-format","error","error-message","loading","selection-mode","week-start-day"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._setupPopoverWithRetry(),this._attachFormResetListener()}disconnectedCallback(){if(this._popoverObserver&&(this._popoverObserver.disconnect(),this._popoverObserver=null),this._removeFocusTrap(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){const s=this.hasError(),n=this.getErrorMessage();this._applyErrorVisuals(s,n,this.isDisabled());return}if(t==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(t){t?(this.setAttribute("value",t),this._textInput&&(this._textInput.value=t),this._parseValue(t)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}getFormat(){return this.getAttribute("format")||"mm/dd/yyyy"}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}isDisabled(){return this.hasAttribute("disabled")}isReadonly(){return this.hasAttribute("readonly")}isRequired(){return this.hasAttribute("required")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isRange(){return this.hasAttribute("range")}getId(){return this.getAttribute("id")||""}getName(){return this.getAttribute("name")||""}getMin(){return this.getAttribute("min")||""}getMax(){return this.getAttribute("max")||""}getSelectionMode(){const t=this.getAttribute("selection-mode");return t==="week"||t==="month"?t:"day"}getWeekStartDay(){var i;const t=(i=this.getAttribute("week-start-day"))==null?void 0:i.toLowerCase();return{sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6}[t||"sunday"]??0}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const t=this.getAttribute("shortcuts");if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=t.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(n=>({label:n.label,action:typeof n.action=="function"?n.action:this._createShortcutAction(n.action)}))}}return[]}_createShortcutAction(t){return typeof t=="function"?t:typeof t=="string"&&typeof window[t]=="function"?window[t]:()=>null}_getDefaultShortcuts(){const t=[{label:"Today",action:()=>new Date}];return this._isRange&&t.push({label:"This Week",action:()=>{const e=new Date,i=e.getDay(),s=new Date(e);s.setDate(e.getDate()-i),s.setHours(0,0,0,0);const n=new Date(s);return n.setDate(s.getDate()+6),n.setHours(23,59,59,999),{start:s,end:n}}},{label:"This Month",action:()=>{const e=new Date,i=new Date(e.getFullYear(),e.getMonth(),1),s=new Date(e.getFullYear(),e.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),t}_getFormatTokens(t){const e=[];let i=0;const s=t.toLowerCase();for(;i<s.length;){const n=s[i];if(n==="d"||n==="m"||n==="y"){let r=1,a=i+1;for(;a<s.length&&s[a]===n;)r++,a++;e.push({type:"part",part:n,len:r}),i=a}else e.push({type:"sep",value:t[i]}),i++}return e}_createPartInput(t,e,i,s,n){const r=document.createElement("input");return r.type="text",r.inputMode="numeric",r.pattern="\\d*",r.maxLength=t,r.placeholder=e,r.className="bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed",r.disabled=i||s,r.readOnly=s,r.required=n,t===4?r.className+=" w-[40px]":t===2&&(r.className+=" w-[30px]"),r}_buildValueFromParts(t,e){let i=0;return e.map(s=>{var r;if(s.type==="sep")return s.value;const n=((r=t[i])==null?void 0:r.value)||"";return i++,n}).join("")}_applyDateToParts(t,e,i,s){if(!e.length)return;if(!t){e.forEach(o=>o.value="");return}const n=this._formatDate(t,s);let r=0,a=0;i.forEach(o=>{if(o.type==="sep")r+=o.value.length;else{const l=n.substr(r,o.len);e[a]&&(e[a].value=l),a++,r+=o.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const t=this.getFormat(),e=this._getFormatTokens(t),i=this._buildValueFromParts(this._startPartInputs,e);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,e);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(t,e){if(e+1<t.length){const i=t[e+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(t,e){if(e-1>=0){const i=t[e-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(t,e,i){t.forEach((s,n)=>{const r=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,r),s.value.length>=r&&this._focusNext(t,n),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(t,n),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(t,n),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(t,n),a.preventDefault())}),s.addEventListener("blur",a=>{var c,d;this._syncHiddenInput();const o=a.relatedTarget;o&&(this.contains(o)||(c=this._popover)!=null&&c.contains(o)||this._calendarContainer&&this._calendarContainer.contains(o))||(this._handleBlur(((d=this._hiddenInput)==null?void 0:d.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const p=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(p)}},0))})})}_splitRangeInput(t,e){const i=t.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[t]}_parseValue(t){const e=this.getFormat(),i=this._getFormatTokens(e),s=this.getSelectionMode();if(this._isRange||s==="week"||s==="month"){const[r,a]=this._splitRangeInput(t,e),o=r?this._parseDateString(r,e):null,l=a?this._parseDateString(a,e):null;if(o&&l){const[c,d]=o<=l?[o,l]:[l,o];this._selectedStartDate=c,this._selectedEndDate=d,this._currentMonth=c.getMonth(),this._currentYear=c.getFullYear()}else o&&(this._selectedStartDate=o,this._selectedEndDate=null,this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,e),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,e)}else{const r=this._parseDateString(t,e);r&&!isNaN(r.getTime())?(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear(),this._applyDateToParts(r,this._startPartInputs,i,e)):this._applyDateToParts(null,this._startPartInputs,i,e)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(t,e){const i=/[\/\-\.\s]+/;if(i.test(t)){const m=t.split(i).filter(g=>g.length>0),_=e.split(/[\/\-\.\s]+/).filter(g=>g.length>0);if(m.length===_.length){let g=0,v=0,b=0;for(let k=0;k<_.length;k++){const A=_[k].toLowerCase(),E=m[k];if(A.includes("d"))g=parseInt(E,10);else if(A.includes("m"))v=parseInt(E,10)-1;else if(A.includes("y")){let y=parseInt(E,10);const x=A.length,T=E.length;T===2&&x===4?y=Math.floor(new Date().getFullYear()/100)*100+y:T===2&&x===2&&(y=Math.floor(new Date().getFullYear()/100)*100+y),b=y}}if(g&&v>=0&&v<=11&&b){const k=new Date(b,v,g);if(!isNaN(k.getTime())&&k.getDate()===g&&k.getMonth()===v&&k.getFullYear()===b)return k}}}const n=t.replace(/[\/\-\.]/g,""),r=e.replace(/[\/\-\.]/g,"").toLowerCase();let a=r.indexOf("d"),o=r.indexOf("m"),l=r.indexOf("y");const c=[{char:"d",index:a},{char:"m",index:o},{char:"y",index:l}].sort((m,_)=>m.index-_.index);let d=0,p=0,h=0,u=0;r.length,n.length;for(const m of c)if(m.char==="d"){const _=r.lastIndexOf("d")-r.indexOf("d")+1,g=n.substr(u,_);if(g.length===0)return null;d=parseInt(g,10),u+=g.length}else if(m.char==="m"){const _=r.lastIndexOf("m")-r.indexOf("m")+1,g=n.substr(u,_);if(g.length===0)return null;p=parseInt(g,10)-1,u+=g.length}else if(m.char==="y"){const _=r.lastIndexOf("y")-r.indexOf("y")+1,g=n.substr(u),v=Math.min(_,g.length),b=g.substr(0,v);if(b.length===0)return null;let k=parseInt(b,10);v===2&&_===4?k=Math.floor(new Date().getFullYear()/100)*100+k:v===2&&_===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),h=k,u+=v}if(!d||p<0||p>11||!h)return null;const f=new Date(h,p,d);return isNaN(f.getTime())||f.getDate()!==d||f.getMonth()!==p||f.getFullYear()!==h?null:f}_formatDate(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=e.toLowerCase();let a=e;return r.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):r.includes("d")&&(a=a.replace(/d/gi,String(i))),r.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):r.includes("m")&&(a=a.replace(/m/gi,String(s))),r.includes("yyyy")?a=a.replace(/yyyy/gi,String(n)):r.includes("yy")&&(a=a.replace(/yy/gi,String(n).substr(2))),a}_formatDatePhp(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=(h,u=2)=>h.toString().padStart(u,"0"),d=h=>{const u=h%10,f=h%100;return u===1&&f!==11?"st":u===2&&f!==12?"nd":u===3&&f!==13?"rd":"th"};let p="";for(let h=0;h<e.length;h++){const u=e[h];if(u==="\\"&&h+1<e.length){p+=e[h+1],h++;continue}switch(u){case"Y":p+=n.toString();break;case"y":p+=n.toString().slice(-2);break;case"m":p+=c(s);break;case"n":p+=s.toString();break;case"M":p+=l[s-1];break;case"F":p+=o[s-1];break;case"d":p+=c(i);break;case"j":p+=i.toString();break;case"D":p+=a[t.getDay()];break;case"l":p+=r[t.getDay()];break;case"S":p+=d(i);break;default:p+=u;break}}return p}_validateDateString(t,e){const i=this._parseDateString(t,e);return i!==null&&!isNaN(i.getTime())}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getValue(),n=this.isDisabled(),r=this.isReadonly(),a=this.isRequired(),o=this.getId(),l=this.getName(),c=this.getFormat(),d=this.hasError(),p=this.getErrorMessage(),h=this.getSelectionMode();this._isRange=this.isRange()||h==="week"||h==="month",this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let u=this.querySelector(".mint-date-picker-label-container");if(e||i){u||(u=document.createElement("div"),u.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(u,this._input):this.appendChild(u));let b=u.querySelector(".mint-date-picker-label");e?(b||(b=document.createElement("label"),b.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",u.insertBefore(b,u.firstChild)),b.textContent=e,o&&this._textInput&&b.setAttribute("for",o)):b&&b.remove();let k=u.querySelector(".mint-date-picker-info");i?(k||(k=document.createElement("span"),k.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",u.appendChild(k)),k.textContent=i):k&&k.remove()}else u&&u.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=s||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),o&&(this._hiddenInput.id=o),l&&(this._hiddenInput.name=l),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",d?"true":"false");let f=this._input.querySelector(".mint-date-fields");f||(f=document.createElement("div"),this._input.appendChild(f)),this._fieldsContainer=f,this._applyErrorVisuals(d,p,n),f.innerHTML="",this._displayEl=document.createElement("div");const m=r?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${r?"cursor-default":"cursor-text"} ${m} focus:outline-none`,this._displayEl.tabIndex=n||r?-1:0,this._displayEl.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",b=>{n||r||(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const _=this._getFormatTokens(c);this._startPartInputs=[],this._endPartInputs=[];const g=b=>{const k=document.createDocumentFragment();return _.forEach(A=>{if(A.type==="sep"){const E=document.createElement("span");E.textContent=A.value,E.className="text-gray-400 dark:text-gray-500 select-none",k.appendChild(E)}else{const E=A.part==="d"?"dd":A.part==="m"?"mm":A.len===2?"yy":"yyyy",y=this._createPartInput(A.len,E,n,r,a);b==="start"?this._startPartInputs.push(y):this._endPartInputs.push(y),k.appendChild(y)}}),k};if(this._inputsWrapperEl.appendChild(g("start")),this._isRange){const b=document.createElement("span");b.textContent=" - ",b.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(b),this._inputsWrapperEl.appendChild(g("end"))}const v=document.createElement("div");if(v.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",v.appendChild(this._displayEl),v.appendChild(this._inputsWrapperEl),f.appendChild(v),f.addEventListener("click",()=>{this._isInputMode||n||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,_,f),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,_,f),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=n||r,!n&&!r?this._iconButton.tabIndex=0:this._iconButton.tabIndex=-1;else{this._iconButton=document.createElement("button"),this._iconButton.type="button",this._iconButton.tabIndex=0,this._iconButton.className="absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";const b=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=b;const k=document.createElement("mint-icon");k.setAttribute("name","calendar"),k.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(k),this._iconButton.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=n||r}this._renderErrorState(d,p),this._renderSkeleton(t)}_renderErrorState(t,e){let i=this.querySelector(".mint-date-picker-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_applyErrorVisuals(t,e,i){if(this._renderErrorState(t,e),this._fieldsContainer){const s=this._getFieldContainerClass(t,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",t?"true":"false")}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},t.addEventListener("reset",this._resetHandler))}_clearPartInputs(t){t.forEach(e=>{e.value=""})}_getFieldContainerClass(t,e){return["mint-date-fields relative w-full pl-10 pr-3.5 py-1.5 min-h-[2rem] text-sm font-medium rounded-lg box-border bg-white dark:bg-gray-700 text-gray-900 dark:text-white","border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600","transition-all duration-200 outline-none focus-within:ring-2 focus-within:ring-offset-1",t?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","flex items-center gap-1"].join(" ")+(e?" opacity-40 cursor-not-allowed":"")}_handleInputChange(t){}_cleanInputValue(t,e){return t}_handleBlur(t){const e=this.getFormat(),i=this.getSelectionMode(),s=this._isRange||i==="week"||i==="month";if(!t){this.setValue(""),this._updateDisplayText();return}if(s){const[n,r]=this._splitRangeInput(t,e),a=n?this._parseDateString(n,e):null,o=r?this._parseDateString(r,e):null;if(a&&o){const[l,c]=a<=o?[a,o]:[o,a],d=this._formatDate(l,e),p=this._formatDate(c,e),h=`${d} - ${p}`;this.setValue(h),this._applyDateToParts(l,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(c,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=l,this._selectedEndDate=c,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else if(a){const l=this._formatDate(a,e);this.setValue(l),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=a,this._selectedEndDate=null,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(t,e)){const n=this._parseDateString(t,e);if(n){const r=this._formatDate(n,e);this.setValue(r),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(t=0){if(!this._iconButton){t<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)});return}const e=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)}):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)})}_createPopover(t){if(!t)return;if(!document.getElementById(t)){setTimeout(()=>{this._createPopover(t)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),this.closest("mint-modal")?document.body.appendChild(this._popover):this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute("trigger-id",t),this._popoverObserver||(this._popoverObserver=new MutationObserver(s=>{s.forEach(n=>{var r;if(n.type==="attributes"&&n.attributeName==="open")if((r=this._popover)==null?void 0:r.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const o=this._popover;typeof o.render=="function"&&o.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var o;(o=this._iconButton)==null||o.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const o=new Date;this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var l;const o=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(l=this._hiddenInput)==null||l.dispatchEvent(o)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==t){this._popover.setAttribute("trigger-id",t);const s=this._popover;typeof s._setupTrigger=="function"&&s._setupTrigger()}this._buildCalendar()}}_buildCalendar(){if(!this._popover)return;this._calendarContainer&&this._calendarContainer.parentNode&&this._calendarContainer.remove(),this._calendarContainer=document.createElement("div"),this._calendarContainer.className="mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]",this._viewMode==="calendar"?this._buildCalendarView():this._viewMode==="month"?this._buildMonthView():this._viewMode==="year"&&this._buildYearView();const t=this._popover.querySelector(".popover-content");if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const t=this._getDaysInMonth(this._currentMonth,this._currentYear),e=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=this.getWeekStartDay(),n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=[...n.slice(s),...n.slice(0,s)],a=this.getShortcuts(),o=a.length>0;this._calendarContainer.className=o?"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]":"mint-date-calendar bg-white dark:bg-gray-800 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";const l=document.createElement("div");l.className="flex flex-col md:flex-row md:gap-6 md:items-start";const c=document.createElement("div");c.className="flex-1 min-w-0";const d=document.createElement("div");d.className="flex items-center justify-between mb-4";const p=document.createElement("button");p.type="button",p.tabIndex=0,p.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",p.setAttribute("data-keep-popover-open","true");const h=document.createElement("mint-icon");h.setAttribute("name","caret-left"),h.className="w-4 h-4",p.appendChild(h),p.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),d.appendChild(p);const u=document.createElement("div");u.className="flex items-center gap-2";const f=document.createElement("button");f.type="button",f.tabIndex=0,f.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",f.setAttribute("data-keep-popover-open","true"),f.textContent=i[this._currentMonth],f.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),u.appendChild(f);const m=document.createElement("button");m.type="button",m.tabIndex=0,m.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",m.setAttribute("data-keep-popover-open","true"),m.textContent=String(this._currentYear),m.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),u.appendChild(m),d.appendChild(u);const _=document.createElement("button");_.type="button",_.tabIndex=0,_.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",_.setAttribute("data-keep-popover-open","true");const g=document.createElement("mint-icon");g.setAttribute("name","caret-right"),g.className="w-4 h-4",_.appendChild(g),_.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),d.appendChild(_);const v=document.createElement("div");v.className="grid grid-cols-7 mb-2",r.forEach(C=>{const I=document.createElement("div");I.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",I.textContent=C,v.appendChild(I)});const b=document.createElement("div");b.className="grid grid-cols-7";const k=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,A=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null,E=this._currentMonth===0?11:this._currentMonth-1,y=this._currentMonth===0?this._currentYear-1:this._currentYear,x=this._getDaysInMonth(E,y),T=this._currentMonth===11?0:this._currentMonth+1,R=this._currentMonth===11?this._currentYear+1:this._currentYear,P=e+t,yt=Math.ceil(P/7)*7-P,Y=(C,I,S)=>{const V=this._isToday(C),O=this._isDateSelected(C),$=this._isDateInRange(C),F=k&&C<k||A&&C>A;let M="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const D=this._isSameDate(C,this._selectedStartDate),L=this._isSameDate(C,this._selectedEndDate);D&&L?M="rounded-md":D?M="rounded-l-md":L?M="rounded-r-md":$&&(M="rounded-none")}else O&&!this._isRange&&(M="rounded-md");const N=document.createElement("button");N.type="button",N.disabled=!!F,N.tabIndex=F?-1:0;let B=`w-full h-8 ${M} border-0 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`;return S?B+=O?" bg-slate-800 dark:bg-slate-600 text-white":$?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":V?" text-gray-900 dark:text-gray-100 font-semibold":" text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700":B+=O?" bg-slate-800 dark:bg-slate-600 text-white":$?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":" text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700",B+=F?" opacity-40 cursor-not-allowed":"",N.className=B,N.textContent=I.toString(),F||N.addEventListener("click",()=>{this._handleDateClick(C)}),N};for(let C=e-1;C>=0;C--){const I=x-C,S=new Date(y,E,I),V=Y(S,I,!1);b.appendChild(V)}for(let C=1;C<=t;C++){const I=new Date(this._currentYear,this._currentMonth,C),S=Y(I,C,!0);b.appendChild(S)}for(let C=1;C<=yt;C++){const I=new Date(R,T,C),S=Y(I,C,!1);b.appendChild(S)}if(o){const C=document.createElement("div");C.className="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";const I=document.createElement("div");I.className="relative md:relative md:flex-1 md:min-h-0";const S=document.createElement("div");S.className="flex gap-2 overflow-x-auto pb-1 md:flex-col md:overflow-x-visible md:overflow-y-auto md:pb-0 md:gap-2",S.style.scrollbarWidth="none",S.style.msOverflowStyle="none",S.style.setProperty("-webkit-overflow-scrolling","touch");const V=document.createElement("style");V.textContent=`
|
|
66
66
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
67
67
|
display: none;
|
|
68
68
|
}
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
background: rgba(255, 255, 255, 0.2);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
`,S.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(V.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(V));const O=document.createElement("div");O.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",I.appendChild(O);const $=document.createElement("div");$.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",I.appendChild($);const F=document.createElement("div");F.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",I.appendChild(F);const M=document.createElement("div");M.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",I.appendChild(M);const N=()=>{if(window.innerWidth>=768){const D=S.scrollTop,L=S.scrollHeight,z=S.clientHeight;D>0?F.style.opacity="1":F.style.opacity="0",D+z<L-1?M.style.opacity="1":M.style.opacity="0",O.style.opacity="0",$.style.opacity="0"}else{const D=S.scrollLeft,L=S.scrollWidth,z=S.clientWidth;D>0?O.style.opacity="1":O.style.opacity="0",D+z<L-1?$.style.opacity="1":$.style.opacity="0",F.style.opacity="0",M.style.opacity="0"}};S.addEventListener("scroll",N),window.addEventListener("resize",N),setTimeout(N,0),a.forEach(B=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=B.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const L=B.action();if(L){if(this._isRange&&"start"in L&&"end"in L){this._selectedStartDate=L.start,this._selectedEndDate=L.end;const z=this.getFormat(),U=this._formatDate(L.start,z),yt=this._formatDate(L.end,z),kt=`${U} - ${yt}`;this.setValue(kt),this._currentMonth=L.start.getMonth(),this._currentYear=L.start.getFullYear()}else if(L instanceof Date){this._selectedStartDate=L,this._selectedEndDate=null;const z=this.getFormat(),U=this._formatDate(L,z);this.setValue(U),this._currentMonth=L.getMonth(),this._currentYear=L.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),S.appendChild(D)}),I.appendChild(S),w.appendChild(I),l.appendChild(w)}c.appendChild(d),c.appendChild(v),c.appendChild(b),l.appendChild(c),this._calendarContainer.appendChild(l)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2",t.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const u=this._currentMonth===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${u?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=l,d.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(d)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(o)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const o=document.createElement("mint-icon");o.setAttribute("name","caret-right"),o.className="w-4 h-4",a.appendChild(o),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const u=this._currentYear===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${u?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(c),d.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(l)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){const i=this.getWeekStartDay(),s=new Date(e,t,1).getDay();return s>=i?s-i:7-(i-s)}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){const e=this.getSelectionMode();return this._isRange||e==="week"||e==="month"?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(t,this._selectedStartDate)||this._isSameDate(t,this._selectedEndDate):!1:this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){const e=this.getSelectionMode();return(this._isRange||e==="week"||e==="month")&&this._selectedStartDate&&this._selectedEndDate?t>=this._selectedStartDate&&t<=this._selectedEndDate:!1}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_getWeekStart(t){const e=this.getWeekStartDay(),i=t.getDay();let s;i>=e?s=i-e:s=7-(e-i);const n=new Date(t);return n.setDate(t.getDate()-s),n.setHours(0,0,0,0),n}_getWeekEnd(t){const e=this._getWeekStart(t),i=new Date(e);return i.setDate(e.getDate()+6),i.setHours(23,59,59,999),i}_getMonthStart(t){const e=new Date(t.getFullYear(),t.getMonth(),1);return e.setHours(0,0,0,0),e}_getMonthEnd(t){const e=new Date(t.getFullYear(),t.getMonth()+1,0);return e.setHours(23,59,59,999),e}_handleDateClick(t){const e=this.getFormat(),i=this.getSelectionMode();let s,n;if(i==="week"?(s=this._getWeekStart(t),n=this._getWeekEnd(t)):i==="month"?(s=this._getMonthStart(t),n=this._getMonthEnd(t)):(s=t,n=t),this.isRange()||i==="week"||i==="month"){this._selectedStartDate=s,this._selectedEndDate=n;const o=this._formatDate(this._selectedStartDate,e),l=this._formatDate(this._selectedEndDate,e),c=`${o} - ${l}`;this.setValue(c),this._textInput&&(this._textInput.value=c),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else{this._selectedStartDate=s,this._selectedEndDate=null;const o=this._formatDate(s,e);this.setValue(o),this._textInput&&(this._textInput.value=o),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();const a=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat(),e=this.getSelectionMode(),i=this._isRange||e==="week"||e==="month";let s="";i?this._selectedStartDate&&this._selectedEndDate?s=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)),s?(this._displayEl.textContent=s,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",ct);class ht extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(s=>{const n=Array.from(s.addedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP"))||Array.from(s.removedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP")),r=s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE&&(s.target.tagName==="OPTION"||s.target.tagName==="OPTGROUP");return n||r})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled"]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._optionObserver&&(this._optionObserver.disconnect(),this._optionObserver=null),this._childrenObserver&&(this._childrenObserver.disconnect(),this._childrenObserver=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{const e=t||"";(this.getAttribute("value")||"")!==e&&this.setAttribute("value",e),this._select&&requestAnimationFrame(()=>{this._select&&(e===""||Array.from(this._select.options).some(n=>n.value===e))&&this._select.value!==e&&(this._select.value=e)})}catch{}}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&e.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),d=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&h.setAttribute("for",r);const 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(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",d?"true":"false");const u=i.length>0?i:e;if(u.length>0&&u.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const p=h.target.value;(this.getAttribute("value")||"")!==p&&(p?this.setAttribute("value",p):this.removeAttribute("value"));const _=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(_),this.dispatchEvent(new CustomEvent("input",{detail:{value:p},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:p},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{const h=this.getAttribute("value")||this.value||"";this._select&&h&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(p=>p.value===h)&&this._select.value!==h&&(this._select.value=h)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(n){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=n,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ht);class dt extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const d=this._dropzone.querySelector(".mint-dropzone-icon"),u=this._dropzone.querySelector(".mint-dropzone-label");d&&d.remove(),u&&u.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),e){const p=document.createElement("div");p.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",p.textContent=e,this._dropzone.appendChild(p)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const d=document.createElement("div");if(d.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",l.type.startsWith("image/")){const p=document.createElement("img");p.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const m=URL.createObjectURL(l);this._previewUrls.push(m),p.src=m,d.appendChild(p)}else{const p=document.createElement("mint-icon");p.setAttribute("name","attach"),p.className="w-5 h-5 text-gray-500 dark:text-gray-300",d.appendChild(p)}const u=document.createElement("div");u.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",u.textContent=l.name,d.appendChild(u);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",p=>{p.preventDefault(),p.stopPropagation(),this._removeFileAt(c)}),d.appendChild(h),e.appendChild(d)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,d=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+d<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",dt);class ut extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||(this._lastDataSnapshot=this._createDataSnapshot(this._formData)),this._applyFormData();else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)?this._setupReactiveDataObserver(t):this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){var l;if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),o=this.getAttribute("method");if(!(!a||!o)){this._setButtonsSubmitting();try{const c=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:c,bubbles:!0,cancelable:!0}))}catch(c){(c==null?void 0:c.status)===422&&((l=c==null?void 0:c.data)!=null&&l.errors)&&this._applyServerErrors(c.data.errors),this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:c},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var d,u,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(f=>f instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((h=(u=(d=window.mintForm)==null?void 0:d.defaults)==null?void 0:u.headers)!=null&&h.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const f=new URLSearchParams;t.forEach((p,m)=>{p instanceof File||f.append(m,String(p))}),l+=(i.includes("?")?"&":"?")+f.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const f=new URLSearchParams;t.forEach((p,m)=>{p instanceof File||f.append(m,String(p))}),a=f,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const f=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),p=await f.text().catch(()=>"");let m=p;try{m=JSON.parse(p)}catch{}if(!f.ok){const g={status:f.status,data:m,response:{status:f.status,data:m}};throw await this._applyErrorInterceptors(g)}const _={status:f.status,ok:f.ok,data:m};return await this._applySuccessInterceptors(_)}catch(f){if(f.response)throw f;const p={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(p)}const c=this;return await new Promise(async(f,p)=>{const m=new XMLHttpRequest;m.open(s||"POST",l,!0),Object.entries(o).forEach(([_,g])=>m.setRequestHeader(_,g)),m.onload=async function(){const{status:_,responseText:g}=m;if(_>=200&&_<300){let v=g;try{v=JSON.parse(g)}catch{}try{const b={status:_,ok:!0,data:v},k=await c._applySuccessInterceptors(b);f(k)}catch(b){p(b)}}else{let v=g;try{v=JSON.parse(g)}catch{}try{const b={status:_,data:v,response:{status:_,data:v}},k=await c._applyErrorInterceptors(b);p(k)}catch(b){p(b)}}},m.onerror=async function(){try{const _={status:m.status||0,data:m.responseText||"Network error",response:{status:m.status||0,data:m.responseText||"Network error"}},g=await c._applyErrorInterceptors(_);p(g)}catch(_){p(_)}},m.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(u=>u.name===c.name&&u.size===c.size&&u.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(d=>d.name===l.name&&d.size===l.size&&d.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")}),this._errors={}}_applyServerErrors(t){this._clearErrors(),Object.entries(t).forEach(([e,i])=>{const s=Array.isArray(i)?i[0]||"Validation error":i||"Validation error",n=this._getFieldElements(e);n.length>0&&(this._errors[e]=s,this._flagFieldError(n,s))})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),d=!!n.closest("mint-tags"),u=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||d||u||h)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t)return!0;try{const e=t.toString();if(e==="[object Object]"||e.includes("Proxy")){const i=Object.keys(t)[0];if(i){const s=Object.getOwnPropertyDescriptor(t,i);if(s&&(s.get||s.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(t){try{const e=this._extractReactiveData(t);return JSON.parse(JSON.stringify(e))}catch{return{...this._extractReactiveData(t)}}}_extractReactiveData(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>this._extractReactiveData(i));const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=this._extractReactiveData(e[s]));return i}return e}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupReactiveDataObserver(t){if(this._stopReactiveDataObserver(),!this.isConnected)return;const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e))this._lastDataSnapshot=this._createDataSnapshot(e);else{this._lastDataSnapshot=null;return}const i=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const s=this._getReactiveValue(this._formData);if(s&&typeof s=="object"&&!Array.isArray(s)){const n=this._createDataSnapshot(s);this._hasDataChanged(n,this._lastDataSnapshot)&&(this._lastDataSnapshot=n,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(i):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(i)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",ut);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(C,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:C,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class pt extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,d)=>{const u=c.querySelector("mint-icon"),h=(u==null?void 0:u.getAttribute("name"))||"",f=u!==null&&h!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),f&&c.classList.add("cursor-pointer","bg-[#F7F7F7]","dark:bg-gray-800","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),d===0&&c.classList.add("pl-6"),d===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,d)=>{const u=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),d===l.length-1&&c.classList.remove("border-b");const h=c.querySelectorAll("td");h.forEach((f,p)=>{this._setClasses(f,["text-gray-900","dark:text-gray-100","px-3","py-2"]),p===0&&f.classList.add("pl-6"),p===h.length-1&&f.classList.add("pr-6"),e?this._applyMobileCell(f,s):this._restoreCell(f)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
89
|
+
`,S.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(V.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(V));const O=document.createElement("div");O.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",I.appendChild(O);const $=document.createElement("div");$.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",I.appendChild($);const F=document.createElement("div");F.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",I.appendChild(F);const M=document.createElement("div");M.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",I.appendChild(M);const N=()=>{if(window.innerWidth>=768){const D=S.scrollTop,L=S.scrollHeight,z=S.clientHeight;D>0?F.style.opacity="1":F.style.opacity="0",D+z<L-1?M.style.opacity="1":M.style.opacity="0",O.style.opacity="0",$.style.opacity="0"}else{const D=S.scrollLeft,L=S.scrollWidth,z=S.clientWidth;D>0?O.style.opacity="1":O.style.opacity="0",D+z<L-1?$.style.opacity="1":$.style.opacity="0",F.style.opacity="0",M.style.opacity="0"}};S.addEventListener("scroll",N),window.addEventListener("resize",N),setTimeout(N,0),a.forEach(B=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=B.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const L=B.action();if(L){if(this._isRange&&"start"in L&&"end"in L){this._selectedStartDate=L.start,this._selectedEndDate=L.end;const z=this.getFormat(),U=this._formatDate(L.start,z),kt=this._formatDate(L.end,z),Et=`${U} - ${kt}`;this.setValue(Et),this._currentMonth=L.start.getMonth(),this._currentYear=L.start.getFullYear()}else if(L instanceof Date){this._selectedStartDate=L,this._selectedEndDate=null;const z=this.getFormat(),U=this._formatDate(L,z);this.setValue(U),this._currentMonth=L.getMonth(),this._currentYear=L.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),S.appendChild(D)}),I.appendChild(S),C.appendChild(I),l.appendChild(C)}c.appendChild(d),c.appendChild(v),c.appendChild(b),l.appendChild(c),this._calendarContainer.appendChild(l)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),e.appendChild(i);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",n.setAttribute("data-keep-popover-open","true"),n.textContent=String(this._currentYear),n.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),e.appendChild(n);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",r.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",r.appendChild(a),r.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),e.appendChild(r);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2",t.forEach((l,c)=>{const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentMonth===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=l,d.addEventListener("click",()=>{this._currentMonth=c,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(d)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(o)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const r=document.createElement("div");r.className="text-sm font-medium text-gray-900 dark:text-gray-100",r.textContent=`${t} - ${e}`,i.appendChild(r);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const o=document.createElement("mint-icon");o.setAttribute("name","caret-right"),o.className="w-4 h-4",a.appendChild(o),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2";for(let c=t;c<=e;c++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const p=this._currentYear===c;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${p?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(c),d.addEventListener("click",()=>{this._currentYear=c,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(l)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){const i=this.getWeekStartDay(),s=new Date(e,t,1).getDay();return s>=i?s-i:7-(i-s)}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){const e=this.getSelectionMode();return this._isRange||e==="week"||e==="month"?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(t,this._selectedStartDate)||this._isSameDate(t,this._selectedEndDate):!1:this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){const e=this.getSelectionMode();return(this._isRange||e==="week"||e==="month")&&this._selectedStartDate&&this._selectedEndDate?t>=this._selectedStartDate&&t<=this._selectedEndDate:!1}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_getWeekStart(t){const e=this.getWeekStartDay(),i=t.getDay();let s;i>=e?s=i-e:s=7-(e-i);const n=new Date(t);return n.setDate(t.getDate()-s),n.setHours(0,0,0,0),n}_getWeekEnd(t){const e=this._getWeekStart(t),i=new Date(e);return i.setDate(e.getDate()+6),i.setHours(23,59,59,999),i}_getMonthStart(t){const e=new Date(t.getFullYear(),t.getMonth(),1);return e.setHours(0,0,0,0),e}_getMonthEnd(t){const e=new Date(t.getFullYear(),t.getMonth()+1,0);return e.setHours(23,59,59,999),e}_handleDateClick(t){const e=this.getFormat(),i=this.getSelectionMode();let s,n;if(i==="week"?(s=this._getWeekStart(t),n=this._getWeekEnd(t)):i==="month"?(s=this._getMonthStart(t),n=this._getMonthEnd(t)):(s=t,n=t),this.isRange()||i==="week"||i==="month"){this._selectedStartDate=s,this._selectedEndDate=n;const o=this._formatDate(this._selectedStartDate,e),l=this._formatDate(this._selectedEndDate,e),c=`${o} - ${l}`;this.setValue(c),this._textInput&&(this._textInput.value=c),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else{this._selectedStartDate=s,this._selectedEndDate=null;const o=this._formatDate(s,e);this.setValue(o),this._textInput&&(this._textInput.value=o),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();const a=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}))}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat(),e=this.getSelectionMode(),i=this._isRange||e==="week"||e==="month";let s="";i?this._selectedStartDate&&this._selectedEndDate?s=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)),s?(this._displayEl.textContent=s,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",ct);class ht extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(s=>{const n=Array.from(s.addedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP"))||Array.from(s.removedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP")),r=s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE&&(s.target.tagName==="OPTION"||s.target.tagName==="OPTGROUP");return n||r})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled"]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._optionObserver&&(this._optionObserver.disconnect(),this._optionObserver=null),this._childrenObserver&&(this._childrenObserver.disconnect(),this._childrenObserver=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{const e=t||"";(this.getAttribute("value")||"")!==e&&this.setAttribute("value",e),this._select&&requestAnimationFrame(()=>{this._select&&(e===""||Array.from(this._select.options).some(n=>n.value===e))&&this._select.value!==e&&(this._select.value=e)})}catch{}}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&e.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),d=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&h.setAttribute("for",r);const u=document.createTextNode(s);h.appendChild(u),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",d?"true":"false");const p=i.length>0?i:e;if(p.length>0&&p.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const f=h.target.value;(this.getAttribute("value")||"")!==f&&(f?this.setAttribute("value",f):this.removeAttribute("value"));const _=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(_),this.dispatchEvent(new CustomEvent("input",{detail:{value:f},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:f},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{const h=this.getAttribute("value")||this.value||"";this._select&&h&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(f=>f.value===h)&&this._select.value!==h&&(this._select.value=h)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(n){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=n,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",ht);class dt extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const d=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");d&&d.remove(),p&&p.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const u=document.createElement("mint-icon");if(u.setAttribute("name","upload"),u.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(u),this._dropzone.appendChild(h),e){const f=document.createElement("div");f.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",f.textContent=e,this._dropzone.appendChild(f)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const d=document.createElement("div");if(d.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",l.type.startsWith("image/")){const f=document.createElement("img");f.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const m=URL.createObjectURL(l);this._previewUrls.push(m),f.src=m,d.appendChild(f)}else{const f=document.createElement("mint-icon");f.setAttribute("name","attach"),f.className="w-5 h-5 text-gray-500 dark:text-gray-300",d.appendChild(f)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=l.name,d.appendChild(p);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const u=document.createElement("mint-icon");u.setAttribute("name","close"),u.className="w-4 h-4",h.appendChild(u),h.addEventListener("click",f=>{f.preventDefault(),f.stopPropagation(),this._removeFileAt(c)}),d.appendChild(h),e.appendChild(d)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,d=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+d<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",dt);class ut extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||(this._lastDataSnapshot=this._createDataSnapshot(this._formData)),this._applyFormData();else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)?this._setupReactiveDataObserver(t):this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){var l;if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(r),r.defaultPrevented)return;const a=this.getAttribute("action"),o=this.getAttribute("method");if(!(!a||!o)){this._setButtonsSubmitting();try{const c=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:c,bubbles:!0,cancelable:!0}))}catch(c){(c==null?void 0:c.status)===422&&((l=c==null?void 0:c.data)!=null&&l.errors)&&this._applyServerErrors(c.data.errors),this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:c},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var d,p,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(u=>u instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((h=(p=(d=window.mintForm)==null?void 0:d.defaults)==null?void 0:p.headers)!=null&&h.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const u=new URLSearchParams;t.forEach((f,m)=>{f instanceof File||u.append(m,String(f))}),l+=(i.includes("?")?"&":"?")+u.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const u=new URLSearchParams;t.forEach((f,m)=>{f instanceof File||u.append(m,String(f))}),a=u,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const u=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),f=await u.text().catch(()=>"");let m=f;try{m=JSON.parse(f)}catch{}if(!u.ok){const g={status:u.status,data:m,response:{status:u.status,data:m}};throw await this._applyErrorInterceptors(g)}const _={status:u.status,ok:u.ok,data:m};return await this._applySuccessInterceptors(_)}catch(u){if(u.response)throw u;const f={status:u.status||0,data:u.data||u.message||"Network error",response:{status:u.status||0,data:u.data||u.message||"Network error"}};throw await this._applyErrorInterceptors(f)}const c=this;return await new Promise(async(u,f)=>{const m=new XMLHttpRequest;m.open(s||"POST",l,!0),Object.entries(o).forEach(([_,g])=>m.setRequestHeader(_,g)),m.onload=async function(){const{status:_,responseText:g}=m;if(_>=200&&_<300){let v=g;try{v=JSON.parse(g)}catch{}try{const b={status:_,ok:!0,data:v},k=await c._applySuccessInterceptors(b);u(k)}catch(b){f(b)}}else{let v=g;try{v=JSON.parse(g)}catch{}try{const b={status:_,data:v,response:{status:_,data:v}},k=await c._applyErrorInterceptors(b);f(k)}catch(b){f(b)}}},m.onerror=async function(){try{const _={status:m.status||0,data:m.responseText||"Network error",response:{status:m.status||0,data:m.responseText||"Network error"}},g=await c._applyErrorInterceptors(_);f(g)}catch(_){f(_)}},m.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(d=>d.name===l.name&&d.size===l.size&&d.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")}),this._errors={}}_applyServerErrors(t){this._clearErrors(),Object.entries(t).forEach(([e,i])=>{const s=Array.isArray(i)?i[0]||"Validation error":i||"Validation error",n=this._getFieldElements(e);n.length>0&&(this._errors[e]=s,this._flagFieldError(n,s))})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),d=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||d||p||h)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const d=this._getFieldName(c);if(!d||!this._collectValidationRules()[d])return;setTimeout(()=>{this._validateField(d)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t)return!0;try{const e=t.toString();if(e==="[object Object]"||e.includes("Proxy")){const i=Object.keys(t)[0];if(i){const s=Object.getOwnPropertyDescriptor(t,i);if(s&&(s.get||s.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(t){try{const e=this._extractReactiveData(t);return JSON.parse(JSON.stringify(e))}catch{return{...this._extractReactiveData(t)}}}_extractReactiveData(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>this._extractReactiveData(i));const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=this._extractReactiveData(e[s]));return i}return e}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupReactiveDataObserver(t){if(this._stopReactiveDataObserver(),!this.isConnected)return;const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e))this._lastDataSnapshot=this._createDataSnapshot(e);else{this._lastDataSnapshot=null;return}const i=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const s=this._getReactiveValue(this._formData);if(s&&typeof s=="object"&&!Array.isArray(s)){const n=this._createDataSnapshot(s);this._hasDataChanged(n,this._lastDataSnapshot)&&(this._lastDataSnapshot=n,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(i):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(i)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",ut);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(w,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class pt extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,d)=>{const p=c.querySelector("mint-icon"),h=(p==null?void 0:p.getAttribute("name"))||"",u=p!==null&&h!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","bg-[#F7F7F7]","dark:bg-gray-800","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),d===0&&c.classList.add("pl-6"),d===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,d)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),d===l.length-1&&c.classList.remove("border-b");const h=c.querySelectorAll("td");h.forEach((u,f)=>{this._setClasses(u,["text-gray-900","dark:text-gray-100","px-3","py-2"]),f===0&&u.classList.add("pl-6"),f===h.length-1&&u.classList.add("pr-6"),e?this._applyMobileCell(u,s):this._restoreCell(u)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
|
|
90
90
|
@media (max-width: 640px) {
|
|
91
91
|
mint-table[collapse] {
|
|
92
92
|
display: block;
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
border: inherit;
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
|
-
`,document.head.appendChild(t)}}customElements.get("mint-table")||customElements.define("mint-table",pt);class ft extends HTMLElement{constructor(){super(...arguments),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return["dismissable"]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener("click",this._clickHandler)}attributeChangedCallback(){this._render()}_render(){var e;if(this.classList.add("inline-flex","items-center","gap-2","px-3","py-1","rounded-full","border","border-gray-200","dark:border-gray-700","bg-gray-100","dark:bg-gray-800","text-gray-900","dark:text-gray-100","text-sm","font-medium"),!this._root){for(this._root=document.createElement("div"),this._root.className="flex items-center gap-2 w-full",this._textWrap=document.createElement("span"),this._textWrap.className="inline-flex items-center min-w-[0.5rem]",this._textWrap.setAttribute("data-mt-chip-text","");this.firstChild;){const i=this.firstChild;if(i===this._root)break;this._textWrap.appendChild(i)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}this.hasAttribute("dismissable")?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&((e=this._root)==null||e.appendChild(this._dismissBtn))):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){const t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Dismiss"),t.className=["shrink-0","inline-flex","items-center","justify-center","w-5","h-5","rounded-full","text-gray-500","dark:text-gray-300","hover:text-gray-700","dark:hover:text-gray-100","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","transition-colors","duration-150","border-none","bg-transparent","cursor-pointer"].join(" ");const e=document.createElement("mint-icon");e.setAttribute("name","close"),e.className="w-3 h-3",t.appendChild(e),this._clickHandler=i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0}))},t.addEventListener("click",this._clickHandler),this._dismissBtn=t}}customElements.get("mint-chip")||customElements.define("mint-chip",ft);class mt extends HTMLElement{constructor(){super(...arguments),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder="Add tag",this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return["tags","placeholder","sortable","label","info","error","error-message","name","id","required","loading"]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=t=>this._onPointerMove(t),window.addEventListener("pointermove",this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=t=>this._onPointerUp(t),window.addEventListener("pointerup",this._pointerUpHandler),window.addEventListener("pointercancel",this._pointerUpHandler))}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){if(this._renderErrorState(),this._container){const s=this.hasError(),n=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1.5","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=n.join(" ")}return}if(t==="loading"){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(t){this._tags=Array.isArray(t)?[...t]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){const t=this.getAttribute("tags");if(!t)return;try{const i=JSON.parse(t);Array.isArray(i)&&(this._tags=i)}catch(i){console.warn("mint-tags: failed to parse tags attribute",i)}const e=this.getAttribute("placeholder");e!==null&&(this._placeholder=e)}_syncAttr(){this.setAttribute("tags",JSON.stringify(this._tags))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getName(){return this.getAttribute("name")||""}getId(){return this.getAttribute("id")||""}isRequired(){return this.hasAttribute("required")}isLoading(){return this.hasAttribute("loading")}_render(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.hasError(),n=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute("id",n),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement("div");const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" "),this._chipsWrap=document.createElement("div"),this._chipsWrap.className="flex flex-wrap items-center gap-2",this._chipsWrap.addEventListener("dragover",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._chipsWrap.addEventListener("drop",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._input=document.createElement("input"),this._input.type="text",this._input.placeholder=this._placeholder,this._input.className=["min-w-[6rem]","flex-1","bg-transparent","border-none","outline-none","text-sm","text-gray-900","dark:text-gray-100","placeholder:text-gray-400","dark:placeholder:text-gray-500","p-1.5"].join(" "),this._input.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" ")}let r=this.querySelector(".mint-tags-label-container");if(e){r||(r=document.createElement("div"),r.className="mint-tags-label-container mb-[.25rem]",this._container&&this._container.parentElement===this?this.insertBefore(r,this._container):this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-tags-label");e?(l||(l=document.createElement("label"),l.className="mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.appendChild(l)),l.textContent=e,l.setAttribute("for",n)):l&&l.remove()}else r&&r.remove();let a=this.querySelector(".mint-tags-info");i?(a||(a=document.createElement("span"),a.className="mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",this._container&&this._container.parentElement===this?this.insertBefore(a,this._container.nextSibling):this.appendChild(a)),a.textContent=i):a&&a.remove();const o=this.getName();o?(this.setAttribute("name",o),this._input&&(this._input.name=o,this._input.id=n)):(this.removeAttribute("name"),this._input&&(this._input.removeAttribute("name"),this._input.id=n)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){const e=this._container;if(!e)return;e.classList.contains("relative")||e.classList.add("relative");let i=e.querySelector(".mint-tags-skeleton");t?(i||(i=document.createElement("div"),i.className="mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(i)),i.style.display="block",this._chipsWrap&&(this._chipsWrap.style.visibility="hidden",this._chipsWrap.style.pointerEvents="none"),this._input&&(this._input.style.visibility="hidden",this._input.style.pointerEvents="none")):(i&&(i.style.display="none"),this._chipsWrap&&(this._chipsWrap.style.visibility="visible",this._chipsWrap.style.pointerEvents="auto"),this._input&&(this._input.style.visibility="visible",this._input.style.pointerEvents="auto"))}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-tags-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML="";let t=0;this._tags.forEach(e=>{const i=document.createElement("mint-chip");i.dataset.index=String(t++),i.dataset.value=e.value,i.draggable=this.hasAttribute("sortable"),i.draggable&&i.classList.add("cursor-move"),e.dismissable&&(i.setAttribute("dismissable",""),i.addEventListener("dismissed",()=>this._removeTag(e.value))),this._chipsWrap.appendChild(i);const s=i.querySelector("[data-mt-chip-text]");s&&(s.textContent=e.label||e.value),this._setupChipEvents(i,e),i.draggable&&(i.addEventListener("dragstart",n=>this._onDragStart(n,i)),i.addEventListener("dragover",n=>this._onDragOverChip(n,i)),i.addEventListener("drop",n=>this._onDrop(n)),i.addEventListener("dragend",()=>this._onDragEnd())),this.hasAttribute("sortable")&&i.addEventListener("pointerdown",n=>this._onPointerDown(n,i))}),this._input&&(this.hasAttribute("sortable")&&(this._input.addEventListener("dragover",e=>this._onDragOverInput(e)),this._input.addEventListener("drop",e=>this._onDrop(e)),this._input.addEventListener("dragend",()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;const t=this._input.value.trim();if(!t)return;if(this._tags.some(i=>i.value.toLowerCase()===t.toLowerCase())){this._input.value="";return}this._tags.push({value:t,label:t,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value="",setTimeout(()=>{var i;(i=this._input)==null||i.focus()},10)}_removeTag(t){this._tags=this._tags.filter(e=>e.value!==t),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("tags-change",{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){var e;const t=(e=this._chipsWrap)==null?void 0:e.querySelectorAll("mint-chip");t&&t.length>0&&t[t.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{var t;(t=this._input)==null||t.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener("keydown",t=>{var e;t.key==="Backspace"&&((e=this._input)==null?void 0:e.value)===""&&(t.preventDefault(),this._focusLastChip())})}_setupChipEvents(t,e){t.tabIndex=0,t.addEventListener("keydown",i=>{(i.key==="Backspace"||i.key==="Delete")&&e.dismissable&&(i.preventDefault(),this._removeTag(e.value),this._focusInput())})}_onDragStart(t,e){var i;this.hasAttribute("sortable")&&(this._dragChip=e,this._dragIndex=Number(e.dataset.index),(i=t.dataTransfer)==null||i.setData("text/plain",e.dataset.index||""),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.dropEffect="move"),e.classList.add("opacity-60"))}_reorderTags(t,e){if(t<0||e<0||t>=this._tags.length||e>=this._tags.length)return;const i=[...this._tags],[s]=i.splice(t,1);i.splice(e,0,s),this._tags=i,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(t){this.hasAttribute("sortable")&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(t,e){if(!this.hasAttribute("sortable")||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!this._dragChip||!this._chipsWrap)||e===this._dragChip)return;const i=e.getBoundingClientRect(),s=t.clientX,n=i.left+i.width*.5;if(s<n){if(this._dragChip.nextSibling===e)return;this._chipsWrap.insertBefore(this._dragChip,e)}else{if(e.nextSibling===this._dragChip)return;const r=e.nextSibling;r?this._chipsWrap.insertBefore(this._dragChip,r):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(t){this.hasAttribute("sortable")&&t.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove("opacity-60"),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;const t=Array.from(this._chipsWrap.querySelectorAll("mint-chip"));if(t.length===0)return;const e=[];t.forEach(i=>{const s=i.dataset.value;if(!s)return;const n=this._tags.find(r=>r.value===s);n&&e.push(n)}),e.length===this._tags.length&&(this._tags=e,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(t,e){if(this.hasAttribute("sortable")&&t.pointerType!=="mouse"){this._isPointerDragging=!0,this._dragChip=e,this._dragIndex=Number(e.dataset.index);try{e.setPointerCapture(t.pointerId)}catch{}e.classList.add("opacity-60","select-none"),t.preventDefault()}}_onPointerMove(t){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||t.pointerType==="mouse")return;const e=document.elementFromPoint(t.clientX,t.clientY);if(!e)return;const i=e.closest("mint-chip");if(i&&i!==this._dragChip){const s=i.getBoundingClientRect(),n=t.clientX,r=s.left+s.width*.5;if(n<r)this._dragChip.nextSibling!==i&&this._chipsWrap.insertBefore(this._dragChip,i);else if(i.nextSibling!==this._dragChip){const a=i.nextSibling;a?this._chipsWrap.insertBefore(this._dragChip,a):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&e.closest("input")===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(t){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(t.pointerId)}catch{}this._dragChip.classList.remove("opacity-60","select-none")}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}}customElements.get("mint-tags")||customElements.define("mint-tags",mt);class gt extends HTMLElement{constructor(){super(...arguments),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add("transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"),this.hasAttribute("disabled")?this.classList.add("cursor-not-allowed","opacity-50"):this.classList.add("cursor-pointer"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}_setupEventListeners(){this._clickHandler=t=>{if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}this._handleClick(t)},this._keydownHandler=t=>{if(t.key==="Enter"||t.key===" "){if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),this._handleClick(t)}},this.addEventListener("click",this._clickHandler),this.addEventListener("keydown",this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._keydownHandler&&(this.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null)}_handleClick(t){this.dispatchEvent(new CustomEvent("clickable-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){t==="disabled"&&(i!==null?(this.classList.remove("cursor-pointer"),this.classList.add("opacity-50","cursor-not-allowed"),this.setAttribute("aria-disabled","true")):(this.classList.remove("opacity-50","cursor-not-allowed"),this.classList.add("cursor-pointer"),this.removeAttribute("aria-disabled")))}}customElements.get("mint-clickable")||customElements.define("mint-clickable",gt);class _t extends HTMLElement{constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}static get observedAttributes(){return["heading","dismissable","tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}getTone(){const t=this.getAttribute("tone");return t==="info"||t==="success"||t==="warning"||t==="danger"?t:"info"}isDismissable(){return this.hasAttribute("dismissable")}getIconName(){switch(this.getTone()){case"info":return"info";case"success":return"success";case"warning":return"warning";case"danger":return"error";default:return"info"}}getIconColorClasses(){switch(this.getTone()){case"info":return"text-blue-600 dark:text-blue-400";case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-yellow-600 dark:text-yellow-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-blue-600 dark:text-blue-400"}}getHeadingColorClasses(){return"text-gray-900 dark:text-gray-100"}getHeaderBackgroundClasses(){switch(this.getTone()){case"info":return"bg-blue-100 dark:bg-blue-900/30";case"success":return"bg-green-100 dark:bg-green-900/30";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30";case"danger":return"bg-red-100 dark:bg-red-900/30";default:return"bg-blue-100 dark:bg-blue-900/30"}}getBorderClasses(){switch(this.getTone()){case"info":return"border-blue-200 dark:border-blue-800";case"success":return"border-green-200 dark:border-green-800";case"warning":return"border-yellow-200 dark:border-yellow-800";case"danger":return"border-red-200 dark:border-red-800";default:return"border-blue-200 dark:border-blue-800"}}getAriaLive(){return this.getTone()==="danger"?"assertive":"polite"}render(){const t=this.getTone(),e=this.getHeading(),i=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;const s=this.getAriaLive();this.setAttribute("role","alert"),this.setAttribute("aria-live",s),t==="danger"?this.setAttribute("aria-atomic","true"):this.removeAttribute("aria-atomic");const n=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(a=>{n.push(a)}):Array.from(this.childNodes).forEach(r=>{r!==this._headerWrapper&&r!==this._bodyWrapper&&r!==this._iconElement&&r!==this._headingElement&&r!==this._dismissButton&&n.push(r)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement("div"),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement("mint-icon"),this._iconElement.setAttribute("name",this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement("mint-text"),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=e||"",this._headerWrapper.appendChild(this._headingElement),i){this._dismissButton=document.createElement("button"),this._dismissButton.className="flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",this._dismissButton.setAttribute("aria-label","Dismiss alert"),this._dismissButton.setAttribute("type","button");const r=document.createElement("mint-icon");r.setAttribute("name","close"),r.className="w-4 h-4 text-gray-700 dark:text-gray-300",this._dismissButton.appendChild(r),this._dismissHandler=a=>{a.preventDefault(),a.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener("click",this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement("div"),this._bodyWrapper.className="px-4 py-3 bg-white dark:bg-gray-800",n.forEach(r=>{this._bodyWrapper.appendChild(r)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}}customElements.get("mint-alert")||customElements.define("mint-alert",_t);class bt extends HTMLElement{constructor(){super(),this._configuration=null,this._rows=[],this._search="",this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._rowsToShow=15,this._loaded=!1,this._fetching=!1,this._loading=!1,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type="provided",this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId="",this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1}static get observedAttributes(){return["configuration"]}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(t){t&&typeof t=="object"&&!Array.isArray(t)?(this._configuration=t,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility(),this.isConnected&&this.render()):t==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){var t,e;this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._inMintCard=((e=(t=this.parentElement)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())==="mint-card",this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadColumnVisibility(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._rowClickHandler&&(this.removeEventListener("click",this._rowClickHandler,!0),this._rowClickHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null)}attributeChangedCallback(t,e,i){t==="configuration"&&e!==i&&(!this._configuration||typeof i=="string")&&(this._parseConfiguration(),this.render())}refresh(){this._configuration&&(this._type==="ajax"?this._configuration.loadMore?(this._offset=0,this._currentPage=1,this._rowsToShow=this._perPage,this._rows=[],this._fetchData(void 0,!0,this._perPage,0)):this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){const t=this.getAttribute("configuration");if(!t){console.error("mint-resource-table: configuration attribute is required");return}try{this._configuration=JSON.parse(t),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility()}catch(e){console.error("mint-resource-table: Invalid configuration JSON",e)}}_getColumnVisibilityStorageKey(){return`mrtc-${this._tableId}`}_saveColumnVisibility(){if(!this._configuration)return;const t={};this._configuration.columns.forEach((e,i)=>{t[i]=e.hidden||!1});try{localStorage.setItem(this._getColumnVisibilityStorageKey(),JSON.stringify(t))}catch(e){console.warn("Failed to save column visibility to localStorage:",e)}}_loadColumnVisibility(){if(this._configuration)try{const t=localStorage.getItem(this._getColumnVisibilityStorageKey());if(t){const e=JSON.parse(t);this._configuration.columns.forEach((i,s)=>{e[s]!==void 0&&(i.hidden=e[s])})}}catch(t){console.warn("Failed to load column visibility from localStorage:",t)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(t=>{t.searchable&&t.data&&this._searchColumns.push(t.data),t.export&&t.data&&(this._exportColumns[t.data]=t.label),t.data&&this._columns.push(t.data)}),this._configuration.sortBy||(this._configuration.sortBy="id"),this._configuration.sort||(this._configuration.sort="asc"))}async _fetchData(t,e=!0,i,s){var o,l,c,d,u,h,f,p;if(!this._configuration)return;const n=t||(typeof this._configuration.data=="string"?this._configuration.data:null);if(!n||this._fetching||this._loading)return;e&&(this._fetching=!0,this.render()),this._loading=!0;const r=i||this._perPage,a=s!==void 0?s:this._offset;try{const m=new URLSearchParams({perPage:r.toString(),offset:a.toString(),search:this._search,sortBy:this._configuration.sortBy||"id",sort:this._configuration.sort||"asc",searchColumns:this._searchColumns.join(","),columns:this._columns.join(",")}),_={};this._configuration.headers&&(_.headers=this._configuration.headers);const g=await fetch(`${n}?${m.toString()}`,_);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);const v=await g.json(),b=((o=v.content)==null?void 0:o.rows)||[],k=((l=v.content)==null?void 0:l.total)||0;if(this._configuration.loadMore&&a!==0)this._rows=this._rows.concat(b);else{let x=b;this._configuration.predefinedData?(x=[...this._configuration.predefinedData,...b],this._totalRows=k+this._configuration.predefinedData.length):this._totalRows=k,this._rows=x}const A=Math.floor(a/r)+1;this._configuration.loadMore||(((c=v.content)==null?void 0:c.current_page)!==void 0&&v.content.current_page===A?this._currentPage=v.content.current_page:this._currentPage=A,this._offset=(this._currentPage-1)*r),this._lastPage=((d=v.content)==null?void 0:d.last_page)||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;const E=this._sorting;if(E&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,E&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent("loaded",{detail:{rows:this._rows}})),this._updateSearchIcon(),(h=(u=this.querySelector(`#${this._tableId}`))==null?void 0:u.closest("table"))==null?void 0:h.querySelector("tbody")){if(E){const x=this._loading,T=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=x,this._fetching=T}else this._updateTableBody();this._updatePagination()}else this.render()}catch(m){this._fetching=!1,this._loading=!1,this._loaded=!0,this._searching=!1,this._fetchError=m instanceof Error?m.message:"Failed to fetch data",console.error("mint-resource-table: Error fetching data",m),this._updateSearchIcon(),((p=(f=this.querySelector(`#${this._tableId}`))==null?void 0:f.closest("table"))==null?void 0:p.querySelector("tbody"))?(this._updateTableBody(),this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type==="ajax")return this._rows;let t=[...this._rows];const e=this._configuration.sortBy||"id",i=this._configuration.sort||"asc";if(this._search){const s=this._search.toLowerCase().trim().split(/\s+/);t=t.filter(n=>{const r=Object.values(n).map(a=>String(a).toLowerCase()).join(" ");return s.every(a=>r.includes(a))})}if(t.sort((s,n)=>{const r=s[e],a=n[e];if(r==null&&a==null)return 0;if(r==null)return 1;if(a==null)return-1;const o=typeof r=="number"?r:typeof r=="string"&&!isNaN(Number(r))&&r.trim()!==""?Number(r):null,l=typeof a=="number"?a:typeof a=="string"&&!isNaN(Number(a))&&a.trim()!==""?Number(a):null;if(o!==null&&l!==null){const h=o-l;return i==="asc"?h:-h}const c=r instanceof Date?r:typeof r=="string"?new Date(r):null,d=a instanceof Date?a:typeof a=="string"?new Date(a):null;if(c&&d&&!isNaN(c.getTime())&&!isNaN(d.getTime())){const h=c.getTime()-d.getTime();return i==="asc"?h:-h}const u=String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"});return i==="asc"?u:-u}),this._perPage){const s=Math.ceil(t.length/this._perPage);this._lastPage=s,t.forEach((n,r)=>{n.page=Math.ceil((r+1)/this._perPage)}),this._currentPage>s&&s>0&&(this._currentPage=s)}return this._configuration.loadMore?t.slice(0,this._rowsToShow):t.filter(s=>!this._perPage||s.page===this._currentPage)}_toggleSort(t){var i;if(!this._configuration||!t.data||!t.sortable)return;const e=t.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=t,this._updateSortIcons(),this._type==="ajax")this._sortTimeoutId=window.setTimeout(()=>{var n;if(this._sortTimeoutId=null,!this._configuration||!e||!t.sortable)return;let s=this._configuration.sort||"asc";((n=this._configuration.sortBy)==null?void 0:n.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._configuration.loadMore&&(this._rowsToShow=this._perPage),this._fetching=!1,this._loading=!1,this._configuration.loadMore?this._fetchData(void 0,!1,this._perPage,0):this._fetchData(void 0,!1,this._perPage,0)},10);else{let s=this._configuration.sort||"asc";((i=this._configuration.sortBy)==null?void 0:i.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render()}}_getSortClass(t){var e,i,s,n,r;return this._sorting&&this._sortingColumn===t?"spinner":((i=(e=this._configuration)==null?void 0:e.sortBy)==null?void 0:i.toLowerCase())===((s=t.data)==null?void 0:s.toLowerCase())?((r=(n=this._configuration)==null?void 0:n.sort)==null?void 0:r.toLowerCase())==="desc"?"caret-down":"caret-up":""}_updateSortIcons(){this._configuration&&this._configuration.columns.forEach((t,e)=>{if(!t.sortable||t.hidden)return;const i=this.querySelector(`th[data-column-key="${e}"]`);if(!i)return;const s=i.querySelector(".ml-2.flex.items-center");if(!s)return;const n=s.querySelector("mint-icon"),r=s.querySelector("mint-spinner"),a=this._getSortClass(t);if(a==="spinner"){if(n&&n.remove(),!r){const o=document.createElement("mint-spinner");o.className="w-4 h-4",s.appendChild(o)}}else if(r&&r.remove(),n)n.setAttribute("name",a),n.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`;else{const o=document.createElement("mint-icon");o.setAttribute("name",a),o.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`,s.appendChild(o)}})}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type==="ajax"&&this._updateSearchIcon(),this._type!=="ajax"&&(this._currentPage=1),this._updateTableBody(),this._type!=="ajax"&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type==="ajax"?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):this._searching=!1},400)}_updateSearchIcon(){const t=this.querySelector(`#search-${this._tableId}`);if(!t)return;const e=this._type==="ajax"&&(this._searching||this._fetching);setTimeout(()=>{const i=t.querySelector(".relative")||t.querySelector("div");if(!i)return;const s=i.querySelector("mint-icon"),n=i.querySelector("mint-spinner");if(e){if(s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",s.replaceWith(r)}else if(!s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",i.appendChild(r)}}else if(n){t.getAttribute("icon")||t.setAttribute("icon","search");const r=document.createElement("mint-icon");r.setAttribute("name","search"),r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",n.replaceWith(r)}},0)}_updateTableBody(){var a,o;if(!this._configuration)return;const t=this._getRows(),e=(o=(a=this.querySelector(`#${this._tableId}`))==null?void 0:a.closest("table"))==null?void 0:o.querySelector("tbody");if(!e){this.render();return}const i=this.querySelector(`#search-${this._tableId}`),s=document.activeElement===i||(i==null?void 0:i.querySelector("input"))===document.activeElement,n=this._search;let r="";if(!((this._fetching||this._loading)&&!this._sorting)&&(t.forEach((l,c)=>{const d=typeof this._configuration.onRowClick=="function",u=d?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";r+=`<tr data-row-index="${c}" ${d?'data-row-clickable="true"':""}${u?` class="${u}"`:""}>`,this._configuration.columns.forEach((h,f)=>{if(h.hidden)return;const p=!h.show||h.show(this,l);if(r+=`<td style="${this._getStyle(h)}" class="${this._getClasses(h,!0)}">`,p)if(h.raw)if(h.action)(!h.action.show||h.action.show(this,l))&&(r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${h.action.label}</mint-button>`);else if(h.actions)if(h.actionStyle!=="buttons"){const m=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${m}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,v)=>{if(!g.show||g.show(this,l)){const b=typeof g.label=="function"?g.label(this,l):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${v}" data-column-key="${this._configuration.columns.indexOf(h)}">${b}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((m,_)=>{if(!m.show||m.show(this,l)){const g=m.label?typeof m.label=="function"?m.label(this,l):m.label:"",v=m.icon?` icon="${this._escapeHtml(m.icon)}"`:"",b=m.tone?` tone="${this._escapeHtml(m.tone)}"`:"";r+=`<mint-button variant="link" class="${m.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${v}${b}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=h.format(this,l):h.data&&(r+=this._escapeHtml(String(l[h.data]||"")));else if(h.action){if(!h.action.show||h.action.show(this,l)){const m=typeof h.action.label=="function"?h.action.label(this,l):h.action.label;r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(m))}</mint-button>`}}else if(h.actions)if(h.actionStyle!=="buttons"){const m=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${m}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,v)=>{if(!g.show||g.show(this,l)){const b=typeof g.label=="function"?g.label(this,l):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${v}" data-column-key="${this._configuration.columns.indexOf(h)}">${b}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((m,_)=>{if(!m.show||m.show(this,l)){const g=m.label?typeof m.label=="function"?m.label(this,l):m.label:"",v=m.icon?` icon="${this._escapeHtml(m.icon)}"`:"",b=m.tone?` tone="${this._escapeHtml(m.tone)}"`:"";r+=`<mint-button variant="link" class="${m.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${v}${b}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=this._escapeHtml(h.format(this,l)):h.data&&(r+=this._escapeHtml(String(l[h.data]||"")));r+="</td>"}),r+="</tr>"}),t.length===0&&(this._fetchError?r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8">No records found.</td></tr>`),e.innerHTML=r,this._attachTableEventListeners(),this._attachRowClickHandler(),s&&i)){const l=i.querySelector("input")||i._element;l?(l.value=n,setTimeout(()=>{l.focus(),l.setSelectionRange(n.length,n.length)},0)):i.value!==void 0&&(i.value=n,setTimeout(()=>{i.focus()},0))}}_updatePagination(){var s,n;if(!this._configuration)return;const t=this._lastPage||Math.ceil(this._rows.length/this._perPage);if(!this._configuration.perPage||this._configuration.loadMore||t<=1){const r=(s=this.querySelector("nav"))==null?void 0:s.closest(".flex.justify-end");r&&r.remove();return}let e=(n=this.querySelector("nav"))==null?void 0:n.closest(".flex.justify-end");if(!e){const r=this.querySelector("mint-table");if(!r){this.render();return}e=document.createElement("div"),e.className="flex justify-end "+(this._inMintCard?"p-3.5":"mt-4"),r.insertAdjacentElement("afterend",e)}let i="<nav>";i+='<ul class="flex gap-1">',i+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,t);r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(t>2&&(i+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<t-1&&(i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),t>2)for(let r=Math.max(t-1,this._currentPage+2);r<=t;r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}i+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=t?'disabled="true"':""} data-action="page-next"></mint-button></li>`,i+="</ul>",i+="</nav>",e.innerHTML=i,setTimeout(()=>{this._attachPaginationListeners(),e.querySelectorAll("mint-button[data-action]").forEach(r=>{"render"in r&&typeof r.render=="function"&&r.render()})},0)}_loadMore(){this._loading||this._fetching||!(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)||(this._offset+=this._perPage,this._currentPage+=1,this._rowsToShow+=this._perPage,this._type==="ajax"?this._fetchData():this.render())}_goToPage(t){const e=this._lastPage||Math.ceil(this._rows.length/this._perPage);t>e&&(t=e),t<1&&(t=1),this._currentPage=t,this._offset=(t-1)*this._perPage,this._type==="ajax"?this._fetchData():this.render()}_handleButtonClick(t){if(this._configuration)switch(t.type){case"export":break;case"print":window.print();break;case"csv":this._downloadCSV();break;default:t.onClick&&t.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;const t=this.querySelector("table");if(!t)return;const e=t.querySelectorAll("tr");let i="data:text/csv;charset=utf-8,";e.forEach(r=>{const a=[];r.querySelectorAll("th, td").forEach(o=>{var c;const l=o.getAttribute("colspan");if(l)for(let d=0;d<parseInt(l)-1;d++)a.push("");a.push('"'+((c=o.textContent)==null?void 0:c.trim().replace(/"/g,'""'))+'"')}),i+=a.join(",")+`
|
|
153
|
-
`});const s=encodeURI(i),n=document.createElement("a");n.setAttribute("href",s),n.setAttribute("download",`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}_columnChange(t,e){const i=t.target.checked;e.hidden=!i,this._saveColumnVisibility();const s=`edit-columns-popover-${this._tableId}`,n=this.querySelector(`#${s}`),r=n==null?void 0:n.hasAttribute("open");this.render(),r&&n&&requestAnimationFrame(()=>{const a=this.querySelector(`#${s}`);a&&typeof a.open=="function"&&a.open()})}_getStyle(t){let e="";return(t.nowrap||t.actions)&&(e+="white-space: nowrap;"),t.offsetLeft&&(e+=`left: ${t.offsetLeft} !important;`),t.offsetRight&&(e+=`right: ${t.offsetRight} !important;`),t.width&&(e+=`min-width: ${t.width}px; max-width: ${t.width}px;`),e}_getClasses(t,e=!1){const i=[];return t.class&&i.push(t.class.trim()),t.sortable&&!e&&i.push("cursor-pointer"),t.stickLeft&&i.push("sticky-left"),t.stickRight&&i.push("sticky-right"),i.join(" ")}render(){if(!this._configuration){this.innerHTML='<div class="p-4 text-red-500">Error: Invalid configuration</div>';return}const t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,e=this._getRows(),i=this._lastPage||Math.ceil(this._rows.length/this._perPage);let s="";if(t){if(s+='<div class="flex '+(this._inMintCard?"p-3.5":"mb-3")+'">',s+='<div class="flex-grow-1 flex-1">',s+='<div class="flex gap-2 items-center">',this._configuration.showSearch!==!1){const r=`search-${this._tableId}`;s+=`<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}if(this._configuration.buttons&&this._configuration.buttons.forEach(r=>{const a=r.icon?` icon="${this._escapeHtml(r.icon)}"`:"",o=r.tone?` tone="${this._escapeHtml(r.tone)}"`:"";s+=`<mint-button variant="solid" class="${r.class||""}" data-button-type="${r.type||"custom"}"${a}${o}>`,r.label&&(s+=this._escapeHtml(r.label)),s+="</mint-button>"}),s+="</div>",s+="</div>",this._configuration.editColumns!==!1&&this._configuration.columns.some(a=>!a.actions&&a.editable!==!1)){const a=`edit-columns-popover-${this._tableId}`,o=`edit-columns-button-${this._tableId}`;s+='<div class="ml-2">',s+=`<mint-button id="${o}" variant="solid" icon="edit"></mint-button>`,s+=`<mint-popover id="${a}" trigger-id="${o}" direction="down">`,this._configuration.columns.forEach(l=>{!l.actions&&l.editable!==!1&&(s+='<div class="p-2">',s+=`<mint-checkbox label="${l.label}" ${l.hidden?"":"checked"} data-column-key="${this._configuration.columns.indexOf(l)}"></mint-checkbox>`,s+="</div>")}),s+="</mint-popover>",s+="</div>"}s+="</div>"}if(this._type==="ajax"&&(!this._loaded||this._fetching||this._loading)&&!this._fetchError&&!this._sorting){s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{r.hidden||(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1&&(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable&&(s+='<div class="ml-2 flex items-center">',s+='<mint-icon name="" class="w-4 h-4 text-gray-400"></mint-icon>',s+="</div>"),s+="</div>"),s+="</th>")}),s+="</tr></thead>",s+="<tbody>";for(let r=0;r<4;r++)s+="<tr>",this._configuration.columns.forEach(a=>{a.hidden||(s+=`<td style="${this._getStyle(a)}" class="${this._getClasses(a,!0)}">`,s+='<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>',s+="</td>")}),s+="</tr>";if(s+="</tbody>",s+="</table>",s+="</mint-table>",this._configuration.perPage&&!this._configuration.loadMore&&(i>1||this._lastPage>0)){const r=this._lastPage>0?this._lastPage:i;if(r>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let a=1;a<=Math.min(2,r);a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}if(r>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<r-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),r>2)for(let a=Math.max(r-1,this._currentPage+2);a<=r;a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=r?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}}}else if(e.length>0||this._search.length>0||this._searching||this._fetchError){if(s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{if(!r.hidden){if(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1){if(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable){s+='<div class="ml-2 flex items-center">';const o=this._getSortClass(r);o==="spinner"?s+='<mint-spinner class="w-4 h-4"></mint-spinner>':s+=`<mint-icon name="${o}" class="w-4 h-4 ${o==="sort-arrows"?"text-gray-400":""}"></mint-icon>`,s+="</div>"}s+="</div>"}s+="</th>"}}),s+="</tr></thead>",s+="<tbody>",!this._fetching&&!this._loading&&e.forEach((r,a)=>{const o=typeof this._configuration.onRowClick=="function",l=o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";s+=`<tr data-row-index="${a}" ${o?'data-row-clickable="true"':""}${l?` class="${l}"`:""}>`,this._configuration.columns.forEach((c,d)=>{if(c.hidden)return;const u=!c.show||c.show(this,r);if(s+=`<td style="${this._getStyle(c)}" class="${this._getClasses(c,!0)}">`,u)if(c.raw)if(c.action){if(!c.action.show||c.action.show(this,r)){const h=typeof c.action.label=="function"?c.action.label(this,r):c.action.label;s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(h))}</mint-button>`}}else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,f=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${f}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${f}" direction="down">`,c.actions.forEach((p,m)=>{if(!p.show||p.show(this,r)){const _=typeof p.label=="function"?p.label(this,r):p.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,f)=>{if(!h.show||h.show(this,r)){const p=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",m=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${f}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${_}>`,p&&(s+=this._escapeHtml(String(p))),s+="</mint-button>"}});else typeof c.format=="function"?s+=c.format(this,r):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));else if(c.action)(!c.action.show||c.action.show(this,r))&&(s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,f=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${f}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${f}" direction="down">`,c.actions.forEach((p,m)=>{if(!p.show||p.show(this,r)){const _=typeof p.label=="function"?p.label(this,r):p.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,f)=>{if(!h.show||h.show(this,r)){const p=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",m=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${f}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${_}>`,p&&(s+=this._escapeHtml(String(p))),s+="</mint-button>"}});else typeof c.format=="function"?s+=this._escapeHtml(c.format(this,r)):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));s+="</td>"}),s+="</tr>"}),!this._fetching&&!this._loading&&e.length===0&&(this._fetchError?s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8">No records found.</td></tr>`),s+="</tbody>",s+="</table>",this._configuration.loadMore&&(this._loading||this._fetching?(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<mint-spinner></mint-spinner>",s+="</div>"):(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)&&(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+='<mint-button variant="ghost" data-action="load-more">Load more</mint-button>',s+="</div>")),this._configuration.perPage&&!this._configuration.loadMore&&this._loaded&&i>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,i);r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(i>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<i-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),i>2)for(let r=Math.max(i-1,this._currentPage+2);r<=i;r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=i?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}s+="</mint-table>"}else s+='<slot name="empty"></slot>';this.innerHTML=s,this.querySelectorAll("mint-button[data-action]").forEach(r=>{r.render&&r.render()}),this.querySelectorAll("mint-button[data-button-type]").forEach(r=>{r.render&&r.render()}),this._attachEventListeners(),this._type==="ajax"&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener("click",this._rowClickHandler,!0);const t=e=>{var l;const i=e.target;if(i.tagName==="MINT-BUTTON"||i.tagName==="BUTTON"||i.closest("mint-button")||i.closest("button")||i.closest("mint-popover")||i.closest("[data-action]"))return;const s=i.closest('tr[data-row-clickable="true"]');if(!s)return;const n=s.getAttribute("data-row-index");if(!n)return;const r=parseInt(n),o=this._getRows()[r];!o||!((l=this._configuration)!=null&&l.onRowClick)||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(o):this._configuration.onRowClick(this,o))};this.addEventListener("click",t,!0),this._rowClickHandler=t}_attachPaginationListeners(){this.querySelectorAll('[data-action="page"]').forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.getAttribute("data-page")||"1");this._goToPage(e)})}),this.querySelectorAll('[data-action="page-prev"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll('[data-action="page-next"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll('[data-action="row-action"]').forEach(t=>{t.addEventListener("click",()=>{var o;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-action-index")||"0"),s=parseInt(t.getAttribute("data-column-key")||"0"),r=this._getRows()[e],a=(o=this._configuration)==null?void 0:o.columns[s];a&&a.actions&&a.actions[i]&&a.actions[i].onClick(this,r)})}),this.querySelectorAll('[data-action="column-action"]').forEach(t=>{t.addEventListener("click",()=>{var a;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-column-key")||"0"),n=this._getRows()[e],r=(a=this._configuration)==null?void 0:a.columns[i];r&&r.action&&r.action.onClick(this,n)})})}_attachEventListeners(){var e;const t=this.querySelector(`#search-${this._tableId}`);if(t){const i=t.querySelector("input")||t._element;i?i.addEventListener("input",s=>{this._search=s.target.value,this._triggerSearch()}):t.addEventListener("input",s=>{this._search=t.value||s.target.value||"",this._triggerSearch()})}if(this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll("th[data-column-key]").forEach(i=>{i.addEventListener("click",()=>{var r;const s=parseInt(i.getAttribute("data-column-key")||"0"),n=(r=this._configuration)==null?void 0:r.columns[s];n&&this._toggleSort(n)})}),this.querySelectorAll("[data-button-type]").forEach(i=>{i.addEventListener("click",()=>{var r,a;const s=i.getAttribute("data-button-type"),n=(a=(r=this._configuration)==null?void 0:r.buttons)==null?void 0:a.find(o=>(o.type||"custom")===s);n&&this._handleButtonClick(n)})}),this.querySelectorAll("mint-checkbox[data-column-key]").forEach(i=>{i.addEventListener("change",s=>{var a;s.stopPropagation();const n=parseInt(i.getAttribute("data-column-key")||"0"),r=(a=this._configuration)==null?void 0:a.columns[n];r&&this._columnChange(s,r)}),i.addEventListener("click",s=>{s.stopPropagation()})}),this._attachPaginationListeners(),this.querySelectorAll('[data-action="load-more"]').forEach(i=>{i.addEventListener("click",()=>{this._loadMore()})}),(e=this._configuration)!=null&&e.loadMore){this._scrollHandler&&window.removeEventListener("scroll",this._scrollHandler);const i=()=>{const s=window.pageYOffset||document.documentElement.scrollTop,n=window.innerHeight;if(document.documentElement.scrollHeight-s-n<=100){const a=this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows;!this._loading&&!this._fetching&&a&&this._loadMore()}};this._scrollHandler=i,window.addEventListener("scroll",i)}}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}customElements.get("mint-resource-table")||customElements.define("mint-resource-table",bt);exports.Alert=_t;exports.BackButton=et;exports.Button=j;exports.Card=Q;exports.Checkbox=at;exports.Chip=ft;exports.Choice=ot;exports.Clickable=gt;exports.DatePicker=ct;exports.Dropzone=dt;exports.Form=ut;exports.Grid=st;exports.Icon=J;exports.Input=lt;exports.Link=tt;exports.Modal=rt;exports.Page=it;exports.Popover=nt;exports.ResourceTable=bt;exports.Select=ht;exports.Spinner=G;exports.Stack=Z;exports.Switch=K;exports.Table=pt;exports.Tags=mt;exports.Text=X;exports.default=j;
|
|
152
|
+
`,document.head.appendChild(t)}}customElements.get("mint-table")||customElements.define("mint-table",pt);class ft extends HTMLElement{constructor(){super(...arguments),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return["dismissable"]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener("click",this._clickHandler)}attributeChangedCallback(){this._render()}_render(){var e;if(this.classList.add("inline-flex","items-center","gap-2","px-3","py-1","rounded-full","border","border-gray-200","dark:border-gray-700","bg-gray-100","dark:bg-gray-800","text-gray-900","dark:text-gray-100","text-sm","font-medium"),!this._root){for(this._root=document.createElement("div"),this._root.className="flex items-center gap-2 w-full",this._textWrap=document.createElement("span"),this._textWrap.className="inline-flex items-center min-w-[0.5rem]",this._textWrap.setAttribute("data-mt-chip-text","");this.firstChild;){const i=this.firstChild;if(i===this._root)break;this._textWrap.appendChild(i)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}this.hasAttribute("dismissable")?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&((e=this._root)==null||e.appendChild(this._dismissBtn))):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){const t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Dismiss"),t.className=["shrink-0","inline-flex","items-center","justify-center","w-5","h-5","rounded-full","text-gray-500","dark:text-gray-300","hover:text-gray-700","dark:hover:text-gray-100","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","transition-colors","duration-150","border-none","bg-transparent","cursor-pointer"].join(" ");const e=document.createElement("mint-icon");e.setAttribute("name","close"),e.className="w-3 h-3",t.appendChild(e),this._clickHandler=i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0}))},t.addEventListener("click",this._clickHandler),this._dismissBtn=t}}customElements.get("mint-chip")||customElements.define("mint-chip",ft);class mt extends HTMLElement{constructor(){super(...arguments),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder="Add tag",this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return["tags","placeholder","sortable","label","info","error","error-message","name","id","required","loading"]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=t=>this._onPointerMove(t),window.addEventListener("pointermove",this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=t=>this._onPointerUp(t),window.addEventListener("pointerup",this._pointerUpHandler),window.addEventListener("pointercancel",this._pointerUpHandler))}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){if(this._renderErrorState(),this._container){const s=this.hasError(),n=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1.5","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=n.join(" ")}return}if(t==="loading"){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(t){this._tags=Array.isArray(t)?[...t]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){const t=this.getAttribute("tags");if(!t)return;try{const i=JSON.parse(t);Array.isArray(i)&&(this._tags=i)}catch(i){console.warn("mint-tags: failed to parse tags attribute",i)}const e=this.getAttribute("placeholder");e!==null&&(this._placeholder=e)}_syncAttr(){this.setAttribute("tags",JSON.stringify(this._tags))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getName(){return this.getAttribute("name")||""}getId(){return this.getAttribute("id")||""}isRequired(){return this.hasAttribute("required")}isLoading(){return this.hasAttribute("loading")}_render(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.hasError(),n=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute("id",n),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement("div");const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" "),this._chipsWrap=document.createElement("div"),this._chipsWrap.className="flex flex-wrap items-center gap-2",this._chipsWrap.addEventListener("dragover",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._chipsWrap.addEventListener("drop",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._input=document.createElement("input"),this._input.type="text",this._input.placeholder=this._placeholder,this._input.className=["min-w-[6rem]","flex-1","bg-transparent","border-none","outline-none","text-sm","text-gray-900","dark:text-gray-100","placeholder:text-gray-400","dark:placeholder:text-gray-500","p-1.5"].join(" "),this._input.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" ")}let r=this.querySelector(".mint-tags-label-container");if(e){r||(r=document.createElement("div"),r.className="mint-tags-label-container mb-[.25rem]",this._container&&this._container.parentElement===this?this.insertBefore(r,this._container):this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-tags-label");e?(l||(l=document.createElement("label"),l.className="mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.appendChild(l)),l.textContent=e,l.setAttribute("for",n)):l&&l.remove()}else r&&r.remove();let a=this.querySelector(".mint-tags-info");i?(a||(a=document.createElement("span"),a.className="mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",this._container&&this._container.parentElement===this?this.insertBefore(a,this._container.nextSibling):this.appendChild(a)),a.textContent=i):a&&a.remove();const o=this.getName();o?(this.setAttribute("name",o),this._input&&(this._input.name=o,this._input.id=n)):(this.removeAttribute("name"),this._input&&(this._input.removeAttribute("name"),this._input.id=n)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){const e=this._container;if(!e)return;e.classList.contains("relative")||e.classList.add("relative");let i=e.querySelector(".mint-tags-skeleton");t?(i||(i=document.createElement("div"),i.className="mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(i)),i.style.display="block",this._chipsWrap&&(this._chipsWrap.style.visibility="hidden",this._chipsWrap.style.pointerEvents="none"),this._input&&(this._input.style.visibility="hidden",this._input.style.pointerEvents="none")):(i&&(i.style.display="none"),this._chipsWrap&&(this._chipsWrap.style.visibility="visible",this._chipsWrap.style.pointerEvents="auto"),this._input&&(this._input.style.visibility="visible",this._input.style.pointerEvents="auto"))}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-tags-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML="";let t=0;this._tags.forEach(e=>{const i=document.createElement("mint-chip");i.dataset.index=String(t++),i.dataset.value=e.value,i.draggable=this.hasAttribute("sortable"),i.draggable&&i.classList.add("cursor-move"),e.dismissable&&(i.setAttribute("dismissable",""),i.addEventListener("dismissed",()=>this._removeTag(e.value))),this._chipsWrap.appendChild(i);const s=i.querySelector("[data-mt-chip-text]");s&&(s.textContent=e.label||e.value),this._setupChipEvents(i,e),i.draggable&&(i.addEventListener("dragstart",n=>this._onDragStart(n,i)),i.addEventListener("dragover",n=>this._onDragOverChip(n,i)),i.addEventListener("drop",n=>this._onDrop(n)),i.addEventListener("dragend",()=>this._onDragEnd())),this.hasAttribute("sortable")&&i.addEventListener("pointerdown",n=>this._onPointerDown(n,i))}),this._input&&(this.hasAttribute("sortable")&&(this._input.addEventListener("dragover",e=>this._onDragOverInput(e)),this._input.addEventListener("drop",e=>this._onDrop(e)),this._input.addEventListener("dragend",()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;const t=this._input.value.trim();if(!t)return;if(this._tags.some(i=>i.value.toLowerCase()===t.toLowerCase())){this._input.value="";return}this._tags.push({value:t,label:t,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value="",setTimeout(()=>{var i;(i=this._input)==null||i.focus()},10)}_removeTag(t){this._tags=this._tags.filter(e=>e.value!==t),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("tags-change",{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){var e;const t=(e=this._chipsWrap)==null?void 0:e.querySelectorAll("mint-chip");t&&t.length>0&&t[t.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{var t;(t=this._input)==null||t.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener("keydown",t=>{var e;t.key==="Backspace"&&((e=this._input)==null?void 0:e.value)===""&&(t.preventDefault(),this._focusLastChip())})}_setupChipEvents(t,e){t.tabIndex=0,t.addEventListener("keydown",i=>{(i.key==="Backspace"||i.key==="Delete")&&e.dismissable&&(i.preventDefault(),this._removeTag(e.value),this._focusInput())})}_onDragStart(t,e){var i;this.hasAttribute("sortable")&&(this._dragChip=e,this._dragIndex=Number(e.dataset.index),(i=t.dataTransfer)==null||i.setData("text/plain",e.dataset.index||""),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.dropEffect="move"),e.classList.add("opacity-60"))}_reorderTags(t,e){if(t<0||e<0||t>=this._tags.length||e>=this._tags.length)return;const i=[...this._tags],[s]=i.splice(t,1);i.splice(e,0,s),this._tags=i,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(t){this.hasAttribute("sortable")&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(t,e){if(!this.hasAttribute("sortable")||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!this._dragChip||!this._chipsWrap)||e===this._dragChip)return;const i=e.getBoundingClientRect(),s=t.clientX,n=i.left+i.width*.5;if(s<n){if(this._dragChip.nextSibling===e)return;this._chipsWrap.insertBefore(this._dragChip,e)}else{if(e.nextSibling===this._dragChip)return;const r=e.nextSibling;r?this._chipsWrap.insertBefore(this._dragChip,r):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(t){this.hasAttribute("sortable")&&t.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove("opacity-60"),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;const t=Array.from(this._chipsWrap.querySelectorAll("mint-chip"));if(t.length===0)return;const e=[];t.forEach(i=>{const s=i.dataset.value;if(!s)return;const n=this._tags.find(r=>r.value===s);n&&e.push(n)}),e.length===this._tags.length&&(this._tags=e,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(t,e){if(this.hasAttribute("sortable")&&t.pointerType!=="mouse"){this._isPointerDragging=!0,this._dragChip=e,this._dragIndex=Number(e.dataset.index);try{e.setPointerCapture(t.pointerId)}catch{}e.classList.add("opacity-60","select-none"),t.preventDefault()}}_onPointerMove(t){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||t.pointerType==="mouse")return;const e=document.elementFromPoint(t.clientX,t.clientY);if(!e)return;const i=e.closest("mint-chip");if(i&&i!==this._dragChip){const s=i.getBoundingClientRect(),n=t.clientX,r=s.left+s.width*.5;if(n<r)this._dragChip.nextSibling!==i&&this._chipsWrap.insertBefore(this._dragChip,i);else if(i.nextSibling!==this._dragChip){const a=i.nextSibling;a?this._chipsWrap.insertBefore(this._dragChip,a):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&e.closest("input")===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(t){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(t.pointerId)}catch{}this._dragChip.classList.remove("opacity-60","select-none")}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}}customElements.get("mint-tags")||customElements.define("mint-tags",mt);class gt extends HTMLElement{constructor(){super(...arguments),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add("transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"),this.hasAttribute("disabled")?this.classList.add("cursor-not-allowed","opacity-50"):this.classList.add("cursor-pointer"),this.hasAttribute("role")||this.setAttribute("role","button"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0")}_setupEventListeners(){this._clickHandler=t=>{if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}this._handleClick(t)},this._keydownHandler=t=>{if(t.key==="Enter"||t.key===" "){if(this.hasAttribute("disabled")){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),this._handleClick(t)}},this.addEventListener("click",this._clickHandler),this.addEventListener("keydown",this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._keydownHandler&&(this.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null)}_handleClick(t){this.dispatchEvent(new CustomEvent("clickable-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){t==="disabled"&&(i!==null?(this.classList.remove("cursor-pointer"),this.classList.add("opacity-50","cursor-not-allowed"),this.setAttribute("aria-disabled","true")):(this.classList.remove("opacity-50","cursor-not-allowed"),this.classList.add("cursor-pointer"),this.removeAttribute("aria-disabled")))}}customElements.get("mint-clickable")||customElements.define("mint-clickable",gt);class _t extends HTMLElement{constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}static get observedAttributes(){return["heading","dismissable","tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}getTone(){const t=this.getAttribute("tone");return t==="info"||t==="success"||t==="warning"||t==="danger"?t:"info"}isDismissable(){return this.hasAttribute("dismissable")}getIconName(){switch(this.getTone()){case"info":return"info";case"success":return"success";case"warning":return"warning";case"danger":return"error";default:return"info"}}getIconColorClasses(){switch(this.getTone()){case"info":return"text-blue-600 dark:text-blue-400";case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-yellow-600 dark:text-yellow-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-blue-600 dark:text-blue-400"}}getHeadingColorClasses(){return"text-gray-900 dark:text-gray-100"}getHeaderBackgroundClasses(){switch(this.getTone()){case"info":return"bg-blue-100 dark:bg-blue-900/30";case"success":return"bg-green-100 dark:bg-green-900/30";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30";case"danger":return"bg-red-100 dark:bg-red-900/30";default:return"bg-blue-100 dark:bg-blue-900/30"}}getBorderClasses(){switch(this.getTone()){case"info":return"border-blue-200 dark:border-blue-800";case"success":return"border-green-200 dark:border-green-800";case"warning":return"border-yellow-200 dark:border-yellow-800";case"danger":return"border-red-200 dark:border-red-800";default:return"border-blue-200 dark:border-blue-800"}}getAriaLive(){return this.getTone()==="danger"?"assertive":"polite"}render(){const t=this.getTone(),e=this.getHeading(),i=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;const s=this.getAriaLive();this.setAttribute("role","alert"),this.setAttribute("aria-live",s),t==="danger"?this.setAttribute("aria-atomic","true"):this.removeAttribute("aria-atomic");const n=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(a=>{n.push(a)}):Array.from(this.childNodes).forEach(r=>{r!==this._headerWrapper&&r!==this._bodyWrapper&&r!==this._iconElement&&r!==this._headingElement&&r!==this._dismissButton&&n.push(r)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement("div"),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement("mint-icon"),this._iconElement.setAttribute("name",this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement("mint-text"),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=e||"",this._headerWrapper.appendChild(this._headingElement),i){this._dismissButton=document.createElement("button"),this._dismissButton.className="flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",this._dismissButton.setAttribute("aria-label","Dismiss alert"),this._dismissButton.setAttribute("type","button");const r=document.createElement("mint-icon");r.setAttribute("name","close"),r.className="w-4 h-4 text-gray-700 dark:text-gray-300",this._dismissButton.appendChild(r),this._dismissHandler=a=>{a.preventDefault(),a.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener("click",this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement("div"),this._bodyWrapper.className="px-4 py-3 bg-white dark:bg-gray-800",n.forEach(r=>{this._bodyWrapper.appendChild(r)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}}customElements.get("mint-alert")||customElements.define("mint-alert",_t);class bt extends HTMLElement{constructor(){super(),this._configuration=null,this._rows=[],this._search="",this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._rowsToShow=15,this._loaded=!1,this._fetching=!1,this._loading=!1,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type="provided",this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId="",this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1}static get observedAttributes(){return["configuration"]}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(t){t&&typeof t=="object"&&!Array.isArray(t)?(this._configuration=t,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility(),this.isConnected&&this.render()):t==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){var t,e;this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._inMintCard=((e=(t=this.parentElement)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())==="mint-card",this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadColumnVisibility(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._rowClickHandler&&(this.removeEventListener("click",this._rowClickHandler,!0),this._rowClickHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null)}attributeChangedCallback(t,e,i){t==="configuration"&&e!==i&&(!this._configuration||typeof i=="string")&&(this._parseConfiguration(),this.render())}refresh(){this._configuration&&(this._type==="ajax"?this._configuration.loadMore?(this._offset=0,this._currentPage=1,this._rowsToShow=this._perPage,this._rows=[],this._fetchData(void 0,!0,this._perPage,0)):this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){const t=this.getAttribute("configuration");if(!t){console.error("mint-resource-table: configuration attribute is required");return}try{this._configuration=JSON.parse(t),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility()}catch(e){console.error("mint-resource-table: Invalid configuration JSON",e)}}_getColumnVisibilityStorageKey(){return`mrtc-${this._tableId}`}_saveColumnVisibility(){if(!this._configuration)return;const t={};this._configuration.columns.forEach((e,i)=>{t[i]=e.hidden||!1});try{localStorage.setItem(this._getColumnVisibilityStorageKey(),JSON.stringify(t))}catch(e){console.warn("Failed to save column visibility to localStorage:",e)}}_loadColumnVisibility(){if(this._configuration)try{const t=localStorage.getItem(this._getColumnVisibilityStorageKey());if(t){const e=JSON.parse(t);this._configuration.columns.forEach((i,s)=>{e[s]!==void 0&&(i.hidden=e[s])})}}catch(t){console.warn("Failed to load column visibility from localStorage:",t)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(t=>{t.searchable&&t.data&&this._searchColumns.push(t.data),t.export&&t.data&&(this._exportColumns[t.data]=t.label),t.data&&this._columns.push(t.data)}),this._configuration.sortBy||(this._configuration.sortBy="id"),this._configuration.sort||(this._configuration.sort="asc"))}async _fetchData(t,e=!0,i,s){var o,l,c,d,p,h,u,f;if(!this._configuration)return;const n=t||(typeof this._configuration.data=="string"?this._configuration.data:null);if(!n||this._fetching||this._loading)return;e&&(this._fetching=!0,this.render()),this._loading=!0;const r=i||this._perPage,a=s!==void 0?s:this._offset;try{const m=new URLSearchParams({perPage:r.toString(),offset:a.toString(),search:this._search,sortBy:this._configuration.sortBy||"id",sort:this._configuration.sort||"asc",searchColumns:this._searchColumns.join(","),columns:this._columns.join(",")}),_={};this._configuration.headers&&(_.headers=this._configuration.headers);const g=await fetch(`${n}?${m.toString()}`,_);if(!g.ok)throw new Error(`HTTP error! status: ${g.status}`);const v=await g.json(),b=((o=v.content)==null?void 0:o.rows)||[],k=((l=v.content)==null?void 0:l.total)||0;if(this._configuration.loadMore&&a!==0)this._rows=this._rows.concat(b);else{let x=b;this._configuration.predefinedData?(x=[...this._configuration.predefinedData,...b],this._totalRows=k+this._configuration.predefinedData.length):this._totalRows=k,this._rows=x}const A=Math.floor(a/r)+1;this._configuration.loadMore||(((c=v.content)==null?void 0:c.current_page)!==void 0&&v.content.current_page===A?this._currentPage=v.content.current_page:this._currentPage=A,this._offset=(this._currentPage-1)*r),this._lastPage=((d=v.content)==null?void 0:d.last_page)||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;const E=this._sorting;if(E&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,E&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent("loaded",{detail:{rows:this._rows}})),this._updateSearchIcon(),(h=(p=this.querySelector(`#${this._tableId}`))==null?void 0:p.closest("table"))==null?void 0:h.querySelector("tbody")){if(E){const x=this._loading,T=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=x,this._fetching=T}else this._updateTableBody();this._updatePagination()}else this.render()}catch(m){this._fetching=!1,this._loading=!1,this._loaded=!0,this._searching=!1,this._fetchError=m instanceof Error?m.message:"Failed to fetch data",console.error("mint-resource-table: Error fetching data",m),this._updateSearchIcon(),((f=(u=this.querySelector(`#${this._tableId}`))==null?void 0:u.closest("table"))==null?void 0:f.querySelector("tbody"))?(this._updateTableBody(),this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type==="ajax")return this._rows;let t=[...this._rows];const e=this._configuration.sortBy||"id",i=this._configuration.sort||"asc";if(this._search){const s=this._search.toLowerCase().trim().split(/\s+/);t=t.filter(n=>{const r=Object.values(n).map(a=>String(a).toLowerCase()).join(" ");return s.every(a=>r.includes(a))})}if(t.sort((s,n)=>{const r=s[e],a=n[e];if(r==null&&a==null)return 0;if(r==null)return 1;if(a==null)return-1;const o=typeof r=="number"?r:typeof r=="string"&&!isNaN(Number(r))&&r.trim()!==""?Number(r):null,l=typeof a=="number"?a:typeof a=="string"&&!isNaN(Number(a))&&a.trim()!==""?Number(a):null;if(o!==null&&l!==null){const h=o-l;return i==="asc"?h:-h}const c=r instanceof Date?r:typeof r=="string"?new Date(r):null,d=a instanceof Date?a:typeof a=="string"?new Date(a):null;if(c&&d&&!isNaN(c.getTime())&&!isNaN(d.getTime())){const h=c.getTime()-d.getTime();return i==="asc"?h:-h}const p=String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"});return i==="asc"?p:-p}),this._perPage){const s=Math.ceil(t.length/this._perPage);this._lastPage=s,t.forEach((n,r)=>{n.page=Math.ceil((r+1)/this._perPage)}),this._currentPage>s&&s>0&&(this._currentPage=s)}return this._configuration.loadMore?t.slice(0,this._rowsToShow):t.filter(s=>!this._perPage||s.page===this._currentPage)}_toggleSort(t){var i;if(!this._configuration||!t.data||!t.sortable)return;const e=t.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=t,this._updateSortIcons(),this._type==="ajax")this._sortTimeoutId=window.setTimeout(()=>{var n;if(this._sortTimeoutId=null,!this._configuration||!e||!t.sortable)return;let s=this._configuration.sort||"asc";((n=this._configuration.sortBy)==null?void 0:n.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._configuration.loadMore&&(this._rowsToShow=this._perPage),this._fetching=!1,this._loading=!1,this._configuration.loadMore?this._fetchData(void 0,!1,this._perPage,0):this._fetchData(void 0,!1,this._perPage,0)},10);else{let s=this._configuration.sort||"asc";((i=this._configuration.sortBy)==null?void 0:i.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render()}}_getSortClass(t){var e,i,s,n,r;return this._sorting&&this._sortingColumn===t?"spinner":((i=(e=this._configuration)==null?void 0:e.sortBy)==null?void 0:i.toLowerCase())===((s=t.data)==null?void 0:s.toLowerCase())?((r=(n=this._configuration)==null?void 0:n.sort)==null?void 0:r.toLowerCase())==="desc"?"caret-down":"caret-up":""}_updateSortIcons(){this._configuration&&this._configuration.columns.forEach((t,e)=>{if(!t.sortable||t.hidden)return;const i=this.querySelector(`th[data-column-key="${e}"]`);if(!i)return;const s=i.querySelector(".ml-2.flex.items-center");if(!s)return;const n=s.querySelector("mint-icon"),r=s.querySelector("mint-spinner"),a=this._getSortClass(t);if(a==="spinner"){if(n&&n.remove(),!r){const o=document.createElement("mint-spinner");o.className="w-4 h-4",s.appendChild(o)}}else if(r&&r.remove(),n)n.setAttribute("name",a),n.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`;else{const o=document.createElement("mint-icon");o.setAttribute("name",a),o.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`,s.appendChild(o)}})}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type==="ajax"&&this._updateSearchIcon(),this._type!=="ajax"&&(this._currentPage=1),this._updateTableBody(),this._type!=="ajax"&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type==="ajax"?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):this._searching=!1},400)}_updateSearchIcon(){const t=this.querySelector(`#search-${this._tableId}`);if(!t)return;const e=this._type==="ajax"&&(this._searching||this._fetching);setTimeout(()=>{const i=t.querySelector(".relative")||t.querySelector("div");if(!i)return;const s=i.querySelector("mint-icon"),n=i.querySelector("mint-spinner");if(e){if(s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",s.replaceWith(r)}else if(!s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",i.appendChild(r)}}else if(n){t.getAttribute("icon")||t.setAttribute("icon","search");const r=document.createElement("mint-icon");r.setAttribute("name","search"),r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",n.replaceWith(r)}},0)}_updateTableBody(){var a,o;if(!this._configuration)return;const t=this._getRows(),e=(o=(a=this.querySelector(`#${this._tableId}`))==null?void 0:a.closest("table"))==null?void 0:o.querySelector("tbody");if(!e){this.render();return}const i=this.querySelector(`#search-${this._tableId}`),s=document.activeElement===i||(i==null?void 0:i.querySelector("input"))===document.activeElement,n=this._search;let r="";if(!((this._fetching||this._loading)&&!this._sorting)&&(t.forEach((l,c)=>{const d=typeof this._configuration.onRowClick=="function",p=d?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";r+=`<tr data-row-index="${c}" ${d?'data-row-clickable="true"':""}${p?` class="${p}"`:""}>`,this._configuration.columns.forEach((h,u)=>{if(h.hidden)return;const f=!h.show||h.show(this,l);if(r+=`<td style="${this._getStyle(h)}" class="${this._getClasses(h,!0)}">`,f)if(h.raw)if(h.action)(!h.action.show||h.action.show(this,l))&&(r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${h.action.label}</mint-button>`);else if(h.actions)if(h.actionStyle!=="buttons"){const m=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${m}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,v)=>{if(!g.show||g.show(this,l)){const b=typeof g.label=="function"?g.label(this,l):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${v}" data-column-key="${this._configuration.columns.indexOf(h)}">${b}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((m,_)=>{if(!m.show||m.show(this,l)){const g=m.label?typeof m.label=="function"?m.label(this,l):m.label:"",v=m.icon?` icon="${this._escapeHtml(m.icon)}"`:"",b=m.tone?` tone="${this._escapeHtml(m.tone)}"`:"";r+=`<mint-button variant="link" class="${m.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${v}${b}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=h.format(this,l):h.data&&(r+=this._escapeHtml(String(l[h.data]||"")));else if(h.action){if(!h.action.show||h.action.show(this,l)){const m=typeof h.action.label=="function"?h.action.label(this,l):h.action.label;r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(h)}">${this._escapeHtml(String(m))}</mint-button>`}}else if(h.actions)if(h.actionStyle!=="buttons"){const m=`actions-popover-${this._tableId}-${c}`,_=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${_}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${m}" trigger-id="${_}" direction="down">`,h.actions.forEach((g,v)=>{if(!g.show||g.show(this,l)){const b=typeof g.label=="function"?g.label(this,l):g.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${v}" data-column-key="${this._configuration.columns.indexOf(h)}">${b}</div>`}}),r+="</mint-popover>"}else h.actions.forEach((m,_)=>{if(!m.show||m.show(this,l)){const g=m.label?typeof m.label=="function"?m.label(this,l):m.label:"",v=m.icon?` icon="${this._escapeHtml(m.icon)}"`:"",b=m.tone?` tone="${this._escapeHtml(m.tone)}"`:"";r+=`<mint-button variant="link" class="${m.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${_}" data-column-key="${this._configuration.columns.indexOf(h)}"${v}${b}>`,g&&(r+=this._escapeHtml(String(g))),r+="</mint-button>"}});else typeof h.format=="function"?r+=this._escapeHtml(h.format(this,l)):h.data&&(r+=this._escapeHtml(String(l[h.data]||"")));r+="</td>"}),r+="</tr>"}),t.length===0&&(this._fetchError?r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8">No records found.</td></tr>`),e.innerHTML=r,this._attachTableEventListeners(),this._attachRowClickHandler(),s&&i)){const l=i.querySelector("input")||i._element;l?(l.value=n,setTimeout(()=>{l.focus(),l.setSelectionRange(n.length,n.length)},0)):i.value!==void 0&&(i.value=n,setTimeout(()=>{i.focus()},0))}}_updatePagination(){var s,n;if(!this._configuration)return;const t=this._lastPage||Math.ceil(this._rows.length/this._perPage);if(!this._configuration.perPage||this._configuration.loadMore||t<=1){const r=(s=this.querySelector("nav"))==null?void 0:s.closest(".flex.justify-end");r&&r.remove();return}let e=(n=this.querySelector("nav"))==null?void 0:n.closest(".flex.justify-end");if(!e){const r=this.querySelector("mint-table");if(!r){this.render();return}e=document.createElement("div"),e.className="flex justify-end "+(this._inMintCard?"p-3.5":"mt-4"),r.insertAdjacentElement("afterend",e)}let i="<nav>";i+='<ul class="flex gap-1">',i+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,t);r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(t>2&&(i+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<t-1&&(i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,i+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),t>2)for(let r=Math.max(t-1,this._currentPage+2);r<=t;r++){const o=this._currentPage===r?' disabled="true"':"";i+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}i+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=t?'disabled="true"':""} data-action="page-next"></mint-button></li>`,i+="</ul>",i+="</nav>",e.innerHTML=i,setTimeout(()=>{this._attachPaginationListeners(),e.querySelectorAll("mint-button[data-action]").forEach(r=>{"render"in r&&typeof r.render=="function"&&r.render()})},0)}_loadMore(){this._loading||this._fetching||!(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)||(this._offset+=this._perPage,this._currentPage+=1,this._rowsToShow+=this._perPage,this._type==="ajax"?this._fetchData():this.render())}_goToPage(t){const e=this._lastPage||Math.ceil(this._rows.length/this._perPage);t>e&&(t=e),t<1&&(t=1),this._currentPage=t,this._offset=(t-1)*this._perPage,this._type==="ajax"?this._fetchData():this.render()}_handleButtonClick(t){if(this._configuration)switch(t.type){case"export":break;case"print":window.print();break;case"csv":this._downloadCSV();break;default:t.onClick&&t.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;const t=this.querySelector("table");if(!t)return;const e=t.querySelectorAll("tr");let i="data:text/csv;charset=utf-8,";e.forEach(r=>{const a=[];r.querySelectorAll("th, td").forEach(o=>{var c;const l=o.getAttribute("colspan");if(l)for(let d=0;d<parseInt(l)-1;d++)a.push("");a.push('"'+((c=o.textContent)==null?void 0:c.trim().replace(/"/g,'""'))+'"')}),i+=a.join(",")+`
|
|
153
|
+
`});const s=encodeURI(i),n=document.createElement("a");n.setAttribute("href",s),n.setAttribute("download",`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}_columnChange(t,e){const i=t.target.checked;e.hidden=!i,this._saveColumnVisibility();const s=`edit-columns-popover-${this._tableId}`,n=this.querySelector(`#${s}`),r=n==null?void 0:n.hasAttribute("open");this.render(),r&&n&&requestAnimationFrame(()=>{const a=this.querySelector(`#${s}`);a&&typeof a.open=="function"&&a.open()})}_getStyle(t){let e="";return(t.nowrap||t.actions)&&(e+="white-space: nowrap;"),t.offsetLeft&&(e+=`left: ${t.offsetLeft} !important;`),t.offsetRight&&(e+=`right: ${t.offsetRight} !important;`),t.width&&(e+=`min-width: ${t.width}px; max-width: ${t.width}px;`),e}_getClasses(t,e=!1){const i=[];return t.class&&i.push(t.class.trim()),t.sortable&&!e&&i.push("cursor-pointer"),t.stickLeft&&i.push("sticky-left"),t.stickRight&&i.push("sticky-right"),i.join(" ")}render(){if(!this._configuration){this.innerHTML='<div class="p-4 text-red-500">Error: Invalid configuration</div>';return}const t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,e=this._getRows(),i=this._lastPage||Math.ceil(this._rows.length/this._perPage);let s="";if(t){if(s+='<div class="flex '+(this._inMintCard?"p-3.5":"mb-3")+'">',s+='<div class="flex-grow-1 flex-1">',s+='<div class="flex gap-2 items-center">',this._configuration.showSearch!==!1){const r=`search-${this._tableId}`;s+=`<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}if(this._configuration.buttons&&this._configuration.buttons.forEach(r=>{const a=r.icon?` icon="${this._escapeHtml(r.icon)}"`:"",o=r.tone?` tone="${this._escapeHtml(r.tone)}"`:"";s+=`<mint-button variant="solid" class="${r.class||""}" data-button-type="${r.type||"custom"}"${a}${o}>`,r.label&&(s+=this._escapeHtml(r.label)),s+="</mint-button>"}),s+="</div>",s+="</div>",this._configuration.editColumns!==!1&&this._configuration.columns.some(a=>!a.actions&&a.editable!==!1)){const a=`edit-columns-popover-${this._tableId}`,o=`edit-columns-button-${this._tableId}`;s+='<div class="ml-2">',s+=`<mint-button id="${o}" variant="solid" icon="edit"></mint-button>`,s+=`<mint-popover id="${a}" trigger-id="${o}" direction="down">`,this._configuration.columns.forEach(l=>{!l.actions&&l.editable!==!1&&(s+='<div class="p-2">',s+=`<mint-checkbox label="${l.label}" ${l.hidden?"":"checked"} data-column-key="${this._configuration.columns.indexOf(l)}"></mint-checkbox>`,s+="</div>")}),s+="</mint-popover>",s+="</div>"}s+="</div>"}if(this._type==="ajax"&&(!this._loaded||this._fetching||this._loading)&&!this._fetchError&&!this._sorting){s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{r.hidden||(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1&&(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable&&(s+='<div class="ml-2 flex items-center">',s+='<mint-icon name="" class="w-4 h-4 text-gray-400"></mint-icon>',s+="</div>"),s+="</div>"),s+="</th>")}),s+="</tr></thead>",s+="<tbody>";for(let r=0;r<4;r++)s+="<tr>",this._configuration.columns.forEach(a=>{a.hidden||(s+=`<td style="${this._getStyle(a)}" class="${this._getClasses(a,!0)}">`,s+='<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>',s+="</td>")}),s+="</tr>";if(s+="</tbody>",s+="</table>",s+="</mint-table>",this._configuration.perPage&&!this._configuration.loadMore&&(i>1||this._lastPage>0)){const r=this._lastPage>0?this._lastPage:i;if(r>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let a=1;a<=Math.min(2,r);a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}if(r>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<r-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),r>2)for(let a=Math.max(r-1,this._currentPage+2);a<=r;a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=r?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}}}else if(e.length>0||this._search.length>0||this._searching||this._fetchError){if(s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{if(!r.hidden){if(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1){if(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable){s+='<div class="ml-2 flex items-center">';const o=this._getSortClass(r);o==="spinner"?s+='<mint-spinner class="w-4 h-4"></mint-spinner>':s+=`<mint-icon name="${o}" class="w-4 h-4 ${o==="sort-arrows"?"text-gray-400":""}"></mint-icon>`,s+="</div>"}s+="</div>"}s+="</th>"}}),s+="</tr></thead>",s+="<tbody>",!this._fetching&&!this._loading&&e.forEach((r,a)=>{const o=typeof this._configuration.onRowClick=="function",l=o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";s+=`<tr data-row-index="${a}" ${o?'data-row-clickable="true"':""}${l?` class="${l}"`:""}>`,this._configuration.columns.forEach((c,d)=>{if(c.hidden)return;const p=!c.show||c.show(this,r);if(s+=`<td style="${this._getStyle(c)}" class="${this._getClasses(c,!0)}">`,p)if(c.raw)if(c.action){if(!c.action.show||c.action.show(this,r)){const h=typeof c.action.label=="function"?c.action.label(this,r):c.action.label;s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(h))}</mint-button>`}}else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${u}" direction="down">`,c.actions.forEach((f,m)=>{if(!f.show||f.show(this,r)){const _=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,u)=>{if(!h.show||h.show(this,r)){const f=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",m=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${_}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=c.format(this,r):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));else if(c.action)(!c.action.show||c.action.show(this,r))&&(s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);else if(c.actions)if(c.actionStyle!=="buttons"){const h=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${h}" trigger-id="${u}" direction="down">`,c.actions.forEach((f,m)=>{if(!f.show||f.show(this,r)){const _=typeof f.label=="function"?f.label(this,r):f.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${m}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(_))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((h,u)=>{if(!h.show||h.show(this,r)){const f=h.label?typeof h.label=="function"?h.label(this,r):h.label:"",m=h.icon?` icon="${this._escapeHtml(h.icon)}"`:"",_=h.tone?` tone="${this._escapeHtml(h.tone)}"`:"";s+=`<mint-button variant="link" class="${h.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${m}${_}>`,f&&(s+=this._escapeHtml(String(f))),s+="</mint-button>"}});else typeof c.format=="function"?s+=this._escapeHtml(c.format(this,r)):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));s+="</td>"}),s+="</tr>"}),!this._fetching&&!this._loading&&e.length===0&&(this._fetchError?s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8">No records found.</td></tr>`),s+="</tbody>",s+="</table>",this._configuration.loadMore&&(this._loading||this._fetching?(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<mint-spinner></mint-spinner>",s+="</div>"):(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)&&(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+='<mint-button variant="ghost" data-action="load-more">Load more</mint-button>',s+="</div>")),this._configuration.perPage&&!this._configuration.loadMore&&this._loaded&&i>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let r=1;r<=Math.min(2,i);r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}if(i>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<i-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),i>2)for(let r=Math.max(i-1,this._currentPage+2);r<=i;r++){const o=this._currentPage===r?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${o} data-action="page" data-page="${r}">${r}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=i?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}s+="</mint-table>"}else s+='<slot name="empty"></slot>';this.innerHTML=s,this.querySelectorAll("mint-button[data-action]").forEach(r=>{r.render&&r.render()}),this.querySelectorAll("mint-button[data-button-type]").forEach(r=>{r.render&&r.render()}),this._attachEventListeners(),this._type==="ajax"&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener("click",this._rowClickHandler,!0);const t=e=>{var l;const i=e.target;if(i.tagName==="MINT-BUTTON"||i.tagName==="BUTTON"||i.closest("mint-button")||i.closest("button")||i.closest("mint-popover")||i.closest("[data-action]"))return;const s=i.closest('tr[data-row-clickable="true"]');if(!s)return;const n=s.getAttribute("data-row-index");if(!n)return;const r=parseInt(n),o=this._getRows()[r];!o||!((l=this._configuration)!=null&&l.onRowClick)||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(o):this._configuration.onRowClick(this,o))};this.addEventListener("click",t,!0),this._rowClickHandler=t}_attachPaginationListeners(){this.querySelectorAll('[data-action="page"]').forEach(t=>{t.addEventListener("click",()=>{const e=parseInt(t.getAttribute("data-page")||"1");this._goToPage(e)})}),this.querySelectorAll('[data-action="page-prev"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll('[data-action="page-next"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll('[data-action="row-action"]').forEach(t=>{t.addEventListener("click",()=>{var o;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-action-index")||"0"),s=parseInt(t.getAttribute("data-column-key")||"0"),r=this._getRows()[e],a=(o=this._configuration)==null?void 0:o.columns[s];a&&a.actions&&a.actions[i]&&a.actions[i].onClick(this,r)})}),this.querySelectorAll('[data-action="column-action"]').forEach(t=>{t.addEventListener("click",()=>{var a;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-column-key")||"0"),n=this._getRows()[e],r=(a=this._configuration)==null?void 0:a.columns[i];r&&r.action&&r.action.onClick(this,n)})})}_attachEventListeners(){var e;const t=this.querySelector(`#search-${this._tableId}`);if(t){const i=t.querySelector("input")||t._element;i?i.addEventListener("input",s=>{this._search=s.target.value,this._triggerSearch()}):t.addEventListener("input",s=>{this._search=t.value||s.target.value||"",this._triggerSearch()})}if(this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll("th[data-column-key]").forEach(i=>{i.addEventListener("click",()=>{var r;const s=parseInt(i.getAttribute("data-column-key")||"0"),n=(r=this._configuration)==null?void 0:r.columns[s];n&&this._toggleSort(n)})}),this.querySelectorAll("[data-button-type]").forEach(i=>{i.addEventListener("click",()=>{var r,a;const s=i.getAttribute("data-button-type"),n=(a=(r=this._configuration)==null?void 0:r.buttons)==null?void 0:a.find(o=>(o.type||"custom")===s);n&&this._handleButtonClick(n)})}),this.querySelectorAll("mint-checkbox[data-column-key]").forEach(i=>{i.addEventListener("change",s=>{var a;s.stopPropagation();const n=parseInt(i.getAttribute("data-column-key")||"0"),r=(a=this._configuration)==null?void 0:a.columns[n];r&&this._columnChange(s,r)}),i.addEventListener("click",s=>{s.stopPropagation()})}),this._attachPaginationListeners(),this.querySelectorAll('[data-action="load-more"]').forEach(i=>{i.addEventListener("click",()=>{this._loadMore()})}),(e=this._configuration)!=null&&e.loadMore){this._scrollHandler&&window.removeEventListener("scroll",this._scrollHandler);const i=()=>{const s=window.pageYOffset||document.documentElement.scrollTop,n=window.innerHeight;if(document.documentElement.scrollHeight-s-n<=100){const a=this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows;!this._loading&&!this._fetching&&a&&this._loadMore()}};this._scrollHandler=i,window.addEventListener("scroll",i)}}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}}customElements.get("mint-resource-table")||customElements.define("mint-resource-table",bt);class vt extends HTMLElement{constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open","position","full-page"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}getPosition(){var e;const t=(e=this.getAttribute("position"))==null?void 0:e.toLowerCase();return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"right"}isFullPage(){return this.hasAttribute("full-page")}isOpen(){return this.hasAttribute("open")}open(){this.setAttribute("open","")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen(),s=this.getPosition(),n=this.isFullPage();t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._offCanvas||(this._offCanvas=document.createElement("div"),this.appendChild(this._offCanvas));const r=this._getPositionClasses(s,n);this._offCanvas.className=r;let a=this._offCanvas.querySelector(".off-canvas-content");a||(a=document.createElement("div"),a.className="off-canvas-content bg-white dark:bg-gray-800 shadow-xl flex flex-col pointer-events-auto transition-all duration-300 ease-out",a.style.transform=this._getTransformValue(s,!1),this._offCanvas.appendChild(a)),i?this._animateEnter():this._animateExit(),a.classList.remove("w-full","h-full","max-w-sm","max-w-md","max-w-lg","max-w-xl","max-h-[90vh]","max-h-screen"),n?a.classList.add("w-full","h-full"):s==="top"||s==="bottom"?a.classList.add("w-full","max-h-[90vh]"):a.classList.add("max-w-sm","h-full"),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",a.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let o=this._headingSlot.querySelector("mint-text");e?(o||(o=document.createElement("mint-text"),o.setAttribute("size","sub-heading"),o.setAttribute("bold",""),this._headingSlot.appendChild(o)),o.textContent=e):o&&o.remove(),Array.from(this.children).filter(u=>u!==this._overlay&&u!==this._offCanvas&&u!==this._headingSlot&&u.getAttribute("slot")==="heading").forEach(u=>{this._headingSlot&&u.parentElement!==this._headingSlot&&this._headingSlot.appendChild(u)}),this._closeButton||(this._closeButton=document.createElement("mint-button"),this._closeButton.setAttribute("variant","ghost"),this._closeButton.setAttribute("icon","close"),this._closeButton.addEventListener("click",()=>this.close()),this._header.appendChild(this._closeButton)),this._bodySlot||(this._bodySlot=document.createElement("div"),this._bodySlot.className="flex-1 overflow-y-auto p-4",this._bodySlot.setAttribute("slot","body"),a.appendChild(this._bodySlot)),Array.from(this.children).filter(u=>u!==this._overlay&&u!==this._offCanvas&&u!==this._bodySlot&&u.getAttribute("slot")==="body").forEach(u=>{this._bodySlot&&u.parentElement!==this._bodySlot&&this._bodySlot.appendChild(u)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",this._actionsSlot.setAttribute("slot","actions"),a.appendChild(this._actionsSlot));let d=this._actionsSlot.querySelector("mint-stack");d||(d=document.createElement("mint-stack"),d.setAttribute("direction","horizontal"),d.className="justify-end",this._actionsSlot.appendChild(d)),Array.from(this.children).filter(u=>u!==this._overlay&&u!==this._offCanvas&&u!==this._actionsSlot&&u.getAttribute("slot")==="actions").forEach(u=>{Array.from(u.children).forEach(m=>{m.parentElement!==d&&d.appendChild(m)}),u.parentElement&&u.remove()}),Array.from(this.children).forEach(u=>{u!==this._overlay&&u!==this._offCanvas&&u.getAttribute("slot")!=="heading"&&u.getAttribute("slot")!=="body"&&u.getAttribute("slot")!=="actions"&&u!==this._headingSlot&&u!==this._bodySlot&&u!==this._actionsSlot&&u.parentElement!==this._bodySlot&&this._bodySlot.appendChild(u)}),this._updateBackgroundColor()}_getPositionClasses(t,e){const i="fixed z-50 pointer-events-none transition-all duration-300 ease-out";switch(t){case"top":return`${i} top-0 left-0 right-0 ${e?"h-full":""}`;case"bottom":return`${i} bottom-0 left-0 right-0 ${e?"h-full":""}`;case"left":return`${i} left-0 top-0 bottom-0 ${e?"w-full":""}`;case"right":return`${i} right-0 top-0 bottom-0 ${e?"w-full":""}`;default:return`${i} right-0 top-0 bottom-0 ${e?"w-full":""}`}}_getTransformValue(t,e){if(e)switch(t){case"top":return"translateY(0)";case"bottom":return"translateY(0)";case"left":return"translateX(0)";case"right":return"translateX(0)";default:return"translateX(0)"}else switch(t){case"top":return"translateY(-100%)";case"bottom":return"translateY(100%)";case"left":return"translateX(-100%)";case"right":return"translateX(100%)";default:return"translateX(100%)"}}_updateBackgroundColor(){if(!this._offCanvas)return;const t=document.documentElement.classList.contains("dark"),e=this._offCanvas.querySelector(".off-canvas-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-800")):(e.classList.remove("bg-gray-800"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var i;const t=(i=this._offCanvas)==null?void 0:i.querySelector(".off-canvas-content");if(!t)return;const e=this.getPosition();t.style.transform=this._getTransformValue(e,!1),t.style.transition="transform 300ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=this._getTransformValue(e,!0)})})}_animateExit(){var i;const t=(i=this._offCanvas)==null?void 0:i.querySelector(".off-canvas-content");if(!t){this.classList.add("hidden");return}const e=this.getPosition();t.style.transition="transform 300ms ease-in",t.style.transform=this._getTransformValue(e,!1),setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.transition=""},300)}}customElements.get("mint-off-canvas")||customElements.define("mint-off-canvas",vt);exports.Alert=_t;exports.BackButton=et;exports.Button=j;exports.Card=Q;exports.Checkbox=at;exports.Chip=ft;exports.Choice=ot;exports.Clickable=gt;exports.DatePicker=ct;exports.Dropzone=dt;exports.Form=ut;exports.Grid=st;exports.Icon=J;exports.Input=lt;exports.Link=tt;exports.Modal=rt;exports.OffCanvas=vt;exports.Page=it;exports.Popover=nt;exports.ResourceTable=bt;exports.Select=ht;exports.Spinner=G;exports.Stack=Z;exports.Switch=X;exports.Table=pt;exports.Tags=mt;exports.Text=K;exports.default=j;
|