monobill-mintui 0.2.93 → 0.2.95

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAA;AACzB,OAAO,eAAe,CAAA;AAEtB,KAAK,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AAC/C,KAAK,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;AACtE,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AACrC,KAAK,YAAY,GAAG,MAAM,GAAG,OAAO,CAAA;AAMpC,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,gBAAgB,CAAiB;;IAOzC,iBAAiB,IAAI,IAAI;IAczB,oBAAoB,IAAI,IAAI;IAI5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM9F,UAAU,IAAI,aAAa;IAI3B,OAAO,IAAI,UAAU;IAIrB,UAAU,IAAI,OAAO;IAWrB,SAAS,IAAI,OAAO;IAWpB,OAAO,IAAI,UAAU;IAgBrB,WAAW,IAAI,OAAO;IAItB,eAAe,IAAI,YAAY;IAI/B,OAAO,IAAI,MAAM;IAIjB,UAAU,IAAI,OAAO;IAiCrB,gBAAgB,IAAI,MAAM;IA4U1B,MAAM,IAAI,IAAI;IAuOd,mBAAmB,IAAI,IAAI;IAmB3B,oBAAoB,IAAI,IAAI;IAgB5B,OAAO,CAAC,gBAAgB,CAIvB;IAED,OAAO,CAAC,cAAc,CAIrB;IAED,OAAO,CAAC,iBAAiB,CAIxB;IAED,OAAO,CAAC,iBAAiB,CAIxB;IAED,OAAO,CAAC,eAAe,CAItB;IAED,OAAO,CAAC,kBAAkB,CAIzB;IAED,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CA2DhC;AAOD,eAAe,UAAU,CAAA"}
1
+ {"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.ts"],"names":[],"mappings":"AAEA,OAAO,kBAAkB,CAAA;AACzB,OAAO,eAAe,CAAA;AAEtB,KAAK,aAAa,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,CAAA;AAC/C,KAAK,UAAU,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAA;AACtE,KAAK,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAA;AACrC,KAAK,YAAY,GAAG,MAAM,GAAG,OAAO,CAAA;AAMpC,cAAM,UAAW,SAAQ,WAAW;IAClC,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;IAED,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,gBAAgB,CAAiB;;IAOzC,iBAAiB,IAAI,IAAI;IAczB,oBAAoB,IAAI,IAAI;IAI5B,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAM9F,UAAU,IAAI,aAAa;IAI3B,OAAO,IAAI,UAAU;IAIrB,UAAU,IAAI,OAAO;IAMrB,SAAS,IAAI,OAAO;IAMpB,OAAO,IAAI,UAAU;IAgBrB,WAAW,IAAI,OAAO;IAItB,eAAe,IAAI,YAAY;IAI/B,OAAO,IAAI,MAAM;IAIjB,UAAU,IAAI,OAAO;IAiCrB,gBAAgB,IAAI,MAAM;IA4U1B,MAAM,IAAI,IAAI;IAuOd,mBAAmB,IAAI,IAAI;IAmB3B,oBAAoB,IAAI,IAAI;IAgB5B,OAAO,CAAC,gBAAgB,CAIvB;IAED,OAAO,CAAC,cAAc,CAIrB;IAED,OAAO,CAAC,iBAAiB,CAIxB;IAED,OAAO,CAAC,iBAAiB,CAIxB;IAED,OAAO,CAAC,eAAe,CAItB;IAED,OAAO,CAAC,kBAAkB,CAIzB;IAED,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;CA2DhC;AAOD,eAAe,UAAU,CAAA"}
package/dist/index.cjs CHANGED
@@ -41,7 +41,7 @@
41
41
  ></animate>
42
42
  </circle>
43
43
  </svg>
44
- `;this.innerHTML=o.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",P);class q extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["name"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","inline-flex","items-center","leading-none"),this.render(),this._observeDarkMode()}attributeChangedCallback(e,t,i){t!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}getIconUrl(){var t;const e=(t=document.querySelector('meta[name="mint-icon-base-url"]'))==null?void 0:t.getAttribute("content");return e?e==="local"?`/icons/${this.getName()}.svg`:e==="cdn"?`https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`:`${e.endsWith("/")?e:`${e}/`}${this.getName()}.svg`:`https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`}render(){var l,o,d;const e=this.getName();if(!e){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}if(!le.getIcon(e)){console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}const i=this.closest("mint-button")||((l=this.parentElement)==null?void 0:l.closest("mint-button")),s=this.closest("mint-switch")||((o=this.parentElement)==null?void 0:o.closest("mint-switch")),r=this.closest("mint-select")||((d=this.parentElement)==null?void 0:d.closest("mint-select"));if(!Array.from(this.classList).some(c=>c.startsWith("w-")||c.startsWith("h-"))&&!r){let c;s?c="w-3 h-3":i?c="w-5 h-5":c="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"),c.split(" ").forEach(m=>{m&&this.classList.add(m)})}const a=this.getIconUrl();if(this.style.maskImage=`url(${a})`,this.style.webkitMaskImage=`url(${a})`,this.style.maskSize="contain",this.style.webkitMaskSize="contain",this.style.maskRepeat="no-repeat",this.style.webkitMaskRepeat="no-repeat",this.style.maskPosition="center",this.style.webkitMaskPosition="center",this.style.aspectRatio="1 / 1",this.style.backgroundColor="currentColor",this.innerHTML="",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 m=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(m)}}}customElements.get("mint-icon")||customElements.define("mint-icon",q);class F 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._button.classList.remove("mint-button-active")},this._handleMouseLeave=()=>{this._button&&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._button.classList.remove("mint-button-active")},this._handleTouchCancel=()=>{this._button&&this._button.classList.remove("mint-button-active")}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon"]}connectedCallback(){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(e,t,i){t!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){const e=this.getAttribute("disabled");return e===null?!1:e!=="false"}isLoading(){const e=this.getAttribute("loading");return e===null?!1:e!=="false"}getType(){const e=this.getAttribute("type"),t=this.getAttribute("button-type");return(e||t||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,r,n,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const t=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(t&&((r=t.textContent)!=null&&r.trim()))return!1;if(this._button)for(let l=this._button.firstChild;l;l=l.nextSibling){if(l.nodeType===Node.TEXT_NODE&&((n=l.textContent)!=null&&n.trim()))return!1;if(l.nodeType===Node.ELEMENT_NODE){const o=l;if(o.tagName!=="MINT-ICON"&&o.tagName!=="MINT-SPINNER"&&!o.querySelector("mint-spinner")&&!o.hasAttribute("slot")&&o.className!=="mint-button-icon"&&!(o.className==="mr-2"&&o.querySelector("mint-spinner"))&&(a=o.textContent)!=null&&a.trim())return!1}}return!0}getButtonClasses(){const e=this.isIconOnly(),t=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...e?["p-1.5","aspect-square","w-[2rem]","h-[2rem]"]:["px-3.5","py-1.5","min-h-[2rem]"],"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(),r={"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"]},n=`${t}-${s}`,a=r[n]||r["solid-neutral"],l=[...i,...a];return this.isFullWidth()&&l.push("w-full"),l.join(" ")}render(){var d,c,m,h,f;const e=this.isDisabled()||this.isLoading(),t=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=t,this._button.disabled=e;let i=this._button.querySelector("mint-spinner");if(this.isLoading())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 u=document.createElement("span");u.className="mr-2 inline-flex items-center";const p=document.createElement("mint-spinner");p.setAttribute("size","default"),p.setAttribute("data-button-variant",this.getVariant()),p.setAttribute("data-button-tone",this.getTone()),p.style.width="0.875rem",p.style.height="0.875rem",u.appendChild(p),this._button.insertBefore(u,this._button.firstChild)}else i&&((d=i.parentElement)==null||d.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",s),r.className="mint-button-icon"):r.setAttribute("name",s)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const n=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const u=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const p=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;u||n==="left"?p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a):a.insertAdjacentElement("afterend",r)}else if(r&&(u||n==="left")&&r.nextSibling!==a){r.remove();const p=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a)}else r&&!u&&n==="right"&&r.previousSibling!==a&&(r.remove(),a.insertAdjacentElement("afterend",r))}else{const u=[];for(let p=this._button.firstChild;p;p=p.nextSibling){if(p.nodeType!==Node.ELEMENT_NODE){u.push(p);continue}const _=p;_.tagName!=="MINT-SPINNER"&&!_.querySelector("mint-spinner")&&p!==r&&!_.hasAttribute("slot")&&!(_.className==="mr-2"&&_.querySelector("mint-spinner"))&&u.push(p)}if(u.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",u.forEach(_=>{a.appendChild(_)});const p=(c=this._button.querySelector("mint-spinner"))==null?void 0:c.parentElement;r&&n==="left"?p?(p.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",a)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",a)):r&&n==="right"?p?(p.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",r)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",r)):p?p.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const p=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),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")):n==="left"?r.classList.add("mr-1.5"):r.classList.add("ml-1.5"));const o=this.getButtonClasses();this._button.className=o}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(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0}));return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",F);class B 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 e=this.querySelector(".mint-switch-container");return e||(e=document.createElement("div"),e.className="mint-switch-container flex items-center gap-2",this.insertBefore(e,this.firstChild)),e}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(e==="checked"&&(this._checked=i!==null),t!==i){if(e==="error"||e==="error-message"){this._renderErrorState();return}if(e==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this.render()}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 e=this.hasError(),t=["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",e?"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",e?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",e?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...t,...i].join(" ")}getThumbClasses(){const e=["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"],t=this._checked?"translate-x-5":"translate-x-0.5";return[...e,t].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const e=this.isLoading(),t=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),r=this.getInfo(),n=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const l=this._getSwitchContainer();this._button?this._button.parentElement!==l&&l.appendChild(this._button):(this._button=document.createElement("button"),l.appendChild(this._button),this.setupEventListeners());let o=l.querySelector(".mint-switch-label");s?(o||(o=document.createElement("label"),o.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===l?l.insertBefore(o,this._button.nextSibling):l.appendChild(o)),o.textContent=s,o.setAttribute("for",a),this.isDisabled()?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove(),this._button.className=t,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 d=this._button.querySelector("span");d||(d=document.createElement("span"),this._button.appendChild(d)),d.className=i;const c=d.querySelector("span");if(n){let h=c;h||(h=document.createElement("span"),h.className=this.getIconClasses(),d.appendChild(h));let f=h.querySelector("mint-icon");f||(f=document.createElement("mint-icon"),h.appendChild(f)),f.setAttribute("name",n)}else c&&c.remove();let m=this.querySelector(".mint-switch-info");r?(m||(m=document.createElement("span"),m.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",l&&l.parentElement===this?this.insertBefore(m,l.nextSibling):this.appendChild(m)),m.textContent=r,this.isDisabled()?m.classList.add("opacity-40"):m.classList.remove("opacity-40")):m&&m.remove(),this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(e){this.isDisabled()||(this.checked=!this._checked,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(e){const t=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let r=t.querySelector(".mint-switch-skeleton-container"),n=this.querySelector(".mint-switch-info-skeleton");if(e){t.classList.contains("relative")||t.classList.add("relative"),r||(r=document.createElement("div"),r.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",t.appendChild(r));let a=r.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",r.appendChild(a)),i){let o=r.querySelector(".mint-switch-skeleton-label");o||(o=document.createElement("div"),o.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",r.appendChild(o))}else{const o=r.querySelector(".mint-switch-skeleton-label");o&&o.remove()}r.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const l=t.querySelector(".mint-switch-label");if(l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),s){n||(n=document.createElement("div"),n.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",t&&t.parentElement===this?this.insertBefore(n,t.nextSibling):this.appendChild(n)),n.style.display="block";const o=this.querySelector(".mint-switch-info");o&&(o.style.display="none")}else n&&(n.style.display="none")}else{r&&(r.style.display="none"),n&&(n.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=t.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const l=this.querySelector(".mint-switch-info");l&&(l.style.display="")}}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");e&&t?(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=t):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",B);class O 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(t=>this._userClasses.add(t))}attributeChangedCallback(e,t,i){t!==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 e=this.getSize(),t=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},r={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"]},n=[];this.isBold()&&n.push("font-bold"),this.isUnderline()&&n.push("underline"),this.isStrike()&&n.push("line-through"),this.isItalic()&&n.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[e]||s.regular,...r[t]||r.default,...n].join(" ")}render(){const e=this.getSize(),t=["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(o=>{this.classList.remove(o),this._userClasses.delete(o)}),t.forEach(o=>{this.classList.remove(o),this._userClasses.delete(o)});const s=this.getTextClasses().split(" ").filter(o=>o.trim());Array.from(this.classList).forEach(o=>{!t.includes(o)&&!i.includes(o)&&this._userClasses.add(o)});const n=[...new Set([...s,...Array.from(this._userClasses)])];this.className=n.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)"},l=a[e]||a.regular;this.style.setProperty("font-size",l)}}customElements.get("mint-text")||customElements.define("mint-text",O);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(e,t,i){t!==i&&(this.render(),e==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),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 e=this.getAttribute("gap")||"3";return parseFloat(e)}getTextAlign(){const e=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(e)?e:""}getStackClasses(){const e=this.getDirection(),t=this.getTextAlign(),i=this.getGap(),s=["flex",e==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return t&&(s.push(`text-${t}`),s.push(`[&>*]:text-${t}`),s.push(`[&>*_.mint-button-content]:text-${t}`),t==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):t==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):t==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const e=this.getStackClasses(),t=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(r=>this.classList.remove(r)),e.split(" ").forEach(r=>{r&&this.classList.add(r)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(r=>{this.classList.contains(r)||this.classList.add(r)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){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"),e==="left"?s.classList.add("justify-start"):e==="right"?s.classList.add("justify-end"):e==="center"&&s.classList.add("justify-center");const r=s.querySelector(".mint-button-content");r&&(r.classList.remove("text-left","text-center","text-right","text-justify"),r.classList.add(`text-${e}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(t=>{if(t.tagName==="MINT-BUTTON"){const i=t.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 t.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",z);class W extends HTMLElement{constructor(){super(),this._headingElement=null,this._contentWrapper=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}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");let e=Array.from(this.children).find(i=>i.classList.contains("p-6")&&i===this._contentWrapper);(!this._contentWrapper||!e)&&(this._contentWrapper=document.createElement("div"),this._contentWrapper.className="p-6",Array.from(this.children).filter(s=>s!==this._contentWrapper).forEach(s=>{this._contentWrapper.appendChild(s)}),this.appendChild(this._contentWrapper));const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this._contentWrapper&&this._contentWrapper.insertBefore(this._headingElement,this._contentWrapper.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",W);class V 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(t=>{t.classList.contains("underline")||t.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var e;return!!(this.querySelector("mint-icon")||(e=this._link)!=null&&e.querySelector("mint-icon"))}render(){const e=this.getHref(),t=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=e,t?(this._link.target=t,t==="_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",V);class R 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(e,t,i){t!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const e=document.referrer,t=window.location.origin;if(e)try{const i=new URL(e);if(i.origin===t)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(e){e.preventDefault(),e.stopPropagation();const t=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),r=new CustomEvent("back",{detail:{url:t,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(r)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",e=>this.handleClick(e)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",R);class j 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(e,t,i){t!==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 e=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 t=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){t||(t=document.createElement("mint-back-button"),this._titleElement.insertBefore(t,this._titleElement.firstChild));const n=this.getFallbackHref();t.setAttribute("fallback-href",n),this._backButton=t}else t&&(t.remove(),t=null,this._backButton=null);e?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.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"),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):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(n=>n!==this._pageContainer&&n!==this._actionsSlot&&n.getAttribute("slot")==="actions").forEach(n=>{this._actionsSlot&&n.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(n)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(n=>{n!==this._pageContainer&&n.getAttribute("slot")!=="actions"&&n!==this._actionsSlot&&n!==this._header&&n!==this._bodySlot&&n!==this._headingText&&n.parentElement!==this._bodySlot&&n.parentElement!==this._pageContainer&&this._bodySlot.appendChild(n)}),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=e=>{const t=e.target;if(t&&t.tagName==="MINT-BACK-BUTTON"){e.stopPropagation();const i=new CustomEvent("back",{detail:e.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",j);class $ 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(e,t,i){t!==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 e=["grid"],t=this.getColumns();e.push(`grid-cols-${t}`);const i=this.getSm();i&&e.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&e.push(`md:grid-cols-${s}`);const r=this.getLg();r&&e.push(`lg:grid-cols-${r}`);const n=this.getXl();n&&e.push(`xl:grid-cols-${n}`);const a=this.getGap();return e.push(`gap-${a}`),e}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",$);class Y 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(e,t,i){t!==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 e=this.getId(),t=this.getHeading(),i=this.isOpen();if(e&&(this.id=e),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 c=this._modal.querySelector(".modal-content");c||(c=document.createElement("div"),c.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(c)),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 r=this._headingSlot.querySelector("mint-text");t?(r||(r=document.createElement("mint-text"),r.setAttribute("size","sub-heading"),r.setAttribute("bold",""),this._headingSlot.appendChild(r)),r.textContent=t):r&&r.remove(),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._headingSlot&&c.getAttribute("slot")==="heading").forEach(c=>{this._headingSlot&&c.parentElement!==this._headingSlot&&this._headingSlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._bodySlot&&c.getAttribute("slot")==="body").forEach(c=>{this._bodySlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),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 l=this._actionsSlot.querySelector("mint-stack");l||(l=document.createElement("mint-stack"),l.setAttribute("direction","horizontal"),l.className="justify-end",this._actionsSlot.appendChild(l)),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._actionsSlot&&c.getAttribute("slot")==="actions").forEach(c=>{Array.from(c.children).forEach(h=>{h.parentElement!==l&&l.appendChild(h)}),c.parentElement&&c.remove()}),Array.from(this.children).forEach(c=>{c!==this._overlay&&c!==this._modal&&c.getAttribute("slot")!=="heading"&&c.getAttribute("slot")!=="body"&&c.getAttribute("slot")!=="actions"&&c!==this._headingSlot&&c!==this._bodySlot&&c!==this._actionsSlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const e=document.documentElement.classList.contains("dark"),t=this._modal.querySelector(".modal-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");e&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})}))}_animateExit(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");if(!e){this.classList.add("hidden");return}e.style.transition="all 200ms ease-in",e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),e.style.transform="",e.style.opacity="",e.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",Y);class U 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(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0","z-50","pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){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(e,t,i){t!==i&&(this.render(),(e==="trigger-id"||e==="hover")&&this._setupTrigger(),e==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const e=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"}[e]||"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 e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){e._cancelHoverClose()},this._popoverHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._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 e=this._triggerElement?this._triggerElement.matches(":hover"):!1,t=this._popover?this._popover.matches(":hover"):!1;return e||t}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const e=this._triggerElement.getBoundingClientRect(),t=this._popover.querySelector(".popover-content");if(!t)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=t.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,a=8;let l=this.getDirection(),o=0,d=0;switch(l){case"down":if(o=e.bottom+a,d=e.left+e.width/2-s.width/2,o+s.height>n){const c=e.top-s.height-a;c>=0?(l="up",o=c):(o=Math.max(0,n-s.height-a),o+s.height>n&&(o=0))}d<0&&(d=a),d+s.width>r&&(d=Math.max(a,r-s.width-a),d+s.width>r&&(d=r-s.width));break;case"up":if(o=e.top-s.height-a,d=e.left+e.width/2-s.width/2,o<0){const c=e.bottom+a;c+s.height<=n?(l="down",o=c):(o=Math.min(n-s.height-a,n-s.height),o<0&&(o=n-s.height))}d<0&&(d=a),d+s.width>r&&(d=Math.max(a,r-s.width-a),d+s.width>r&&(d=r-s.width));break;case"right":if(o=e.top+e.height/2-s.height/2,d=e.right+a,d+s.width>r){const c=e.left-s.width-a;c>=0?(l="left",d=c):(d=Math.max(0,r-s.width-a),d+s.width>r&&(d=r-s.width))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break;case"left":if(o=e.top+e.height/2-s.height/2,d=e.left-s.width-a,d<0){const c=e.right+a;c+s.width<=r?(l="right",d=c):(d=Math.min(r-s.width-a,r-s.width),d<0&&(d=0))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break}return{top:o,left:d,direction:l}}render(){const e=this.getId(),t=this.isOpen(),i=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const n=this;this._clickOutsideHandler=function(a){const l=a.composedPath(),o=l.includes(n);if(!(n._triggerElement&&l.includes(n._triggerElement))&&!o){n.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 pointer-events-none z-40",this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement("div"),this._popover.className="fixed z-50 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 n=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"],l=n.filter(o=>!a.includes(o));s.className=[...l,i].join(" ")}Array.from(this.children).forEach(n=>{n!==this._overlay&&n!==this._popover&&n.parentElement===this&&s.appendChild(n)}),t?(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"})}))):!t&&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 e=document.documentElement.classList.contains("dark"),t=this._popover.querySelector(".popover-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;const t=this._popover.style.visibility!=="hidden";t||(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`,t||(this._popover.style.visibility="visible",e&&(!e.style.opacity||e.style.opacity==="")&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},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(t=>{if(t!==this){const i=t;typeof i.close=="function"?i.close():t.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",U);class G 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 e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(e==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),t!==i){if(e==="error"||e==="error-message"){this._renderErrorState();return}if(e==="loading"){this.render();return}this.render(),e==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}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 e=this.hasError(),t=["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",e?"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",e?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",e?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...t,...i].join(" ")}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let r=this.querySelector(".mint-checkbox-container");r||(r=document.createElement("div"),r.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(r,this.firstChild));let n=this.querySelector(".mint-checkbox-wrapper");n?n.parentElement!==r&&r.appendChild(n):(n=document.createElement("div"),n.className="mint-checkbox-wrapper",r.appendChild(n)),this._checkbox?this._checkbox.parentElement!==n&&n.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",n.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 l=this.getName();l?this._checkbox.name=l:this._checkbox.removeAttribute("name");const o=this.getValue();o?this._checkbox.value=o:this._checkbox.removeAttribute("value"),t?this._checkbox.setAttribute("aria-label",t):this._checkbox.removeAttribute("aria-label"),n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,n.style.pointerEvents="none",this._checkbox.style.pointerEvents="auto";let d=n.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",n.appendChild(d)),this.updateVisualState();let c=this.querySelector(".mint-checkbox-label-container");const m=this.querySelector(".mint-checkbox-container");if(t||i){c?m&&c.parentElement!==m&&m.appendChild(c):(c=document.createElement("div"),c.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",m?m.appendChild(c):this.appendChild(c));let h=c.querySelector(".mint-checkbox-label");t?(h||(h=document.createElement("span"),h.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",c.insertBefore(h,c.firstChild)),h.textContent=t,s?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let f=c.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",c.appendChild(f)),f.textContent=i,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove(),s)c.style.cursor="default",c._clickHandler&&(c.removeEventListener("click",c._clickHandler),c._clickHandler=null);else{c.style.cursor="pointer";const u=c._clickHandler;u&&c.removeEventListener("click",u),c._clickHandler=p=>{this._checkbox&&(p.target===this._checkbox||this._checkbox.contains(p.target)||p.composedPath().includes(this._checkbox))||this.toggle()},c.addEventListener("click",c._clickHandler)}}else c&&c.remove();this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&e.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=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.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))}updateVisualState(){const e=this.querySelector(".mint-checkbox-wrapper"),t=e==null?void 0:e.querySelector("mint-icon");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,e.classList.contains("mint-checkbox-active")||(e.style.backgroundColor="",e.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();const e=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}_renderSkeleton(e){let t=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),r=this.querySelector(".mint-checkbox-label-container");if(e){t||(t=document.createElement("div"),t.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(t):(this.style.position="relative",this.appendChild(t)));let n=t.querySelector(".mint-checkbox-skeleton-box");if(n||(n=document.createElement("div"),n.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",t.appendChild(n)),r){let a=t.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",t.appendChild(a))}t.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),r&&(r.style.visibility="hidden",r.style.pointerEvents="none")}else t&&(t.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),r&&(r.style.visibility="visible",r.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&e&&t&&(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");e&&t?(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=t):s&&s.remove();const r=this.querySelector(".mint-checkbox-wrapper");r&&(r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",G);class ce 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 e=this.getAttribute("checked");this._checked=e!==null&&e!=="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(e,t,i){if(e==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),t!==i){if(e==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(e){this._checked=!!e,e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}getValue(){return this.getAttribute("value")||""}isDisabled(){const e=this.closest("mint-choice");return this.hasAttribute("disabled")||((e==null?void 0:e.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=e=>{e.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 t=this.closest("mint-choice");t&&t.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 e=this.isLoading(),t=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),r=(s==null?void 0:s.getAttribute("name"))||"";let n="";const a=this.querySelector(".mint-choice-option-label");a?n=((f=a.textContent)==null?void 0:f.trim())||"":Array.from(this.childNodes).forEach(u=>{var p;if(u.nodeType===Node.TEXT_NODE){const _=(p=u.textContent)==null?void 0:p.trim();_&&(n+=_)}});const l=this.querySelectorAll(".mint-choice-option-wrapper");let o=null;if(l.length>0&&(this._radio&&(o=Array.from(l).find(u=>u.contains(this._radio))),o||(o=l[0]),l.forEach((u,p)=>{u!==o&&u.remove()})),o||(o=document.createElement("div"),o.className="mint-choice-option-wrapper",o.style.position="relative",this.insertBefore(o,this.firstChild)),o.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,o.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(u=>{u!==this._radio&&u.remove()}),this._radio)this._radio.parentElement!==o&&o.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=u=>{const p=this.querySelector(".mint-choice-option-wrapper");p&&!this.isDisabled()&&p.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const u=this.querySelector(".mint-choice-option-wrapper");u&&u.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=u=>{this.isDisabled()||(u.key==="ArrowDown"||u.key==="ArrowRight"?(u.preventDefault(),this._focusNextOption()):(u.key==="ArrowUp"||u.key==="ArrowLeft")&&(u.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",o.appendChild(this._radio),this._changeHandler=p=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const b=this.closest("mint-choice");_!==this._checked&&b&&setTimeout(()=>{b.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const u=()=>{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",u),this._focusHandler=p=>{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 p=this.querySelector(".mint-choice-option-wrapper");p&&p.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),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.addEventListener("keydown",this._keydownHandler)}this._radio.name=r,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=t,t?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),n?this._radio.setAttribute("aria-label",n):this._radio.removeAttribute("aria-label"),o.querySelectorAll(".mint-choice-option-indicator").forEach((u,p)=>{p>0&&u.remove()});let m=o.querySelector(".mint-choice-option-indicator");m||(m=document.createElement("div"),m.className="mint-choice-option-indicator",o.appendChild(m)),m.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",m.style.position="absolute",m.style.top="50%",m.style.left="50%",m.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",m.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(e);let h=this.querySelector(".mint-choice-option-label");n&&(h||(h=document.createElement("span"),h.className="mint-choice-option-label",this.appendChild(h),Array.from(this.childNodes).forEach(u=>{var p;u.nodeType===Node.TEXT_NODE&&((p=u.textContent)!=null&&p.trim())&&(u.textContent="")})),h.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t?"opacity-40":""}`,h.textContent=n),t?(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 e=this.isDisabled(),t=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return e&&t.push("opacity-40","cursor-not-allowed"),this._checked?t.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):t.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),t.join(" ")}_updateVisualState(){const e=this.querySelector(".mint-choice-option-wrapper");e&&(e.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const t=this.querySelector(".mint-choice-option-indicator");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(e){let t=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector('input[type="radio"]'),n=i.querySelector(".mint-choice-option-indicator");r&&(r.style.visibility="hidden"),n&&(n.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(t&&(t.style.display="none"),i){const r=i.querySelector('input[type="radio"]'),n=i.querySelector(".mint-choice-option-indicator");r&&(r.style.visibility="visible"),n&&(n.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 t;if(!((t=this._radio)!=null&&t.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 e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(r=>!r.disabled),t=e.indexOf(this._radio);let i=null;if(t>=0&&t<e.length-1?i=e[t+1]:e.length>0&&(i=e[0]),i){const r=i.closest("mint-choice-option");if(i.checked=!0,r){const n=r._checked;if(r._checked=!0,r.setAttribute("checked",""),r._changeHandler){const l=new Event("change",{bubbles:!0});r._changeHandler.call(r,l)}else r._updateVisualState(),r._updateGroupState();const a=r.closest("mint-choice");a&&!n&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:r.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 e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(r=>!r.disabled),t=e.indexOf(this._radio);let i=null;if(t>0?i=e[t-1]:e.length>0&&(i=e[e.length-1]),i){const r=i.closest("mint-choice-option");if(i.checked=!0,r){const n=r._checked;if(r._checked=!0,r.setAttribute("checked",""),r._changeHandler){const l=new Event("change",{bubbles:!0});r._changeHandler.call(r,l)}else r._updateVisualState(),r._updateGroupState();const a=r.closest("mint-choice");a&&!n&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:r.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",ce);class J 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()}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){t!==i&&(e==="error"||e==="error-message"?this._renderErrorState():e==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(r=>{this.isLoading()?r.setAttribute("loading",""):r.removeAttribute("loading")})):(this.render(),e==="name"&&this.querySelectorAll("mint-choice-option").forEach(r=>{typeof r.render=="function"&&r.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 e=this.querySelector('input[type="radio"]:checked');return(e==null?void 0:e.value)||""}setValue(e){const t=this.querySelectorAll("mint-choice-option");t.forEach(i=>{if((i.getAttribute("value")||"")===e){const r=i;r.checked=!0;const n=i.querySelector('input[type="radio"]');n&&(n.checked=!0,n.dispatchEvent(new Event("change",{bubbles:!0})))}else{const r=i;r.checked=!1;const n=i.querySelector('input[type="radio"]');n&&(n.checked=!1)}}),requestAnimationFrame(()=>{t.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const r=i;s.checked!==r.checked&&(s.checked=r.checked)}})})}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const r=this.isDisabled();let n=this.querySelector(".mint-choice-label-container");if(t||i){n||(n=document.createElement("div"),n.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(n,this.firstChild));let o=n.querySelector(".mint-choice-label");t?(o||(o=document.createElement("label"),o.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",n.insertBefore(o,n.firstChild)),o.textContent=t,o.setAttribute("for",s),r?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove();let d=n.querySelector(".mint-choice-info");i?(d||(d=document.createElement("span"),d.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",n.appendChild(d)),d.textContent=i,r?d.classList.add("opacity-40"):d.classList.remove("opacity-40")):d&&d.remove()}else n&&n.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const o=this.querySelector(".mint-choice-label-container");o&&o.parentElement===this?this.insertBefore(a,o.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(o=>o.tagName==="MINT-CHOICE-OPTION"&&o.parentElement!==this._optionsContainer).forEach(o=>{this._optionsContainer.appendChild(o)}),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(e){if(t||(t=document.createElement("div"),t.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(t):(this.style.position="relative",this.appendChild(t))),t.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let n=0;n<3;n++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const l=document.createElement("div");l.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l);const o=document.createElement("div");o.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o),t.appendChild(a)}t.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else t&&(t.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",J);class X 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.getLabel()||console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(e==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const e=this.getAttribute("rows");return e?parseInt(e,10):3}_getNormalizedType(){const e=this.getType();return e==="datetime"?"datetime-local":e==="money"?"text":e==="textarea"?"textarea":e}_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 e,t,i;return this._isColor()?((e=this._colorPicker)==null?void 0:e.value)||((t=this._colorTextInput)==null?void 0:t.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(e){this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||"#000000"),this._colorTextInput&&(this._colorTextInput.value=e||"#000000")):this._element&&(this._element.value=e),e?this.setAttribute("value",e):this.removeAttribute("value")}get value(){return this.getValue()}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 e=this._isTextarea(),t=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),r=this.hasError(),n=["w-full",t||i?"pl-10":"px-3.5",t||i?"pr-3.5":s?"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",e?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",e?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",r?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],l=["focus-visible:ring-2","focus-visible:ring-offset-1",r?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...n,...a,...l].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var y,x,k,E;this.getType();const e=this._getNormalizedType(),t=this._isTextarea(),i=this._isMoney(),s=this._isColor(),r=this.getPlaceholder(),n=this.isDisabled(),a=this.isReadonly(),l=this.isRequired(),o=this.getId(),d=this.getName(),c=this.getAttribute("value")||(s?"#000000":""),m=this.getRows(),h=this.getIcon(),f=this.getLabel(),u=this.getInfo(),p=this.isLoading();if(this._renderSkeleton(p),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=c||"#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=v=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var C;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((C=this._colorPickerWrapper)==null||C.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 C;const v=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this._colorTextInput&&(this._colorTextInput.value=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("input",{detail:{value:v},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var C;const v=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("change",{detail:{value:v},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=r||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var C;const v=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(v)&&(this._colorPicker&&(this._colorPicker.value=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("input",{detail:{value:v},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var C,A;const v=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(v)?(this._colorPicker&&(this._colorPicker.value=v),this.setAttribute("value",v)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((A=this._colorPicker)==null?void 0:A.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const g=c||"#000000";if(this._colorPicker&&this._colorPicker.value!==g&&(this._colorPicker.value=g),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=g),this._colorTextInput&&this._colorTextInput.value!==g&&(this._colorTextInput.value=g),this._colorPicker&&(this._colorPicker.disabled=n),this._colorPickerWrapper&&(n?(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=n,this._colorTextInput.readOnly=a,this._colorTextInput.required=l),this._colorTextInput){const v=this._colorTextInput;o?v.id=o:v.removeAttribute("id"),d?v.name=d:v.removeAttribute("name"),v.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=v}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&&!t?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()&&!t){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 g=document.createElement("mint-icon");g.setAttribute("name","caret-up"),g.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(g),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 v=document.createElement("mint-icon");v.setAttribute("name","caret-down"),v.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(v),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",C=>{if(C.preventDefault(),C.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,T=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A+T;H!==void 0&&L>H&&(L=H),S!==void 0&&L<S&&(L=S),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",C=>{if(C.preventDefault(),C.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,T=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A-T;S!==void 0&&L<S&&(L=S),H!==void 0&&L>H&&(L=H),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=n||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=n||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){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=r,this._textarea.disabled=n,this._textarea.readOnly=a,this._textarea.required=l,this._textarea.rows=m,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),c!==this._textarea.value&&(this._textarea.value=c),o?this._textarea.id=o:this._textarea.removeAttribute("id"),d?this._textarea.name=d:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const g=this.firstChild.textContent;g&&!this._textarea.value&&(this._textarea.value=g.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=e,this._input.placeholder=r,this._input.disabled=n,this._input.readOnly=a,this._input.required=l,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")),c!==this._input.value&&(this._input.value=c),o?this._input.id=o:this._input.removeAttribute("id"),d?this._input.name=d:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const g=this.firstChild.textContent;g&&!this._input.value&&(this._input.value=g.trim()),this.removeChild(this.firstChild)}let b=this.querySelector(".mint-input-label-container");if(f||u){b||(b=document.createElement("div"),b.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(b,this._wrapper):this.insertBefore(b,this.firstChild));let g=b.querySelector(".mint-input-label");if(f){g||(g=document.createElement("label"),g.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",b.insertBefore(g,b.firstChild)),g.textContent=f;const C=o||((y=this._element)==null?void 0:y.id)||((x=this._colorTextInput)==null?void 0:x.id)||((k=this._input)==null?void 0:k.id)||((E=this._textarea)==null?void 0:E.id);if(C)g.setAttribute("for",C);else{const A=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=A:this._colorTextInput?this._colorTextInput.id=A:this._input?this._input.id=A:this._textarea&&(this._textarea.id=A),g.setAttribute("for",A)}n?g.classList.add("opacity-40"):g.classList.remove("opacity-40")}else g&&g.remove();let v=b.querySelector(".mint-input-info");u?(v||(v=document.createElement("span"),v.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",b.appendChild(v)),v.textContent=u,n?v.classList.add("opacity-40"):v.classList.remove("opacity-40")):v&&v.remove()}else b&&b.remove();this._renderErrorState(),this._renderSkeleton(p)}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-input-error");e&&t?(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=t):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:e},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 e;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(e=this._element)==null||e.focus()}blur(){var e;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(e=this._element)==null||e.blur()}_renderSkeleton(e){let t=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(e){t||(t=document.createElement("div"),t.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-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 r=this._isTextarea(),n=this.getRows();if(r){const a=n*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";t.appendChild(s)}t.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 t&&(t.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",X);class K 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){const s=this.hasError(),r=this.getErrorMessage();this._applyErrorVisuals(s,r,this.isDisabled());return}if(e==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(e){e?(this.setAttribute("value",e),this._textInput&&(this._textInput.value=e),this._parseValue(e)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}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")||""}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const e=this.getAttribute("shortcuts");if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=e.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(r=>({label:r.label,action:typeof r.action=="function"?r.action:this._createShortcutAction(r.action)}))}}return[]}_createShortcutAction(e){return typeof e=="function"?e:typeof e=="string"&&typeof window[e]=="function"?window[e]:()=>null}_getDefaultShortcuts(){const e=[{label:"Today",action:()=>new Date}];return this._isRange&&e.push({label:"This Week",action:()=>{const t=new Date,i=t.getDay(),s=new Date(t);s.setDate(t.getDate()-i),s.setHours(0,0,0,0);const r=new Date(s);return r.setDate(s.getDate()+6),r.setHours(23,59,59,999),{start:s,end:r}}},{label:"This Month",action:()=>{const t=new Date,i=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),e}_getFormatTokens(e){const t=[];let i=0;const s=e.toLowerCase();for(;i<s.length;){const r=s[i];if(r==="d"||r==="m"||r==="y"){let n=1,a=i+1;for(;a<s.length&&s[a]===r;)n++,a++;t.push({type:"part",part:r,len:n}),i=a}else t.push({type:"sep",value:e[i]}),i++}return t}_createPartInput(e,t,i,s,r){const n=document.createElement("input");return n.type="text",n.inputMode="numeric",n.pattern="\\d*",n.maxLength=e,n.placeholder=t,n.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",n.disabled=i||s,n.readOnly=s,n.required=r,e===4?n.className+=" w-[40px]":e===2&&(n.className+=" w-[30px]"),n}_buildValueFromParts(e,t){let i=0;return t.map(s=>{var n;if(s.type==="sep")return s.value;const r=((n=e[i])==null?void 0:n.value)||"";return i++,r}).join("")}_applyDateToParts(e,t,i,s){if(!t.length)return;if(!e){t.forEach(l=>l.value="");return}const r=this._formatDate(e,s);let n=0,a=0;i.forEach(l=>{if(l.type==="sep")n+=l.value.length;else{const o=r.substr(n,l.len);t[a]&&(t[a].value=o),a++,n+=l.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const e=this.getFormat(),t=this._getFormatTokens(e),i=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(e,t){if(t+1<e.length){const i=e[t+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(e,t){if(t-1>=0){const i=e[t-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(e,t,i){e.forEach((s,r)=>{const n=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,n),s.value.length>=n&&this._focusNext(e,r),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(e,r),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(e,r),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(e,r),a.preventDefault())}),s.addEventListener("blur",a=>{var d,c;this._syncHiddenInput();const l=a.relatedTarget;l&&(this.contains(l)||(d=this._popover)!=null&&d.contains(l)||this._calendarContainer&&this._calendarContainer.contains(l))||(this._handleBlur(((c=this._hiddenInput)==null?void 0:c.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const m=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(m)}},0))})})}_splitRangeInput(e,t){const i=e.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[e]}_parseValue(e){const t=this.getFormat(),i=this._getFormatTokens(t);if(this._isRange){const[s,r]=this._splitRangeInput(e,t),n=s?this._parseDateString(s,t):null,a=r?this._parseDateString(r,t):null;if(n&&a){const[l,o]=n<=a?[n,a]:[a,n];this._selectedStartDate=l,this._selectedEndDate=o,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else n&&(this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,t)}else{const s=this._parseDateString(e,t);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,t)):this._applyDateToParts(null,this._startPartInputs,i,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){const i=/[\/\-\.\s]+/;if(i.test(e)){const p=e.split(i).filter(b=>b.length>0),_=t.split(/[\/\-\.\s]+/).filter(b=>b.length>0);if(p.length===_.length){let b=0,y=0,x=0;for(let k=0;k<_.length;k++){const E=_[k].toLowerCase(),g=p[k];if(E.includes("d"))b=parseInt(g,10);else if(E.includes("m"))y=parseInt(g,10)-1;else if(E.includes("y")){let v=parseInt(g,10);const C=E.length,A=g.length;A===2&&C===4?v=Math.floor(new Date().getFullYear()/100)*100+v:A===2&&C===2&&(v=Math.floor(new Date().getFullYear()/100)*100+v),x=v}}if(b&&y>=0&&y<=11&&x){const k=new Date(x,y,b);if(!isNaN(k.getTime())&&k.getDate()===b&&k.getMonth()===y&&k.getFullYear()===x)return k}}}const r=e.replace(/[\/\-\.]/g,""),n=t.replace(/[\/\-\.]/g,"").toLowerCase();let a=n.indexOf("d"),l=n.indexOf("m"),o=n.indexOf("y");const d=[{char:"d",index:a},{char:"m",index:l},{char:"y",index:o}].sort((p,_)=>p.index-_.index);let c=0,m=0,h=0,f=0;n.length,r.length;for(const p of d)if(p.char==="d"){const _=n.lastIndexOf("d")-n.indexOf("d")+1,b=r.substr(f,_);if(b.length===0)return null;c=parseInt(b,10),f+=b.length}else if(p.char==="m"){const _=n.lastIndexOf("m")-n.indexOf("m")+1,b=r.substr(f,_);if(b.length===0)return null;m=parseInt(b,10)-1,f+=b.length}else if(p.char==="y"){const _=n.lastIndexOf("y")-n.indexOf("y")+1,b=r.substr(f),y=Math.min(_,b.length),x=b.substr(0,y);if(x.length===0)return null;let k=parseInt(x,10);y===2&&_===4?k=Math.floor(new Date().getFullYear()/100)*100+k:y===2&&_===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),h=k,f+=y}if(!c||m<0||m>11||!h)return null;const u=new Date(h,m,c);return isNaN(u.getTime())||u.getDate()!==c||u.getMonth()!==m||u.getFullYear()!==h?null:u}_formatDate(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=t.toLowerCase();let a=t;return n.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):n.includes("d")&&(a=a.replace(/d/gi,String(i))),n.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):n.includes("m")&&(a=a.replace(/m/gi,String(s))),n.includes("yyyy")?a=a.replace(/yyyy/gi,String(r)):n.includes("yy")&&(a=a.replace(/yy/gi,String(r).substr(2))),a}_formatDatePhp(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=(h,f=2)=>h.toString().padStart(f,"0"),c=h=>{const f=h%10,u=h%100;return f===1&&u!==11?"st":f===2&&u!==12?"nd":f===3&&u!==13?"rd":"th"};let m="";for(let h=0;h<t.length;h++){const f=t[h];if(f==="\\"&&h+1<t.length){m+=t[h+1],h++;continue}switch(f){case"Y":m+=r.toString();break;case"y":m+=r.toString().slice(-2);break;case"m":m+=d(s);break;case"n":m+=s.toString();break;case"M":m+=o[s-1];break;case"F":m+=l[s-1];break;case"d":m+=d(i);break;case"j":m+=i.toString();break;case"D":m+=a[e.getDay()];break;case"l":m+=n[e.getDay()];break;case"S":m+=c(i);break;default:m+=f;break}}return m}_validateDateString(e,t){const i=this._parseDateString(e,t);return i!==null&&!isNaN(i.getTime())}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.getValue(),r=this.isDisabled(),n=this.isReadonly(),a=this.isRequired(),l=this.getId(),o=this.getName(),d=this.getFormat(),c=this.hasError(),m=this.getErrorMessage();this._isRange=this.isRange(),this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let h=this.querySelector(".mint-date-picker-label-container");if(t||i){h||(h=document.createElement("div"),h.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(h,this._input):this.appendChild(h));let y=h.querySelector(".mint-date-picker-label");t?(y||(y=document.createElement("label"),y.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",h.insertBefore(y,h.firstChild)),y.textContent=t,l&&this._textInput&&y.setAttribute("for",l)):y&&y.remove();let x=h.querySelector(".mint-date-picker-info");i?(x||(x=document.createElement("span"),x.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",h.appendChild(x)),x.textContent=i):x&&x.remove()}else h&&h.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)),l&&(this._hiddenInput.id=l),o&&(this._hiddenInput.name=o),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",c?"true":"false");let f=this._input.querySelector(".mint-date-fields");f||(f=document.createElement("div"),this._input.appendChild(f)),this._fieldsContainer=f,this._applyErrorVisuals(c,m,r),f.innerHTML="",this._displayEl=document.createElement("div");const u=n?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${n?"cursor-default":"cursor-text"} ${u} focus:outline-none`,this._displayEl.tabIndex=r||n?-1:0,this._displayEl.addEventListener("click",()=>{r||n||this._enterInputMode()}),this._displayEl.addEventListener("keydown",y=>{r||n||(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const p=this._getFormatTokens(d);this._startPartInputs=[],this._endPartInputs=[];const _=y=>{const x=document.createDocumentFragment();return p.forEach(k=>{if(k.type==="sep"){const E=document.createElement("span");E.textContent=k.value,E.className="text-gray-400 dark:text-gray-500 select-none",x.appendChild(E)}else{const E=k.part==="d"?"dd":k.part==="m"?"mm":k.len===2?"yy":"yyyy",g=this._createPartInput(k.len,E,r,n,a);y==="start"?this._startPartInputs.push(g):this._endPartInputs.push(g),x.appendChild(g)}}),x};if(this._inputsWrapperEl.appendChild(_("start")),this._isRange){const y=document.createElement("span");y.textContent=" - ",y.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(y),this._inputsWrapperEl.appendChild(_("end"))}const b=document.createElement("div");if(b.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",b.appendChild(this._displayEl),b.appendChild(this._inputsWrapperEl),f.appendChild(b),f.addEventListener("click",()=>{this._isInputMode||r||n||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,p,f),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,p,f),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=r||n,!r&&!n?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 y=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=y;const x=document.createElement("mint-icon");x.setAttribute("name","calendar"),x.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(x),this._iconButton.addEventListener("click",()=>{r||n||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=r||n}this._renderErrorState(c,m),this._renderSkeleton(e)}_renderErrorState(e,t){let i=this.querySelector(".mint-date-picker-error");e&&t?(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=t):i&&i.remove()}_applyErrorVisuals(e,t,i){if(this._renderErrorState(e,t),this._fieldsContainer){const s=this._getFieldContainerClass(e,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",e?"true":"false")}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},e.addEventListener("reset",this._resetHandler))}_clearPartInputs(e){e.forEach(t=>{t.value=""})}_getFieldContainerClass(e,t){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",e?"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",e?"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(" ")+(t?" opacity-40 cursor-not-allowed":"")}_handleInputChange(e){}_cleanInputValue(e,t){return e}_handleBlur(e){const t=this.getFormat();if(!e){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(e,t),r=i?this._parseDateString(i,t):null,n=s?this._parseDateString(s,t):null;if(r&&n){const[a,l]=r<=n?[r,n]:[n,r],o=this._formatDate(a,t),d=this._formatDate(l,t),c=`${o} - ${d}`;this.setValue(c),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(l,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=a,this._selectedEndDate=l,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(r){const a=this._formatDate(r,t);this.setValue(a),this._applyDateToParts(r,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){const i=this._parseDateString(e,t);if(i){const s=this._formatDate(i,t);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(e=0){if(!this._iconButton){e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)});return}const t=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)}):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(!e)return;if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),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",e),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var r;if(s.type==="attributes"&&s.attributeName==="open")if((r=this._popover)==null?void 0:r.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const a=this._popover;typeof a.render=="function"&&a.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var a;(a=this._iconButton)==null||a.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const a=new Date;this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var l;const a=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(l=this._hiddenInput)==null||l.dispatchEvent(a)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==e){this._popover.setAttribute("trigger-id",e);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 e=this._popover.querySelector(".popover-content");if(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=this.getShortcuts(),n=r.length>0;this._calendarContainer.className=n?"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 a=document.createElement("div");a.className="flex flex-col md:flex-row md:gap-6 md:items-start";const l=document.createElement("div");l.className="flex-1 min-w-0";const o=document.createElement("div");o.className="flex items-center justify-between mb-4";const d=document.createElement("button");d.type="button",d.tabIndex=0,d.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",d.setAttribute("data-keep-popover-open","true");const c=document.createElement("mint-icon");c.setAttribute("name","caret-left"),c.className="w-4 h-4",d.appendChild(c),d.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),o.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-2";const h=document.createElement("button");h.type="button",h.tabIndex=0,h.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",h.setAttribute("data-keep-popover-open","true"),h.textContent=i[this._currentMonth],h.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),m.appendChild(h);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=String(this._currentYear),f.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),m.appendChild(f),o.appendChild(m);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 p=document.createElement("mint-icon");p.setAttribute("name","caret-right"),p.className="w-4 h-4",u.appendChild(p),u.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),o.appendChild(u);const _=document.createElement("div");_.className="grid grid-cols-7 mb-2",s.forEach(k=>{const E=document.createElement("div");E.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",E.textContent=k,_.appendChild(E)});const b=document.createElement("div");b.className="grid grid-cols-7";for(let k=0;k<t;k++){const E=document.createElement("div");E.className="w-8 h-8",b.appendChild(E)}const y=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,x=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let k=1;k<=e;k++){const E=new Date(this._currentYear,this._currentMonth,k),g=this._isToday(E),v=this._isDateSelected(E),C=this._isDateInRange(E),A=y&&E<y||x&&E>x;let T="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const H=this._isSameDate(E,this._selectedStartDate),L=this._isSameDate(E,this._selectedEndDate);H&&L?T="rounded-md":H?T="rounded-l-md":L?T="rounded-r-md":C&&(T="rounded-none")}else v&&!this._isRange&&(T="rounded-md");const S=document.createElement("button");S.type="button",S.disabled=!!A,S.tabIndex=A?-1:0,S.className=`w-full h-8 ${T} 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 ${v?"bg-slate-800 dark:bg-slate-600 text-white":C?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":g?"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"} ${A?"opacity-40 cursor-not-allowed":""}`,S.textContent=k.toString(),A||S.addEventListener("click",()=>{this._handleDateClick(E)}),b.appendChild(S)}if(n){const k=document.createElement("div");k.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 E=document.createElement("div");E.className="relative md:relative md:flex-1 md:min-h-0";const g=document.createElement("div");g.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",g.style.scrollbarWidth="none",g.style.msOverflowStyle="none",g.style.setProperty("-webkit-overflow-scrolling","touch");const v=document.createElement("style");v.textContent=`
44
+ `;this.innerHTML=o.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",P);class q extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["name"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","inline-flex","items-center","leading-none"),this.render(),this._observeDarkMode()}attributeChangedCallback(e,t,i){t!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(e=>{for(const t of e)if(t.type==="attributes"&&t.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}getIconUrl(){var t;const e=(t=document.querySelector('meta[name="mint-icon-base-url"]'))==null?void 0:t.getAttribute("content");return e?e==="local"?`/icons/${this.getName()}.svg`:e==="cdn"?`https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`:`${e.endsWith("/")?e:`${e}/`}${this.getName()}.svg`:`https://assets.gomonobill.com/mintui/icons/${this.getName()}.svg`}render(){var l,o,d;const e=this.getName();if(!e){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}if(!le.getIcon(e)){console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="";return}const i=this.closest("mint-button")||((l=this.parentElement)==null?void 0:l.closest("mint-button")),s=this.closest("mint-switch")||((o=this.parentElement)==null?void 0:o.closest("mint-switch")),r=this.closest("mint-select")||((d=this.parentElement)==null?void 0:d.closest("mint-select"));if(!Array.from(this.classList).some(c=>c.startsWith("w-")||c.startsWith("h-"))&&!r){let c;s?c="w-3 h-3":i?c="w-5 h-5":c="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"),c.split(" ").forEach(m=>{m&&this.classList.add(m)})}const a=this.getIconUrl();if(this.style.maskImage=`url(${a})`,this.style.webkitMaskImage=`url(${a})`,this.style.maskSize="contain",this.style.webkitMaskSize="contain",this.style.maskRepeat="no-repeat",this.style.webkitMaskRepeat="no-repeat",this.style.maskPosition="center",this.style.webkitMaskPosition="center",this.style.aspectRatio="1 / 1",this.style.backgroundColor="currentColor",this.innerHTML="",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 m=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(m)}}}customElements.get("mint-icon")||customElements.define("mint-icon",q);class F 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._button.classList.remove("mint-button-active")},this._handleMouseLeave=()=>{this._button&&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._button.classList.remove("mint-button-active")},this._handleTouchCancel=()=>{this._button&&this._button.classList.remove("mint-button-active")}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon"]}connectedCallback(){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(e,t,i){t!==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 e=this.getAttribute("type"),t=this.getAttribute("button-type");return(e||t||"default")==="submit"?"submit":"button"}isFullWidth(){return this.hasAttribute("full-width")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}isIconOnly(){var i,s,r,n,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const t=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(t&&((r=t.textContent)!=null&&r.trim()))return!1;if(this._button)for(let l=this._button.firstChild;l;l=l.nextSibling){if(l.nodeType===Node.TEXT_NODE&&((n=l.textContent)!=null&&n.trim()))return!1;if(l.nodeType===Node.ELEMENT_NODE){const o=l;if(o.tagName!=="MINT-ICON"&&o.tagName!=="MINT-SPINNER"&&!o.querySelector("mint-spinner")&&!o.hasAttribute("slot")&&o.className!=="mint-button-icon"&&!(o.className==="mr-2"&&o.querySelector("mint-spinner"))&&(a=o.textContent)!=null&&a.trim())return!1}}return!0}getButtonClasses(){const e=this.isIconOnly(),t=this.getVariant(),i=["inline-flex","items-center","justify-center","font-medium","rounded-lg","box-border",...e?["p-1.5","aspect-square","w-[2rem]","h-[2rem]"]:["px-3.5","py-1.5","min-h-[2rem]"],"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(),r={"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"]},n=`${t}-${s}`,a=r[n]||r["solid-neutral"],l=[...i,...a];return this.isFullWidth()&&l.push("w-full"),l.join(" ")}render(){var d,c,m,h,f;const e=this.isDisabled()||this.isLoading(),t=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=t,this._button.disabled=e;let i=this._button.querySelector("mint-spinner");if(this.isLoading())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 u=document.createElement("span");u.className="mr-2 inline-flex items-center";const p=document.createElement("mint-spinner");p.setAttribute("size","default"),p.setAttribute("data-button-variant",this.getVariant()),p.setAttribute("data-button-tone",this.getTone()),p.style.width="0.875rem",p.style.height="0.875rem",u.appendChild(p),this._button.insertBefore(u,this._button.firstChild)}else i&&((d=i.parentElement)==null||d.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const s=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');s?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",s),r.className="mint-button-icon"):r.setAttribute("name",s)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const n=this.getIconPosition();let a=this._button.querySelector(".mint-button-content");if(a){const u=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const p=(h=this._button.querySelector("mint-spinner"))==null?void 0:h.parentElement;u||n==="left"?p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a):a.insertAdjacentElement("afterend",r)}else if(r&&(u||n==="left")&&r.nextSibling!==a){r.remove();const p=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,a)}else r&&!u&&n==="right"&&r.previousSibling!==a&&(r.remove(),a.insertAdjacentElement("afterend",r))}else{const u=[];for(let p=this._button.firstChild;p;p=p.nextSibling){if(p.nodeType!==Node.ELEMENT_NODE){u.push(p);continue}const _=p;_.tagName!=="MINT-SPINNER"&&!_.querySelector("mint-spinner")&&p!==r&&!_.hasAttribute("slot")&&!(_.className==="mr-2"&&_.querySelector("mint-spinner"))&&u.push(p)}if(u.length>0){a=document.createElement("span"),a.className="mint-button-content inline-flex items-center",u.forEach(_=>{a.appendChild(_)});const p=(c=this._button.querySelector("mint-spinner"))==null?void 0:c.parentElement;r&&n==="left"?p?(p.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",a)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",a)):r&&n==="right"?p?(p.insertAdjacentElement("afterend",a),a.insertAdjacentElement("afterend",r)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement("afterend",r)):p?p.insertAdjacentElement("afterend",a):this._button.insertBefore(a,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const p=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;p?p.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),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")):n==="left"?r.classList.add("mr-1.5"):r.classList.add("ml-1.5"));const o=this.getButtonClasses();this._button.className=o}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(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0}));return}if(e.stopPropagation(),e.stopImmediatePropagation(),this._isHandlingClick){e.preventDefault();return}this._isHandlingClick=!0,e.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:e},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}}customElements.get("mint-button")||customElements.define("mint-button",F);class B 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 e=this.querySelector(".mint-switch-container");return e||(e=document.createElement("div"),e.className="mint-switch-container flex items-center gap-2",this.insertBefore(e,this.firstChild)),e}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(e==="checked"&&(this._checked=i!==null),t!==i){if(e==="error"||e==="error-message"){this._renderErrorState();return}if(e==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this.render()}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 e=this.hasError(),t=["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",e?"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",e?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",e?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...t,...i].join(" ")}getThumbClasses(){const e=["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"],t=this._checked?"translate-x-5":"translate-x-0.5";return[...e,t].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const e=this.isLoading(),t=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),r=this.getInfo(),n=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const l=this._getSwitchContainer();this._button?this._button.parentElement!==l&&l.appendChild(this._button):(this._button=document.createElement("button"),l.appendChild(this._button),this.setupEventListeners());let o=l.querySelector(".mint-switch-label");s?(o||(o=document.createElement("label"),o.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===l?l.insertBefore(o,this._button.nextSibling):l.appendChild(o)),o.textContent=s,o.setAttribute("for",a),this.isDisabled()?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove(),this._button.className=t,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 d=this._button.querySelector("span");d||(d=document.createElement("span"),this._button.appendChild(d)),d.className=i;const c=d.querySelector("span");if(n){let h=c;h||(h=document.createElement("span"),h.className=this.getIconClasses(),d.appendChild(h));let f=h.querySelector("mint-icon");f||(f=document.createElement("mint-icon"),h.appendChild(f)),f.setAttribute("name",n)}else c&&c.remove();let m=this.querySelector(".mint-switch-info");r?(m||(m=document.createElement("span"),m.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",l&&l.parentElement===this?this.insertBefore(m,l.nextSibling):this.appendChild(m)),m.textContent=r,this.isDisabled()?m.classList.add("opacity-40"):m.classList.remove("opacity-40")):m&&m.remove(),this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(e){this.isDisabled()||(this.checked=!this._checked,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(e){const t=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let r=t.querySelector(".mint-switch-skeleton-container"),n=this.querySelector(".mint-switch-info-skeleton");if(e){t.classList.contains("relative")||t.classList.add("relative"),r||(r=document.createElement("div"),r.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",t.appendChild(r));let a=r.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",r.appendChild(a)),i){let o=r.querySelector(".mint-switch-skeleton-label");o||(o=document.createElement("div"),o.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",r.appendChild(o))}else{const o=r.querySelector(".mint-switch-skeleton-label");o&&o.remove()}r.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const l=t.querySelector(".mint-switch-label");if(l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),s){n||(n=document.createElement("div"),n.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",t&&t.parentElement===this?this.insertBefore(n,t.nextSibling):this.appendChild(n)),n.style.display="block";const o=this.querySelector(".mint-switch-info");o&&(o.style.display="none")}else n&&(n.style.display="none")}else{r&&(r.style.display="none"),n&&(n.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=t.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const l=this.querySelector(".mint-switch-info");l&&(l.style.display="")}}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");e&&t?(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=t):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",B);class O 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(t=>this._userClasses.add(t))}attributeChangedCallback(e,t,i){t!==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 e=this.getSize(),t=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},r={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"]},n=[];this.isBold()&&n.push("font-bold"),this.isUnderline()&&n.push("underline"),this.isStrike()&&n.push("line-through"),this.isItalic()&&n.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[e]||s.regular,...r[t]||r.default,...n].join(" ")}render(){const e=this.getSize(),t=["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(o=>{this.classList.remove(o),this._userClasses.delete(o)}),t.forEach(o=>{this.classList.remove(o),this._userClasses.delete(o)});const s=this.getTextClasses().split(" ").filter(o=>o.trim());Array.from(this.classList).forEach(o=>{!t.includes(o)&&!i.includes(o)&&this._userClasses.add(o)});const n=[...new Set([...s,...Array.from(this._userClasses)])];this.className=n.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)"},l=a[e]||a.regular;this.style.setProperty("font-size",l)}}customElements.get("mint-text")||customElements.define("mint-text",O);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(e,t,i){t!==i&&(this.render(),e==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),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 e=this.getAttribute("gap")||"3";return parseFloat(e)}getTextAlign(){const e=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(e)?e:""}getStackClasses(){const e=this.getDirection(),t=this.getTextAlign(),i=this.getGap(),s=["flex",e==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return t&&(s.push(`text-${t}`),s.push(`[&>*]:text-${t}`),s.push(`[&>*_.mint-button-content]:text-${t}`),t==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):t==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):t==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const e=this.getStackClasses(),t=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(r=>this.classList.remove(r)),e.split(" ").forEach(r=>{r&&this.classList.add(r)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(r=>{this.classList.contains(r)||this.classList.add(r)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){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"),e==="left"?s.classList.add("justify-start"):e==="right"?s.classList.add("justify-end"):e==="center"&&s.classList.add("justify-center");const r=s.querySelector(".mint-button-content");r&&(r.classList.remove("text-left","text-center","text-right","text-justify"),r.classList.add(`text-${e}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(t=>{if(t.tagName==="MINT-BUTTON"){const i=t.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 t.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",z);class W extends HTMLElement{constructor(){super(),this._headingElement=null,this._contentWrapper=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}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");let e=Array.from(this.children).find(i=>i.classList.contains("p-6")&&i===this._contentWrapper);(!this._contentWrapper||!e)&&(this._contentWrapper=document.createElement("div"),this._contentWrapper.className="p-6",Array.from(this.children).filter(s=>s!==this._contentWrapper).forEach(s=>{this._contentWrapper.appendChild(s)}),this.appendChild(this._contentWrapper));const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this._contentWrapper&&this._contentWrapper.insertBefore(this._headingElement,this._contentWrapper.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",W);class V 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(t=>{t.classList.contains("underline")||t.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,i){t!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var e;return!!(this.querySelector("mint-icon")||(e=this._link)!=null&&e.querySelector("mint-icon"))}render(){const e=this.getHref(),t=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=e,t?(this._link.target=t,t==="_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",V);class R 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(e,t,i){t!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const e=document.referrer,t=window.location.origin;if(e)try{const i=new URL(e);if(i.origin===t)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(e){e.preventDefault(),e.stopPropagation();const t=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),r=new CustomEvent("back",{detail:{url:t,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(r)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",e=>this.handleClick(e)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",R);class j 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(e,t,i){t!==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 e=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 t=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){t||(t=document.createElement("mint-back-button"),this._titleElement.insertBefore(t,this._titleElement.firstChild));const n=this.getFallbackHref();t.setAttribute("fallback-href",n),this._backButton=t}else t&&(t.remove(),t=null,this._backButton=null);e?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.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"),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):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(n=>n!==this._pageContainer&&n!==this._actionsSlot&&n.getAttribute("slot")==="actions").forEach(n=>{this._actionsSlot&&n.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(n)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(n=>{n!==this._pageContainer&&n.getAttribute("slot")!=="actions"&&n!==this._actionsSlot&&n!==this._header&&n!==this._bodySlot&&n!==this._headingText&&n.parentElement!==this._bodySlot&&n.parentElement!==this._pageContainer&&this._bodySlot.appendChild(n)}),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=e=>{const t=e.target;if(t&&t.tagName==="MINT-BACK-BUTTON"){e.stopPropagation();const i=new CustomEvent("back",{detail:e.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",j);class $ 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(e,t,i){t!==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 e=["grid"],t=this.getColumns();e.push(`grid-cols-${t}`);const i=this.getSm();i&&e.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&e.push(`md:grid-cols-${s}`);const r=this.getLg();r&&e.push(`lg:grid-cols-${r}`);const n=this.getXl();n&&e.push(`xl:grid-cols-${n}`);const a=this.getGap();return e.push(`gap-${a}`),e}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",$);class Y 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(e,t,i){t!==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 e=this.getId(),t=this.getHeading(),i=this.isOpen();if(e&&(this.id=e),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 c=this._modal.querySelector(".modal-content");c||(c=document.createElement("div"),c.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(c)),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 r=this._headingSlot.querySelector("mint-text");t?(r||(r=document.createElement("mint-text"),r.setAttribute("size","sub-heading"),r.setAttribute("bold",""),this._headingSlot.appendChild(r)),r.textContent=t):r&&r.remove(),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._headingSlot&&c.getAttribute("slot")==="heading").forEach(c=>{this._headingSlot&&c.parentElement!==this._headingSlot&&this._headingSlot.appendChild(c)}),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(c=>c!==this._overlay&&c!==this._modal&&c!==this._bodySlot&&c.getAttribute("slot")==="body").forEach(c=>{this._bodySlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),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 l=this._actionsSlot.querySelector("mint-stack");l||(l=document.createElement("mint-stack"),l.setAttribute("direction","horizontal"),l.className="justify-end",this._actionsSlot.appendChild(l)),Array.from(this.children).filter(c=>c!==this._overlay&&c!==this._modal&&c!==this._actionsSlot&&c.getAttribute("slot")==="actions").forEach(c=>{Array.from(c.children).forEach(h=>{h.parentElement!==l&&l.appendChild(h)}),c.parentElement&&c.remove()}),Array.from(this.children).forEach(c=>{c!==this._overlay&&c!==this._modal&&c.getAttribute("slot")!=="heading"&&c.getAttribute("slot")!=="body"&&c.getAttribute("slot")!=="actions"&&c!==this._headingSlot&&c!==this._bodySlot&&c!==this._actionsSlot&&c.parentElement!==this._bodySlot&&this._bodySlot.appendChild(c)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const e=document.documentElement.classList.contains("dark"),t=this._modal.querySelector(".modal-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");e&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})}))}_animateExit(){var t;const e=(t=this._modal)==null?void 0:t.querySelector(".modal-content");if(!e){this.classList.add("hidden");return}e.style.transition="all 200ms ease-in",e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),e.style.transform="",e.style.opacity="",e.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",Y);class U 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(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0","z-50","pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){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(e,t,i){t!==i&&(this.render(),(e==="trigger-id"||e==="hover")&&this._setupTrigger(),e==="open"&&this.isOpen()&&this._closeOtherPopovers())}getId(){return this.getAttribute("id")||""}getPadding(){const e=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"}[e]||"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 e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute("open")?e.removeAttribute("open"):e.setAttribute("open","")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){e._cancelHoverClose()},this._popoverHoverLeaveHandler=function(t){var s;const i=t.relatedTarget;i&&(e.contains(i)||(s=e._triggerElement)!=null&&s.contains(i))||e._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 e=this._triggerElement?this._triggerElement.matches(":hover"):!1,t=this._popover?this._popover.matches(":hover"):!1;return e||t}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const e=this._triggerElement.getBoundingClientRect(),t=this._popover.querySelector(".popover-content");if(!t)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=t.getBoundingClientRect(),r=window.innerWidth,n=window.innerHeight,a=8;let l=this.getDirection(),o=0,d=0;switch(l){case"down":if(o=e.bottom+a,d=e.left+e.width/2-s.width/2,o+s.height>n){const c=e.top-s.height-a;c>=0?(l="up",o=c):(o=Math.max(0,n-s.height-a),o+s.height>n&&(o=0))}d<0&&(d=a),d+s.width>r&&(d=Math.max(a,r-s.width-a),d+s.width>r&&(d=r-s.width));break;case"up":if(o=e.top-s.height-a,d=e.left+e.width/2-s.width/2,o<0){const c=e.bottom+a;c+s.height<=n?(l="down",o=c):(o=Math.min(n-s.height-a,n-s.height),o<0&&(o=n-s.height))}d<0&&(d=a),d+s.width>r&&(d=Math.max(a,r-s.width-a),d+s.width>r&&(d=r-s.width));break;case"right":if(o=e.top+e.height/2-s.height/2,d=e.right+a,d+s.width>r){const c=e.left-s.width-a;c>=0?(l="left",d=c):(d=Math.max(0,r-s.width-a),d+s.width>r&&(d=r-s.width))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break;case"left":if(o=e.top+e.height/2-s.height/2,d=e.left-s.width-a,d<0){const c=e.right+a;c+s.width<=r?(l="right",d=c):(d=Math.min(r-s.width-a,r-s.width),d<0&&(d=0))}o<0&&(o=a),o+s.height>n&&(o=Math.max(a,n-s.height-a),o+s.height>n&&(o=n-s.height));break}return{top:o,left:d,direction:l}}render(){const e=this.getId(),t=this.isOpen(),i=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",!this._clickOutsideHandler){const n=this;this._clickOutsideHandler=function(a){const l=a.composedPath(),o=l.includes(n);if(!(n._triggerElement&&l.includes(n._triggerElement))&&!o){n.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 pointer-events-none z-40",this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement("div"),this._popover.className="fixed z-50 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 n=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"],l=n.filter(o=>!a.includes(o));s.className=[...l,i].join(" ")}Array.from(this.children).forEach(n=>{n!==this._overlay&&n!==this._popover&&n.parentElement===this&&s.appendChild(n)}),t?(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"})}))):!t&&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 e=document.documentElement.classList.contains("dark"),t=this._popover.querySelector(".popover-content");t&&(e?(t.classList.remove("bg-white"),t.classList.add("bg-gray-800")):(t.classList.remove("bg-gray-800"),t.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;const t=this._popover.style.visibility!=="hidden";t||(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`,t||(this._popover.style.visibility="visible",e&&(!e.style.opacity||e.style.opacity==="")&&(e.style.transform="scale(0.97) translateY(10px)",e.style.opacity="0",e.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform="scale(1) translateY(0)",e.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){const t=e._popover.querySelector(".popover-content");t&&e._updatePosition(t)}},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(t=>{if(t!==this){const i=t;typeof i.close=="function"?i.close():t.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",U);class G 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 e=this.getAttribute("checked");this._checked=e!==null&&e!=="false",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(e==="checked"&&(this._checked=i!==null&&i!=="false",this._checkbox&&(this._checkbox.checked=this._checked)),t!==i){if(e==="error"||e==="error-message"){this._renderErrorState();return}if(e==="loading"){this.render();return}this.render(),e==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){return this._checked}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}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 e=this.hasError(),t=["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",e?"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",e?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",e?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...t,...i].join(" ")}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let r=this.querySelector(".mint-checkbox-container");r||(r=document.createElement("div"),r.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(r,this.firstChild));let n=this.querySelector(".mint-checkbox-wrapper");n?n.parentElement!==r&&r.appendChild(n):(n=document.createElement("div"),n.className="mint-checkbox-wrapper",r.appendChild(n)),this._checkbox?this._checkbox.parentElement!==n&&n.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",n.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 l=this.getName();l?this._checkbox.name=l:this._checkbox.removeAttribute("name");const o=this.getValue();o?this._checkbox.value=o:this._checkbox.removeAttribute("value"),t?this._checkbox.setAttribute("aria-label",t):this._checkbox.removeAttribute("aria-label"),n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,n.style.pointerEvents="none",this._checkbox.style.pointerEvents="auto";let d=n.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",n.appendChild(d)),this.updateVisualState();let c=this.querySelector(".mint-checkbox-label-container");const m=this.querySelector(".mint-checkbox-container");if(t||i){c?m&&c.parentElement!==m&&m.appendChild(c):(c=document.createElement("div"),c.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",m?m.appendChild(c):this.appendChild(c));let h=c.querySelector(".mint-checkbox-label");t?(h||(h=document.createElement("span"),h.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",c.insertBefore(h,c.firstChild)),h.textContent=t,s?h.classList.add("opacity-40"):h.classList.remove("opacity-40")):h&&h.remove();let f=c.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",c.appendChild(f)),f.textContent=i,s?f.classList.add("opacity-40"):f.classList.remove("opacity-40")):f&&f.remove(),s)c.style.cursor="default",c._clickHandler&&(c.removeEventListener("click",c._clickHandler),c._clickHandler=null);else{c.style.cursor="pointer";const u=c._clickHandler;u&&c.removeEventListener("click",u),c._clickHandler=p=>{this._checkbox&&(p.target===this._checkbox||this._checkbox.contains(p.target)||p.composedPath().includes(this._checkbox))||this.toggle()},c.addEventListener("click",c._clickHandler)}}else c&&c.remove();this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute("checked")||this.setAttribute("checked",""):this.hasAttribute("checked")&&this.removeAttribute("checked"),this.updateVisualState();const t=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._mouseleaveHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=e=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(t==null||t.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&e.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=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&!this.isDisabled()&&(t.classList.add("mint-checkbox-active"),this._checked?(t.style.backgroundColor="rgb(15 23 42)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(t.style.backgroundColor="rgb(243 244 246)",t.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?t.style.backgroundColor="rgb(51 65 85)":t.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=e=>{e.stopPropagation();const t=this.querySelector(".mint-checkbox-wrapper");t&&(t.classList.remove("mint-checkbox-active"),t.style.backgroundColor="",t.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))}updateVisualState(){const e=this.querySelector(".mint-checkbox-wrapper"),t=e==null?void 0:e.querySelector("mint-icon");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"scale(1)":"scale(0.8)"),e&&(e.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,e.classList.contains("mint-checkbox-active")||(e.style.backgroundColor="",e.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();const e=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}_renderSkeleton(e){let t=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),r=this.querySelector(".mint-checkbox-label-container");if(e){t||(t=document.createElement("div"),t.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(t):(this.style.position="relative",this.appendChild(t)));let n=t.querySelector(".mint-checkbox-skeleton-box");if(n||(n=document.createElement("div"),n.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",t.appendChild(n)),r){let a=t.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",t.appendChild(a))}t.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),r&&(r.style.visibility="hidden",r.style.pointerEvents="none")}else t&&(t.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),r&&(r.style.visibility="visible",r.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&e&&t&&(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");e&&t?(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=t):s&&s.remove();const r=this.querySelector(".mint-checkbox-wrapper");r&&(r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",G);class ce 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 e=this.getAttribute("checked");this._checked=e!==null&&e!=="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(e,t,i){if(e==="checked"&&(this._checked=i!==null&&i!=="false",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),t!==i){if(e==="loading"){this.render();return}this.render()}}get checked(){return this._checked}set checked(e){this._checked=!!e,e?this.setAttribute("checked",""):this.removeAttribute("checked"),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}getValue(){return this.getAttribute("value")||""}isDisabled(){const e=this.closest("mint-choice");return this.hasAttribute("disabled")||((e==null?void 0:e.hasAttribute("disabled"))??!1)}_setupClickHandler(){this._clickHandler||(this._clickHandler=e=>{e.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 t=this.closest("mint-choice");t&&t.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 e=this.isLoading(),t=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),r=(s==null?void 0:s.getAttribute("name"))||"";let n="";const a=this.querySelector(".mint-choice-option-label");a?n=((f=a.textContent)==null?void 0:f.trim())||"":Array.from(this.childNodes).forEach(u=>{var p;if(u.nodeType===Node.TEXT_NODE){const _=(p=u.textContent)==null?void 0:p.trim();_&&(n+=_)}});const l=this.querySelectorAll(".mint-choice-option-wrapper");let o=null;if(l.length>0&&(this._radio&&(o=Array.from(l).find(u=>u.contains(this._radio))),o||(o=l[0]),l.forEach((u,p)=>{u!==o&&u.remove()})),o||(o=document.createElement("div"),o.className="mint-choice-option-wrapper",o.style.position="relative",this.insertBefore(o,this.firstChild)),o.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,o.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(u=>{u!==this._radio&&u.remove()}),this._radio)this._radio.parentElement!==o&&o.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=u=>{const p=this.querySelector(".mint-choice-option-wrapper");p&&!this.isDisabled()&&p.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const u=this.querySelector(".mint-choice-option-wrapper");u&&u.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=u=>{this.isDisabled()||(u.key==="ArrowDown"||u.key==="ArrowRight"?(u.preventDefault(),this._focusNextOption()):(u.key==="ArrowUp"||u.key==="ArrowLeft")&&(u.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",o.appendChild(this._radio),this._changeHandler=p=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked",""):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const b=this.closest("mint-choice");_!==this._checked&&b&&setTimeout(()=>{b.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const u=()=>{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",u),this._focusHandler=p=>{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 p=this.querySelector(".mint-choice-option-wrapper");p&&p.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),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.addEventListener("keydown",this._keydownHandler)}this._radio.name=r,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=t,t?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),n?this._radio.setAttribute("aria-label",n):this._radio.removeAttribute("aria-label"),o.querySelectorAll(".mint-choice-option-indicator").forEach((u,p)=>{p>0&&u.remove()});let m=o.querySelector(".mint-choice-option-indicator");m||(m=document.createElement("div"),m.className="mint-choice-option-indicator",o.appendChild(m)),m.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",m.style.position="absolute",m.style.top="50%",m.style.left="50%",m.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",m.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(e);let h=this.querySelector(".mint-choice-option-label");n&&(h||(h=document.createElement("span"),h.className="mint-choice-option-label",this.appendChild(h),Array.from(this.childNodes).forEach(u=>{var p;u.nodeType===Node.TEXT_NODE&&((p=u.textContent)!=null&&p.trim())&&(u.textContent="")})),h.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t?"opacity-40":""}`,h.textContent=n),t?(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 e=this.isDisabled(),t=["inline-flex","items-center","justify-center","w-5","h-5","rounded-full","border-2","transition-all","duration-200","flex-shrink-0"];return e&&t.push("opacity-40","cursor-not-allowed"),this._checked?t.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):t.push("bg-white","dark:bg-gray-700","border-gray-300","dark:border-gray-500"),t.join(" ")}_updateVisualState(){const e=this.querySelector(".mint-choice-option-wrapper");e&&(e.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const t=this.querySelector(".mint-choice-option-indicator");t&&(t.style.opacity=this._checked?"1":"0",t.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(e){let t=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(e){t||(t=document.createElement("div"),t.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(t)):(this.style.position="relative",this.appendChild(t)));let s=t.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",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector('input[type="radio"]'),n=i.querySelector(".mint-choice-option-indicator");r&&(r.style.visibility="hidden"),n&&(n.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(t&&(t.style.display="none"),i){const r=i.querySelector('input[type="radio"]'),n=i.querySelector(".mint-choice-option-indicator");r&&(r.style.visibility="visible"),n&&(n.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 t;if(!((t=this._radio)!=null&&t.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 e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(r=>!r.disabled),t=e.indexOf(this._radio);let i=null;if(t>=0&&t<e.length-1?i=e[t+1]:e.length>0&&(i=e[0]),i){const r=i.closest("mint-choice-option");if(i.checked=!0,r){const n=r._checked;if(r._checked=!0,r.setAttribute("checked",""),r._changeHandler){const l=new Event("change",{bubbles:!0});r._changeHandler.call(r,l)}else r._updateVisualState(),r._updateGroupState();const a=r.closest("mint-choice");a&&!n&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:r.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 e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(r=>!r.disabled),t=e.indexOf(this._radio);let i=null;if(t>0?i=e[t-1]:e.length>0&&(i=e[e.length-1]),i){const r=i.closest("mint-choice-option");if(i.checked=!0,r){const n=r._checked;if(r._checked=!0,r.setAttribute("checked",""),r._changeHandler){const l=new Event("change",{bubbles:!0});r._changeHandler.call(r,l)}else r._updateVisualState(),r._updateGroupState();const a=r.closest("mint-choice");a&&!n&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:r.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",ce);class J 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()}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){t!==i&&(e==="error"||e==="error-message"?this._renderErrorState():e==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(r=>{this.isLoading()?r.setAttribute("loading",""):r.removeAttribute("loading")})):(this.render(),e==="name"&&this.querySelectorAll("mint-choice-option").forEach(r=>{typeof r.render=="function"&&r.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 e=this.querySelector('input[type="radio"]:checked');return(e==null?void 0:e.value)||""}setValue(e){const t=this.querySelectorAll("mint-choice-option");t.forEach(i=>{if((i.getAttribute("value")||"")===e){const r=i;r.checked=!0;const n=i.querySelector('input[type="radio"]');n&&(n.checked=!0,n.dispatchEvent(new Event("change",{bubbles:!0})))}else{const r=i;r.checked=!1;const n=i.querySelector('input[type="radio"]');n&&(n.checked=!1)}}),requestAnimationFrame(()=>{t.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const r=i;s.checked!==r.checked&&(s.checked=r.checked)}})})}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const r=this.isDisabled();let n=this.querySelector(".mint-choice-label-container");if(t||i){n||(n=document.createElement("div"),n.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(n,this.firstChild));let o=n.querySelector(".mint-choice-label");t?(o||(o=document.createElement("label"),o.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",n.insertBefore(o,n.firstChild)),o.textContent=t,o.setAttribute("for",s),r?o.classList.add("opacity-40"):o.classList.remove("opacity-40")):o&&o.remove();let d=n.querySelector(".mint-choice-info");i?(d||(d=document.createElement("span"),d.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",n.appendChild(d)),d.textContent=i,r?d.classList.add("opacity-40"):d.classList.remove("opacity-40")):d&&d.remove()}else n&&n.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const o=this.querySelector(".mint-choice-label-container");o&&o.parentElement===this?this.insertBefore(a,o.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(o=>o.tagName==="MINT-CHOICE-OPTION"&&o.parentElement!==this._optionsContainer).forEach(o=>{this._optionsContainer.appendChild(o)}),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(e){if(t||(t=document.createElement("div"),t.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(t):(this.style.position="relative",this.appendChild(t))),t.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let n=0;n<3;n++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const l=document.createElement("div");l.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l);const o=document.createElement("div");o.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o),t.appendChild(a)}t.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else t&&(t.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");e&&t?(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=t):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",J);class X 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.getLabel()||console.error('mint-input: The "label" attribute is required. Please provide a label for the input.'),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(e==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const e=this.getAttribute("rows");return e?parseInt(e,10):3}_getNormalizedType(){const e=this.getType();return e==="datetime"?"datetime-local":e==="money"?"text":e==="textarea"?"textarea":e}_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 e,t,i;return this._isColor()?((e=this._colorPicker)==null?void 0:e.value)||((t=this._colorTextInput)==null?void 0:t.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(e){this._isColor()?(this._colorPicker&&(this._colorPicker.value=e||"#000000"),this._colorTextInput&&(this._colorTextInput.value=e||"#000000")):this._element&&(this._element.value=e),e?this.setAttribute("value",e):this.removeAttribute("value")}get value(){return this.getValue()}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 e=this._isTextarea(),t=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),r=this.hasError(),n=["w-full",t||i?"pl-10":"px-3.5",t||i?"pr-3.5":s?"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",e?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",e?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",r?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],l=["focus-visible:ring-2","focus-visible:ring-offset-1",r?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...n,...a,...l].filter(Boolean).join(" ")}isLoading(){return this.hasAttribute("loading")}render(){var y,x,k,E;this.getType();const e=this._getNormalizedType(),t=this._isTextarea(),i=this._isMoney(),s=this._isColor(),r=this.getPlaceholder(),n=this.isDisabled(),a=this.isReadonly(),l=this.isRequired(),o=this.getId(),d=this.getName(),c=this.getAttribute("value")||(s?"#000000":""),m=this.getRows(),h=this.getIcon(),f=this.getLabel(),u=this.getInfo(),p=this.isLoading();if(this._renderSkeleton(p),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=c||"#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=v=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var C;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((C=this._colorPickerWrapper)==null||C.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 C;const v=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this._colorTextInput&&(this._colorTextInput.value=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("input",{detail:{value:v},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var C;const v=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("change",{detail:{value:v},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=r||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var C;const v=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(v)&&(this._colorPicker&&(this._colorPicker.value=v),this.setAttribute("value",v),this.dispatchEvent(new CustomEvent("input",{detail:{value:v},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var C,A;const v=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(v)?(this._colorPicker&&(this._colorPicker.value=v),this.setAttribute("value",v)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((A=this._colorPicker)==null?void 0:A.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const g=c||"#000000";if(this._colorPicker&&this._colorPicker.value!==g&&(this._colorPicker.value=g),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=g),this._colorTextInput&&this._colorTextInput.value!==g&&(this._colorTextInput.value=g),this._colorPicker&&(this._colorPicker.disabled=n),this._colorPickerWrapper&&(n?(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=n,this._colorTextInput.readOnly=a,this._colorTextInput.required=l),this._colorTextInput){const v=this._colorTextInput;o?v.id=o:v.removeAttribute("id"),d?v.name=d:v.removeAttribute("name"),v.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=v}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&&!t?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()&&!t){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 g=document.createElement("mint-icon");g.setAttribute("name","caret-up"),g.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(g),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 v=document.createElement("mint-icon");v.setAttribute("name","caret-down"),v.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(v),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",C=>{if(C.preventDefault(),C.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,T=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A+T;H!==void 0&&L>H&&(L=H),S!==void 0&&L<S&&(L=S),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",C=>{if(C.preventDefault(),C.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const A=parseFloat(this._input.value)||0,T=parseFloat(this._input.step)||1,S=this._input.min?parseFloat(this._input.min):void 0,H=this._input.max?parseFloat(this._input.max):void 0;let L=A-T;S!==void 0&&L<S&&(L=S),H!==void 0&&L>H&&(L=H),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=n||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=n||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){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=r,this._textarea.disabled=n,this._textarea.readOnly=a,this._textarea.required=l,this._textarea.rows=m,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),c!==this._textarea.value&&(this._textarea.value=c),o?this._textarea.id=o:this._textarea.removeAttribute("id"),d?this._textarea.name=d:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const g=this.firstChild.textContent;g&&!this._textarea.value&&(this._textarea.value=g.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=e,this._input.placeholder=r,this._input.disabled=n,this._input.readOnly=a,this._input.required=l,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")),c!==this._input.value&&(this._input.value=c),o?this._input.id=o:this._input.removeAttribute("id"),d?this._input.name=d:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const g=this.firstChild.textContent;g&&!this._input.value&&(this._input.value=g.trim()),this.removeChild(this.firstChild)}let b=this.querySelector(".mint-input-label-container");if(f||u){b||(b=document.createElement("div"),b.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(b,this._wrapper):this.insertBefore(b,this.firstChild));let g=b.querySelector(".mint-input-label");if(f){g||(g=document.createElement("label"),g.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",b.insertBefore(g,b.firstChild)),g.textContent=f;const C=o||((y=this._element)==null?void 0:y.id)||((x=this._colorTextInput)==null?void 0:x.id)||((k=this._input)==null?void 0:k.id)||((E=this._textarea)==null?void 0:E.id);if(C)g.setAttribute("for",C);else{const A=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=A:this._colorTextInput?this._colorTextInput.id=A:this._input?this._input.id=A:this._textarea&&(this._textarea.id=A),g.setAttribute("for",A)}n?g.classList.add("opacity-40"):g.classList.remove("opacity-40")}else g&&g.remove();let v=b.querySelector(".mint-input-info");u?(v||(v=document.createElement("span"),v.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",b.appendChild(v)),v.textContent=u,n?v.classList.add("opacity-40"):v.classList.remove("opacity-40")):v&&v.remove()}else b&&b.remove();this._renderErrorState(),this._renderSkeleton(p)}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-input-error");e&&t?(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=t):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("input",{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._element.addEventListener("blur",()=>{var t;const e=((t=this._element)==null?void 0:t.value)||"";e?this.setAttribute("value",e):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:e},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 e;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(e=this._element)==null||e.focus()}blur(){var e;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(e=this._element)==null||e.blur()}_renderSkeleton(e){let t=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(e){t||(t=document.createElement("div"),t.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-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 r=this._isTextarea(),n=this.getRows();if(r){const a=n*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";t.appendChild(s)}t.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 t&&(t.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",X);class K 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"]}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 e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){const s=this.hasError(),r=this.getErrorMessage();this._applyErrorVisuals(s,r,this.isDisabled());return}if(e==="loading"){this.render();return}this.render(),this._input&&this._setupPopoverWithRetry()}}getValue(){return this.getAttribute("value")||""}setValue(e){e?(this.setAttribute("value",e),this._textInput&&(this._textInput.value=e),this._parseValue(e)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}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")||""}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const e=this.getAttribute("shortcuts");if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=e.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(r=>({label:r.label,action:typeof r.action=="function"?r.action:this._createShortcutAction(r.action)}))}}return[]}_createShortcutAction(e){return typeof e=="function"?e:typeof e=="string"&&typeof window[e]=="function"?window[e]:()=>null}_getDefaultShortcuts(){const e=[{label:"Today",action:()=>new Date}];return this._isRange&&e.push({label:"This Week",action:()=>{const t=new Date,i=t.getDay(),s=new Date(t);s.setDate(t.getDate()-i),s.setHours(0,0,0,0);const r=new Date(s);return r.setDate(s.getDate()+6),r.setHours(23,59,59,999),{start:s,end:r}}},{label:"This Month",action:()=>{const t=new Date,i=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),e}_getFormatTokens(e){const t=[];let i=0;const s=e.toLowerCase();for(;i<s.length;){const r=s[i];if(r==="d"||r==="m"||r==="y"){let n=1,a=i+1;for(;a<s.length&&s[a]===r;)n++,a++;t.push({type:"part",part:r,len:n}),i=a}else t.push({type:"sep",value:e[i]}),i++}return t}_createPartInput(e,t,i,s,r){const n=document.createElement("input");return n.type="text",n.inputMode="numeric",n.pattern="\\d*",n.maxLength=e,n.placeholder=t,n.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",n.disabled=i||s,n.readOnly=s,n.required=r,e===4?n.className+=" w-[40px]":e===2&&(n.className+=" w-[30px]"),n}_buildValueFromParts(e,t){let i=0;return t.map(s=>{var n;if(s.type==="sep")return s.value;const r=((n=e[i])==null?void 0:n.value)||"";return i++,r}).join("")}_applyDateToParts(e,t,i,s){if(!t.length)return;if(!e){t.forEach(l=>l.value="");return}const r=this._formatDate(e,s);let n=0,a=0;i.forEach(l=>{if(l.type==="sep")n+=l.value.length;else{const o=r.substr(n,l.len);t[a]&&(t[a].value=o),a++,n+=l.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const e=this.getFormat(),t=this._getFormatTokens(e),i=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(e,t){if(t+1<e.length){const i=e[t+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(e,t){if(t-1>=0){const i=e[t-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(e,t,i){e.forEach((s,r)=>{const n=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,n),s.value.length>=n&&this._focusNext(e,r),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(e,r),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(e,r),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(e,r),a.preventDefault())}),s.addEventListener("blur",a=>{var d,c;this._syncHiddenInput();const l=a.relatedTarget;l&&(this.contains(l)||(d=this._popover)!=null&&d.contains(l)||this._calendarContainer&&this._calendarContainer.contains(l))||(this._handleBlur(((c=this._hiddenInput)==null?void 0:c.value)||""),this._exitInputMode(),setTimeout(()=>{if(this._hiddenInput){const m=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(m)}},0))})})}_splitRangeInput(e,t){const i=e.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[e]}_parseValue(e){const t=this.getFormat(),i=this._getFormatTokens(t);if(this._isRange){const[s,r]=this._splitRangeInput(e,t),n=s?this._parseDateString(s,t):null,a=r?this._parseDateString(r,t):null;if(n&&a){const[l,o]=n<=a?[n,a]:[a,n];this._selectedStartDate=l,this._selectedEndDate=o,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else n&&(this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,t)}else{const s=this._parseDateString(e,t);s&&!isNaN(s.getTime())?(this._selectedStartDate=s,this._selectedEndDate=null,this._currentMonth=s.getMonth(),this._currentYear=s.getFullYear(),this._applyDateToParts(s,this._startPartInputs,i,t)):this._applyDateToParts(null,this._startPartInputs,i,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){const i=/[\/\-\.\s]+/;if(i.test(e)){const p=e.split(i).filter(b=>b.length>0),_=t.split(/[\/\-\.\s]+/).filter(b=>b.length>0);if(p.length===_.length){let b=0,y=0,x=0;for(let k=0;k<_.length;k++){const E=_[k].toLowerCase(),g=p[k];if(E.includes("d"))b=parseInt(g,10);else if(E.includes("m"))y=parseInt(g,10)-1;else if(E.includes("y")){let v=parseInt(g,10);const C=E.length,A=g.length;A===2&&C===4?v=Math.floor(new Date().getFullYear()/100)*100+v:A===2&&C===2&&(v=Math.floor(new Date().getFullYear()/100)*100+v),x=v}}if(b&&y>=0&&y<=11&&x){const k=new Date(x,y,b);if(!isNaN(k.getTime())&&k.getDate()===b&&k.getMonth()===y&&k.getFullYear()===x)return k}}}const r=e.replace(/[\/\-\.]/g,""),n=t.replace(/[\/\-\.]/g,"").toLowerCase();let a=n.indexOf("d"),l=n.indexOf("m"),o=n.indexOf("y");const d=[{char:"d",index:a},{char:"m",index:l},{char:"y",index:o}].sort((p,_)=>p.index-_.index);let c=0,m=0,h=0,f=0;n.length,r.length;for(const p of d)if(p.char==="d"){const _=n.lastIndexOf("d")-n.indexOf("d")+1,b=r.substr(f,_);if(b.length===0)return null;c=parseInt(b,10),f+=b.length}else if(p.char==="m"){const _=n.lastIndexOf("m")-n.indexOf("m")+1,b=r.substr(f,_);if(b.length===0)return null;m=parseInt(b,10)-1,f+=b.length}else if(p.char==="y"){const _=n.lastIndexOf("y")-n.indexOf("y")+1,b=r.substr(f),y=Math.min(_,b.length),x=b.substr(0,y);if(x.length===0)return null;let k=parseInt(x,10);y===2&&_===4?k=Math.floor(new Date().getFullYear()/100)*100+k:y===2&&_===2&&(k=Math.floor(new Date().getFullYear()/100)*100+k),h=k,f+=y}if(!c||m<0||m>11||!h)return null;const u=new Date(h,m,c);return isNaN(u.getTime())||u.getDate()!==c||u.getMonth()!==m||u.getFullYear()!==h?null:u}_formatDate(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=t.toLowerCase();let a=t;return n.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):n.includes("d")&&(a=a.replace(/d/gi,String(i))),n.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):n.includes("m")&&(a=a.replace(/m/gi,String(s))),n.includes("yyyy")?a=a.replace(/yyyy/gi,String(r)):n.includes("yy")&&(a=a.replace(/yy/gi,String(r).substr(2))),a}_formatDatePhp(e,t){const i=e.getDate(),s=e.getMonth()+1,r=e.getFullYear(),n=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],l=["January","February","March","April","May","June","July","August","September","October","November","December"],o=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],d=(h,f=2)=>h.toString().padStart(f,"0"),c=h=>{const f=h%10,u=h%100;return f===1&&u!==11?"st":f===2&&u!==12?"nd":f===3&&u!==13?"rd":"th"};let m="";for(let h=0;h<t.length;h++){const f=t[h];if(f==="\\"&&h+1<t.length){m+=t[h+1],h++;continue}switch(f){case"Y":m+=r.toString();break;case"y":m+=r.toString().slice(-2);break;case"m":m+=d(s);break;case"n":m+=s.toString();break;case"M":m+=o[s-1];break;case"F":m+=l[s-1];break;case"d":m+=d(i);break;case"j":m+=i.toString();break;case"D":m+=a[e.getDay()];break;case"l":m+=n[e.getDay()];break;case"S":m+=c(i);break;default:m+=f;break}}return m}_validateDateString(e,t){const i=this._parseDateString(e,t);return i!==null&&!isNaN(i.getTime())}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getInfo(),s=this.getValue(),r=this.isDisabled(),n=this.isReadonly(),a=this.isRequired(),l=this.getId(),o=this.getName(),d=this.getFormat(),c=this.hasError(),m=this.getErrorMessage();this._isRange=this.isRange(),this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let h=this.querySelector(".mint-date-picker-label-container");if(t||i){h||(h=document.createElement("div"),h.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(h,this._input):this.appendChild(h));let y=h.querySelector(".mint-date-picker-label");t?(y||(y=document.createElement("label"),y.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",h.insertBefore(y,h.firstChild)),y.textContent=t,l&&this._textInput&&y.setAttribute("for",l)):y&&y.remove();let x=h.querySelector(".mint-date-picker-info");i?(x||(x=document.createElement("span"),x.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",h.appendChild(x)),x.textContent=i):x&&x.remove()}else h&&h.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)),l&&(this._hiddenInput.id=l),o&&(this._hiddenInput.name=o),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",c?"true":"false");let f=this._input.querySelector(".mint-date-fields");f||(f=document.createElement("div"),this._input.appendChild(f)),this._fieldsContainer=f,this._applyErrorVisuals(c,m,r),f.innerHTML="",this._displayEl=document.createElement("div");const u=n?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${n?"cursor-default":"cursor-text"} ${u} focus:outline-none`,this._displayEl.tabIndex=r||n?-1:0,this._displayEl.addEventListener("click",()=>{r||n||this._enterInputMode()}),this._displayEl.addEventListener("keydown",y=>{r||n||(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._inputsWrapperEl.className="flex items-center gap-1 w-full";const p=this._getFormatTokens(d);this._startPartInputs=[],this._endPartInputs=[];const _=y=>{const x=document.createDocumentFragment();return p.forEach(k=>{if(k.type==="sep"){const E=document.createElement("span");E.textContent=k.value,E.className="text-gray-400 dark:text-gray-500 select-none",x.appendChild(E)}else{const E=k.part==="d"?"dd":k.part==="m"?"mm":k.len===2?"yy":"yyyy",g=this._createPartInput(k.len,E,r,n,a);y==="start"?this._startPartInputs.push(g):this._endPartInputs.push(g),x.appendChild(g)}}),x};if(this._inputsWrapperEl.appendChild(_("start")),this._isRange){const y=document.createElement("span");y.textContent=" - ",y.className="text-gray-400 dark:text-gray-500 select-none",this._inputsWrapperEl.appendChild(y),this._inputsWrapperEl.appendChild(_("end"))}const b=document.createElement("div");if(b.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",b.appendChild(this._displayEl),b.appendChild(this._inputsWrapperEl),f.appendChild(b),f.addEventListener("click",()=>{this._isInputMode||r||n||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,p,f),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,p,f),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=r||n,!r&&!n?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 y=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=y;const x=document.createElement("mint-icon");x.setAttribute("name","calendar"),x.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(x),this._iconButton.addEventListener("click",()=>{r||n||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=r||n}this._renderErrorState(c,m),this._renderSkeleton(e)}_renderErrorState(e,t){let i=this.querySelector(".mint-date-picker-error");e&&t?(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=t):i&&i.remove()}_applyErrorVisuals(e,t,i){if(this._renderErrorState(e,t),this._fieldsContainer){const s=this._getFieldContainerClass(e,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",e?"true":"false")}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},e.addEventListener("reset",this._resetHandler))}_clearPartInputs(e){e.forEach(t=>{t.value=""})}_getFieldContainerClass(e,t){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",e?"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",e?"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(" ")+(t?" opacity-40 cursor-not-allowed":"")}_handleInputChange(e){}_cleanInputValue(e,t){return e}_handleBlur(e){const t=this.getFormat();if(!e){this.setValue(""),this._updateDisplayText();return}if(this._isRange){const[i,s]=this._splitRangeInput(e,t),r=i?this._parseDateString(i,t):null,n=s?this._parseDateString(s,t):null;if(r&&n){const[a,l]=r<=n?[r,n]:[n,r],o=this._formatDate(a,t),d=this._formatDate(l,t),c=`${o} - ${d}`;this.setValue(c),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(l,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=a,this._selectedEndDate=l,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else if(r){const a=this._formatDate(r,t);this.setValue(a),this._applyDateToParts(r,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){const i=this._parseDateString(e,t);if(i){const s=this._formatDate(i,t);this.setValue(s),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=i,this._selectedEndDate=null,this._currentMonth=i.getMonth(),this._currentYear=i.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(e=0){if(!this._iconButton){e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)});return}const t=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)}):e<t&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(!e)return;if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},50);return}if(!this._popover)this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0"),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",e),this._popoverObserver||(this._popoverObserver=new MutationObserver(i=>{i.forEach(s=>{var r;if(s.type==="attributes"&&s.attributeName==="open")if((r=this._popover)==null?void 0:r.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const a=this._popover;typeof a.render=="function"&&a.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var a;(a=this._iconButton)==null||a.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const a=new Date;this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var l;const a=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(l=this._hiddenInput)==null||l.dispatchEvent(a)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:["open"]})),requestAnimationFrame(()=>{this._buildCalendar()}))})});else{if(this._popover.getAttribute("trigger-id")!==e){this._popover.setAttribute("trigger-id",e);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 e=this._popover.querySelector(".popover-content");if(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=this.getShortcuts(),n=r.length>0;this._calendarContainer.className=n?"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 a=document.createElement("div");a.className="flex flex-col md:flex-row md:gap-6 md:items-start";const l=document.createElement("div");l.className="flex-1 min-w-0";const o=document.createElement("div");o.className="flex items-center justify-between mb-4";const d=document.createElement("button");d.type="button",d.tabIndex=0,d.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",d.setAttribute("data-keep-popover-open","true");const c=document.createElement("mint-icon");c.setAttribute("name","caret-left"),c.className="w-4 h-4",d.appendChild(c),d.addEventListener("click",()=>{this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar()}),o.appendChild(d);const m=document.createElement("div");m.className="flex items-center gap-2";const h=document.createElement("button");h.type="button",h.tabIndex=0,h.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",h.setAttribute("data-keep-popover-open","true"),h.textContent=i[this._currentMonth],h.addEventListener("click",()=>{this._viewMode="month",this._buildCalendar()}),m.appendChild(h);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=String(this._currentYear),f.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),m.appendChild(f),o.appendChild(m);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 p=document.createElement("mint-icon");p.setAttribute("name","caret-right"),p.className="w-4 h-4",u.appendChild(p),u.addEventListener("click",()=>{this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar()}),o.appendChild(u);const _=document.createElement("div");_.className="grid grid-cols-7 mb-2",s.forEach(k=>{const E=document.createElement("div");E.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",E.textContent=k,_.appendChild(E)});const b=document.createElement("div");b.className="grid grid-cols-7";for(let k=0;k<t;k++){const E=document.createElement("div");E.className="w-8 h-8",b.appendChild(E)}const y=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,x=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;for(let k=1;k<=e;k++){const E=new Date(this._currentYear,this._currentMonth,k),g=this._isToday(E),v=this._isDateSelected(E),C=this._isDateInRange(E),A=y&&E<y||x&&E>x;let T="rounded-md";if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){const H=this._isSameDate(E,this._selectedStartDate),L=this._isSameDate(E,this._selectedEndDate);H&&L?T="rounded-md":H?T="rounded-l-md":L?T="rounded-r-md":C&&(T="rounded-none")}else v&&!this._isRange&&(T="rounded-md");const S=document.createElement("button");S.type="button",S.disabled=!!A,S.tabIndex=A?-1:0,S.className=`w-full h-8 ${T} 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 ${v?"bg-slate-800 dark:bg-slate-600 text-white":C?"bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":g?"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"} ${A?"opacity-40 cursor-not-allowed":""}`,S.textContent=k.toString(),A||S.addEventListener("click",()=>{this._handleDateClick(E)}),b.appendChild(S)}if(n){const k=document.createElement("div");k.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 E=document.createElement("div");E.className="relative md:relative md:flex-1 md:min-h-0";const g=document.createElement("div");g.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",g.style.scrollbarWidth="none",g.style.msOverflowStyle="none",g.style.setProperty("-webkit-overflow-scrolling","touch");const v=document.createElement("style");v.textContent=`
45
45
  .mint-date-shortcuts-row::-webkit-scrollbar {
46
46
  display: none;
47
47
  }
@@ -65,7 +65,7 @@
65
65
  background: rgba(255, 255, 255, 0.2);
66
66
  }
67
67
  }
68
- `,g.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(v.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(v));const C=document.createElement("div");C.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",E.appendChild(C);const A=document.createElement("div");A.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",E.appendChild(A);const T=document.createElement("div");T.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",E.appendChild(T);const S=document.createElement("div");S.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=g.scrollTop,I=g.scrollHeight,N=g.clientHeight;D>0?T.style.opacity="1":T.style.opacity="0",D+N<I-1?S.style.opacity="1":S.style.opacity="0",C.style.opacity="0",A.style.opacity="0"}else{const D=g.scrollLeft,I=g.scrollWidth,N=g.clientWidth;D>0?C.style.opacity="1":C.style.opacity="0",D+N<I-1?A.style.opacity="1":A.style.opacity="0",T.style.opacity="0",S.style.opacity="0"}};g.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),r.forEach(L=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const I=L.action();if(I){if(this._isRange&&"start"in I&&"end"in I){this._selectedStartDate=I.start,this._selectedEndDate=I.end;const N=this.getFormat(),M=this._formatDate(I.start,N),ae=this._formatDate(I.end,N),oe=`${M} - ${ae}`;this.setValue(oe),this._currentMonth=I.start.getMonth(),this._currentYear=I.start.getFullYear()}else if(I instanceof Date){this._selectedStartDate=I,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(I,N);this.setValue(M),this._currentMonth=I.getMonth(),this._currentYear=I.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),g.appendChild(D)}),E.appendChild(g),k.appendChild(E),a.appendChild(k)}l.appendChild(o),l.appendChild(_),l.appendChild(b),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,d)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentMonth===d;c.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=d,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",a.appendChild(l),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2";for(let d=e;d<=t;d++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentYear===d;c.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,c.textContent=String(d),c.addEventListener("click",()=>{this._currentYear=d,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}_updateDisplayText(){if(!this._displayEl)return;const e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(e){let t=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(e){t||(t=document.createElement("div"),t.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let r=t.querySelector(".mint-date-picker-skeleton");r||(r=document.createElement("div"),r.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",r.style.height="2.25rem",t.appendChild(r)),t.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else t&&(t.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const e=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(e)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",K);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="loading"){this.render();return}if(e==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(e){const t=e||"";this.setAttribute("value",t),this._select&&(this._select.value=t)}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"pr-10",t?"py-2":"py-1.5",t?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...r].filter(Boolean).join(" ")}render(){const e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&t.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),r=this.getInfo(),n=this.getId(),a=this.getName(),l=this.getValue(),o=this.isDisabled(),d=this.isMultiple(),c=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",n&&h.setAttribute("for",n);const f=document.createTextNode(s);h.appendChild(f),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),n&&(this._select.id=n),a&&(this._select.name=a),o&&(this._select.disabled=!0),d&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",c?"true":"false");const m=t.length>0?t:i;if(m.length>0&&m.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=l||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const u=h.target.value;u?this.setAttribute("value",u):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:u},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),d)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(r){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=r,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(e){t||(t=document.createElement("div"),t.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const r=this.isMultiple();s.style.height=r?"6rem":"2.25rem",t.appendChild(s)}t.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else t&&(t.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(e){let t=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(e){t||(t=document.createElement("div"),t.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),l=this._fileInput;if(r){const o=r;o.style.visibility="hidden",o.style.pointerEvents="none"}if(n){const o=n;o.style.visibility="hidden",o.style.pointerEvents="none"}if(a){const o=a;o.style.visibility="hidden",o.style.pointerEvents="none"}l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(t&&(t.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),n=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const l=s;l.style.visibility="visible",l.style.pointerEvents="auto"}if(r){const l=r;l.style.visibility="visible",l.style.pointerEvents="auto"}if(n){const l=n;l.style.visibility="visible",l.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),r=this.isDisabled(),n=this.getWidth(),a=this.getHeight(),l=this.getName(),o=this.hasError(),d=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",o?"true":"false"),r?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",t||"File upload dropzone")),this._dropzone.style.width=n,this._dropzone.style.height=a,this._dropzone.style.minWidth=n,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=r,l?this._fileInput.name=l:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",o?"true":"false");const c=this._dropzone.querySelector(".mint-dropzone-icon"),m=this._dropzone.querySelector(".mint-dropzone-label");c&&c.remove(),m&&m.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const f=document.createElement("mint-icon");if(f.setAttribute("name","upload"),f.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(f),this._dropzone.appendChild(h),t){const u=document.createElement("div");u.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",u.textContent=t,this._dropzone.appendChild(u)}this.setupEventListeners(),this._renderErrorState(o,d),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,n=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"",o="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${r} ${t?a:n} ${l} ${o}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onKeyDown||(this._onKeyDown=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onFocus||(this._onFocus=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=e=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.splice(1)),a.length>0){const l=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(l)}n.length>0&&this._applyValidFiles(n)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((o,d)=>{const c=document.createElement("div");if(c.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",o.type.startsWith("image/")){const u=document.createElement("img");u.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const p=URL.createObjectURL(o);this._previewUrls.push(p),u.src=p,c.appendChild(u)}else{const u=document.createElement("mint-icon");u.setAttribute("name","attach"),u.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(u)}const m=document.createElement("div");m.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",m.textContent=o.name,c.appendChild(m);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",h.appendChild(f),h.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this._removeFileAt(d)}),c.appendChild(h),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,d=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<d-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class ee extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const e=this.getAttribute("headers");e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._applyFormData();else{const t=this.getAttribute("data-form-data");t&&(this._parseFormData(t),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){e==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e==="headers"?this._parseHeaders(i):e==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){e&&typeof e=="object"&&!Array.isArray(e)?this._formData=e:e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e=="object"&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const a=this.getAttribute("action"),l=this.getAttribute("method");if(!(!a||!l)){this._setButtonsSubmitting();try{const o=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:o,bubbles:!0,cancelable:!0}))}catch(o){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:o},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){var c,m,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(f=>f instanceof File);let a=null;const l={};let o=i;if(typeof window<"u"&&((h=(m=(c=window.mintForm)==null?void 0:c.defaults)==null?void 0:m.headers)!=null&&h.common)&&Object.assign(l,window.mintForm.defaults.headers.common),this._headers&&Object.assign(l,this._headers),s==="GET"){const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),o+=(i.includes("?")?"&":"?")+f.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),a=f,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const f=await fetch(o,{method:s||"POST",body:s==="GET"?null:a,headers:l}),u=await f.text().catch(()=>"");let p=u;try{p=JSON.parse(u)}catch{}if(!f.ok){const b={status:f.status,data:p,response:{status:f.status,data:p}};throw await this._applyErrorInterceptors(b)}const _={status:f.status,ok:f.ok,data:p};return await this._applySuccessInterceptors(_)}catch(f){if(f.response)throw f;const u={status:f.status||0,data:f.data||f.message||"Network error",response:{status:f.status||0,data:f.data||f.message||"Network error"}};throw await this._applyErrorInterceptors(u)}const d=this;return await new Promise(async(f,u)=>{const p=new XMLHttpRequest;p.open(s||"POST",o,!0),Object.entries(l).forEach(([_,b])=>p.setRequestHeader(_,b)),p.onload=async function(){const{status:_,responseText:b}=p;if(_>=200&&_<300){let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,ok:!0,data:y},k=await d._applySuccessInterceptors(x);f(k)}catch(x){u(x)}}else{let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,data:y,response:{status:_,data:y}},k=await d._applyErrorInterceptors(x);u(k)}catch(x){u(x)}}},p.onerror=async function(){try{const _={status:p.status||0,data:p.responseText||"Network error",response:{status:p.status||0,data:p.responseText||"Network error"}},b=await d._applyErrorInterceptors(_);u(b)}catch(_){u(_)}},p.send(s==="GET"?null:a)})}async _applySuccessInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return e;let t=e;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(t=await a.fulfilled(t));return t}async _applyErrorInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return Promise.reject(e);let t=e;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const l=i[a];if(l.rejected)try{if(t=await l.rejected(t),t!==void 0)return t}catch(o){t=o}}return Promise.reject(t)}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(n=>{const a=n.getAttribute("name");if(a&&typeof n.files<"u"&&n.files){const l=n.files;if(l.length>0){const o=Array.from(l);t[a]&&Array.isArray(t[a])?o.forEach(d=>{t[a].some(m=>m.name===d.name&&m.size===d.size&&m.lastModified===d.lastModified)||t[a].push(d)}):t[a]=o}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(n=>{const a=n.name;if(a&&n.files&&n.files.length>0){const l=Array.from(n.files);t[a]&&Array.isArray(t[a])?l.forEach(o=>{t[a].some(c=>c.name===o.name&&c.size===o.size&&c.lastModified===o.lastModified)||t[a].push(o)}):t[a]=l}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(n=>{const a=n.getAttribute("name");if(a){let l=[];if(typeof n.tags<"u"?l=n.tags:typeof n.getTags=="function"&&(l=n.getTags()),Array.isArray(l)&&l.length>0){const o=l.map(d=>typeof d=="string"?d:(d==null?void 0:d.value)||(d==null?void 0:d.label)||"").filter(d=>d.trim()!=="");t[a]=o}else t[a]=[]}})),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(n=>n.tagName==="MINT-SELECT");if(i.length>0){const n=[];return i.forEach(a=>{const l=a.querySelector('select[name="'+e+'"]');l&&n.push(l)}),t.filter(a=>a.tagName!=="MINT-SELECT").concat(n)}if(t.filter(n=>n.tagName==="MINT-TAGS").length>0)return t.filter(n=>n.tagName!=="INPUT"||!n.closest("mint-tags"));const r=t.filter(n=>n.tagName==="INPUT"&&n.closest("mint-tags"));if(r.length>0){const n=[];return r.forEach(a=>{const l=a.closest("mint-tags");l&&!n.includes(l)&&n.push(l)}),t.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(n)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===e.length){const a=s.filter(l=>l.checked);if(s.every(l=>l.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(l=>l.type==="checkbox"))return a.map(l=>l.value||"on")}const r=e.filter(a=>a.tagName==="MINT-CHOICE");if(r.length>0&&r.length===e.length){const a=r.find(l=>typeof l.getValue=="function"?l.getValue()!=="":l.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const l=a.querySelector("mint-choice-option[checked]");if(l)return l.getAttribute("value")||""}return""}const n=e.filter(a=>a.tagName==="MINT-CHECKBOX");if(n.length>0&&n.length===e.length)return n.filter(l=>typeof l.checked<"u"?l.checked:l.hasAttribute("checked")).map(l=>l.getAttribute("value")||"on")}const i=e[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(n=>typeof n=="string"?n:(n==null?void 0:n.value)||(n==null?void 0:n.label)||"").filter(n=>n.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(e,t){e.length!==0&&e.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e=="object"&&!Array.isArray(e)){this._formData=e;return}if(typeof e=="string")try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const e=()=>{Object.entries(this._formData).forEach(([t,i])=>{const s=this._getFieldElements(t);if(s.length===0){setTimeout(()=>{const r=this._getFieldElements(t);r.length>0&&this._applyValueToField(r,t,i)},300);return}this._applyValueToField(s,t,i)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(e,t,i){e.forEach(s=>{var n;const r=s.tagName;try{if(r==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(r==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-SELECT"||r==="SELECT")r==="SELECT"?(n=s.closest("mint-select"))==null||n.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(l=>{l.checked=l.getAttribute("value")===i});else if(r==="MINT-CHECKBOX"||r==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else r==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${t}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof t.checked<"u")t.checked=!1;else{t.removeAttribute("checked");const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof t.setValue=="function"?t.setValue(""):t.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{t.tags=[]}catch{}})}_resolveHost(e){if(e.tagName==="MINT-CHOICE-OPTION"){const i=e.closest("mint-choice");if(i)return i}const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),d=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),c=!!r.closest("mint-tags"),m=r.tagName==="MINT-CHECKBOX"||r.tagName==="MINT-SWITCH"||r.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=r.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(o||d||c||m||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}const a=this._findFieldElement(s);if(!a)return;const l=this._getFieldName(a);!l||!this._collectValidationRules()[l]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(l)},0)};this._form.addEventListener("change",t,!0),this._form.addEventListener("tags-change",t,!0),this._form.addEventListener("choice-change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener("change",e,!0),this._form.removeEventListener("tags-change",e,!0),this._form.removeEventListener("choice-change",e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const e=this.getAttribute("loading"),t=e!==null&&e!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{t?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=i.hasAttribute("disabled"),r=i.hasAttribute("loading");this._buttonStates.set(i,{disabled:s,loading:r});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled",""),a&&i.setAttribute("loading",""),typeof i.render=="function"&&i.render()}),t.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled",""):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading",""):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),t.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}}customElements.get("mint-form")||customElements.define("mint-form",ee);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(w,e){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:e}),window.mintForm.interceptors.response.handlers.length-1}));class te extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto","border","border-gray-200","rounded-lg","dark:border-gray-700"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const e=this.querySelector("table");if(!e){this._observer&&this._observeChanges();return}const t=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],r=e.querySelector("thead tr");r&&r.querySelectorAll("th").forEach(d=>s.push((d.textContent||"").trim())),this._setClasses(e,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","rounded-lg","border-2","border-gray-200","dark:border-gray-700","overflow-hidden"]);const n=e.querySelector("thead");n&&(this._setClasses(n,["bg-[#F7F7F7]","dark:bg-gray-800"]),n.querySelectorAll("th").forEach(d=>{this._setClasses(d,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"])}));const a=e.querySelector("tbody");if(a){const o=Array.from(a.querySelectorAll("tr"));o.forEach((d,c)=>{this._setClasses(d,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),c===o.length-1&&d.classList.remove("border-b"),d.querySelectorAll("td").forEach(h=>{this._setClasses(h,["text-gray-900","dark:text-gray-100","px-3","py-2"]),t?this._applyMobileCell(h,s):this._restoreCell(h)})})}const l=e.querySelector("tfoot");l&&(this._setClasses(l,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(d=>{this._setClasses(d,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(d)})),this._observer&&this._observeChanges()}_applyMobileCell(e,t){if(e.closest("tfoot")||e.dataset.mtProcessed==="true")return;const i=t[e.cellIndex]||"",s=e.getAttribute("data-original"),r=s!==null?s:e.innerHTML;e.setAttribute("data-original",r),e.dataset.mtProcessed="true",e.innerHTML="";const n=document.createElement("span");n.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",n.textContent=i;const a=document.createElement("span");a.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",a.innerHTML=r,e.appendChild(n),e.appendChild(a)}_restoreCell(e){if(e.dataset.mtProcessed!=="true")return;const t=e.getAttribute("data-original")||"";e.dataset.mtProcessed="",e.innerHTML=t}_setClasses(e,t){e.className="",t.filter(Boolean).forEach(i=>e.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const e=document.createElement("style");e.id="mint-table-responsive-style",e.textContent=`
68
+ `,g.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(v.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(v));const C=document.createElement("div");C.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",E.appendChild(C);const A=document.createElement("div");A.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",E.appendChild(A);const T=document.createElement("div");T.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",E.appendChild(T);const S=document.createElement("div");S.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",E.appendChild(S);const H=()=>{if(window.innerWidth>=768){const D=g.scrollTop,I=g.scrollHeight,N=g.clientHeight;D>0?T.style.opacity="1":T.style.opacity="0",D+N<I-1?S.style.opacity="1":S.style.opacity="0",C.style.opacity="0",A.style.opacity="0"}else{const D=g.scrollLeft,I=g.scrollWidth,N=g.clientWidth;D>0?C.style.opacity="1":C.style.opacity="0",D+N<I-1?A.style.opacity="1":A.style.opacity="0",T.style.opacity="0",S.style.opacity="0"}};g.addEventListener("scroll",H),window.addEventListener("resize",H),setTimeout(H,0),r.forEach(L=>{const D=document.createElement("button");D.type="button",D.tabIndex=0,D.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",D.textContent=L.label,D.setAttribute("data-keep-popover-open","true"),D.addEventListener("click",()=>{const I=L.action();if(I){if(this._isRange&&"start"in I&&"end"in I){this._selectedStartDate=I.start,this._selectedEndDate=I.end;const N=this.getFormat(),M=this._formatDate(I.start,N),ae=this._formatDate(I.end,N),oe=`${M} - ${ae}`;this.setValue(oe),this._currentMonth=I.start.getMonth(),this._currentYear=I.start.getFullYear()}else if(I instanceof Date){this._selectedStartDate=I,this._selectedEndDate=null;const N=this.getFormat(),M=this._formatDate(I,N);this.setValue(M),this._currentMonth=I.getMonth(),this._currentYear=I.getFullYear()}this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}}),g.appendChild(D)}),E.appendChild(g),k.appendChild(E),a.appendChild(k)}l.appendChild(o),l.appendChild(_),l.appendChild(b),a.appendChild(l),this._calendarContainer.appendChild(a)}_buildMonthView(){if(!this._calendarContainer)return;const e=["January","February","March","April","May","June","July","August","September","October","November","December"],t=document.createElement("div");t.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s),i.addEventListener("click",()=>{this._currentYear--,this._buildCalendar()}),t.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear),r.addEventListener("click",()=>{this._viewMode="year",this._buildCalendar()}),t.appendChild(r);const n=document.createElement("button");n.type="button",n.tabIndex=0,n.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",n.setAttribute("data-keep-popover-open","true");const a=document.createElement("mint-icon");a.setAttribute("name","caret-right"),a.className="w-4 h-4",n.appendChild(a),n.addEventListener("click",()=>{this._currentYear++,this._buildCalendar()}),t.appendChild(n);const l=document.createElement("div");l.className="grid grid-cols-3 gap-2",e.forEach((o,d)=>{const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentMonth===d;c.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,c.textContent=o,c.addEventListener("click",()=>{this._currentMonth=d,this._viewMode="calendar",this._buildCalendar()}),l.appendChild(c)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(l)}_buildYearView(){if(!this._calendarContainer)return;const e=this._currentYear-6,t=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const r=document.createElement("mint-icon");r.setAttribute("name","caret-left"),r.className="w-4 h-4",s.appendChild(r),s.addEventListener("click",()=>{this._currentYear-=12,this._buildCalendar()}),i.appendChild(s);const n=document.createElement("div");n.className="text-sm font-medium text-gray-900 dark:text-gray-100",n.textContent=`${e} - ${t}`,i.appendChild(n);const a=document.createElement("button");a.type="button",a.tabIndex=0,a.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",a.setAttribute("data-keep-popover-open","true");const l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",a.appendChild(l),a.addEventListener("click",()=>{this._currentYear+=12,this._buildCalendar()}),i.appendChild(a);const o=document.createElement("div");o.className="grid grid-cols-3 gap-2";for(let d=e;d<=t;d++){const c=document.createElement("button");c.type="button",c.tabIndex=0,c.setAttribute("data-keep-popover-open","true");const m=this._currentYear===d;c.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,c.textContent=String(d),c.addEventListener("click",()=>{this._currentYear=d,this._viewMode="calendar",this._buildCalendar()}),o.appendChild(c)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(o)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){return new Date(t,e,1).getDay()}_isToday(e){const t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){return this._isRange?this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)||this._selectedEndDate!==null&&this._isSameDate(e,this._selectedEndDate):this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){return!this._isRange||!this._selectedStartDate||!this._selectedEndDate?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(e,t){return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_handleDateClick(e){const t=this.getFormat();if(this._isRange){if(!this._selectedStartDate||this._selectedStartDate&&this._selectedEndDate?(this._selectedStartDate=e,this._selectedEndDate=null):this._selectedStartDate&&!this._selectedEndDate&&(e<this._selectedStartDate?(this._selectedEndDate=this._selectedStartDate,this._selectedStartDate=e):this._selectedEndDate=e),this._selectedStartDate&&this._selectedEndDate){const i=this._formatDate(this._selectedStartDate,t),s=this._formatDate(this._selectedEndDate,t),r=`${i} - ${s}`;this.setValue(r),this._textInput&&(this._textInput.value=r),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._selectedStartDate){const i=this._formatDate(this._selectedStartDate,t);this.setValue(i),this._textInput&&(this._textInput.value=i)}}else{this._selectedStartDate=e;const i=this._formatDate(e,t);this.setValue(i),this._textInput&&(this._textInput.value=i),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode(),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0}))}_updateDisplayText(){if(!this._displayEl)return;const e=this.getDisplayFormat();let t="";this._isRange?this._selectedStartDate&&this._selectedEndDate?t=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)):this._selectedStartDate&&(t=this._formatDatePhp(this._selectedStartDate,e)),t?(this._displayEl.textContent=t,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const e=this._startPartInputs[0];requestAnimationFrame(()=>{e.focus();try{e.setSelectionRange(0,e.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(e){let t=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(e){t||(t=document.createElement("div"),t.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let r=t.querySelector(".mint-date-picker-skeleton");r||(r=document.createElement("div"),r.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",r.style.height="2.25rem",t.appendChild(r)),t.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else t&&(t.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const e=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(e)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const e=this;this._focusTrapHandler=function(t){var l;if(t.key!=="Tab")return;if(!e._popover||!e._popover.hasAttribute("open")){e._removeFocusTrap();return}const i=e._getFocusableElements();if(i.length===0)return;const s=i[0],r=i[i.length-1],n=document.activeElement;if(!(((l=e._calendarContainer)==null?void 0:l.contains(n))||!1)){t.preventDefault(),s.focus();return}if(t.shiftKey&&n===s){t.preventDefault(),r.focus();return}if(!t.shiftKey&&n===r){t.preventDefault(),s.focus();return}},this._escapeHandler=function(t){(t.key==="Escape"||t.key==="Esc")&&e._popover&&e._popover.hasAttribute("open")&&(t.preventDefault(),t.stopPropagation(),typeof e._popover.close=="function"&&e._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const t=this._getFocusableElements();t.length>0&&t[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",K);class Z extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render()}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null)}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(e==="loading"){this.render();return}if(e==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(e){const t=e||"";this.setAttribute("value",t),this._select&&(this._select.value=t)}isDisabled(){return this.hasAttribute("disabled")}isMultiple(){return this.hasAttribute("multiple")}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}getId(){return this.getAttribute("id")||""}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getSelectClasses(){const e=this.hasError(),t=this.isMultiple(),i=["w-full","px-3.5",t?"pr-3.5":"pr-10",t?"py-2":"py-1.5",t?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-700","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",e?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-600"],r=["focus-visible:ring-2","focus-visible:ring-offset-1",e?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...r].filter(Boolean).join(" ")}render(){const e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(h=>{(h.tagName==="OPTION"||h.tagName==="OPTGROUP")&&t.push(h.cloneNode(!0))});const i=Array.from(this.children).filter(h=>h.tagName==="OPTION"||h.tagName==="OPTGROUP").map(h=>h.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),r=this.getInfo(),n=this.getId(),a=this.getName(),l=this.getValue(),o=this.isDisabled(),d=this.isMultiple(),c=this.hasError();if(s){const h=document.createElement("label");h.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",n&&h.setAttribute("for",n);const f=document.createTextNode(s);h.appendChild(f),this.appendChild(h)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),n&&(this._select.id=n),a&&(this._select.name=a),o&&(this._select.disabled=!0),d&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",c?"true":"false");const m=t.length>0?t:i;if(m.length>0&&m.forEach(h=>{this._select.appendChild(h)}),this._select.options.length===0){const h=document.createElement("option");h.value="",h.textContent="Select an option",h.disabled=!0,h.selected=!0,this._select.appendChild(h)}if(this._select.value=l||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=h=>{const u=h.target.value;u?this.setAttribute("value",u):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:u},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._wrapper.appendChild(this._select),d)this._caretUpIcon=null,this._caretDownIcon=null;else{const h=document.createElement("div");h.className="absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none z-10 flex flex-col",this._caretUpIcon=document.createElement("mint-icon"),this._caretUpIcon.setAttribute("name","caret-up"),this._caretUpIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mb-[-.2rem]",h.appendChild(this._caretUpIcon),this._caretDownIcon=document.createElement("mint-icon"),this._caretDownIcon.setAttribute("name","caret-down"),this._caretDownIcon.className="w-[.9em] h-[.9em] text-gray-400 dark:text-gray-500 mt-[-.2rem]",h.appendChild(this._caretDownIcon),this._wrapper.appendChild(h)}if(r){const h=document.createElement("div");h.className="mt-1 text-xs text-gray-500 dark:text-gray-400",h.textContent=r,this.appendChild(h)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(e){t||(t=document.createElement("div"),t.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const r=this.isMultiple();s.style.height=r?"6rem":"2.25rem",t.appendChild(s)}t.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else t&&(t.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const e=this.hasError(),t=this.getErrorMessage();let i=this.querySelector(".mint-select-error");e&&t?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=t):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",Z);class Q extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const e=this.closest("form");e&&e.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,i){if(t!==i){if(e==="error"||e==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(e==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.hasAttribute("multiple")}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(e){let t=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(e){t||(t=document.createElement("div"),t.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(t)):(this.style.position="relative",this.appendChild(t)));let s=t.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",t.appendChild(s)),t.style.display="flex",i){const r=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),l=this._fileInput;if(r){const o=r;o.style.visibility="hidden",o.style.pointerEvents="none"}if(n){const o=n;o.style.visibility="hidden",o.style.pointerEvents="none"}if(a){const o=a;o.style.visibility="hidden",o.style.pointerEvents="none"}l&&(l.style.visibility="hidden",l.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(t&&(t.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),n=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const l=s;l.style.visibility="visible",l.style.pointerEvents="auto"}if(r){const l=r;l.style.visibility="visible",l.style.pointerEvents="auto"}if(n){const l=n;l.style.visibility="visible",l.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.hasAttribute("error")}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.hasAttribute("disabled")}isLoading(){return this.hasAttribute("loading")}render(){const e=this.isLoading(),t=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),r=this.isDisabled(),n=this.getWidth(),a=this.getHeight(),l=this.getName(),o=this.hasError(),d=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",o?"true":"false"),r?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",t||"File upload dropzone")),this._dropzone.style.width=n,this._dropzone.style.height=a,this._dropzone.style.minWidth=n,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=r,l?this._fileInput.name=l:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",o?"true":"false");const c=this._dropzone.querySelector(".mint-dropzone-icon"),m=this._dropzone.querySelector(".mint-dropzone-label");c&&c.remove(),m&&m.remove();const h=document.createElement("div");h.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const f=document.createElement("mint-icon");if(f.setAttribute("name","upload"),f.className="w-12 h-12 text-gray-400 dark:text-gray-500",h.appendChild(f),this._dropzone.appendChild(h),t){const u=document.createElement("div");u.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",u.textContent=t,this._dropzone.appendChild(u)}this.setupEventListeners(),this._renderErrorState(o,d),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let i=this.querySelector(".mint-dropzone-error");e&&t?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=t):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const e=this.isDisabled(),t=this.hasError(),r=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,n=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-800":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=t?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",l=e?"opacity-40 cursor-not-allowed":"",o="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${r} ${t?a:n} ${l} ${o}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onDragOver||(this._onDragOver=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=e=>{var i;e.preventDefault(),e.stopPropagation();const t=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();t&&(e.clientX<t.left||e.clientX>t.right||e.clientY<t.top||e.clientY>t.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=e=>{var i;if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const t=(i=e.dataTransfer)==null?void 0:i.files;t&&t.length>0&&this._handleFiles(t)}),this._onFileInputInput||(this._onFileInputInput=e=>{e.stopImmediatePropagation(),e.stopPropagation()}),this._onKeyDown||(this._onKeyDown=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(t){console.debug("File chooser blocked:",t)}}),this._onFocus||(this._onFocus=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=e=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;const i=e.target.files;if(i&&i.length>0){const s=this.getAccept(),r=this.isMultiple(),n=[],a=[];for(let l=0;l<i.length;l++){const o=i[l];this._isFileAccepted(o,s)?n.push(o):a.push(o)}if(!r&&n.length>1&&(a.push(...n.slice(1)),n.splice(1)),a.length>0){const l=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(l)}n.length>0&&this._applyValidFiles(n)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){const t=this.getAccept(),i=this.isMultiple(),s=[],r=[];for(let n=0;n<e.length;n++){const a=e[n];this._isFileAccepted(a,t)?s.push(a):r.push(a)}if(!i&&s.length>1&&(r.push(...s.slice(1)),s.splice(1)),r.length>0){const n=new CustomEvent("dropRejected",{detail:{files:r,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(e,t){var s;if(!t)return!0;const i=t.split(",").map(r=>r.trim().toLowerCase());for(const r of i)if(r.startsWith(".")){if("."+((s=e.name.split(".").pop())==null?void 0:s.toLowerCase())===r)return!0}else if(r.includes("/*")){const n=r.split("/")[0],a=e.type.split("/")[0];if(n===a)return!0}else if(e.type===r)return!0;return!1}_dispatchEvent(e,t){const i=t.target,s=new CustomEvent(e,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const t={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:t,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(t){console.warn("Failed to set files on input:",t)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var e;return this._syncFileInputFromSelected(),((e=this._fileInput)==null?void 0:e.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const e=document.createElement("div");e.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const t=document.createElement("div");t.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((o,d)=>{const c=document.createElement("div");if(c.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800",o.type.startsWith("image/")){const u=document.createElement("img");u.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const p=URL.createObjectURL(o);this._previewUrls.push(p),u.src=p,c.appendChild(u)}else{const u=document.createElement("mint-icon");u.setAttribute("name","attach"),u.className="w-5 h-5 text-gray-500 dark:text-gray-300",c.appendChild(u)}const m=document.createElement("div");m.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",m.textContent=o.name,c.appendChild(m);const h=document.createElement("button");h.type="button",h.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const f=document.createElement("mint-icon");f.setAttribute("name","close"),f.className="w-4 h-4",h.appendChild(f),h.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),this._removeFileAt(d)}),c.appendChild(h),t.appendChild(c)});const i=this.hasError(),s=this._isDragging;let r="from-white dark:from-gray-700";i?r="from-red-50 dark:from-red-900/30":s&&(r="from-gray-50 dark:from-gray-800");const n=document.createElement("div");n.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${r} to-transparent opacity-0 transition-opacity duration-200`,e.appendChild(n);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${r} to-transparent opacity-100 transition-opacity duration-200`,e.appendChild(a);const l=()=>{const o=t.scrollTop,d=t.scrollHeight,c=t.clientHeight;o>0?n.style.opacity="1":n.style.opacity="0",o+c<d-1?a.style.opacity="1":a.style.opacity="0"};l(),t.addEventListener("scroll",l),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;const[t]=this._selectedFiles.splice(e,1);t&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(e=>URL.revokeObjectURL(e)),this._previewUrls=[]}_attachFormResetListener(){const e=this.closest("form");!e||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},e.addEventListener("reset",this._resetHandler))}_applyValidFiles(e){if(this.isMultiple()){const i=e.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[e[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(e){return this._selectedFiles.some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Q);class ee extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const e=this.getAttribute("headers");e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._applyFormData();else{const t=this.getAttribute("data-form-data");t&&(this._parseFormData(t),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,i){e==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e==="headers"?this._parseHeaders(i):e==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){e&&typeof e=="object"&&!Array.isArray(e)?this._formData=e:e==null?this._formData=null:this._parseFormData(e),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(e){if(e&&typeof e=="object"&&!Array.isArray(e))this._headers=e;else if(e==null)this._headers=null;else if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=e=>{e.preventDefault(),e.stopImmediatePropagation(),this._handleSubmit(e)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const e=this.getAttribute("action")||"",t=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=i}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const t=this._collectValidationRules(),i=new FormData(this._form),s=this._formDataToValues(i);if(!this._validate(s,t)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const n=new CustomEvent("submit",{detail:{formData:i,values:s},bubbles:!0,cancelable:!0,composed:!0});if(this.dispatchEvent(n),n.defaultPrevented)return;const a=this.getAttribute("action"),l=this.getAttribute("method");if(!(!a||!l)){this._setButtonsSubmitting();try{const o=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:o,bubbles:!0,cancelable:!0}))}catch(o){this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:o},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){var c,m,h;const i=this.getAttribute("action"),s=this.getAttribute("method"),r=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:t}};const n=Array.from(e.values()).some(f=>f instanceof File);let a=null;const l={};let o=i;if(typeof window<"u"&&((h=(m=(c=window.mintForm)==null?void 0:c.defaults)==null?void 0:m.headers)!=null&&h.common)&&Object.assign(l,window.mintForm.defaults.headers.common),this._headers&&Object.assign(l,this._headers),s==="GET"){const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),o+=(i.includes("?")?"&":"?")+f.toString()}else if(r==="multipart/form-data"||n)a=e;else if(r==="application/json")a=JSON.stringify(t),l["Content-Type"]="application/json";else{const f=new URLSearchParams;e.forEach((u,p)=>{u instanceof File||f.append(p,String(u))}),a=f,l["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const f=await fetch(o,{method:s||"POST",body:s==="GET"?null:a,headers:l}),u=await f.text().catch(()=>"");let p=u;try{p=JSON.parse(u)}catch{}if(!f.ok){const b={status:f.status,data:p,response:{status:f.status,data:p}};throw await this._applyErrorInterceptors(b)}const _={status:f.status,ok:f.ok,data:p};return await this._applySuccessInterceptors(_)}catch(f){if(f.response)throw f;const u={status:f.status||0,data:f.data||f.message||"Network error",response:{status:f.status||0,data:f.data||f.message||"Network error"}};throw await this._applyErrorInterceptors(u)}const d=this;return await new Promise(async(f,u)=>{const p=new XMLHttpRequest;p.open(s||"POST",o,!0),Object.entries(l).forEach(([_,b])=>p.setRequestHeader(_,b)),p.onload=async function(){const{status:_,responseText:b}=p;if(_>=200&&_<300){let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,ok:!0,data:y},k=await d._applySuccessInterceptors(x);f(k)}catch(x){u(x)}}else{let y=b;try{y=JSON.parse(b)}catch{}try{const x={status:_,data:y,response:{status:_,data:y}},k=await d._applyErrorInterceptors(x);u(k)}catch(x){u(x)}}},p.onerror=async function(){try{const _={status:p.status||0,data:p.responseText||"Network error",response:{status:p.status||0,data:p.responseText||"Network error"}},b=await d._applyErrorInterceptors(_);u(b)}catch(_){u(_)}},p.send(s==="GET"?null:a)})}async _applySuccessInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return e;let t=e;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(t=await a.fulfilled(t));return t}async _applyErrorInterceptors(e){var s,r,n;if(typeof window>"u"||!((n=(r=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:r.response)!=null&&n.handlers))return Promise.reject(e);let t=e;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const l=i[a];if(l.rejected)try{if(t=await l.rejected(t),t!==void 0)return t}catch(o){t=o}}return Promise.reject(t)}_formDataToValues(e){const t={};return e.forEach((i,s)=>{i instanceof File?(t[s]||(t[s]=[]),t[s].push(i)):s in t?Array.isArray(t[s])?(t[s].length>0&&t[s][0]instanceof File,t[s].push(i)):t[s]=[t[s],i]:t[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(n=>{const a=n.getAttribute("name");if(a&&typeof n.files<"u"&&n.files){const l=n.files;if(l.length>0){const o=Array.from(l);t[a]&&Array.isArray(t[a])?o.forEach(d=>{t[a].some(m=>m.name===d.name&&m.size===d.size&&m.lastModified===d.lastModified)||t[a].push(d)}):t[a]=o}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(n=>{const a=n.name;if(a&&n.files&&n.files.length>0){const l=Array.from(n.files);t[a]&&Array.isArray(t[a])?l.forEach(o=>{t[a].some(c=>c.name===o.name&&c.size===o.size&&c.lastModified===o.lastModified)||t[a].push(o)}):t[a]=l}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(n=>{const a=n.getAttribute("name");if(a){let l=[];if(typeof n.tags<"u"?l=n.tags:typeof n.getTags=="function"&&(l=n.getTags()),Array.isArray(l)&&l.length>0){const o=l.map(d=>typeof d=="string"?d:(d==null?void 0:d.value)||(d==null?void 0:d.label)||"").filter(d=>d.trim()!=="");t[a]=o}else t[a]=[]}})),t}_collectValidationRules(){const e={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",r=i.getAttribute("validation");if(!s||!r)return;const n=this._parseRules(r);n.length&&(e[s]=n)}),e}_parseRules(e){if(!e)return[];try{const t=e.replace(/'/g,'"'),i=JSON.parse(t);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}_validate(e,t){let i=!0;return this._errors={},Object.entries(t||{}).forEach(([s,r])=>{const n=Array.isArray(r)?r:[r],a=this._getFieldElements(s),l=this._extractFieldValue(a),o=this._validateRules(l,n);o?(i=!1,this._errors[s]=o,this._flagFieldError(a,o)):this._clearFieldError(a)}),i}_validateField(e){const t=this._collectValidationRules();if(!t[e])return;const i=t[e],s=Array.isArray(i)?i:[i],r=this._getFieldElements(e),n=this._extractFieldValue(r),a=this._validateRules(n,s);a?(this._errors[e]=a,this._flagFieldError(r,a)):(this._clearFieldError(r),delete this._errors[e])}_validateRules(e,t){for(const i of t){const[s,r]=i.split(":");switch(s){case"required":{if(e==null||typeof e=="string"&&e.trim()===""||e instanceof FileList&&e.length===0||Array.isArray(e)&&e.length===0)return"This field is required.";break}case"string":{if(typeof e!="string")return"Must be a string.";break}case"email":{if(typeof e=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e.trim()))return"Enter a valid email.";break}case"number":{const n=Number(e);if(Number.isNaN(n))return"Must be a number.";break}case"min":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length<n)return`Must be at least ${n} characters.`;if(Array.isArray(e)&&e.length<n)return`Select at least ${n}.`;if(e instanceof FileList&&e.length<n)return`Upload at least ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<n)return`Must be at least ${n}.`;break}case"max":{const n=Number(r);if(Number.isNaN(n))break;if(typeof e=="string"&&e.trim().length>n)return`Must be at most ${n} characters.`;if(Array.isArray(e)&&e.length>n)return`Select no more than ${n}.`;if(e instanceof FileList&&e.length>n)return`Upload no more than ${n} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>n)return`Must be at most ${n}.`;break}}}return null}_getFieldElements(e){if(!this._form)return[];const t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),i=t.filter(n=>n.tagName==="MINT-SELECT");if(i.length>0){const n=[];return i.forEach(a=>{const l=a.querySelector('select[name="'+e+'"]');l&&n.push(l)}),t.filter(a=>a.tagName!=="MINT-SELECT").concat(n)}if(t.filter(n=>n.tagName==="MINT-TAGS").length>0)return t.filter(n=>n.tagName!=="INPUT"||!n.closest("mint-tags"));const r=t.filter(n=>n.tagName==="INPUT"&&n.closest("mint-tags"));if(r.length>0){const n=[];return r.forEach(a=>{const l=a.closest("mint-tags");l&&!n.includes(l)&&n.push(l)}),t.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(n)}return t}_extractFieldValue(e){if(e.length===0)return"";const t=e.find(s=>s instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){const s=e.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===e.length){const a=s.filter(l=>l.checked);if(s.every(l=>l.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(l=>l.type==="checkbox"))return a.map(l=>l.value||"on")}const r=e.filter(a=>a.tagName==="MINT-CHOICE");if(r.length>0&&r.length===e.length){const a=r.find(l=>typeof l.getValue=="function"?l.getValue()!=="":l.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const l=a.querySelector("mint-choice-option[checked]");if(l)return l.getAttribute("value")||""}return""}const n=e.filter(a=>a.tagName==="MINT-CHECKBOX");if(n.length>0&&n.length===e.length)return n.filter(l=>typeof l.checked<"u"?l.checked:l.hasAttribute("checked")).map(l=>l.getAttribute("value")||"on")}const i=e[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const n=i.getValue();if(n!=null&&n!=="")return n}const r=i.getAttribute("value");return r||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(n=>typeof n=="string"?n:(n==null?void 0:n.value)||(n==null?void 0:n.label)||"").filter(n=>n.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(e,t){e.length!==0&&e.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error",""),s.setAttribute("error-message",t),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(e){e.length!==0&&e.forEach(t=>{(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.removeAttribute("aria-invalid");const i=this._resolveHost(t);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(e=>{const t=e;t.removeAttribute("error"),t.removeAttribute("error-message"),t.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(e=>{e.removeAttribute("aria-invalid")})}_parseFormData(e){if(!e){this._formData=null;return}if(typeof e=="object"&&!Array.isArray(e)){this._formData=e;return}if(typeof e=="string")try{this._formData=JSON.parse(e)}catch{this._formData=null}else this._formData=null}_parseHeaders(e){if(!e){this._headers=null;return}if(typeof e=="string")try{this._headers=JSON.parse(e)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const e=()=>{Object.entries(this._formData).forEach(([t,i])=>{const s=this._getFieldElements(t);if(s.length===0){setTimeout(()=>{const r=this._getFieldElements(t);r.length>0&&this._applyValueToField(r,t,i)},300);return}this._applyValueToField(s,t,i)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(e,t,i){e.forEach(s=>{var n;const r=s.tagName;try{if(r==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(r==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-SELECT"||r==="SELECT")r==="SELECT"?(n=s.closest("mint-select"))==null||n.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(r==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(l=>{l.checked=l.getAttribute("value")===i});else if(r==="MINT-CHECKBOX"||r==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked",""):s.removeAttribute("checked")}else r==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${t}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(t=>{var s,r;t.removeAttribute("error"),t.removeAttribute("error-message");const i=t.tagName;if(i==="MINT-INPUT")try{t.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=t.setValue)==null||s.call(t,"")}catch{}else if(i==="MINT-SELECT")try{(r=t.setValue)==null||r.call(t,"")}catch{}else if(i==="MINT-DROPZONE"){const n=t.querySelector('input[type="file"]');n&&(n.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof t.checked<"u")t.checked=!1;else{t.removeAttribute("checked");const n=t.querySelector('input[type="checkbox"], input[type="radio"]');n&&(n.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof t.setValue=="function"?t.setValue(""):t.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{t.tags=[]}catch{}})}_resolveHost(e){if(e.tagName==="MINT-CHOICE-OPTION"){const i=e.closest("mint-choice");if(i)return i}const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return t||e}_setupBlurValidation(){if(!this._form)return;const e=i=>{const s=i.target;if(!s)return;const r=this._findFieldElement(s);if(!r)return;const n=this._getFieldName(r);if(!n||!this._collectValidationRules()[n])return;const l=this._extractFieldValue([r]),o=l!=null&&(typeof l=="string"?l.trim()!=="":l instanceof FileList||Array.isArray(l)?l.length>0:!0),d=r.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),c=!!r.closest("mint-tags"),m=r.tagName==="MINT-CHECKBOX"||r.tagName==="MINT-SWITCH"||r.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),h=r.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(o||d||c||m||h)&&setTimeout(()=>{this._validateField(n)},0)};this._form.addEventListener("blur",e,!0),this._fieldBlurHandlers.set(this._form,e);const t=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const d=s,c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const d=this._findFieldElement(s);if(!d)return;const c=this._getFieldName(d);if(!c||!this._collectValidationRules()[c])return;setTimeout(()=>{this._validateField(c)},0);return}const a=this._findFieldElement(s);if(!a)return;const l=this._getFieldName(a);!l||!this._collectValidationRules()[l]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(l)},0)};this._form.addEventListener("change",t,!0),this._form.addEventListener("tags-change",t,!0),this._form.addEventListener("choice-change",t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){if(e.hasAttribute("name")&&(e.tagName.startsWith("MINT-")||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement))return e;const t=e.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(t&&t.hasAttribute("name"))return t;if((e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute("name"))return e;let i=e;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(e){return e.hasAttribute("name")||e.tagName.startsWith("MINT-")?e.getAttribute("name"):(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const e=this._fieldBlurHandlers.get(this._form);e&&this._form.removeEventListener("blur",e,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener("change",e,!0),this._form.removeEventListener("tags-change",e,!0),this._form.removeEventListener("choice-change",e,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(t=>{typeof t.syncFiles=="function"&&t.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const e=this.getAttribute("loading"),t=e!==null&&e!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{t?s.setAttribute("loading",""):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=i.getAttribute("disabled")==="true",r=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:r});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()}),t.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const e=Array.from(this.querySelectorAll("mint-button")),t=Array.from(this.querySelectorAll("button"));e.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),t.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}}customElements.get("mint-form")||customElements.define("mint-form",ee);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(w,e){return window.mintForm.interceptors.response.handlers.push({fulfilled:w,rejected:e}),window.mintForm.interceptors.response.handlers.length-1}));class te extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto","border","border-gray-200","rounded-lg","dark:border-gray-700"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const e=this.querySelector("table");if(!e){this._observer&&this._observeChanges();return}const t=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],r=e.querySelector("thead tr");r&&r.querySelectorAll("th").forEach(d=>s.push((d.textContent||"").trim())),this._setClasses(e,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","rounded-lg","border-2","border-gray-200","dark:border-gray-700","overflow-hidden"]);const n=e.querySelector("thead");n&&(this._setClasses(n,["bg-[#F7F7F7]","dark:bg-gray-800"]),n.querySelectorAll("th").forEach(d=>{this._setClasses(d,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"])}));const a=e.querySelector("tbody");if(a){const o=Array.from(a.querySelectorAll("tr"));o.forEach((d,c)=>{this._setClasses(d,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),c===o.length-1&&d.classList.remove("border-b"),d.querySelectorAll("td").forEach(h=>{this._setClasses(h,["text-gray-900","dark:text-gray-100","px-3","py-2"]),t?this._applyMobileCell(h,s):this._restoreCell(h)})})}const l=e.querySelector("tfoot");l&&(this._setClasses(l,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),l.querySelectorAll("td").forEach(d=>{this._setClasses(d,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(d)})),this._observer&&this._observeChanges()}_applyMobileCell(e,t){if(e.closest("tfoot")||e.dataset.mtProcessed==="true")return;const i=t[e.cellIndex]||"",s=e.getAttribute("data-original"),r=s!==null?s:e.innerHTML;e.setAttribute("data-original",r),e.dataset.mtProcessed="true",e.innerHTML="";const n=document.createElement("span");n.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",n.textContent=i;const a=document.createElement("span");a.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",a.innerHTML=r,e.appendChild(n),e.appendChild(a)}_restoreCell(e){if(e.dataset.mtProcessed!=="true")return;const t=e.getAttribute("data-original")||"";e.dataset.mtProcessed="",e.innerHTML=t}_setClasses(e,t){e.className="",t.filter(Boolean).forEach(i=>e.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const e=document.createElement("style");e.id="mint-table-responsive-style",e.textContent=`
69
69
  @media (max-width: 640px) {
70
70
  mint-table[collapse] {
71
71
  display: block;
package/dist/index.js CHANGED
@@ -190,12 +190,10 @@ class z extends HTMLElement {
190
190
  return this.getAttribute("tone") || "neutral";
191
191
  }
192
192
  isDisabled() {
193
- const e = this.getAttribute("disabled");
194
- return e === null ? !1 : e !== "false";
193
+ return this.getAttribute("disabled") === "true";
195
194
  }
196
195
  isLoading() {
197
- const e = this.getAttribute("loading");
198
- return e === null ? !1 : e !== "false";
196
+ return this.getAttribute("loading") === "true";
199
197
  }
200
198
  getType() {
201
199
  const e = this.getAttribute("type"), t = this.getAttribute("button-type");
@@ -4654,10 +4652,10 @@ class re extends HTMLElement {
4654
4652
  this._buttonStates.clear();
4655
4653
  const e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
4656
4654
  e.forEach((i) => {
4657
- const s = i.hasAttribute("disabled"), r = i.hasAttribute("loading");
4655
+ const s = i.getAttribute("disabled") === "true", r = i.getAttribute("loading") === "true";
4658
4656
  this._buttonStates.set(i, { disabled: s, loading: r });
4659
4657
  const a = (i.getAttribute("type") || i.getAttribute("button-type") || "default") === "submit";
4660
- s || i.setAttribute("disabled", ""), a && i.setAttribute("loading", ""), typeof i.render == "function" && i.render();
4658
+ s || i.setAttribute("disabled", "true"), a && i.setAttribute("loading", "true"), typeof i.render == "function" && i.render();
4661
4659
  }), t.forEach((i) => {
4662
4660
  if (i.closest("mint-button")) return;
4663
4661
  const s = i.disabled;
@@ -4669,7 +4667,7 @@ class re extends HTMLElement {
4669
4667
  const e = Array.from(this.querySelectorAll("mint-button")), t = Array.from(this.querySelectorAll("button"));
4670
4668
  e.forEach((i) => {
4671
4669
  const s = this._buttonStates.get(i);
4672
- s && (s.disabled ? i.setAttribute("disabled", "") : i.removeAttribute("disabled"), s.loading ? i.setAttribute("loading", "") : i.removeAttribute("loading"), typeof i.render == "function" && i.render());
4670
+ 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());
4673
4671
  }), t.forEach((i) => {
4674
4672
  if (i.closest("mint-button")) return;
4675
4673
  const s = this._buttonStates.get(i);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monobill-mintui",
3
- "version": "0.2.93",
3
+ "version": "0.2.95",
4
4
  "description": "A modern framework-agnostic UI kit built as Web Components. Requires Tailwind CSS.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",