monobill-mintui 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/icon/icons/grip-lines.d.ts +3 -0
- package/dist/components/icon/icons/grip-lines.d.ts.map +1 -0
- package/dist/components/icon/icons/index.cjs +17 -14
- package/dist/components/icon/icons/index.d.ts +1 -0
- package/dist/components/icon/icons/index.d.ts.map +1 -1
- package/dist/components/icon/icons/index.js +61 -56
- package/dist/components/sortable/Sortable.d.ts +62 -0
- package/dist/components/sortable/Sortable.d.ts.map +1 -0
- package/dist/components/sortable/index.d.ts +3 -0
- package/dist/components/sortable/index.d.ts.map +1 -0
- package/dist/components/stack/Stack.d.ts +3 -0
- package/dist/components/stack/Stack.d.ts.map +1 -1
- package/dist/icons/ai.svg +8 -0
- package/dist/icons/bank.svg +3 -0
- package/dist/icons/barcode.svg +1 -1
- package/dist/icons/basket.svg +1 -1
- package/dist/icons/building.svg +1 -1
- package/dist/icons/buildings.svg +1 -1
- package/dist/icons/calendar-day.svg +1 -0
- package/dist/icons/check.svg +1 -1
- package/dist/icons/close.svg +1 -1
- package/dist/icons/gavel.svg +9 -0
- package/dist/icons/grip-lines.svg +4 -0
- package/dist/icons/plus.svg +1 -1
- package/dist/icons/remove.svg +1 -1
- package/dist/icons/truck.svg +13 -0
- package/dist/index.cjs +5 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +415 -116
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,7 +55,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
55
55
|
mint-button[data-variant="link"] .mint-button-active {
|
|
56
56
|
box-shadow: none !important;
|
|
57
57
|
}
|
|
58
|
-
`,document.head.appendChild(t),e._activeShadowStyleInjected=!0}this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add(`w-full`)}disconnectedCallback(){this._disconnectHostChildObserver(),this._hostRenderFromObserverRaf!==null&&(cancelAnimationFrame(this._hostRenderFromObserverRaf),this._hostRenderFromObserverRaf=null),this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&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(){let e=this.getAttribute(`type`),t=this.getAttribute(`button-type`);return(e||t||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.getAttribute(`full-width`)===`true`}isActive(){return this.getAttribute(`active`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.removeAttribute(`active`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}getAlignment(){let e=this.getAttribute(`align`);return e===`left`||e===`center`||e===`right`?e:`center`}isIconOnly(){if(!(this.getIcon()||this._getGeneratedIcon()||this._button?.querySelector(`mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent?.trim())return!1;if(this._button)for(let e=this._button.firstChild;e;e=e.nextSibling){if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!1;if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.tagName!==`MINT-ICON`&&t.tagName!==`MINT-SPINNER`&&!t.querySelector(`mint-spinner`)&&!t.hasAttribute(`slot`)&&t.className!==`mint-button-icon`&&!(t.className===`mr-2`&&t.querySelector(`mint-spinner`))&&t.textContent?.trim())return!1}}return!0}getActiveStateClasses(){let e=`${this.getVariant()}-${this.getTone()}`;return{"solid-action":[`!bg-neutral-900`,`dark:!bg-neutral-700`,`hover:!bg-neutral-900`,`dark:hover:!bg-neutral-700`,`!border-t-neutral-900`,`!border-l-neutral-900`,`!border-r-neutral-600`,`!border-b-neutral-600`,`dark:!border-t-neutral-700`,`dark:!border-l-neutral-700`,`dark:!border-r-neutral-500`,`dark:!border-b-neutral-500`],"solid-neutral":[`!bg-gray-100`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`!border-t-gray-400`,`!border-l-gray-400`,`!border-r-gray-200`,`!border-b-gray-200`,`dark:!border-t-gray-950`,`dark:!border-l-gray-950`,`dark:!border-r-mint-divider`,`dark:!border-b-mint-divider`],"solid-info":[`!bg-blue-900`,`dark:!bg-blue-700`,`hover:!bg-blue-900`,`dark:hover:!bg-blue-700`,`!border-t-blue-900`,`!border-l-blue-900`,`!border-r-blue-600`,`!border-b-blue-600`,`dark:!border-t-blue-700`,`dark:!border-l-blue-700`,`dark:!border-r-blue-500`,`dark:!border-b-blue-500`],"solid-warning":[`!bg-amber-900`,`dark:!bg-amber-700`,`hover:!bg-amber-900`,`dark:hover:!bg-amber-700`,`!border-t-amber-900`,`!border-l-amber-900`,`!border-r-amber-600`,`!border-b-amber-600`,`dark:!border-t-amber-700`,`dark:!border-l-amber-700`,`dark:!border-r-amber-500`,`dark:!border-b-amber-500`],"solid-danger":[`!bg-red-900`,`dark:!bg-red-700`,`hover:!bg-red-900`,`dark:hover:!bg-red-700`,`!border-t-red-900`,`!border-l-red-900`,`!border-r-red-600`,`!border-b-red-600`,`dark:!border-t-red-700`,`dark:!border-l-red-700`,`dark:!border-r-red-500`,`dark:!border-b-red-500`],"ghost-action":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-neutral":[`!bg-gray-50`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`!text-gray-900`,`dark:!text-white`,`hover:!bg-gray-50`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`hover:!text-gray-900`,`dark:hover:!text-white`],"ghost-info":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-warning":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-danger":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"link-action":[`!text-neutral-900`,`dark:!text-neutral-300`,`hover:!text-neutral-900`,`dark:hover:!text-neutral-300`],"link-neutral":[`!text-gray-950`,`dark:!text-gray-200`,`hover:!text-gray-950`,`dark:hover:!text-gray-200`],"link-info":[`!text-blue-900`,`dark:!text-blue-200`,`hover:!text-blue-900`,`dark:hover:!text-blue-200`],"link-warning":[`!text-amber-900`,`dark:!text-amber-200`,`hover:!text-amber-900`,`dark:hover:!text-amber-200`],"link-danger":[`!text-red-900`,`dark:!text-red-200`,`hover:!text-red-900`,`dark:hover:!text-red-200`]}[e]||[]}_disconnectHostChildObserver(){this._hostChildObserver?.disconnect()}_connectHostChildObserver(){this.isConnected&&(this._hostChildObserver||=new MutationObserver(e=>{this._onLightDomMutation(e)}),this._hostChildObserver.disconnect(),this._hostChildObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_onLightDomMutation(e){if(this.isConnected){if(this._button&&!this._button.isConnected){this._button=null,this._scheduleRenderFromHostObserver();return}for(let t of e){let e=t.target;if(!(this._button&&(e===this._button||this._button.contains(e)))){this._scheduleRenderFromHostObserver();return}}}}_scheduleRenderFromHostObserver(){this._hostRenderFromObserverRaf===null&&(this._hostRenderFromObserverRaf=requestAnimationFrame(()=>{this._hostRenderFromObserverRaf=null,this.isConnected&&this.render()}))}getButtonClasses(){let e=this.isIconOnly(),t=this.getVariant(),n=this.getAlignment(),r=`justify-center`;n===`left`?r=`justify-start`:n===`right`&&(r=`justify-end`);let i=[`inline-flex`,`items-center`,r,`cursor-pointer`,`font-medium`,`rounded-lg`,`box-border`,...e?[`p-1.5`,`aspect-square`,`w-[2.25rem]`,`h-[2.25rem]`]:[`px-3.5`,`py-1.5`,`min-h-[2.25rem]`],`text-sm`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`[&.mint-button-active:not(:disabled):not([data-loading="true"]):not([data-variant="ghost"]):not([data-variant="link"])>*]:translate-y-[1px]`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],a=this.getTone(),o={"solid-action":`bg-neutral-800.dark:bg-neutral-600.text-white.hover:bg-neutral-950.dark:hover:bg-neutral-700.active:bg-neutral-900.dark:active:bg-neutral-700.disabled:active:bg-neutral-800.dark:disabled:active:bg-neutral-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-neutral-600.border-l-neutral-600.border-r-neutral-900.border-b-neutral-900.dark:border-t-neutral-500.dark:border-l-neutral-500.dark:border-r-neutral-700.dark:border-b-neutral-700.active:border-t-neutral-900.active:border-l-neutral-900.active:border-r-neutral-600.active:border-b-neutral-600.dark:active:border-t-neutral-700.dark:active:border-l-neutral-700.dark:active:border-r-neutral-500.dark:active:border-b-neutral-500.disabled:active:border-t-neutral-600.disabled:active:border-l-neutral-600.disabled:active:border-r-neutral-900.disabled:active:border-b-neutral-900.dark:disabled:active:border-t-neutral-500.dark:disabled:active:border-l-neutral-500.dark:disabled:active:border-r-neutral-700.dark:disabled:active:border-b-neutral-700.[&[data-loading="true"]:active]:border-t-neutral-600.[&[data-loading="true"]:active]:border-l-neutral-600.[&[data-loading="true"]:active]:border-r-neutral-900.[&[data-loading="true"]:active]:border-b-neutral-900.[&[data-loading="true"]:active]:dark:border-t-neutral-500.[&[data-loading="true"]:active]:dark:border-l-neutral-500.[&[data-loading="true"]:active]:dark:border-r-neutral-700.[&[data-loading="true"]:active]:dark:border-b-neutral-700`.split(`.`),"solid-neutral":`bg-white.dark:bg-mint-canvas.text-gray-900.dark:text-white.hover:bg-gray-50.dark:hover:bg-mint-hover.active:bg-gray-100.dark:active:bg-mint-hover.disabled:active:bg-white.dark:disabled:active:bg-mint-canvas.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-gray-200.border-l-gray-200.border-r-gray-300.border-b-gray-300.dark:border-t-gray-600.dark:border-l-gray-600.dark:border-r-mint-divider.dark:border-b-mint-divider.active:border-t-gray-400.active:border-l-gray-400.active:border-r-gray-200.active:border-b-gray-200.dark:active:border-t-gray-950.dark:active:border-l-gray-950.dark:active:border-r-mint-divider.dark:active:border-b-mint-divider.disabled:active:border-t-gray-200.disabled:active:border-l-gray-200.disabled:active:border-r-gray-400.disabled:active:border-b-gray-400.dark:disabled:active:border-t-mint-divider.dark:disabled:active:border-l-mint-divider.dark:disabled:active:border-r-gray-950.dark:disabled:active:border-b-gray-950.[&[data-loading="true"]:active]:border-t-gray-200.[&[data-loading="true"]:active]:border-l-gray-200.[&[data-loading="true"]:active]:border-r-gray-400.[&[data-loading="true"]:active]:border-b-gray-400.[&[data-loading="true"]:active]:dark:border-t-mint-divider.[&[data-loading="true"]:active]:dark:border-l-mint-divider.[&[data-loading="true"]:active]:dark:border-r-gray-950.[&[data-loading="true"]:active]:dark:border-b-gray-950`.split(`.`),"solid-info":`bg-blue-800.dark:bg-blue-600.text-white.hover:bg-blue-950.dark:hover:bg-blue-700.active:bg-blue-900.dark:active:bg-blue-700.disabled:active:bg-blue-800.dark:disabled:active:bg-blue-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-blue-600.border-l-blue-600.border-r-blue-900.border-b-blue-900.dark:border-t-blue-500.dark:border-l-blue-500.dark:border-r-blue-700.dark:border-b-blue-700.active:border-t-blue-900.active:border-l-blue-900.active:border-r-blue-600.active:border-b-blue-600.dark:active:border-t-blue-700.dark:active:border-l-blue-700.dark:active:border-r-blue-500.dark:active:border-b-blue-500.disabled:active:border-t-blue-600.disabled:active:border-l-blue-600.disabled:active:border-r-blue-900.disabled:active:border-b-blue-900.dark:disabled:active:border-t-blue-500.dark:disabled:active:border-l-blue-500.dark:disabled:active:border-r-blue-700.dark:disabled:active:border-b-blue-700.[&[data-loading="true"]:active]:border-t-blue-600.[&[data-loading="true"]:active]:border-l-blue-600.[&[data-loading="true"]:active]:border-r-blue-900.[&[data-loading="true"]:active]:border-b-blue-900.[&[data-loading="true"]:active]:dark:border-t-blue-500.[&[data-loading="true"]:active]:dark:border-l-blue-500.[&[data-loading="true"]:active]:dark:border-r-blue-700.[&[data-loading="true"]:active]:dark:border-b-blue-700`.split(`.`),"solid-warning":`bg-amber-800.dark:bg-amber-600.text-white.hover:bg-amber-950.dark:hover:bg-amber-700.active:bg-amber-900.dark:active:bg-amber-700.disabled:active:bg-amber-800.dark:disabled:active:bg-amber-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-amber-600.border-l-amber-600.border-r-amber-900.border-b-amber-900.dark:border-t-amber-500.dark:border-l-amber-500.dark:border-r-amber-700.dark:border-b-amber-700.active:border-t-amber-900.active:border-l-amber-900.active:border-r-amber-600.active:border-b-amber-600.dark:active:border-t-amber-700.dark:active:border-l-amber-700.dark:active:border-r-amber-500.dark:active:border-b-amber-500.disabled:active:border-t-amber-600.disabled:active:border-l-amber-600.disabled:active:border-r-amber-900.disabled:active:border-b-amber-900.dark:disabled:active:border-t-amber-500.dark:disabled:active:border-l-amber-500.dark:disabled:active:border-r-amber-700.dark:disabled:active:border-b-amber-700.[&[data-loading="true"]:active]:border-t-amber-600.[&[data-loading="true"]:active]:border-l-amber-600.[&[data-loading="true"]:active]:border-r-amber-900.[&[data-loading="true"]:active]:border-b-amber-900.[&[data-loading="true"]:active]:dark:border-t-amber-500.[&[data-loading="true"]:active]:dark:border-l-amber-500.[&[data-loading="true"]:active]:dark:border-r-amber-700.[&[data-loading="true"]:active]:dark:border-b-amber-700`.split(`.`),"solid-danger":`bg-red-800.dark:bg-red-600.text-white.hover:bg-red-950.dark:hover:bg-red-700.active:bg-red-900.dark:active:bg-red-700.disabled:active:bg-red-800.dark:disabled:active:bg-red-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-red-600.border-l-red-600.border-r-red-900.border-b-red-900.dark:border-t-red-500.dark:border-l-red-500.dark:border-r-red-700.dark:border-b-red-700.active:border-t-red-900.active:border-l-red-900.active:border-r-red-600.active:border-b-red-600.dark:active:border-t-red-700.dark:active:border-l-red-700.dark:active:border-r-red-500.dark:active:border-b-red-500.disabled:active:border-t-red-600.disabled:active:border-l-red-600.disabled:active:border-r-red-900.disabled:active:border-b-red-900.dark:disabled:active:border-t-red-500.dark:disabled:active:border-l-red-500.dark:disabled:active:border-r-red-700.dark:disabled:active:border-b-red-700.[&[data-loading="true"]:active]:border-t-red-600.[&[data-loading="true"]:active]:border-l-red-600.[&[data-loading="true"]:active]:border-r-red-900.[&[data-loading="true"]:active]:border-b-red-900.[&[data-loading="true"]:active]:dark:border-t-red-500.[&[data-loading="true"]:active]:dark:border-l-red-500.[&[data-loading="true"]:active]:dark:border-r-red-700.[&[data-loading="true"]:active]:dark:border-b-red-700`.split(`.`),"ghost-action":[`bg-transparent`,`text-neutral-800`,`dark:text-neutral-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-neutral-800`,`dark:text-neutral-400`,`hover:text-neutral-950`,`dark:hover:text-neutral-200`,`active:text-neutral-900`,`dark:active:text-neutral-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`]},s=o[`${t}-${a}`]||o[`solid-neutral`],c=[...i,...s];if(this.isActive()){let e=this.getActiveStateClasses();c.push(...e)}return this.isFullWidth()&&c.push(`w-full`),c.join(` `)}render(){this._disconnectHostChildObserver(),this._button&&!this._button.isConnected&&(this._button=null);try{let e=this.isDisabled()||this.isLoading(),t=this.getType();if(!this._button){let e=this.firstElementChild;if(e instanceof HTMLButtonElement)this._button=e;else{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 n=this._button.querySelector(`mint-spinner`),r=this.isLoading();if(r)if(n)n.setAttribute(`data-button-variant`,this.getVariant()),n.setAttribute(`data-button-tone`,this.getTone()),`render`in n&&typeof n.render==`function`&&n.render();else{let e=document.createElement(`span`);e.className=`mr-2 inline-flex items-center`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else n&&n.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let i=this.getIcon(),a=this._getGeneratedIcon();i?(a||(a=document.createElement(`mint-icon`),a.setAttribute(`data-generated-icon`,`true`),a.className=`mint-button-icon`),a.setAttribute(`name`,i)):a&&a.tagName===`MINT-ICON`&&(a.remove(),a=null);let o=this.getIconPosition(),s=this._button.querySelector(`.mint-button-content`);if(s){s.className=this._getContentWrapperClass(s);let e=a&&a.tagName===`MINT-ICON`;if(a&&!a.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||o===`left`?t?t.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s):s.insertAdjacentElement(`afterend`,a)}else if(a&&(e||o===`left`)&&a.nextSibling!==s){a.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s)}else a&&!e&&o===`right`&&a.previousSibling!==s&&(a.remove(),s.insertAdjacentElement(`afterend`,a))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling){if(t.nodeType!==Node.ELEMENT_NODE){e.push(t);continue}let n=t;n.tagName!==`MINT-SPINNER`&&!n.querySelector(`mint-spinner`)&&t!==a&&!n.hasAttribute(`slot`)&&!(n.className===`mr-2`&&n.querySelector(`mint-spinner`))&&e.push(t)}if(e.length>0){s=document.createElement(`span`),s.className=this._getContentWrapperClass(s),e.forEach(e=>{s.appendChild(e)}),s.className=this._getContentWrapperClass(s);let t=this._button.querySelector(`mint-spinner`)?.parentElement;a&&o===`left`?t?(t.insertAdjacentElement(`afterend`,a),a.insertAdjacentElement(`afterend`,s)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement(`afterend`,s)):a&&o===`right`?t?(t.insertAdjacentElement(`afterend`,s),s.insertAdjacentElement(`afterend`,a)):(this._button.insertBefore(s,this._button.firstChild),s.insertAdjacentElement(`afterend`,a)):t?t.insertAdjacentElement(`afterend`,s):this._button.insertBefore(s,this._button.firstChild)}else if(a&&a.tagName===`MINT-ICON`&&!a.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,this._button.firstChild)}}let c=this.isIconOnly();if(a&&(a.classList.contains(`mint-button-icon`)||a.classList.add(`mint-button-icon`),r?a.style.display=`none`:a.style.display=``,a.classList.remove(`mr-1.5`,`ml-1.5`),c?a.tagName===`MINT-ICON`?(a.style.width=`1em`,a.style.height=`1em`,a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`):(a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`,a.tagName===`svg`&&(a.style.width=`1em`,a.style.height=`1em`)):o===`left`?a.classList.add(`mr-1.5`):a.classList.add(`ml-1.5`)),r){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e&&(c?(e.classList.remove(`mr-2`),e.classList.add(`mr-0`)):e.classList.contains(`mr-2`)||(e.classList.remove(`mr-0`),e.classList.add(`mr-2`)))}let l=this.getButtonClasses();this._button.className=l,this.setAttribute(`data-variant`,this.getVariant()),this.setAttribute(`data-tone`,this.getTone()),this._button.setAttribute(`data-variant`,this.getVariant()),r?this._button.setAttribute(`data-loading`,`true`):this._button.removeAttribute(`data-loading`),this.isActive()?this._button.classList.add(`mint-button-active`):this._button.classList.remove(`mint-button-active`)}finally{queueMicrotask(()=>{this.isConnected&&this._connectHostChildObserver()})}}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),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`,r);var i=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`icon`,`info`,`error`,`error-message`,`loading`]}constructor(){super(),this._button=null,this._checked=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._checked=this.getAttribute(`checked`)===`true`,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.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`),t!==n){if(e===`error`||e===`error-message`){this._renderErrorState();return}if(e===`loading`){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(e){try{e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._checked=!!e,this.render()}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getIcon(){return this.getAttribute(`icon`)||``}hasIcon(){return!!this.getIcon()}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getSwitchClasses(){let e=this.hasError(),t=[`relative`,`inline-flex`,`items-center`,`cursor-pointer`,`rounded-full`,`h-5`,`w-10`,`border`,`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`],n=this._checked?[`bg-neutral-900`,`dark:bg-neutral-700`,e?`border-red-300 dark:border-red-300`:`border-neutral-800 dark:border-neutral-600`]:[`bg-neutral-200`,`dark:bg-neutral-600`,e?`border-red-300 dark:border-red-300`:`border-neutral-300 dark:border-neutral-500`];return[...t,...n].join(` `)}getThumbClasses(){let 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(){let e=this.isLoading(),t=this.getSwitchClasses(),n=this.getThumbClasses(),r=this.getLabel(),i=this.getInfo(),a=this.getIcon(),o=this.getAttribute(`id`)||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute(`id`)||this.setAttribute(`id`,o);let s=this._getSwitchContainer();this._button?this._button.parentElement!==s&&s.appendChild(this._button):(this._button=document.createElement(`button`),s.appendChild(this._button),this.setupEventListeners());let c=s.querySelector(`.mint-switch-label`);r?(c||(c=document.createElement(`label`),c.className=`mint-switch-label cursor-pointer text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,this._button&&this._button.parentElement===s?s.insertBefore(c,this._button.nextSibling):s.appendChild(c)),c.textContent=r,c.setAttribute(`for`,o),this.isDisabled()?(c.classList.add(`opacity-40`,`cursor-not-allowed`),c.classList.remove(`cursor-pointer`)):(c.classList.remove(`opacity-40`,`cursor-not-allowed`),c.classList.add(`cursor-pointer`))):c&&c.remove(),this._button.className=t,this._button.disabled=this.isDisabled(),this._button.id=o,this._button.setAttribute(`aria-checked`,String(this._checked)),this._button.setAttribute(`aria-label`,r||`Toggle switch`),this._button.setAttribute(`role`,`switch`),this._button.type=`button`;let l=this._button.querySelector(`span`);l||(l=document.createElement(`span`),this._button.appendChild(l)),l.className=n;let u=l.querySelector(`span`);if(a){let e=u;e||(e=document.createElement(`span`),e.className=this.getIconClasses(),l.appendChild(e));let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a)}else u&&u.remove();let d=this.querySelector(`.mint-switch-info`);i?(d||(d=document.createElement(`span`),d.className=`mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,s&&s.parentElement===this?this.insertBefore(d,s.nextSibling):this.appendChild(d)),d.textContent=i,this.isDisabled()?d.classList.add(`opacity-40`):d.classList.remove(`opacity-40`)):d&&d.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){if(!this.isDisabled()){this.checked=!this._checked;let e=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent(`toggle`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0}))}}_renderSkeleton(e){let t=this._getSwitchContainer(),n=this.getLabel(),r=this.getInfo(),i=t.querySelector(`.mint-switch-skeleton-container`),a=this.querySelector(`.mint-switch-info-skeleton`);if(e){t.classList.contains(`relative`)||t.classList.add(`relative`),i||(i=document.createElement(`div`),i.className=`mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2`,t.appendChild(i));let e=i.querySelector(`.mint-switch-skeleton-box`);if(e||(e=document.createElement(`div`),e.className=`mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,i.appendChild(e)),n){let e=i.querySelector(`.mint-switch-skeleton-label`);e||(e=document.createElement(`div`),e.className=`mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,i.appendChild(e))}else{let e=i.querySelector(`.mint-switch-skeleton-label`);e&&e.remove()}i.style.display=`flex`,this._button&&(this._button.style.visibility=`hidden`,this._button.style.pointerEvents=`none`);let o=t.querySelector(`.mint-switch-label`);if(o&&(o.style.visibility=`hidden`,o.style.pointerEvents=`none`),r){a||(a=document.createElement(`div`),a.className=`mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-mint-hover animate-pulse mt-2`,t&&t.parentElement===this?this.insertBefore(a,t.nextSibling):this.appendChild(a)),a.style.display=`block`;let e=this.querySelector(`.mint-switch-info`);e&&(e.style.display=`none`)}else a&&(a.style.display=`none`)}else{i&&(i.style.display=`none`),a&&(a.style.display=`none`),this._button&&(this._button.style.visibility=`visible`,this._button.style.pointerEvents=`auto`);let e=t.querySelector(`.mint-switch-label`);e&&(e.style.visibility=`visible`,e.style.pointerEvents=`auto`);let n=this.querySelector(`.mint-switch-info`);n&&(n.style.display=``)}}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-switch-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove(),this._button&&(this._button.className=this.getSwitchClasses())}};customElements.get(`mint-switch`)||customElements.define(`mint-switch`,i);var a=class extends HTMLElement{static get observedAttributes(){return[`variant`,`size`,`bold`,`underline`,`strike`,`italic`,`display`,`inline`]}constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(e,t,n){t!==n&&this.render()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),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.getAttribute(`bold`)===`true`}isUnderline(){return this.getAttribute(`underline`)===`true`}isStrike(){return this.getAttribute(`strike`)===`true`}isItalic(){return this.getAttribute(`italic`)===`true`}getDisplay(){return this.getAttribute(`display`)||(this.getAttribute(`inline`)===`true`?`inline-block`:`block`)}getTextClasses(){let e=this.getSize(),t=this.getVariant(),n=document.documentElement.classList.contains(`dark`),r={heading:[`font-semibold`],"sub-heading":[`font-medium`],regular:[]},i={default:n?[`text-gray-100`]:[`text-gray-900`],muted:[`text-gray-400`],danger:n?[`text-red-400`]:[`text-red-600`],success:n?[`text-green-400`]:[`text-green-600`]},a=[];this.isBold()&&a.push(`font-bold`),this.isUnderline()&&a.push(`underline`),this.isStrike()&&a.push(`line-through`),this.isItalic()&&a.push(`italic`);let o=this.getDisplay();return[o===`block`?`block`:o===`inline`?`inline`:`inline-block`,...r[e]||r.regular,...i[t]||i.default,...a].join(` `)}render(){let 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`],n=[`text-2xl`,`text-lg`,`text-sm`];n.forEach(e=>{this.classList.remove(e),this._userClasses.delete(e)}),t.forEach(e=>{this.classList.remove(e),this._userClasses.delete(e)});let r=this.getTextClasses().split(` `).filter(e=>e.trim());Array.from(this.classList).forEach(e=>{!t.includes(e)&&!n.includes(e)&&this._userClasses.add(e)}),this.className=[...new Set([...r,...Array.from(this._userClasses)])].join(` `);let i={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)`},a=i[e]||i.regular;this.style.setProperty(`font-size`,a)}};customElements.get(`mint-text`)||customElements.define(`mint-text`,a);var o=class extends HTMLElement{static get observedAttributes(){return[`direction`,`text-align`,`gap`]}constructor(){super(),this._childObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`text-align`&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{let e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&=(this._childObserver.disconnect(),null)}getDirection(){return(this.getAttribute(`direction`)||`vertical`)===`horizontal`?`horizontal`:`vertical`}getGap(){let e=this.getAttribute(`gap`)||`3`;return parseFloat(e)}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getStackClasses(){let e=this.getDirection(),t=this.getTextAlign(),n=this.getGap(),r=[`flex`,e===`horizontal`?`flex-row`:`flex-col`,`gap-${n}`];return t&&(r.push(`text-${t}`),r.push(`[&>*]:text-${t}`),r.push(`[&>*_.mint-button-content]:text-${t}`),t===`left`?(r.push(`[&>mint-button]:!justify-start`),r.push(`[&>mint-button>button]:!justify-start`)):t===`right`?(r.push(`[&>mint-button]:!justify-end`),r.push(`[&>mint-button>button]:!justify-end`)):t===`center`&&(r.push(`[&>mint-button]:!justify-center`),r.push(`[&>mint-button>button]:!justify-center`))),r.join(` `)}render(){let 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(e=>this.classList.remove(e)),e.split(` `).forEach(e=>{e&&this.classList.add(e)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){Array.from(this.children).forEach(t=>{if(t.tagName===`MINT-BUTTON`){let n=t.querySelector(`button`);if(n){n.classList.remove(`justify-start`,`justify-center`,`justify-end`),e===`left`?n.classList.add(`justify-start`):e===`right`?n.classList.add(`justify-end`):e===`center`&&n.classList.add(`justify-center`);let t=n.querySelector(`.mint-button-content`);t&&(t.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`),t.classList.add(`text-${e}`))}}else t.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`),t.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName===`MINT-BUTTON`){let t=e.querySelector(`button`);if(t){t.classList.remove(`justify-start`,`justify-end`),t.classList.add(`justify-center`);let e=t.querySelector(`.mint-button-content`);e&&e.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`)}}else e.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`)})}};customElements.get(`mint-stack`)||customElements.define(`mint-stack`,o);var s=class extends HTMLElement{static get observedAttributes(){return[`heading`]}constructor(){super(),this._headingElement=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`align-baseline`,`block`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add(`rounded-lg`,`shadow`,`bg-white`,`dark:bg-mint-elevated`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasPaddingClass()||this.classList.add(`p-4`);let e=this.getHeading();e?(this._headingElement||(this._headingElement=document.createElement(`mint-text`),this._headingElement.setAttribute(`size`,`sub-heading`),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=e):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}};customElements.get(`mint-card`)||customElements.define(`mint-card`,s);var c=class extends HTMLElement{static get observedAttributes(){return[`href`,`target`]}constructor(){super(),this._link=null,this._contentObserver=null}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(),null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHref(){return this.getAttribute(`href`)||`#`}getTarget(){return this.getAttribute(`target`)||``}hasIcon(){return!!(this.querySelector(`mint-icon`)||this._link?.querySelector(`mint-icon`))}render(){let 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`));let n=this.hasIcon(),r=[`text-slate-800`,`dark:text-slate-200`,`underline`,`hover:text-slate-950`,`dark:hover:text-slate-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`];n&&r.push(`inline-flex`,`items-center`,`gap-2`),this._link.className=r.join(` `),this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)})}};customElements.get(`mint-link`)||customElements.define(`mint-link`,c);var l=class extends HTMLElement{static get observedAttributes(){return[`href`,`fallback-href`]}constructor(){super(),this._button=null}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,n){t!==n&&this.render()}getFallbackHref(){return this.getAttribute(`fallback-href`)||this.getAttribute(`href`)||`/`}_getTargetUrl(){let e=document.referrer,t=window.location.origin;if(e)try{let n=new URL(e);if(n.origin===t)return n.pathname+n.search}catch{}return this.getFallbackHref()}handleClick(e){e.preventDefault(),e.stopPropagation();let t=this._getTargetUrl(),n=document.referrer,r=n&&(()=>{try{return new URL(n).origin===window.location.origin}catch{return!1}})(),i=new CustomEvent(`back`,{detail:{url:t,isFromReferrer:r,referrer:n||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}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`,l);var u=class extends HTMLElement{static get observedAttributes(){return[`heading`,`fallback-href`,`show-back-button`,`containered`]}constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._contentObserver=null,this._backButton=null,this._backButtonHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this._observeDarkMode(),this._observeContentMutations(),this._setupBackButtonListener()}attributeChangedCallback(e,t,n){t!==n&&(e===`containered`&&this._applyContainerClasses(),this.render())}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._removeBackButtonListener()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getHeading(){return this.getAttribute(`heading`)||``}getFallbackHref(){return this.getAttribute(`fallback-href`)||`/`}shouldShowBackButton(){return this.getAttribute(`show-back-button`)===`true`}render(){let 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));let e=this.getFallbackHref();t.setAttribute(`fallback-href`,e),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`,`true`),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(),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(e=>e!==this._pageContainer&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{this._actionsSlot&&e.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(e)}),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(e=>{e!==this._pageContainer&&e.getAttribute(`slot`)!==`actions`&&e!==this._actionsSlot&&e!==this._header&&e!==this._bodySlot&&e!==this._headingText&&e.parentElement!==this._bodySlot&&e.parentElement!==this._pageContainer&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add(`p-5`),this.getAttribute(`containered`)===`true`?this._pageContainer.classList.add(`max-w-6xl`,`mx-auto`,`w-full`):this._pageContainer.classList.remove(`max-w-6xl`,`mx-auto`,`w-full`))}_updateBackgroundColor(){this._pageContainer&&(document.documentElement.classList.contains(`dark`)?(this._pageContainer.classList.remove(`bg-gray-20`),this._pageContainer.classList.add(`bg-mint-canvas`)):(this._pageContainer.classList.remove(`bg-mint-canvas`),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`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_setupBackButtonListener(){this._backButtonHandler||=e=>{let t=e.target;if(t&&t.tagName===`MINT-BACK-BUTTON`){e.stopPropagation();let t=new CustomEvent(`back`,{detail:e.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t)}},this.addEventListener(`back`,this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&=(this.removeEventListener(`back`,this._backButtonHandler,!0),null)}};customElements.get(`mint-page`)||customElements.define(`mint-page`,u);var d=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,n){t!==n&&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(){let e=[`grid`],t=this.getColumns();e.push(`grid-cols-${t}`);let n=this.getSm();n&&e.push(`sm:grid-cols-${n}`);let r=this.getMd();r&&e.push(`md:grid-cols-${r}`);let i=this.getLg();i&&e.push(`lg:grid-cols-${i}`);let a=this.getXl();a&&e.push(`xl:grid-cols-${a}`);let o=this.getGap();return e.push(`gap-${o}`),e}render(){Array.from(this.classList).filter(e=>e.startsWith(`grid-cols-`)||e.startsWith(`sm:grid-cols-`)||e.startsWith(`md:grid-cols-`)||e.startsWith(`lg:grid-cols-`)||e.startsWith(`xl:grid-cols-`)||e.startsWith(`gap-`)).forEach(e=>this.classList.remove(e)),this.classList.contains(`grid`)||this.classList.add(`grid`),this.getGridClasses().forEach(e=>{e&&e!==`grid`&&this.classList.add(e)})}};customElements.get(`mint-grid`)||customElements.define(`mint-grid`,d);var f=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`]}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,this._contentObserver=null,this._renderFrame=null}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(),this._observeContentMutations()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black/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)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transform`,this._modal.appendChild(e)),this._animateEnter()}else this._animateExit();let r=this._modal.querySelector(`.modal-content`);r||(r=document.createElement(`div`),r.className=`modal-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transform`,this._modal.appendChild(r)),this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-mint-divider`,r.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 i=this._headingSlot.querySelector(`mint-text`);t?(i||(i=document.createElement(`mint-text`),i.setAttribute(`size`,`sub-heading`),i.setAttribute(`bold`,`true`),this._headingSlot.appendChild(i)),i.textContent=t):i&&i.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),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`),r.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),r.appendChild(this._actionsSlot));let a=this._actionsSlot.querySelector(`mint-stack`);a||(a=document.createElement(`mint-stack`),a.setAttribute(`direction`,`horizontal`),a.className=`justify-end`,this._actionsSlot.appendChild(a)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==a&&a.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;let e=document.documentElement.classList.contains(`dark`),t=this._modal.querySelector(`.modal-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`,`border`,`border-mint-divider`)):(t.classList.remove(`bg-mint-elevated`,`border`,`border-mint-divider`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,e.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})}))}_animateExit(){let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`hidden`);return}e.style.transition=`opacity 200ms ease-in, transform 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`,f);var p=class extends HTMLElement{static get observedAttributes(){return[`id`,`direction`,`open`,`trigger-id`,`padding`,`hover`,`distance`]}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}connectedCallback(){let e=this._isInsideModal()?`z-[60]`:`z-50`;this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`top-0`,`left-0`,e,`pointer-events-none`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._setupTrigger(),this._observeDarkMode()}_ownsNode(e){return e?!!(this.contains(e)||this._triggerElement?.contains(e)):!1}_isInsideModal(){let e=this;for(;e;){if(e.tagName===`MINT-MODAL`)return!0;e=e.parentElement}if(this._triggerElement)for(e=this._triggerElement;e;){if(e.tagName===`MINT-MODAL`)return!0;e=e.parentElement}return!1}disconnectedCallback(){this._removeHoverListeners(),this._overlay?.remove(),this._popover?.remove(),this._overlay=null,this._popover=null,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&this._triggerElement.removeAttribute(`active`),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!1),null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler,!0),this._triggerClickHandler=null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}attributeChangedCallback(e,t,n){if(t!==n){if(this.isConnected){let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this.classList.remove(`z-50`,`z-[60]`,`z-[80]`),this.classList.add(e)}this.render(),(e===`trigger-id`||e===`hover`)&&this._setupTrigger(),e===`open`&&this.isOpen()&&this._closeOtherPopovers()}}getId(){return this.getAttribute(`id`)||``}getPadding(){let 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`)||``}getDistance(){return(this.getAttribute(`distance`)||``).trim()}_getDistancePx(){let e=this.getDistance();if(!e)return 8;let t=e.match(/^(-?\d*\.?\d+)\s*(px|rem)$/i);if(!t)return 8;let n=parseFloat(t[1]),r=t[2].toLowerCase();if(!Number.isFinite(n))return 8;let i=Math.max(0,n);if(r===`px`)return i;let a=parseFloat(getComputedStyle(document.documentElement).fontSize||`16`);return i*(Number.isFinite(a)?a:16)}isHoverEnabled(){return this.getAttribute(`hover`)===`true`}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}_setupTrigger(){let 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){let e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.getAttribute(`open`)===`true`?e.removeAttribute(`open`):e.setAttribute(`open`,`true`)},this._triggerElement.addEventListener(`click`,this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();let e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){let n=t.relatedTarget;n&&e._ownsNode(n)||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){let n=t.relatedTarget;n&&e._ownsNode(n)||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(){let 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`};let 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`);let n=t.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=this._getDistancePx(),o=this.getDirection(),s=0,c=0;switch(o){case`down`:if(s=e.bottom+a,c=e.left+e.width/2-n.width/2,s+n.height>i){let t=e.top-n.height-a;t>=0?(o=`up`,s=t):(s=Math.max(0,i-n.height-a),s+n.height>i&&(s=0))}c<0&&(c=a),c+n.width>r&&(c=Math.max(a,r-n.width-a),c+n.width>r&&(c=r-n.width));break;case`up`:if(s=e.top-n.height-a,c=e.left+e.width/2-n.width/2,s<0){let t=e.bottom+a;t+n.height<=i?(o=`down`,s=t):(s=Math.min(i-n.height-a,i-n.height),s<0&&(s=i-n.height))}c<0&&(c=a),c+n.width>r&&(c=Math.max(a,r-n.width-a),c+n.width>r&&(c=r-n.width));break;case`right`:if(s=e.top+e.height/2-n.height/2,c=e.right+a,c+n.width>r){let t=e.left-n.width-a;t>=0?(o=`left`,c=t):(c=Math.max(0,r-n.width-a),c+n.width>r&&(c=r-n.width))}s<0&&(s=a),s+n.height>i&&(s=Math.max(a,i-n.height-a),s+n.height>i&&(s=i-n.height));break;case`left`:if(s=e.top+e.height/2-n.height/2,c=e.left-n.width-a,c<0){let t=e.right+a;t+n.width<=r?(o=`right`,c=t):(c=Math.min(r-n.width-a,r-n.width),c<0&&(c=0))}s<0&&(s=a),s+n.height>i&&(s=Math.max(a,i-n.height-a),s+n.height>i&&(s=i-n.height));break}return{top:s,left:c,direction:o}}render(){let e=this.getId(),t=this.isOpen(),n=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove(`hidden`),this.style.pointerEvents=`auto`,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&requestAnimationFrame(()=>{this._triggerElement.setAttribute(`active`,`true`);let e=this._triggerElement;typeof e.render==`function`&&requestAnimationFrame(()=>{e.render()})}),!this._clickOutsideHandler){let e=this;this._clickOutsideHandler=function(t){let n=t.composedPath(),r=n.some(t=>t===e?!0:t instanceof Node?e._ownsNode(t):!1);if(!(e._triggerElement&&n.includes(e._triggerElement))&&!r){e.close();return}},setTimeout(()=>{document.addEventListener(`click`,this._clickOutsideHandler,!1)},100)}}else this.classList.add(`hidden`),this.style.pointerEvents=`none`,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&requestAnimationFrame(()=>{this._triggerElement.removeAttribute(`active`);let e=this._triggerElement;typeof e.render==`function`&&requestAnimationFrame(()=>{e.render()})}),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!1),null);if(this._overlay){let e=this._isInsideModal()?`z-[75]`:`z-[55]`;this._overlay.className=`fixed inset-0 pointer-events-none ${e}`,this._overlay.parentElement!==this&&this.appendChild(this._overlay)}else{this._overlay=document.createElement(`div`);let e=this._isInsideModal()?`z-[75]`:`z-[55]`;this._overlay.className=`fixed inset-0 pointer-events-none ${e}`,this.appendChild(this._overlay)}if(this._popover){let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this._popover.className=`fixed ${e} pointer-events-auto`,this._popover.parentElement!==this&&this.appendChild(this._popover)}else{this._popover=document.createElement(`div`);let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this._popover.className=`fixed ${e} pointer-events-auto`,this.appendChild(this._popover)}this.isHoverEnabled()&&this._attachHoverListeners();let r=this._popover.querySelector(`.popover-content`);if(!r)r=document.createElement(`div`),r.className=`popover-content bg-white dark:bg-mint-elevated border border-gray-200 dark:border-mint-divider rounded-lg shadow-xl ${n} transform`,this._popover.appendChild(r);else{let e=r.className.split(/\s+/).filter(Boolean),t=[`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`],i=e.filter(e=>!t.includes(e)),a=[`border`,`border-gray-200`,`dark:border-mint-divider`],o=[...i];for(let e of a)o.includes(e)||o.push(e);r.className=[...o,n].join(` `)}Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._popover&&e.parentElement===this&&r.appendChild(e)}),t?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(r):(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`,r.style.transform=`scale(0.97) translateY(10px)`,r.style.opacity=`0`,r.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.style.transform=`scale(1) translateY(0)`,r.style.opacity=`1`})}))):!t&&r&&(this._removePositionListeners(),r.style.opacity!==`0`&&r.style.opacity!==``&&(r.style.transition=`opacity 200ms ease-in, transform 200ms ease-in`,r.style.transform=`scale(0.97) translateY(10px)`,r.style.opacity=`0`,setTimeout(()=>{r.style.transform=``,r.style.opacity=``,r.style.transition=``,this._popover.style.visibility=``,this._popover.style.display=``},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;let e=document.documentElement.classList.contains(`dark`),t=this._popover.querySelector(`.popover-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`)):(t.classList.remove(`bg-mint-elevated`),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;let 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;let n=this._calculatePosition();this._popover.style.top=`${n.top}px`,this._popover.style.left=`${n.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=`opacity 200ms ease-out, transform 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){let e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);t&&e._updatePosition(t)}},window.addEventListener(`scroll`,this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){let e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);t&&e._updatePosition(t)}},window.addEventListener(`resize`,this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}_closeOtherPopovers(){Array.from(document.querySelectorAll(`mint-popover[open]`)).forEach(e=>{if(e!==this){let t=e;typeof t.close==`function`?t.close():e.removeAttribute(`open`)}})}};customElements.get(`mint-popover`)||customElements.define(`mint-popover`,p);var m=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`,`error`,`error-message`,`loading`]}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}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`),this._checked=this.getAttribute(`checked`)===`true`,this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`,this._checkbox&&(this._checkbox.checked=this._checked)),t!==n){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(){try{return this._checked||!1}catch{return!1}}set checked(e){try{e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}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.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getCheckboxClasses(){let e=this.hasError(),t=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded`,`border-2`,`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`],n=this._checked?[`bg-neutral-800`,`dark:bg-neutral-600`,e?`border-red-300 dark:border-red-300`:`border-neutral-800 dark:border-neutral-600`]:[`bg-white`,`dark:bg-mint-elevated`,e?`border-red-300 dark:border-red-300`:`border-gray-300 dark:border-gray-500`];return[...t,...n].join(` `)}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.isDisabled(),i=this.querySelector(`.mint-checkbox-container`);i||(i=document.createElement(`div`),i.className=`mint-checkbox-container relative inline-flex items-start gap-2`,this.insertBefore(i,this.firstChild));let a=this.querySelector(`.mint-checkbox-wrapper`);a?a.parentElement!==i&&i.appendChild(a):(a=document.createElement(`div`),a.className=`mint-checkbox-wrapper`,i.appendChild(a)),this._checkbox?this._checkbox.parentElement!==a&&a.appendChild(this._checkbox):(this._checkbox=document.createElement(`input`),this._checkbox.type=`checkbox`,a.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=r,this._changeHandler||this.setupEventListeners();let o=this.getId();o?this._checkbox.id=o:this._checkbox.removeAttribute(`id`);let s=this.getName();s?this._checkbox.name=s:this._checkbox.removeAttribute(`name`);let c=this.getValue();c?this._checkbox.value=c:this._checkbox.removeAttribute(`value`),t?this._checkbox.setAttribute(`aria-label`,t):this._checkbox.removeAttribute(`aria-label`),a.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,a.style.cursor=`pointer`,a.style.pointerEvents=`auto`,this._checkbox.style.pointerEvents=`auto`;let l=a;l._wrapperClickHandler||(l._wrapperClickHandler=e=>{e.target===a&&!r&&(e.preventDefault(),e.stopPropagation(),this.toggle())},a.addEventListener(`click`,l._wrapperClickHandler));let u=a.querySelector(`mint-icon`);u||(u=document.createElement(`mint-icon`),u.setAttribute(`name`,`check`),u.className=`w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto`,u.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,u.style.zIndex=`1`,a.appendChild(u)),this.updateVisualState();let d=this.querySelector(`.mint-checkbox-label-container`),f=this.querySelector(`.mint-checkbox-container`);if(t||n){d?f&&d.parentElement!==f&&f.appendChild(d):(d=document.createElement(`div`),d.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,f?f.appendChild(d):this.appendChild(d));let e=d.querySelector(`.mint-checkbox-label`);t?(e||(e=document.createElement(`span`),e.className=`mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,d.insertBefore(e,d.firstChild)),e.textContent=t,r?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)):e&&e.remove();let i=d.querySelector(`.mint-checkbox-info`);if(n?(i||(i=document.createElement(`span`),i.className=`mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,d.appendChild(i)),i.textContent=n,r?i.classList.add(`opacity-40`):i.classList.remove(`opacity-40`)):i&&i.remove(),r)d.style.cursor=`default`,d._clickHandler&&(d.removeEventListener(`click`,d._clickHandler),d._clickHandler=null);else{d.style.cursor=`pointer`;let e=d._clickHandler;e&&d.removeEventListener(`click`,e),d._clickHandler=e=>{this._checkbox&&(e.target===this._checkbox||this._checkbox.contains(e.target)||e.composedPath().includes(this._checkbox))||this.toggle()},d.addEventListener(`click`,d._clickHandler)}}else d&&d.remove();this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this.updateVisualState();let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}));let n=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(n)},this._checkbox.addEventListener(`change`,this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(38 38 38)`,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(64 64 64)`:t.style.backgroundColor=`rgb(48 48 48)`))},this._mouseupHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&(t.classList.remove(`mint-checkbox-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._mouseleaveHandler=e=>{let 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=>{let t=this.querySelector(`.mint-checkbox-wrapper`);t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(`:focus-visible`)&&t?.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)})},this._blurHandler=()=>{let 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();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(38 38 38)`,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(64 64 64)`:t.style.backgroundColor=`rgb(48 48 48)`))},this._touchendHandler=e=>{e.stopPropagation();let 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),null),this._mousedownHandler&&=(this._checkbox.removeEventListener(`mousedown`,this._mousedownHandler),null),this._mouseupHandler&&=(this._checkbox.removeEventListener(`mouseup`,this._mouseupHandler),null),this._mouseleaveHandler&&=(this._checkbox.removeEventListener(`mouseleave`,this._mouseleaveHandler),null),this._touchstartHandler&&=(this._checkbox.removeEventListener(`touchstart`,this._touchstartHandler),null),this._touchendHandler&&=(this._checkbox.removeEventListener(`touchend`,this._touchendHandler),null),this._focusHandler&&=(this._checkbox.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._checkbox.removeEventListener(`blur`,this._blurHandler),null));let e=this.querySelector(`.mint-checkbox-wrapper`);if(e){let t=e;t._wrapperClickHandler&&=(e.removeEventListener(`click`,t._wrapperClickHandler),null)}}updateVisualState(){let e=this.querySelector(`.mint-checkbox-wrapper`),t=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.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this.updateVisualState(),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0}));let 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`),n=this.querySelector(`.mint-checkbox-container`),r=this.querySelector(`.mint-checkbox-wrapper`),i=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`,n?n.appendChild(t):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-checkbox-skeleton-box`);if(e||(e=document.createElement(`div`),e.className=`mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e)),i){let e=t.querySelector(`.mint-checkbox-skeleton-label`);e||(e=document.createElement(`div`),e.className=`mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e))}t.style.display=`flex`,r&&(r.style.visibility=`hidden`,r.style.pointerEvents=`none`),i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),r&&(r.style.visibility=`visible`,r.style.pointerEvents=`auto`),i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-checkbox-label-container`);!n&&e&&t&&(n=document.createElement(`div`),n.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(n));let r=this.querySelector(`.mint-checkbox-error`);e&&t?(r?(r.classList.add(`block`,`w-full`),r.style.display=`block`,(n&&r.parentElement!==n||n&&r.parentElement===n)&&n.appendChild(r)):(r=document.createElement(`div`),r.className=`mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full`,r.style.display=`block`,n?n.appendChild(r):this.appendChild(r)),r.textContent=t):r&&r.remove();let i=this.querySelector(`.mint-checkbox-wrapper`);i&&(i.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}};customElements.get(`mint-checkbox`)||customElements.define(`mint-checkbox`,m);var h=class extends HTMLElement{static get observedAttributes(){return[`value`,`checked`,`disabled`,`loading`,`info`]}constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}connectedCallback(){this.classList.add(`inline-flex`,`items-start`,`gap-2`,`cursor-pointer`,`select-none`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._radio&&(this._changeHandler&&=(this._radio.removeEventListener(`change`,this._changeHandler),null),this._focusHandler&&=(this._radio.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._radio.removeEventListener(`blur`,this._blurHandler),null),this._keydownHandler&&=(this._radio.removeEventListener(`keydown`,this._keydownHandler),null))}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`,this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),t!==n){if(e===`loading`){this.render();return}if(e===`info`){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(e){try{this._checked=!!e,e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}catch{}}getValue(){return this.getAttribute(`value`)||``}getInfo(){return this.getAttribute(`info`)||``}isDisabled(){let e=this.getAttribute(`disabled`)===`true`,t=this.closest(`mint-choice`)?.getAttribute(`disabled`)===`true`;return e||t}_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`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState();let e=this.closest(`mint-choice`);e&&e.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener(`click`,this._clickHandler))}render(){let e=this.isLoading(),t=this.isDisabled(),n=this.getValue(),r=this.closest(`mint-choice`)?.getAttribute(`name`)||``,i=``,a=this.querySelector(`.mint-choice-option-label`);if(a)i=a.textContent?.trim()||``;else{let e=this.querySelector(`.mint-choice-option-label-container`);Array.from(this.childNodes).forEach(t=>{if(t!==e&&t.nodeType===Node.TEXT_NODE){let e=t.textContent?.trim();e&&(i+=e)}})}let o=this.querySelectorAll(`.mint-choice-option-wrapper`),s=null;o.length>0&&(this._radio&&(s=Array.from(o).find(e=>e.contains(this._radio))),s||=o[0],o.forEach((e,t)=>{e!==s&&e.remove()})),s||(s=document.createElement(`div`),s.className=`mint-choice-option-wrapper`,s.style.position=`relative`,this.insertBefore(s,this.firstChild)),s.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,s.style.position=`relative`,this.querySelectorAll(`input[type="radio"]`).forEach(e=>{e!==this._radio&&e.remove()}),this._radio?(this._radio.parentElement!==s&&s.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener(`change`,this._changeHandler),this._radio.addEventListener(`change`,this._changeHandler)),this._radio&&(this._focusHandler||=e=>{let t=this.querySelector(`.mint-choice-option-wrapper`);t&&!this.isDisabled()&&t.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._blurHandler||=()=>{let e=this.querySelector(`.mint-choice-option-wrapper`);e&&e.classList.remove(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._keydownHandler||=e=>{this.isDisabled()||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),this._focusNextOption()):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.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))):(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`,s.appendChild(this._radio),this._changeHandler=e=>{let t=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState();let n=this.closest(`mint-choice`);t!==this._checked&&n&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener(`change`,this._changeHandler),this._radio.addEventListener(`click`,()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState())}),this._focusHandler=e=>{let t=this.querySelector(`.mint-choice-option-wrapper`);t&&!this.isDisabled()&&t.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._radio.addEventListener(`focus`,this._focusHandler),this._blurHandler=()=>{let e=this.querySelector(`.mint-choice-option-wrapper`);e&&e.classList.remove(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._radio.addEventListener(`blur`,this._blurHandler),this._keydownHandler=e=>{this.isDisabled()||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),this._focusNextOption()):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener(`keydown`,this._keydownHandler)),this._radio.name=r,this._radio.value=n,this._radio.checked===this._checked?this._radio.checked=this._checked:(this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`)),this._radio.disabled=t,t?this._radio.setAttribute(`tabindex`,`-1`):this._radio.removeAttribute(`tabindex`),i?this._radio.setAttribute(`aria-label`,i):this._radio.removeAttribute(`aria-label`),s.querySelectorAll(`.mint-choice-option-indicator`).forEach((e,t)=>{t>0&&e.remove()});let c=s.querySelector(`.mint-choice-option-indicator`);c||(c=document.createElement(`div`),c.className=`mint-choice-option-indicator`,s.appendChild(c)),c.className=`mint-choice-option-indicator w-2 h-2 rounded-full bg-white pointer-events-none`,c.style.position=`absolute`,c.style.top=`50%`,c.style.left=`50%`,c.style.transform=this._checked?`translate(-50%, -50%) scale(1)`:`translate(-50%, -50%) scale(0)`,c.style.opacity=this._checked?`1`:`0`,this._updateVisualState(),this._renderSkeleton(e);let l=this.getInfo(),u=this.querySelector(`.mint-choice-option-label-container`);if(i||l){u||(u=document.createElement(`div`),u.className=`mint-choice-option-label-container flex flex-col gap-0.5`,this.appendChild(u),Array.from(this.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&e.textContent?.trim()&&e!==u&&(e.textContent=``)}));let e=u.querySelector(`.mint-choice-option-label`);i?(e||(e=document.createElement(`span`),e.className=`mint-choice-option-label`,u.appendChild(e)),e.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t?`opacity-40`:``}`,e.textContent=i):e&&e.remove();let n=u.querySelector(`.mint-choice-option-info`);l?(n||(n=document.createElement(`span`),n.className=`mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none`,u.appendChild(n)),n.textContent=l,t?n.classList.add(`opacity-40`):n.classList.remove(`opacity-40`)):n&&n.remove()}else u&&u.remove();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(){let e=this.isDisabled(),t=[`inline-flex`,`items-center`,`justify-center`,`w-[1rem]`,`h-[1rem]`,`rounded-full`,`border-2`,`flex-shrink-0`,`mt-0.5`];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-mint-elevated`,`border-gray-300`,`dark:border-gray-500`),t.join(` `)}_updateVisualState(){let e=this.querySelector(`.mint-choice-option-wrapper`);e&&(e.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);let 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`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-choice-option-skeleton-radio`);if(e||(e=document.createElement(`div`),e.className=`mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`input[type="radio"]`),t=n.querySelector(`.mint-choice-option-indicator`);e&&(e.style.visibility=`hidden`),t&&(t.style.visibility=`hidden`),n.style.pointerEvents=`none`}}else{if(t&&(t.style.display=`none`),n){let e=n.querySelector(`input[type="radio"]`),t=n.querySelector(`.mint-choice-option-indicator`);e&&(e.style.visibility=`visible`),t&&(t.style.visibility=`visible`),n.style.pointerEvents=`auto`}let e=this.querySelector(`.mint-choice-option-label`);e&&!n?.contains(e)&&(e.style.visibility=`visible`,e.style.pointerEvents=`auto`)}}_updateGroupState(){this._radio?.name&&document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(e=>{if(e===this._radio)return;let t=e.closest(`mint-choice-option`);t&&t!==this&&(t._checked=e.checked,e.checked?t.setAttribute(`checked`,`true`):t.removeAttribute(`checked`),t._updateVisualState())})}_focusNextOption(){if(!this._radio?.name)return;let e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(e=>!e.disabled),t=e.indexOf(this._radio),n=null;if(t>=0&&t<e.length-1?n=e[t+1]:e.length>0&&(n=e[0]),n){let e=n.closest(`mint-choice-option`);if(n.checked=!0,e){let t=e._checked;if(e._checked=!0,e.setAttribute(`checked`,`true`),e._changeHandler){let t=new Event(`change`,{bubbles:!0});e._changeHandler.call(e,t)}else e._updateVisualState(),e._updateGroupState();let n=e.closest(`mint-choice`);n&&!t&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:!0,value:e.getValue()},bubbles:!0,cancelable:!0}))},0)}n.focus(),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}_focusPreviousOption(){if(!this._radio?.name)return;let e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(e=>!e.disabled),t=e.indexOf(this._radio),n=null;if(t>0?n=e[t-1]:e.length>0&&(n=e[e.length-1]),n){let e=n.closest(`mint-choice-option`);if(n.checked=!0,e){let t=e._checked;if(e._checked=!0,e.setAttribute(`checked`,`true`),e._changeHandler){let t=new Event(`change`,{bubbles:!0});e._changeHandler.call(e,t)}else e._updateVisualState(),e._updateGroupState();let n=e.closest(`mint-choice`);n&&!t&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:!0,value:e.getValue()},bubbles:!0,cancelable:!0}))},0)}n.focus(),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}};customElements.get(`mint-choice-option`)||customElements.define(`mint-choice-option`,h);var g=class extends HTMLElement{static get observedAttributes(){return[`label`,`name`,`info`,`error`,`error-message`,`id`,`disabled`,`required`,`loading`]}constructor(){super(),this._optionsContainer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`,`w-full`),this.render(),this.addEventListener(`choice-change`,e=>{let t=e.detail?.value||this.getValue();(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))})}disconnectedCallback(){}isLoading(){return this.hasAttribute(`loading`)}attributeChangedCallback(e,t,n){t!==n&&(e===`error`||e===`error-message`?this._renderErrorState():e===`loading`?(this.render(),this.querySelectorAll(`mint-choice-option`).forEach(e=>{this.isLoading()?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`)})):(this.render(),e===`name`&&this.querySelectorAll(`mint-choice-option`).forEach(e=>{typeof e.render==`function`&&e.render()})))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}getValue(){return this.querySelector(`input[type="radio"]:checked`)?.value||``}setValue(e){let t=this.querySelectorAll(`mint-choice-option`);t.forEach(t=>{if((t.getAttribute(`value`)||``)===e){let e=t;e.checked=!0;let n=t.querySelector(`input[type="radio"]`);n&&(n.checked=!0,n.dispatchEvent(new Event(`change`,{bubbles:!0})))}else{let e=t;e.checked=!1;let n=t.querySelector(`input[type="radio"]`);n&&(n.checked=!1)}}),requestAnimationFrame(()=>{t.forEach(e=>{typeof e._updateVisualState==`function`&&e._updateVisualState();let t=e.querySelector(`input[type="radio"]`);if(t){let n=e;t.checked!==n.checked&&(t.checked=n.checked)}})})}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{this.setValue(e||``)}catch{}}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute(`id`,r);let i=this.isDisabled(),a=this.querySelector(`.mint-choice-label-container`);if(t||n){a||(a=document.createElement(`div`),a.className=`mint-choice-label-container flex flex-col gap-0.5 mb-2`,this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-choice-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.insertBefore(e,a.firstChild)),e.textContent=t,e.setAttribute(`for`,r),i?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)):e&&e.remove();let o=a.querySelector(`.mint-choice-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none`,a.appendChild(o)),o.textContent=n,i?o.classList.add(`opacity-40`):o.classList.remove(`opacity-40`)):o&&o.remove()}else a&&a.remove();let o=this.querySelector(`.mint-choice-options-wrapper`);if(!o){o=document.createElement(`div`),o.className=`mint-choice-options-wrapper relative`;let e=this.querySelector(`.mint-choice-label-container`);e&&e.parentElement===this?this.insertBefore(o,e.nextSibling):this.insertBefore(o,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==o&&o.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement(`div`),this._optionsContainer.className=`mint-choice-options-container flex flex-col gap-3`,o.appendChild(this._optionsContainer)),Array.from(this.children).filter(e=>e.tagName===`MINT-CHOICE-OPTION`&&e.parentElement!==this._optionsContainer).forEach(e=>{this._optionsContainer.appendChild(e)}),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-choice-skeleton-container`),n=this.querySelector(`.mint-choice-options-wrapper`),r=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`,n?n.appendChild(t):(this.style.position=`relative`,this.appendChild(t))),t.querySelectorAll(`.mint-choice-option-skeleton`).length===0)for(let e=0;e<3;e++){let e=document.createElement(`div`);e.className=`mint-choice-option-skeleton flex items-center gap-3`;let n=document.createElement(`div`);n.className=`flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,e.appendChild(n);let r=document.createElement(`div`);r.className=`h-4 w-20 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,e.appendChild(r),t.appendChild(e)}t.style.display=`flex`,r&&(r.style.opacity=`0`,r.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),r&&(r.style.opacity=`1`,r.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-choice-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-choice`)||customElements.define(`mint-choice`,g);var _=class extends HTMLElement{static get observedAttributes(){return[`type`,`placeholder`,`value`,`disabled`,`id`,`name`,`required`,`readonly`,`rows`,`icon`,`label`,`info`,`error`,`error-message`,`loading`]}constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._prependSlotContainer=null,this._appendSlotContainer=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._slotResizeObserver=null,this._slotMutationObserver=null,this._contentObserver=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._observeContentMutations()}disconnectedCallback(){this.removeEventListeners(),this._slotResizeObserver&&=(this._slotResizeObserver.disconnect(),null),this._slotMutationObserver&&=(this._slotMutationObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){if(t!==n){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()}}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getType(){return this.getAttribute(`type`)||`text`}getRows(){let e=this.getAttribute(`rows`);return e?parseInt(e,10):3}_getNormalizedType(){let 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(){return this._isColor()?this._colorTextInput?this._colorTextInput.value:this._colorPicker?this._colorPicker.value:this.getAttribute(`value`)||`#000000`:this._element?this._element.value:this.getAttribute(`value`)||``}set value(e){try{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`)}catch{}}get value(){try{return this.getValue()||``}catch{return``}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}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(){let e=this._isTextarea(),t=!!this.getIcon(),n=this.querySelector(`[slot="prepend"]`)!==null,r=this.querySelector(`[slot="append"]`)!==null,i=this._isColor(),a=this._isNumber(),o=this.hasError(),s=[`w-full`,t||i||n?`pl-10`:`px-3.5`,r?`pr-10`:t||i?`pr-3.5`:a?`pr-10`:``,e?`py-2`:`py-1.5`,e?`min-h-[6rem]`:`min-h-[2rem]`,`text-base`,`min-[1100px]:text-sm`,`font-medium`,`rounded-lg`,`box-border`,`bg-white`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`readonly:cursor-default`,e?`resize-y`:``,a?`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`:``],c=[`border-2`,o?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],l=[`focus-visible:ring-2`,`focus-visible:ring-offset-1`,o?`focus-visible:ring-red-400 dark:focus-visible:ring-red-500`:`focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`];return[...s,...c,...l].filter(Boolean).join(` `)}_syncSlotAdornments(e,t){if(!this._wrapper||e||this._isColor()){this._prependSlotContainer&&=(this._prependSlotContainer.remove(),null),this._appendSlotContainer&&=(this._appendSlotContainer.remove(),null),this._clearAdornmentPadding();return}this._prependSlotContainer||(this._prependSlotContainer=document.createElement(`div`),this._prependSlotContainer.className=`mint-input-prepend-slot absolute top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1.5 text-gray-500 dark:text-gray-400 pointer-events-auto`,this._wrapper.appendChild(this._prependSlotContainer)),this._appendSlotContainer||(this._appendSlotContainer=document.createElement(`div`),this._appendSlotContainer.className=`mint-input-append-slot absolute right-3 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1.5 text-gray-500 dark:text-gray-400 pointer-events-auto`,this._wrapper.appendChild(this._appendSlotContainer)),this._prependSlotContainer.classList.remove(`left-3`,`left-10`),this._prependSlotContainer.classList.add(t?`left-10`:`left-3`);let n=Array.from(this.querySelectorAll(`[slot="prepend"]`)),r=Array.from(this.querySelectorAll(`[slot="append"]`));this._prependSlotContainer.replaceChildren(),this._appendSlotContainer.replaceChildren(),n.forEach(e=>this._prependSlotContainer.appendChild(e)),r.forEach(e=>this._appendSlotContainer.appendChild(e)),this._prependSlotContainer.classList.toggle(`hidden`,n.length===0),this._appendSlotContainer.classList.toggle(`hidden`,r.length===0),this._ensureSlotObservers(),this._applyAdornmentPadding(t)}_clearAdornmentPadding(){this._element&&(this._element.style.removeProperty(`padding-left`),this._element.style.removeProperty(`padding-right`)),this._colorTextInput&&(this._colorTextInput.style.removeProperty(`padding-left`),this._colorTextInput.style.removeProperty(`padding-right`))}_applyAdornmentPadding(e){this._element&&requestAnimationFrame(()=>{if(this._element){if(this._prependSlotContainer&&!this._prependSlotContainer.classList.contains(`hidden`)){let t=(e?40:12)+this._prependSlotContainer.offsetWidth+8;this._element.style.paddingLeft=`${t}px`}else this._element.style.removeProperty(`padding-left`);if(this._appendSlotContainer&&!this._appendSlotContainer.classList.contains(`hidden`)){let e=12+this._appendSlotContainer.offsetWidth+8;this._element.style.paddingRight=`${e}px`}else this._element.style.removeProperty(`padding-right`)}})}_ensureSlotObservers(){!this._prependSlotContainer&&!this._appendSlotContainer||(this._slotResizeObserver||=new ResizeObserver(()=>{this._applyAdornmentPadding(!!this.getIcon())}),this._slotResizeObserver.disconnect(),this._prependSlotContainer&&this._slotResizeObserver.observe(this._prependSlotContainer),this._appendSlotContainer&&this._slotResizeObserver.observe(this._appendSlotContainer),this._slotMutationObserver||=new MutationObserver(()=>{this._applyAdornmentPadding(!!this.getIcon())}),this._slotMutationObserver.disconnect(),this._prependSlotContainer&&this._slotMutationObserver.observe(this._prependSlotContainer,{childList:!0,subtree:!0,characterData:!0}),this._appendSlotContainer&&this._slotMutationObserver.observe(this._appendSlotContainer,{childList:!0,subtree:!0,characterData:!0}))}isLoading(){return this.getAttribute(`loading`)===`true`}render(){this.getType();let e=this._getNormalizedType(),t=this._isTextarea(),n=this._isMoney(),r=this._isColor(),i=this.getPlaceholder(),a=this.isDisabled(),o=this.isReadonly(),s=this.isRequired(),c=this.getId(),l=this.getName(),u=this.getAttribute(`value`)||(r?`#000000`:``),d=this.getRows(),f=this.getIcon(),p=this.getLabel(),m=this.getInfo(),h=this.isLoading();if(this._renderSkeleton(h),r){this._input&&=(this._input.remove(),null),this._textarea&&=(this._textarea.remove(),null),this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`relative w-full`,this.appendChild(this._wrapper)),this._colorContainer&&=(this._colorContainer.remove(),null),this._colorPickerWrapper&&!r&&(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=u||`#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=e=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&requestAnimationFrame(()=>{this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&this._colorPickerWrapper?.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`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this._colorTextInput&&(this._colorTextInput.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener(`change`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement(`input`),this._colorTextInput.type=`text`,this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=i||`#000000`,this._colorTextInput.pattern=`^#[0-9A-Fa-f]{6}$`,this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener(`input`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)&&(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener(`blur`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)?(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this._colorPicker?.value||`#000000`},bubbles:!0,cancelable:!0}))}));let e=u||`#000000`;if(this._colorPicker&&this._colorPicker.value!==e&&(this._colorPicker.value=e),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this._colorTextInput&&this._colorTextInput.value!==e&&(this._colorTextInput.value=e),this._colorPicker&&(this._colorPicker.disabled=a),this._colorPickerWrapper&&(a?(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=a,this._colorTextInput.readOnly=o,this._colorTextInput.required=s),this._colorTextInput){let e=this._colorTextInput;c?e.id=c:e.removeAttribute(`id`),l?e.name=l:e.removeAttribute(`name`),e.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._element=e}this._renderErrorState();let t=this.querySelector(`.mint-input-label-container`);if(p||m){t||(t=document.createElement(`div`),t.className=`mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(t,this._wrapper):this.insertBefore(t,this.firstChild));let e=t.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,t.insertBefore(e,t.firstChild)),e.textContent=p;let n=c||this._colorTextInput?.id;if(n)e.setAttribute(`for`,n);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._colorTextInput&&(this._colorTextInput.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)}else e&&e.remove();let n=t.querySelector(`.mint-input-info`);m?(n||(n=document.createElement(`span`),n.className=`mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none`,t.appendChild(n)),n.textContent=m,a?n.classList.add(`opacity-40`):n.classList.remove(`opacity-40`)):n&&n.remove()}else t&&t.remove();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&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),f&&!t?this._icon?this._icon.setAttribute(`name`,f):(this._icon=document.createElement(`mint-icon`),this._icon.setAttribute(`name`,f),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(),null),this._syncSlotAdornments(t,!!f),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 pointer-events-auto bg-gray-100 dark:bg-mint-hover active:bg-gray-200 dark:active:bg-mint-elevated rounded`;let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`caret-up`),e.className=`w-[1rem] h-[1rem]`,this._numberIncrementButton.appendChild(e),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement(`button`),this._numberDecrementButton.type=`button`,this._numberDecrementButton.className=`flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed pointer-events-auto bg-gray-100 dark:bg-mint-hover active:bg-gray-200 dark:active:bg-mint-elevated rounded`;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`caret-down`),t.className=`w-[1rem] h-[1rem]`,this._numberDecrementButton.appendChild(t),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e+t;r!==void 0&&i>r&&(i=r),n!==void 0&&i<n&&(i=n),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}}),this._numberDecrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e-t;n!==void 0&&i<n&&(i=n),r!==void 0&&i>r&&(i=r),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=a||o),this._numberDecrementButton&&(this._numberDecrementButton.disabled=a||o)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){if(this._input&&=(this._input.remove(),null),this._textarea||(this._textarea=document.createElement(`textarea`),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=i,this._textarea.disabled=a,this._textarea.readOnly=o,this._textarea.required=s,this._textarea.rows=d,this._textarea.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),u!==this._textarea.value&&(this._textarea.value=u),c?this._textarea.id=c:this._textarea.removeAttribute(`id`),l?this._textarea.name=l:this._textarea.removeAttribute(`name`),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._textarea.value&&(this._textarea.value=e.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&=(this._textarea.remove(),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=i,this._input.disabled=a,this._input.readOnly=o,this._input.required=s,this._input.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),n?(this._input.inputMode=`decimal`,this._input.pattern=`[0-9]*\\.?[0-9]*`):(this._input.removeAttribute(`inputmode`),this._input.removeAttribute(`pattern`)),u!==this._input.value&&(this._input.value=u),c?this._input.id=c:this._input.removeAttribute(`id`),l?this._input.name=l:this._input.removeAttribute(`name`),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._input.value&&(this._input.value=e.trim()),this.removeChild(this.firstChild)}let g=this.querySelector(`.mint-input-label-container`);if(p||m){g||(g=document.createElement(`div`),g.className=`mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let e=g.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,g.insertBefore(e,g.firstChild)),e.textContent=p;let t=c||this._element?.id||this._colorTextInput?.id||this._input?.id||this._textarea?.id;if(t)e.setAttribute(`for`,t);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=t:this._colorTextInput?this._colorTextInput.id=t:this._input?this._input.id=t:this._textarea&&(this._textarea.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)}else e&&e.remove();let t=g.querySelector(`.mint-input-info`);m?(t||(t=document.createElement(`span`),t.className=`mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none`,g.appendChild(t)),t.textContent=m,a?t.classList.add(`opacity-40`):t.classList.remove(`opacity-40`)):t&&t.remove()}else g&&g.remove();this._syncSlotAdornments(t,!!f),this._renderErrorState(),this._renderSkeleton(h)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-input-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-input-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}setupEventListeners(){this._element&&(this._element.addEventListener(`input`,()=>{let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`);let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener(`blur`,()=>{let e=this._element?.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),null),this._blurHandler&&=(this._colorPicker.removeEventListener(`blur`,this._blurHandler),null))}focus(){this._isColor()&&this._colorTextInput?this._colorTextInput.focus():this._element?.focus()}blur(){this._isColor()&&this._colorTextInput?this._colorTextInput.blur():this._element?.blur()}_renderSkeleton(e){let t=this.querySelector(`.mint-input-skeleton-container`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-input-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this._isTextarea(),r=this.getRows();if(n){let t=r*24+12;e.style.height=`${t}px`}else e.style.height=`2.2rem`;t.appendChild(e)}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`,_);var v=class extends HTMLElement{static get observedAttributes(){return[`value`,`label`,`info`,`disabled`,`id`,`name`,`required`,`readonly`,`format`,`min`,`max`,`range`,`shortcuts`,`display-format`,`error`,`error-message`,`loading`,`selection-mode`,`week-start-day`,`mode`,`disabled-dates`]}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._hoveredDate=null,this._isHandlingClick=!1,this._touchStartDate=null,this._touchStartElement=null,this._isTouchActive=!1,this._resizeObserver=null,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}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(),null),this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._removeFocusTrap(),this._resetHandler){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){let e=this.hasError(),t=this.getErrorMessage();this._applyErrorVisuals(e,t,this.isDisabled());return}if(e===`loading`){this.render();return}if(e===`mode`||e===`format`){let e=this.getMode();e===`month`?this._viewMode=`month`:e===`year`?this._viewMode=`year`:this._viewMode=`calendar`,this._popover&&this._calendarContainer&&this._buildCalendar()}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()}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{this.setValue(e||``)}catch{}}getFormat(){return this.getAttribute(`format`)||`mm/dd/yyyy`}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isRange(){return this.getAttribute(`range`)===`true`}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getMin(){return this.getAttribute(`min`)||``}getMax(){return this.getAttribute(`max`)||``}getDisabledDates(){let e=this.getAttribute(`disabled-dates`);if(!e)return[];try{let t=JSON.parse(e),n=this.getFormat();return t.map(e=>this._parseDateString(e,n)).filter(e=>e!==null)}catch{return[]}}getDisabledDateStrings(){let e=this.getAttribute(`disabled-dates`);if(!e)return[];try{return JSON.parse(e)}catch{return[]}}disableDate(e){let t=this.getFormat(),n=this.getDisabledDateStrings(),r=Array.isArray(e)?e:[e],i=[];for(let e of r){let r=this._parseDateString(e,t);if(r){let e=this._formatDate(r,t);n.includes(e)||i.push(e)}}if(i.length>0){let e=[...n,...i];this.setAttribute(`disabled-dates`,JSON.stringify(e)),this._buildCalendar()}}enableDate(e){let t=this.getFormat(),n=this.getDisabledDateStrings(),r=Array.isArray(e)?e:[e],i=[];for(let e of r){let n=this._parseDateString(e,t);if(n){let e=this._formatDate(n,t);i.push(e)}}if(i.length>0){let e=n.filter(e=>!i.includes(e));e.length===0?this.removeAttribute(`disabled-dates`):this.setAttribute(`disabled-dates`,JSON.stringify(e)),this._buildCalendar()}}getSelectionMode(){let e=this.getAttribute(`selection-mode`);return e===`week`||e===`month`?e:`day`}getMode(){let e=this.getAttribute(`mode`);if(e===`month`||e===`year`)return e;let t=this.getFormat().toLowerCase(),n=t.includes(`d`),r=t.includes(`m`);return!n&&!r?`year`:!n&&r?`month`:`default`}getWeekStartDay(){return{sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6}[this.getAttribute(`week-start-day`)?.toLowerCase()||`sunday`]??0}getDisplayFormat(){return this.getAttribute(`display-format`)||`F j, Y`}getShortcuts(){let e=this.getAttribute(`shortcuts`);if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(e=>({label:e.label,action:this._createShortcutAction(e.action)}))}catch{let t=e.trim();if(t&&typeof window[t]==`function`){let e=window[t]();if(Array.isArray(e))return e.map(e=>({label:e.label,action:typeof e.action==`function`?e.action:this._createShortcutAction(e.action)}))}}return[]}_createShortcutAction(e){return typeof e==`function`?e:typeof e==`string`&&typeof window[e]==`function`?window[e]:()=>null}_getDefaultShortcuts(){let e=[{label:`Today`,action:()=>new Date}];return this._isRange&&e.push({label:`This Week`,action:()=>{let e=new Date,t=e.getDay(),n=new Date(e);n.setDate(e.getDate()-t),n.setHours(0,0,0,0);let r=new Date(n);return r.setDate(n.getDate()+6),r.setHours(23,59,59,999),{start:n,end:r}}},{label:`This Month`,action:()=>{let e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return n.setHours(23,59,59,999),{start:t,end:n}}}),e}_getFormatTokens(e){let t=[],n=0,r=e.toLowerCase();for(;n<r.length;){let i=r[n];if(i===`d`||i===`m`||i===`y`){let e=1,a=n+1;for(;a<r.length&&r[a]===i;)e++,a++;t.push({type:`part`,part:i,len:e}),n=a}else t.push({type:`sep`,value:e[n]}),n++}return t}_createPartInput(e,t,n,r,i){let a=document.createElement(`input`);return a.type=`text`,a.inputMode=`numeric`,a.pattern=`\\d*`,a.maxLength=e,a.placeholder=t,a.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`,a.disabled=n||r,a.readOnly=r,a.required=i,e===4?a.className+=` w-[40px]`:e===2&&(a.className+=` w-[30px]`),a}_buildValueFromParts(e,t){let n=0;return t.map(t=>{if(t.type===`sep`)return t.value;let r=e[n]?.value||``;return n++,r}).join(``)}_applyDateToParts(e,t,n,r){if(!t.length)return;if(!e){t.forEach(e=>e.value=``);return}let i=this._formatDate(e,r),a=0,o=0;n.forEach(e=>{if(e.type===`sep`)a+=e.value.length;else{let n=i.substr(a,e.len);t[o]&&(t[o].value=n),o++,a+=e.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;let e=this.getFormat(),t=this._getFormatTokens(e),n=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){let e=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=e?`${n} - ${e}`:n}else this._hiddenInput.value=n}_focusNext(e,t){if(t+1<e.length){let n=e[t+1];n.focus(),n.setSelectionRange(0,n.value.length)}}_focusPrev(e,t){if(t-1>=0){let n=e[t-1];n.focus(),n.setSelectionRange(n.value.length,n.value.length)}}_attachPartInputHandlers(e,t,n){e.forEach((t,n)=>{let r=t.maxLength||2;t.addEventListener(`input`,()=>{t.value=t.value.replace(/\D/g,``).slice(0,r),t.value.length>=r&&this._focusNext(e,n),this._syncHiddenInput()}),t.addEventListener(`keydown`,r=>{r.key===`Backspace`&&t.selectionStart===0&&t.selectionEnd===0&&this._focusPrev(e,n),r.key===`ArrowLeft`&&t.selectionStart===0&&t.selectionEnd===0&&(this._focusPrev(e,n),r.preventDefault()),r.key===`ArrowRight`&&t.selectionStart===t.value.length&&t.selectionEnd===t.value.length&&(this._focusNext(e,n),r.preventDefault())}),t.addEventListener(`blur`,e=>{this._syncHiddenInput();let t=e.relatedTarget,n=t&&(this._startPartInputs.includes(t)||this._endPartInputs.includes(t));setTimeout(()=>{if(!(this._startPartInputs.some(e=>e===document.activeElement)||this._endPartInputs.some(e=>e===document.activeElement))&&(n||this._handleBlur(this._hiddenInput?.value||``),this._exitInputMode(),!n&&this._hiddenInput)){let t=new FocusEvent(`blur`,{bubbles:!0,cancelable:!0,relatedTarget:e.relatedTarget});this._hiddenInput.dispatchEvent(t)}},0)})})}_splitRangeInput(e,t){let n=e.split(/\s*-\s*/);return n.length>=2?[n[0],n.slice(1).join(`-`)]:[e]}_parseValue(e){let t=this.getFormat(),n=this._getFormatTokens(t),r=this.getSelectionMode();if(this._isRange||r===`week`||r===`month`){let[r,i]=this._splitRangeInput(e,t),a=r?this._parseDateString(r,t):null,o=i?this._parseDateString(i,t):null;if(a&&o){let[e,t]=a<=o?[a,o]:[o,a];this._selectedStartDate=e,this._selectedEndDate=t,this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}else a&&(this._selectedStartDate=a,this._selectedEndDate=null,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,n,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,n,t)}else{let r=this._parseDateString(e,t);r&&!isNaN(r.getTime())?(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear(),this._applyDateToParts(r,this._startPartInputs,n,t)):this._applyDateToParts(null,this._startPartInputs,n,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){let n=/[\/\-\.\s]+/;if(n.test(e)){let r=e.split(n).filter(e=>e.length>0),i=t.split(/[\/\-\.\s]+/).filter(e=>e.length>0);if(r.length===i.length){let e=0,t=0,n=0;for(let a=0;a<i.length;a++){let o=i[a].toLowerCase(),s=r[a];if(o.includes(`d`))e=parseInt(s,10);else if(o.includes(`m`))t=parseInt(s,10)-1;else if(o.includes(`y`)){let e=parseInt(s,10),t=o.length,r=s.length;(r===2&&t===4||r===2&&t===2)&&(e=Math.floor(new Date().getFullYear()/100)*100+e),n=e}}let a=i.some(e=>e.toLowerCase().includes(`d`)),o=i.some(e=>e.toLowerCase().includes(`m`));if(a||(e=1),o||(t=0),t>=0&&t<=11&&n){let r=new Date(n,t,e);if(!isNaN(r.getTime()))return a&&r.getDate()!==e||r.getMonth()!==t||r.getFullYear()!==n?null:r}}}let r=e.replace(/[\/\-\.]/g,``),i=t.replace(/[\/\-\.]/g,``).toLowerCase(),a=i.indexOf(`d`),o=i.indexOf(`m`),s=i.indexOf(`y`),c=[{char:`d`,index:a},{char:`m`,index:o},{char:`y`,index:s}].sort((e,t)=>e.index-t.index),l=0,u=0,d=0,f=0;i.length,r.length;for(let e of c)if(e.char===`d`){let e=i.lastIndexOf(`d`)-i.indexOf(`d`)+1,t=r.substr(f,e);if(t.length===0)return null;l=parseInt(t,10),f+=t.length}else if(e.char===`m`){let e=i.lastIndexOf(`m`)-i.indexOf(`m`)+1,t=r.substr(f,e);if(t.length===0)return null;u=parseInt(t,10)-1,f+=t.length}else if(e.char===`y`){let e=i.lastIndexOf(`y`)-i.indexOf(`y`)+1,t=r.substr(f),n=Math.min(e,t.length),a=t.substr(0,n);if(a.length===0)return null;let o=parseInt(a,10);(n===2&&e===4||n===2&&e===2)&&(o=Math.floor(new Date().getFullYear()/100)*100+o),d=o,f+=n}let p=t.toLowerCase(),m=p.includes(`d`),h=p.includes(`m`);if(m||(l=1),h||(u=0),u<0||u>11||!d)return null;let g=new Date(d,u,l);return isNaN(g.getTime())||m&&g.getDate()!==l||g.getMonth()!==u||g.getFullYear()!==d?null:g}_formatDate(e,t){let n=e.getDate(),r=e.getMonth()+1,i=e.getFullYear(),a=t.toLowerCase(),o=t;return a.includes(`dd`)?o=o.replace(/dd/gi,String(n).padStart(2,`0`)):a.includes(`d`)&&(o=o.replace(/d/gi,String(n))),a.includes(`mm`)?o=o.replace(/mm/gi,String(r).padStart(2,`0`)):a.includes(`m`)&&(o=o.replace(/m/gi,String(r))),a.includes(`yyyy`)?o=o.replace(/yyyy/gi,String(i)):a.includes(`yy`)&&(o=o.replace(/yy/gi,String(i).substr(2))),o}_formatDatePhp(e,t){let n=e.getDate(),r=e.getMonth()+1,i=e.getFullYear(),a=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],o=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],l=(e,t=2)=>e.toString().padStart(t,`0`),u=e=>{let t=e%10,n=e%100;return t===1&&n!==11?`st`:t===2&&n!==12?`nd`:t===3&&n!==13?`rd`:`th`},d=``;for(let f=0;f<t.length;f++){let p=t[f];if(p===`\\`&&f+1<t.length){d+=t[f+1],f++;continue}switch(p){case`Y`:d+=i.toString();break;case`y`:d+=i.toString().slice(-2);break;case`m`:d+=l(r);break;case`n`:d+=r.toString();break;case`M`:d+=c[r-1];break;case`F`:d+=s[r-1];break;case`d`:d+=l(n);break;case`j`:d+=n.toString();break;case`D`:d+=o[e.getDay()];break;case`l`:d+=a[e.getDay()];break;case`S`:d+=u(n);break;default:d+=p;break}}return d}_validateDateString(e,t){let n=this._parseDateString(e,t);return n!==null&&!isNaN(n.getTime())}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.getValue(),i=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),s=this.getId(),c=this.getName(),l=this.getFormat(),u=this.hasError(),d=this.getErrorMessage(),f=this.getSelectionMode();this._isRange=this.isRange()||f===`week`||f===`month`,this._input||(this._input=document.createElement(`div`),this._input.className=`relative w-full`,this.appendChild(this._input));let p=this.querySelector(`.mint-date-picker-label-container`);if(t||n){p||(p=document.createElement(`div`),p.className=`mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]`,this.contains(this._input)?this.insertBefore(p,this._input):this.appendChild(p));let e=p.querySelector(`.mint-date-picker-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,p.insertBefore(e,p.firstChild)),e.textContent=t,s&&this._textInput&&e.setAttribute(`for`,s)):e&&e.remove();let r=p.querySelector(`.mint-date-picker-info`);n?(r||(r=document.createElement(`span`),r.className=`mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none`,p.appendChild(r)),r.textContent=n):r&&r.remove()}else p&&p.remove();this._hiddenInput||(this._hiddenInput=document.createElement(`input`),this._hiddenInput.type=`hidden`,this._hiddenInput.value=r||``,this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),s&&(this._hiddenInput.id=s),c&&(this._hiddenInput.name=c),this._hiddenInput.value=r||``,this._hiddenInput.setAttribute(`aria-invalid`,u?`true`:`false`);let m=this._input.querySelector(`.mint-date-fields`);m||(m=document.createElement(`div`),this._input.appendChild(m)),this._fieldsContainer=m,this._applyErrorVisuals(u,d,i),m.innerHTML=``,this._displayEl=document.createElement(`div`);let h=a?`select-text`:`select-none`;this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${a?`cursor-default`:`cursor-text`} ${h} focus:outline-none`,this._displayEl.tabIndex=i||a?-1:0,this._displayEl.addEventListener(`click`,()=>{i||a||this._enterInputMode()}),this._displayEl.addEventListener(`keydown`,e=>{i||a||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement(`div`),this._isRange,this._inputsWrapperEl.className=`flex items-center gap-1 w-full`;let g=this._getFormatTokens(l);this._startPartInputs=[],this._endPartInputs=[];let _=e=>{let t=document.createDocumentFragment();return g.forEach(n=>{if(n.type===`sep`){let e=document.createElement(`span`);e.textContent=n.value,e.className=`text-gray-400 dark:text-gray-500 select-none`,t.appendChild(e)}else{let r=n.part===`d`?`dd`:n.part===`m`?`mm`:n.len===2?`yy`:`yyyy`,s=this._createPartInput(n.len,r,i,a,o);e===`start`?this._startPartInputs.push(s):this._endPartInputs.push(s),t.appendChild(s)}}),t};if(this._isRange){let e=document.createElement(`div`);e.className=`flex items-center gap-1 flex-shrink-0`,e.appendChild(_(`start`)),this._inputsWrapperEl.appendChild(e);let t=document.createElement(`span`);t.textContent=` - `,t.className=`text-gray-400 dark:text-gray-500 select-none flex-shrink-0`,this._inputsWrapperEl.appendChild(t);let n=document.createElement(`div`);n.className=`flex items-center gap-1 flex-shrink-0`,n.appendChild(_(`end`)),this._inputsWrapperEl.appendChild(n)}else this._inputsWrapperEl.appendChild(_(`start`));let v=document.createElement(`div`);if(v.className=`flex flex-col w-full`,this._displayEl.style.display=this._isInputMode?`none`:`flex`,this._inputsWrapperEl.style.display=this._isInputMode?`flex`:`none`,v.appendChild(this._displayEl),v.appendChild(this._inputsWrapperEl),m.appendChild(v),this._isRange&&this._inputsWrapperEl&&this._setupContainerObserver(),m.addEventListener(`click`,()=>{this._isInputMode||i||a||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,g,m),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,g,m),this._parseValue(r),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=i||a,!i&&!a?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`;let e=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=e;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`calendar`),t.className=`w-4 h-4 pointer-events-none`,this._iconButton.appendChild(t),this._iconButton.addEventListener(`click`,()=>{i||a||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=i||a}this._renderErrorState(u,d),this._renderSkeleton(e)}_renderErrorState(e,t){let n=this.querySelector(`.mint-date-picker-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_applyErrorVisuals(e,t,n){if(this._renderErrorState(e,t),this._fieldsContainer){let t=this._getFieldContainerClass(e,n);this._fieldsContainer.className=t}this._hiddenInput&&this._hiddenInput.setAttribute(`aria-invalid`,e?`true`:`false`)}_attachFormResetListener(){let 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(e=>{e.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-mint-elevated dark:border dark:border-mint-divider text-gray-900 dark:text-white`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`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){let t=this.getFormat(),n=this.getSelectionMode(),r=this._isRange||n===`week`||n===`month`;if(!e){this.setValue(``),this._updateDisplayText();return}if(r){let[n,r]=this._splitRangeInput(e,t),i=n?this._parseDateString(n,t):null,a=r?this._parseDateString(r,t):null;if(i&&a){let[e,n]=i<=a?[i,a]:[a,i],r=`${this._formatDate(e,t)} - ${this._formatDate(n,t)}`;this.setValue(r),this._applyDateToParts(e,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(n,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=e,this._selectedEndDate=n,this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}else if(i){let e=this._formatDate(i,t);this.setValue(e),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,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._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){let n=this._parseDateString(e,t);if(n){let e=this._formatDate(n,t);this.setValue(e),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.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}let t=this._iconButton.id;t&&this._iconButton.isConnected&&document.getElementById(t)?this._createPopover(t):e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(e){if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},50);return}if(this._popover){if(this._popover.getAttribute(`trigger-id`)!==e){this._popover.setAttribute(`trigger-id`,e);let t=this._popover;typeof t._setupTrigger==`function`&&t._setupTrigger()}this._buildCalendar()}else{this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`direction`,`down`),this._popover.setAttribute(`padding`,`0`);let t=this.closest(`mint-modal`),n=this.closest(`mint-off-canvas`);t||n?document.body.appendChild(this._popover):this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute(`trigger-id`,e),this._popoverObserver||(this._popoverObserver=new MutationObserver(e=>{e.forEach(e=>{if(e.type===`attributes`&&e.attributeName===`open`)if(this._popover?.hasAttribute(`open`))requestAnimationFrame(()=>{this._buildCalendar();let e=this._popover;typeof e.render==`function`&&e.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{this._iconButton?.focus()}),this._viewMode=`calendar`,this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{let e=new Date;this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{let e=new FocusEvent(`blur`,{bubbles:!0,cancelable:!0,relatedTarget:null});this._hiddenInput?.dispatchEvent(e)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:[`open`]})),requestAnimationFrame(()=>{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-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]`;let e=this.getMode();e===`month`&&this._viewMode===`calendar`?this._viewMode=`month`:e===`year`&&this._viewMode===`calendar`?this._viewMode=`year`:e===`default`&&this._viewMode!==`month`&&this._viewMode!==`year`&&(this._viewMode=`calendar`),this._viewMode===`calendar`?this._buildCalendarView():this._viewMode===`month`?this._buildMonthView():this._viewMode===`year`&&this._buildYearView();let t=this._popover.querySelector(`.popover-content`);if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;let e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),n=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],r=this.getWeekStartDay(),i=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],a=[...i.slice(r),...i.slice(0,r)],o=this.getShortcuts(),s=o.length>0;this._calendarContainer.className=s?`mint-date-calendar bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]`:`mint-date-calendar bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[18rem] md:min-w-[18rem]`;let c=document.createElement(`div`);c.className=`flex flex-col md:flex-row md:gap-6 md:items-start`;let l=document.createElement(`div`);l.className=`flex-1 min-w-0`;let u=document.createElement(`div`);u.className=`flex items-center justify-between mb-4`;let d=document.createElement(`button`);d.type=`button`,d.tabIndex=0,d.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let f=document.createElement(`mint-icon`);f.setAttribute(`name`,`caret-left`),f.className=`w-4 h-4`,d.appendChild(f),d.addEventListener(`click`,()=>{let e=this._currentMonth,t=this._currentYear;this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}),u.appendChild(d);let p=document.createElement(`div`);p.className=`flex items-center gap-2`;let m=document.createElement(`button`);m.type=`button`,m.tabIndex=0,m.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,m.setAttribute(`data-keep-popover-open`,`true`),m.textContent=n[this._currentMonth];let h=()=>{let e=this.getMode();e!==`month`&&e!==`year`&&(this._viewMode=`month`,this._buildCalendar())};m.addEventListener(`click`,h),m.addEventListener(`touchend`,e=>{e.preventDefault(),h()},{passive:!1}),p.appendChild(m);let g=document.createElement(`button`);g.type=`button`,g.tabIndex=0,g.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 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`,g.setAttribute(`data-keep-popover-open`,`true`),g.textContent=String(this._currentYear),g.addEventListener(`click`,()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())}),p.appendChild(g),u.appendChild(p);let _=document.createElement(`button`);_.type=`button`,_.tabIndex=0,_.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,_.setAttribute(`data-keep-popover-open`,`true`);let v=document.createElement(`mint-icon`);v.setAttribute(`name`,`caret-right`),v.className=`w-4 h-4`,_.appendChild(v);let y=()=>{let e=this._currentMonth,t=this._currentYear;this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};_.addEventListener(`click`,y),_.addEventListener(`touchend`,e=>{e.preventDefault(),y()},{passive:!1}),u.appendChild(_);let b=document.createElement(`div`);b.className=`grid grid-cols-7 mb-2`,a.forEach(e=>{let t=document.createElement(`div`);t.className=`text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1`,t.textContent=e,b.appendChild(t)});let x=document.createElement(`div`);x.className=`grid grid-cols-7`;let S=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,C=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;this.getDisabledDates();let w=this._currentMonth===0?11:this._currentMonth-1,T=this._currentMonth===0?this._currentYear-1:this._currentYear,E=this._getDaysInMonth(w,T),D=this._currentMonth===11?0:this._currentMonth+1,O=this._currentMonth===11?this._currentYear+1:this._currentYear,k=t+e,A=Math.ceil(k/7)*7-k,j=(e,t,n)=>{let r=this._isToday(e),i=this._isDateSelected(e),a=this._isDateInRange(e),o=S&&e<S||C&&e>C||this._isDateDisabled(e),s=`rounded-md`,c=this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate,l=c&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._selectedStartDate:c&&this._hoveredDate?this._hoveredDate:null,u=c&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._hoveredDate:c&&this._selectedStartDate?this._selectedStartDate:null,d=l!==null&&this._isSameDate(e,l),f=u!==null&&this._isSameDate(e,u),p=this._hoveredDate!==null&&this._isSameDate(e,this._hoveredDate),m=c&&this._hoveredDate&&this._selectedStartDate?!this._rangeIncludesDisabledDates(this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate):!1;if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){let t=this._isSameDate(e,this._selectedStartDate),n=this._isSameDate(e,this._selectedEndDate);t&&n?s=`rounded-md`:t?s=`rounded-l-md`:n?s=`rounded-r-md`:a&&(s=`rounded-none`)}else c&&(d||f)&&m?d&&f?s=`rounded-md`:d?s=`rounded-l-md`:f&&(s=`rounded-r-md`):i&&!this._isRange||i&&this._isRange&&!this._selectedEndDate?s=`rounded-md`:a&&c&&m&&(s=`rounded-none`);let h=document.createElement(`button`);h.type=`button`,h.disabled=!!o,h.tabIndex=o?-1:0;let g=`w-full h-8 ${s} border-0 text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,_=i||c&&p&&m;return n?g+=_?` bg-slate-800 dark:bg-slate-600 text-white`:a?` bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200`:r?` text-gray-900 dark:text-gray-100 font-semibold`:` text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`:g+=_?` bg-slate-800 dark:bg-slate-600 text-white`:a?` bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200`:` text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-mint-hover`,g+=o?` opacity-40 cursor-not-allowed`:``,h.className=g,h.textContent=t.toString(),o||(h.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),this._handleDateClick(e)}),h.addEventListener(`touchstart`,t=>{t.preventDefault(),t.stopPropagation(),this._isTouchActive=!0,this._touchStartDate=e,this._touchStartElement=h,h.classList.add(`active`,`bg-gray-200`,`dark:bg-gray-600`)},{passive:!1}),h.addEventListener(`touchend`,t=>{t.preventDefault(),t.stopPropagation(),this._isTouchActive&&this._touchStartDate&&this._isSameDate(this._touchStartDate,e)&&this._handleDateClick(e),this._touchStartElement&&this._touchStartElement.classList.remove(`active`,`bg-gray-200`,`dark:bg-gray-600`),this._isTouchActive=!1,this._touchStartDate=null,this._touchStartElement=null},{passive:!1}),h.addEventListener(`touchcancel`,()=>{this._touchStartElement&&this._touchStartElement.classList.remove(`active`,`bg-gray-200`,`dark:bg-gray-600`),this._isTouchActive=!1,this._touchStartDate=null,this._touchStartElement=null}),this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&!o&&(h.addEventListener(`mouseenter`,()=>{this._isHandlingClick||this._isTouchActive||this._isDateDisabled(e)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,e))&&(this._hoveredDate=e,this._buildCalendar())}),h.addEventListener(`touchmove`,e=>{if(!this._isTouchActive||!this._touchStartDate)return;let t=e.touches[0],n=document.elementFromPoint(t.clientX,t.clientY);for(;n&&!n.classList.contains(`mint-date-picker-day`);)n=n.parentElement;if(n&&n!==h){let e=n.getAttribute(`data-date`);if(e){let t=new Date(e);this._isDateDisabled(t)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,t))&&(this._hoveredDate=t,this._buildCalendar())}}},{passive:!0}))),h};for(let e=t-1;e>=0;e--){let t=E-e,n=j(new Date(T,w,t),t,!1);x.appendChild(n)}for(let t=1;t<=e;t++){let e=j(new Date(this._currentYear,this._currentMonth,t),t,!0);x.appendChild(e)}for(let e=1;e<=A;e++){let t=j(new Date(O,D,e),e,!1);x.appendChild(t)}if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&(x.addEventListener(`mouseleave`,()=>{this._isTouchActive||(this._hoveredDate=null,this._buildCalendar())}),x.addEventListener(`touchend`,e=>{let t=e.changedTouches[0],n=document.elementFromPoint(t.clientX,t.clientY);n&&!x.contains(n)&&(this._hoveredDate=null,this._buildCalendar())},{passive:!0})),s){let e=document.createElement(`div`);e.className=`mb-4 pb-4 border-b border-gray-200 dark:border-mint-divider md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-mint-divider md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col`;let t=document.createElement(`div`);t.className=`relative md:relative md:flex-1 md:min-h-0`;let n=document.createElement(`div`);n.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`,n.style.scrollbarWidth=`none`,n.style.msOverflowStyle=`none`,n.style.setProperty(`-webkit-overflow-scrolling`,`touch`);let r=document.createElement(`style`);r.textContent=`
|
|
58
|
+
`,document.head.appendChild(t),e._activeShadowStyleInjected=!0}this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add(`w-full`)}disconnectedCallback(){this._disconnectHostChildObserver(),this._hostRenderFromObserverRaf!==null&&(cancelAnimationFrame(this._hostRenderFromObserverRaf),this._hostRenderFromObserverRaf=null),this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&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(){let e=this.getAttribute(`type`),t=this.getAttribute(`button-type`);return(e||t||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.getAttribute(`full-width`)===`true`}isActive(){return this.getAttribute(`active`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.removeAttribute(`active`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}getAlignment(){let e=this.getAttribute(`align`);return e===`left`||e===`center`||e===`right`?e:`center`}isIconOnly(){if(!(this.getIcon()||this._getGeneratedIcon()||this._button?.querySelector(`mint-icon`)))return!1;let e=this._button?.querySelector(`.mint-button-content`);if(e&&e.textContent?.trim())return!1;if(this._button)for(let e=this._button.firstChild;e;e=e.nextSibling){if(e.nodeType===Node.TEXT_NODE&&e.textContent?.trim())return!1;if(e.nodeType===Node.ELEMENT_NODE){let t=e;if(t.tagName!==`MINT-ICON`&&t.tagName!==`MINT-SPINNER`&&!t.querySelector(`mint-spinner`)&&!t.hasAttribute(`slot`)&&t.className!==`mint-button-icon`&&!(t.className===`mr-2`&&t.querySelector(`mint-spinner`))&&t.textContent?.trim())return!1}}return!0}getActiveStateClasses(){let e=`${this.getVariant()}-${this.getTone()}`;return{"solid-action":[`!bg-neutral-900`,`dark:!bg-neutral-700`,`hover:!bg-neutral-900`,`dark:hover:!bg-neutral-700`,`!border-t-neutral-900`,`!border-l-neutral-900`,`!border-r-neutral-600`,`!border-b-neutral-600`,`dark:!border-t-neutral-700`,`dark:!border-l-neutral-700`,`dark:!border-r-neutral-500`,`dark:!border-b-neutral-500`],"solid-neutral":[`!bg-gray-100`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`!border-t-gray-400`,`!border-l-gray-400`,`!border-r-gray-200`,`!border-b-gray-200`,`dark:!border-t-gray-950`,`dark:!border-l-gray-950`,`dark:!border-r-mint-divider`,`dark:!border-b-mint-divider`],"solid-info":[`!bg-blue-900`,`dark:!bg-blue-700`,`hover:!bg-blue-900`,`dark:hover:!bg-blue-700`,`!border-t-blue-900`,`!border-l-blue-900`,`!border-r-blue-600`,`!border-b-blue-600`,`dark:!border-t-blue-700`,`dark:!border-l-blue-700`,`dark:!border-r-blue-500`,`dark:!border-b-blue-500`],"solid-warning":[`!bg-amber-900`,`dark:!bg-amber-700`,`hover:!bg-amber-900`,`dark:hover:!bg-amber-700`,`!border-t-amber-900`,`!border-l-amber-900`,`!border-r-amber-600`,`!border-b-amber-600`,`dark:!border-t-amber-700`,`dark:!border-l-amber-700`,`dark:!border-r-amber-500`,`dark:!border-b-amber-500`],"solid-danger":[`!bg-red-900`,`dark:!bg-red-700`,`hover:!bg-red-900`,`dark:hover:!bg-red-700`,`!border-t-red-900`,`!border-l-red-900`,`!border-r-red-600`,`!border-b-red-600`,`dark:!border-t-red-700`,`dark:!border-l-red-700`,`dark:!border-r-red-500`,`dark:!border-b-red-500`],"ghost-action":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-neutral":[`!bg-gray-50`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`!text-gray-900`,`dark:!text-white`,`hover:!bg-gray-50`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`hover:!text-gray-900`,`dark:hover:!text-white`],"ghost-info":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-warning":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"ghost-danger":[`!bg-gray-100`,`!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:!bg-mint-hover`,`hover:!bg-gray-100`,`dark:hover:!bg-mint-hover`,`hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`],"link-action":[`!text-neutral-900`,`dark:!text-neutral-300`,`hover:!text-neutral-900`,`dark:hover:!text-neutral-300`],"link-neutral":[`!text-gray-950`,`dark:!text-gray-200`,`hover:!text-gray-950`,`dark:hover:!text-gray-200`],"link-info":[`!text-blue-900`,`dark:!text-blue-200`,`hover:!text-blue-900`,`dark:hover:!text-blue-200`],"link-warning":[`!text-amber-900`,`dark:!text-amber-200`,`hover:!text-amber-900`,`dark:hover:!text-amber-200`],"link-danger":[`!text-red-900`,`dark:!text-red-200`,`hover:!text-red-900`,`dark:hover:!text-red-200`]}[e]||[]}_disconnectHostChildObserver(){this._hostChildObserver?.disconnect()}_connectHostChildObserver(){this.isConnected&&(this._hostChildObserver||=new MutationObserver(e=>{this._onLightDomMutation(e)}),this._hostChildObserver.disconnect(),this._hostChildObserver.observe(this,{childList:!0,subtree:!0,characterData:!0}))}_onLightDomMutation(e){if(this.isConnected){if(this._button&&!this._button.isConnected){this._button=null,this._scheduleRenderFromHostObserver();return}for(let t of e){let e=t.target;if(!(this._button&&(e===this._button||this._button.contains(e)))){this._scheduleRenderFromHostObserver();return}}}}_scheduleRenderFromHostObserver(){this._hostRenderFromObserverRaf===null&&(this._hostRenderFromObserverRaf=requestAnimationFrame(()=>{this._hostRenderFromObserverRaf=null,this.isConnected&&this.render()}))}getButtonClasses(){let e=this.isIconOnly(),t=this.getVariant(),n=this.getAlignment(),r=`justify-center`;n===`left`?r=`justify-start`:n===`right`&&(r=`justify-end`);let i=[`inline-flex`,`items-center`,r,`cursor-pointer`,`font-medium`,`rounded-lg`,`box-border`,...e?[`p-1.5`,`aspect-square`,`w-[2.25rem]`,`h-[2.25rem]`]:[`px-3.5`,`py-1.5`,`min-h-[2.25rem]`],`text-sm`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`[&.mint-button-active:not(:disabled):not([data-loading="true"]):not([data-variant="ghost"]):not([data-variant="link"])>*]:translate-y-[1px]`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],a=this.getTone(),o={"solid-action":`bg-neutral-800.dark:bg-neutral-600.text-white.hover:bg-neutral-950.dark:hover:bg-neutral-700.active:bg-neutral-900.dark:active:bg-neutral-700.disabled:active:bg-neutral-800.dark:disabled:active:bg-neutral-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-neutral-600.border-l-neutral-600.border-r-neutral-900.border-b-neutral-900.dark:border-t-neutral-500.dark:border-l-neutral-500.dark:border-r-neutral-700.dark:border-b-neutral-700.active:border-t-neutral-900.active:border-l-neutral-900.active:border-r-neutral-600.active:border-b-neutral-600.dark:active:border-t-neutral-700.dark:active:border-l-neutral-700.dark:active:border-r-neutral-500.dark:active:border-b-neutral-500.disabled:active:border-t-neutral-600.disabled:active:border-l-neutral-600.disabled:active:border-r-neutral-900.disabled:active:border-b-neutral-900.dark:disabled:active:border-t-neutral-500.dark:disabled:active:border-l-neutral-500.dark:disabled:active:border-r-neutral-700.dark:disabled:active:border-b-neutral-700.[&[data-loading="true"]:active]:border-t-neutral-600.[&[data-loading="true"]:active]:border-l-neutral-600.[&[data-loading="true"]:active]:border-r-neutral-900.[&[data-loading="true"]:active]:border-b-neutral-900.[&[data-loading="true"]:active]:dark:border-t-neutral-500.[&[data-loading="true"]:active]:dark:border-l-neutral-500.[&[data-loading="true"]:active]:dark:border-r-neutral-700.[&[data-loading="true"]:active]:dark:border-b-neutral-700`.split(`.`),"solid-neutral":`bg-white.dark:bg-mint-canvas.text-gray-900.dark:text-white.hover:bg-gray-50.dark:hover:bg-mint-hover.active:bg-gray-100.dark:active:bg-mint-hover.disabled:active:bg-white.dark:disabled:active:bg-mint-canvas.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-gray-200.border-l-gray-200.border-r-gray-300.border-b-gray-300.dark:border-t-gray-600.dark:border-l-gray-600.dark:border-r-mint-divider.dark:border-b-mint-divider.active:border-t-gray-400.active:border-l-gray-400.active:border-r-gray-200.active:border-b-gray-200.dark:active:border-t-gray-950.dark:active:border-l-gray-950.dark:active:border-r-mint-divider.dark:active:border-b-mint-divider.disabled:active:border-t-gray-200.disabled:active:border-l-gray-200.disabled:active:border-r-gray-400.disabled:active:border-b-gray-400.dark:disabled:active:border-t-mint-divider.dark:disabled:active:border-l-mint-divider.dark:disabled:active:border-r-gray-950.dark:disabled:active:border-b-gray-950.[&[data-loading="true"]:active]:border-t-gray-200.[&[data-loading="true"]:active]:border-l-gray-200.[&[data-loading="true"]:active]:border-r-gray-400.[&[data-loading="true"]:active]:border-b-gray-400.[&[data-loading="true"]:active]:dark:border-t-mint-divider.[&[data-loading="true"]:active]:dark:border-l-mint-divider.[&[data-loading="true"]:active]:dark:border-r-gray-950.[&[data-loading="true"]:active]:dark:border-b-gray-950`.split(`.`),"solid-info":`bg-blue-800.dark:bg-blue-600.text-white.hover:bg-blue-950.dark:hover:bg-blue-700.active:bg-blue-900.dark:active:bg-blue-700.disabled:active:bg-blue-800.dark:disabled:active:bg-blue-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-blue-600.border-l-blue-600.border-r-blue-900.border-b-blue-900.dark:border-t-blue-500.dark:border-l-blue-500.dark:border-r-blue-700.dark:border-b-blue-700.active:border-t-blue-900.active:border-l-blue-900.active:border-r-blue-600.active:border-b-blue-600.dark:active:border-t-blue-700.dark:active:border-l-blue-700.dark:active:border-r-blue-500.dark:active:border-b-blue-500.disabled:active:border-t-blue-600.disabled:active:border-l-blue-600.disabled:active:border-r-blue-900.disabled:active:border-b-blue-900.dark:disabled:active:border-t-blue-500.dark:disabled:active:border-l-blue-500.dark:disabled:active:border-r-blue-700.dark:disabled:active:border-b-blue-700.[&[data-loading="true"]:active]:border-t-blue-600.[&[data-loading="true"]:active]:border-l-blue-600.[&[data-loading="true"]:active]:border-r-blue-900.[&[data-loading="true"]:active]:border-b-blue-900.[&[data-loading="true"]:active]:dark:border-t-blue-500.[&[data-loading="true"]:active]:dark:border-l-blue-500.[&[data-loading="true"]:active]:dark:border-r-blue-700.[&[data-loading="true"]:active]:dark:border-b-blue-700`.split(`.`),"solid-warning":`bg-amber-800.dark:bg-amber-600.text-white.hover:bg-amber-950.dark:hover:bg-amber-700.active:bg-amber-900.dark:active:bg-amber-700.disabled:active:bg-amber-800.dark:disabled:active:bg-amber-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-amber-600.border-l-amber-600.border-r-amber-900.border-b-amber-900.dark:border-t-amber-500.dark:border-l-amber-500.dark:border-r-amber-700.dark:border-b-amber-700.active:border-t-amber-900.active:border-l-amber-900.active:border-r-amber-600.active:border-b-amber-600.dark:active:border-t-amber-700.dark:active:border-l-amber-700.dark:active:border-r-amber-500.dark:active:border-b-amber-500.disabled:active:border-t-amber-600.disabled:active:border-l-amber-600.disabled:active:border-r-amber-900.disabled:active:border-b-amber-900.dark:disabled:active:border-t-amber-500.dark:disabled:active:border-l-amber-500.dark:disabled:active:border-r-amber-700.dark:disabled:active:border-b-amber-700.[&[data-loading="true"]:active]:border-t-amber-600.[&[data-loading="true"]:active]:border-l-amber-600.[&[data-loading="true"]:active]:border-r-amber-900.[&[data-loading="true"]:active]:border-b-amber-900.[&[data-loading="true"]:active]:dark:border-t-amber-500.[&[data-loading="true"]:active]:dark:border-l-amber-500.[&[data-loading="true"]:active]:dark:border-r-amber-700.[&[data-loading="true"]:active]:dark:border-b-amber-700`.split(`.`),"solid-danger":`bg-red-800.dark:bg-red-600.text-white.hover:bg-red-950.dark:hover:bg-red-700.active:bg-red-900.dark:active:bg-red-700.disabled:active:bg-red-800.dark:disabled:active:bg-red-600.focus-visible:ring-gray-400.dark:focus-visible:ring-gray-500.border-2.border-t-red-600.border-l-red-600.border-r-red-900.border-b-red-900.dark:border-t-red-500.dark:border-l-red-500.dark:border-r-red-700.dark:border-b-red-700.active:border-t-red-900.active:border-l-red-900.active:border-r-red-600.active:border-b-red-600.dark:active:border-t-red-700.dark:active:border-l-red-700.dark:active:border-r-red-500.dark:active:border-b-red-500.disabled:active:border-t-red-600.disabled:active:border-l-red-600.disabled:active:border-r-red-900.disabled:active:border-b-red-900.dark:disabled:active:border-t-red-500.dark:disabled:active:border-l-red-500.dark:disabled:active:border-r-red-700.dark:disabled:active:border-b-red-700.[&[data-loading="true"]:active]:border-t-red-600.[&[data-loading="true"]:active]:border-l-red-600.[&[data-loading="true"]:active]:border-r-red-900.[&[data-loading="true"]:active]:border-b-red-900.[&[data-loading="true"]:active]:dark:border-t-red-500.[&[data-loading="true"]:active]:dark:border-l-red-500.[&[data-loading="true"]:active]:dark:border-r-red-700.[&[data-loading="true"]:active]:dark:border-b-red-700`.split(`.`),"ghost-action":[`bg-transparent`,`text-neutral-800`,`dark:text-neutral-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-mint-hover`,`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-neutral-800`,`dark:text-neutral-400`,`hover:text-neutral-950`,`dark:hover:text-neutral-200`,`active:text-neutral-900`,`dark:active:text-neutral-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`]},s=o[`${t}-${a}`]||o[`solid-neutral`],c=[...i,...s];if(this.isActive()){let e=this.getActiveStateClasses();c.push(...e)}return this.isFullWidth()&&c.push(`w-full`),c.join(` `)}render(){this._disconnectHostChildObserver(),this._button&&!this._button.isConnected&&(this._button=null);try{let e=this.isDisabled()||this.isLoading(),t=this.getType();if(!this._button){let e=this.firstElementChild;if(e instanceof HTMLButtonElement)this._button=e;else{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 n=this._button.querySelector(`mint-spinner`),r=this.isLoading();if(r)if(n)n.setAttribute(`data-button-variant`,this.getVariant()),n.setAttribute(`data-button-tone`,this.getTone()),`render`in n&&typeof n.render==`function`&&n.render();else{let e=document.createElement(`span`);e.className=`mr-2 inline-flex items-center`;let t=document.createElement(`mint-spinner`);t.setAttribute(`size`,`default`),t.setAttribute(`data-button-variant`,this.getVariant()),t.setAttribute(`data-button-tone`,this.getTone()),t.style.width=`0.875rem`,t.style.height=`0.875rem`,e.appendChild(t),this._button.insertBefore(e,this._button.firstChild)}else n&&n.parentElement?.remove();for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);let i=this.getIcon(),a=this._getGeneratedIcon();i?(a||(a=document.createElement(`mint-icon`),a.setAttribute(`data-generated-icon`,`true`),a.className=`mint-button-icon`),a.setAttribute(`name`,i)):a&&a.tagName===`MINT-ICON`&&(a.remove(),a=null);let o=this.getIconPosition(),s=this._button.querySelector(`.mint-button-content`);if(s){s.className=this._getContentWrapperClass(s);let e=a&&a.tagName===`MINT-ICON`;if(a&&!a.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||o===`left`?t?t.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s):s.insertAdjacentElement(`afterend`,a)}else if(a&&(e||o===`left`)&&a.nextSibling!==s){a.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,s)}else a&&!e&&o===`right`&&a.previousSibling!==s&&(a.remove(),s.insertAdjacentElement(`afterend`,a))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling){if(t.nodeType!==Node.ELEMENT_NODE){e.push(t);continue}let n=t;n.tagName!==`MINT-SPINNER`&&!n.querySelector(`mint-spinner`)&&t!==a&&!n.hasAttribute(`slot`)&&!(n.className===`mr-2`&&n.querySelector(`mint-spinner`))&&e.push(t)}if(e.length>0){s=document.createElement(`span`),s.className=this._getContentWrapperClass(s),e.forEach(e=>{s.appendChild(e)}),s.className=this._getContentWrapperClass(s);let t=this._button.querySelector(`mint-spinner`)?.parentElement;a&&o===`left`?t?(t.insertAdjacentElement(`afterend`,a),a.insertAdjacentElement(`afterend`,s)):(this._button.insertBefore(a,this._button.firstChild),a.insertAdjacentElement(`afterend`,s)):a&&o===`right`?t?(t.insertAdjacentElement(`afterend`,s),s.insertAdjacentElement(`afterend`,a)):(this._button.insertBefore(s,this._button.firstChild),s.insertAdjacentElement(`afterend`,a)):t?t.insertAdjacentElement(`afterend`,s):this._button.insertBefore(s,this._button.firstChild)}else if(a&&a.tagName===`MINT-ICON`&&!a.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,a):this._button.insertBefore(a,this._button.firstChild)}}let c=this.isIconOnly();if(a&&(a.classList.contains(`mint-button-icon`)||a.classList.add(`mint-button-icon`),r?a.style.display=`none`:a.style.display=``,a.classList.remove(`mr-1.5`,`ml-1.5`),c?a.tagName===`MINT-ICON`?(a.style.width=`1em`,a.style.height=`1em`,a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`):(a.style.maxWidth=`1em`,a.style.maxHeight=`1em`,a.style.flexShrink=`0`,a.tagName===`svg`&&(a.style.width=`1em`,a.style.height=`1em`)):o===`left`?a.classList.add(`mr-1.5`):a.classList.add(`ml-1.5`)),r){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e&&(c?(e.classList.remove(`mr-2`),e.classList.add(`mr-0`)):e.classList.contains(`mr-2`)||(e.classList.remove(`mr-0`),e.classList.add(`mr-2`)))}let l=this.getButtonClasses();this._button.className=l,this.setAttribute(`data-variant`,this.getVariant()),this.setAttribute(`data-tone`,this.getTone()),this._button.setAttribute(`data-variant`,this.getVariant()),r?this._button.setAttribute(`data-loading`,`true`):this._button.removeAttribute(`data-loading`),this.isActive()?this._button.classList.add(`mint-button-active`):this._button.classList.remove(`mint-button-active`)}finally{queueMicrotask(()=>{this.isConnected&&this._connectHostChildObserver()})}}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),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`,r);var i=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`icon`,`info`,`error`,`error-message`,`loading`]}constructor(){super(),this._button=null,this._checked=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._checked=this.getAttribute(`checked`)===`true`,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.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`),t!==n){if(e===`error`||e===`error-message`){this._renderErrorState();return}if(e===`loading`){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(e){try{e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._checked=!!e,this.render()}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getIcon(){return this.getAttribute(`icon`)||``}hasIcon(){return!!this.getIcon()}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getSwitchClasses(){let e=this.hasError(),t=[`relative`,`inline-flex`,`items-center`,`cursor-pointer`,`rounded-full`,`h-5`,`w-10`,`border`,`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`],n=this._checked?[`bg-neutral-900`,`dark:bg-neutral-700`,e?`border-red-300 dark:border-red-300`:`border-neutral-800 dark:border-neutral-600`]:[`bg-neutral-200`,`dark:bg-neutral-600`,e?`border-red-300 dark:border-red-300`:`border-neutral-300 dark:border-neutral-500`];return[...t,...n].join(` `)}getThumbClasses(){let 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(){let e=this.isLoading(),t=this.getSwitchClasses(),n=this.getThumbClasses(),r=this.getLabel(),i=this.getInfo(),a=this.getIcon(),o=this.getAttribute(`id`)||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute(`id`)||this.setAttribute(`id`,o);let s=this._getSwitchContainer();this._button?this._button.parentElement!==s&&s.appendChild(this._button):(this._button=document.createElement(`button`),s.appendChild(this._button),this.setupEventListeners());let c=s.querySelector(`.mint-switch-label`);r?(c||(c=document.createElement(`label`),c.className=`mint-switch-label cursor-pointer text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,this._button&&this._button.parentElement===s?s.insertBefore(c,this._button.nextSibling):s.appendChild(c)),c.textContent=r,c.setAttribute(`for`,o),this.isDisabled()?(c.classList.add(`opacity-40`,`cursor-not-allowed`),c.classList.remove(`cursor-pointer`)):(c.classList.remove(`opacity-40`,`cursor-not-allowed`),c.classList.add(`cursor-pointer`))):c&&c.remove(),this._button.className=t,this._button.disabled=this.isDisabled(),this._button.id=o,this._button.setAttribute(`aria-checked`,String(this._checked)),this._button.setAttribute(`aria-label`,r||`Toggle switch`),this._button.setAttribute(`role`,`switch`),this._button.type=`button`;let l=this._button.querySelector(`span`);l||(l=document.createElement(`span`),this._button.appendChild(l)),l.className=n;let u=l.querySelector(`span`);if(a){let e=u;e||(e=document.createElement(`span`),e.className=this.getIconClasses(),l.appendChild(e));let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a)}else u&&u.remove();let d=this.querySelector(`.mint-switch-info`);i?(d||(d=document.createElement(`span`),d.className=`mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,s&&s.parentElement===this?this.insertBefore(d,s.nextSibling):this.appendChild(d)),d.textContent=i,this.isDisabled()?d.classList.add(`opacity-40`):d.classList.remove(`opacity-40`)):d&&d.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){if(!this.isDisabled()){this.checked=!this._checked;let e=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent(`toggle`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0}))}}_renderSkeleton(e){let t=this._getSwitchContainer(),n=this.getLabel(),r=this.getInfo(),i=t.querySelector(`.mint-switch-skeleton-container`),a=this.querySelector(`.mint-switch-info-skeleton`);if(e){t.classList.contains(`relative`)||t.classList.add(`relative`),i||(i=document.createElement(`div`),i.className=`mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2`,t.appendChild(i));let e=i.querySelector(`.mint-switch-skeleton-box`);if(e||(e=document.createElement(`div`),e.className=`mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,i.appendChild(e)),n){let e=i.querySelector(`.mint-switch-skeleton-label`);e||(e=document.createElement(`div`),e.className=`mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,i.appendChild(e))}else{let e=i.querySelector(`.mint-switch-skeleton-label`);e&&e.remove()}i.style.display=`flex`,this._button&&(this._button.style.visibility=`hidden`,this._button.style.pointerEvents=`none`);let o=t.querySelector(`.mint-switch-label`);if(o&&(o.style.visibility=`hidden`,o.style.pointerEvents=`none`),r){a||(a=document.createElement(`div`),a.className=`mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-mint-hover animate-pulse mt-2`,t&&t.parentElement===this?this.insertBefore(a,t.nextSibling):this.appendChild(a)),a.style.display=`block`;let e=this.querySelector(`.mint-switch-info`);e&&(e.style.display=`none`)}else a&&(a.style.display=`none`)}else{i&&(i.style.display=`none`),a&&(a.style.display=`none`),this._button&&(this._button.style.visibility=`visible`,this._button.style.pointerEvents=`auto`);let e=t.querySelector(`.mint-switch-label`);e&&(e.style.visibility=`visible`,e.style.pointerEvents=`auto`);let n=this.querySelector(`.mint-switch-info`);n&&(n.style.display=``)}}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-switch-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove(),this._button&&(this._button.className=this.getSwitchClasses())}};customElements.get(`mint-switch`)||customElements.define(`mint-switch`,i);var a=class extends HTMLElement{static get observedAttributes(){return[`variant`,`size`,`bold`,`underline`,`strike`,`italic`,`display`,`inline`]}constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(e,t,n){t!==n&&this.render()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),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.getAttribute(`bold`)===`true`}isUnderline(){return this.getAttribute(`underline`)===`true`}isStrike(){return this.getAttribute(`strike`)===`true`}isItalic(){return this.getAttribute(`italic`)===`true`}getDisplay(){return this.getAttribute(`display`)||(this.getAttribute(`inline`)===`true`?`inline-block`:`block`)}getTextClasses(){let e=this.getSize(),t=this.getVariant(),n=document.documentElement.classList.contains(`dark`),r={heading:[`font-semibold`],"sub-heading":[`font-medium`],regular:[]},i={default:n?[`text-gray-100`]:[`text-gray-900`],muted:[`text-gray-400`],danger:n?[`text-red-400`]:[`text-red-600`],success:n?[`text-green-400`]:[`text-green-600`]},a=[];this.isBold()&&a.push(`font-bold`),this.isUnderline()&&a.push(`underline`),this.isStrike()&&a.push(`line-through`),this.isItalic()&&a.push(`italic`);let o=this.getDisplay();return[o===`block`?`block`:o===`inline`?`inline`:`inline-block`,...r[e]||r.regular,...i[t]||i.default,...a].join(` `)}render(){let 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`],n=[`text-2xl`,`text-lg`,`text-sm`];n.forEach(e=>{this.classList.remove(e),this._userClasses.delete(e)}),t.forEach(e=>{this.classList.remove(e),this._userClasses.delete(e)});let r=this.getTextClasses().split(` `).filter(e=>e.trim());Array.from(this.classList).forEach(e=>{!t.includes(e)&&!n.includes(e)&&this._userClasses.add(e)}),this.className=[...new Set([...r,...Array.from(this._userClasses)])].join(` `);let i={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)`},a=i[e]||i.regular;this.style.setProperty(`font-size`,a)}};customElements.get(`mint-text`)||customElements.define(`mint-text`,a);var o=class extends HTMLElement{static get observedAttributes(){return[`direction`,`text-align`,`gap`,`align-content`]}constructor(){super(),this._childObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`text-align`&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{let e=this.getTextAlign();e&&this._applyTextAlignToChildren(e)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&=(this._childObserver.disconnect(),null)}getDirection(){return(this.getAttribute(`direction`)||`vertical`)===`horizontal`?`horizontal`:`vertical`}getGap(){let e=this.getAttribute(`gap`)||`3`;return parseFloat(e)}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getAlignContent(){let e=(this.getAttribute(`align-content`)||``).trim().toLowerCase();return e===`left`||e===`right`||e===`center`?e:``}getStackClasses(){let e=this.getDirection(),t=this.getTextAlign(),n=this.getGap(),r=this.getAlignContent(),i=[`flex`,e===`horizontal`?`flex-row`:`flex-col`,`gap-${n}`];return r&&(e===`horizontal`?r===`left`?i.push(`justify-start`):r===`right`?i.push(`justify-end`):i.push(`justify-center`):r===`left`?i.push(`items-start`):r===`right`?i.push(`items-end`):i.push(`items-center`)),t&&(i.push(`text-${t}`),i.push(`[&>*]:text-${t}`),i.push(`[&>*_.mint-button-content]:text-${t}`),t===`left`?(i.push(`[&>mint-button]:!justify-start`),i.push(`[&>mint-button>button]:!justify-start`)):t===`right`?(i.push(`[&>mint-button]:!justify-end`),i.push(`[&>mint-button>button]:!justify-end`)):t===`center`&&(i.push(`[&>mint-button]:!justify-center`),i.push(`[&>mint-button>button]:!justify-center`))),i.join(` `)}render(){let e=this.getStackClasses(),t=this.getTextAlign();`flex,flex-row,flex-col,gap-1,gap-2,gap-3,gap-4,gap-5,gap-6,gap-7,gap-8,gap-9,gap-10,gap-11,gap-12,items-start,items-end,items-center,justify-start,justify-end,justify-center,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`.split(`,`).forEach(e=>this.classList.remove(e)),e.split(` `).forEach(e=>{e&&this.classList.add(e)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)}),t?this._applyTextAlignToChildren(t):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(e){Array.from(this.children).forEach(t=>{if(t.tagName===`MINT-BUTTON`){let n=t.querySelector(`button`);if(n){n.classList.remove(`justify-start`,`justify-center`,`justify-end`),e===`left`?n.classList.add(`justify-start`):e===`right`?n.classList.add(`justify-end`):e===`center`&&n.classList.add(`justify-center`);let t=n.querySelector(`.mint-button-content`);t&&(t.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`),t.classList.add(`text-${e}`))}}else t.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`),t.classList.add(`text-${e}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName===`MINT-BUTTON`){let t=e.querySelector(`button`);if(t){t.classList.remove(`justify-start`,`justify-end`),t.classList.add(`justify-center`);let e=t.querySelector(`.mint-button-content`);e&&e.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`)}}else e.classList.remove(`text-left`,`text-center`,`text-right`,`text-justify`)})}};customElements.get(`mint-stack`)||customElements.define(`mint-stack`,o);var s=`mint-sortable-placeholder`,c=`mint-sortable-dragging`;function l(e,t,n,r){let i=[`flex`,e===`horizontal`?`flex-row`:`flex-col`,`gap-${Number.isFinite(n)?Math.min(12,Math.max(1,Math.round(n))):3}`,`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`min-w-0`];return r&&(e===`horizontal`?r===`left`?i.push(`justify-start`):r===`right`?i.push(`justify-end`):i.push(`justify-center`):r===`left`?i.push(`items-start`):r===`right`?i.push(`items-end`):i.push(`items-center`)),t&&(i.push(`text-${t}`),i.push(`[&>*]:text-${t}`),i.push(`[&>*_.mint-button-content]:text-${t}`),t===`left`?i.push(`[&>mint-button]:!justify-start`,`[&>mint-button>button]:!justify-start`):t===`right`?i.push(`[&>mint-button]:!justify-end`,`[&>mint-button>button]:!justify-end`):t===`center`&&i.push(`[&>mint-button]:!justify-center`,`[&>mint-button>button]:!justify-center`)),i}var u=class extends HTMLElement{static get observedAttributes(){return[`direction`,`gap`,`text-align`,`align-content`,`scroll-max-height`,`disabled`,`handle-selector`,`scroll-sensitivity`,`scroll-speed`,`animation-duration`,`item-key-attribute`]}constructor(){super(),this._pointerId=null,this._dragEl=null,this._placeholder=null,this._listRoot=this,this._startIndex=0,this._pointerStartX=0,this._pointerStartY=0,this._dragStartLeft=0,this._dragStartTop=0,this._scrollRaf=null,this._childObserver=null,this._pointerBoundRoot=null,this._restoreAfter=null,this._onListPointerDown=e=>{let t=e;if(this._isDisabled()||this._pointerId!==null||t.button!==0)return;let n=t.target;if(!n||!this.contains(n))return;let r=this._closestSortableItem(n);if(!r||!this._listRoot.contains(r)||r.hasAttribute(`data-sortable-disabled`))return;let i=this._getHandleSelector();if(i){let e=t.target.closest(i);if(!e||!r.contains(e))return}t.preventDefault(),this._startDrag(t,r)},this._boundPointerMove=this._onPointerMove.bind(this),this._boundPointerUp=this._onPointerUp.bind(this),this._boundPointerCancel=this._onPointerCancel.bind(this)}connectedCallback(){this.classList.add(`relative`,`block`),this._syncInnerStackAttributes(),this._applyHostScrollAndLayout(),this._observeInnerStack()}disconnectedCallback(){this._unobserveInnerStack(),this._teardownDrag(),this._pointerBoundRoot&&=(this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),null)}attributeChangedCallback(e,t,n){t!==n&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}_observeInnerStack(){this._childObserver||(this._childObserver=new MutationObserver(()=>{this._pointerId===null&&(this._syncInnerStackAttributes(),this._applyHostScrollAndLayout())}),this._childObserver.observe(this,{childList:!0}))}_unobserveInnerStack(){this._childObserver&&=(this._childObserver.disconnect(),null)}_getInnerStack(){for(let e=0;e<this.children.length;e++){let t=this.children[e];if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===`MINT-STACK`)return t}return null}_resolveListRoot(){return this._getInnerStack()??this}_getItemKeyAttribute(){return this.getAttribute(`item-key-attribute`)?.trim()||`data-sortable-id`}_collectOrderedKeys(){let e=this._resolveListRoot(),t=this._getItemKeyAttribute(),n=[];for(let r=0;r<e.children.length;r++){let i=e.children[r];if(i.nodeType!==Node.ELEMENT_NODE)continue;let a=i;a.classList.contains(s)||n.push(a.getAttribute(t)??``)}return n}_syncInnerStackAttributes(){let e=this._getInnerStack();if(!e)return;let t=this.getDirection(),n=this.getGap(),r=this.getTextAlign();e.setAttribute(`direction`,t),e.setAttribute(`gap`,String(n)),r?e.setAttribute(`text-align`,r):e.removeAttribute(`text-align`);let i=this.getAlignContent();i?e.setAttribute(`align-content`,i):e.removeAttribute(`align-content`)}_applyHostScrollAndLayout(){this._listRoot=this._resolveListRoot();let e=this.getAttribute(`scroll-max-height`);e?(this.style.maxHeight=e,this.style.overflowY=`auto`,this.style.overflowX=`hidden`,this.classList.add(`overscroll-y-contain`)):(this.style.maxHeight=``,this.style.overflowY=``,this.style.overflowX=``,this.classList.remove(`overscroll-y-contain`));let t=this._getInnerStack();this._stripHostLayoutClasses(),t||l(this.getDirection(),this.getTextAlign(),this.getGap(),this.getAlignContent()).forEach(e=>{e&&this.classList.add(e)}),this._ensureListPointerBinding()}_stripHostLayoutClasses(){Array.from(this.classList).filter(e=>e===`flex`||e===`flex-row`||e===`flex-col`||e.startsWith(`gap-`)||e===`items-start`||e===`items-end`||e===`items-center`||e===`justify-start`||e===`justify-end`||e===`justify-center`||e.startsWith(`text-`)||e.startsWith(`[&`)).forEach(e=>this.classList.remove(e))}getDirection(){return(this.getAttribute(`direction`)||`vertical`)===`horizontal`?`horizontal`:`vertical`}getGap(){let e=this.getAttribute(`gap`)||`3`,t=parseFloat(e);return Number.isFinite(t)?t:3}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getAlignContent(){let e=(this.getAttribute(`align-content`)||``).trim().toLowerCase();return e===`left`||e===`right`||e===`center`?e:``}_isDisabled(){return this.hasAttribute(`disabled`)&&this.getAttribute(`disabled`)!==`false`}_getHandleSelector(){let e=this.getAttribute(`handle-selector`);return e&&e.trim()?e.trim():null}_getScrollSensitivity(){let e=parseFloat(this.getAttribute(`scroll-sensitivity`)||`48`);return Number.isFinite(e)?e:48}_getScrollSpeed(){let e=parseFloat(this.getAttribute(`scroll-speed`)||`12`);return Number.isFinite(e)?e:12}_getAnimationDurationMs(){let e=parseFloat(this.getAttribute(`animation-duration`)||`220`);return Number.isFinite(e)?Math.max(0,e):220}_ensureListPointerBinding(){let e=this._resolveListRoot();this._pointerBoundRoot!==e&&(this._pointerBoundRoot&&this._pointerBoundRoot.removeEventListener(`pointerdown`,this._onListPointerDown),e.addEventListener(`pointerdown`,this._onListPointerDown),this._pointerBoundRoot=e,this._listRoot=e)}_closestSortableItem(e){let t=e;for(;t&&t!==this._listRoot;){if(t.nodeType===Node.ELEMENT_NODE){let e=t;if(e.classList.contains(s)||e.classList.contains(c))return null;if(t.parentElement===this._listRoot)return e}t=t.parentElement}return null}_startDrag(e,t){this._listRoot=this._resolveListRoot(),this._restoreAfter=t.nextElementSibling,this._dragEl=t,this._pointerId=e.pointerId,this._startIndex=this._indexOfItem(t);let n=t.getBoundingClientRect();this._pointerStartX=e.clientX,this._pointerStartY=e.clientY,this._dragStartLeft=n.left,this._dragStartTop=n.top;let r=document.createElement(`div`);r.className=[s,`box-border`,`shrink-0`,`rounded-lg`,`border-2`,`border-dashed`,`border-gray-300`,`bg-gray-50/80`,`dark:border-mint-divider`,`dark:bg-mint-hover/40`].join(` `),r.style.minHeight=`${n.height}px`,r.style.minWidth=`${n.width}px`,r.setAttribute(`aria-hidden`,`true`),this._placeholder=r,this._listRoot.insertBefore(r,t),t.classList.add(c),t.style.position=`fixed`,t.style.left=`${n.left}px`,t.style.top=`${n.top}px`,t.style.width=`${n.width}px`,t.style.height=`${n.height}px`,t.style.margin=`0`,t.style.zIndex=`10000`,t.style.boxSizing=`border-box`,t.style.pointerEvents=`none`,t.style.touchAction=`none`,t.style.willChange=`transform, left, top`,t.setPointerCapture(e.pointerId);let i=this._collectOrderedKeys(),a={index:this._startIndex,keys:i};this.dispatchEvent(new CustomEvent(`mint-sortable-start`,{bubbles:!0,composed:!0,detail:a})),this.dispatchEvent(new CustomEvent(`sort-start`,{bubbles:!0,composed:!0,detail:a})),window.addEventListener(`pointermove`,this._boundPointerMove,{passive:!1}),window.addEventListener(`pointerup`,this._boundPointerUp),window.addEventListener(`pointercancel`,this._boundPointerCancel)}_indexOfItem(e){let t=0;for(let n=0;n<this._listRoot.children.length;n++){let r=this._listRoot.children[n];if(r.nodeType!==Node.ELEMENT_NODE)continue;let i=r;if(!i.classList.contains(s)){if(i===e)return t;t++}}return-1}_getLayoutChildren(){return Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE)}_onPointerMove(e){if(e.pointerId!==this._pointerId||!this._dragEl||!this._placeholder)return;e.preventDefault();let t=e.clientX-this._pointerStartX,n=e.clientY-this._pointerStartY;this._dragEl.style.left=`${this._dragStartLeft+t}px`,this._dragEl.style.top=`${this._dragStartTop+n}px`,this._autoScroll(e),this._maybeMovePlaceholder(e)}_autoScroll(e){let t=this;if(!t.style.maxHeight)return;let n=this._getScrollSensitivity(),r=this._getScrollSpeed(),i=t.getBoundingClientRect();this._scrollRaf!==null&&cancelAnimationFrame(this._scrollRaf),this._scrollRaf=requestAnimationFrame(()=>{this._scrollRaf=null;let a=0;e.clientY<i.top+n?a=-r:e.clientY>i.bottom-n&&(a=r),a!==0&&(t.scrollTop+=a,this._maybeMovePlaceholder(e))})}_maybeMovePlaceholder(e){let t=this._placeholder,n=this._dragEl;if(!t||!n)return;let r=this.getDirection()===`horizontal`,i=r?e.clientX:e.clientY,a=Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n&&e!==t),o=null;for(let e of a){let t=e.getBoundingClientRect();if(i<(r?t.left+t.width/2:t.top+t.height/2)){o=e;break}}let s=Array.from(this._listRoot.children).filter(e=>e.nodeType===Node.ELEMENT_NODE&&e!==n),c=s.length>0&&s[s.length-1]===t;(o?!(t.nextSibling===o&&t.parentNode===this._listRoot):!c)&&this._flipAnimate(()=>{o?this._listRoot.insertBefore(t,o):this._listRoot.appendChild(t)})}_flipAnimate(e){let t=this._dragEl,n=this._getAnimationDurationMs(),r=this._getLayoutChildren().filter(e=>e!==t),i=new Map;r.forEach(e=>i.set(e,e.getBoundingClientRect())),e(),!(n<=0)&&r.forEach(e=>{let t=i.get(e);if(!t)return;let r=e.getBoundingClientRect(),a=t.left-r.left,o=t.top-r.top;Math.abs(a)<.5&&Math.abs(o)<.5||(e.style.transition=`none`,e.style.transform=`translate(${a}px, ${o}px)`,requestAnimationFrame(()=>{e.style.transition=`transform ${n}ms cubic-bezier(0.2, 0.8, 0.2, 1)`,e.style.transform=``;let t=()=>{e.removeEventListener(`transitionend`,t),e.style.transition=``,e.style.transform=``};e.addEventListener(`transitionend`,t,{once:!0}),setTimeout(t,n+40)}))})}_onPointerUp(e){e.pointerId===this._pointerId&&this._finishDrag(!1)}_onPointerCancel(e){e.pointerId===this._pointerId&&this._finishDrag(!0)}_finishDrag(e){let t=this._dragEl,n=this._placeholder;if(!t||this._pointerId===null){this._teardownDrag();return}try{t.releasePointerCapture(this._pointerId)}catch{}if(window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel),e){let e=this._restoreAfter;e&&e.parentNode===this._listRoot?this._listRoot.insertBefore(t,e):this._listRoot.appendChild(t)}else n?.parentNode&&this._listRoot.insertBefore(t,n);n?.remove(),this._placeholder=null,t.classList.remove(c),t.style.cssText=``;let r=this._indexOfItem(t),i=this._startIndex;this._pointerId=null,this._dragEl=null,this._restoreAfter=null;let a=this._collectOrderedKeys(),o={oldIndex:i,newIndex:r,cancelled:e,keys:a};this.dispatchEvent(new CustomEvent(`mint-sortable-end`,{bubbles:!0,composed:!0,detail:o})),this.dispatchEvent(new CustomEvent(`sort-stop`,{bubbles:!0,composed:!0,detail:o})),!e&&r!==i&&(this.dispatchEvent(new CustomEvent(`mint-sortable-change`,{bubbles:!0,composed:!0,detail:{oldIndex:i,newIndex:r,keys:a}})),this.dispatchEvent(new CustomEvent(`mint-sortable-order`,{bubbles:!0,composed:!0,detail:{keys:a}})))}_teardownDrag(){if(this._scrollRaf!==null&&(cancelAnimationFrame(this._scrollRaf),this._scrollRaf=null),window.removeEventListener(`pointermove`,this._boundPointerMove),window.removeEventListener(`pointerup`,this._boundPointerUp),window.removeEventListener(`pointercancel`,this._boundPointerCancel),this._dragEl){try{this._pointerId!==null&&this._dragEl.releasePointerCapture(this._pointerId)}catch{}this._dragEl.classList.remove(c),this._dragEl.style.cssText=``}this._placeholder?.remove(),this._placeholder=null,this._dragEl=null,this._pointerId=null,this._restoreAfter=null}};customElements.get(`mint-sortable`)||customElements.define(`mint-sortable`,u);var d=class extends HTMLElement{static get observedAttributes(){return[`heading`]}constructor(){super(),this._headingElement=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`align-baseline`,`block`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add(`rounded-lg`,`shadow`,`bg-white`,`dark:bg-mint-elevated`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasPaddingClass()||this.classList.add(`p-4`);let e=this.getHeading();e?(this._headingElement||(this._headingElement=document.createElement(`mint-text`),this._headingElement.setAttribute(`size`,`sub-heading`),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=e):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}};customElements.get(`mint-card`)||customElements.define(`mint-card`,d);var f=class extends HTMLElement{static get observedAttributes(){return[`href`,`target`]}constructor(){super(),this._link=null,this._contentObserver=null}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(),null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHref(){return this.getAttribute(`href`)||`#`}getTarget(){return this.getAttribute(`target`)||``}hasIcon(){return!!(this.querySelector(`mint-icon`)||this._link?.querySelector(`mint-icon`))}render(){let 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`));let n=this.hasIcon(),r=[`text-slate-800`,`dark:text-slate-200`,`underline`,`hover:text-slate-950`,`dark:hover:text-slate-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`];n&&r.push(`inline-flex`,`items-center`,`gap-2`),this._link.className=r.join(` `),this._link.querySelectorAll(`mint-text`).forEach(e=>{e.classList.contains(`underline`)||e.classList.add(`underline`)}),[`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`].forEach(e=>{this.classList.contains(e)||this.classList.add(e)})}};customElements.get(`mint-link`)||customElements.define(`mint-link`,f);var p=class extends HTMLElement{static get observedAttributes(){return[`href`,`fallback-href`]}constructor(){super(),this._button=null}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,n){t!==n&&this.render()}getFallbackHref(){return this.getAttribute(`fallback-href`)||this.getAttribute(`href`)||`/`}_getTargetUrl(){let e=document.referrer,t=window.location.origin;if(e)try{let n=new URL(e);if(n.origin===t)return n.pathname+n.search}catch{}return this.getFallbackHref()}handleClick(e){e.preventDefault(),e.stopPropagation();let t=this._getTargetUrl(),n=document.referrer,r=n&&(()=>{try{return new URL(n).origin===window.location.origin}catch{return!1}})(),i=new CustomEvent(`back`,{detail:{url:t,isFromReferrer:r,referrer:n||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}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`,p);var m=class extends HTMLElement{static get observedAttributes(){return[`heading`,`fallback-href`,`show-back-button`,`containered`]}constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._contentObserver=null,this._backButton=null,this._backButtonHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this._observeDarkMode(),this._observeContentMutations(),this._setupBackButtonListener()}attributeChangedCallback(e,t,n){t!==n&&(e===`containered`&&this._applyContainerClasses(),this.render())}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._removeBackButtonListener()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getHeading(){return this.getAttribute(`heading`)||``}getFallbackHref(){return this.getAttribute(`fallback-href`)||`/`}shouldShowBackButton(){return this.getAttribute(`show-back-button`)===`true`}render(){let 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));let e=this.getFallbackHref();t.setAttribute(`fallback-href`,e),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`,`true`),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(),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(e=>e!==this._pageContainer&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{this._actionsSlot&&e.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(e)}),this._bodySlot||(this._bodySlot=document.createElement(`div`),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(e=>{e!==this._pageContainer&&e.getAttribute(`slot`)!==`actions`&&e!==this._actionsSlot&&e!==this._header&&e!==this._bodySlot&&e!==this._headingText&&e.parentElement!==this._bodySlot&&e.parentElement!==this._pageContainer&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_applyContainerClasses(){this._pageContainer&&(this._pageContainer.classList.add(`p-5`),this.getAttribute(`containered`)===`true`?this._pageContainer.classList.add(`max-w-6xl`,`mx-auto`,`w-full`):this._pageContainer.classList.remove(`max-w-6xl`,`mx-auto`,`w-full`))}_updateBackgroundColor(){this._pageContainer&&(document.documentElement.classList.contains(`dark`)?(this._pageContainer.classList.remove(`bg-gray-20`),this._pageContainer.classList.add(`bg-mint-canvas`)):(this._pageContainer.classList.remove(`bg-mint-canvas`),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`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_setupBackButtonListener(){this._backButtonHandler||=e=>{let t=e.target;if(t&&t.tagName===`MINT-BACK-BUTTON`){e.stopPropagation();let t=new CustomEvent(`back`,{detail:e.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t)}},this.addEventListener(`back`,this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&=(this.removeEventListener(`back`,this._backButtonHandler,!0),null)}};customElements.get(`mint-page`)||customElements.define(`mint-page`,m);var h=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,n){t!==n&&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(){let e=[`grid`],t=this.getColumns();e.push(`grid-cols-${t}`);let n=this.getSm();n&&e.push(`sm:grid-cols-${n}`);let r=this.getMd();r&&e.push(`md:grid-cols-${r}`);let i=this.getLg();i&&e.push(`lg:grid-cols-${i}`);let a=this.getXl();a&&e.push(`xl:grid-cols-${a}`);let o=this.getGap();return e.push(`gap-${o}`),e}render(){Array.from(this.classList).filter(e=>e.startsWith(`grid-cols-`)||e.startsWith(`sm:grid-cols-`)||e.startsWith(`md:grid-cols-`)||e.startsWith(`lg:grid-cols-`)||e.startsWith(`xl:grid-cols-`)||e.startsWith(`gap-`)).forEach(e=>this.classList.remove(e)),this.classList.contains(`grid`)||this.classList.add(`grid`),this.getGridClasses().forEach(e=>{e&&e!==`grid`&&this.classList.add(e)})}};customElements.get(`mint-grid`)||customElements.define(`mint-grid`,h);var g=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`]}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,this._contentObserver=null,this._renderFrame=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`inset-0`,`z-[120]`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._observeDarkMode(),this._observeContentMutations()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen();if(e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black/50 transition-opacity duration-200 z-[120]`,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-[130]`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transform`,this._modal.appendChild(e)),this._animateEnter()}else this._animateExit();let r=this._modal.querySelector(`.modal-content`);r||(r=document.createElement(`div`),r.className=`modal-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transform`,this._modal.appendChild(r)),this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-mint-divider`,r.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 i=this._headingSlot.querySelector(`mint-text`);t?(i||(i=document.createElement(`mint-text`),i.setAttribute(`size`,`sub-heading`),i.setAttribute(`bold`,`true`),this._headingSlot.appendChild(i)),i.textContent=t):i&&i.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),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`),r.appendChild(this._bodySlot)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider`,this._actionsSlot.setAttribute(`slot`,`actions`),r.appendChild(this._actionsSlot));let a=this._actionsSlot.querySelector(`mint-stack`);a||(a=document.createElement(`mint-stack`),a.setAttribute(`direction`,`horizontal`),a.className=`justify-end`,this._actionsSlot.appendChild(a)),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._modal&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==a&&a.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._modal&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;let e=document.documentElement.classList.contains(`dark`),t=this._modal.querySelector(`.modal-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`,`border`,`border-mint-divider`)):(t.classList.remove(`bg-mint-elevated`,`border`,`border-mint-divider`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,e.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})}))}_animateExit(){let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`hidden`);return}e.style.transition=`opacity 200ms ease-in, transform 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`,g);var _=class extends HTMLElement{static get observedAttributes(){return[`id`,`direction`,`open`,`trigger-id`,`padding`,`hover`,`distance`]}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}connectedCallback(){let e=this._isInsideModal()?`z-[60]`:`z-50`;this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`top-0`,`left-0`,e,`pointer-events-none`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._setupTrigger(),this._observeDarkMode()}_ownsNode(e){return e?!!(this.contains(e)||this._triggerElement?.contains(e)):!1}_isInsideModal(){let e=this;for(;e;){if(e.tagName===`MINT-MODAL`)return!0;e=e.parentElement}if(this._triggerElement)for(e=this._triggerElement;e;){if(e.tagName===`MINT-MODAL`)return!0;e=e.parentElement}return!1}disconnectedCallback(){this._removeHoverListeners(),this._overlay?.remove(),this._popover?.remove(),this._overlay=null,this._popover=null,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&this._triggerElement.removeAttribute(`active`),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!1),null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler,!0),this._triggerClickHandler=null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}attributeChangedCallback(e,t,n){if(t!==n){if(this.isConnected){let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this.classList.remove(`z-50`,`z-[60]`,`z-[80]`),this.classList.add(e)}this.render(),(e===`trigger-id`||e===`hover`)&&this._setupTrigger(),e===`open`&&this.isOpen()&&this._closeOtherPopovers()}}getId(){return this.getAttribute(`id`)||``}getPadding(){let 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`)||``}getDistance(){return(this.getAttribute(`distance`)||``).trim()}_getDistancePx(){let e=this.getDistance();if(!e)return 8;let t=e.match(/^(-?\d*\.?\d+)\s*(px|rem)$/i);if(!t)return 8;let n=parseFloat(t[1]),r=t[2].toLowerCase();if(!Number.isFinite(n))return 8;let i=Math.max(0,n);if(r===`px`)return i;let a=parseFloat(getComputedStyle(document.documentElement).fontSize||`16`);return i*(Number.isFinite(a)?a:16)}isHoverEnabled(){return this.getAttribute(`hover`)===`true`}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}_setupTrigger(){let 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){let e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.getAttribute(`open`)===`true`?e.removeAttribute(`open`):e.setAttribute(`open`,`true`)},this._triggerElement.addEventListener(`click`,this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();let e=this;this._triggerHoverEnterHandler=function(){e._cancelHoverClose(),e.open()},this._triggerHoverLeaveHandler=function(t){let n=t.relatedTarget;n&&e._ownsNode(n)||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){let n=t.relatedTarget;n&&e._ownsNode(n)||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(){let 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`};let 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`);let n=t.getBoundingClientRect(),r=window.innerWidth,i=window.innerHeight,a=this._getDistancePx(),o=this.getDirection(),s=0,c=0;switch(o){case`down`:if(s=e.bottom+a,c=e.left+e.width/2-n.width/2,s+n.height>i){let t=e.top-n.height-a;t>=0?(o=`up`,s=t):(s=Math.max(0,i-n.height-a),s+n.height>i&&(s=0))}c<0&&(c=a),c+n.width>r&&(c=Math.max(a,r-n.width-a),c+n.width>r&&(c=r-n.width));break;case`up`:if(s=e.top-n.height-a,c=e.left+e.width/2-n.width/2,s<0){let t=e.bottom+a;t+n.height<=i?(o=`down`,s=t):(s=Math.min(i-n.height-a,i-n.height),s<0&&(s=i-n.height))}c<0&&(c=a),c+n.width>r&&(c=Math.max(a,r-n.width-a),c+n.width>r&&(c=r-n.width));break;case`right`:if(s=e.top+e.height/2-n.height/2,c=e.right+a,c+n.width>r){let t=e.left-n.width-a;t>=0?(o=`left`,c=t):(c=Math.max(0,r-n.width-a),c+n.width>r&&(c=r-n.width))}s<0&&(s=a),s+n.height>i&&(s=Math.max(a,i-n.height-a),s+n.height>i&&(s=i-n.height));break;case`left`:if(s=e.top+e.height/2-n.height/2,c=e.left-n.width-a,c<0){let t=e.right+a;t+n.width<=r?(o=`right`,c=t):(c=Math.min(r-n.width-a,r-n.width),c<0&&(c=0))}s<0&&(s=a),s+n.height>i&&(s=Math.max(a,i-n.height-a),s+n.height>i&&(s=i-n.height));break}return{top:s,left:c,direction:o}}render(){let e=this.getId(),t=this.isOpen(),n=this.getPadding();if(e&&(this.id=e),t){if(this.classList.remove(`hidden`),this.style.pointerEvents=`auto`,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&requestAnimationFrame(()=>{this._triggerElement.setAttribute(`active`,`true`);let e=this._triggerElement;typeof e.render==`function`&&requestAnimationFrame(()=>{e.render()})}),!this._clickOutsideHandler){let e=this;this._clickOutsideHandler=function(t){let n=t.composedPath(),r=n.some(t=>t===e?!0:t instanceof Node?e._ownsNode(t):!1);if(!(e._triggerElement&&n.includes(e._triggerElement))&&!r){e.close();return}},setTimeout(()=>{document.addEventListener(`click`,this._clickOutsideHandler,!1)},100)}}else this.classList.add(`hidden`),this.style.pointerEvents=`none`,this._triggerElement&&this._triggerElement.tagName===`MINT-BUTTON`&&requestAnimationFrame(()=>{this._triggerElement.removeAttribute(`active`);let e=this._triggerElement;typeof e.render==`function`&&requestAnimationFrame(()=>{e.render()})}),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!1),null);if(this._overlay){let e=this._isInsideModal()?`z-[75]`:`z-[55]`;this._overlay.className=`fixed inset-0 pointer-events-none ${e}`,this._overlay.parentElement!==this&&this.appendChild(this._overlay)}else{this._overlay=document.createElement(`div`);let e=this._isInsideModal()?`z-[75]`:`z-[55]`;this._overlay.className=`fixed inset-0 pointer-events-none ${e}`,this.appendChild(this._overlay)}if(this._popover){let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this._popover.className=`fixed ${e} pointer-events-auto`,this._popover.parentElement!==this&&this.appendChild(this._popover)}else{this._popover=document.createElement(`div`);let e=this._isInsideModal()?`z-[80]`:`z-[60]`;this._popover.className=`fixed ${e} pointer-events-auto`,this.appendChild(this._popover)}this.isHoverEnabled()&&this._attachHoverListeners();let r=this._popover.querySelector(`.popover-content`);if(!r)r=document.createElement(`div`),r.className=`popover-content bg-white dark:bg-mint-elevated border border-gray-200 dark:border-mint-divider rounded-lg shadow-xl ${n} transform`,this._popover.appendChild(r);else{let e=r.className.split(/\s+/).filter(Boolean),t=[`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`],i=e.filter(e=>!t.includes(e)),a=[`border`,`border-gray-200`,`dark:border-mint-divider`],o=[...i];for(let e of a)o.includes(e)||o.push(e);r.className=[...o,n].join(` `)}Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._popover&&e.parentElement===this&&r.appendChild(e)}),t?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(r):(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`,r.style.transform=`scale(0.97) translateY(10px)`,r.style.opacity=`0`,r.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{r.style.transform=`scale(1) translateY(0)`,r.style.opacity=`1`})}))):!t&&r&&(this._removePositionListeners(),r.style.opacity!==`0`&&r.style.opacity!==``&&(r.style.transition=`opacity 200ms ease-in, transform 200ms ease-in`,r.style.transform=`scale(0.97) translateY(10px)`,r.style.opacity=`0`,setTimeout(()=>{r.style.transform=``,r.style.opacity=``,r.style.transition=``,this._popover.style.visibility=``,this._popover.style.display=``},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;let e=document.documentElement.classList.contains(`dark`),t=this._popover.querySelector(`.popover-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`)):(t.classList.remove(`bg-mint-elevated`),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;let 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;let n=this._calculatePosition();this._popover.style.top=`${n.top}px`,this._popover.style.left=`${n.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=`opacity 200ms ease-out, transform 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){let e=this;this._scrollHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);t&&e._updatePosition(t)}},window.addEventListener(`scroll`,this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){let e=this;this._resizeHandler=function(){if(e.isOpen()&&e._popover){let t=e._popover.querySelector(`.popover-content`);t&&e._updatePosition(t)}},window.addEventListener(`resize`,this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}_closeOtherPopovers(){Array.from(document.querySelectorAll(`mint-popover[open]`)).forEach(e=>{if(e!==this){let t=e;typeof t.close==`function`?t.close():e.removeAttribute(`open`)}})}};customElements.get(`mint-popover`)||customElements.define(`mint-popover`,_);var v=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`,`error`,`error-message`,`loading`]}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}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`),this._checked=this.getAttribute(`checked`)===`true`,this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`,this._checkbox&&(this._checkbox.checked=this._checked)),t!==n){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(){try{return this._checked||!1}catch{return!1}}set checked(e){try{e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}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.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getCheckboxClasses(){let e=this.hasError(),t=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded`,`border-2`,`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`],n=this._checked?[`bg-neutral-800`,`dark:bg-neutral-600`,e?`border-red-300 dark:border-red-300`:`border-neutral-800 dark:border-neutral-600`]:[`bg-white`,`dark:bg-mint-elevated`,e?`border-red-300 dark:border-red-300`:`border-gray-300 dark:border-gray-500`];return[...t,...n].join(` `)}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.isDisabled(),i=this.querySelector(`.mint-checkbox-container`);i||(i=document.createElement(`div`),i.className=`mint-checkbox-container relative inline-flex items-start gap-2`,this.insertBefore(i,this.firstChild));let a=this.querySelector(`.mint-checkbox-wrapper`);a?a.parentElement!==i&&i.appendChild(a):(a=document.createElement(`div`),a.className=`mint-checkbox-wrapper`,i.appendChild(a)),this._checkbox?this._checkbox.parentElement!==a&&a.appendChild(this._checkbox):(this._checkbox=document.createElement(`input`),this._checkbox.type=`checkbox`,a.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=r,this._changeHandler||this.setupEventListeners();let o=this.getId();o?this._checkbox.id=o:this._checkbox.removeAttribute(`id`);let s=this.getName();s?this._checkbox.name=s:this._checkbox.removeAttribute(`name`);let c=this.getValue();c?this._checkbox.value=c:this._checkbox.removeAttribute(`value`),t?this._checkbox.setAttribute(`aria-label`,t):this._checkbox.removeAttribute(`aria-label`),a.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,a.style.cursor=`pointer`,a.style.pointerEvents=`auto`,this._checkbox.style.pointerEvents=`auto`;let l=a;l._wrapperClickHandler||(l._wrapperClickHandler=e=>{e.target===a&&!r&&(e.preventDefault(),e.stopPropagation(),this.toggle())},a.addEventListener(`click`,l._wrapperClickHandler));let u=a.querySelector(`mint-icon`);u||(u=document.createElement(`mint-icon`),u.setAttribute(`name`,`check`),u.className=`w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto`,u.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,u.style.zIndex=`1`,a.appendChild(u)),this.updateVisualState();let d=this.querySelector(`.mint-checkbox-label-container`),f=this.querySelector(`.mint-checkbox-container`);if(t||n){d?f&&d.parentElement!==f&&f.appendChild(d):(d=document.createElement(`div`),d.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,f?f.appendChild(d):this.appendChild(d));let e=d.querySelector(`.mint-checkbox-label`);t?(e||(e=document.createElement(`span`),e.className=`mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,d.insertBefore(e,d.firstChild)),e.textContent=t,r?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)):e&&e.remove();let i=d.querySelector(`.mint-checkbox-info`);if(n?(i||(i=document.createElement(`span`),i.className=`mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,d.appendChild(i)),i.textContent=n,r?i.classList.add(`opacity-40`):i.classList.remove(`opacity-40`)):i&&i.remove(),r)d.style.cursor=`default`,d._clickHandler&&(d.removeEventListener(`click`,d._clickHandler),d._clickHandler=null);else{d.style.cursor=`pointer`;let e=d._clickHandler;e&&d.removeEventListener(`click`,e),d._clickHandler=e=>{this._checkbox&&(e.target===this._checkbox||this._checkbox.contains(e.target)||e.composedPath().includes(this._checkbox))||this.toggle()},d.addEventListener(`click`,d._clickHandler)}}else d&&d.remove();this._renderErrorState(),this._renderSkeleton(e)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this.updateVisualState();let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}));let n=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(n)},this._checkbox.addEventListener(`change`,this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(38 38 38)`,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(64 64 64)`:t.style.backgroundColor=`rgb(48 48 48)`))},this._mouseupHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&(t.classList.remove(`mint-checkbox-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._mouseleaveHandler=e=>{let 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=>{let t=this.querySelector(`.mint-checkbox-wrapper`);t&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(`:focus-visible`)&&t?.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)})},this._blurHandler=()=>{let 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();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(38 38 38)`,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(64 64 64)`:t.style.backgroundColor=`rgb(48 48 48)`))},this._touchendHandler=e=>{e.stopPropagation();let 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),null),this._mousedownHandler&&=(this._checkbox.removeEventListener(`mousedown`,this._mousedownHandler),null),this._mouseupHandler&&=(this._checkbox.removeEventListener(`mouseup`,this._mouseupHandler),null),this._mouseleaveHandler&&=(this._checkbox.removeEventListener(`mouseleave`,this._mouseleaveHandler),null),this._touchstartHandler&&=(this._checkbox.removeEventListener(`touchstart`,this._touchstartHandler),null),this._touchendHandler&&=(this._checkbox.removeEventListener(`touchend`,this._touchendHandler),null),this._focusHandler&&=(this._checkbox.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._checkbox.removeEventListener(`blur`,this._blurHandler),null));let e=this.querySelector(`.mint-checkbox-wrapper`);if(e){let t=e;t._wrapperClickHandler&&=(e.removeEventListener(`click`,t._wrapperClickHandler),null)}}updateVisualState(){let e=this.querySelector(`.mint-checkbox-wrapper`),t=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.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this.updateVisualState(),this.dispatchEvent(new CustomEvent(`input`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0}));let 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`),n=this.querySelector(`.mint-checkbox-container`),r=this.querySelector(`.mint-checkbox-wrapper`),i=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`,n?n.appendChild(t):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-checkbox-skeleton-box`);if(e||(e=document.createElement(`div`),e.className=`mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e)),i){let e=t.querySelector(`.mint-checkbox-skeleton-label`);e||(e=document.createElement(`div`),e.className=`mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e))}t.style.display=`flex`,r&&(r.style.visibility=`hidden`,r.style.pointerEvents=`none`),i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),r&&(r.style.visibility=`visible`,r.style.pointerEvents=`auto`),i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-checkbox-label-container`);!n&&e&&t&&(n=document.createElement(`div`),n.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(n));let r=this.querySelector(`.mint-checkbox-error`);e&&t?(r?(r.classList.add(`block`,`w-full`),r.style.display=`block`,(n&&r.parentElement!==n||n&&r.parentElement===n)&&n.appendChild(r)):(r=document.createElement(`div`),r.className=`mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full`,r.style.display=`block`,n?n.appendChild(r):this.appendChild(r)),r.textContent=t):r&&r.remove();let i=this.querySelector(`.mint-checkbox-wrapper`);i&&(i.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}};customElements.get(`mint-checkbox`)||customElements.define(`mint-checkbox`,v);var y=class extends HTMLElement{static get observedAttributes(){return[`value`,`checked`,`disabled`,`loading`,`info`]}constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}connectedCallback(){this.classList.add(`inline-flex`,`items-start`,`gap-2`,`cursor-pointer`,`select-none`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._radio&&(this._changeHandler&&=(this._radio.removeEventListener(`change`,this._changeHandler),null),this._focusHandler&&=(this._radio.removeEventListener(`focus`,this._focusHandler),null),this._blurHandler&&=(this._radio.removeEventListener(`blur`,this._blurHandler),null),this._keydownHandler&&=(this._radio.removeEventListener(`keydown`,this._keydownHandler),null))}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(e===`checked`&&(this._checked=n===`true`,this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),t!==n){if(e===`loading`){this.render();return}if(e===`info`){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(e){try{this._checked=!!e,e?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`),this._radio&&(this._radio.checked=this._checked),this.isConnected?requestAnimationFrame(()=>{this._updateVisualState()}):this._updateVisualState()}catch{}}getValue(){return this.getAttribute(`value`)||``}getInfo(){return this.getAttribute(`info`)||``}isDisabled(){let e=this.getAttribute(`disabled`)===`true`,t=this.closest(`mint-choice`)?.getAttribute(`disabled`)===`true`;return e||t}_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`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState();let e=this.closest(`mint-choice`);e&&e.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener(`click`,this._clickHandler))}render(){let e=this.isLoading(),t=this.isDisabled(),n=this.getValue(),r=this.closest(`mint-choice`)?.getAttribute(`name`)||``,i=``,a=this.querySelector(`.mint-choice-option-label`);if(a)i=a.textContent?.trim()||``;else{let e=this.querySelector(`.mint-choice-option-label-container`);Array.from(this.childNodes).forEach(t=>{if(t!==e&&t.nodeType===Node.TEXT_NODE){let e=t.textContent?.trim();e&&(i+=e)}})}let o=this.querySelectorAll(`.mint-choice-option-wrapper`),s=null;o.length>0&&(this._radio&&(s=Array.from(o).find(e=>e.contains(this._radio))),s||=o[0],o.forEach((e,t)=>{e!==s&&e.remove()})),s||(s=document.createElement(`div`),s.className=`mint-choice-option-wrapper`,s.style.position=`relative`,this.insertBefore(s,this.firstChild)),s.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,s.style.position=`relative`,this.querySelectorAll(`input[type="radio"]`).forEach(e=>{e!==this._radio&&e.remove()}),this._radio?(this._radio.parentElement!==s&&s.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener(`change`,this._changeHandler),this._radio.addEventListener(`change`,this._changeHandler)),this._radio&&(this._focusHandler||=e=>{let t=this.querySelector(`.mint-choice-option-wrapper`);t&&!this.isDisabled()&&t.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._blurHandler||=()=>{let e=this.querySelector(`.mint-choice-option-wrapper`);e&&e.classList.remove(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._keydownHandler||=e=>{this.isDisabled()||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),this._focusNextOption()):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.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))):(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`,s.appendChild(this._radio),this._changeHandler=e=>{let t=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState();let n=this.closest(`mint-choice`);t!==this._checked&&n&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener(`change`,this._changeHandler),this._radio.addEventListener(`click`,()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.removeAttribute(`checked`),this._updateVisualState(),this._updateGroupState())}),this._focusHandler=e=>{let t=this.querySelector(`.mint-choice-option-wrapper`);t&&!this.isDisabled()&&t.classList.add(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._radio.addEventListener(`focus`,this._focusHandler),this._blurHandler=()=>{let e=this.querySelector(`.mint-choice-option-wrapper`);e&&e.classList.remove(`ring-2`,`ring-offset-1`,`ring-gray-400`,`dark:ring-gray-500`)},this._radio.addEventListener(`blur`,this._blurHandler),this._keydownHandler=e=>{this.isDisabled()||(e.key===`ArrowDown`||e.key===`ArrowRight`?(e.preventDefault(),this._focusNextOption()):(e.key===`ArrowUp`||e.key===`ArrowLeft`)&&(e.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener(`keydown`,this._keydownHandler)),this._radio.name=r,this._radio.value=n,this._radio.checked===this._checked?this._radio.checked=this._checked:(this._checked=this._radio.checked,this._checked?this.setAttribute(`checked`,`true`):this.setAttribute(`checked`,`false`)),this._radio.disabled=t,t?this._radio.setAttribute(`tabindex`,`-1`):this._radio.removeAttribute(`tabindex`),i?this._radio.setAttribute(`aria-label`,i):this._radio.removeAttribute(`aria-label`),s.querySelectorAll(`.mint-choice-option-indicator`).forEach((e,t)=>{t>0&&e.remove()});let c=s.querySelector(`.mint-choice-option-indicator`);c||(c=document.createElement(`div`),c.className=`mint-choice-option-indicator`,s.appendChild(c)),c.className=`mint-choice-option-indicator w-2 h-2 rounded-full bg-white pointer-events-none`,c.style.position=`absolute`,c.style.top=`50%`,c.style.left=`50%`,c.style.transform=this._checked?`translate(-50%, -50%) scale(1)`:`translate(-50%, -50%) scale(0)`,c.style.opacity=this._checked?`1`:`0`,this._updateVisualState(),this._renderSkeleton(e);let l=this.getInfo(),u=this.querySelector(`.mint-choice-option-label-container`);if(i||l){u||(u=document.createElement(`div`),u.className=`mint-choice-option-label-container flex flex-col gap-0.5`,this.appendChild(u),Array.from(this.childNodes).forEach(e=>{e.nodeType===Node.TEXT_NODE&&e.textContent?.trim()&&e!==u&&(e.textContent=``)}));let e=u.querySelector(`.mint-choice-option-label`);i?(e||(e=document.createElement(`span`),e.className=`mint-choice-option-label`,u.appendChild(e)),e.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${t?`opacity-40`:``}`,e.textContent=i):e&&e.remove();let n=u.querySelector(`.mint-choice-option-info`);l?(n||(n=document.createElement(`span`),n.className=`mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none`,u.appendChild(n)),n.textContent=l,t?n.classList.add(`opacity-40`):n.classList.remove(`opacity-40`)):n&&n.remove()}else u&&u.remove();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(){let e=this.isDisabled(),t=[`inline-flex`,`items-center`,`justify-center`,`w-[1rem]`,`h-[1rem]`,`rounded-full`,`border-2`,`flex-shrink-0`,`mt-0.5`];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-mint-elevated`,`border-gray-300`,`dark:border-gray-500`),t.join(` `)}_updateVisualState(){let e=this.querySelector(`.mint-choice-option-wrapper`);e&&(e.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);let 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`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-choice-option-skeleton-radio`);if(e||(e=document.createElement(`div`),e.className=`mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`input[type="radio"]`),t=n.querySelector(`.mint-choice-option-indicator`);e&&(e.style.visibility=`hidden`),t&&(t.style.visibility=`hidden`),n.style.pointerEvents=`none`}}else{if(t&&(t.style.display=`none`),n){let e=n.querySelector(`input[type="radio"]`),t=n.querySelector(`.mint-choice-option-indicator`);e&&(e.style.visibility=`visible`),t&&(t.style.visibility=`visible`),n.style.pointerEvents=`auto`}let e=this.querySelector(`.mint-choice-option-label`);e&&!n?.contains(e)&&(e.style.visibility=`visible`,e.style.pointerEvents=`auto`)}}_updateGroupState(){this._radio?.name&&document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(e=>{if(e===this._radio)return;let t=e.closest(`mint-choice-option`);t&&t!==this&&(t._checked=e.checked,e.checked?t.setAttribute(`checked`,`true`):t.removeAttribute(`checked`),t._updateVisualState())})}_focusNextOption(){if(!this._radio?.name)return;let e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(e=>!e.disabled),t=e.indexOf(this._radio),n=null;if(t>=0&&t<e.length-1?n=e[t+1]:e.length>0&&(n=e[0]),n){let e=n.closest(`mint-choice-option`);if(n.checked=!0,e){let t=e._checked;if(e._checked=!0,e.setAttribute(`checked`,`true`),e._changeHandler){let t=new Event(`change`,{bubbles:!0});e._changeHandler.call(e,t)}else e._updateVisualState(),e._updateGroupState();let n=e.closest(`mint-choice`);n&&!t&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:!0,value:e.getValue()},bubbles:!0,cancelable:!0}))},0)}n.focus(),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}_focusPreviousOption(){if(!this._radio?.name)return;let e=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(e=>!e.disabled),t=e.indexOf(this._radio),n=null;if(t>0?n=e[t-1]:e.length>0&&(n=e[e.length-1]),n){let e=n.closest(`mint-choice-option`);if(n.checked=!0,e){let t=e._checked;if(e._checked=!0,e.setAttribute(`checked`,`true`),e._changeHandler){let t=new Event(`change`,{bubbles:!0});e._changeHandler.call(e,t)}else e._updateVisualState(),e._updateGroupState();let n=e.closest(`mint-choice`);n&&!t&&setTimeout(()=>{n.dispatchEvent(new CustomEvent(`choice-change`,{detail:{checked:!0,value:e.getValue()},bubbles:!0,cancelable:!0}))},0)}n.focus(),n.dispatchEvent(new Event(`change`,{bubbles:!0}))}}};customElements.get(`mint-choice-option`)||customElements.define(`mint-choice-option`,y);var b=class extends HTMLElement{static get observedAttributes(){return[`label`,`name`,`info`,`error`,`error-message`,`id`,`disabled`,`required`,`loading`]}constructor(){super(),this._optionsContainer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`,`w-full`),this.render(),this.addEventListener(`choice-change`,e=>{let t=e.detail?.value||this.getValue();(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))})}disconnectedCallback(){}isLoading(){return this.hasAttribute(`loading`)}attributeChangedCallback(e,t,n){t!==n&&(e===`error`||e===`error-message`?this._renderErrorState():e===`loading`?(this.render(),this.querySelectorAll(`mint-choice-option`).forEach(e=>{this.isLoading()?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`)})):(this.render(),e===`name`&&this.querySelectorAll(`mint-choice-option`).forEach(e=>{typeof e.render==`function`&&e.render()})))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}getValue(){return this.querySelector(`input[type="radio"]:checked`)?.value||``}setValue(e){let t=this.querySelectorAll(`mint-choice-option`);t.forEach(t=>{if((t.getAttribute(`value`)||``)===e){let e=t;e.checked=!0;let n=t.querySelector(`input[type="radio"]`);n&&(n.checked=!0,n.dispatchEvent(new Event(`change`,{bubbles:!0})))}else{let e=t;e.checked=!1;let n=t.querySelector(`input[type="radio"]`);n&&(n.checked=!1)}}),requestAnimationFrame(()=>{t.forEach(e=>{typeof e._updateVisualState==`function`&&e._updateVisualState();let t=e.querySelector(`input[type="radio"]`);if(t){let n=e;t.checked!==n.checked&&(t.checked=n.checked)}})})}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{this.setValue(e||``)}catch{}}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute(`id`,r);let i=this.isDisabled(),a=this.querySelector(`.mint-choice-label-container`);if(t||n){a||(a=document.createElement(`div`),a.className=`mint-choice-label-container flex flex-col gap-0.5 mb-2`,this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-choice-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.insertBefore(e,a.firstChild)),e.textContent=t,e.setAttribute(`for`,r),i?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)):e&&e.remove();let o=a.querySelector(`.mint-choice-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none`,a.appendChild(o)),o.textContent=n,i?o.classList.add(`opacity-40`):o.classList.remove(`opacity-40`)):o&&o.remove()}else a&&a.remove();let o=this.querySelector(`.mint-choice-options-wrapper`);if(!o){o=document.createElement(`div`),o.className=`mint-choice-options-wrapper relative`;let e=this.querySelector(`.mint-choice-label-container`);e&&e.parentElement===this?this.insertBefore(o,e.nextSibling):this.insertBefore(o,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==o&&o.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement(`div`),this._optionsContainer.className=`mint-choice-options-container flex flex-col gap-3`,o.appendChild(this._optionsContainer)),Array.from(this.children).filter(e=>e.tagName===`MINT-CHOICE-OPTION`&&e.parentElement!==this._optionsContainer).forEach(e=>{this._optionsContainer.appendChild(e)}),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-choice-skeleton-container`),n=this.querySelector(`.mint-choice-options-wrapper`),r=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`,n?n.appendChild(t):(this.style.position=`relative`,this.appendChild(t))),t.querySelectorAll(`.mint-choice-option-skeleton`).length===0)for(let e=0;e<3;e++){let e=document.createElement(`div`);e.className=`mint-choice-option-skeleton flex items-center gap-3`;let n=document.createElement(`div`);n.className=`flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-mint-hover animate-pulse`,e.appendChild(n);let r=document.createElement(`div`);r.className=`h-4 w-20 rounded bg-gray-200 dark:bg-mint-hover animate-pulse`,e.appendChild(r),t.appendChild(e)}t.style.display=`flex`,r&&(r.style.opacity=`0`,r.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),r&&(r.style.opacity=`1`,r.style.pointerEvents=`auto`)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-choice-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-choice`)||customElements.define(`mint-choice`,b);var x=class extends HTMLElement{static get observedAttributes(){return[`type`,`placeholder`,`value`,`disabled`,`id`,`name`,`required`,`readonly`,`rows`,`icon`,`label`,`info`,`error`,`error-message`,`loading`]}constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._prependSlotContainer=null,this._appendSlotContainer=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._slotResizeObserver=null,this._slotMutationObserver=null,this._contentObserver=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null,this._renderFrame=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._observeContentMutations()}disconnectedCallback(){this.removeEventListeners(),this._slotResizeObserver&&=(this._slotResizeObserver.disconnect(),null),this._slotMutationObserver&&=(this._slotMutationObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){if(t!==n){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()}}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getType(){return this.getAttribute(`type`)||`text`}getRows(){let e=this.getAttribute(`rows`);return e?parseInt(e,10):3}_getNormalizedType(){let 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(){return this._isColor()?this._colorTextInput?this._colorTextInput.value:this._colorPicker?this._colorPicker.value:this.getAttribute(`value`)||`#000000`:this._element?this._element.value:this.getAttribute(`value`)||``}set value(e){try{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`)}catch{}}get value(){try{return this.getValue()||``}catch{return``}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}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(){let e=this._isTextarea(),t=!!this.getIcon(),n=this.querySelector(`[slot="prepend"]`)!==null,r=this.querySelector(`[slot="append"]`)!==null,i=this._isColor(),a=this._isNumber(),o=this.hasError(),s=[`w-full`,t||i||n?`pl-10`:`px-3.5`,r?`pr-10`:t||i?`pr-3.5`:a?`pr-10`:``,e?`py-2`:`py-1.5`,e?`min-h-[6rem]`:`min-h-[2rem]`,`text-base`,`min-[1100px]:text-sm`,`font-medium`,`rounded-lg`,`box-border`,`bg-white`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`readonly:cursor-default`,e?`resize-y`:``,a?`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`:``],c=[`border-2`,o?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],l=[`focus-visible:ring-2`,`focus-visible:ring-offset-1`,o?`focus-visible:ring-red-400 dark:focus-visible:ring-red-500`:`focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`];return[...s,...c,...l].filter(Boolean).join(` `)}_syncSlotAdornments(e,t){if(!this._wrapper||e||this._isColor()){this._prependSlotContainer&&=(this._prependSlotContainer.remove(),null),this._appendSlotContainer&&=(this._appendSlotContainer.remove(),null),this._clearAdornmentPadding();return}this._prependSlotContainer||(this._prependSlotContainer=document.createElement(`div`),this._prependSlotContainer.className=`mint-input-prepend-slot absolute top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1.5 text-gray-500 dark:text-gray-400 pointer-events-auto`,this._wrapper.appendChild(this._prependSlotContainer)),this._appendSlotContainer||(this._appendSlotContainer=document.createElement(`div`),this._appendSlotContainer.className=`mint-input-append-slot absolute right-3 top-1/2 z-[1] flex -translate-y-1/2 items-center gap-1.5 text-gray-500 dark:text-gray-400 pointer-events-auto`,this._wrapper.appendChild(this._appendSlotContainer)),this._prependSlotContainer.classList.remove(`left-3`,`left-10`),this._prependSlotContainer.classList.add(t?`left-10`:`left-3`);let n=Array.from(this.querySelectorAll(`[slot="prepend"]`)),r=Array.from(this.querySelectorAll(`[slot="append"]`));this._prependSlotContainer.replaceChildren(),this._appendSlotContainer.replaceChildren(),n.forEach(e=>this._prependSlotContainer.appendChild(e)),r.forEach(e=>this._appendSlotContainer.appendChild(e)),this._prependSlotContainer.classList.toggle(`hidden`,n.length===0),this._appendSlotContainer.classList.toggle(`hidden`,r.length===0),this._ensureSlotObservers(),this._applyAdornmentPadding(t)}_clearAdornmentPadding(){this._element&&(this._element.style.removeProperty(`padding-left`),this._element.style.removeProperty(`padding-right`)),this._colorTextInput&&(this._colorTextInput.style.removeProperty(`padding-left`),this._colorTextInput.style.removeProperty(`padding-right`))}_applyAdornmentPadding(e){this._element&&requestAnimationFrame(()=>{if(this._element){if(this._prependSlotContainer&&!this._prependSlotContainer.classList.contains(`hidden`)){let t=(e?40:12)+this._prependSlotContainer.offsetWidth+8;this._element.style.paddingLeft=`${t}px`}else this._element.style.removeProperty(`padding-left`);if(this._appendSlotContainer&&!this._appendSlotContainer.classList.contains(`hidden`)){let e=12+this._appendSlotContainer.offsetWidth+8;this._element.style.paddingRight=`${e}px`}else this._element.style.removeProperty(`padding-right`)}})}_ensureSlotObservers(){!this._prependSlotContainer&&!this._appendSlotContainer||(this._slotResizeObserver||=new ResizeObserver(()=>{this._applyAdornmentPadding(!!this.getIcon())}),this._slotResizeObserver.disconnect(),this._prependSlotContainer&&this._slotResizeObserver.observe(this._prependSlotContainer),this._appendSlotContainer&&this._slotResizeObserver.observe(this._appendSlotContainer),this._slotMutationObserver||=new MutationObserver(()=>{this._applyAdornmentPadding(!!this.getIcon())}),this._slotMutationObserver.disconnect(),this._prependSlotContainer&&this._slotMutationObserver.observe(this._prependSlotContainer,{childList:!0,subtree:!0,characterData:!0}),this._appendSlotContainer&&this._slotMutationObserver.observe(this._appendSlotContainer,{childList:!0,subtree:!0,characterData:!0}))}isLoading(){return this.getAttribute(`loading`)===`true`}render(){this.getType();let e=this._getNormalizedType(),t=this._isTextarea(),n=this._isMoney(),r=this._isColor(),i=this.getPlaceholder(),a=this.isDisabled(),o=this.isReadonly(),s=this.isRequired(),c=this.getId(),l=this.getName(),u=this.getAttribute(`value`)||(r?`#000000`:``),d=this.getRows(),f=this.getIcon(),p=this.getLabel(),m=this.getInfo(),h=this.isLoading();if(this._renderSkeleton(h),r){this._input&&=(this._input.remove(),null),this._textarea&&=(this._textarea.remove(),null),this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`relative w-full`,this.appendChild(this._wrapper)),this._colorContainer&&=(this._colorContainer.remove(),null),this._colorPickerWrapper&&!r&&(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=u||`#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=e=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&requestAnimationFrame(()=>{this._colorPicker&&this._colorPicker.matches(`:focus-visible`)&&this._colorPickerWrapper?.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`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this._colorTextInput&&(this._colorTextInput.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener(`change`,()=>{let e=this._colorPicker?.value||`#000000`;this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:e},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement(`input`),this._colorTextInput.type=`text`,this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=i||`#000000`,this._colorTextInput.pattern=`^#[0-9A-Fa-f]{6}$`,this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener(`input`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)&&(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener(`blur`,()=>{let e=this._colorTextInput?.value||``;/^#[0-9A-Fa-f]{6}$/.test(e)?(this._colorPicker&&(this._colorPicker.value=e),this.setAttribute(`value`,e)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this._colorPicker?.value||`#000000`},bubbles:!0,cancelable:!0}))}));let e=u||`#000000`;if(this._colorPicker&&this._colorPicker.value!==e&&(this._colorPicker.value=e),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=e),this._colorTextInput&&this._colorTextInput.value!==e&&(this._colorTextInput.value=e),this._colorPicker&&(this._colorPicker.disabled=a),this._colorPickerWrapper&&(a?(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=a,this._colorTextInput.readOnly=o,this._colorTextInput.required=s),this._colorTextInput){let e=this._colorTextInput;c?e.id=c:e.removeAttribute(`id`),l?e.name=l:e.removeAttribute(`name`),e.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),this._element=e}this._renderErrorState();let t=this.querySelector(`.mint-input-label-container`);if(p||m){t||(t=document.createElement(`div`),t.className=`mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(t,this._wrapper):this.insertBefore(t,this.firstChild));let e=t.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,t.insertBefore(e,t.firstChild)),e.textContent=p;let n=c||this._colorTextInput?.id;if(n)e.setAttribute(`for`,n);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._colorTextInput&&(this._colorTextInput.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)}else e&&e.remove();let n=t.querySelector(`.mint-input-info`);m?(n||(n=document.createElement(`span`),n.className=`mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none`,t.appendChild(n)),n.textContent=m,a?n.classList.add(`opacity-40`):n.classList.remove(`opacity-40`)):n&&n.remove()}else t&&t.remove();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&&!r&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),f&&!t?this._icon?this._icon.setAttribute(`name`,f):(this._icon=document.createElement(`mint-icon`),this._icon.setAttribute(`name`,f),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(),null),this._syncSlotAdornments(t,!!f),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 pointer-events-auto bg-gray-100 dark:bg-mint-hover active:bg-gray-200 dark:active:bg-mint-elevated rounded`;let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`caret-up`),e.className=`w-[1rem] h-[1rem]`,this._numberIncrementButton.appendChild(e),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement(`button`),this._numberDecrementButton.type=`button`,this._numberDecrementButton.className=`flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed pointer-events-auto bg-gray-100 dark:bg-mint-hover active:bg-gray-200 dark:active:bg-mint-elevated rounded`;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`caret-down`),t.className=`w-[1rem] h-[1rem]`,this._numberDecrementButton.appendChild(t),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e+t;r!==void 0&&i>r&&(i=r),n!==void 0&&i<n&&(i=n),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}}),this._numberDecrementButton.addEventListener(`click`,e=>{if(e.preventDefault(),e.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){let e=parseFloat(this._input.value)||0,t=parseFloat(this._input.step)||1,n=this._input.min?parseFloat(this._input.min):void 0,r=this._input.max?parseFloat(this._input.max):void 0,i=e-t;n!==void 0&&i<n&&(i=n),r!==void 0&&i>r&&(i=r),this._input.value=i.toString(),this.setAttribute(`value`,i.toString()),this._input.dispatchEvent(new Event(`input`,{bubbles:!0})),this._input.dispatchEvent(new Event(`change`,{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=a||o),this._numberDecrementButton&&(this._numberDecrementButton.disabled=a||o)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(t){if(this._input&&=(this._input.remove(),null),this._textarea||(this._textarea=document.createElement(`textarea`),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=i,this._textarea.disabled=a,this._textarea.readOnly=o,this._textarea.required=s,this._textarea.rows=d,this._textarea.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),u!==this._textarea.value&&(this._textarea.value=u),c?this._textarea.id=c:this._textarea.removeAttribute(`id`),l?this._textarea.name=l:this._textarea.removeAttribute(`name`),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._textarea.value&&(this._textarea.value=e.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&=(this._textarea.remove(),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=i,this._input.disabled=a,this._input.readOnly=o,this._input.required=s,this._input.setAttribute(`aria-invalid`,this.hasError()?`true`:`false`),n?(this._input.inputMode=`decimal`,this._input.pattern=`[0-9]*\\.?[0-9]*`):(this._input.removeAttribute(`inputmode`),this._input.removeAttribute(`pattern`)),u!==this._input.value&&(this._input.value=u),c?this._input.id=c:this._input.removeAttribute(`id`),l?this._input.name=l:this._input.removeAttribute(`name`),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){let e=this.firstChild.textContent;e&&!this._input.value&&(this._input.value=e.trim()),this.removeChild(this.firstChild)}let g=this.querySelector(`.mint-input-label-container`);if(p||m){g||(g=document.createElement(`div`),g.className=`mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]`,this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(g,this._wrapper):this.insertBefore(g,this.firstChild));let e=g.querySelector(`.mint-input-label`);if(p){e||(e=document.createElement(`label`),e.className=`mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,g.insertBefore(e,g.firstChild)),e.textContent=p;let t=c||this._element?.id||this._colorTextInput?.id||this._input?.id||this._textarea?.id;if(t)e.setAttribute(`for`,t);else{let t=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=t:this._colorTextInput?this._colorTextInput.id=t:this._input?this._input.id=t:this._textarea&&(this._textarea.id=t),e.setAttribute(`for`,t)}a?e.classList.add(`opacity-40`):e.classList.remove(`opacity-40`)}else e&&e.remove();let t=g.querySelector(`.mint-input-info`);m?(t||(t=document.createElement(`span`),t.className=`mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none`,g.appendChild(t)),t.textContent=m,a?t.classList.add(`opacity-40`):t.classList.remove(`opacity-40`)):t&&t.remove()}else g&&g.remove();this._syncSlotAdornments(t,!!f),this._renderErrorState(),this._renderSkeleton(h)}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-input-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-input-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}setupEventListeners(){this._element&&(this._element.addEventListener(`input`,()=>{let e=this._element?.value||``;e?this.setAttribute(`value`,e):this.removeAttribute(`value`);let t=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(t),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:e},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener(`blur`,()=>{let e=this._element?.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),null),this._blurHandler&&=(this._colorPicker.removeEventListener(`blur`,this._blurHandler),null))}focus(){this._isColor()&&this._colorTextInput?this._colorTextInput.focus():this._element?.focus()}blur(){this._isColor()&&this._colorTextInput?this._colorTextInput.blur():this._element?.blur()}_renderSkeleton(e){let t=this.querySelector(`.mint-input-skeleton-container`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-input-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this._isTextarea(),r=this.getRows();if(n){let t=r*24+12;e.style.height=`${t}px`}else e.style.height=`2.2rem`;t.appendChild(e)}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);var S=class extends HTMLElement{static get observedAttributes(){return[`value`,`label`,`info`,`disabled`,`id`,`name`,`required`,`readonly`,`format`,`min`,`max`,`range`,`shortcuts`,`display-format`,`error`,`error-message`,`loading`,`selection-mode`,`week-start-day`,`mode`,`disabled-dates`]}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._hoveredDate=null,this._isHandlingClick=!1,this._touchStartDate=null,this._touchStartElement=null,this._isTouchActive=!1,this._resizeObserver=null,this._popoverObserver=null,this._focusTrapHandler=null,this._escapeHandler=null}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(),null),this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._removeFocusTrap(),this._resetHandler){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){let e=this.hasError(),t=this.getErrorMessage();this._applyErrorVisuals(e,t,this.isDisabled());return}if(e===`loading`){this.render();return}if(e===`mode`||e===`format`){let e=this.getMode();e===`month`?this._viewMode=`month`:e===`year`?this._viewMode=`year`:this._viewMode=`calendar`,this._popover&&this._calendarContainer&&this._buildCalendar()}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()}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{this.setValue(e||``)}catch{}}getFormat(){return this.getAttribute(`format`)||`mm/dd/yyyy`}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isReadonly(){return this.getAttribute(`readonly`)===`true`}isRequired(){return this.getAttribute(`required`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isRange(){return this.getAttribute(`range`)===`true`}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getMin(){return this.getAttribute(`min`)||``}getMax(){return this.getAttribute(`max`)||``}getDisabledDates(){let e=this.getAttribute(`disabled-dates`);if(!e)return[];try{let t=JSON.parse(e),n=this.getFormat();return t.map(e=>this._parseDateString(e,n)).filter(e=>e!==null)}catch{return[]}}getDisabledDateStrings(){let e=this.getAttribute(`disabled-dates`);if(!e)return[];try{return JSON.parse(e)}catch{return[]}}disableDate(e){let t=this.getFormat(),n=this.getDisabledDateStrings(),r=Array.isArray(e)?e:[e],i=[];for(let e of r){let r=this._parseDateString(e,t);if(r){let e=this._formatDate(r,t);n.includes(e)||i.push(e)}}if(i.length>0){let e=[...n,...i];this.setAttribute(`disabled-dates`,JSON.stringify(e)),this._buildCalendar()}}enableDate(e){let t=this.getFormat(),n=this.getDisabledDateStrings(),r=Array.isArray(e)?e:[e],i=[];for(let e of r){let n=this._parseDateString(e,t);if(n){let e=this._formatDate(n,t);i.push(e)}}if(i.length>0){let e=n.filter(e=>!i.includes(e));e.length===0?this.removeAttribute(`disabled-dates`):this.setAttribute(`disabled-dates`,JSON.stringify(e)),this._buildCalendar()}}getSelectionMode(){let e=this.getAttribute(`selection-mode`);return e===`week`||e===`month`?e:`day`}getMode(){let e=this.getAttribute(`mode`);if(e===`month`||e===`year`)return e;let t=this.getFormat().toLowerCase(),n=t.includes(`d`),r=t.includes(`m`);return!n&&!r?`year`:!n&&r?`month`:`default`}getWeekStartDay(){return{sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6}[this.getAttribute(`week-start-day`)?.toLowerCase()||`sunday`]??0}getDisplayFormat(){return this.getAttribute(`display-format`)||`F j, Y`}getShortcuts(){let e=this.getAttribute(`shortcuts`);if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t.map(e=>({label:e.label,action:this._createShortcutAction(e.action)}))}catch{let t=e.trim();if(t&&typeof window[t]==`function`){let e=window[t]();if(Array.isArray(e))return e.map(e=>({label:e.label,action:typeof e.action==`function`?e.action:this._createShortcutAction(e.action)}))}}return[]}_createShortcutAction(e){return typeof e==`function`?e:typeof e==`string`&&typeof window[e]==`function`?window[e]:()=>null}_getDefaultShortcuts(){let e=[{label:`Today`,action:()=>new Date}];return this._isRange&&e.push({label:`This Week`,action:()=>{let e=new Date,t=e.getDay(),n=new Date(e);n.setDate(e.getDate()-t),n.setHours(0,0,0,0);let r=new Date(n);return r.setDate(n.getDate()+6),r.setHours(23,59,59,999),{start:n,end:r}}},{label:`This Month`,action:()=>{let e=new Date,t=new Date(e.getFullYear(),e.getMonth(),1),n=new Date(e.getFullYear(),e.getMonth()+1,0);return n.setHours(23,59,59,999),{start:t,end:n}}}),e}_getFormatTokens(e){let t=[],n=0,r=e.toLowerCase();for(;n<r.length;){let i=r[n];if(i===`d`||i===`m`||i===`y`){let e=1,a=n+1;for(;a<r.length&&r[a]===i;)e++,a++;t.push({type:`part`,part:i,len:e}),n=a}else t.push({type:`sep`,value:e[n]}),n++}return t}_createPartInput(e,t,n,r,i){let a=document.createElement(`input`);return a.type=`text`,a.inputMode=`numeric`,a.pattern=`\\d*`,a.maxLength=e,a.placeholder=t,a.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`,a.disabled=n||r,a.readOnly=r,a.required=i,e===4?a.className+=` w-[40px]`:e===2&&(a.className+=` w-[30px]`),a}_buildValueFromParts(e,t){let n=0;return t.map(t=>{if(t.type===`sep`)return t.value;let r=e[n]?.value||``;return n++,r}).join(``)}_applyDateToParts(e,t,n,r){if(!t.length)return;if(!e){t.forEach(e=>e.value=``);return}let i=this._formatDate(e,r),a=0,o=0;n.forEach(e=>{if(e.type===`sep`)a+=e.value.length;else{let n=i.substr(a,e.len);t[o]&&(t[o].value=n),o++,a+=e.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;let e=this.getFormat(),t=this._getFormatTokens(e),n=this._buildValueFromParts(this._startPartInputs,t);if(this._isRange){let e=this._buildValueFromParts(this._endPartInputs,t);this._hiddenInput.value=e?`${n} - ${e}`:n}else this._hiddenInput.value=n}_focusNext(e,t){if(t+1<e.length){let n=e[t+1];n.focus(),n.setSelectionRange(0,n.value.length)}}_focusPrev(e,t){if(t-1>=0){let n=e[t-1];n.focus(),n.setSelectionRange(n.value.length,n.value.length)}}_attachPartInputHandlers(e,t,n){e.forEach((t,n)=>{let r=t.maxLength||2;t.addEventListener(`input`,()=>{t.value=t.value.replace(/\D/g,``).slice(0,r),t.value.length>=r&&this._focusNext(e,n),this._syncHiddenInput()}),t.addEventListener(`keydown`,r=>{r.key===`Backspace`&&t.selectionStart===0&&t.selectionEnd===0&&this._focusPrev(e,n),r.key===`ArrowLeft`&&t.selectionStart===0&&t.selectionEnd===0&&(this._focusPrev(e,n),r.preventDefault()),r.key===`ArrowRight`&&t.selectionStart===t.value.length&&t.selectionEnd===t.value.length&&(this._focusNext(e,n),r.preventDefault())}),t.addEventListener(`blur`,e=>{this._syncHiddenInput();let t=e.relatedTarget,n=t&&(this._startPartInputs.includes(t)||this._endPartInputs.includes(t));setTimeout(()=>{if(!(this._startPartInputs.some(e=>e===document.activeElement)||this._endPartInputs.some(e=>e===document.activeElement))&&(n||this._handleBlur(this._hiddenInput?.value||``),this._exitInputMode(),!n&&this._hiddenInput)){let t=new FocusEvent(`blur`,{bubbles:!0,cancelable:!0,relatedTarget:e.relatedTarget});this._hiddenInput.dispatchEvent(t)}},0)})})}_splitRangeInput(e,t){let n=e.split(/\s*-\s*/);return n.length>=2?[n[0],n.slice(1).join(`-`)]:[e]}_parseValue(e){let t=this.getFormat(),n=this._getFormatTokens(t),r=this.getSelectionMode();if(this._isRange||r===`week`||r===`month`){let[r,i]=this._splitRangeInput(e,t),a=r?this._parseDateString(r,t):null,o=i?this._parseDateString(i,t):null;if(a&&o){let[e,t]=a<=o?[a,o]:[o,a];this._selectedStartDate=e,this._selectedEndDate=t,this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}else a&&(this._selectedStartDate=a,this._selectedEndDate=null,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,n,t),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,n,t)}else{let r=this._parseDateString(e,t);r&&!isNaN(r.getTime())?(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear(),this._applyDateToParts(r,this._startPartInputs,n,t)):this._applyDateToParts(null,this._startPartInputs,n,t)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(e,t){let n=/[\/\-\.\s]+/;if(n.test(e)){let r=e.split(n).filter(e=>e.length>0),i=t.split(/[\/\-\.\s]+/).filter(e=>e.length>0);if(r.length===i.length){let e=0,t=0,n=0;for(let a=0;a<i.length;a++){let o=i[a].toLowerCase(),s=r[a];if(o.includes(`d`))e=parseInt(s,10);else if(o.includes(`m`))t=parseInt(s,10)-1;else if(o.includes(`y`)){let e=parseInt(s,10),t=o.length,r=s.length;(r===2&&t===4||r===2&&t===2)&&(e=Math.floor(new Date().getFullYear()/100)*100+e),n=e}}let a=i.some(e=>e.toLowerCase().includes(`d`)),o=i.some(e=>e.toLowerCase().includes(`m`));if(a||(e=1),o||(t=0),t>=0&&t<=11&&n){let r=new Date(n,t,e);if(!isNaN(r.getTime()))return a&&r.getDate()!==e||r.getMonth()!==t||r.getFullYear()!==n?null:r}}}let r=e.replace(/[\/\-\.]/g,``),i=t.replace(/[\/\-\.]/g,``).toLowerCase(),a=i.indexOf(`d`),o=i.indexOf(`m`),s=i.indexOf(`y`),c=[{char:`d`,index:a},{char:`m`,index:o},{char:`y`,index:s}].sort((e,t)=>e.index-t.index),l=0,u=0,d=0,f=0;i.length,r.length;for(let e of c)if(e.char===`d`){let e=i.lastIndexOf(`d`)-i.indexOf(`d`)+1,t=r.substr(f,e);if(t.length===0)return null;l=parseInt(t,10),f+=t.length}else if(e.char===`m`){let e=i.lastIndexOf(`m`)-i.indexOf(`m`)+1,t=r.substr(f,e);if(t.length===0)return null;u=parseInt(t,10)-1,f+=t.length}else if(e.char===`y`){let e=i.lastIndexOf(`y`)-i.indexOf(`y`)+1,t=r.substr(f),n=Math.min(e,t.length),a=t.substr(0,n);if(a.length===0)return null;let o=parseInt(a,10);(n===2&&e===4||n===2&&e===2)&&(o=Math.floor(new Date().getFullYear()/100)*100+o),d=o,f+=n}let p=t.toLowerCase(),m=p.includes(`d`),h=p.includes(`m`);if(m||(l=1),h||(u=0),u<0||u>11||!d)return null;let g=new Date(d,u,l);return isNaN(g.getTime())||m&&g.getDate()!==l||g.getMonth()!==u||g.getFullYear()!==d?null:g}_formatDate(e,t){let n=e.getDate(),r=e.getMonth()+1,i=e.getFullYear(),a=t.toLowerCase(),o=t;return a.includes(`dd`)?o=o.replace(/dd/gi,String(n).padStart(2,`0`)):a.includes(`d`)&&(o=o.replace(/d/gi,String(n))),a.includes(`mm`)?o=o.replace(/mm/gi,String(r).padStart(2,`0`)):a.includes(`m`)&&(o=o.replace(/m/gi,String(r))),a.includes(`yyyy`)?o=o.replace(/yyyy/gi,String(i)):a.includes(`yy`)&&(o=o.replace(/yy/gi,String(i).substr(2))),o}_formatDatePhp(e,t){let n=e.getDate(),r=e.getMonth()+1,i=e.getFullYear(),a=[`Sunday`,`Monday`,`Tuesday`,`Wednesday`,`Thursday`,`Friday`,`Saturday`],o=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],s=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],c=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],l=(e,t=2)=>e.toString().padStart(t,`0`),u=e=>{let t=e%10,n=e%100;return t===1&&n!==11?`st`:t===2&&n!==12?`nd`:t===3&&n!==13?`rd`:`th`},d=``;for(let f=0;f<t.length;f++){let p=t[f];if(p===`\\`&&f+1<t.length){d+=t[f+1],f++;continue}switch(p){case`Y`:d+=i.toString();break;case`y`:d+=i.toString().slice(-2);break;case`m`:d+=l(r);break;case`n`:d+=r.toString();break;case`M`:d+=c[r-1];break;case`F`:d+=s[r-1];break;case`d`:d+=l(n);break;case`j`:d+=n.toString();break;case`D`:d+=o[e.getDay()];break;case`l`:d+=a[e.getDay()];break;case`S`:d+=u(n);break;default:d+=p;break}}return d}_validateDateString(e,t){let n=this._parseDateString(e,t);return n!==null&&!isNaN(n.getTime())}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.getValue(),i=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),s=this.getId(),c=this.getName(),l=this.getFormat(),u=this.hasError(),d=this.getErrorMessage(),f=this.getSelectionMode();this._isRange=this.isRange()||f===`week`||f===`month`,this._input||(this._input=document.createElement(`div`),this._input.className=`relative w-full`,this.appendChild(this._input));let p=this.querySelector(`.mint-date-picker-label-container`);if(t||n){p||(p=document.createElement(`div`),p.className=`mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]`,this.contains(this._input)?this.insertBefore(p,this._input):this.appendChild(p));let e=p.querySelector(`.mint-date-picker-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,p.insertBefore(e,p.firstChild)),e.textContent=t,s&&this._textInput&&e.setAttribute(`for`,s)):e&&e.remove();let r=p.querySelector(`.mint-date-picker-info`);n?(r||(r=document.createElement(`span`),r.className=`mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none`,p.appendChild(r)),r.textContent=n):r&&r.remove()}else p&&p.remove();this._hiddenInput||(this._hiddenInput=document.createElement(`input`),this._hiddenInput.type=`hidden`,this._hiddenInput.value=r||``,this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),s&&(this._hiddenInput.id=s),c&&(this._hiddenInput.name=c),this._hiddenInput.value=r||``,this._hiddenInput.setAttribute(`aria-invalid`,u?`true`:`false`);let m=this._input.querySelector(`.mint-date-fields`);m||(m=document.createElement(`div`),this._input.appendChild(m)),this._fieldsContainer=m,this._applyErrorVisuals(u,d,i),m.innerHTML=``,this._displayEl=document.createElement(`div`);let h=a?`select-text`:`select-none`;this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${a?`cursor-default`:`cursor-text`} ${h} focus:outline-none`,this._displayEl.tabIndex=i||a?-1:0,this._displayEl.addEventListener(`click`,()=>{i||a||this._enterInputMode()}),this._displayEl.addEventListener(`keydown`,e=>{i||a||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement(`div`),this._isRange,this._inputsWrapperEl.className=`flex items-center gap-1 w-full`;let g=this._getFormatTokens(l);this._startPartInputs=[],this._endPartInputs=[];let _=e=>{let t=document.createDocumentFragment();return g.forEach(n=>{if(n.type===`sep`){let e=document.createElement(`span`);e.textContent=n.value,e.className=`text-gray-400 dark:text-gray-500 select-none`,t.appendChild(e)}else{let r=n.part===`d`?`dd`:n.part===`m`?`mm`:n.len===2?`yy`:`yyyy`,s=this._createPartInput(n.len,r,i,a,o);e===`start`?this._startPartInputs.push(s):this._endPartInputs.push(s),t.appendChild(s)}}),t};if(this._isRange){let e=document.createElement(`div`);e.className=`flex items-center gap-1 flex-shrink-0`,e.appendChild(_(`start`)),this._inputsWrapperEl.appendChild(e);let t=document.createElement(`span`);t.textContent=` - `,t.className=`text-gray-400 dark:text-gray-500 select-none flex-shrink-0`,this._inputsWrapperEl.appendChild(t);let n=document.createElement(`div`);n.className=`flex items-center gap-1 flex-shrink-0`,n.appendChild(_(`end`)),this._inputsWrapperEl.appendChild(n)}else this._inputsWrapperEl.appendChild(_(`start`));let v=document.createElement(`div`);if(v.className=`flex flex-col w-full`,this._displayEl.style.display=this._isInputMode?`none`:`flex`,this._inputsWrapperEl.style.display=this._isInputMode?`flex`:`none`,v.appendChild(this._displayEl),v.appendChild(this._inputsWrapperEl),m.appendChild(v),this._isRange&&this._inputsWrapperEl&&this._setupContainerObserver(),m.addEventListener(`click`,()=>{this._isInputMode||i||a||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,g,m),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,g,m),this._parseValue(r),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=i||a,!i&&!a?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`;let e=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=e;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`calendar`),t.className=`w-4 h-4 pointer-events-none`,this._iconButton.appendChild(t),this._iconButton.addEventListener(`click`,()=>{i||a||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=i||a}this._renderErrorState(u,d),this._renderSkeleton(e)}_renderErrorState(e,t){let n=this.querySelector(`.mint-date-picker-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_applyErrorVisuals(e,t,n){if(this._renderErrorState(e,t),this._fieldsContainer){let t=this._getFieldContainerClass(e,n);this._fieldsContainer.className=t}this._hiddenInput&&this._hiddenInput.setAttribute(`aria-invalid`,e?`true`:`false`)}_attachFormResetListener(){let 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(e=>{e.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-mint-elevated dark:border dark:border-mint-divider text-gray-900 dark:text-white`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`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){let t=this.getFormat(),n=this.getSelectionMode(),r=this._isRange||n===`week`||n===`month`;if(!e){this.setValue(``),this._updateDisplayText();return}if(r){let[n,r]=this._splitRangeInput(e,t),i=n?this._parseDateString(n,t):null,a=r?this._parseDateString(r,t):null;if(i&&a){let[e,n]=i<=a?[i,a]:[a,i],r=`${this._formatDate(e,t)} - ${this._formatDate(n,t)}`;this.setValue(r),this._applyDateToParts(e,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(n,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=e,this._selectedEndDate=n,this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}else if(i){let e=this._formatDate(i,t);this.setValue(e),this._applyDateToParts(i,this._startPartInputs,this._getFormatTokens(t),t),this._applyDateToParts(null,this._endPartInputs,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._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(e,t)){let n=this._parseDateString(e,t);if(n){let e=this._formatDate(n,t);this.setValue(e),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(t),t),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.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}let t=this._iconButton.id;t&&this._iconButton.isConnected&&document.getElementById(t)?this._createPopover(t):e<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(e+1)})}_createPopover(e){if(e){if(!document.getElementById(e)){setTimeout(()=>{this._createPopover(e)},50);return}if(this._popover){if(this._popover.getAttribute(`trigger-id`)!==e){this._popover.setAttribute(`trigger-id`,e);let t=this._popover;typeof t._setupTrigger==`function`&&t._setupTrigger()}this._buildCalendar()}else{this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`direction`,`down`),this._popover.setAttribute(`padding`,`0`);let t=this.closest(`mint-modal`),n=this.closest(`mint-off-canvas`);t||n?document.body.appendChild(this._popover):this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute(`trigger-id`,e),this._popoverObserver||(this._popoverObserver=new MutationObserver(e=>{e.forEach(e=>{if(e.type===`attributes`&&e.attributeName===`open`)if(this._popover?.hasAttribute(`open`))requestAnimationFrame(()=>{this._buildCalendar();let e=this._popover;typeof e.render==`function`&&e.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{this._iconButton?.focus()}),this._viewMode=`calendar`,this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{let e=new Date;this._currentMonth=e.getMonth(),this._currentYear=e.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{let e=new FocusEvent(`blur`,{bubbles:!0,cancelable:!0,relatedTarget:null});this._hiddenInput?.dispatchEvent(e)},0))}})}),this._popoverObserver.observe(this._popover,{attributes:!0,attributeFilter:[`open`]})),requestAnimationFrame(()=>{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-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]`;let e=this.getMode();e===`month`&&this._viewMode===`calendar`?this._viewMode=`month`:e===`year`&&this._viewMode===`calendar`?this._viewMode=`year`:e===`default`&&this._viewMode!==`month`&&this._viewMode!==`year`&&(this._viewMode=`calendar`),this._viewMode===`calendar`?this._buildCalendarView():this._viewMode===`month`?this._buildMonthView():this._viewMode===`year`&&this._buildYearView();let t=this._popover.querySelector(`.popover-content`);if(t){for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;let e=this._getDaysInMonth(this._currentMonth,this._currentYear),t=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),n=[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],r=this.getWeekStartDay(),i=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],a=[...i.slice(r),...i.slice(0,r)],o=this.getShortcuts(),s=o.length>0;this._calendarContainer.className=s?`mint-date-calendar bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]`:`mint-date-calendar bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider rounded-lg p-4 w-[18rem] md:min-w-[18rem]`;let c=document.createElement(`div`);c.className=`flex flex-col md:flex-row md:gap-6 md:items-start`;let l=document.createElement(`div`);l.className=`flex-1 min-w-0`;let u=document.createElement(`div`);u.className=`flex items-center justify-between mb-4`;let d=document.createElement(`button`);d.type=`button`,d.tabIndex=0,d.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let f=document.createElement(`mint-icon`);f.setAttribute(`name`,`caret-left`),f.className=`w-4 h-4`,d.appendChild(f),d.addEventListener(`click`,()=>{let e=this._currentMonth,t=this._currentYear;this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}),u.appendChild(d);let p=document.createElement(`div`);p.className=`flex items-center gap-2`;let m=document.createElement(`button`);m.type=`button`,m.tabIndex=0,m.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,m.setAttribute(`data-keep-popover-open`,`true`),m.textContent=n[this._currentMonth];let h=()=>{let e=this.getMode();e!==`month`&&e!==`year`&&(this._viewMode=`month`,this._buildCalendar())};m.addEventListener(`click`,h),m.addEventListener(`touchend`,e=>{e.preventDefault(),h()},{passive:!1}),p.appendChild(m);let g=document.createElement(`button`);g.type=`button`,g.tabIndex=0,g.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 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`,g.setAttribute(`data-keep-popover-open`,`true`),g.textContent=String(this._currentYear),g.addEventListener(`click`,()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())}),p.appendChild(g),u.appendChild(p);let _=document.createElement(`button`);_.type=`button`,_.tabIndex=0,_.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,_.setAttribute(`data-keep-popover-open`,`true`);let v=document.createElement(`mint-icon`);v.setAttribute(`name`,`caret-right`),v.className=`w-4 h-4`,_.appendChild(v);let y=()=>{let e=this._currentMonth,t=this._currentYear;this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};_.addEventListener(`click`,y),_.addEventListener(`touchend`,e=>{e.preventDefault(),y()},{passive:!1}),u.appendChild(_);let b=document.createElement(`div`);b.className=`grid grid-cols-7 mb-2`,a.forEach(e=>{let t=document.createElement(`div`);t.className=`text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1`,t.textContent=e,b.appendChild(t)});let x=document.createElement(`div`);x.className=`grid grid-cols-7`;let S=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,C=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;this.getDisabledDates();let w=this._currentMonth===0?11:this._currentMonth-1,T=this._currentMonth===0?this._currentYear-1:this._currentYear,E=this._getDaysInMonth(w,T),D=this._currentMonth===11?0:this._currentMonth+1,O=this._currentMonth===11?this._currentYear+1:this._currentYear,k=t+e,A=Math.ceil(k/7)*7-k,j=(e,t,n)=>{let r=this._isToday(e),i=this._isDateSelected(e),a=this._isDateInRange(e),o=S&&e<S||C&&e>C||this._isDateDisabled(e),s=`rounded-md`,c=this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate,l=c&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._selectedStartDate:c&&this._hoveredDate?this._hoveredDate:null,u=c&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._hoveredDate:c&&this._selectedStartDate?this._selectedStartDate:null,d=l!==null&&this._isSameDate(e,l),f=u!==null&&this._isSameDate(e,u),p=this._hoveredDate!==null&&this._isSameDate(e,this._hoveredDate),m=c&&this._hoveredDate&&this._selectedStartDate?!this._rangeIncludesDisabledDates(this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate):!1;if(this._isRange&&this._selectedStartDate&&this._selectedEndDate){let t=this._isSameDate(e,this._selectedStartDate),n=this._isSameDate(e,this._selectedEndDate);t&&n?s=`rounded-md`:t?s=`rounded-l-md`:n?s=`rounded-r-md`:a&&(s=`rounded-none`)}else c&&(d||f)&&m?d&&f?s=`rounded-md`:d?s=`rounded-l-md`:f&&(s=`rounded-r-md`):i&&!this._isRange||i&&this._isRange&&!this._selectedEndDate?s=`rounded-md`:a&&c&&m&&(s=`rounded-none`);let h=document.createElement(`button`);h.type=`button`,h.disabled=!!o,h.tabIndex=o?-1:0;let g=`w-full h-8 ${s} border-0 text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,_=i||c&&p&&m;return n?g+=_?` bg-slate-800 dark:bg-slate-600 text-white`:a?` bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200`:r?` text-gray-900 dark:text-gray-100 font-semibold`:` text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`:g+=_?` bg-slate-800 dark:bg-slate-600 text-white`:a?` bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200`:` text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-mint-hover`,g+=o?` opacity-40 cursor-not-allowed`:``,h.className=g,h.textContent=t.toString(),o||(h.addEventListener(`click`,t=>{t.preventDefault(),t.stopPropagation(),this._handleDateClick(e)}),h.addEventListener(`touchstart`,t=>{t.preventDefault(),t.stopPropagation(),this._isTouchActive=!0,this._touchStartDate=e,this._touchStartElement=h,h.classList.add(`active`,`bg-gray-200`,`dark:bg-gray-600`)},{passive:!1}),h.addEventListener(`touchend`,t=>{t.preventDefault(),t.stopPropagation(),this._isTouchActive&&this._touchStartDate&&this._isSameDate(this._touchStartDate,e)&&this._handleDateClick(e),this._touchStartElement&&this._touchStartElement.classList.remove(`active`,`bg-gray-200`,`dark:bg-gray-600`),this._isTouchActive=!1,this._touchStartDate=null,this._touchStartElement=null},{passive:!1}),h.addEventListener(`touchcancel`,()=>{this._touchStartElement&&this._touchStartElement.classList.remove(`active`,`bg-gray-200`,`dark:bg-gray-600`),this._isTouchActive=!1,this._touchStartDate=null,this._touchStartElement=null}),this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&!o&&(h.addEventListener(`mouseenter`,()=>{this._isHandlingClick||this._isTouchActive||this._isDateDisabled(e)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,e))&&(this._hoveredDate=e,this._buildCalendar())}),h.addEventListener(`touchmove`,e=>{if(!this._isTouchActive||!this._touchStartDate)return;let t=e.touches[0],n=document.elementFromPoint(t.clientX,t.clientY);for(;n&&!n.classList.contains(`mint-date-picker-day`);)n=n.parentElement;if(n&&n!==h){let e=n.getAttribute(`data-date`);if(e){let t=new Date(e);this._isDateDisabled(t)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,t))&&(this._hoveredDate=t,this._buildCalendar())}}},{passive:!0}))),h};for(let e=t-1;e>=0;e--){let t=E-e,n=j(new Date(T,w,t),t,!1);x.appendChild(n)}for(let t=1;t<=e;t++){let e=j(new Date(this._currentYear,this._currentMonth,t),t,!0);x.appendChild(e)}for(let e=1;e<=A;e++){let t=j(new Date(O,D,e),e,!1);x.appendChild(t)}if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&(x.addEventListener(`mouseleave`,()=>{this._isTouchActive||(this._hoveredDate=null,this._buildCalendar())}),x.addEventListener(`touchend`,e=>{let t=e.changedTouches[0],n=document.elementFromPoint(t.clientX,t.clientY);n&&!x.contains(n)&&(this._hoveredDate=null,this._buildCalendar())},{passive:!0})),s){let e=document.createElement(`div`);e.className=`mb-4 pb-4 border-b border-gray-200 dark:border-mint-divider md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-mint-divider md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col`;let t=document.createElement(`div`);t.className=`relative md:relative md:flex-1 md:min-h-0`;let n=document.createElement(`div`);n.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`,n.style.scrollbarWidth=`none`,n.style.msOverflowStyle=`none`,n.style.setProperty(`-webkit-overflow-scrolling`,`touch`);let r=document.createElement(`style`);r.textContent=`
|
|
59
59
|
.mint-date-shortcuts-row::-webkit-scrollbar {
|
|
60
60
|
display: none;
|
|
61
61
|
}
|
|
@@ -79,8 +79,8 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
79
79
|
background: rgba(255, 255, 255, 0.2);
|
|
80
80
|
}
|
|
81
81
|
}
|
|
82
|
-
`,n.classList.add(`mint-date-shortcuts-row`),document.head.querySelector(`style[data-mint-date-shortcuts]`)||(r.setAttribute(`data-mint-date-shortcuts`,`true`),document.head.appendChild(r));let i=document.createElement(`div`);i.className=`absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-mint-elevated to-transparent opacity-0 md:hidden`,t.appendChild(i);let 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-mint-elevated to-transparent opacity-100 md:hidden`,t.appendChild(a);let s=document.createElement(`div`);s.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-mint-elevated to-transparent opacity-0`,t.appendChild(s);let l=document.createElement(`div`);l.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-mint-elevated to-transparent opacity-100`,t.appendChild(l);let u=()=>{if(window.innerWidth>=768){let e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;e>0?s.style.opacity=`1`:s.style.opacity=`0`,e+r<t-1?l.style.opacity=`1`:l.style.opacity=`0`,i.style.opacity=`0`,a.style.opacity=`0`}else{let e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;e>0?i.style.opacity=`1`:i.style.opacity=`0`,e+r<t-1?a.style.opacity=`1`:a.style.opacity=`0`,s.style.opacity=`0`,l.style.opacity=`0`}};n.addEventListener(`scroll`,u),window.addEventListener(`resize`,u),setTimeout(u,0),o.forEach(e=>{let t=document.createElement(`button`);t.type=`button`,t.tabIndex=0,t.className=`px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-mint-hover text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-mint-elevated 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`,t.textContent=e.label,t.setAttribute(`data-keep-popover-open`,`true`);let r=()=>{let t=e.action();if(t){if(this._isRange&&`start`in t&&`end`in t){this._selectedStartDate=t.start,this._selectedEndDate=t.end;let e=this.getFormat(),n=`${this._formatDate(t.start,e)} - ${this._formatDate(t.end,e)}`;this.setValue(n),this._currentMonth=t.start.getMonth(),this._currentYear=t.start.getFullYear()}else if(t instanceof Date){this._selectedStartDate=t,this._selectedEndDate=null;let e=this.getFormat(),n=this._formatDate(t,e);this.setValue(n),this._currentMonth=t.getMonth(),this._currentYear=t.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}))}};t.addEventListener(`click`,r),t.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),n.appendChild(t)}),t.appendChild(n),e.appendChild(t),c.appendChild(e)}l.appendChild(u),l.appendChild(b),l.appendChild(x),c.appendChild(l),this._calendarContainer.appendChild(c)}_buildMonthView(){if(!this._calendarContainer)return;let 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`;let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let r=document.createElement(`mint-icon`);r.setAttribute(`name`,`caret-left`),r.className=`w-4 h-4`,n.appendChild(r);let i=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};n.addEventListener(`click`,i),n.addEventListener(`touchend`,e=>{e.preventDefault(),i()},{passive:!1}),t.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.tabIndex=0,a.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer 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`,a.setAttribute(`data-keep-popover-open`,`true`),a.textContent=String(this._currentYear);let o=()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())};a.addEventListener(`click`,o),a.addEventListener(`touchend`,e=>{e.preventDefault(),o()},{passive:!1}),t.appendChild(a);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),t.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`,e.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.setAttribute(`data-keep-popover-open`,`true`),n.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentMonth===t?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,n.textContent=e;let r=()=>{if(this.getMode()===`month`){let e=new Date(this._currentYear,t,1),n=this.getFormat(),r=this._formatDate(e,n);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentMonth=t,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else{let e=this._currentMonth,n=this._currentYear;this._currentMonth=t,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,n,this._currentMonth,this._currentYear)}};n.addEventListener(`click`,r),n.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),u.appendChild(n)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(u)}_buildYearView(){if(!this._calendarContainer)return;let e=this._currentYear-6,t=this._currentYear+6,n=document.createElement(`div`);n.className=`flex items-center justify-between mb-4`;let r=document.createElement(`button`);r.type=`button`,r.tabIndex=0,r.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,r.setAttribute(`data-keep-popover-open`,`true`);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`caret-left`),i.className=`w-4 h-4`,r.appendChild(i);let a=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear-=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};r.addEventListener(`click`,a),r.addEventListener(`touchend`,e=>{e.preventDefault(),a()},{passive:!1}),n.appendChild(r);let o=document.createElement(`div`);o.className=`text-sm font-medium text-gray-900 dark:text-gray-100`,o.textContent=`${e} - ${t}`,n.appendChild(o);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear+=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),n.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`;for(let n=e;n<=t;n++){let e=document.createElement(`button`);e.type=`button`,e.tabIndex=0,e.setAttribute(`data-keep-popover-open`,`true`),e.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentYear===n?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,e.textContent=String(n),e.addEventListener(`click`,()=>{let e=this.getMode();if(e===`year`){let e=new Date(n,0,1),t=this.getFormat(),r=this._formatDate(e,t);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentYear=n,this._currentMonth=0,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(e===`month`){let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`month`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}else{let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}}),u.appendChild(e)}this._calendarContainer.appendChild(n),this._calendarContainer.appendChild(u)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){let n=this.getWeekStartDay(),r=new Date(t,e,1).getDay();return r>=n?r-n:7-(n-r)}_isToday(e){let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){let t=this.getSelectionMode();return this._isRange||t===`week`||t===`month`?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(e,this._selectedStartDate)||this._isSameDate(e,this._selectedEndDate):this._isRange&&this._selectedStartDate&&!this._selectedEndDate?this._isSameDate(e,this._selectedStartDate):!1:this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){let t=this.getSelectionMode();if((this._isRange||t===`week`||t===`month`)&&this._selectedStartDate&&this._selectedEndDate)return this._rangeIncludesDisabledDates(this._selectedStartDate,this._selectedEndDate)?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate;if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate){let t=this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,n=this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate;if(this._rangeIncludesDisabledDates(t,n)){let r=this._findFirstDisabledDateInRange(t,n);return r?this._selectedStartDate<this._hoveredDate?e>=t&&e<r&&!this._isSameDate(e,t):e>r&&e<=n&&!this._isSameDate(e,n):!1}return e>=t&&e<=n&&!this._isSameDate(e,t)&&!this._isSameDate(e,n)}return!1}_rangeIncludesDisabledDates(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate());return n.some(e=>{let t=new Date(e.getFullYear(),e.getMonth(),e.getDate());return t>=r&&t<=i})}_findFirstDisabledDateInRange(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=n.map(e=>new Date(e.getFullYear(),e.getMonth(),e.getDate())).filter(e=>e>=r&&e<=i).sort((e,t)=>e.getTime()-t.getTime());return a.length>0?a[0]:null}_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()}_isDateDisabled(e){return this.getDisabledDates().some(t=>this._isSameDate(e,t))}_dispatchMonthChangeEvent(e,t,n,r){(e!==n||t!==r)&&this.dispatchEvent(new CustomEvent(`month-change`,{detail:{month:n,year:r,oldMonth:e,oldYear:t},bubbles:!0,cancelable:!0,composed:!0}))}_dispatchDateChangeEvent(){let e=this.getFormat(),t={value:this.getValue()};this._selectedStartDate&&(t.startDate=this._selectedStartDate,t.startDateFormatted=this._formatDate(this._selectedStartDate,e)),this._selectedEndDate&&(t.endDate=this._selectedEndDate,t.endDateFormatted=this._formatDate(this._selectedEndDate,e)),this.dispatchEvent(new CustomEvent(`date-change`,{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_setupContainerObserver(){if(this._resizeObserver&&=(this._resizeObserver.disconnect(),null),!this._inputsWrapperEl)return;let e=e=>{this._inputsWrapperEl&&(e<400?(this._inputsWrapperEl.classList.add(`flex-wrap`),this._inputsWrapperEl.classList.remove(`flex-nowrap`)):(this._inputsWrapperEl.classList.remove(`flex-wrap`),this._inputsWrapperEl.classList.add(`flex-nowrap`)))};e(this._inputsWrapperEl.offsetWidth||this.offsetWidth),this._resizeObserver=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect.width;e(t)}}),this._resizeObserver.observe(this)}_getWeekStart(e){let t=this.getWeekStartDay(),n=e.getDay(),r;r=n>=t?n-t:7-(t-n);let i=new Date(e);return i.setDate(e.getDate()-r),i.setHours(0,0,0,0),i}_getWeekEnd(e){let t=this._getWeekStart(e),n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),n}_getMonthStart(e){let t=new Date(e.getFullYear(),e.getMonth(),1);return t.setHours(0,0,0,0),t}_getMonthEnd(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t}_handleDateClick(e){this._isHandlingClick=!0;try{let t=this.getFormat(),n=this.getSelectionMode(),r,i;if(n===`week`?(r=this._getWeekStart(e),i=this._getWeekEnd(e)):n===`month`?(r=this._getMonthStart(e),i=this._getMonthEnd(e)):(r=e,i=e),this.isRange()||n===`week`||n===`month`)if(n===`week`||n===`month`){if(this._rangeIncludesDisabledDates(r,i)){this._buildCalendar();return}this._selectedStartDate=r,this._selectedEndDate=i;let e=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(this._hoveredDate=null,this._selectedStartDate===null){if(this._isDateDisabled(r)){this._buildCalendar();return}this._selectedStartDate=new Date(r.getFullYear(),r.getMonth(),r.getDate()),this._selectedEndDate=null,this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear(),this._hoveredDate=null,this._buildCalendar()}else if(this._selectedEndDate===null){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=this._selectedStartDate?new Date(this._selectedStartDate.getFullYear(),this._selectedStartDate.getMonth(),this._selectedStartDate.getDate()):null,i,a;if(r&&n<r?(i=n,a=r):(i=r,a=n),this._rangeIncludesDisabledDates(i,a)){this._buildCalendar();return}r&&n<r?(this._selectedEndDate=r,this._selectedStartDate=n):(this._selectedEndDate=n,r&&(this._selectedStartDate=r)),this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();let o=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setAttribute(`value`,o),this._textInput&&(this._textInput.value=o),this._hiddenInput&&(this._hiddenInput.value=o),this._updateDisplayText(),this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else this._selectedStartDate=r,this._selectedEndDate=null;else{this._selectedStartDate=r,this._selectedEndDate=null;let e=this._formatDate(r,t);this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this._dispatchDateChangeEvent()}finally{this._isHandlingClick=!1}}_updateDisplayText(){if(!this._displayEl)return;let e=this.getDisplayFormat(),t=this.getSelectionMode(),n=this._isRange||t===`week`||t===`month`,r=``;n&&this._selectedStartDate&&this._selectedEndDate?r=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(r=this._formatDatePhp(this._selectedStartDate,e)),r?(this._displayEl.textContent=r,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)){let 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`),n=this._fieldsContainer,r=this._input;if(e){t||(t=document.createElement(`div`),t.className=`mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none`,r?(r.classList.contains(`relative`)||r.classList.add(`relative`),r.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-date-picker-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.height=`2.25rem`,t.appendChild(e)),t.style.display=`block`,n&&(n.style.visibility=`hidden`,n.style.pointerEvents=`none`),this._displayEl&&(this._displayEl.style.visibility=`hidden`,this._displayEl.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),n&&(n.style.visibility=`visible`,n.style.pointerEvents=`auto`),this._displayEl&&(this._displayEl.style.visibility=`visible`,this._displayEl.style.pointerEvents=`auto`)}_getFocusableElements(){if(!this._calendarContainer)return[];let 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(e=>{let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute(`open`))return;this._removeFocusTrap();let e=this;this._focusTrapHandler=function(t){if(t.key!==`Tab`)return;if(!e._popover||!e._popover.hasAttribute(`open`)){e._removeFocusTrap();return}let n=e._getFocusableElements();if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!e._calendarContainer?.contains(a)){t.preventDefault(),r.focus();return}if(t.shiftKey&&a===r){t.preventDefault(),i.focus();return}if(!t.shiftKey&&a===i){t.preventDefault(),r.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(()=>{let e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&=(document.removeEventListener(`keydown`,this._focusTrapHandler,!0),null),this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler,!0),null)}};customElements.get(`mint-date-picker`)||customElements.define(`mint-date-picker`,v);var y=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`,`w-full`),this.getLabel()||console.error(`mint-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(e=>{let t=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),n=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return t||n})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null)}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){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=n||``);return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){let t=e||``;this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isMultiple(){return this.getAttribute(`multiple`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){let e=this.hasError(),t=this.isMultiple(),n=[`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-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`appearance-none`,`bg-no-repeat`,`bg-right`,`cursor-pointer`],r=[`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],i=[`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[...n,...r,...i].filter(Boolean).join(` `)}render(){let e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&t.push(e.cloneNode(!0))});let n=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;let r=this.getLabel(),i=this.getInfo(),a=this.getId(),o=this.getName(),s=this.getValue(),c=this.isDisabled(),l=this.isMultiple(),u=this.hasError();if(r){let e=document.createElement(`label`);e.className=`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,a&&e.setAttribute(`for`,a);let t=document.createTextNode(r);e.appendChild(t),this.appendChild(e)}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(),a&&(this._select.id=a),o&&(this._select.name=o),c&&(this._select.disabled=!0),l&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,u?`true`:`false`);let d=n.length>0?n:t;if(d.length>0&&d.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(this._select.value=s||``,this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target.value;(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),l)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.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]`,e.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]`,e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(i){let e=document.createElement(`div`);e.className=`mt-1 text-xs text-gray-500 dark:text-gray-400`,e.textContent=i,this.appendChild(e)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-select-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this.isMultiple();e.style.height=n?`6rem`:`2.25rem`,t.appendChild(e)}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(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-select-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-select-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-select`)||customElements.define(`mint-select`,y);var b=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`]}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}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){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){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.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-dropzone-skeleton`);if(e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-mint-divider bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.width=`100%`,e.style.height=`100%`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`hidden`,t.style.pointerEvents=`none`}if(t){let e=t;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}if(r){let e=r;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`),n.style.pointerEvents=`none`}}else if(t&&(t.style.display=`none`),n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`visible`,t.style.pointerEvents=`auto`}if(t){let e=t;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}if(r){let e=r;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`),n.style.pointerEvents=`auto`}}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i?(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=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=a,this._dropzone.style.minHeight=o,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=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`);let u=this._dropzone.querySelector(`.mint-dropzone-icon`),d=this._dropzone.querySelector(`.mint-dropzone-label`);u&&u.remove(),d&&d.remove();let f=document.createElement(`div`);f.className=`mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0`;let p=document.createElement(`mint-icon`);if(p.setAttribute(`name`,`upload`),p.className=`w-12 h-12 text-gray-400 dark:text-gray-500`,f.appendChild(p),this._dropzone.appendChild(f),t){let e=document.createElement(`div`);e.className=`mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0`,e.textContent=t,this._dropzone.appendChild(e)}this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError(),n=`relative border-2 border-dashed rounded-lg flex flex-col items-center ${this._selectedFiles.length>0?`justify-start`:`justify-center`} cursor-pointer overflow-hidden`,r=this._isDragging?`border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-mint-elevated dark:border-mint-divider`:`border-gray-300 dark:border-mint-divider bg-white dark:bg-mint-elevated dark:border-mint-divider hover:border-gray-400 dark:hover:border-mint-divider`,i=t?`border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30`:``,a=e?`opacity-40 cursor-not-allowed`:``;this._dropzone.className=`${n} ${t?i:r} ${a} focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.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||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`focus-visible:ring-2`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.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}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48`;let 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((e,n)=>{let r=document.createElement(`div`);if(r.className=`flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-mint-divider bg-gray-50 dark:bg-mint-elevated`,e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`w-12 h-12 object-cover rounded border border-gray-200 dark:border-mint-divider`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,r.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`w-5 h-5 text-gray-500 dark:text-gray-300`,r.appendChild(e)}let i=document.createElement(`div`);i.className=`flex-1 text-sm text-gray-800 dark:text-gray-100 truncate`,i.textContent=e.name,r.appendChild(i);let a=document.createElement(`button`);a.type=`button`,a.className=`text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 flex items-center justify-center w-6 h-6 rounded-full`;let o=document.createElement(`mint-icon`);o.setAttribute(`name`,`close`),o.className=`w-4 h-4`,a.appendChild(o),a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),r.appendChild(a),t.appendChild(r)});let n=this.hasError(),r=this._isDragging,i=`from-white dark:from-mint-elevated`;n?i=`from-red-50 dark:from-red-900/30`:r&&(i=`from-gray-50 dark:from-mint-elevated`);let a=document.createElement(`div`);a.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${i} to-transparent opacity-0`,e.appendChild(a);let o=document.createElement(`div`);o.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${i} to-transparent opacity-100`,e.appendChild(o);let s=()=>{let e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;e>0?a.style.opacity=`1`:a.style.opacity=`0`,e+r<n-1?o.style.opacity=`1`:o.style.opacity=`0`};s(),t.addEventListener(`scroll`,s),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[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(){let 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()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t)}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`,b);var x=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupReactiveDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(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;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getReactiveValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}if(!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let i=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i),i.form=this;let a=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(a.form=this,this.dispatchEvent(a),i.defaultPrevented||a.defaultPrevented)return;let o=this.getAttribute(`action`),s=this.getAttribute(`method`);if(!(!o||!s)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){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`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?(n.checked===void 0?n.hasAttribute(`checked`):n.checked)?n.getAttribute(`value`)||`on`:``:n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let 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`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_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;let e=this._getReactiveValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=()=>{Object.entries(e).forEach(([e,t])=>{let n=this._getFieldElements(e);if(n.length===0){setTimeout(()=>{let n=this._getFieldElements(e);n.length>0&&this._applyValueToField(n,e,t)},300);return}this._applyValueToField(n,e,t)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-SELECT`||r===`SELECT`)r===`SELECT`?e.closest(`mint-select`)?.setValue(n||``):typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n||``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)Array.isArray(n)&&e.tags!==void 0&&(e.tags=n.map(e=>typeof e==`string`?{value:e,label:e,dismissable:!0}:e));else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let 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.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.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}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getReactiveValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i),this._lastDataSnapshot=this._createDataSnapshot(n)}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let 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)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,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(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;let 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(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=this._buttonStates.get(e);t&&(t.disabled?e.setAttribute(`disabled`,`true`):e.removeAttribute(`disabled`),t.loading?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=this._buttonStates.get(e);t&&(e.disabled=t.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;if(`__v_isRef`in e||`_value`in e||`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e)return!0;try{let t=e.toString();if(t===`[object Object]`||t.includes(`Proxy`)){let t=Object.keys(e)[0];if(t){let n=Object.getOwnPropertyDescriptor(e,t);if(n&&(n.get||n.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupReactiveDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getReactiveValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}};customElements.get(`mint-form`)||customElements.define(`mint-form`,x),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));var S=class extends HTMLElement{constructor(...e){super(...e),this._observer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`align-baseline`,`block`,`w-full`,`rounded-lg`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasAttribute(`data-mint-rt-scroll-inner`)?this.classList.add(`min-w-0`,`overflow-x-visible`,`overflow-y-visible`):this.classList.add(`min-w-0`,`overflow-x-auto`),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&=(this._observer.disconnect(),null)}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();let e=Array.from(this.querySelectorAll(`table`));if(e.length===0){this._observer&&this._observeChanges();return}let t=e.find(e=>e.querySelector(`thead`))??e[0],n=e.find(e=>e.querySelector(`tbody`))??e[0];e.forEach(e=>{let t=!!e.closest(`[id^="mint-rt-vscroll-"]`),n=!!e.closest(`mint-resource-table[data-mint-rt-fixed-header]`),r=t||n,i=[`w-full`,r?`border-separate border-spacing-0`:`border-collapse`,`text-sm`,`font-medium`,...r?[]:[`overflow-hidden`]];this._setClasses(e,i)});let r=t.querySelector(`thead`);if(r){r.classList.add(`bg-[#F7F7F7]`,`dark:bg-mint-nav`);let e=r.querySelectorAll(`th`);e.forEach((t,n)=>{let r=t.querySelector(`mint-icon`),i=r?.getAttribute(`name`)||``,a=t.hasAttribute(`data-mint-rt-sortable`)||r!==null&&i!==`ellipsis`;this._setClasses(t,[`text-left`,`font-semibold`,`text-gray-900`,`dark:text-white`,`px-3`,`py-2`,`border-b`,`border-gray-200`,`dark:border-mint-divider`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`]),a&&t.classList.add(`cursor-pointer`,`hover:bg-gray-100`,`dark:hover:bg-mint-hover`),n===0&&t.classList.add(`pl-3`),n===e.length-1&&t.classList.add(`pr-3`);let o=t.closest(`table`),s=o?.closest(`mint-resource-table`),c=!!s?.hasAttribute(`data-mint-rt-fixed-header`),l=!!s?.hasAttribute(`data-mint-rt-fixed-controls`);if(o?.closest(`[id^="mint-rt-vscroll-"]`)||c){let e=c&&l?`top-[var(--mint-rt-fixed-controls-h,0px)]`:`top-0`;t.classList.add(`sticky`,e,`z-30`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`shadow-sm`)}})}let i=n.querySelector(`tbody`);if(i){let e=Array.from(i.querySelectorAll(`tr`)),t=!!n.closest(`[id^="mint-rt-vscroll-"]`)||!!n.closest(`mint-resource-table`)?.hasAttribute(`data-mint-rt-fixed-header`),r=e.findIndex(e=>e.getAttribute(`data-mint-rt-spacer`)===`bottom`);e.forEach((n,i)=>{let a=n.hasAttribute(`data-mint-rt-spacer`),o=n.hasAttribute(`data-row-clickable`);a||t?this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`]):this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`,`border-b`,`border-gray-200`,`dark:border-mint-divider`]),o&&!a&&n.classList.add(`cursor-pointer`,`hover:bg-gray-50`,`dark:hover:bg-mint-elevated`),!t&&i===e.length-1&&n.classList.remove(`border-b`);let s=n.querySelectorAll(`td`);s.forEach((o,c)=>{let l=[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`];if(t&&!a){let t=n.hasAttribute(`data-mint-rt-last-row`),a=r===-1&&i===e.length-1;!t&&!a&&l.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`)}this._setClasses(o,l),c===0&&o.classList.add(`pl-3`),c===s.length-1&&o.classList.add(`pr-3`),this._restoreCell(o)})})}let a=n.querySelector(`tfoot`);a&&(this._setClasses(a,[`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`font-semibold`]),a.querySelectorAll(`td`).forEach(e=>{this._setClasses(e,[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`,`border-t`,`border-gray-200`,`dark:border-mint-divider`]),this._restoreCell(e)})),this._observer&&this._observeChanges()}_restoreCell(e){if(e.dataset.mtProcessed!==`true`)return;let t={};Array.from(e.attributes).forEach(e=>{e.name.startsWith(`data-`)&&e.name!==`data-original`&&e.name!==`data-mt-processed`&&(t[e.name]=e.value)});let n=e.getAttribute(`data-original`)||``;e.dataset.mtProcessed=``,e.innerHTML=n,Object.entries(t).forEach(([t,n])=>{e.setAttribute(t,n)})}_setClasses(e,t){e.className=``,t.filter(Boolean).forEach(t=>e.classList.add(...t.split(` `)))}};customElements.get(`mint-table`)||customElements.define(`mint-table`,S);var C=class extends HTMLElement{constructor(...e){super(...e),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return[`dismissable`]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener(`click`,this._clickHandler)}attributeChangedCallback(){this._render()}_render(){if(this.classList.add(`inline-flex`,`items-center`,`gap-2`,`px-3`,`py-1`,`rounded-full`,`border`,`border-gray-200`,`dark:border-mint-divider`,`bg-gray-100`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-gray-100`,`text-sm`,`font-medium`),!this._root){for(this._root=document.createElement(`div`),this._root.className=`flex items-center gap-2 w-full`,this._textWrap=document.createElement(`span`),this._textWrap.className=`inline-flex items-center min-w-[0.5rem]`,this._textWrap.setAttribute(`data-mt-chip-text`,``);this.firstChild;){let e=this.firstChild;if(e===this._root)break;this._textWrap.appendChild(e)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}let e=this.getAttribute(`dismissable`);e===``||e===`true`||this.hasAttribute(`dismissable`)?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&this._root?.appendChild(this._dismissBtn)):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){let e=document.createElement(`button`);e.type=`button`,e.setAttribute(`aria-label`,`Dismiss`),e.className=[`shrink-0`,`inline-flex`,`items-center`,`justify-center`,`w-5`,`h-5`,`rounded-full`,`text-gray-500`,`dark:text-gray-300`,`hover:text-gray-700`,`dark:hover:text-gray-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`border-none`,`bg-transparent`,`cursor-pointer`].join(` `);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`close`),t.className=`w-3 h-3`,e.appendChild(t),this._clickHandler=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismiss`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},e.addEventListener(`click`,this._clickHandler),this._dismissBtn=e}};customElements.get(`mint-chip`)||customElements.define(`mint-chip`,C);var w=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder=`Add tag`,this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return[`tags`,`placeholder`,`sortable`,`label`,`info`,`error`,`error-message`,`name`,`id`,`required`,`loading`]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=e=>this._onPointerMove(e),window.addEventListener(`pointermove`,this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=e=>this._onPointerUp(e),window.addEventListener(`pointerup`,this._pointerUpHandler),window.addEventListener(`pointercancel`,this._pointerUpHandler))}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){if(this._renderErrorState(),this._container){let e=this.hasError(),t=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1.5`,`min-h-[2rem]`,`rounded-lg`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`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`];this._container.className=t.join(` `)}return}if(e===`loading`){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(e){this._tags=Array.isArray(e)?[...e]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){let e=this.getAttribute(`tags`);if(!e)return;try{let t=JSON.parse(e);Array.isArray(t)&&(this._tags=t)}catch(e){console.warn(`mint-tags: failed to parse tags attribute`,e)}let t=this.getAttribute(`placeholder`);t!==null&&(this._placeholder=t)}_syncAttr(){this.setAttribute(`tags`,JSON.stringify(this._tags))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getName(){return this.getAttribute(`name`)||``}getId(){return this.getAttribute(`id`)||``}isRequired(){return this.getAttribute(`required`)===`true`}isLoading(){return this.hasAttribute(`loading`)}_render(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.hasError(),i=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute(`id`,i),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement(`div`);let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `),this._chipsWrap=document.createElement(`div`),this._chipsWrap.className=`flex flex-wrap items-center gap-2`,this._chipsWrap.addEventListener(`dragover`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._chipsWrap.addEventListener(`drop`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._input=document.createElement(`input`),this._input.type=`text`,this._input.placeholder=this._placeholder,this._input.className=[`min-w-[6rem]`,`flex-1`,`bg-transparent`,`border-none`,`outline-none`,`text-sm`,`text-gray-900`,`dark:text-gray-100`,`placeholder:text-gray-400`,`dark:placeholder:text-gray-500`,`p-1.5`].join(` `),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `)}let a=this.querySelector(`.mint-tags-label-container`);if(t){a||(a=document.createElement(`div`),a.className=`mint-tags-label-container mb-[.25rem]`,this._container&&this._container.parentElement===this?this.insertBefore(a,this._container):this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-tags-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.appendChild(e)),e.textContent=t,e.setAttribute(`for`,i)):e&&e.remove()}else a&&a.remove();let o=this.querySelector(`.mint-tags-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,this._container&&this._container.parentElement===this?this.insertBefore(o,this._container.nextSibling):this.appendChild(o)),o.textContent=n):o&&o.remove();let s=this.getName();s?(this.setAttribute(`name`,s),this._input&&(this._input.name=s,this._input.id=i)):(this.removeAttribute(`name`),this._input&&(this._input.removeAttribute(`name`),this._input.id=i)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this._container;if(!t)return;t.classList.contains(`relative`)||t.classList.add(`relative`);let n=t.querySelector(`.mint-tags-skeleton`);e?(n||(n=document.createElement(`div`),n.className=`mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(n)),n.style.display=`block`,this._chipsWrap&&(this._chipsWrap.style.visibility=`hidden`,this._chipsWrap.style.pointerEvents=`none`),this._input&&(this._input.style.visibility=`hidden`,this._input.style.pointerEvents=`none`)):(n&&(n.style.display=`none`),this._chipsWrap&&(this._chipsWrap.style.visibility=`visible`,this._chipsWrap.style.pointerEvents=`auto`),this._input&&(this._input.style.visibility=`visible`,this._input.style.pointerEvents=`auto`))}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-tags-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML=``;let e=0;this._tags.forEach(t=>{let n=document.createElement(`mint-chip`);n.dataset.index=String(e++),n.dataset.value=t.value,n.draggable=this.hasAttribute(`sortable`),n.draggable&&n.classList.add(`cursor-move`),t.dismissable&&(n.setAttribute(`dismissable`,`true`),n.addEventListener(`dismissed`,()=>this._removeTag(t.value))),this._chipsWrap.appendChild(n);let r=n.querySelector(`[data-mt-chip-text]`);r&&(r.textContent=t.label||t.value),this._setupChipEvents(n,t),n.draggable&&(n.addEventListener(`dragstart`,e=>this._onDragStart(e,n)),n.addEventListener(`dragover`,e=>this._onDragOverChip(e,n)),n.addEventListener(`drop`,e=>this._onDrop(e)),n.addEventListener(`dragend`,()=>this._onDragEnd())),this.hasAttribute(`sortable`)&&n.addEventListener(`pointerdown`,e=>this._onPointerDown(e,n))}),this._input&&(this.hasAttribute(`sortable`)&&(this._input.addEventListener(`dragover`,e=>this._onDragOverInput(e)),this._input.addEventListener(`drop`,e=>this._onDrop(e)),this._input.addEventListener(`dragend`,()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;let e=this._input.value.trim();if(e){if(this._tags.some(t=>t.value.toLowerCase()===e.toLowerCase())){this._input.value=``;return}this._tags.push({value:e,label:e,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value=``,setTimeout(()=>{this._input?.focus()},10)}}_removeTag(e){this._tags=this._tags.filter(t=>t.value!==e),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`tags-change`,{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){let e=this._chipsWrap?.querySelectorAll(`mint-chip`);e&&e.length>0&&e[e.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{this._input?.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener(`keydown`,e=>{e.key===`Backspace`&&this._input?.value===``&&(e.preventDefault(),this._focusLastChip())})}_setupChipEvents(e,t){e.tabIndex=0,e.addEventListener(`keydown`,e=>{(e.key===`Backspace`||e.key===`Delete`)&&t.dismissable&&(e.preventDefault(),this._removeTag(t.value),this._focusInput())})}_onDragStart(e,t){this.hasAttribute(`sortable`)&&(this._dragChip=t,this._dragIndex=Number(t.dataset.index),e.dataTransfer?.setData(`text/plain`,t.dataset.index||``),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`),t.classList.add(`opacity-60`))}_reorderTags(e,t){if(e<0||t<0||e>=this._tags.length||t>=this._tags.length)return;let n=[...this._tags],[r]=n.splice(e,1);n.splice(t,0,r),this._tags=n,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(e){this.hasAttribute(`sortable`)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(e,t){if(!this.hasAttribute(`sortable`)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),!this._dragChip||!this._chipsWrap)||t===this._dragChip)return;let n=t.getBoundingClientRect();if(e.clientX<n.left+n.width*.5){if(this._dragChip.nextSibling===t)return;this._chipsWrap.insertBefore(this._dragChip,t)}else{if(t.nextSibling===this._dragChip)return;let e=t.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(e){this.hasAttribute(`sortable`)&&e.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove(`opacity-60`),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;let e=Array.from(this._chipsWrap.querySelectorAll(`mint-chip`));if(e.length===0)return;let t=[];e.forEach(e=>{let n=e.dataset.value;if(!n)return;let r=this._tags.find(e=>e.value===n);r&&t.push(r)}),t.length===this._tags.length&&(this._tags=t,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(e,t){if(this.hasAttribute(`sortable`)&&e.pointerType!==`mouse`){this._isPointerDragging=!0,this._dragChip=t,this._dragIndex=Number(t.dataset.index);try{t.setPointerCapture(e.pointerId)}catch{}t.classList.add(`opacity-60`,`select-none`),e.preventDefault()}}_onPointerMove(e){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||e.pointerType===`mouse`)return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t.closest(`mint-chip`);if(n&&n!==this._dragChip){let t=n.getBoundingClientRect();if(e.clientX<t.left+t.width*.5)this._dragChip.nextSibling!==n&&this._chipsWrap.insertBefore(this._dragChip,n);else if(n.nextSibling!==this._dragChip){let e=n.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&t.closest(`input`)===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(e){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(e.pointerId)}catch{}this._dragChip.classList.remove(`opacity-60`,`select-none`)}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}};customElements.get(`mint-tags`)||customElements.define(`mint-tags`,w);var T=class extends HTMLElement{constructor(...e){super(...e),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add(`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`),this.getAttribute(`disabled`)===`true`?this.classList.add(`cursor-not-allowed`,`opacity-50`):this.classList.add(`cursor-pointer`),this.getAttribute(`role`)||this.setAttribute(`role`,`button`),this.getAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`)}_setupEventListeners(){this._clickHandler=e=>{if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}this._handleClick(e)},this._keydownHandler=e=>{if(e.key===`Enter`||e.key===` `){if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),this._handleClick(e)}},this.addEventListener(`click`,this._clickHandler),this.addEventListener(`keydown`,this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._keydownHandler&&=(this.removeEventListener(`keydown`,this._keydownHandler),null)}_handleClick(e){this.dispatchEvent(new CustomEvent(`clickable-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}static get observedAttributes(){return[`disabled`]}attributeChangedCallback(e,t,n){e===`disabled`&&(n===`true`?(this.classList.remove(`cursor-pointer`),this.classList.add(`opacity-50`,`cursor-not-allowed`),this.setAttribute(`aria-disabled`,`true`)):(this.classList.remove(`opacity-50`,`cursor-not-allowed`),this.classList.add(`cursor-pointer`),this.removeAttribute(`aria-disabled`)))}};customElements.get(`mint-clickable`)||customElements.define(`mint-clickable`,T);var E=class extends HTMLElement{static get observedAttributes(){return[`heading`,`dismissable`,`tone`]}constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}getTone(){let e=this.getAttribute(`tone`);return e===`info`||e===`success`||e===`warning`||e===`danger`?e:`info`}isDismissable(){return this.getAttribute(`dismissable`)===`true`}getIconName(){switch(this.getTone()){case`info`:return`info`;case`success`:return`success`;case`warning`:return`warning`;case`danger`:return`error`;default:return`info`}}getIconColorClasses(){switch(this.getTone()){case`info`:return`text-gray-700 dark:text-gray-300`;case`success`:return`text-green-600 dark:text-green-400`;case`warning`:return`text-yellow-600 dark:text-yellow-400`;case`danger`:return`text-red-600 dark:text-red-400`;default:return`text-gray-700 dark:text-gray-300`}}getHeadingColorClasses(){return`text-gray-900 dark:text-gray-100`}getHeaderBackgroundClasses(){switch(this.getTone()){case`info`:return`bg-gray-100 dark:bg-white/5`;case`success`:return`bg-green-100 dark:bg-green-900/30`;case`warning`:return`bg-yellow-100 dark:bg-yellow-900/30`;case`danger`:return`bg-red-100 dark:bg-red-900/30`;default:return`bg-gray-100 dark:bg-white/5`}}getBorderClasses(){switch(this.getTone()){case`info`:return`border-gray-200 dark:border-mint-divider`;case`success`:return`border-green-200 dark:border-green-800`;case`warning`:return`border-yellow-200 dark:border-yellow-800`;case`danger`:return`border-red-200 dark:border-red-800`;default:return`border-gray-200 dark:border-mint-divider`}}getAriaLive(){return this.getTone()===`danger`?`assertive`:`polite`}render(){let e=this.getTone(),t=this.getHeading(),n=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden ${this.getBorderClasses()}`;let r=this.getAriaLive();this.setAttribute(`role`,`alert`),this.setAttribute(`aria-live`,r),e===`danger`?this.setAttribute(`aria-atomic`,`true`):this.removeAttribute(`aria-atomic`);let i=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(e=>{i.push(e)}):Array.from(this.childNodes).forEach(e=>{e!==this._headerWrapper&&e!==this._bodyWrapper&&e!==this._iconElement&&e!==this._headingElement&&e!==this._dismissButton&&i.push(e)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement(`div`),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement(`mint-icon`),this._iconElement.setAttribute(`name`,this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement(`mint-text`),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=t||``,this._headerWrapper.appendChild(this._headingElement),n){this._dismissButton=document.createElement(`button`),this._dismissButton.className=`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10`,this._dismissButton.setAttribute(`aria-label`,`Dismiss alert`),this._dismissButton.setAttribute(`type`,`button`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`close`),e.className=`w-4 h-4 text-gray-700 dark:text-gray-300`,this._dismissButton.appendChild(e),this._dismissHandler=e=>{e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener(`click`,this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement(`div`),this._bodyWrapper.className=`px-4 py-3 bg-white dark:bg-mint-elevated`,i.forEach(e=>{this._bodyWrapper.appendChild(e)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}};customElements.get(`mint-alert`)||customElements.define(`mint-alert`,E);var D=class extends HTMLElement{static get observedAttributes(){return[`configuration`,`virtual-scroll`,`virtual-scroll-root`,`virtual-row-height`,`virtual-max-height`,`fixed-header`,`fixed-controls`]}constructor(){super(),this._configuration=null,this._rows=[],this._search=``,this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._loaded=!1,this._fetching=!1,this._loading=!1,this._loadingPage=null,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type=`provided`,this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId=``,this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1,this._virtualBodyScrollEl=null,this._virtualScrollHandler=null,this._virtualWindowRaf=null,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualResizeObserver=null,this._virtualWindowResizeHandler=null,this._virtualRowCache=new Map,this._virtualRangeFetching=!1,this._mobileListMql=null,this._boundMobileListMqlListener=null,this._virtualFetchGeneration=0,this._virtualAjaxPrefetchTimer=null,this._fixedChromeResizeObserver=null}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(e){e&&typeof e==`object`&&!Array.isArray(e)?(this._configuration=e,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=1,this._offset=0,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this.isConnected&&this.render()):e==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._inMintCard=this.parentElement?.tagName?.toLowerCase()===`mint-card`,this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadPageFromUrl(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._detachMobileListMql(),this._rowClickHandler&&=(this.removeEventListener(`click`,this._rowClickHandler,!0),null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}attributeChangedCallback(e,t,n){e===`configuration`&&t!==n?(!this._configuration||typeof n==`string`)&&(this._parseConfiguration(),this.render()):t!==n&&(e===`virtual-scroll`||e===`virtual-scroll-root`||e===`virtual-row-height`||e===`virtual-max-height`||e===`fixed-header`||e===`fixed-controls`)&&this._configuration&&this.isConnected&&this.render()}refresh(){this._configuration&&(this._type===`ajax`?this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){let e=this.getAttribute(`configuration`);if(!e){console.error(`mint-resource-table: configuration attribute is required`);return}try{this._configuration=JSON.parse(e),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=this._getPageFromUrl()||1,this._offset=(this._currentPage-1)*this._perPage,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns()}catch(e){console.error(`mint-resource-table: Invalid configuration JSON`,e)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(e=>{e.searchable&&e.data&&this._searchColumns.push(e.data),e.export&&e.data&&(this._exportColumns[e.data]=e.label),e.data&&this._columns.push(e.data)}),this._configuration.sortBy||(this._configuration.sortBy=`id`),this._configuration.sort||(this._configuration.sort=`asc`))}async _fetchData(e,t=!0,n,r){if(!this._configuration)return;let i=e||(typeof this._configuration.data==`string`?this._configuration.data:null);if(!i||this._fetching||this._loading)return;t&&(this._fetching=!0,this._loaded?this._updatePagination():this.render()),this._loading=!0;let a=n||this._perPage,o=r===void 0?this._offset:r;this._virtualScrollActive()&&this._type===`ajax`&&o===0&&(this._virtualFetchGeneration++,this._virtualRowCache.clear(),this._virtualInvalidate());try{let e=new URLSearchParams({perPage:a.toString(),offset:o.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let n=await fetch(`${i}?${e.toString()}`,t);if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.json(),s=r.content?.rows||[],c=r.content?.total||0,l=s;this._configuration.predefinedData?(l=[...this._configuration.predefinedData,...s],this._totalRows=c+this._configuration.predefinedData.length):this._totalRows=c,this._rows=l;let u=Math.floor(o/a)+1;r.content?.current_page!==void 0&&r.content.current_page===u?this._currentPage=r.content.current_page:this._currentPage=u,this._offset=(this._currentPage-1)*a,this._lastPage=r.content?.last_page||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;let d=this._sorting;d&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,d&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent(`loaded`,{detail:{rows:this._rows}})),this._updateSearchIcon();let f=`tbody[data-mint-rt-tbody="${this._tableId}"]`,p=!!this.querySelector(f);if(this._virtualScrollActive()&&this._type===`ajax`)p||this.render(),s.forEach((e,t)=>{this._virtualRowCache.set(o+t,e)}),this._virtualInvalidate(),o===0?queueMicrotask(()=>this._scrollVirtualTableTopIntoView()):this._scheduleVirtualWindowSync(),this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0);else if(this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)){if(d){let e=this._loading,t=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=e,this._fetching=t}else this._updateTableBody();this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0)}else this.render()}catch(e){this._fetching=!1,this._loading=!1,this._loadingPage=null,this._loaded=!0,this._searching=!1,this._fetchError=e instanceof Error?e.message:`Failed to fetch data`,console.error(`mint-resource-table: Error fetching data`,e),this._updateSearchIcon(),this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)?(this._updateTableBody(),this._loadingPage=null,this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type===`ajax`)return this._rows;let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_getAllFilteredRowsSorted(){if(!this._configuration||this._type!==`provided`)return[];let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_virtualInvalidate(){this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``}_getRowDataForEventIndex(e){if(this._configuration){if(!this._virtualScrollActive())return this._getRows()[e];if(this._type===`provided`)return this._getAllFilteredRowsSorted()[e];if(this._type===`ajax`)return this._virtualRowCache.get(e)}}getRowByIndex(e){return this._getRowDataForEventIndex(e)}_virtualScrollActive(){return this._configuration?(this.getAttribute(`virtual-scroll`)||``).toLowerCase().trim()===`true`:!1}_virtualScrollRoot(){let e=(this.getAttribute(`virtual-scroll-root`)||``).toLowerCase().trim();return e===`table-body`||e===`body`||this._configuration?.virtualScrollRoot===`table-body`?`table-body`:`document`}_virtualBodyScrollDisablesDocumentFixedChrome(){return this._virtualScrollActive()&&this._virtualScrollRoot()===`table-body`}_fixedHeader(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-header`))return!1;let e=(this.getAttribute(`fixed-header`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_fixedControls(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-controls`))return!1;let e=(this.getAttribute(`fixed-controls`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_virtualRowHeightPx(){let e=parseInt(this.getAttribute(`virtual-row-height`)||``,10);if(!isNaN(e)&&e>0)return e;let t=this._configuration?.virtualRowHeight;return typeof t==`number`&&t>0?t:48}_virtualRowHeightPxForSync(e){let t=this._virtualRowHeightPx();if(!this._configuration)return t;if(e){let e=this._mobileThumbnailColumn();if(e){let n=this._thumbnailMobilePx(e);return Math.max(t,n+36)}return Math.max(t,80)}let n=this._mobileThumbnailColumn();if(n){let e=this._thumbnailDesktopPx(n);return Math.max(t,e+28)}return t}_virtualMaxHeightCss(){let e=this.getAttribute(`virtual-max-height`);if(e&&e.trim())return e.trim();let t=this._configuration?.virtualMaxHeight;return t&&String(t).trim()?String(t).trim():`min(70dvh, 28rem)`}_virtualColspan(){return this._configuration?Math.max(1,this._configuration.columns.filter(e=>!e.hidden).length):1}_ensureMobileListMql(){typeof window>`u`||!window.matchMedia||this._mobileListMql||(this._mobileListMql=window.matchMedia(`(max-width: 767px)`),this._boundMobileListMqlListener=()=>{this._configuration&&this.isConnected&&this.render()},this._mobileListMql.addEventListener(`change`,this._boundMobileListMqlListener))}_detachMobileListMql(){this._mobileListMql&&this._boundMobileListMqlListener&&this._mobileListMql.removeEventListener(`change`,this._boundMobileListMqlListener),this._mobileListMql=null,this._boundMobileListMqlListener=null}_useMobileListLayout(){return!!this._mobileListMql?.matches}_paginationHostPlaceholderHtml(){if(!this._configuration?.perPage||this._virtualScrollActive())return``;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage);if((this._lastPage>0?this._lastPage:e)<=1)return``;let t=[`mint-rt-pagination-host`,`w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain`,`flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end`,this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`].join(` `);return`<div id="mint-rt-pagination-host-${this._tableId}" data-mint-rt-pagination-wrap="" class="${t}"></div>`}_getPaginationHostEl(){return this.querySelector(`#mint-rt-pagination-host-${this._tableId}`)}_paginationMountedRoot(){return this._getPaginationHostEl()||this.querySelector(`nav[data-mint-rt-pagination-nav]`)?.parentElement||this.querySelector(`nav`)?.closest(`.flex.justify-end`)}_paginationPageButtonLi(e){let t=this._currentPage===e,n=this._loadingPage===e;return`<li class="shrink-0"><mint-button variant="solid" size="sm"${t?` active="true"`:``}${this._loading||this._fetching?` disabled="true"`:``}${n?` loading="true"`:``} data-action="page" data-page="${e}">${n?``:`${e}`}</mint-button></li>`}_paginationHtmlCompactMiddle(e){let t=``,n=this._currentPage;if(e<=5){for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}let r=[...new Set([1,e,n-1,n,n+1].map(t=>Math.min(e,Math.max(1,t))))].sort((e,t)=>e-t),i=0;for(let e of r)i>0&&e-i>1&&(t+=`<li class="shrink-0"><span class="px-1 text-gray-500 dark:text-gray-400" aria-hidden="true">…</span></li>`),t+=this._paginationPageButtonLi(e),i=e;return t}_paginationHtmlDesktopMiddle(e){let t=``,n=e>=10,r=Math.max(1,this._currentPage-1),i=Math.min(e,this._currentPage+1);if(n){for(let e=1;e<=3;e++)t+=this._paginationPageButtonLi(e);let n=i<=3,a=r>=e-2;if(!n&&!a){r>4&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let e=r;e<=i;e++)e<=3||(t+=this._paginationPageButtonLi(e));i<e-3&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`)}else (n&&!a||!n&&a&&e-2>4)&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let o=e-2;o<=e;o++)o<=3||!n&&!a&&o>=r&&o<=i||(t+=this._paginationPageButtonLi(o))}else for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}_buildPaginationNavMarkup(e){let t=this._currentPage===1||this._loading||this._fetching,n=`<nav data-mint-rt-pagination-nav="" class="w-max max-w-none shrink-0" aria-label="Pagination">`;n+=`<ul class="flex flex-nowrap items-center gap-1">`,n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-left" ${t?`disabled="true"`:``} data-action="page-prev"></mint-button></li>`,n+=this._useMobileListLayout()?this._paginationHtmlCompactMiddle(e):this._paginationHtmlDesktopMiddle(e);let r=this._currentPage>=e||this._loading||this._fetching;return n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-right" ${r?`disabled="true"`:``} data-action="page-next"></mint-button></li>`,n+=`</ul></nav>`,n}_hasSortableColumns(){return!!this._configuration?.columns.some(e=>!e.hidden&&e.sortable&&e.data)}_getMobileSortTriggerIconName(){return`sort-arrows`}_mobileSortPopoverAffordanceInnerHtml(e){return e===`spinner`?`<span class="inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700 dark:border-gray-600 dark:border-t-gray-200" aria-hidden="true"></span>`:e===`caret-up`||e===`caret-down`?`<mint-icon name="${e}" class="h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400"></mint-icon>`:``}_buildMobileSortPopoverInnerHtml(){if(!this._configuration)return``;let e=`<div class="flex w-full min-w-[11rem] flex-col gap-0.5 p-1">`;return this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=t.raw?t.label:this._escapeHtml(t.label),i=this._getSortClass(t),a=this._mobileSortPopoverAffordanceInnerHtml(i),o=` type="button" variant="ghost" tone="neutral" size="sm" full-width="true" align="left" data-action="mobile-sort" data-column-key="${n}"`;e+=`<mint-button${o}>`,e+=`<span class="flex w-full min-w-0 flex-1 items-center justify-between gap-2">`,e+=`<span class="min-w-0 flex-1 truncate text-left">${r}</span>`,e+=`<span class="inline-flex shrink-0 items-center justify-end" data-mint-rt-mobile-sort-affordance="">${a}</span>`,e+=`</span></mint-button>`}),e+=`</div>`,e}_syncMobileSortPopoverIcons(){if(!this._configuration)return;let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=e.querySelector(`[data-action="mobile-sort"][data-column-key="${n}"]`);if(!r||r.tagName!==`MINT-BUTTON`)return;let i=r.querySelector(`[data-mint-rt-mobile-sort-affordance]`);if(!i)return;let a=this._getSortClass(t);i.innerHTML=this._mobileSortPopoverAffordanceInnerHtml(a),i.querySelectorAll(`mint-icon`).forEach(e=>{let t=e;typeof t.render==`function`&&t.render()})})}_closeMobileSortPopover(){let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&typeof e.close==`function`?e.close():e&&e.removeAttribute(`open`)}_buildMobileSortToolbarHtml(){if(!this._hasSortableColumns())return``;let e=`mint-rt-mobile-sort-btn-${this._tableId}`,t=`mint-rt-mobile-sort-popover-${this._tableId}`,n=this._sorting?` loading="true"`:``,r=` icon="${this._escapeHtml(this._getMobileSortTriggerIconName())}"`,i=`<div class="flex shrink-0 items-center md:hidden">`;return i+=`<mint-button id="${e}" data-mint-rt-toolbar="mobile-sort" variant="solid" tone="neutral" size="sm"${n}${r}></mint-button>`,i+=`<mint-popover id="${t}" trigger-id="${e}" direction="down" padding="0">`,i+=this._buildMobileSortPopoverInnerHtml(),i+=`</mint-popover></div>`,i}_stripHtml(e){if(!e)return``;let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).replace(/\s+/g,` `).trim()}_visibleDataColumns(){return this._configuration?this._configuration.columns.filter(e=>!e.hidden):[]}_mobileThumbnailColumn(){return this._visibleDataColumns().find(e=>e.thumbnail)||null}_thumbnailDesktopPx(e){let t=typeof e.thumbnailDesktopPx==`number`&&e.thumbnailDesktopPx>0?e.thumbnailDesktopPx:void 0,n=this._configuration,r=n&&typeof n.thumbnailDesktopPx==`number`&&n.thumbnailDesktopPx>0?n.thumbnailDesktopPx:void 0;return Math.round(t??r??40)}_thumbnailMobilePx(e){let t=typeof e.thumbnailMobilePx==`number`&&e.thumbnailMobilePx>0?e.thumbnailMobilePx:void 0,n=this._configuration,r=n&&typeof n.thumbnailMobilePx==`number`&&n.thumbnailMobilePx>0?n.thumbnailMobilePx:void 0;return Math.round(t??r??56)}_wrapThumbnailDesktopBox(e,t){let n=this._thumbnailDesktopPx(t);return`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${`width:${n}px;height:${n}px;min-width:${n}px;min-height:${n}px`}">${e}</div>`}_mobilePrimaryColumn(){let e=this._visibleDataColumns();return e.find(e=>e.primary)||e.find(e=>(e.data||typeof e.format==`function`)&&!e.thumbnail&&!e.actions)||e[0]||null}_mobileActionsDropdownColumn(){return this._visibleDataColumns().find(e=>e.actions&&e.actionStyle!==`buttons`)||null}_columnPlainSummaryText(e,t){if(!(!e.show||e.show(this,t))||e.actions||e.action)return``;try{if(e.raw){if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}else{if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}}catch{return``}return``}_buildTableCellInnerHtml(e,t,n,r=`table`){if(!this._configuration)return``;let i=n,a=``;if(!(!e.show||e.show(this,t)))return``;if(e.raw)if(e.action){if(!e.action.show||e.action.show(this,t)){let n=typeof e.action.label==`function`?e.action.label(this,t):e.action.label;a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(n))}</mint-button>`}}else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=e.format(this,t):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));else if(e.action)(!e.action.show||e.action.show(this,t))&&(a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${e.action.label}</mint-button>`);else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=this._escapeHtml(e.format(this,t)):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));return r===`table`&&e.thumbnail&&a&&!e.actions&&!e.action?this._wrapThumbnailDesktopBox(a,e):a}_buildMobileListItemHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=typeof this._configuration.onRowClick==`function`,o=this._mobileThumbnailColumn(),s=this._mobilePrimaryColumn(),c=this._mobileActionsDropdownColumn(),l=o?this._buildTableCellInnerHtml(o,e,i,`mobile`):``,u=s?this._buildTableCellInnerHtml(s,e,i,`mobile`):``,d=c?this._buildTableCellInnerHtml(c,e,i,`mobile`):``,f=[];for(let t of this._configuration.columns){if(t.hidden||o&&t===o||s&&t===s||c&&t===c)continue;let n=this._columnPlainSummaryText(t,e);n&&f.push(this._escapeHtml(n))}let p=f.join(`<span class="text-gray-300 dark:text-gray-600" aria-hidden="true"> · </span>`),m=[`list-none`,...r?[]:[`border-b`,`border-gray-200`,`dark:border-mint-divider`],`bg-white`,`dark:bg-mint-canvas`,a?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``].filter(Boolean).join(` `),h=`<div class="flex items-center gap-3 py-3 pr-4${o?` pl-0`:` pl-4`}">`;if(o){let e=this._thumbnailMobilePx(o),t=`width:${e}px;height:${e}px;min-width:${e}px;min-height:${e}px`;h+=`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${t}">${l}</div>`}h+=`<div class="flex min-w-0 flex-1 flex-col justify-center gap-1">`,h+=`<div class="flex items-start justify-between gap-2">`,h+=`<div class="min-w-0 text-sm font-semibold leading-snug text-gray-900 dark:text-white">${u}</div>`,d&&(h+=`<div class="shrink-0 -mr-1">${d}</div>`),h+=`</div>`,p&&(h+=`<div class="text-xs font-normal leading-snug text-gray-500 dark:text-gray-400">${p}</div>`),h+=`</div></div>`;let g=typeof n==`number`&&n>0?` style="box-sizing:border-box;min-height:${n}px;max-height:${n}px;height:${n}px;overflow:hidden"`:``;return`<li data-row-index="${i}" ${a?`data-row-clickable="true" `:``}class="${m}"${g}>${h}</li>`}_buildMobileListPlaceholderLi(e,t,n=!1){let r=this._mobileThumbnailColumn(),i=r?this._thumbnailMobilePx(r):56,a=`width:${i}px;height:${i}px;min-width:${i}px;min-height:${i}px`;return`<li data-row-index="${e}" data-mint-rt-placeholder="true" class="list-none${n?``:` border-b border-gray-200 dark:border-mint-divider`} bg-white dark:bg-mint-canvas" style="box-sizing:border-box;min-height:${t}px;max-height:${t}px;height:${t}px;overflow:hidden"><div class="flex h-full min-h-0 items-center gap-3 py-3 pl-0 pr-4"><div class="shrink-0 overflow-hidden rounded-md bg-gray-200 dark:bg-white/15" style="${a}"></div><div class="flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 py-0.5"><div class="h-4 w-40 rounded bg-gray-200 dark:bg-white/15"></div><div class="h-3 w-full max-w-xs rounded bg-gray-200 dark:bg-white/15"></div></div></div></li>`}_renderColgroupHtml(){if(!this._configuration)return``;let e=this._configuration.columns.filter(e=>!e.hidden),t=[],n=0;for(let r of e){let e=r.width==null?``:String(r.width).trim();e?/^\d+(\.\d+)?$/.test(e)?(n+=parseFloat(e),t.push(`px`)):t.push(`lit`):t.push(`flex`)}let r=t.filter(e=>e===`flex`).length,i=t.includes(`lit`),a=``;r>0&&!i&&(a=n>0?`width:calc((100% - ${n}px) / ${r});min-width:0`:`width:${100/r}%;min-width:0`);let o=`<colgroup>`;return e.forEach((e,n)=>{let r=e.width==null?``:String(e.width).trim(),i=t[n],s=``;i===`px`?s=` style="width:${r}px;min-width:0"`:i===`lit`?s=` style="width:${this._escapeHtml(r)};min-width:0"`:a&&(s=` style="${a}"`),o+=`<col${s} />`}),o+=`</colgroup>`,o}_buildDataRowHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=n,o=`box-sizing:border-box;min-height:${a}px;max-height:${a}px;height:${a}px;overflow:hidden`,s=``,c=typeof this._configuration.onRowClick==`function`,l=c?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``,u=c?` data-row-clickable="true"`:``,d=l?` class="${l}"`:``;return s+=`<tr data-row-index="${i}"${r?` data-mint-rt-last-row=""`:``}${u}${d} style="${o}">`,this._configuration.columns.forEach(t=>{if(t.hidden)return;let n=!t.show||t.show(this,e),r=`${this._getStyle(t)}box-sizing:border-box;max-height:${a}px;overflow:hidden;vertical-align:middle;`;s+=`<td style="${r}" class="${this._getClasses(t,!0)}">`,s+=n?this._buildTableCellInnerHtml(t,e,i):``,s+=`</td>`}),s+=`</tr>`,s}_getVirtualRowCount(){return!this._virtualScrollActive()||!this._configuration?0:this._type===`provided`?this._getAllFilteredRowsSorted().length:this._type===`ajax`?this._totalRows:0}_getVirtualRowAt(e){return this._type===`provided`?this._getAllFilteredRowsSorted()[e]??null:this._type===`ajax`&&this._virtualRowCache.has(e)?this._virtualRowCache.get(e):null}_buildVirtualPlaceholderRowHtml(e,t,n=!1){if(!this._configuration)return``;let r=t,i=`box-sizing:border-box;min-height:${r}px;max-height:${r}px;height:${r}px;overflow:hidden`,a=`<tr data-row-index="${e}" data-mint-rt-placeholder="true"${n?` data-mint-rt-last-row=""`:``} class="bg-white dark:bg-mint-canvas" style="${i}">`;return this._configuration.columns.forEach(e=>{if(e.hidden)return;let t=`${this._getStyle(e)}box-sizing:border-box;max-height:${r}px;height:${r}px;overflow:hidden;vertical-align:middle;line-height:0;`;if(a+=`<td style="${t}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);a+=`<div class="rounded-md bg-gray-200 dark:bg-white/15" style="width:${t}px;height:${t}px;max-width:100%;box-sizing:border-box"></div>`}else a+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15"></div>`;a+=`</td>`}),a+=`</tr>`,a}_virtualScrollStickyOverlapPx(e){let t=0;if(this._fixedControls()){let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(e)t+=Math.ceil(e.getBoundingClientRect().height);else{let e=getComputedStyle(this).getPropertyValue(`--mint-rt-fixed-controls-h`).trim(),n=parseFloat(e);isNaN(n)||(t+=Math.ceil(n))}}if(this._fixedHeader()&&e){let n=e.querySelector(`thead`);n&&(t+=Math.ceil(n.getBoundingClientRect().height))}return t}_scrollVirtualTableTopIntoView(){if(!this._virtualScrollActive()||!this.isConnected)return;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl?.isConnected?this._virtualBodyScrollEl:this.querySelector(`#mint-rt-vscroll-${this._tableId}`),t=this._useMobileListLayout()&&e?e.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`):null,n=e?.querySelector(`mint-table.table-section`)||e?.querySelector(`mint-table`),r=n?.querySelector(`#${this._tableId}`)?.closest(`table`)||n?.querySelector(`table`),i=this._virtualScrollStickyOverlapPx(r),a=t||n;if(a&&i>0){let e=a.getBoundingClientRect(),t=window.scrollY+e.top-i;window.scrollTo({top:Math.max(0,t),behavior:`auto`})}e&&(e.scrollTop=0,this._virtualBodyScrollEl=e,this._virtualInvalidate(),this._scheduleVirtualWindowSync());return}let e=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),t=this.querySelector(`mint-table.table-section`),n=this.querySelector(`#${this._tableId}`)?.closest(`table`)||t?.querySelector(`table`),r=this._useMobileListLayout()&&e?e:t||n;if(!r)return;let i=this._virtualScrollStickyOverlapPx(n),a=r.getBoundingClientRect(),o=window.scrollY+a.top-i;window.scrollTo({top:Math.max(0,o),behavior:`auto`}),this._virtualInvalidate(),this._scheduleVirtualWindowSync()}_scheduleVirtualWindowSync(){this._virtualScrollActive()&&this._virtualWindowRaf===null&&(this._virtualWindowRaf=window.requestAnimationFrame(()=>{this._virtualWindowRaf=null,this._syncVirtualWindow()}))}_syncVirtualWindow(){if(!this._virtualScrollActive()||!this._configuration)return;let e=this._useMobileListLayout(),t=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),n=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),r=e?n:t;if(!r)return;let i=this._getVirtualRowCount(),a=this._virtualRowHeightPxForSync(e),o=this._virtualColspan();if(i===0){e?this._fetchError?r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`:r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`:this._fetchError?r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8">No records found.</td></tr>`,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``;return}let s=0,c=window.innerHeight;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl;if((!e||!e.isConnected)&&(e=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl=e),!e)return;s=e.scrollTop,c=e.clientHeight||400}else{let e=r.getBoundingClientRect();s=Math.max(0,-e.top)}let l=Math.min(Math.max(0,Math.floor(s/a)),Math.max(0,i-1)),u=Math.ceil(c/a)+16,d=Math.max(0,l-8),f=Math.min(i,l+u),p=``;if(this._type===`ajax`)for(let e=d;e<f;e++)p+=this._virtualRowCache.has(e)?`1`:`0`;if(d===this._virtualLastRangeStart&&f===this._virtualLastRangeEnd&&(this._type!==`ajax`||p===this._virtualLastRangeCacheSig))return;this._virtualLastRangeStart=d,this._virtualLastRangeEnd=f,this._virtualLastRangeCacheSig=p;let m=d*a,h=Math.max(0,(i-f)*a),g=``;if(e){g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${m}px"></li>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildMobileListItemHtml(t,e,a,n):g+=this._buildMobileListPlaceholderLi(e,a,n)}g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${h}px"></li>`}else{g+=`<tr data-mint-rt-spacer="top" aria-hidden="true"><td colspan="${o}" style="height:${m}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildDataRowHtml(t,e,a,n):g+=this._buildVirtualPlaceholderRowHtml(e,a,n)}g+=`<tr data-mint-rt-spacer="bottom" aria-hidden="true"><td colspan="${o}" style="height:${h}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`}if(r.innerHTML=g,this.querySelectorAll(`tbody[data-mint-rt-tbody="${this._tableId}"] mint-button[data-action], ul[data-mint-rt-mobile-list="${this._tableId}"] mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this._attachTableEventListeners(),this._attachRowClickHandler(),this._type===`ajax`&&this._virtualScrollActive()&&this._scheduleVirtualAjaxPrefetch(d,f),this._virtualScrollRoot()===`table-body`&&!e){let e=this._virtualBodyScrollEl;e?.isConnected&&requestAnimationFrame(()=>{if(!e.isConnected)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop>t&&(e.scrollTop=t)})}}_detachVirtualScroll(){this._virtualScrollHandler&&=(window.removeEventListener(`scroll`,this._virtualScrollHandler),this._virtualBodyScrollEl?.removeEventListener(`scroll`,this._virtualScrollHandler),null),this._virtualWindowResizeHandler&&=(window.removeEventListener(`resize`,this._virtualWindowResizeHandler),null),this._virtualResizeObserver&&=(this._virtualResizeObserver.disconnect(),null),this._virtualBodyScrollEl=null,this._virtualWindowRaf!==null&&(window.cancelAnimationFrame(this._virtualWindowRaf),this._virtualWindowRaf=null),this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualAjaxPrefetchTimer!==null&&(window.clearTimeout(this._virtualAjaxPrefetchTimer),this._virtualAjaxPrefetchTimer=null),this._virtualRangeFetching=!1}_scheduleVirtualAjaxPrefetch(e,t){if(this._type!==`ajax`||!this._virtualScrollActive()||!this._configuration)return;let n=!1;for(let r=e;r<t;r++)if(!this._virtualRowCache.has(r)){n=!0;break}if(!n)return;this._virtualAjaxPrefetchTimer!==null&&window.clearTimeout(this._virtualAjaxPrefetchTimer);let r=e,i=t;this._virtualAjaxPrefetchTimer=window.setTimeout(()=>{this._virtualAjaxPrefetchTimer=null,this._fetchVirtualAjaxRange(r,i-r)},60)}async _fetchVirtualAjaxRange(e,t){if(!this._configuration||this._type!==`ajax`||!this._virtualScrollActive())return;let n=typeof this._configuration.data==`string`?this._configuration.data:null;if(!n||t<=0||this._virtualRangeFetching||e<0||e>=this._totalRows)return;this._virtualRangeFetching=!0;let r=this._virtualFetchGeneration,i=Math.min(e,Math.max(0,this._totalRows-1)),a=Math.min(150,Math.max(this._perPage,t,15),Math.max(1,this._totalRows-i));try{let e=new URLSearchParams({perPage:a.toString(),offset:i.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let o=await fetch(`${n}?${e.toString()}`,t);if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(r!==this._virtualFetchGeneration)return;(s.content?.rows||[]).forEach((e,t)=>{let n=i+t;n<this._totalRows&&this._virtualRowCache.set(n,e)})}catch(e){console.error(`mint-resource-table: virtual range fetch failed`,e)}finally{this._virtualRangeFetching=!1,r===this._virtualFetchGeneration&&(this._virtualInvalidate(),this._scheduleVirtualWindowSync())}}_detachFixedChromeResize(){this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null,this.style.removeProperty(`--mint-rt-fixed-controls-h`)}_syncFixedControlsChromeHeight(){if(!this._fixedHeader()||!this._fixedControls())return;this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null;let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height);this.style.setProperty(`--mint-rt-fixed-controls-h`,`${t}px`)};t(),this._fixedChromeResizeObserver=new ResizeObserver(t),this._fixedChromeResizeObserver.observe(e)}_attachVirtualScrollListeners(){if(this._detachVirtualScroll(),!this._virtualScrollActive())return;let e=()=>{this._scheduleVirtualWindowSync()};this._virtualScrollHandler=e,this._virtualScrollRoot()===`table-body`?(this._virtualBodyScrollEl=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl?.addEventListener(`scroll`,e,{passive:!0}),this._virtualBodyScrollEl&&typeof ResizeObserver<`u`&&(this._virtualResizeObserver=new ResizeObserver(()=>this._scheduleVirtualWindowSync()),this._virtualResizeObserver.observe(this._virtualBodyScrollEl))):window.addEventListener(`scroll`,e,{passive:!0}),this._virtualWindowResizeHandler=()=>this._scheduleVirtualWindowSync(),window.addEventListener(`resize`,this._virtualWindowResizeHandler,{passive:!0}),this._scheduleVirtualWindowSync()}_toggleSort(e){if(!this._configuration||!e.data||!e.sortable)return;let t=e.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=e,this._updateSortIcons(),this._type===`ajax`)this._sortTimeoutId=window.setTimeout(()=>{if(this._sortTimeoutId=null,!this._configuration||!t||!e.sortable)return;let n=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(n=n===`desc`?`asc`:`desc`),this._configuration.sort=n,this._configuration.sortBy=t,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._fetching=!1,this._loading=!1,this._fetchData(void 0,!1,this._perPage,0)},10);else{let e=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(e=e===`desc`?`asc`:`desc`),this._configuration.sort=e,this._configuration.sortBy=t,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render(),this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView())}}_getSortClass(e){return this._sorting&&this._sortingColumn===e?`spinner`:this._configuration?.sortBy?.toLowerCase()===e.data?.toLowerCase()?this._configuration?.sort?.toLowerCase()===`desc`?`caret-down`:`caret-up`:``}_updateSortIcons(){if(!this._configuration)return;this._configuration.columns.forEach((e,t)=>{if(!e.sortable||e.hidden)return;let n=this.querySelector(`th[data-column-key="${t}"]`);if(!n)return;let r=n.querySelector(`:scope > div.flex.items-center`);if(!r)return;let i=r.querySelector(`:scope > div.ml-2.flex.items-center`),a=this._getSortClass(e),o=()=>{if(!i){let e=document.createElement(`div`);e.className=`ml-2 flex items-center`,r.appendChild(e),i=e}return i},s=()=>{i&&=(i.remove(),null)};if(a===`spinner`){let e=o();if(e.querySelector(`mint-icon`)?.remove(),!e.querySelector(`mint-spinner`)){let t=document.createElement(`mint-spinner`);t.className=`w-4 h-4`,e.appendChild(t)}}else if(a===`caret-up`||a===`caret-down`){let e=o();e.querySelector(`mint-spinner`)?.remove();let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a),t.className=`w-4 h-4`}else s()}),this._syncMobileSortPopoverIcons();let e=this.querySelector(`#mint-rt-mobile-sort-btn-${this._tableId}`);e&&(e.setAttribute(`icon`,this._getMobileSortTriggerIconName()),this._sorting?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type===`ajax`&&this._updateSearchIcon(),this._type!==`ajax`&&(this._currentPage=1),this._updateTableBody(),this._type!==`ajax`&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type===`ajax`?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):(this._searching=!1,this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView()))},400)}_updateSearchIcon(){let e=this.querySelector(`#search-${this._tableId}`);if(!e)return;let t=this._type===`ajax`&&(this._searching||this._fetching);setTimeout(()=>{let n=e.querySelector(`.relative`)||e.querySelector(`div`);if(!n)return;let r=n.querySelector(`mint-icon`),i=n.querySelector(`mint-spinner`);if(t){if(r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,r.replaceWith(e)}else if(!r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,n.appendChild(e)}}else if(i){e.getAttribute(`icon`)||e.setAttribute(`icon`,`search`);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.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`,i.replaceWith(t)}},0)}_updateTableBody(){if(!this._configuration)return;let e=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),t=this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`);if(this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)){if(!(e||t)){this.render();return}let n=this.querySelector(`#search-${this._tableId}`),r=document.activeElement===n||n?.querySelector(`input`)===document.activeElement,i=this._search;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;if(this._virtualInvalidate(),this._syncVirtualWindow(),r&&n){let e=n.querySelector(`input`)||n._element;e?(e.value=i,setTimeout(()=>{e.focus(),e.setSelectionRange(i.length,i.length)},0)):n.value!==void 0&&(n.value=i,setTimeout(()=>{n.focus()},0))}return}let n=this._getRows(),r=t;if(!r){this.render();return}let i=this.querySelector(`#search-${this._tableId}`),a=document.activeElement===i||i?.querySelector(`input`)===document.activeElement,o=this._search,s=``,c=``;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;n.forEach((e,t)=>{c+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let r=typeof this._configuration.onRowClick==`function`,i=r?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``;s+=`<tr data-row-index="${t}" ${r?`data-row-clickable="true"`:``}${i?` class="${i}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let r=!n.show||n.show(this,e);s+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,r&&(s+=this._buildTableCellInnerHtml(n,e,t,`table`)),s+=`</td>`}),s+=`</tr>`}),n.length===0&&(this._fetchError?(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`):(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8">No records found.</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`)),r.innerHTML=s;let l=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`);if(l&&(l.innerHTML=c),this._attachTableEventListeners(),this._attachRowClickHandler(),a&&i){let e=i.querySelector(`input`)||i._element;e?(e.value=o,setTimeout(()=>{e.focus(),e.setSelectionRange(o.length,o.length)},0)):i.value!==void 0&&(i.value=o,setTimeout(()=>{i.focus()},0))}}_updatePagination(){if(!this._configuration)return;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage),t=()=>{let e=this.querySelector(`mint-table`),t=e?.nextElementSibling;e&&t&&t.id!==`mint-rt-pagination-host-${this._tableId}`&&!t.classList.contains(`mint-rt-pagination-host`)&&t.querySelector?.(`[data-action="page"]`)&&t.remove()};if(!this._configuration.perPage||e<=1||this._virtualScrollActive()){this._getPaginationHostEl()?.replaceChildren(),t();return}let n=this._getPaginationHostEl();if(!n){let e=this.querySelector(`[data-mint-rt-mobile-list="${this._tableId}"]`)||this.querySelector(`mint-table`);if(!e){this.render();return}n=document.createElement(`div`),n.id=`mint-rt-pagination-host-${this._tableId}`,n.setAttribute(`data-mint-rt-pagination-wrap`,``),n.className=`mint-rt-pagination-host w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end `+(this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`),e.insertAdjacentElement(`afterend`,n)}let r=this._buildPaginationNavMarkup(e);n.innerHTML=r,setTimeout(()=>{this._attachPaginationListeners(),n.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{let t=e.getAttribute(`data-page`),n=t&&this._loadingPage===parseInt(t),r=e._button||e.querySelector(`button`);if(r)if(n){let e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),n;for(;n=t.nextNode();)e.push(n);e.forEach(e=>e.parentNode?.removeChild(e));let i=r.querySelector(`.mint-button-content`);if(i){let e=i.textContent?.trim();e&&/^\d+$/.test(e)&&i.remove()}let a=r.querySelector(`span.mr-2`);a&&a.querySelector(`mint-spinner`)&&(a.classList.remove(`mr-2`),a.classList.add(`mr-0`))}else{let e=r.textContent?.trim();if(!e||!/^\d+$/.test(e)){let e=t||``,n=r.querySelector(`mint-spinner`);r.innerHTML=``,n&&r.appendChild(n),r.appendChild(document.createTextNode(e))}}if(`render`in e&&typeof e.render==`function`&&(e.render(),n&&r)){let e=r.querySelector(`span.mr-2`);e&&e.querySelector(`mint-spinner`)&&(e.classList.remove(`mr-2`),e.classList.add(`mr-0`))}}),n.querySelectorAll(`mint-button[data-action="page-prev"], mint-button[data-action="page-next"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()}),this._loadingPage!==null&&!this._loading&&!this._fetching&&this._updatePagination()},0)}_goToPage(e){let t=this._lastPage||Math.ceil(this._rows.length/this._perPage);e>t&&(e=t),e<1&&(e=1),e!==this._currentPage&&(this._currentPage=e,this._offset=(e-1)*this._perPage,this._updatePageInUrl(e),this._type===`ajax`?(this._loadingPage=e,this._updatePagination(),this._fetchData()):this.render())}_handleButtonClick(e){if(this._configuration)switch(e.type){case`export`:break;case`print`:window.print();break;case`csv`:this._downloadCSV();break;default:e.onClick&&e.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;let e=this.querySelector(`#${this._tableId}`)||this.querySelector(`table`);if(!e)return;let t=`data:text/csv;charset=utf-8,`,n=e=>{let n=[];e.querySelectorAll(`th, td`).forEach(e=>{let t=e.getAttribute(`colspan`);if(t)for(let e=0;e<parseInt(t,10)-1;e++)n.push(``);n.push(`"`+e.textContent?.trim().replace(/"/g,`""`)+`"`)}),t+=n.join(`,`)+`
|
|
83
|
-
`};e.querySelectorAll(`tr`).forEach(e=>n(e));let r=encodeURI(t),i=document.createElement(`a`);i.setAttribute(`href`,r),i.setAttribute(`download`,`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(i),i.click(),document.body.removeChild(i)}_getStyle(e){let t=``;return(e.nowrap||e.actions)&&(t+=`white-space: nowrap;`),e.offsetLeft&&(t+=`left: ${e.offsetLeft} !important;`),e.offsetRight&&(t+=`right: ${e.offsetRight} !important;`),e.width&&(t+=`min-width: ${e.width}px; max-width: ${e.width}px;`),t}_getClasses(e,t=!1){let n=[];return e.class&&n.push(e.class.trim()),e.sortable&&!t&&n.push(`cursor-pointer`),e.stickLeft&&n.push(`sticky-left`),e.stickRight&&n.push(`sticky-right`),n.join(` `)}_renderTheadHtml(e,t,n=!1,r=!1){if(!this._configuration)return``;let i=[`bg-white`,`dark:bg-mint-nav`];e&&(i.push(`sticky`,`z-40`),r?i.push(`top-[var(--mint-rt-fixed-controls-h,0px)]`):i.push(`top-0`)),t&&i.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`);let a=`<thead class="${i.join(` `)}"><tr>`;return this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let r=n?``:` width="${e.width||``}"`,i=e.sortable?` data-mint-rt-sortable=""`:``;if(a+=`<th${r} style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${i}>`,e.showLabel!==!1){if(a+=`<div class="flex items-center">`,a+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?a+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(a+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}a+=`</div>`}a+=`</th>`}),a+=`</tr></thead>`,a}render(){if(!this._configuration){this.innerHTML=`<div class="p-4 text-red-500">Error: Invalid configuration</div>`;return}this._ensureMobileListMql();let e=String(this._configuration.id||``).trim();e&&(this.id=e),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._virtualScrollActive()||this._virtualRowCache.clear();let t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,n=this._getRows();this._lastPage||Math.ceil(this._rows.length/this._perPage);let r=``;if(t){let e=this._fixedControls(),t=[`flex`,`items-center`,`min-w-0`,this._inMintCard?`p-3.5`:`mb-3`,e?`sticky top-0 z-50 bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider`:``].filter(Boolean).join(` `);if(r+=`<div id="mint-rt-fixed-controls-${this._tableId}" class="${t}">`,r+=`<div class="flex min-w-0 flex-1 items-center gap-2">`,r+=this._buildMobileSortToolbarHtml(),this._configuration.showSearch!==!1){let e=`search-${this._tableId}`,t=this._escapeHtml(this._configuration.searchPlaceholder||`Search...`);r+=`<mint-input id="${e}" type="search" label="" placeholder="${t}" class="min-w-0 flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}r+=`<div class="hidden shrink-0 items-center gap-2 md:flex">`,this._configuration.buttons&&this._configuration.buttons.forEach(e=>{let t=e.icon?` icon="${this._escapeHtml(e.icon)}"`:``,n=e.tone?` tone="${this._escapeHtml(e.tone)}"`:``;r+=`<mint-button variant="solid" class="${e.class||``}" data-button-type="${e.type||`custom`}"${t}${n}>`,e.label&&(r+=this._escapeHtml(e.label)),r+=`</mint-button>`}),r+=`</div>`,r+=`</div>`,r+=`</div>`}if(this._type===`ajax`&&!this._loaded&&!this._fetchError&&!this._sorting){let e=this._fixedHeader()?` data-mint-rt-scroll-inner=""`:``,t=this._fixedHeader()&&this._fixedControls(),n=this._fixedHeader()?t?`sticky top-[var(--mint-rt-fixed-controls-h,0px)] z-40 `:`sticky top-0 z-40 `:`sticky top-0 z-20 `;r+=`<div class="min-w-0">`,r+=`<mint-table class="table-section`+(this._inMintCard?` rounded-t-none`:``)+`"`+e+`>`,r+=`<table id="${this._tableId}">`,r+=`<thead class="`+n+`bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider"><tr>`,this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let n=e.sortable?` data-mint-rt-sortable=""`:``;if(r+=`<th width="${e.width||``}" style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${n}>`,e.showLabel!==!1){if(r+=`<div class="flex items-center">`,r+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?r+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(r+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}r+=`</div>`}r+=`</th>`}),r+=`</tr></thead>`,r+=`<tbody>`;for(let e=0;e<4;e++)r+=`<tr>`,this._configuration.columns.forEach(e=>{if(!e.hidden){if(r+=`<td style="${this._getStyle(e)}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);r+=`<div class="rounded-md bg-gray-200 dark:bg-white/15 animate-pulse" style="width:${t}px;height:${t}px;box-sizing:border-box"></div>`}else r+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15 animate-pulse"></div>`;r+=`</td>`}}),r+=`</tr>`;r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=this._paginationHostPlaceholderHtml()}else if(n.length>0||this._search.length>0||this._searching||this._fetchError){let e=this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`&&this._loaded&&!this._fetchError),t=e&&this._virtualScrollRoot()===`table-body`,i=this._escapeHtml(this._virtualMaxHeightCss()),a=t||this._fixedHeader(),o=this._fixedHeader()&&this._fixedControls(),s=a?` data-mint-rt-scroll-inner=""`:``,c=`table-section`+(this._inMintCard?` rounded-t-none`:``),l=`m-0 min-h-0 w-full list-none border-collapse overflow-x-hidden bg-white ${this._inMintCard?`px-3.5 py-3.5`:`py-3`} dark:bg-mint-canvas md:hidden`,u=``;if(t){let e=this._renderColgroupHtml();r+=`<div id="mint-rt-vscroll-${this._tableId}" class="overflow-y-auto overflow-x-auto min-h-0 w-full" style="max-height: ${i}; scrollbar-gutter: stable; overscroll-behavior-x: contain; overscroll-behavior-y: none; overflow-anchor: none;">`,r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}" class="w-full min-w-0 table-fixed">`,r+=e,r+=this._renderTheadHtml(!0,!0,!0,o)}else r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}">`,e&&(r+=this._renderColgroupHtml()),r+=this._renderTheadHtml(!0,!0,!!e,o);if(r+=`<tbody`+(e?` data-mint-rt-tbody="${this._tableId}"`:``)+`>`,!this._fetching&&!this._loading&&!e&&n.forEach((e,t)=>{u+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let i=typeof this._configuration.onRowClick==`function`,a=i?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``;r+=`<tr data-row-index="${t}" ${i?`data-row-clickable="true"`:``}${a?` class="${a}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let i=!n.show||n.show(this,e);r+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,i&&(r+=this._buildTableCellInnerHtml(n,e,t,`table`)),r+=`</td>`}),r+=`</tr>`}),!this._fetching&&!this._loading&&n.length===0&&!e)if(this._fetchError){let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`}else{let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8">No records found.</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`}r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=`<ul class="${l}" data-mint-rt-mobile-list="${this._tableId}">${e?``:u}</ul>`,e||(r+=this._paginationHostPlaceholderHtml()),t&&(r+=`</div>`)}else r+=`<slot name="empty"></slot>`;this._fixedHeader()?this.setAttribute(`data-mint-rt-fixed-header`,``):this.removeAttribute(`data-mint-rt-fixed-header`),this._fixedControls()?this.setAttribute(`data-mint-rt-fixed-controls`,``):this.removeAttribute(`data-mint-rt-fixed-controls`),this.innerHTML=r,this._updatePagination(),this.querySelectorAll(`mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-mint-rt-toolbar]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-button-type]`).forEach(e=>{e.render&&e.render()}),this._attachEventListeners(),this._type===`ajax`&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener(`click`,this._rowClickHandler,!0);let e=e=>{let t=e.target;if(t.tagName===`MINT-BUTTON`||t.tagName===`BUTTON`||t.closest(`mint-button`)||t.closest(`button`)||t.closest(`mint-popover`)||t.closest(`[data-action]`))return;let n=t.closest(`tr[data-row-clickable="true"]`)||t.closest(`li[data-row-clickable="true"]`);if(!n)return;let r=n.getAttribute(`data-row-index`);if(!r)return;let i=parseInt(r),a=this._getRowDataForEventIndex(i);!a||!this._configuration?.onRowClick||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(a):this._configuration.onRowClick(this,a))};this.addEventListener(`click`,e,!0),this._rowClickHandler=e}_attachPaginationListeners(){this.querySelectorAll(`[data-action="page"]`).forEach(e=>{e.addEventListener(`click`,()=>{if(e.getAttribute(`active`)===`true`)return;let t=parseInt(e.getAttribute(`data-page`)||`1`);t!==this._currentPage&&this._goToPage(t)})}),this.querySelectorAll(`[data-action="page-prev"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll(`[data-action="page-next"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll(`[data-action="row-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-action-index`)||`0`),r=parseInt(e.getAttribute(`data-column-key`)||`0`),i=this._getRowDataForEventIndex(t),a=this._configuration?.columns[r];a&&a.actions&&a.actions[n]&&i!==void 0&&a.actions[n].onClick(this,i)})}),this.querySelectorAll(`[data-action="column-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-column-key`)||`0`),r=this._getRowDataForEventIndex(t),i=this._configuration?.columns[n];i&&i.action&&r!==void 0&&i.action.onClick(this,r)})})}_attachEventListeners(){let e=this.querySelector(`#search-${this._tableId}`);if(e){let t=e.querySelector(`input`)||e._element;t?t.addEventListener(`input`,e=>{this._search=e.target.value,this._triggerSearch()}):e.addEventListener(`input`,t=>{this._search=e.value||t.target.value||``,this._triggerSearch()})}this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll(`th[data-column-key]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-column-key`)||`0`),n=this._configuration?.columns[t];n&&this._toggleSort(n)})}),this.querySelectorAll(`[data-action="mobile-sort"]`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.getAttribute(`data-column-key`)||`0`,10),r=this._configuration?.columns[n];r&&(this._closeMobileSortPopover(),this._toggleSort(r))})}),this.querySelectorAll(`[data-button-type]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-button-type`),n=this._configuration?.buttons?.find(e=>(e.type||`custom`)===t);n&&this._handleButtonClick(n)})}),this._attachPaginationListeners(),this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)&&this._attachVirtualScrollListeners(),this._fixedHeader()&&this._fixedControls()&&queueMicrotask(()=>{this._syncFixedControlsChromeHeight(),requestAnimationFrame(()=>this._syncFixedControlsChromeHeight())})}_escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}_getPageFromUrl(){if(!this._tableId)return null;let e=new URLSearchParams(window.location.search).get(`mui.${this._tableId}`);if(!e)return null;let t=parseInt(e,10);return isNaN(t)||t<1?null:t}_updatePageInUrl(e){if(!this._tableId)return;let t=new URL(window.location.href),n=t.searchParams;n.set(`mui.${this._tableId}`,e.toString()),e===1&&n.set(`mui.${this._tableId}`,`1`),window.history.replaceState({},``,t.toString())}_loadPageFromUrl(){if(!this._configuration||!this._tableId)return;let e=this._getPageFromUrl();e!==null&&(this._currentPage=e,this._offset=(this._currentPage-1)*this._perPage)}};customElements.get(`mint-resource-table`)||customElements.define(`mint-resource-table`,D);var O=550,k=12,A={passive:!0},j=class extends HTMLElement{constructor(...e){super(...e),this._table=null,this._anchor=null,this._popover=null,this._menuRoot=null,this._baseId=``,this._touchTimer=null,this._touchStart=null,this._slotObserver=null,this._scrollCloseTargets=[],this._onScrollClose=()=>{this._closePopover()},this._onContextMenu=e=>{let t=e,n=this._rowTargetFromEventTarget(t.target);n&&(t.preventDefault(),this._openAtRowIndex(n.index,t.clientX,t.clientY))},this._onTouchStart=e=>{let t=e;if(!t.touches.length)return;let n=this._rowTargetFromEventTarget(t.target);if(!n)return;let r=t.touches[0];this._touchStart={x:r.clientX,y:r.clientY,rowIndex:n.index},this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null);let i=this._longPressMs();this._touchTimer=window.setTimeout(()=>{this._touchTimer=null,this._touchStart&&=(this._openAtRowIndex(this._touchStart.rowIndex,this._touchStart.x,this._touchStart.y),null)},i)},this._onTouchMove=e=>{if(!this._touchStart||this._touchTimer===null)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this._touchStart.x,r=t.clientY-this._touchStart.y;n*n+r*r>k*k&&(this._clearTouchTimer(),this._touchStart=null)},this._onTouchEnd=()=>{this._clearTouchTimer(),this._touchStart=null}}static get observedAttributes(){return[`for`,`long-press-ms`]}connectedCallback(){this.classList.add(`contents`),this._baseId=this.id?.trim()||`mint-rt-ctx-${Math.random().toString(36).slice(2,10)}`,this._anchor=document.createElement(`div`),this._anchor.id=`${this._baseId}-anchor`,this._anchor.setAttribute(`aria-hidden`,`true`),this._anchor.className=`pointer-events-none fixed z-0 h-px w-px overflow-hidden p-0 m-0 border-0 opacity-0`,document.body.appendChild(this._anchor),this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`data-mint-rt-ctx-internal`,``),this._popover.id=`${this._baseId}-popover`,this._popover.setAttribute(`trigger-id`,this._anchor.id),this._popover.setAttribute(`direction`,`down`),this._popover.setAttribute(`padding`,`0`),this._popover.setAttribute(`distance`,`6px`),this._menuRoot=document.createElement(`div`),this._menuRoot.className=`flex min-w-[11rem] flex-col gap-0.5 py-1`,this._popover.appendChild(this._menuRoot),this.appendChild(this._popover),this._slotObserver=new MutationObserver(()=>{this._hideMenuSlotSources()}),this._slotObserver.observe(this,{childList:!0}),queueMicrotask(()=>{this._hideMenuSlotSources(),this._bindTable()})}disconnectedCallback(){this._slotObserver?.disconnect(),this._slotObserver=null,this._unbindTable(),this._anchor?.remove(),this._anchor=null,this._popover?.remove(),this._popover=null,this._menuRoot=null}attributeChangedCallback(){this.isConnected&&this._bindTable()}_longPressMs(){let e=parseInt(this.getAttribute(`long-press-ms`)||``,10);return!Number.isNaN(e)&&e>100?e:O}_resolveTable(){let e=this.getAttribute(`for`)?.trim();if(e){let t=document.getElementById(e);return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:null}let t=this.previousElementSibling;return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:this.parentElement?.querySelector?.(`mint-resource-table`)??null}_hideMenuSlotSources(){for(let e of Array.from(this.children))e===this._popover||e.hasAttribute(`data-mint-rt-ctx-internal`)||e.setAttribute(`hidden`,``)}_bindTable(){this._unbindTable(),this._table=this._resolveTable(),this._table&&(this._table.addEventListener(`contextmenu`,this._onContextMenu,!0),this._table.addEventListener(`touchstart`,this._onTouchStart,{passive:!0}),this._table.addEventListener(`touchmove`,this._onTouchMove,{passive:!0}),this._table.addEventListener(`touchend`,this._onTouchEnd,{passive:!0}),this._table.addEventListener(`touchcancel`,this._onTouchEnd,{passive:!0}))}_unbindTable(){this._closePopover(),this._table&&=(this._table.removeEventListener(`contextmenu`,this._onContextMenu,!0),this._table.removeEventListener(`touchstart`,this._onTouchStart),this._table.removeEventListener(`touchmove`,this._onTouchMove),this._table.removeEventListener(`touchend`,this._onTouchEnd),this._table.removeEventListener(`touchcancel`,this._onTouchEnd),null)}_rowTargetFromEventTarget(e){if(!e||!this._table)return null;let t=e.closest?.(`tr[data-row-index], li[data-row-index]`);if(!t||!this._table.contains(t)||t.hasAttribute(`data-mint-rt-spacer`)||t.getAttribute(`data-mint-rt-placeholder`)===`true`)return null;let n=t.getAttribute(`data-row-index`);if(n==null)return null;let r=parseInt(n,10);return Number.isNaN(r)?null:{index:r}}_clearTouchTimer(){this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null)}_positionAnchor(e,t){this._anchor&&(this._anchor.style.left=`${Math.round(e)}px`,this._anchor.style.top=`${Math.round(t)}px`)}_slotTemplateElements(){return Array.from(this.children).filter(e=>e!==this._popover&&e instanceof HTMLElement&&!e.hasAttribute(`data-mint-rt-ctx-internal`))}_elementIsScrollContainer(e){let t=getComputedStyle(e);return t.overflowX===`auto`||t.overflowX===`scroll`||t.overflowY===`auto`||t.overflowY===`scroll`}_collectScrollCloseTargets(e){let t=[],n=new Set,r=e=>{!e||n.has(e)||(n.add(e),t.push(e))};r(window),e.querySelectorAll(`[id^="mint-rt-vscroll-"]`).forEach(e=>{this._elementIsScrollContainer(e)&&r(e)});let i=e.querySelector(`mint-table`);for(;i&&i!==e;)this._elementIsScrollContainer(i)&&r(i),i=i.parentElement;return this._elementIsScrollContainer(e)&&r(e),t}_detachScrollCloseListeners(){for(let e of this._scrollCloseTargets)e.removeEventListener(`scroll`,this._onScrollClose,A);this._scrollCloseTargets=[]}_attachScrollCloseListeners(e){this._detachScrollCloseListeners(),this._scrollCloseTargets=this._collectScrollCloseTargets(e);for(let e of this._scrollCloseTargets)e.addEventListener(`scroll`,this._onScrollClose,A)}_closePopover(){if(this._detachScrollCloseListeners(),!this._popover?.hasAttribute(`open`))return;let e=this._popover;typeof e.close==`function`?e.close():this._popover.removeAttribute(`open`)}_openAtRowIndex(e,t,n){this._closePopover();let r=this._resolveTable();if(!r||typeof r.getRowByIndex!=`function`||!this._popover||!this._menuRoot)return;let i=this._popover,a=this._menuRoot,o=r.getRowByIndex(e);if(o===void 0)return;let s=this._slotTemplateElements();if(!s.length)return;this._positionAnchor(t,n),a.innerHTML=``,s.forEach(t=>{if(t.hasAttribute(`data-mint-rt-ctx-if-selection`)&&!(window.getSelection?.()?.toString?.()?.trim()??``))return;let n=t.cloneNode(!0);n.removeAttribute(`hidden`),n.addEventListener(`click`,t=>{t.stopPropagation();let r=n.getAttribute(`data-context-action`)||n.querySelector?.(`[data-context-action]`)?.getAttribute(`data-context-action`)||``,i=window.getSelection?.()?.toString?.()?.trim()??``;this.dispatchEvent(new CustomEvent(`context-action`,{bubbles:!0,composed:!0,detail:{action:r,row:o,rowIndex:e,selectedText:i}})),this._closePopover()}),a.appendChild(n);let r=n;typeof r.render==`function`&&queueMicrotask(()=>r.render())}),i.removeAttribute(`open`),i.offsetHeight,i.setAttribute(`open`,`true`);let c=i;typeof c.render==`function`&&queueMicrotask(()=>c.render());let l=this._resolveTable();l&&this._attachScrollCloseListeners(l)}};customElements.get(`mint-resource-table-context-menu`)||customElements.define(`mint-resource-table-context-menu`,j);var M=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null,this._contentObserver=null,this._renderFrame=null}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(),this._observeContentMutations()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getPosition(){let e=this.getAttribute(`position`)?.toLowerCase();return e===`top`||e===`bottom`||e===`left`||e===`right`?e:`right`}isFullPage(){return this.getAttribute(`full-page`)===`true`}getWidth(){return this.getAttribute(`width`)||`320px`}getHeight(){return this.getAttribute(`height`)||``}_normalizeCssValue(e){return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:e.trim()}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),r=this.getPosition(),i=this.isFullPage(),a=this.getHeight();e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black/50 transition-opacity duration-200 z-40`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._offCanvas||(this._offCanvas=document.createElement(`div`),this.appendChild(this._offCanvas));let o=this._getPositionClasses(r,i);this._offCanvas.className=o;let s=this._offCanvas.querySelector(`.off-canvas-content`);if(s||(s=document.createElement(`div`),s.className=`off-canvas-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider shadow-xl flex flex-col pointer-events-auto`,s.style.transform=this._getTransformValue(r,!1),this._offCanvas.appendChild(s)),n?this._animateEnter():this._animateExit(),Array.from(s.classList).forEach(e=>{(e.startsWith(`w-`)||e.startsWith(`max-w-`)||e.startsWith(`md:w-`)||e.startsWith(`md:max-w-`)||e.startsWith(`sm:w-`)||e.startsWith(`sm:max-w-`))&&s.classList.remove(e)}),s.classList.remove(`h-full`,`max-h-[90vh]`,`max-h-screen`,`md:h-full`,`md:max-h-[90vh]`,`md:max-h-screen`,`sm:h-full`,`sm:max-h-[90vh]`),s.classList.remove(`has-custom-width`,`has-custom-height`),s.style.removeProperty(`--off-canvas-width`),s.style.removeProperty(`--off-canvas-height`),i)s.classList.add(`w-full`,`h-full`,`max-w-none`);else if(r===`top`||r===`bottom`)if(s.classList.add(`w-full`,`h-full`,`max-w-none`),a){let e=this._normalizeCssValue(a);s.style.setProperty(`--off-canvas-height`,e),s.classList.add(`has-custom-height`),this._ensureHeightStyle()}else s.classList.add(`md:max-h-[90vh]`,`md:h-auto`);else{s.classList.add(`w-full`,`h-full`,`max-w-none`);let e=this.getWidth(),t=this._normalizeCssValue(e);s.style.setProperty(`--off-canvas-width`,t),s.classList.add(`has-custom-width`),this._ensureWidthStyle()}this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-mint-divider flex-shrink-0`,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 c=this._headingSlot.querySelector(`mint-text`);t?(c||(c=document.createElement(`mint-text`),c.setAttribute(`size`,`sub-heading`),c.setAttribute(`bold`,`true`),this._headingSlot.appendChild(c)),c.textContent=t):c&&c.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider flex-shrink-0`,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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==l&&l.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._offCanvas&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_getPositionClasses(e,t){let n=`fixed z-50 pointer-events-none`;switch(e){case`top`:return`${n} inset-0 md:inset-x-0 md:top-0 md:bottom-auto ${t?`md:h-full`:`md:h-auto`}`;case`bottom`:return`${n} inset-0 md:inset-x-0 md:bottom-0 md:top-auto ${t?`md:h-full`:`md:h-auto`}`;case`left`:return`${n} inset-0 md:inset-y-0 md:left-0 md:right-auto ${t?`md:w-full`:`md:w-auto`}`;case`right`:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`;default:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`}}_getTransformValue(e,t){if(t)switch(e){case`top`:return`translateY(0)`;case`bottom`:return`translateY(0)`;case`left`:return`translateX(0)`;case`right`:return`translateX(0)`;default:return`translateX(0)`}else switch(e){case`top`:return`translateY(-100%)`;case`bottom`:return`translateY(100%)`;case`left`:return`translateX(-100%)`;case`right`:return`translateX(100%)`;default:return`translateX(100%)`}}_updateBackgroundColor(){if(!this._offCanvas)return;let e=document.documentElement.classList.contains(`dark`),t=this._offCanvas.querySelector(`.off-canvas-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`,`border`,`border-mint-divider`)):(t.classList.remove(`bg-mint-elevated`,`border`,`border-mint-divider`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_animateEnter(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e)return;let t=this.getPosition();e.style.transform=this._getTransformValue(t,!1),e.style.transition=`transform 300ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=this._getTransformValue(t,!0)})})}_animateExit(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e){this.classList.add(`hidden`);return}let t=this.getPosition();e.style.transition=`transform 300ms ease-in`,e.style.transform=this._getTransformValue(t,!1),setTimeout(()=>{this.classList.add(`hidden`),e.style.transform=``,e.style.transition=``},300)}_ensureWidthStyle(){if(!document.getElementById(`off-canvas-width-style`)){let e=document.createElement(`style`);e.id=`off-canvas-width-style`,e.textContent=`
|
|
82
|
+
`,n.classList.add(`mint-date-shortcuts-row`),document.head.querySelector(`style[data-mint-date-shortcuts]`)||(r.setAttribute(`data-mint-date-shortcuts`,`true`),document.head.appendChild(r));let i=document.createElement(`div`);i.className=`absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-mint-elevated to-transparent opacity-0 md:hidden`,t.appendChild(i);let 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-mint-elevated to-transparent opacity-100 md:hidden`,t.appendChild(a);let s=document.createElement(`div`);s.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-mint-elevated to-transparent opacity-0`,t.appendChild(s);let l=document.createElement(`div`);l.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-mint-elevated to-transparent opacity-100`,t.appendChild(l);let u=()=>{if(window.innerWidth>=768){let e=n.scrollTop,t=n.scrollHeight,r=n.clientHeight;e>0?s.style.opacity=`1`:s.style.opacity=`0`,e+r<t-1?l.style.opacity=`1`:l.style.opacity=`0`,i.style.opacity=`0`,a.style.opacity=`0`}else{let e=n.scrollLeft,t=n.scrollWidth,r=n.clientWidth;e>0?i.style.opacity=`1`:i.style.opacity=`0`,e+r<t-1?a.style.opacity=`1`:a.style.opacity=`0`,s.style.opacity=`0`,l.style.opacity=`0`}};n.addEventListener(`scroll`,u),window.addEventListener(`resize`,u),setTimeout(u,0),o.forEach(e=>{let t=document.createElement(`button`);t.type=`button`,t.tabIndex=0,t.className=`px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-mint-hover text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-mint-elevated 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`,t.textContent=e.label,t.setAttribute(`data-keep-popover-open`,`true`);let r=()=>{let t=e.action();if(t){if(this._isRange&&`start`in t&&`end`in t){this._selectedStartDate=t.start,this._selectedEndDate=t.end;let e=this.getFormat(),n=`${this._formatDate(t.start,e)} - ${this._formatDate(t.end,e)}`;this.setValue(n),this._currentMonth=t.start.getMonth(),this._currentYear=t.start.getFullYear()}else if(t instanceof Date){this._selectedStartDate=t,this._selectedEndDate=null;let e=this.getFormat(),n=this._formatDate(t,e);this.setValue(n),this._currentMonth=t.getMonth(),this._currentYear=t.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}))}};t.addEventListener(`click`,r),t.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),n.appendChild(t)}),t.appendChild(n),e.appendChild(t),c.appendChild(e)}l.appendChild(u),l.appendChild(b),l.appendChild(x),c.appendChild(l),this._calendarContainer.appendChild(c)}_buildMonthView(){if(!this._calendarContainer)return;let 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`;let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let r=document.createElement(`mint-icon`);r.setAttribute(`name`,`caret-left`),r.className=`w-4 h-4`,n.appendChild(r);let i=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear--,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};n.addEventListener(`click`,i),n.addEventListener(`touchend`,e=>{e.preventDefault(),i()},{passive:!1}),t.appendChild(n);let a=document.createElement(`button`);a.type=`button`,a.tabIndex=0,a.className=`text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer 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`,a.setAttribute(`data-keep-popover-open`,`true`),a.textContent=String(this._currentYear);let o=()=>{this.getMode()!==`year`&&(this._viewMode=`year`,this._buildCalendar())};a.addEventListener(`click`,o),a.addEventListener(`touchend`,e=>{e.preventDefault(),o()},{passive:!1}),t.appendChild(a);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear++,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),t.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`,e.forEach((e,t)=>{let n=document.createElement(`button`);n.type=`button`,n.tabIndex=0,n.setAttribute(`data-keep-popover-open`,`true`),n.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentMonth===t?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,n.textContent=e;let r=()=>{if(this.getMode()===`month`){let e=new Date(this._currentYear,t,1),n=this.getFormat(),r=this._formatDate(e,n);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentMonth=t,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else{let e=this._currentMonth,n=this._currentYear;this._currentMonth=t,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,n,this._currentMonth,this._currentYear)}};n.addEventListener(`click`,r),n.addEventListener(`touchend`,e=>{e.preventDefault(),r()},{passive:!1}),u.appendChild(n)}),this._calendarContainer.appendChild(t),this._calendarContainer.appendChild(u)}_buildYearView(){if(!this._calendarContainer)return;let e=this._currentYear-6,t=this._currentYear+6,n=document.createElement(`div`);n.className=`flex items-center justify-between mb-4`;let r=document.createElement(`button`);r.type=`button`,r.tabIndex=0,r.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`,r.setAttribute(`data-keep-popover-open`,`true`);let i=document.createElement(`mint-icon`);i.setAttribute(`name`,`caret-left`),i.className=`w-4 h-4`,r.appendChild(i);let a=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear-=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};r.addEventListener(`click`,a),r.addEventListener(`touchend`,e=>{e.preventDefault(),a()},{passive:!1}),n.appendChild(r);let o=document.createElement(`div`);o.className=`text-sm font-medium text-gray-900 dark:text-gray-100`,o.textContent=`${e} - ${t}`,n.appendChild(o);let s=document.createElement(`button`);s.type=`button`,s.tabIndex=0,s.className=`p-1 rounded hover:bg-gray-100 dark:hover:bg-mint-hover text-gray-600 dark:text-gray-300 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`);let c=document.createElement(`mint-icon`);c.setAttribute(`name`,`caret-right`),c.className=`w-4 h-4`,s.appendChild(c);let l=()=>{let e=this._currentMonth,t=this._currentYear;this._currentYear+=12,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)};s.addEventListener(`click`,l),s.addEventListener(`touchend`,e=>{e.preventDefault(),l()},{passive:!1}),n.appendChild(s);let u=document.createElement(`div`);u.className=`grid grid-cols-3 gap-2`;for(let n=e;n<=t;n++){let e=document.createElement(`button`);e.type=`button`,e.tabIndex=0,e.setAttribute(`data-keep-popover-open`,`true`),e.className=`p-2 rounded text-sm font-medium focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${this._currentYear===n?`bg-slate-800 dark:bg-slate-600 text-white`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-mint-hover`}`,e.textContent=String(n),e.addEventListener(`click`,()=>{let e=this.getMode();if(e===`year`){let e=new Date(n,0,1),t=this.getFormat(),r=this._formatDate(e,t);this.setValue(r),this._selectedStartDate=e,this._selectedEndDate=null;let i=this._currentMonth,a=this._currentYear;this._currentYear=n,this._currentMonth=0,this._dispatchMonthChangeEvent(i,a,this._currentMonth,this._currentYear),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})),this._dispatchDateChangeEvent(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(e===`month`){let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`month`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}else{let e=this._currentMonth,t=this._currentYear;this._currentYear=n,this._viewMode=`calendar`,this._buildCalendar(),this._dispatchMonthChangeEvent(e,t,this._currentMonth,this._currentYear)}}),u.appendChild(e)}this._calendarContainer.appendChild(n),this._calendarContainer.appendChild(u)}_getDaysInMonth(e,t){return new Date(t,e+1,0).getDate()}_getFirstDayOfMonth(e,t){let n=this.getWeekStartDay(),r=new Date(t,e,1).getDay();return r>=n?r-n:7-(n-r)}_isToday(e){let t=new Date;return e.getDate()===t.getDate()&&e.getMonth()===t.getMonth()&&e.getFullYear()===t.getFullYear()}_isDateSelected(e){let t=this.getSelectionMode();return this._isRange||t===`week`||t===`month`?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(e,this._selectedStartDate)||this._isSameDate(e,this._selectedEndDate):this._isRange&&this._selectedStartDate&&!this._selectedEndDate?this._isSameDate(e,this._selectedStartDate):!1:this._selectedStartDate!==null&&this._isSameDate(e,this._selectedStartDate)}_isDateInRange(e){let t=this.getSelectionMode();if((this._isRange||t===`week`||t===`month`)&&this._selectedStartDate&&this._selectedEndDate)return this._rangeIncludesDisabledDates(this._selectedStartDate,this._selectedEndDate)?!1:e>=this._selectedStartDate&&e<=this._selectedEndDate;if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate){let t=this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,n=this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate;if(this._rangeIncludesDisabledDates(t,n)){let r=this._findFirstDisabledDateInRange(t,n);return r?this._selectedStartDate<this._hoveredDate?e>=t&&e<r&&!this._isSameDate(e,t):e>r&&e<=n&&!this._isSameDate(e,n):!1}return e>=t&&e<=n&&!this._isSameDate(e,t)&&!this._isSameDate(e,n)}return!1}_rangeIncludesDisabledDates(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate());return n.some(e=>{let t=new Date(e.getFullYear(),e.getMonth(),e.getDate());return t>=r&&t<=i})}_findFirstDisabledDateInRange(e,t){let n=this.getDisabledDates(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()),i=new Date(t.getFullYear(),t.getMonth(),t.getDate()),a=n.map(e=>new Date(e.getFullYear(),e.getMonth(),e.getDate())).filter(e=>e>=r&&e<=i).sort((e,t)=>e.getTime()-t.getTime());return a.length>0?a[0]:null}_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()}_isDateDisabled(e){return this.getDisabledDates().some(t=>this._isSameDate(e,t))}_dispatchMonthChangeEvent(e,t,n,r){(e!==n||t!==r)&&this.dispatchEvent(new CustomEvent(`month-change`,{detail:{month:n,year:r,oldMonth:e,oldYear:t},bubbles:!0,cancelable:!0,composed:!0}))}_dispatchDateChangeEvent(){let e=this.getFormat(),t={value:this.getValue()};this._selectedStartDate&&(t.startDate=this._selectedStartDate,t.startDateFormatted=this._formatDate(this._selectedStartDate,e)),this._selectedEndDate&&(t.endDate=this._selectedEndDate,t.endDateFormatted=this._formatDate(this._selectedEndDate,e)),this.dispatchEvent(new CustomEvent(`date-change`,{detail:t,bubbles:!0,cancelable:!0,composed:!0}))}_setupContainerObserver(){if(this._resizeObserver&&=(this._resizeObserver.disconnect(),null),!this._inputsWrapperEl)return;let e=e=>{this._inputsWrapperEl&&(e<400?(this._inputsWrapperEl.classList.add(`flex-wrap`),this._inputsWrapperEl.classList.remove(`flex-nowrap`)):(this._inputsWrapperEl.classList.remove(`flex-wrap`),this._inputsWrapperEl.classList.add(`flex-nowrap`)))};e(this._inputsWrapperEl.offsetWidth||this.offsetWidth),this._resizeObserver=new ResizeObserver(t=>{for(let n of t){let t=n.contentRect.width;e(t)}}),this._resizeObserver.observe(this)}_getWeekStart(e){let t=this.getWeekStartDay(),n=e.getDay(),r;r=n>=t?n-t:7-(t-n);let i=new Date(e);return i.setDate(e.getDate()-r),i.setHours(0,0,0,0),i}_getWeekEnd(e){let t=this._getWeekStart(e),n=new Date(t);return n.setDate(t.getDate()+6),n.setHours(23,59,59,999),n}_getMonthStart(e){let t=new Date(e.getFullYear(),e.getMonth(),1);return t.setHours(0,0,0,0),t}_getMonthEnd(e){let t=new Date(e.getFullYear(),e.getMonth()+1,0);return t.setHours(23,59,59,999),t}_handleDateClick(e){this._isHandlingClick=!0;try{let t=this.getFormat(),n=this.getSelectionMode(),r,i;if(n===`week`?(r=this._getWeekStart(e),i=this._getWeekEnd(e)):n===`month`?(r=this._getMonthStart(e),i=this._getMonthEnd(e)):(r=e,i=e),this.isRange()||n===`week`||n===`month`)if(n===`week`||n===`month`){if(this._rangeIncludesDisabledDates(r,i)){this._buildCalendar();return}this._selectedStartDate=r,this._selectedEndDate=i;let e=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else if(this._hoveredDate=null,this._selectedStartDate===null){if(this._isDateDisabled(r)){this._buildCalendar();return}this._selectedStartDate=new Date(r.getFullYear(),r.getMonth(),r.getDate()),this._selectedEndDate=null,this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear(),this._hoveredDate=null,this._buildCalendar()}else if(this._selectedEndDate===null){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=this._selectedStartDate?new Date(this._selectedStartDate.getFullYear(),this._selectedStartDate.getMonth(),this._selectedStartDate.getDate()):null,i,a;if(r&&n<r?(i=n,a=r):(i=r,a=n),this._rangeIncludesDisabledDates(i,a)){this._buildCalendar();return}r&&n<r?(this._selectedEndDate=r,this._selectedStartDate=n):(this._selectedEndDate=n,r&&(this._selectedStartDate=r)),this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();let o=`${this._formatDate(this._selectedStartDate,t)} - ${this._formatDate(this._selectedEndDate,t)}`;this.setAttribute(`value`,o),this._textInput&&(this._textInput.value=o),this._hiddenInput&&(this._hiddenInput.value=o),this._updateDisplayText(),this._buildCalendar(),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}else this._selectedStartDate=r,this._selectedEndDate=null;else{this._selectedStartDate=r,this._selectedEndDate=null;let e=this._formatDate(r,t);this.setValue(e),this._textInput&&(this._textInput.value=e),this._popover&&typeof this._popover.close==`function`&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();let a=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this._dispatchDateChangeEvent()}finally{this._isHandlingClick=!1}}_updateDisplayText(){if(!this._displayEl)return;let e=this.getDisplayFormat(),t=this.getSelectionMode(),n=this._isRange||t===`week`||t===`month`,r=``;n&&this._selectedStartDate&&this._selectedEndDate?r=`${this._formatDatePhp(this._selectedStartDate,e)} - ${this._formatDatePhp(this._selectedEndDate,e)}`:this._selectedStartDate&&(r=this._formatDatePhp(this._selectedStartDate,e)),r?(this._displayEl.textContent=r,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)){let 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`),n=this._fieldsContainer,r=this._input;if(e){t||(t=document.createElement(`div`),t.className=`mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none`,r?(r.classList.contains(`relative`)||r.classList.add(`relative`),r.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-date-picker-skeleton`);e||(e=document.createElement(`div`),e.className=`mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.height=`2.25rem`,t.appendChild(e)),t.style.display=`block`,n&&(n.style.visibility=`hidden`,n.style.pointerEvents=`none`),this._displayEl&&(this._displayEl.style.visibility=`hidden`,this._displayEl.style.pointerEvents=`none`)}else t&&(t.style.display=`none`),n&&(n.style.visibility=`visible`,n.style.pointerEvents=`auto`),this._displayEl&&(this._displayEl.style.visibility=`visible`,this._displayEl.style.pointerEvents=`auto`)}_getFocusableElements(){if(!this._calendarContainer)return[];let 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(e=>{let t=window.getComputedStyle(e);return t.display!==`none`&&t.visibility!==`hidden`})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute(`open`))return;this._removeFocusTrap();let e=this;this._focusTrapHandler=function(t){if(t.key!==`Tab`)return;if(!e._popover||!e._popover.hasAttribute(`open`)){e._removeFocusTrap();return}let n=e._getFocusableElements();if(n.length===0)return;let r=n[0],i=n[n.length-1],a=document.activeElement;if(!e._calendarContainer?.contains(a)){t.preventDefault(),r.focus();return}if(t.shiftKey&&a===r){t.preventDefault(),i.focus();return}if(!t.shiftKey&&a===i){t.preventDefault(),r.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(()=>{let e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&=(document.removeEventListener(`keydown`,this._focusTrapHandler,!0),null),this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler,!0),null)}};customElements.get(`mint-date-picker`)||customElements.define(`mint-date-picker`,S);var C=class extends HTMLElement{static get observedAttributes(){return[`name`,`value`,`disabled`,`id`,`required`,`label`,`info`,`error`,`error-message`,`multiple`,`loading`]}constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`,`w-full`),this.getLabel()||console.error(`mint-select: The "label" attribute is required. Please provide a label for the select.`),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(e=>{let t=Array.from(e.addedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`))||Array.from(e.removedNodes).some(e=>e.nodeType===Node.ELEMENT_NODE&&(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)),n=e.type===`attributes`&&e.target.nodeType===Node.ELEMENT_NODE&&(e.target.tagName===`OPTION`||e.target.tagName===`OPTGROUP`);return t||n})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`value`,`selected`,`disabled`]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=null),this._optionObserver&&=(this._optionObserver.disconnect(),null),this._childrenObserver&&=(this._childrenObserver.disconnect(),null)}isLoading(){return this.getAttribute(`loading`)===`true`}attributeChangedCallback(e,t,n){if(t!==n){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=n||``);return}this.render()}}getName(){return this.getAttribute(`name`)||``}getValue(){return this.hasAttribute(`value`)?this.getAttribute(`value`)||``:this._select?this._select.value:``}setValue(e){let t=e||``;this.setAttribute(`value`,t),this._select&&(this._select.value=t)}get value(){try{return this.getValue()||``}catch{return``}}set value(e){try{let t=e||``;(this.getAttribute(`value`)||``)!==t&&this.setAttribute(`value`,t),this._select&&requestAnimationFrame(()=>{this._select&&(t===``||Array.from(this._select.options).some(e=>e.value===t))&&this._select.value!==t&&(this._select.value=t)})}catch{}}isDisabled(){return this.getAttribute(`disabled`)===`true`}isMultiple(){return this.getAttribute(`multiple`)===`true`}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getId(){return this.getAttribute(`id`)||``}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getSelectClasses(){let e=this.hasError(),t=this.isMultiple(),n=[`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-mint-elevated`,`text-gray-900`,`dark:text-white`,`outline-none`,`focus:outline-none`,`disabled:opacity-40`,`disabled:cursor-not-allowed`,`appearance-none`,`bg-no-repeat`,`bg-right`,`cursor-pointer`],r=[`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`],i=[`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[...n,...r,...i].filter(Boolean).join(` `)}render(){let e=this.isLoading(),t=[];this._select&&Array.from(this._select.children).forEach(e=>{(e.tagName===`OPTION`||e.tagName===`OPTGROUP`)&&t.push(e.cloneNode(!0))});let n=Array.from(this.children).filter(e=>e.tagName===`OPTION`||e.tagName===`OPTGROUP`).map(e=>e.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;let r=this.getLabel(),i=this.getInfo(),a=this.getId(),o=this.getName(),s=this.getValue(),c=this.isDisabled(),l=this.isMultiple(),u=this.hasError();if(r){let e=document.createElement(`label`);e.className=`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,a&&e.setAttribute(`for`,a);let t=document.createTextNode(r);e.appendChild(t),this.appendChild(e)}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(),a&&(this._select.id=a),o&&(this._select.name=o),c&&(this._select.disabled=!0),l&&(this._select.multiple=!0),this._select.setAttribute(`aria-invalid`,u?`true`:`false`);let d=n.length>0?n:t;if(d.length>0&&d.forEach(e=>{this._select.appendChild(e)}),this._select.options.length===0){let e=document.createElement(`option`);e.value=``,e.textContent=`Select an option`,e.disabled=!0,e.selected=!0,this._select.appendChild(e)}if(this._select.value=s||``,this._changeHandler&&this._select&&this._select.removeEventListener(`change`,this._changeHandler),this._changeHandler=e=>{let t=e.target.value;(this.getAttribute(`value`)||``)!==t&&(t?this.setAttribute(`value`,t):this.removeAttribute(`value`));let n=new Event(`input`,{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent(`input`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener(`change`,this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{let e=this.getAttribute(`value`)||this.value||``;this._select&&e&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(t=>t.value===e)&&this._select.value!==e&&(this._select.value=e)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),l)this._caretUpIcon=null,this._caretDownIcon=null;else{let e=document.createElement(`div`);e.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]`,e.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]`,e.appendChild(this._caretDownIcon),this._wrapper.appendChild(e)}if(i){let e=document.createElement(`div`);e.className=`mt-1 text-xs text-gray-500 dark:text-gray-400`,e.textContent=i,this.appendChild(e)}this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this.querySelector(`.mint-select-skeleton-container`),n=this._wrapper;if(e){t||(t=document.createElement(`div`),t.className=`mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-select-skeleton`);if(!e){e=document.createElement(`div`),e.className=`mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`;let n=this.isMultiple();e.style.height=n?`6rem`:`2.25rem`,t.appendChild(e)}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(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-select-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-select-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}};customElements.get(`mint-select`)||customElements.define(`mint-select`,C);var w=class extends HTMLElement{static get observedAttributes(){return[`label`,`accept`,`multiple`,`width`,`height`,`disabled`,`name`,`error`,`error-message`,`loading`]}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}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){let e=this.closest(`form`);e&&e.removeEventListener(`reset`,this._resetHandler),this._resetHandler=null}}attributeChangedCallback(e,t,n){if(t!==n){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.getAttribute(`multiple`)===`true`}getWidth(){return this.getAttribute(`width`)||`200px`}getHeight(){return this.getAttribute(`height`)||`200px`}_renderSkeleton(e){let t=this.querySelector(`.mint-dropzone-skeleton-container`),n=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`,n?(n.classList.contains(`relative`)||n.classList.add(`relative`),n.appendChild(t)):(this.style.position=`relative`,this.appendChild(t)));let e=t.querySelector(`.mint-dropzone-skeleton`);if(e||(e=document.createElement(`div`),e.className=`mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-mint-divider bg-gray-200 dark:bg-mint-hover animate-pulse`,e.style.width=`100%`,e.style.height=`100%`,t.appendChild(e)),t.style.display=`flex`,n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`hidden`,t.style.pointerEvents=`none`}if(t){let e=t;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}if(r){let e=r;e.style.visibility=`hidden`,e.style.pointerEvents=`none`}i&&(i.style.visibility=`hidden`,i.style.pointerEvents=`none`),n.style.pointerEvents=`none`}}else if(t&&(t.style.display=`none`),n){let e=n.querySelector(`.mint-dropzone-icon`),t=n.querySelector(`.mint-dropzone-label`),r=n.querySelector(`.mint-dropzone-previews-wrapper`),i=this._fileInput;if(e){let t=e;t.style.visibility=`visible`,t.style.pointerEvents=`auto`}if(t){let e=t;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}if(r){let e=r;e.style.visibility=`visible`,e.style.pointerEvents=`auto`}i&&(i.style.visibility=`visible`,i.style.pointerEvents=`auto`),n.style.pointerEvents=`auto`}}getName(){return this.getAttribute(`name`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}isDisabled(){return this.getAttribute(`disabled`)===`true`}isLoading(){return this.getAttribute(`loading`)===`true`}render(){let e=this.isLoading(),t=this.getLabel(),n=this.getAccept(),r=this.isMultiple(),i=this.isDisabled(),a=this.getWidth(),o=this.getHeight(),s=this.getName(),c=this.hasError(),l=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement(`div`),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute(`aria-invalid`,c?`true`:`false`),i?(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=a,this._dropzone.style.height=o,this._dropzone.style.minWidth=a,this._dropzone.style.minHeight=o,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=n,this._fileInput.multiple=r,this._fileInput.disabled=i,s?this._fileInput.name=s:this._fileInput.removeAttribute(`name`),this._fileInput.setAttribute(`aria-invalid`,c?`true`:`false`);let u=this._dropzone.querySelector(`.mint-dropzone-icon`),d=this._dropzone.querySelector(`.mint-dropzone-label`);u&&u.remove(),d&&d.remove();let f=document.createElement(`div`);f.className=`mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0`;let p=document.createElement(`mint-icon`);if(p.setAttribute(`name`,`upload`),p.className=`w-12 h-12 text-gray-400 dark:text-gray-500`,f.appendChild(p),this._dropzone.appendChild(f),t){let e=document.createElement(`div`);e.className=`mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0`,e.textContent=t,this._dropzone.appendChild(e)}this.setupEventListeners(),this._renderErrorState(c,l),this._renderPreviews(),this._renderSkeleton(e)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(e,t){let n=this.querySelector(`.mint-dropzone-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_updateDragStateClass(){if(!this._dropzone)return;let e=this.isDisabled(),t=this.hasError(),n=`relative border-2 border-dashed rounded-lg flex flex-col items-center ${this._selectedFiles.length>0?`justify-start`:`justify-center`} cursor-pointer overflow-hidden`,r=this._isDragging?`border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-mint-elevated dark:border-mint-divider`:`border-gray-300 dark:border-mint-divider bg-white dark:bg-mint-elevated dark:border-mint-divider hover:border-gray-400 dark:hover:border-mint-divider`,i=t?`border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30`:``,a=e?`opacity-40 cursor-not-allowed`:``;this._dropzone.className=`${n} ${t?i:r} ${a} focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||=e=>{if(!(this.isDisabled()||!this._fileInput)&&e.target!==this._fileInput&&(e.stopPropagation(),e.preventDefault(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onDragOver||=e=>{e.preventDefault(),e.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())},this._onDragLeave||=e=>{e.preventDefault(),e.stopPropagation();let t=this._dropzone?.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||=e=>{if(e.preventDefault(),e.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;let t=e.dataTransfer?.files;t&&t.length>0&&this._handleFiles(t)},this._onFileInputInput||=e=>{e.stopImmediatePropagation(),e.stopPropagation()},this._onKeyDown||=e=>{if(!(this.isDisabled()||!this._fileInput)&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),e.stopPropagation(),e.isTrusted))try{this._fileInput.click()}catch(e){console.debug(`File chooser blocked:`,e)}},this._onFocus||=e=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add(`focus-visible:ring-2`)},this._onBlur||=e=>{this._dropzone},this._onFileInputChange||=e=>{if(e.stopImmediatePropagation(),e.stopPropagation(),this._isUpdatingFiles)return;let t=e.target.files;if(t&&t.length>0){let e=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<t.length;n++){let a=t[n];this._isFileAccepted(a,e)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}},this._dropzone.addEventListener(`click`,this._onDropzoneClick),this._dropzone.addEventListener(`dragover`,this._onDragOver),this._dropzone.addEventListener(`dragleave`,this._onDragLeave),this._dropzone.addEventListener(`drop`,this._onDrop),this._dropzone.addEventListener(`keydown`,this._onKeyDown),this._dropzone.addEventListener(`focus`,this._onFocus),this._dropzone.addEventListener(`blur`,this._onBlur),this._fileInput.addEventListener(`change`,this._onFileInputChange),this._fileInput.addEventListener(`input`,this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener(`click`,this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener(`dragover`,this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener(`dragleave`,this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener(`drop`,this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener(`keydown`,this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener(`focus`,this._onFocus),this._onBlur&&this._dropzone.removeEventListener(`blur`,this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener(`change`,this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener(`input`,this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(e){let t=this.getAccept(),n=this.isMultiple(),r=[],i=[];for(let n=0;n<e.length;n++){let a=e[n];this._isFileAccepted(a,t)?r.push(a):i.push(a)}if(!n&&r.length>1&&(i.push(...r.slice(1)),r.splice(1)),i.length>0){let e=new CustomEvent(`dropRejected`,{detail:{files:i,reason:`File type not accepted or multiple files not allowed`},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}r.length>0&&this._applyValidFiles(r)}_isFileAccepted(e,t){if(!t)return!0;let n=t.split(`,`).map(e=>e.trim().toLowerCase());for(let t of n)if(t.startsWith(`.`)){if(`.`+e.name.split(`.`).pop()?.toLowerCase()===t)return!0}else if(t.includes(`/*`)){if(t.split(`/`)[0]===e.type.split(`/`)[0])return!0}else if(e.type===t)return!0;return!1}_dispatchEvent(e,t){let n=t.target,r=new CustomEvent(e,{detail:{files:n.files?Array.from(n.files):[],value:n.value||``},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}_dispatchSelectionEvents(){let e={files:[...this._selectedFiles],value:``};this.dispatchEvent(new CustomEvent(`input`,{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`change`,{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;let e=new DataTransfer;this._selectedFiles.forEach(t=>{try{e.items.add(t)}catch(e){console.warn(`Failed to add file to DataTransfer:`,e)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=e.files}catch(e){console.warn(`Failed to set files on input:`,e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){return this._syncFileInputFromSelected(),this._fileInput?.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}let e=document.createElement(`div`);e.className=`mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48`;let 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((e,n)=>{let r=document.createElement(`div`);if(r.className=`flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-mint-divider bg-gray-50 dark:bg-mint-elevated`,e.type.startsWith(`image/`)){let t=document.createElement(`img`);t.className=`w-12 h-12 object-cover rounded border border-gray-200 dark:border-mint-divider`;let n=URL.createObjectURL(e);this._previewUrls.push(n),t.src=n,r.appendChild(t)}else{let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`attach`),e.className=`w-5 h-5 text-gray-500 dark:text-gray-300`,r.appendChild(e)}let i=document.createElement(`div`);i.className=`flex-1 text-sm text-gray-800 dark:text-gray-100 truncate`,i.textContent=e.name,r.appendChild(i);let a=document.createElement(`button`);a.type=`button`,a.className=`text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 flex items-center justify-center w-6 h-6 rounded-full`;let o=document.createElement(`mint-icon`);o.setAttribute(`name`,`close`),o.className=`w-4 h-4`,a.appendChild(o),a.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this._removeFileAt(n)}),r.appendChild(a),t.appendChild(r)});let n=this.hasError(),r=this._isDragging,i=`from-white dark:from-mint-elevated`;n?i=`from-red-50 dark:from-red-900/30`:r&&(i=`from-gray-50 dark:from-mint-elevated`);let a=document.createElement(`div`);a.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${i} to-transparent opacity-0`,e.appendChild(a);let o=document.createElement(`div`);o.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${i} to-transparent opacity-100`,e.appendChild(o);let s=()=>{let e=t.scrollTop,n=t.scrollHeight,r=t.clientHeight;e>0?a.style.opacity=`1`:a.style.opacity=`0`,e+r<n-1?o.style.opacity=`1`:o.style.opacity=`0`};s(),t.addEventListener(`scroll`,s),e.appendChild(t),this._previewContainer=e,this._dropzone.appendChild(e),this._updateDragStateClass()}_removeFileAt(e){if(e<0||e>=this._selectedFiles.length)return;let[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(){let 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()){let t=e.filter(e=>!this._isDuplicateFile(e));this._selectedFiles.push(...t)}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`,w);var T=class extends HTMLElement{static get observedAttributes(){return[`action`,`method`,`enctype`,`data-form-data`,`loading`,`headers`]}constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();let e=this.getAttribute(`headers`);e&&this._parseHeaders(e),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||=this._createDataSnapshot(this._formData),this._applyFormData();else{let e=this.getAttribute(`data-form-data`);e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener(`submit`,this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener(`submit`,this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(e,t,n){e===`form-data`?(this._parseFormData(n),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):e===`headers`?this._parseHeaders(n):e===`loading`?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(e){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,e&&typeof e==`object`&&!Array.isArray(e)?(this._formData=e,this._isReactiveObject(e)?this._setupReactiveDataObserver(e):this._lastDataSnapshot=this._createDataSnapshot(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;let e=this.getAttribute(`action`)||``,t=this.getAttribute(`method`)||``,n=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;e&&(this._form.action=e),t&&(this._form.method=t),this._form.enctype=n}async _handleSubmit(e){if(e.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();let t=this._collectValidationRules(),n=new FormData(this._form),r=this._formDataToValues(n);if(this._formData){let e=this._getReactiveValue(this._formData);e&&typeof e==`object`&&!Array.isArray(e)&&(r={...this._extractReactiveData(e),...r})}if(!this._validate(r,t)){this.dispatchEvent(new CustomEvent(`invalid`,{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}let i=new CustomEvent(`submit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i),i.form=this;let a=new CustomEvent(`mintFormSubmit`,{detail:{formData:n,values:r,form:this},bubbles:!0,cancelable:!0,composed:!0});if(a.form=this,this.dispatchEvent(a),i.defaultPrevented||a.defaultPrevented)return;let o=this.getAttribute(`action`),s=this.getAttribute(`method`);if(!(!o||!s)){this._setButtonsSubmitting();try{let e=await this._submitData(n,r);this.dispatchEvent(new CustomEvent(`submitsuccess`,{detail:e,bubbles:!0,cancelable:!0}))}catch(e){e?.status===422&&e?.data?.errors&&this._applyServerErrors(e.data.errors),this.dispatchEvent(new CustomEvent(`submiterror`,{detail:{error:e},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(e,t){let n=this.getAttribute(`action`),r=this.getAttribute(`method`),i=this.getAttribute(`enctype`)||`application/x-www-form-urlencoded`;if(!n)return{status:0,ok:!0,data:{values:t}};let a=Array.from(e.values()).some(e=>e instanceof File),o=null,s={},c=n;if(typeof window<`u`&&window.mintForm?.defaults?.headers?.common&&Object.assign(s,window.mintForm.defaults.headers.common),this._headers&&Object.assign(s,this._headers),r===`GET`){let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),c+=(n.includes(`?`)?`&`:`?`)+t.toString()}else if(i===`multipart/form-data`||a)o=e;else if(i===`application/json`)o=JSON.stringify(t),s[`Content-Type`]=`application/json`;else{let t=new URLSearchParams;e.forEach((e,n)=>{e instanceof File||t.append(n,String(e))}),o=t,s[`Content-Type`]=`application/x-www-form-urlencoded`}if(typeof fetch==`function`)try{let e=await fetch(c,{method:r||`POST`,body:r===`GET`?null:o,headers:s}),t=await e.text().catch(()=>``),n=t;try{n=JSON.parse(t)}catch{}if(!e.ok){let t={status:e.status,data:n,response:{status:e.status,data:n}};throw await this._applyErrorInterceptors(t)}let i={status:e.status,ok:e.ok,data:n};return await this._applySuccessInterceptors(i)}catch(e){if(e.response)throw e;let t={status:e.status||0,data:e.data||e.message||`Network error`,response:{status:e.status||0,data:e.data||e.message||`Network error`}};throw await this._applyErrorInterceptors(t)}let l=this;return await new Promise(async(e,t)=>{let n=new XMLHttpRequest;n.open(r||`POST`,c,!0),Object.entries(s).forEach(([e,t])=>n.setRequestHeader(e,t)),n.onload=async function(){let{status:r,responseText:i}=n;if(r>=200&&r<300){let n=i;try{n=JSON.parse(i)}catch{}try{let t={status:r,ok:!0,data:n};e(await l._applySuccessInterceptors(t))}catch(e){t(e)}}else{let e=i;try{e=JSON.parse(i)}catch{}try{let n={status:r,data:e,response:{status:r,data:e}};t(await l._applyErrorInterceptors(n))}catch(e){t(e)}}},n.onerror=async function(){try{let e={status:n.status||0,data:n.responseText||`Network error`,response:{status:n.status||0,data:n.responseText||`Network error`}};t(await l._applyErrorInterceptors(e))}catch(e){t(e)}},n.send(r===`GET`?null:o)})}async _applySuccessInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return e;let t=e,n=window.mintForm.interceptors.response.handlers;for(let e of n)e.fulfilled&&(t=await e.fulfilled(t));return t}async _applyErrorInterceptors(e){if(typeof window>`u`||!window.mintForm?.interceptors?.response?.handlers)return Promise.reject(e);let t=e,n=window.mintForm.interceptors.response.handlers;for(let e=n.length-1;e>=0;e--){let r=n[e];if(r.rejected)try{if(t=await r.rejected(t),t!==void 0)return t}catch(e){t=e}}return Promise.reject(t)}_formDataToValues(e){let t={};return e.forEach((e,n)=>{e instanceof File?(t[n]||(t[n]=[]),t[n].push(e)):n in t?Array.isArray(t[n])?(t[n].length>0&&t[n][0]instanceof File,t[n].push(e)):t[n]=[t[n],e]:t[n]=e}),this._form&&(Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n&&e.files!==void 0&&e.files){let r=e.files;if(r.length>0){let e=Array.from(r);t[n]&&Array.isArray(t[n])?e.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=e}}}),Array.from(this._form.querySelectorAll(`input[type="file"][name]`)).forEach(e=>{let n=e.name;if(n&&e.files&&e.files.length>0){let r=Array.from(e.files);t[n]&&Array.isArray(t[n])?r.forEach(e=>{t[n].some(t=>t.name===e.name&&t.size===e.size&&t.lastModified===e.lastModified)||t[n].push(e)}):t[n]=r}}),Array.from(this._form.querySelectorAll(`mint-tags[name]`)).forEach(e=>{let n=e.getAttribute(`name`);if(n){let r=[];e.tags===void 0?typeof e.getTags==`function`&&(r=e.getTags()):r=e.tags,Array.isArray(r)&&r.length>0?t[n]=r.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):t[n]=[]}})),t}_collectValidationRules(){let e={};return this._form&&Array.from(this._form.querySelectorAll(`[name][validation]`)).forEach(t=>{let n=t.getAttribute(`name`)||``,r=t.getAttribute(`validation`);if(!n||!r)return;let i=this._parseRules(r);i.length&&(e[n]=i)}),e}_parseRules(e){if(!e)return[];try{let t=e.replace(/'/g,`"`),n=JSON.parse(t);if(Array.isArray(n))return n.map(e=>String(e))}catch{}return e.split(`,`).map(e=>e.trim()).filter(Boolean)}_validate(e,t){let n=!0;return this._errors={},Object.entries(t||{}).forEach(([e,t])=>{let r=Array.isArray(t)?t:[t],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(n=!1,this._errors[e]=o,this._flagFieldError(i,o)):this._clearFieldError(i)}),n}_validateField(e){let t=this._collectValidationRules();if(!t[e])return;let n=t[e],r=Array.isArray(n)?n:[n],i=this._getFieldElements(e),a=this._extractFieldValue(i),o=this._validateRules(a,r);o?(this._errors[e]=o,this._flagFieldError(i,o)):(this._clearFieldError(i),delete this._errors[e])}_validateRules(e,t){for(let n of t){let[t,r]=n.split(`:`);switch(t){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`:{let t=Number(e);if(Number.isNaN(t))return`Must be a number.`;break}case`min`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length<t)return`Must be at least ${t} characters.`;if(Array.isArray(e)&&e.length<t)return`Select at least ${t}.`;if(e instanceof FileList&&e.length<t)return`Upload at least ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)<t)return`Must be at least ${t}.`;break}case`max`:{let t=Number(r);if(Number.isNaN(t))break;if(typeof e==`string`&&e.trim().length>t)return`Must be at most ${t} characters.`;if(Array.isArray(e)&&e.length>t)return`Select no more than ${t}.`;if(e instanceof FileList&&e.length>t)return`Upload no more than ${t} files.`;if(e!=null&&!Number.isNaN(Number(e))&&Number(e)>t)return`Must be at most ${t}.`;break}default:break}}return null}_getFieldElements(e){if(!this._form)return[];let t=Array.from(this._form.querySelectorAll(`[name="${e}"]`)),n=t.filter(e=>e.tagName===`MINT-SELECT`);if(n.length>0){let r=[];return n.forEach(t=>{let n=t.querySelector(`select[name="`+e+`"]`);n&&r.push(n)}),t.filter(e=>e.tagName!==`MINT-SELECT`).concat(r)}if(t.filter(e=>e.tagName===`MINT-TAGS`).length>0)return t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`));let r=t.filter(e=>e.tagName===`INPUT`&&e.closest(`mint-tags`));if(r.length>0){let e=[];return r.forEach(t=>{let n=t.closest(`mint-tags`);n&&!e.includes(n)&&e.push(n)}),t.filter(e=>e.tagName!==`INPUT`||!e.closest(`mint-tags`)).concat(e)}return t}_extractFieldValue(e){if(e.length===0)return``;let t=e.find(e=>e instanceof HTMLSelectElement);if(t)return t.value;if(e.length>1){let t=e.filter(e=>e instanceof HTMLInputElement);if(t.length>0&&t.length===e.length){let e=t.filter(e=>e.checked);if(t.every(e=>e.type===`radio`))return e.length>0?e[0].value||`on`:``;if(t.every(e=>e.type===`checkbox`))return e.map(e=>e.value||`on`)}let n=e.filter(e=>e.tagName===`MINT-CHOICE`);if(n.length>0&&n.length===e.length){let e=n.find(e=>typeof e.getValue==`function`?e.getValue()!==``:e.querySelector(`mint-choice-option[checked]`)!==null);if(e){if(typeof e.getValue==`function`)return e.getValue();let t=e.querySelector(`mint-choice-option[checked]`);if(t)return t.getAttribute(`value`)||``}return``}let r=e.filter(e=>e.tagName===`MINT-CHECKBOX`);if(r.length>0&&r.length===e.length)return r.filter(e=>e.checked===void 0?e.hasAttribute(`checked`):e.checked).map(e=>e.getAttribute(`value`)||`on`)}let n=e[0];if(n instanceof HTMLInputElement)return n.type===`file`?n.files:n.type===`checkbox`||n.type===`radio`?n.checked?n.value||`on`:``:n.value;if(n instanceof HTMLTextAreaElement)return n.value;if(n.tagName===`MINT-SELECT`){let e=n.querySelector(`select`);if(e)return e.value;if(typeof n.getValue==`function`){let e=n.getValue();if(e!=null&&e!==``)return e}return n.getAttribute(`value`)||``}if(n.tagName===`MINT-DROPZONE`&&n.files!==void 0)return n.files;if(n.tagName===`MINT-TAGS`){let e=null;return n.tags===void 0?typeof n.getTags==`function`&&(e=n.getTags()):e=n.tags,Array.isArray(e)?e.map(e=>typeof e==`string`?e:e?.value||e?.label||``).filter(e=>e.trim()!==``):[]}return n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`?(n.checked===void 0?n.hasAttribute(`checked`):n.checked)?n.getAttribute(`value`)||`on`:``:n.tagName===`MINT-CHOICE`?(typeof n.getValue==`function`?n.getValue():``)||``:n.value===void 0?n.getAttribute(`value`)||``:n.value}_flagFieldError(e,t){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.setAttribute(`aria-invalid`,`true`);let n=this._resolveHost(e);n&&(n.setAttribute(`error`,`true`),n.setAttribute(`error-message`,t),n.setAttribute(`data-mint-form-error`,`true`))})}_clearFieldError(e){e.length!==0&&e.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute(`aria-invalid`);let t=this._resolveHost(e);t&&(t.removeAttribute(`error`),t.removeAttribute(`error-message`),t.removeAttribute(`data-mint-form-error`))})}_clearErrors(){this.querySelectorAll(`[data-mint-form-error]`).forEach(e=>{let 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`)}),this._errors={}}setFormErrors(e){this._applyServerErrors(e)}_applyServerErrors(e){this._clearErrors(),Object.entries(e).forEach(([e,t])=>{let n=Array.isArray(t)?t[0]||`Validation error`:t||`Validation error`,r=this._getFieldElements(e);r.length>0&&(this._errors[e]=n,this._flagFieldError(r,n))})}_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;let e=this._getReactiveValue(this._formData);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=()=>{Object.entries(e).forEach(([e,t])=>{let n=this._getFieldElements(e);if(n.length===0){setTimeout(()=>{let n=this._getFieldElements(e);n.length>0&&this._applyValueToField(n,e,t)},300);return}this._applyValueToField(n,e,t)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})}_applyValueToField(e,t,n){e.forEach(e=>{let r=e.tagName;try{if(r===`MINT-INPUT`)e.value!==void 0&&(e.value=n||``);else if(r===`MINT-DATE-PICKER`)typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-SELECT`||r===`SELECT`)r===`SELECT`?e.closest(`mint-select`)?.setValue(n||``):typeof e.setValue==`function`&&e.setValue(n||``);else if(r===`MINT-CHOICE`)typeof e.setValue==`function`?e.setValue(n||``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=e.getAttribute(`value`)===n});else if(r===`MINT-CHECKBOX`||r===`MINT-SWITCH`){let t=n===!0||n===`true`||n===`on`||n===1||n===`1`;e.checked===void 0?t?e.setAttribute(`checked`,`true`):e.removeAttribute(`checked`):e.checked=t}else if(r===`MINT-TAGS`)Array.isArray(n)&&e.tags!==void 0&&(e.tags=n.map(e=>typeof e==`string`?{value:e,label:e,dismissable:!0}:e));else if(e instanceof HTMLInputElement){if(e.type===`file`)return;e.type===`checkbox`||e.type===`radio`?e.checked=n===!0||n===`true`||n===`on`||n===1||n===`1`:e.value=n||``}else (e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&(e.value=n||``)}catch(e){console.warn(`Failed to set value for field ${t}:`,e)}})}_resetCustomFields(){this.querySelectorAll(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`).forEach(e=>{e.removeAttribute(`error`),e.removeAttribute(`error-message`);let t=e.tagName;if(t===`MINT-INPUT`)try{e.value=``}catch{}else if(t===`MINT-DATE-PICKER`)try{e.setValue?.(``)}catch{}else if(t===`MINT-SELECT`)try{e.setValue?.(``)}catch{}else if(t===`MINT-DROPZONE`){let t=e.querySelector(`input[type="file"]`);t&&(t.value=``)}else if(t===`MINT-CHECKBOX`||t===`MINT-SWITCH`)try{if(e.checked!==void 0)e.checked=!1;else{e.removeAttribute(`checked`);let t=e.querySelector(`input[type="checkbox"], input[type="radio"]`);t&&(t.checked=!1)}}catch{}else if(t===`MINT-CHOICE`)try{typeof e.setValue==`function`?e.setValue(``):e.querySelectorAll(`mint-choice-option`).forEach(e=>{e.checked=!1})}catch{}else if(t===`MINT-TAGS`)try{e.tags=[]}catch{}})}_resolveHost(e){if(e.tagName===`MINT-CHOICE-OPTION`){let t=e.closest(`mint-choice`);if(t)return t}return e.closest(`mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags`)||e}_setupBlurValidation(){if(!this._form)return;let e=e=>{let t=e.target;if(!t)return;let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;let i=this._extractFieldValue([n]),a=i!=null&&(typeof i==`string`?i.trim()!==``:i instanceof FileList||Array.isArray(i)?i.length>0:!0),o=n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&(t.hasAttribute(`aria-invalid`)||t.closest(`[data-mint-form-error]`)),s=!!n.closest(`mint-tags`),c=n.tagName===`MINT-CHECKBOX`||n.tagName===`MINT-SWITCH`||n.tagName===`MINT-CHOICE`||t instanceof HTMLElement&&(t.closest(`mint-checkbox, mint-switch, mint-choice`)||t.closest(`mint-choice-option`)),l=n.tagName===`MINT-DATE-PICKER`||t instanceof HTMLElement&&t.closest(`mint-date-picker`);(a||o||s||c||l)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`blur`,e,!0),this._fieldBlurHandlers.set(this._form,e);let t=e=>{let t=e.target;if(!t)return;if(!(t instanceof HTMLInputElement&&t.type===`file`)){let e=this._findFieldElement(t),n=e?this._getFieldName(e):null;e&&n&&this._syncFieldToReactiveData(e,n)}if(e.type===`tags-change`&&t.tagName===`MINT-TAGS`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLSelectElement||t.tagName===`MINT-SELECT`||t.closest(`mint-select`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(e.type===`choice-change`&&t.tagName===`MINT-CHOICE`){let e=t,n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}if(t instanceof HTMLInputElement&&t.type===`checkbox`||t.tagName===`MINT-CHECKBOX`||t.tagName===`MINT-SWITCH`||t.closest(`mint-checkbox, mint-switch`)){let e=this._findFieldElement(t);if(!e)return;let n=this._getFieldName(e);if(!n||!this._collectValidationRules()[n])return;setTimeout(()=>{this._validateField(n)},0);return}let n=this._findFieldElement(t);if(!n)return;let r=this._getFieldName(n);r&&this._collectValidationRules()[r]&&(n.hasAttribute(`data-mint-form-error`)||t instanceof HTMLElement&&t.hasAttribute(`aria-invalid`))&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener(`change`,t,!0),this._form.addEventListener(`input`,t,!0),this._form.addEventListener(`tags-change`,t,!0),this._form.addEventListener(`choice-change`,t,!0),this._fieldChangeHandlers.set(this._form,t)}_findFieldElement(e){let 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.hasAttribute(`name`)&&(e.tagName.startsWith(`MINT-`)||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)||(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.hasAttribute(`name`))return e;let n=e;for(;n&&n!==this._form;){if(n.hasAttribute(`name`))return n;n=n.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}_syncFieldToReactiveData(e,t){if(!this._formData||!t)return;let n=this._getReactiveValue(this._formData);if(!n||typeof n!=`object`||Array.isArray(n))return;let r=this._getFieldElements(t),i=this._extractFieldValue(r.length?r:[e]);n[t]=this._normalizeReactiveValue(r,i),this._lastDataSnapshot=this._createDataSnapshot(n)}_normalizeReactiveValue(e,t){if(t instanceof FileList)return Array.from(t);if(Array.isArray(t))return t;let n=e[0];return e.length===1&&(n instanceof HTMLInputElement&&n.type===`checkbox`||n?.tagName===`MINT-CHECKBOX`||n?.tagName===`MINT-SWITCH`)?!!t:t??``}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){let 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)){let e=this._fieldChangeHandlers.get(this._form);e&&(this._form.removeEventListener(`change`,e,!0),this._form.removeEventListener(`input`,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(),null)}_syncDropzoneFiles(){this._form&&Array.from(this._form.querySelectorAll(`mint-dropzone[name]`)).forEach(e=>{typeof e.syncFiles==`function`&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;let 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(e=>{t?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=e.getAttribute(`disabled`)===`true`,n=e.getAttribute(`loading`)===`true`;this._buttonStates.set(e,{disabled:t,loading:n});let r=(e.getAttribute(`type`)||e.getAttribute(`button-type`)||`default`)===`submit`;t||e.setAttribute(`disabled`,`true`),r&&e.setAttribute(`loading`,`true`),typeof e.render==`function`&&e.render()}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=e.disabled;this._buttonStates.set(e,{disabled:t,loading:!1}),t||(e.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;let e=Array.from(this.querySelectorAll(`mint-button`)),t=Array.from(this.querySelectorAll(`button`));e.forEach(e=>{let t=this._buttonStates.get(e);t&&(t.disabled?e.setAttribute(`disabled`,`true`):e.removeAttribute(`disabled`),t.loading?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}),t.forEach(e=>{if(e.closest(`mint-button`))return;let t=this._buttonStates.get(e);t&&(e.disabled=t.disabled)}),this._buttonStates.clear()}_isReactiveObject(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;if(`__v_isRef`in e||`_value`in e||`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e)return!0;try{let t=e.toString();if(t===`[object Object]`||t.includes(`Proxy`)){let t=Object.keys(e)[0];if(t){let n=Object.getOwnPropertyDescriptor(e,t);if(n&&(n.get||n.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(e){try{let t=this._extractReactiveData(e);return JSON.parse(JSON.stringify(t))}catch{return{...this._extractReactiveData(e)}}}_extractReactiveData(e){if(!e||typeof e!=`object`)return e;if(Array.isArray(e))return e.map(e=>this._extractReactiveData(e));let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t)){let e={};for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=this._extractReactiveData(t[n]));return e}return t}_hasDataChanged(e,t){try{return JSON.stringify(e)!==JSON.stringify(t)}catch{return!0}}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupReactiveDataObserver(e){if(this._stopReactiveDataObserver(),!this.isConnected)return;let t=this._getReactiveValue(e);if(t&&typeof t==`object`&&!Array.isArray(t))this._lastDataSnapshot=this._createDataSnapshot(t);else{this._lastDataSnapshot=null;return}let n=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}let e=this._getReactiveValue(this._formData);if(e&&typeof e==`object`&&!Array.isArray(e)){let t=this._createDataSnapshot(e);this._hasDataChanged(t,this._lastDataSnapshot)&&(this._lastDataSnapshot=t,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(n):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(n)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}};customElements.get(`mint-form`)||customElements.define(`mint-form`,T),typeof window<`u`&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(e,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:e,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));var E=class extends HTMLElement{constructor(...e){super(...e),this._observer=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`align-baseline`,`block`,`w-full`,`rounded-lg`,`border`,`border-gray-200`,`dark:border-mint-divider`),this.hasAttribute(`data-mint-rt-scroll-inner`)?this.classList.add(`min-w-0`,`overflow-x-visible`,`overflow-y-visible`):this.classList.add(`min-w-0`,`overflow-x-auto`),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&=(this._observer.disconnect(),null)}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();let e=Array.from(this.querySelectorAll(`table`));if(e.length===0){this._observer&&this._observeChanges();return}let t=e.find(e=>e.querySelector(`thead`))??e[0],n=e.find(e=>e.querySelector(`tbody`))??e[0];e.forEach(e=>{let t=!!e.closest(`[id^="mint-rt-vscroll-"]`),n=!!e.closest(`mint-resource-table[data-mint-rt-fixed-header]`),r=t||n,i=[`w-full`,r?`border-separate border-spacing-0`:`border-collapse`,`text-sm`,`font-medium`,...r?[]:[`overflow-hidden`]];this._setClasses(e,i)});let r=t.querySelector(`thead`);if(r){r.classList.add(`bg-[#F7F7F7]`,`dark:bg-mint-nav`);let e=r.querySelectorAll(`th`);e.forEach((t,n)=>{let r=t.querySelector(`mint-icon`),i=r?.getAttribute(`name`)||``,a=t.hasAttribute(`data-mint-rt-sortable`)||r!==null&&i!==`ellipsis`;this._setClasses(t,[`text-left`,`font-semibold`,`text-gray-900`,`dark:text-white`,`px-3`,`py-2`,`border-b`,`border-gray-200`,`dark:border-mint-divider`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`]),a&&t.classList.add(`cursor-pointer`,`hover:bg-gray-100`,`dark:hover:bg-mint-hover`),n===0&&t.classList.add(`pl-3`),n===e.length-1&&t.classList.add(`pr-3`);let o=t.closest(`table`),s=o?.closest(`mint-resource-table`),c=!!s?.hasAttribute(`data-mint-rt-fixed-header`),l=!!s?.hasAttribute(`data-mint-rt-fixed-controls`);if(o?.closest(`[id^="mint-rt-vscroll-"]`)||c){let e=c&&l?`top-[var(--mint-rt-fixed-controls-h,0px)]`:`top-0`;t.classList.add(`sticky`,e,`z-30`,`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`shadow-sm`)}})}let i=n.querySelector(`tbody`);if(i){let e=Array.from(i.querySelectorAll(`tr`)),t=!!n.closest(`[id^="mint-rt-vscroll-"]`)||!!n.closest(`mint-resource-table`)?.hasAttribute(`data-mint-rt-fixed-header`),r=e.findIndex(e=>e.getAttribute(`data-mint-rt-spacer`)===`bottom`);e.forEach((n,i)=>{let a=n.hasAttribute(`data-mint-rt-spacer`),o=n.hasAttribute(`data-row-clickable`);a||t?this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`]):this._setClasses(n,[`bg-white`,`dark:bg-mint-canvas`,`border-b`,`border-gray-200`,`dark:border-mint-divider`]),o&&!a&&n.classList.add(`cursor-pointer`,`hover:bg-gray-50`,`dark:hover:bg-mint-elevated`),!t&&i===e.length-1&&n.classList.remove(`border-b`);let s=n.querySelectorAll(`td`);s.forEach((o,c)=>{let l=[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`];if(t&&!a){let t=n.hasAttribute(`data-mint-rt-last-row`),a=r===-1&&i===e.length-1;!t&&!a&&l.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`)}this._setClasses(o,l),c===0&&o.classList.add(`pl-3`),c===s.length-1&&o.classList.add(`pr-3`),this._restoreCell(o)})})}let a=n.querySelector(`tfoot`);a&&(this._setClasses(a,[`bg-[#F7F7F7]`,`dark:bg-mint-nav`,`font-semibold`]),a.querySelectorAll(`td`).forEach(e=>{this._setClasses(e,[`text-gray-900`,`dark:text-gray-100`,`px-3`,`py-2`,`border-t`,`border-gray-200`,`dark:border-mint-divider`]),this._restoreCell(e)})),this._observer&&this._observeChanges()}_restoreCell(e){if(e.dataset.mtProcessed!==`true`)return;let t={};Array.from(e.attributes).forEach(e=>{e.name.startsWith(`data-`)&&e.name!==`data-original`&&e.name!==`data-mt-processed`&&(t[e.name]=e.value)});let n=e.getAttribute(`data-original`)||``;e.dataset.mtProcessed=``,e.innerHTML=n,Object.entries(t).forEach(([t,n])=>{e.setAttribute(t,n)})}_setClasses(e,t){e.className=``,t.filter(Boolean).forEach(t=>e.classList.add(...t.split(` `)))}};customElements.get(`mint-table`)||customElements.define(`mint-table`,E);var D=class extends HTMLElement{constructor(...e){super(...e),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return[`dismissable`]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener(`click`,this._clickHandler)}attributeChangedCallback(){this._render()}_render(){if(this.classList.add(`inline-flex`,`items-center`,`gap-2`,`px-3`,`py-1`,`rounded-full`,`border`,`border-gray-200`,`dark:border-mint-divider`,`bg-gray-100`,`dark:bg-mint-elevated`,`text-gray-900`,`dark:text-gray-100`,`text-sm`,`font-medium`),!this._root){for(this._root=document.createElement(`div`),this._root.className=`flex items-center gap-2 w-full`,this._textWrap=document.createElement(`span`),this._textWrap.className=`inline-flex items-center min-w-[0.5rem]`,this._textWrap.setAttribute(`data-mt-chip-text`,``);this.firstChild;){let e=this.firstChild;if(e===this._root)break;this._textWrap.appendChild(e)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}let e=this.getAttribute(`dismissable`);e===``||e===`true`||this.hasAttribute(`dismissable`)?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&this._root?.appendChild(this._dismissBtn)):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){let e=document.createElement(`button`);e.type=`button`,e.setAttribute(`aria-label`,`Dismiss`),e.className=[`shrink-0`,`inline-flex`,`items-center`,`justify-center`,`w-5`,`h-5`,`rounded-full`,`text-gray-500`,`dark:text-gray-300`,`hover:text-gray-700`,`dark:hover:text-gray-100`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`border-none`,`bg-transparent`,`cursor-pointer`].join(` `);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`close`),t.className=`w-3 h-3`,e.appendChild(t),this._clickHandler=e=>{e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismiss`,{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},e.addEventListener(`click`,this._clickHandler),this._dismissBtn=e}};customElements.get(`mint-chip`)||customElements.define(`mint-chip`,D);var O=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder=`Add tag`,this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return[`tags`,`placeholder`,`sortable`,`label`,`info`,`error`,`error-message`,`name`,`id`,`required`,`loading`]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=e=>this._onPointerMove(e),window.addEventListener(`pointermove`,this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=e=>this._onPointerUp(e),window.addEventListener(`pointerup`,this._pointerUpHandler),window.addEventListener(`pointercancel`,this._pointerUpHandler))}attributeChangedCallback(e,t,n){if(t!==n){if(e===`error`||e===`error-message`){if(this._renderErrorState(),this._container){let e=this.hasError(),t=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1.5`,`min-h-[2rem]`,`rounded-lg`,`border-2`,e?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`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`];this._container.className=t.join(` `)}return}if(e===`loading`){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(e){this._tags=Array.isArray(e)?[...e]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){let e=this.getAttribute(`tags`);if(!e)return;try{let t=JSON.parse(e);Array.isArray(t)&&(this._tags=t)}catch(e){console.warn(`mint-tags: failed to parse tags attribute`,e)}let t=this.getAttribute(`placeholder`);t!==null&&(this._placeholder=t)}_syncAttr(){this.setAttribute(`tags`,JSON.stringify(this._tags))}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}hasError(){return this.getAttribute(`error`)===`true`}getErrorMessage(){return this.getAttribute(`error-message`)||``}getName(){return this.getAttribute(`name`)||``}getId(){return this.getAttribute(`id`)||``}isRequired(){return this.getAttribute(`required`)===`true`}isLoading(){return this.hasAttribute(`loading`)}_render(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this.isLoading(),t=this.getLabel(),n=this.getInfo(),r=this.hasError(),i=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute(`id`,i),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement(`div`);let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `),this._chipsWrap=document.createElement(`div`),this._chipsWrap.className=`flex flex-wrap items-center gap-2`,this._chipsWrap.addEventListener(`dragover`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._chipsWrap.addEventListener(`drop`,e=>{this.hasAttribute(`sortable`)&&e.preventDefault()}),this._input=document.createElement(`input`),this._input.type=`text`,this._input.placeholder=this._placeholder,this._input.className=[`min-w-[6rem]`,`flex-1`,`bg-transparent`,`border-none`,`outline-none`,`text-sm`,`text-gray-900`,`dark:text-gray-100`,`placeholder:text-gray-400`,`dark:placeholder:text-gray-500`,`p-1.5`].join(` `),this._input.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){let e=[`flex`,`flex-wrap`,`items-center`,`gap-2`,`w-full`,`px-2`,`py-1`,`min-h-[2rem]`,`rounded-lg`,`border-2`,r?`border-red-300 dark:border-red-300`:`border-gray-200 dark:border-mint-divider`,`bg-white`,`dark:bg-mint-elevated`,`focus-within:ring-2`,`focus-within:ring-offset-1`,r?`focus-within:ring-red-400 dark:focus-within:ring-red-500`:`focus-within:ring-gray-400 dark:focus-within:ring-gray-500`];this._container.className=e.join(` `)}let a=this.querySelector(`.mint-tags-label-container`);if(t){a||(a=document.createElement(`div`),a.className=`mint-tags-label-container mb-[.25rem]`,this._container&&this._container.parentElement===this?this.insertBefore(a,this._container):this.insertBefore(a,this.firstChild));let e=a.querySelector(`.mint-tags-label`);t?(e||(e=document.createElement(`label`),e.className=`mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none`,a.appendChild(e)),e.textContent=t,e.setAttribute(`for`,i)):e&&e.remove()}else a&&a.remove();let o=this.querySelector(`.mint-tags-info`);n?(o||(o=document.createElement(`span`),o.className=`mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block`,this._container&&this._container.parentElement===this?this.insertBefore(o,this._container.nextSibling):this.appendChild(o)),o.textContent=n):o&&o.remove();let s=this.getName();s?(this.setAttribute(`name`,s),this._input&&(this._input.name=s,this._input.id=i)):(this.removeAttribute(`name`),this._input&&(this._input.removeAttribute(`name`),this._input.id=i)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(e)}_renderSkeleton(e){let t=this._container;if(!t)return;t.classList.contains(`relative`)||t.classList.add(`relative`);let n=t.querySelector(`.mint-tags-skeleton`);e?(n||(n=document.createElement(`div`),n.className=`mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-mint-hover animate-pulse`,t.appendChild(n)),n.style.display=`block`,this._chipsWrap&&(this._chipsWrap.style.visibility=`hidden`,this._chipsWrap.style.pointerEvents=`none`),this._input&&(this._input.style.visibility=`hidden`,this._input.style.pointerEvents=`none`)):(n&&(n.style.display=`none`),this._chipsWrap&&(this._chipsWrap.style.visibility=`visible`,this._chipsWrap.style.pointerEvents=`auto`),this._input&&(this._input.style.visibility=`visible`,this._input.style.pointerEvents=`auto`))}_renderErrorState(){let e=this.hasError(),t=this.getErrorMessage(),n=this.querySelector(`.mint-tags-error`);e&&t?(n||(n=document.createElement(`div`),n.className=`mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400`,this.appendChild(n)),n.textContent=t):n&&n.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML=``;let e=0;this._tags.forEach(t=>{let n=document.createElement(`mint-chip`);n.dataset.index=String(e++),n.dataset.value=t.value,n.draggable=this.hasAttribute(`sortable`),n.draggable&&n.classList.add(`cursor-move`),t.dismissable&&(n.setAttribute(`dismissable`,`true`),n.addEventListener(`dismissed`,()=>this._removeTag(t.value))),this._chipsWrap.appendChild(n);let r=n.querySelector(`[data-mt-chip-text]`);r&&(r.textContent=t.label||t.value),this._setupChipEvents(n,t),n.draggable&&(n.addEventListener(`dragstart`,e=>this._onDragStart(e,n)),n.addEventListener(`dragover`,e=>this._onDragOverChip(e,n)),n.addEventListener(`drop`,e=>this._onDrop(e)),n.addEventListener(`dragend`,()=>this._onDragEnd())),this.hasAttribute(`sortable`)&&n.addEventListener(`pointerdown`,e=>this._onPointerDown(e,n))}),this._input&&(this.hasAttribute(`sortable`)&&(this._input.addEventListener(`dragover`,e=>this._onDragOverInput(e)),this._input.addEventListener(`drop`,e=>this._onDrop(e)),this._input.addEventListener(`dragend`,()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;let e=this._input.value.trim();if(e){if(this._tags.some(t=>t.value.toLowerCase()===e.toLowerCase())){this._input.value=``;return}this._tags.push({value:e,label:e,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value=``,setTimeout(()=>{this._input?.focus()},10)}}_removeTag(e){this._tags=this._tags.filter(t=>t.value!==e),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent(`tags-change`,{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){let e=this._chipsWrap?.querySelectorAll(`mint-chip`);e&&e.length>0&&e[e.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{this._input?.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener(`keydown`,e=>{e.key===`Backspace`&&this._input?.value===``&&(e.preventDefault(),this._focusLastChip())})}_setupChipEvents(e,t){e.tabIndex=0,e.addEventListener(`keydown`,e=>{(e.key===`Backspace`||e.key===`Delete`)&&t.dismissable&&(e.preventDefault(),this._removeTag(t.value),this._focusInput())})}_onDragStart(e,t){this.hasAttribute(`sortable`)&&(this._dragChip=t,this._dragIndex=Number(t.dataset.index),e.dataTransfer?.setData(`text/plain`,t.dataset.index||``),e.dataTransfer&&(e.dataTransfer.effectAllowed=`move`,e.dataTransfer.dropEffect=`move`),t.classList.add(`opacity-60`))}_reorderTags(e,t){if(e<0||t<0||e>=this._tags.length||t>=this._tags.length)return;let n=[...this._tags],[r]=n.splice(e,1);n.splice(t,0,r),this._tags=n,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(e){this.hasAttribute(`sortable`)&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(e,t){if(!this.hasAttribute(`sortable`)||(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),!this._dragChip||!this._chipsWrap)||t===this._dragChip)return;let n=t.getBoundingClientRect();if(e.clientX<n.left+n.width*.5){if(this._dragChip.nextSibling===t)return;this._chipsWrap.insertBefore(this._dragChip,t)}else{if(t.nextSibling===this._dragChip)return;let e=t.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(e){this.hasAttribute(`sortable`)&&e.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove(`opacity-60`),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;let e=Array.from(this._chipsWrap.querySelectorAll(`mint-chip`));if(e.length===0)return;let t=[];e.forEach(e=>{let n=e.dataset.value;if(!n)return;let r=this._tags.find(e=>e.value===n);r&&t.push(r)}),t.length===this._tags.length&&(this._tags=t,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(e,t){if(this.hasAttribute(`sortable`)&&e.pointerType!==`mouse`){this._isPointerDragging=!0,this._dragChip=t,this._dragIndex=Number(t.dataset.index);try{t.setPointerCapture(e.pointerId)}catch{}t.classList.add(`opacity-60`,`select-none`),e.preventDefault()}}_onPointerMove(e){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||e.pointerType===`mouse`)return;let t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;let n=t.closest(`mint-chip`);if(n&&n!==this._dragChip){let t=n.getBoundingClientRect();if(e.clientX<t.left+t.width*.5)this._dragChip.nextSibling!==n&&this._chipsWrap.insertBefore(this._dragChip,n);else if(n.nextSibling!==this._dragChip){let e=n.nextSibling;e?this._chipsWrap.insertBefore(this._dragChip,e):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&t.closest(`input`)===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(e){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(e.pointerId)}catch{}this._dragChip.classList.remove(`opacity-60`,`select-none`)}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}};customElements.get(`mint-tags`)||customElements.define(`mint-tags`,O);var k=class extends HTMLElement{constructor(...e){super(...e),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add(`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-1`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`rounded`),this.getAttribute(`disabled`)===`true`?this.classList.add(`cursor-not-allowed`,`opacity-50`):this.classList.add(`cursor-pointer`),this.getAttribute(`role`)||this.setAttribute(`role`,`button`),this.getAttribute(`tabindex`)||this.setAttribute(`tabindex`,`0`)}_setupEventListeners(){this._clickHandler=e=>{if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}this._handleClick(e)},this._keydownHandler=e=>{if(e.key===`Enter`||e.key===` `){if(this.getAttribute(`disabled`)===`true`){e.preventDefault(),e.stopPropagation();return}e.preventDefault(),this._handleClick(e)}},this.addEventListener(`click`,this._clickHandler),this.addEventListener(`keydown`,this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null),this._keydownHandler&&=(this.removeEventListener(`keydown`,this._keydownHandler),null)}_handleClick(e){this.dispatchEvent(new CustomEvent(`clickable-click`,{bubbles:!0,composed:!0,detail:{originalEvent:e}}))}static get observedAttributes(){return[`disabled`]}attributeChangedCallback(e,t,n){e===`disabled`&&(n===`true`?(this.classList.remove(`cursor-pointer`),this.classList.add(`opacity-50`,`cursor-not-allowed`),this.setAttribute(`aria-disabled`,`true`)):(this.classList.remove(`opacity-50`,`cursor-not-allowed`),this.classList.add(`cursor-pointer`),this.removeAttribute(`aria-disabled`)))}};customElements.get(`mint-clickable`)||customElements.define(`mint-clickable`,k);var A=class extends HTMLElement{static get observedAttributes(){return[`heading`,`dismissable`,`tone`]}constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getHeading(){return this.getAttribute(`heading`)||``}getTone(){let e=this.getAttribute(`tone`);return e===`info`||e===`success`||e===`warning`||e===`danger`?e:`info`}isDismissable(){return this.getAttribute(`dismissable`)===`true`}getIconName(){switch(this.getTone()){case`info`:return`info`;case`success`:return`success`;case`warning`:return`warning`;case`danger`:return`error`;default:return`info`}}getIconColorClasses(){switch(this.getTone()){case`info`:return`text-gray-700 dark:text-gray-300`;case`success`:return`text-green-600 dark:text-green-400`;case`warning`:return`text-yellow-600 dark:text-yellow-400`;case`danger`:return`text-red-600 dark:text-red-400`;default:return`text-gray-700 dark:text-gray-300`}}getHeadingColorClasses(){return`text-gray-900 dark:text-gray-100`}getHeaderBackgroundClasses(){switch(this.getTone()){case`info`:return`bg-gray-100 dark:bg-white/5`;case`success`:return`bg-green-100 dark:bg-green-900/30`;case`warning`:return`bg-yellow-100 dark:bg-yellow-900/30`;case`danger`:return`bg-red-100 dark:bg-red-900/30`;default:return`bg-gray-100 dark:bg-white/5`}}getBorderClasses(){switch(this.getTone()){case`info`:return`border-gray-200 dark:border-mint-divider`;case`success`:return`border-green-200 dark:border-green-800`;case`warning`:return`border-yellow-200 dark:border-yellow-800`;case`danger`:return`border-red-200 dark:border-red-800`;default:return`border-gray-200 dark:border-mint-divider`}}getAriaLive(){return this.getTone()===`danger`?`assertive`:`polite`}render(){let e=this.getTone(),t=this.getHeading(),n=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden ${this.getBorderClasses()}`;let r=this.getAriaLive();this.setAttribute(`role`,`alert`),this.setAttribute(`aria-live`,r),e===`danger`?this.setAttribute(`aria-atomic`,`true`):this.removeAttribute(`aria-atomic`);let i=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(e=>{i.push(e)}):Array.from(this.childNodes).forEach(e=>{e!==this._headerWrapper&&e!==this._bodyWrapper&&e!==this._iconElement&&e!==this._headingElement&&e!==this._dismissButton&&i.push(e)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener(`click`,this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement(`div`),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement(`mint-icon`),this._iconElement.setAttribute(`name`,this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement(`mint-text`),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=t||``,this._headerWrapper.appendChild(this._headingElement),n){this._dismissButton=document.createElement(`button`),this._dismissButton.className=`flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10`,this._dismissButton.setAttribute(`aria-label`,`Dismiss alert`),this._dismissButton.setAttribute(`type`,`button`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`close`),e.className=`w-4 h-4 text-gray-700 dark:text-gray-300`,this._dismissButton.appendChild(e),this._dismissHandler=e=>{e.preventDefault(),e.stopPropagation(),this.dispatchEvent(new CustomEvent(`dismissed`,{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener(`click`,this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement(`div`),this._bodyWrapper.className=`px-4 py-3 bg-white dark:bg-mint-elevated`,i.forEach(e=>{this._bodyWrapper.appendChild(e)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}};customElements.get(`mint-alert`)||customElements.define(`mint-alert`,A);var j=class extends HTMLElement{static get observedAttributes(){return[`configuration`,`virtual-scroll`,`virtual-scroll-root`,`virtual-row-height`,`virtual-max-height`,`fixed-header`,`fixed-controls`]}constructor(){super(),this._configuration=null,this._rows=[],this._search=``,this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._loaded=!1,this._fetching=!1,this._loading=!1,this._loadingPage=null,this._fetchError=null,this._searching=!1,this._sorting=!1,this._sortingColumn=null,this._type=`provided`,this._searchTimeoutId=null,this._sortTimeoutId=null,this._searchColumns=[],this._exportColumns={},this._columns=[],this._tableId=``,this._searchInput=null,this._tableContainer=null,this._paginationContainer=null,this._skeletonContainer=null,this._inMintCard=!1,this._virtualBodyScrollEl=null,this._virtualScrollHandler=null,this._virtualWindowRaf=null,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualResizeObserver=null,this._virtualWindowResizeHandler=null,this._virtualRowCache=new Map,this._virtualRangeFetching=!1,this._mobileListMql=null,this._boundMobileListMqlListener=null,this._virtualFetchGeneration=0,this._virtualAjaxPrefetchTimer=null,this._fixedChromeResizeObserver=null}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(e){e&&typeof e==`object`&&!Array.isArray(e)?(this._configuration=e,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=1,this._offset=0,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this.isConnected&&this.render()):e==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`),this._inMintCard=this.parentElement?.tagName?.toLowerCase()===`mint-card`,this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadPageFromUrl(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._detachMobileListMql(),this._rowClickHandler&&=(this.removeEventListener(`click`,this._rowClickHandler,!0),null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}attributeChangedCallback(e,t,n){e===`configuration`&&t!==n?(!this._configuration||typeof n==`string`)&&(this._parseConfiguration(),this.render()):t!==n&&(e===`virtual-scroll`||e===`virtual-scroll-root`||e===`virtual-row-height`||e===`virtual-max-height`||e===`fixed-header`||e===`fixed-controls`)&&this._configuration&&this.isConnected&&this.render()}refresh(){this._configuration&&(this._type===`ajax`?this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){let e=this.getAttribute(`configuration`);if(!e){console.error(`mint-resource-table: configuration attribute is required`);return}try{this._configuration=JSON.parse(e),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._type=typeof this._configuration.data==`string`?`ajax`:`provided`,this._loaded=!1,this._currentPage=this._getPageFromUrl()||1,this._offset=(this._currentPage-1)*this._perPage,this._type===`provided`&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns()}catch(e){console.error(`mint-resource-table: Invalid configuration JSON`,e)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(e=>{e.searchable&&e.data&&this._searchColumns.push(e.data),e.export&&e.data&&(this._exportColumns[e.data]=e.label),e.data&&this._columns.push(e.data)}),this._configuration.sortBy||(this._configuration.sortBy=`id`),this._configuration.sort||(this._configuration.sort=`asc`))}async _fetchData(e,t=!0,n,r){if(!this._configuration)return;let i=e||(typeof this._configuration.data==`string`?this._configuration.data:null);if(!i||this._fetching||this._loading)return;t&&(this._fetching=!0,this._loaded?this._updatePagination():this.render()),this._loading=!0;let a=n||this._perPage,o=r===void 0?this._offset:r;this._virtualScrollActive()&&this._type===`ajax`&&o===0&&(this._virtualFetchGeneration++,this._virtualRowCache.clear(),this._virtualInvalidate());try{let e=new URLSearchParams({perPage:a.toString(),offset:o.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let n=await fetch(`${i}?${e.toString()}`,t);if(!n.ok)throw Error(`HTTP error! status: ${n.status}`);let r=await n.json(),s=r.content?.rows||[],c=r.content?.total||0,l=s;this._configuration.predefinedData?(l=[...this._configuration.predefinedData,...s],this._totalRows=c+this._configuration.predefinedData.length):this._totalRows=c,this._rows=l;let u=Math.floor(o/a)+1;r.content?.current_page!==void 0&&r.content.current_page===u?this._currentPage=r.content.current_page:this._currentPage=u,this._offset=(this._currentPage-1)*a,this._lastPage=r.content?.last_page||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;let d=this._sorting;d&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,d&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent(`loaded`,{detail:{rows:this._rows}})),this._updateSearchIcon();let f=`tbody[data-mint-rt-tbody="${this._tableId}"]`,p=!!this.querySelector(f);if(this._virtualScrollActive()&&this._type===`ajax`)p||this.render(),s.forEach((e,t)=>{this._virtualRowCache.set(o+t,e)}),this._virtualInvalidate(),o===0?queueMicrotask(()=>this._scrollVirtualTableTopIntoView()):this._scheduleVirtualWindowSync(),this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0);else if(this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)){if(d){let e=this._loading,t=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=e,this._fetching=t}else this._updateTableBody();this._loadingPage,this._loadingPage=null,this._updatePagination(),setTimeout(()=>{let e=this._paginationMountedRoot();e&&e.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()})},0)}else this.render()}catch(e){this._fetching=!1,this._loading=!1,this._loadingPage=null,this._loaded=!0,this._searching=!1,this._fetchError=e instanceof Error?e.message:`Failed to fetch data`,console.error(`mint-resource-table: Error fetching data`,e),this._updateSearchIcon(),this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`)?(this._updateTableBody(),this._loadingPage=null,this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type===`ajax`)return this._rows;let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_getAllFilteredRowsSorted(){if(!this._configuration||this._type!==`provided`)return[];let e=[...this._rows],t=this._configuration.sortBy||`id`,n=this._configuration.sort||`asc`;if(this._search){let t=this._search.toLowerCase().trim().split(/\s+/);e=e.filter(e=>{let n=Object.values(e).map(e=>String(e).toLowerCase()).join(` `);return t.every(e=>n.includes(e))})}if(e.sort((e,r)=>{let i=e[t],a=r[t];if(i==null&&a==null)return 0;if(i==null)return 1;if(a==null)return-1;let o=typeof i==`number`?i:typeof i==`string`&&!isNaN(Number(i))&&i.trim()!==``?Number(i):null,s=typeof a==`number`?a:typeof a==`string`&&!isNaN(Number(a))&&a.trim()!==``?Number(a):null;if(o!==null&&s!==null){let e=o-s;return n===`asc`?e:-e}let c=i instanceof Date?i:typeof i==`string`?new Date(i):null,l=a instanceof Date?a:typeof a==`string`?new Date(a):null;if(c&&l&&!isNaN(c.getTime())&&!isNaN(l.getTime())){let e=c.getTime()-l.getTime();return n===`asc`?e:-e}let u=String(i).localeCompare(String(a),void 0,{numeric:!0,sensitivity:`base`});return n===`asc`?u:-u}),this._perPage){let t=Math.ceil(e.length/this._perPage);this._lastPage=t,e.forEach((e,t)=>{e.page=Math.ceil((t+1)/this._perPage)}),this._currentPage>t&&t>0&&(this._currentPage=t)}return e.filter(e=>!this._perPage||e.page===this._currentPage)}_virtualInvalidate(){this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``}_getRowDataForEventIndex(e){if(this._configuration){if(!this._virtualScrollActive())return this._getRows()[e];if(this._type===`provided`)return this._getAllFilteredRowsSorted()[e];if(this._type===`ajax`)return this._virtualRowCache.get(e)}}getRowByIndex(e){return this._getRowDataForEventIndex(e)}_virtualScrollActive(){return this._configuration?(this.getAttribute(`virtual-scroll`)||``).toLowerCase().trim()===`true`:!1}_virtualScrollRoot(){let e=(this.getAttribute(`virtual-scroll-root`)||``).toLowerCase().trim();return e===`table-body`||e===`body`||this._configuration?.virtualScrollRoot===`table-body`?`table-body`:`document`}_virtualBodyScrollDisablesDocumentFixedChrome(){return this._virtualScrollActive()&&this._virtualScrollRoot()===`table-body`}_fixedHeader(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-header`))return!1;let e=(this.getAttribute(`fixed-header`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_fixedControls(){if(this._virtualBodyScrollDisablesDocumentFixedChrome()||!this.hasAttribute(`fixed-controls`))return!1;let e=(this.getAttribute(`fixed-controls`)||``).toLowerCase().trim();return e!==`false`&&e!==`0`}_virtualRowHeightPx(){let e=parseInt(this.getAttribute(`virtual-row-height`)||``,10);if(!isNaN(e)&&e>0)return e;let t=this._configuration?.virtualRowHeight;return typeof t==`number`&&t>0?t:48}_virtualRowHeightPxForSync(e){let t=this._virtualRowHeightPx();if(!this._configuration)return t;if(e){let e=this._mobileThumbnailColumn();if(e){let n=this._thumbnailMobilePx(e);return Math.max(t,n+36)}return Math.max(t,80)}let n=this._mobileThumbnailColumn();if(n){let e=this._thumbnailDesktopPx(n);return Math.max(t,e+28)}return t}_virtualMaxHeightCss(){let e=this.getAttribute(`virtual-max-height`);if(e&&e.trim())return e.trim();let t=this._configuration?.virtualMaxHeight;return t&&String(t).trim()?String(t).trim():`min(70dvh, 28rem)`}_virtualColspan(){return this._configuration?Math.max(1,this._configuration.columns.filter(e=>!e.hidden).length):1}_ensureMobileListMql(){typeof window>`u`||!window.matchMedia||this._mobileListMql||(this._mobileListMql=window.matchMedia(`(max-width: 767px)`),this._boundMobileListMqlListener=()=>{this._configuration&&this.isConnected&&this.render()},this._mobileListMql.addEventListener(`change`,this._boundMobileListMqlListener))}_detachMobileListMql(){this._mobileListMql&&this._boundMobileListMqlListener&&this._mobileListMql.removeEventListener(`change`,this._boundMobileListMqlListener),this._mobileListMql=null,this._boundMobileListMqlListener=null}_useMobileListLayout(){return!!this._mobileListMql?.matches}_paginationHostPlaceholderHtml(){if(!this._configuration?.perPage||this._virtualScrollActive())return``;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage);if((this._lastPage>0?this._lastPage:e)<=1)return``;let t=[`mint-rt-pagination-host`,`w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain`,`flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end`,this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`].join(` `);return`<div id="mint-rt-pagination-host-${this._tableId}" data-mint-rt-pagination-wrap="" class="${t}"></div>`}_getPaginationHostEl(){return this.querySelector(`#mint-rt-pagination-host-${this._tableId}`)}_paginationMountedRoot(){return this._getPaginationHostEl()||this.querySelector(`nav[data-mint-rt-pagination-nav]`)?.parentElement||this.querySelector(`nav`)?.closest(`.flex.justify-end`)}_paginationPageButtonLi(e){let t=this._currentPage===e,n=this._loadingPage===e;return`<li class="shrink-0"><mint-button variant="solid" size="sm"${t?` active="true"`:``}${this._loading||this._fetching?` disabled="true"`:``}${n?` loading="true"`:``} data-action="page" data-page="${e}">${n?``:`${e}`}</mint-button></li>`}_paginationHtmlCompactMiddle(e){let t=``,n=this._currentPage;if(e<=5){for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}let r=[...new Set([1,e,n-1,n,n+1].map(t=>Math.min(e,Math.max(1,t))))].sort((e,t)=>e-t),i=0;for(let e of r)i>0&&e-i>1&&(t+=`<li class="shrink-0"><span class="px-1 text-gray-500 dark:text-gray-400" aria-hidden="true">…</span></li>`),t+=this._paginationPageButtonLi(e),i=e;return t}_paginationHtmlDesktopMiddle(e){let t=``,n=e>=10,r=Math.max(1,this._currentPage-1),i=Math.min(e,this._currentPage+1);if(n){for(let e=1;e<=3;e++)t+=this._paginationPageButtonLi(e);let n=i<=3,a=r>=e-2;if(!n&&!a){r>4&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let e=r;e<=i;e++)e<=3||(t+=this._paginationPageButtonLi(e));i<e-3&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`)}else (n&&!a||!n&&a&&e-2>4)&&(t+=`<li class="shrink-0"><span class="px-2">...</span></li>`);for(let o=e-2;o<=e;o++)o<=3||!n&&!a&&o>=r&&o<=i||(t+=this._paginationPageButtonLi(o))}else for(let n=1;n<=e;n++)t+=this._paginationPageButtonLi(n);return t}_buildPaginationNavMarkup(e){let t=this._currentPage===1||this._loading||this._fetching,n=`<nav data-mint-rt-pagination-nav="" class="w-max max-w-none shrink-0" aria-label="Pagination">`;n+=`<ul class="flex flex-nowrap items-center gap-1">`,n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-left" ${t?`disabled="true"`:``} data-action="page-prev"></mint-button></li>`,n+=this._useMobileListLayout()?this._paginationHtmlCompactMiddle(e):this._paginationHtmlDesktopMiddle(e);let r=this._currentPage>=e||this._loading||this._fetching;return n+=`<li class="shrink-0"><mint-button variant="solid" size="sm" icon="caret-right" ${r?`disabled="true"`:``} data-action="page-next"></mint-button></li>`,n+=`</ul></nav>`,n}_hasSortableColumns(){return!!this._configuration?.columns.some(e=>!e.hidden&&e.sortable&&e.data)}_getMobileSortTriggerIconName(){return`sort-arrows`}_mobileSortPopoverAffordanceInnerHtml(e){return e===`spinner`?`<span class="inline-block h-4 w-4 shrink-0 animate-spin rounded-full border-2 border-gray-300 border-t-gray-700 dark:border-gray-600 dark:border-t-gray-200" aria-hidden="true"></span>`:e===`caret-up`||e===`caret-down`?`<mint-icon name="${e}" class="h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400"></mint-icon>`:``}_buildMobileSortPopoverInnerHtml(){if(!this._configuration)return``;let e=`<div class="flex w-full min-w-[11rem] flex-col gap-0.5 p-1">`;return this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=t.raw?t.label:this._escapeHtml(t.label),i=this._getSortClass(t),a=this._mobileSortPopoverAffordanceInnerHtml(i),o=` type="button" variant="ghost" tone="neutral" size="sm" full-width="true" align="left" data-action="mobile-sort" data-column-key="${n}"`;e+=`<mint-button${o}>`,e+=`<span class="flex w-full min-w-0 flex-1 items-center justify-between gap-2">`,e+=`<span class="min-w-0 flex-1 truncate text-left">${r}</span>`,e+=`<span class="inline-flex shrink-0 items-center justify-end" data-mint-rt-mobile-sort-affordance="">${a}</span>`,e+=`</span></mint-button>`}),e+=`</div>`,e}_syncMobileSortPopoverIcons(){if(!this._configuration)return;let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&this._configuration.columns.forEach((t,n)=>{if(t.hidden||!t.sortable||!t.data)return;let r=e.querySelector(`[data-action="mobile-sort"][data-column-key="${n}"]`);if(!r||r.tagName!==`MINT-BUTTON`)return;let i=r.querySelector(`[data-mint-rt-mobile-sort-affordance]`);if(!i)return;let a=this._getSortClass(t);i.innerHTML=this._mobileSortPopoverAffordanceInnerHtml(a),i.querySelectorAll(`mint-icon`).forEach(e=>{let t=e;typeof t.render==`function`&&t.render()})})}_closeMobileSortPopover(){let e=this.querySelector(`#mint-rt-mobile-sort-popover-${this._tableId}`);e&&typeof e.close==`function`?e.close():e&&e.removeAttribute(`open`)}_buildMobileSortToolbarHtml(){if(!this._hasSortableColumns())return``;let e=`mint-rt-mobile-sort-btn-${this._tableId}`,t=`mint-rt-mobile-sort-popover-${this._tableId}`,n=this._sorting?` loading="true"`:``,r=` icon="${this._escapeHtml(this._getMobileSortTriggerIconName())}"`,i=`<div class="flex shrink-0 items-center md:hidden">`;return i+=`<mint-button id="${e}" data-mint-rt-toolbar="mobile-sort" variant="solid" tone="neutral" size="sm"${n}${r}></mint-button>`,i+=`<mint-popover id="${t}" trigger-id="${e}" direction="down" padding="0">`,i+=this._buildMobileSortPopoverInnerHtml(),i+=`</mint-popover></div>`,i}_stripHtml(e){if(!e)return``;let t=document.createElement(`div`);return t.innerHTML=e,(t.textContent||t.innerText||``).replace(/\s+/g,` `).trim()}_visibleDataColumns(){return this._configuration?this._configuration.columns.filter(e=>!e.hidden):[]}_mobileThumbnailColumn(){return this._visibleDataColumns().find(e=>e.thumbnail)||null}_thumbnailDesktopPx(e){let t=typeof e.thumbnailDesktopPx==`number`&&e.thumbnailDesktopPx>0?e.thumbnailDesktopPx:void 0,n=this._configuration,r=n&&typeof n.thumbnailDesktopPx==`number`&&n.thumbnailDesktopPx>0?n.thumbnailDesktopPx:void 0;return Math.round(t??r??40)}_thumbnailMobilePx(e){let t=typeof e.thumbnailMobilePx==`number`&&e.thumbnailMobilePx>0?e.thumbnailMobilePx:void 0,n=this._configuration,r=n&&typeof n.thumbnailMobilePx==`number`&&n.thumbnailMobilePx>0?n.thumbnailMobilePx:void 0;return Math.round(t??r??56)}_wrapThumbnailDesktopBox(e,t){let n=this._thumbnailDesktopPx(t);return`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${`width:${n}px;height:${n}px;min-width:${n}px;min-height:${n}px`}">${e}</div>`}_mobilePrimaryColumn(){let e=this._visibleDataColumns();return e.find(e=>e.primary)||e.find(e=>(e.data||typeof e.format==`function`)&&!e.thumbnail&&!e.actions)||e[0]||null}_mobileActionsDropdownColumn(){return this._visibleDataColumns().find(e=>e.actions&&e.actionStyle!==`buttons`)||null}_columnPlainSummaryText(e,t){if(!(!e.show||e.show(this,t))||e.actions||e.action)return``;try{if(e.raw){if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}else{if(typeof e.format==`function`)return this._stripHtml(e.format(this,t));if(e.data)return String(t[e.data]??``)}}catch{return``}return``}_buildTableCellInnerHtml(e,t,n,r=`table`){if(!this._configuration)return``;let i=n,a=``;if(!(!e.show||e.show(this,t)))return``;if(e.raw)if(e.action){if(!e.action.show||e.action.show(this,t)){let n=typeof e.action.label==`function`?e.action.label(this,t):e.action.label;a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(n))}</mint-button>`}}else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=e.format(this,t):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));else if(e.action)(!e.action.show||e.action.show(this,t))&&(a+=`<mint-button variant="solid" data-action="column-action" data-row-index="${i}" data-column-key="${this._configuration.columns.indexOf(e)}">${e.action.label}</mint-button>`);else if(e.actions)if(e.actionStyle!==`buttons`){let n=`actions-popover-${this._tableId}-${i}`,r=`actions-button-${this._tableId}-${i}`;a+=`<mint-button id="${r}" variant="link" icon="ellipsis">`,a+=`</mint-button>`,a+=`<mint-popover id="${n}" trigger-id="${r}" direction="down">`,e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=typeof n.label==`function`?n.label(this,t):n.label;a+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-mint-hover" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}">${this._escapeHtml(String(o))}</div>`}}),a+=`</mint-popover>`}else e.actions.forEach((n,r)=>{if(!n.show||n.show(this,t)){let o=n.label?typeof n.label==`function`?n.label(this,t):n.label:``,s=n.icon?` icon="${this._escapeHtml(n.icon)}"`:``,c=n.tone?` tone="${this._escapeHtml(n.tone)}"`:``;a+=`<mint-button variant="link" class="${n.classes||``}" data-action="row-action" data-row-index="${i}" data-action-index="${r}" data-column-key="${this._configuration.columns.indexOf(e)}"${s}${c}>`,o&&(a+=this._escapeHtml(String(o))),a+=`</mint-button>`}});else typeof e.format==`function`?a+=this._escapeHtml(e.format(this,t)):e.data&&(a+=this._escapeHtml(String(t[e.data]||``)));return r===`table`&&e.thumbnail&&a&&!e.actions&&!e.action?this._wrapThumbnailDesktopBox(a,e):a}_buildMobileListItemHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=typeof this._configuration.onRowClick==`function`,o=this._mobileThumbnailColumn(),s=this._mobilePrimaryColumn(),c=this._mobileActionsDropdownColumn(),l=o?this._buildTableCellInnerHtml(o,e,i,`mobile`):``,u=s?this._buildTableCellInnerHtml(s,e,i,`mobile`):``,d=c?this._buildTableCellInnerHtml(c,e,i,`mobile`):``,f=[];for(let t of this._configuration.columns){if(t.hidden||o&&t===o||s&&t===s||c&&t===c)continue;let n=this._columnPlainSummaryText(t,e);n&&f.push(this._escapeHtml(n))}let p=f.join(`<span class="text-gray-300 dark:text-gray-600" aria-hidden="true"> · </span>`),m=[`list-none`,...r?[]:[`border-b`,`border-gray-200`,`dark:border-mint-divider`],`bg-white`,`dark:bg-mint-canvas`,a?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``].filter(Boolean).join(` `),h=`<div class="flex items-center gap-3 py-3 pr-4${o?` pl-0`:` pl-4`}">`;if(o){let e=this._thumbnailMobilePx(o),t=`width:${e}px;height:${e}px;min-width:${e}px;min-height:${e}px`;h+=`<div class="flex shrink-0 items-stretch overflow-hidden rounded-md border border-gray-200 bg-gray-100 p-0 dark:border-mint-divider dark:bg-mint-hover [&>*]:m-0 [&>*]:min-h-0 [&>*]:min-w-0 [&>*]:w-full [&>*]:max-w-full [&>*]:p-0 [&>span]:flex [&>span]:h-full [&>span]:w-full [&>span]:min-h-0 [&>span]:min-w-0 [&>span]:items-stretch [&>span]:justify-stretch [&_img]:!m-0 [&_img]:!box-border [&_img]:!block [&_img]:!h-full [&_img]:!w-full [&_img]:!min-h-0 [&_img]:!min-w-0 [&_img]:!max-h-full [&_img]:!max-w-full [&_img]:!border-0 [&_img]:!p-0 [&_img]:!rounded-none [&_img]:!object-cover [&_img]:!object-center" style="${t}">${l}</div>`}h+=`<div class="flex min-w-0 flex-1 flex-col justify-center gap-1">`,h+=`<div class="flex items-start justify-between gap-2">`,h+=`<div class="min-w-0 text-sm font-semibold leading-snug text-gray-900 dark:text-white">${u}</div>`,d&&(h+=`<div class="shrink-0 -mr-1">${d}</div>`),h+=`</div>`,p&&(h+=`<div class="text-xs font-normal leading-snug text-gray-500 dark:text-gray-400">${p}</div>`),h+=`</div></div>`;let g=typeof n==`number`&&n>0?` style="box-sizing:border-box;min-height:${n}px;max-height:${n}px;height:${n}px;overflow:hidden"`:``;return`<li data-row-index="${i}" ${a?`data-row-clickable="true" `:``}class="${m}"${g}>${h}</li>`}_buildMobileListPlaceholderLi(e,t,n=!1){let r=this._mobileThumbnailColumn(),i=r?this._thumbnailMobilePx(r):56,a=`width:${i}px;height:${i}px;min-width:${i}px;min-height:${i}px`;return`<li data-row-index="${e}" data-mint-rt-placeholder="true" class="list-none${n?``:` border-b border-gray-200 dark:border-mint-divider`} bg-white dark:bg-mint-canvas" style="box-sizing:border-box;min-height:${t}px;max-height:${t}px;height:${t}px;overflow:hidden"><div class="flex h-full min-h-0 items-center gap-3 py-3 pl-0 pr-4"><div class="shrink-0 overflow-hidden rounded-md bg-gray-200 dark:bg-white/15" style="${a}"></div><div class="flex min-h-0 min-w-0 flex-1 flex-col justify-center gap-1 py-0.5"><div class="h-4 w-40 rounded bg-gray-200 dark:bg-white/15"></div><div class="h-3 w-full max-w-xs rounded bg-gray-200 dark:bg-white/15"></div></div></div></li>`}_renderColgroupHtml(){if(!this._configuration)return``;let e=this._configuration.columns.filter(e=>!e.hidden),t=[],n=0;for(let r of e){let e=r.width==null?``:String(r.width).trim();e?/^\d+(\.\d+)?$/.test(e)?(n+=parseFloat(e),t.push(`px`)):t.push(`lit`):t.push(`flex`)}let r=t.filter(e=>e===`flex`).length,i=t.includes(`lit`),a=``;r>0&&!i&&(a=n>0?`width:calc((100% - ${n}px) / ${r});min-width:0`:`width:${100/r}%;min-width:0`);let o=`<colgroup>`;return e.forEach((e,n)=>{let r=e.width==null?``:String(e.width).trim(),i=t[n],s=``;i===`px`?s=` style="width:${r}px;min-width:0"`:i===`lit`?s=` style="width:${this._escapeHtml(r)};min-width:0"`:a&&(s=` style="${a}"`),o+=`<col${s} />`}),o+=`</colgroup>`,o}_buildDataRowHtml(e,t,n,r=!1){if(!this._configuration)return``;let i=t,a=n,o=`box-sizing:border-box;min-height:${a}px;max-height:${a}px;height:${a}px;overflow:hidden`,s=``,c=typeof this._configuration.onRowClick==`function`,l=c?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``,u=c?` data-row-clickable="true"`:``,d=l?` class="${l}"`:``;return s+=`<tr data-row-index="${i}"${r?` data-mint-rt-last-row=""`:``}${u}${d} style="${o}">`,this._configuration.columns.forEach(t=>{if(t.hidden)return;let n=!t.show||t.show(this,e),r=`${this._getStyle(t)}box-sizing:border-box;max-height:${a}px;overflow:hidden;vertical-align:middle;`;s+=`<td style="${r}" class="${this._getClasses(t,!0)}">`,s+=n?this._buildTableCellInnerHtml(t,e,i):``,s+=`</td>`}),s+=`</tr>`,s}_getVirtualRowCount(){return!this._virtualScrollActive()||!this._configuration?0:this._type===`provided`?this._getAllFilteredRowsSorted().length:this._type===`ajax`?this._totalRows:0}_getVirtualRowAt(e){return this._type===`provided`?this._getAllFilteredRowsSorted()[e]??null:this._type===`ajax`&&this._virtualRowCache.has(e)?this._virtualRowCache.get(e):null}_buildVirtualPlaceholderRowHtml(e,t,n=!1){if(!this._configuration)return``;let r=t,i=`box-sizing:border-box;min-height:${r}px;max-height:${r}px;height:${r}px;overflow:hidden`,a=`<tr data-row-index="${e}" data-mint-rt-placeholder="true"${n?` data-mint-rt-last-row=""`:``} class="bg-white dark:bg-mint-canvas" style="${i}">`;return this._configuration.columns.forEach(e=>{if(e.hidden)return;let t=`${this._getStyle(e)}box-sizing:border-box;max-height:${r}px;height:${r}px;overflow:hidden;vertical-align:middle;line-height:0;`;if(a+=`<td style="${t}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);a+=`<div class="rounded-md bg-gray-200 dark:bg-white/15" style="width:${t}px;height:${t}px;max-width:100%;box-sizing:border-box"></div>`}else a+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15"></div>`;a+=`</td>`}),a+=`</tr>`,a}_virtualScrollStickyOverlapPx(e){let t=0;if(this._fixedControls()){let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(e)t+=Math.ceil(e.getBoundingClientRect().height);else{let e=getComputedStyle(this).getPropertyValue(`--mint-rt-fixed-controls-h`).trim(),n=parseFloat(e);isNaN(n)||(t+=Math.ceil(n))}}if(this._fixedHeader()&&e){let n=e.querySelector(`thead`);n&&(t+=Math.ceil(n.getBoundingClientRect().height))}return t}_scrollVirtualTableTopIntoView(){if(!this._virtualScrollActive()||!this.isConnected)return;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl?.isConnected?this._virtualBodyScrollEl:this.querySelector(`#mint-rt-vscroll-${this._tableId}`),t=this._useMobileListLayout()&&e?e.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`):null,n=e?.querySelector(`mint-table.table-section`)||e?.querySelector(`mint-table`),r=n?.querySelector(`#${this._tableId}`)?.closest(`table`)||n?.querySelector(`table`),i=this._virtualScrollStickyOverlapPx(r),a=t||n;if(a&&i>0){let e=a.getBoundingClientRect(),t=window.scrollY+e.top-i;window.scrollTo({top:Math.max(0,t),behavior:`auto`})}e&&(e.scrollTop=0,this._virtualBodyScrollEl=e,this._virtualInvalidate(),this._scheduleVirtualWindowSync());return}let e=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),t=this.querySelector(`mint-table.table-section`),n=this.querySelector(`#${this._tableId}`)?.closest(`table`)||t?.querySelector(`table`),r=this._useMobileListLayout()&&e?e:t||n;if(!r)return;let i=this._virtualScrollStickyOverlapPx(n),a=r.getBoundingClientRect(),o=window.scrollY+a.top-i;window.scrollTo({top:Math.max(0,o),behavior:`auto`}),this._virtualInvalidate(),this._scheduleVirtualWindowSync()}_scheduleVirtualWindowSync(){this._virtualScrollActive()&&this._virtualWindowRaf===null&&(this._virtualWindowRaf=window.requestAnimationFrame(()=>{this._virtualWindowRaf=null,this._syncVirtualWindow()}))}_syncVirtualWindow(){if(!this._virtualScrollActive()||!this._configuration)return;let e=this._useMobileListLayout(),t=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),n=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`),r=e?n:t;if(!r)return;let i=this._getVirtualRowCount(),a=this._virtualRowHeightPxForSync(e),o=this._virtualColspan();if(i===0){e?this._fetchError?r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`:r.innerHTML=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`:this._fetchError?r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r.innerHTML=`<tr><td colspan="${o}" class="text-center py-8">No records found.</td></tr>`,this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``;return}let s=0,c=window.innerHeight;if(this._virtualScrollRoot()===`table-body`){let e=this._virtualBodyScrollEl;if((!e||!e.isConnected)&&(e=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl=e),!e)return;s=e.scrollTop,c=e.clientHeight||400}else{let e=r.getBoundingClientRect();s=Math.max(0,-e.top)}let l=Math.min(Math.max(0,Math.floor(s/a)),Math.max(0,i-1)),u=Math.ceil(c/a)+16,d=Math.max(0,l-8),f=Math.min(i,l+u),p=``;if(this._type===`ajax`)for(let e=d;e<f;e++)p+=this._virtualRowCache.has(e)?`1`:`0`;if(d===this._virtualLastRangeStart&&f===this._virtualLastRangeEnd&&(this._type!==`ajax`||p===this._virtualLastRangeCacheSig))return;this._virtualLastRangeStart=d,this._virtualLastRangeEnd=f,this._virtualLastRangeCacheSig=p;let m=d*a,h=Math.max(0,(i-f)*a),g=``;if(e){g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${m}px"></li>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildMobileListItemHtml(t,e,a,n):g+=this._buildMobileListPlaceholderLi(e,a,n)}g+=`<li aria-hidden="true" class="pointer-events-none m-0 block list-none border-0 p-0" style="height:${h}px"></li>`}else{g+=`<tr data-mint-rt-spacer="top" aria-hidden="true"><td colspan="${o}" style="height:${m}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`;for(let e=d;e<f;e++){let t=this._getVirtualRowAt(e),n=i>0&&e===i-1;t?g+=this._buildDataRowHtml(t,e,a,n):g+=this._buildVirtualPlaceholderRowHtml(e,a,n)}g+=`<tr data-mint-rt-spacer="bottom" aria-hidden="true"><td colspan="${o}" style="height:${h}px;padding:0;border:0;line-height:0;font-size:0"></td></tr>`}if(r.innerHTML=g,this.querySelectorAll(`tbody[data-mint-rt-tbody="${this._tableId}"] mint-button[data-action], ul[data-mint-rt-mobile-list="${this._tableId}"] mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this._attachTableEventListeners(),this._attachRowClickHandler(),this._type===`ajax`&&this._virtualScrollActive()&&this._scheduleVirtualAjaxPrefetch(d,f),this._virtualScrollRoot()===`table-body`&&!e){let e=this._virtualBodyScrollEl;e?.isConnected&&requestAnimationFrame(()=>{if(!e.isConnected)return;let t=Math.max(0,e.scrollHeight-e.clientHeight);e.scrollTop>t&&(e.scrollTop=t)})}}_detachVirtualScroll(){this._virtualScrollHandler&&=(window.removeEventListener(`scroll`,this._virtualScrollHandler),this._virtualBodyScrollEl?.removeEventListener(`scroll`,this._virtualScrollHandler),null),this._virtualWindowResizeHandler&&=(window.removeEventListener(`resize`,this._virtualWindowResizeHandler),null),this._virtualResizeObserver&&=(this._virtualResizeObserver.disconnect(),null),this._virtualBodyScrollEl=null,this._virtualWindowRaf!==null&&(window.cancelAnimationFrame(this._virtualWindowRaf),this._virtualWindowRaf=null),this._virtualLastRangeStart=-1,this._virtualLastRangeEnd=-1,this._virtualLastRangeCacheSig=``,this._virtualAjaxPrefetchTimer!==null&&(window.clearTimeout(this._virtualAjaxPrefetchTimer),this._virtualAjaxPrefetchTimer=null),this._virtualRangeFetching=!1}_scheduleVirtualAjaxPrefetch(e,t){if(this._type!==`ajax`||!this._virtualScrollActive()||!this._configuration)return;let n=!1;for(let r=e;r<t;r++)if(!this._virtualRowCache.has(r)){n=!0;break}if(!n)return;this._virtualAjaxPrefetchTimer!==null&&window.clearTimeout(this._virtualAjaxPrefetchTimer);let r=e,i=t;this._virtualAjaxPrefetchTimer=window.setTimeout(()=>{this._virtualAjaxPrefetchTimer=null,this._fetchVirtualAjaxRange(r,i-r)},60)}async _fetchVirtualAjaxRange(e,t){if(!this._configuration||this._type!==`ajax`||!this._virtualScrollActive())return;let n=typeof this._configuration.data==`string`?this._configuration.data:null;if(!n||t<=0||this._virtualRangeFetching||e<0||e>=this._totalRows)return;this._virtualRangeFetching=!0;let r=this._virtualFetchGeneration,i=Math.min(e,Math.max(0,this._totalRows-1)),a=Math.min(150,Math.max(this._perPage,t,15),Math.max(1,this._totalRows-i));try{let e=new URLSearchParams({perPage:a.toString(),offset:i.toString(),search:this._search,sortBy:this._configuration.sortBy||`id`,sort:this._configuration.sort||`asc`,searchColumns:this._searchColumns.join(`,`),columns:this._columns.join(`,`)}),t={};this._configuration.headers&&(t.headers=this._configuration.headers);let o=await fetch(`${n}?${e.toString()}`,t);if(!o.ok)throw Error(`HTTP error! status: ${o.status}`);let s=await o.json();if(r!==this._virtualFetchGeneration)return;(s.content?.rows||[]).forEach((e,t)=>{let n=i+t;n<this._totalRows&&this._virtualRowCache.set(n,e)})}catch(e){console.error(`mint-resource-table: virtual range fetch failed`,e)}finally{this._virtualRangeFetching=!1,r===this._virtualFetchGeneration&&(this._virtualInvalidate(),this._scheduleVirtualWindowSync())}}_detachFixedChromeResize(){this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null,this.style.removeProperty(`--mint-rt-fixed-controls-h`)}_syncFixedControlsChromeHeight(){if(!this._fixedHeader()||!this._fixedControls())return;this._fixedChromeResizeObserver?.disconnect(),this._fixedChromeResizeObserver=null;let e=this.querySelector(`#mint-rt-fixed-controls-${this._tableId}`);if(!e)return;let t=()=>{let t=Math.ceil(e.getBoundingClientRect().height);this.style.setProperty(`--mint-rt-fixed-controls-h`,`${t}px`)};t(),this._fixedChromeResizeObserver=new ResizeObserver(t),this._fixedChromeResizeObserver.observe(e)}_attachVirtualScrollListeners(){if(this._detachVirtualScroll(),!this._virtualScrollActive())return;let e=()=>{this._scheduleVirtualWindowSync()};this._virtualScrollHandler=e,this._virtualScrollRoot()===`table-body`?(this._virtualBodyScrollEl=this.querySelector(`#mint-rt-vscroll-${this._tableId}`),this._virtualBodyScrollEl?.addEventListener(`scroll`,e,{passive:!0}),this._virtualBodyScrollEl&&typeof ResizeObserver<`u`&&(this._virtualResizeObserver=new ResizeObserver(()=>this._scheduleVirtualWindowSync()),this._virtualResizeObserver.observe(this._virtualBodyScrollEl))):window.addEventListener(`scroll`,e,{passive:!0}),this._virtualWindowResizeHandler=()=>this._scheduleVirtualWindowSync(),window.addEventListener(`resize`,this._virtualWindowResizeHandler,{passive:!0}),this._scheduleVirtualWindowSync()}_toggleSort(e){if(!this._configuration||!e.data||!e.sortable)return;let t=e.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=e,this._updateSortIcons(),this._type===`ajax`)this._sortTimeoutId=window.setTimeout(()=>{if(this._sortTimeoutId=null,!this._configuration||!t||!e.sortable)return;let n=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(n=n===`desc`?`asc`:`desc`),this._configuration.sort=n,this._configuration.sortBy=t,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._fetching=!1,this._loading=!1,this._fetchData(void 0,!1,this._perPage,0)},10);else{let e=this._configuration.sort||`asc`;this._configuration.sortBy?.toLowerCase()===t.toLowerCase()&&(e=e===`desc`?`asc`:`desc`),this._configuration.sort=e,this._configuration.sortBy=t,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render(),this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView())}}_getSortClass(e){return this._sorting&&this._sortingColumn===e?`spinner`:this._configuration?.sortBy?.toLowerCase()===e.data?.toLowerCase()?this._configuration?.sort?.toLowerCase()===`desc`?`caret-down`:`caret-up`:``}_updateSortIcons(){if(!this._configuration)return;this._configuration.columns.forEach((e,t)=>{if(!e.sortable||e.hidden)return;let n=this.querySelector(`th[data-column-key="${t}"]`);if(!n)return;let r=n.querySelector(`:scope > div.flex.items-center`);if(!r)return;let i=r.querySelector(`:scope > div.ml-2.flex.items-center`),a=this._getSortClass(e),o=()=>{if(!i){let e=document.createElement(`div`);e.className=`ml-2 flex items-center`,r.appendChild(e),i=e}return i},s=()=>{i&&=(i.remove(),null)};if(a===`spinner`){let e=o();if(e.querySelector(`mint-icon`)?.remove(),!e.querySelector(`mint-spinner`)){let t=document.createElement(`mint-spinner`);t.className=`w-4 h-4`,e.appendChild(t)}}else if(a===`caret-up`||a===`caret-down`){let e=o();e.querySelector(`mint-spinner`)?.remove();let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,a),t.className=`w-4 h-4`}else s()}),this._syncMobileSortPopoverIcons();let e=this.querySelector(`#mint-rt-mobile-sort-btn-${this._tableId}`);e&&(e.setAttribute(`icon`,this._getMobileSortTriggerIconName()),this._sorting?e.setAttribute(`loading`,`true`):e.removeAttribute(`loading`),typeof e.render==`function`&&e.render())}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type===`ajax`&&this._updateSearchIcon(),this._type!==`ajax`&&(this._currentPage=1),this._updateTableBody(),this._type!==`ajax`&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type===`ajax`?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):(this._searching=!1,this._virtualScrollActive()&&queueMicrotask(()=>this._scrollVirtualTableTopIntoView()))},400)}_updateSearchIcon(){let e=this.querySelector(`#search-${this._tableId}`);if(!e)return;let t=this._type===`ajax`&&(this._searching||this._fetching);setTimeout(()=>{let n=e.querySelector(`.relative`)||e.querySelector(`div`);if(!n)return;let r=n.querySelector(`mint-icon`),i=n.querySelector(`mint-spinner`);if(t){if(r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,r.replaceWith(e)}else if(!r&&!i){let e=document.createElement(`mint-spinner`);e.className=`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none`,n.appendChild(e)}}else if(i){e.getAttribute(`icon`)||e.setAttribute(`icon`,`search`);let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.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`,i.replaceWith(t)}},0)}_updateTableBody(){if(!this._configuration)return;let e=this.querySelector(`tbody[data-mint-rt-tbody="${this._tableId}"]`),t=this.querySelector(`#${this._tableId}`)?.closest(`table`)?.querySelector(`tbody`);if(this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)){if(!(e||t)){this.render();return}let n=this.querySelector(`#search-${this._tableId}`),r=document.activeElement===n||n?.querySelector(`input`)===document.activeElement,i=this._search;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;if(this._virtualInvalidate(),this._syncVirtualWindow(),r&&n){let e=n.querySelector(`input`)||n._element;e?(e.value=i,setTimeout(()=>{e.focus(),e.setSelectionRange(i.length,i.length)},0)):n.value!==void 0&&(n.value=i,setTimeout(()=>{n.focus()},0))}return}let n=this._getRows(),r=t;if(!r){this.render();return}let i=this.querySelector(`#search-${this._tableId}`),a=document.activeElement===i||i?.querySelector(`input`)===document.activeElement,o=this._search,s=``,c=``;if((this._fetching||this._loading)&&!this._loaded&&!this._sorting)return;n.forEach((e,t)=>{c+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let r=typeof this._configuration.onRowClick==`function`,i=r?`cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800`:``;s+=`<tr data-row-index="${t}" ${r?`data-row-clickable="true"`:``}${i?` class="${i}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let r=!n.show||n.show(this,e);s+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,r&&(s+=this._buildTableCellInnerHtml(n,e,t,`table`)),s+=`</td>`}),s+=`</tr>`}),n.length===0&&(this._fetchError?(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`):(s+=`<tr><td colspan="${this._configuration.columns.filter(e=>!e.hidden).length}" class="text-center py-8">No records found.</td></tr>`,c+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`)),r.innerHTML=s;let l=this.querySelector(`ul[data-mint-rt-mobile-list="${this._tableId}"]`);if(l&&(l.innerHTML=c),this._attachTableEventListeners(),this._attachRowClickHandler(),a&&i){let e=i.querySelector(`input`)||i._element;e?(e.value=o,setTimeout(()=>{e.focus(),e.setSelectionRange(o.length,o.length)},0)):i.value!==void 0&&(i.value=o,setTimeout(()=>{i.focus()},0))}}_updatePagination(){if(!this._configuration)return;let e=this._lastPage||Math.ceil(this._rows.length/this._perPage),t=()=>{let e=this.querySelector(`mint-table`),t=e?.nextElementSibling;e&&t&&t.id!==`mint-rt-pagination-host-${this._tableId}`&&!t.classList.contains(`mint-rt-pagination-host`)&&t.querySelector?.(`[data-action="page"]`)&&t.remove()};if(!this._configuration.perPage||e<=1||this._virtualScrollActive()){this._getPaginationHostEl()?.replaceChildren(),t();return}let n=this._getPaginationHostEl();if(!n){let e=this.querySelector(`[data-mint-rt-mobile-list="${this._tableId}"]`)||this.querySelector(`mint-table`);if(!e){this.render();return}n=document.createElement(`div`),n.id=`mint-rt-pagination-host-${this._tableId}`,n.setAttribute(`data-mint-rt-pagination-wrap`,``),n.className=`mint-rt-pagination-host w-full min-w-0 overflow-x-auto overflow-y-hidden overscroll-x-contain flex justify-center [-webkit-overflow-scrolling:touch] md:justify-end `+(this._inMintCard?`border-t border-gray-200 px-3.5 pb-3.5 pt-3 dark:border-mint-divider md:border-t-0 md:pt-0`:`border-t border-gray-200 px-2 py-3 dark:border-mint-divider md:border-t-0 md:py-0 md:mt-4`),e.insertAdjacentElement(`afterend`,n)}let r=this._buildPaginationNavMarkup(e);n.innerHTML=r,setTimeout(()=>{this._attachPaginationListeners(),n.querySelectorAll(`mint-button[data-action="page"]`).forEach(e=>{let t=e.getAttribute(`data-page`),n=t&&this._loadingPage===parseInt(t),r=e._button||e.querySelector(`button`);if(r)if(n){let e=[],t=document.createTreeWalker(r,NodeFilter.SHOW_TEXT,null),n;for(;n=t.nextNode();)e.push(n);e.forEach(e=>e.parentNode?.removeChild(e));let i=r.querySelector(`.mint-button-content`);if(i){let e=i.textContent?.trim();e&&/^\d+$/.test(e)&&i.remove()}let a=r.querySelector(`span.mr-2`);a&&a.querySelector(`mint-spinner`)&&(a.classList.remove(`mr-2`),a.classList.add(`mr-0`))}else{let e=r.textContent?.trim();if(!e||!/^\d+$/.test(e)){let e=t||``,n=r.querySelector(`mint-spinner`);r.innerHTML=``,n&&r.appendChild(n),r.appendChild(document.createTextNode(e))}}if(`render`in e&&typeof e.render==`function`&&(e.render(),n&&r)){let e=r.querySelector(`span.mr-2`);e&&e.querySelector(`mint-spinner`)&&(e.classList.remove(`mr-2`),e.classList.add(`mr-0`))}}),n.querySelectorAll(`mint-button[data-action="page-prev"], mint-button[data-action="page-next"]`).forEach(e=>{`render`in e&&typeof e.render==`function`&&e.render()}),this._loadingPage!==null&&!this._loading&&!this._fetching&&this._updatePagination()},0)}_goToPage(e){let t=this._lastPage||Math.ceil(this._rows.length/this._perPage);e>t&&(e=t),e<1&&(e=1),e!==this._currentPage&&(this._currentPage=e,this._offset=(e-1)*this._perPage,this._updatePageInUrl(e),this._type===`ajax`?(this._loadingPage=e,this._updatePagination(),this._fetchData()):this.render())}_handleButtonClick(e){if(this._configuration)switch(e.type){case`export`:break;case`print`:window.print();break;case`csv`:this._downloadCSV();break;default:e.onClick&&e.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;let e=this.querySelector(`#${this._tableId}`)||this.querySelector(`table`);if(!e)return;let t=`data:text/csv;charset=utf-8,`,n=e=>{let n=[];e.querySelectorAll(`th, td`).forEach(e=>{let t=e.getAttribute(`colspan`);if(t)for(let e=0;e<parseInt(t,10)-1;e++)n.push(``);n.push(`"`+e.textContent?.trim().replace(/"/g,`""`)+`"`)}),t+=n.join(`,`)+`
|
|
83
|
+
`};e.querySelectorAll(`tr`).forEach(e=>n(e));let r=encodeURI(t),i=document.createElement(`a`);i.setAttribute(`href`,r),i.setAttribute(`download`,`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(i),i.click(),document.body.removeChild(i)}_getStyle(e){let t=``;return(e.nowrap||e.actions)&&(t+=`white-space: nowrap;`),e.offsetLeft&&(t+=`left: ${e.offsetLeft} !important;`),e.offsetRight&&(t+=`right: ${e.offsetRight} !important;`),e.width&&(t+=`min-width: ${e.width}px; max-width: ${e.width}px;`),t}_getClasses(e,t=!1){let n=[];return e.class&&n.push(e.class.trim()),e.sortable&&!t&&n.push(`cursor-pointer`),e.stickLeft&&n.push(`sticky-left`),e.stickRight&&n.push(`sticky-right`),n.join(` `)}_renderTheadHtml(e,t,n=!1,r=!1){if(!this._configuration)return``;let i=[`bg-white`,`dark:bg-mint-nav`];e&&(i.push(`sticky`,`z-40`),r?i.push(`top-[var(--mint-rt-fixed-controls-h,0px)]`):i.push(`top-0`)),t&&i.push(`border-b`,`border-gray-200`,`dark:border-mint-divider`);let a=`<thead class="${i.join(` `)}"><tr>`;return this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let r=n?``:` width="${e.width||``}"`,i=e.sortable?` data-mint-rt-sortable=""`:``;if(a+=`<th${r} style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${i}>`,e.showLabel!==!1){if(a+=`<div class="flex items-center">`,a+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?a+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(a+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}a+=`</div>`}a+=`</th>`}),a+=`</tr></thead>`,a}render(){if(!this._configuration){this.innerHTML=`<div class="p-4 text-red-500">Error: Invalid configuration</div>`;return}this._ensureMobileListMql();let e=String(this._configuration.id||``).trim();e&&(this.id=e),this._detachVirtualScroll(),this._detachFixedChromeResize(),this._virtualScrollActive()||this._virtualRowCache.clear();let t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,n=this._getRows();this._lastPage||Math.ceil(this._rows.length/this._perPage);let r=``;if(t){let e=this._fixedControls(),t=[`flex`,`items-center`,`min-w-0`,this._inMintCard?`p-3.5`:`mb-3`,e?`sticky top-0 z-50 bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider`:``].filter(Boolean).join(` `);if(r+=`<div id="mint-rt-fixed-controls-${this._tableId}" class="${t}">`,r+=`<div class="flex min-w-0 flex-1 items-center gap-2">`,r+=this._buildMobileSortToolbarHtml(),this._configuration.showSearch!==!1){let e=`search-${this._tableId}`,t=this._escapeHtml(this._configuration.searchPlaceholder||`Search...`);r+=`<mint-input id="${e}" type="search" label="" placeholder="${t}" class="min-w-0 flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}r+=`<div class="hidden shrink-0 items-center gap-2 md:flex">`,this._configuration.buttons&&this._configuration.buttons.forEach(e=>{let t=e.icon?` icon="${this._escapeHtml(e.icon)}"`:``,n=e.tone?` tone="${this._escapeHtml(e.tone)}"`:``;r+=`<mint-button variant="solid" class="${e.class||``}" data-button-type="${e.type||`custom`}"${t}${n}>`,e.label&&(r+=this._escapeHtml(e.label)),r+=`</mint-button>`}),r+=`</div>`,r+=`</div>`,r+=`</div>`}if(this._type===`ajax`&&!this._loaded&&!this._fetchError&&!this._sorting){let e=this._fixedHeader()?` data-mint-rt-scroll-inner=""`:``,t=this._fixedHeader()&&this._fixedControls(),n=this._fixedHeader()?t?`sticky top-[var(--mint-rt-fixed-controls-h,0px)] z-40 `:`sticky top-0 z-40 `:`sticky top-0 z-20 `;r+=`<div class="min-w-0">`,r+=`<mint-table class="table-section`+(this._inMintCard?` rounded-t-none`:``)+`"`+e+`>`,r+=`<table id="${this._tableId}">`,r+=`<thead class="`+n+`bg-white dark:bg-mint-nav border-b border-gray-200 dark:border-mint-divider"><tr>`,this._configuration.columns.forEach((e,t)=>{if(e.hidden)return;let n=e.sortable?` data-mint-rt-sortable=""`:``;if(r+=`<th width="${e.width||``}" style="${this._getStyle(e)}" class="${this._getClasses(e)}" data-column-key="${t}"${n}>`,e.showLabel!==!1){if(r+=`<div class="flex items-center">`,r+=`<div class="flex-1">${e.raw?e.label:this._escapeHtml(e.label)}</div>`,e.sortable){let t=this._getSortClass(e);t===`spinner`?r+=`<div class="ml-2 flex items-center"><mint-spinner class="w-4 h-4"></mint-spinner></div>`:(t===`caret-up`||t===`caret-down`)&&(r+=`<div class="ml-2 flex items-center"><mint-icon name="${t}" class="w-4 h-4"></mint-icon></div>`)}r+=`</div>`}r+=`</th>`}),r+=`</tr></thead>`,r+=`<tbody>`;for(let e=0;e<4;e++)r+=`<tr>`,this._configuration.columns.forEach(e=>{if(!e.hidden){if(r+=`<td style="${this._getStyle(e)}" class="${this._getClasses(e,!0)}">`,e.thumbnail){let t=this._thumbnailDesktopPx(e);r+=`<div class="rounded-md bg-gray-200 dark:bg-white/15 animate-pulse" style="width:${t}px;height:${t}px;box-sizing:border-box"></div>`}else r+=`<div class="h-4 max-w-[95%] rounded bg-gray-200 dark:bg-white/15 animate-pulse"></div>`;r+=`</td>`}}),r+=`</tr>`;r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=this._paginationHostPlaceholderHtml()}else if(n.length>0||this._search.length>0||this._searching||this._fetchError){let e=this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`&&this._loaded&&!this._fetchError),t=e&&this._virtualScrollRoot()===`table-body`,i=this._escapeHtml(this._virtualMaxHeightCss()),a=t||this._fixedHeader(),o=this._fixedHeader()&&this._fixedControls(),s=a?` data-mint-rt-scroll-inner=""`:``,c=`table-section`+(this._inMintCard?` rounded-t-none`:``),l=`m-0 min-h-0 w-full list-none border-collapse overflow-x-hidden bg-white ${this._inMintCard?`px-3.5 py-3.5`:`py-3`} dark:bg-mint-canvas md:hidden`,u=``;if(t){let e=this._renderColgroupHtml();r+=`<div id="mint-rt-vscroll-${this._tableId}" class="overflow-y-auto overflow-x-auto min-h-0 w-full" style="max-height: ${i}; scrollbar-gutter: stable; overscroll-behavior-x: contain; overscroll-behavior-y: none; overflow-anchor: none;">`,r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}" class="w-full min-w-0 table-fixed">`,r+=e,r+=this._renderTheadHtml(!0,!0,!0,o)}else r+=`<div class="hidden min-h-0 min-w-0 md:block">`,r+=`<mint-table class="${c}"${s}>`,r+=`<table id="${this._tableId}">`,e&&(r+=this._renderColgroupHtml()),r+=this._renderTheadHtml(!0,!0,!!e,o);if(r+=`<tbody`+(e?` data-mint-rt-tbody="${this._tableId}"`:``)+`>`,!this._fetching&&!this._loading&&!e&&n.forEach((e,t)=>{u+=this._buildMobileListItemHtml(e,t,void 0,t===n.length-1);let i=typeof this._configuration.onRowClick==`function`,a=i?`cursor-pointer hover:bg-gray-50 dark:hover:bg-mint-elevated`:``;r+=`<tr data-row-index="${t}" ${i?`data-row-clickable="true"`:``}${a?` class="${a}"`:``}>`,this._configuration.columns.forEach(n=>{if(n.hidden)return;let i=!n.show||n.show(this,e);r+=`<td style="${this._getStyle(n)}" class="${this._getClasses(n,!0)}">`,i&&(r+=this._buildTableCellInnerHtml(n,e,t,`table`)),r+=`</td>`}),r+=`</tr>`}),!this._fetching&&!this._loading&&n.length===0&&!e)if(this._fetchError){let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</li>`}else{let e=this._configuration.columns.filter(e=>!e.hidden).length;r+=`<tr><td colspan="${e}" class="text-center py-8">No records found.</td></tr>`,u+=`<li class="list-none px-4 py-8 text-center text-sm">No records found.</li>`}r+=`</tbody>`,r+=`</table>`,r+=`</mint-table>`,r+=`</div>`,r+=`<ul class="${l}" data-mint-rt-mobile-list="${this._tableId}">${e?``:u}</ul>`,e||(r+=this._paginationHostPlaceholderHtml()),t&&(r+=`</div>`)}else r+=`<slot name="empty"></slot>`;this._fixedHeader()?this.setAttribute(`data-mint-rt-fixed-header`,``):this.removeAttribute(`data-mint-rt-fixed-header`),this._fixedControls()?this.setAttribute(`data-mint-rt-fixed-controls`,``):this.removeAttribute(`data-mint-rt-fixed-controls`),this.innerHTML=r,this._updatePagination(),this.querySelectorAll(`mint-button[data-action]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-mint-rt-toolbar]`).forEach(e=>{e.render&&e.render()}),this.querySelectorAll(`mint-button[data-button-type]`).forEach(e=>{e.render&&e.render()}),this._attachEventListeners(),this._type===`ajax`&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener(`click`,this._rowClickHandler,!0);let e=e=>{let t=e.target;if(t.tagName===`MINT-BUTTON`||t.tagName===`BUTTON`||t.closest(`mint-button`)||t.closest(`button`)||t.closest(`mint-popover`)||t.closest(`[data-action]`))return;let n=t.closest(`tr[data-row-clickable="true"]`)||t.closest(`li[data-row-clickable="true"]`);if(!n)return;let r=n.getAttribute(`data-row-index`);if(!r)return;let i=parseInt(r),a=this._getRowDataForEventIndex(i);!a||!this._configuration?.onRowClick||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(a):this._configuration.onRowClick(this,a))};this.addEventListener(`click`,e,!0),this._rowClickHandler=e}_attachPaginationListeners(){this.querySelectorAll(`[data-action="page"]`).forEach(e=>{e.addEventListener(`click`,()=>{if(e.getAttribute(`active`)===`true`)return;let t=parseInt(e.getAttribute(`data-page`)||`1`);t!==this._currentPage&&this._goToPage(t)})}),this.querySelectorAll(`[data-action="page-prev"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll(`[data-action="page-next"]`).forEach(e=>{e.addEventListener(`click`,()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll(`[data-action="row-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-action-index`)||`0`),r=parseInt(e.getAttribute(`data-column-key`)||`0`),i=this._getRowDataForEventIndex(t),a=this._configuration?.columns[r];a&&a.actions&&a.actions[n]&&i!==void 0&&a.actions[n].onClick(this,i)})}),this.querySelectorAll(`[data-action="column-action"]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-row-index`)||`0`),n=parseInt(e.getAttribute(`data-column-key`)||`0`),r=this._getRowDataForEventIndex(t),i=this._configuration?.columns[n];i&&i.action&&r!==void 0&&i.action.onClick(this,r)})})}_attachEventListeners(){let e=this.querySelector(`#search-${this._tableId}`);if(e){let t=e.querySelector(`input`)||e._element;t?t.addEventListener(`input`,e=>{this._search=e.target.value,this._triggerSearch()}):e.addEventListener(`input`,t=>{this._search=e.value||t.target.value||``,this._triggerSearch()})}this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll(`th[data-column-key]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=parseInt(e.getAttribute(`data-column-key`)||`0`),n=this._configuration?.columns[t];n&&this._toggleSort(n)})}),this.querySelectorAll(`[data-action="mobile-sort"]`).forEach(e=>{e.addEventListener(`click`,t=>{t.stopPropagation();let n=parseInt(e.getAttribute(`data-column-key`)||`0`,10),r=this._configuration?.columns[n];r&&(this._closeMobileSortPopover(),this._toggleSort(r))})}),this.querySelectorAll(`[data-button-type]`).forEach(e=>{e.addEventListener(`click`,()=>{let t=e.getAttribute(`data-button-type`),n=this._configuration?.buttons?.find(e=>(e.type||`custom`)===t);n&&this._handleButtonClick(n)})}),this._attachPaginationListeners(),this._virtualScrollActive()&&(this._type===`provided`||this._type===`ajax`)&&this._attachVirtualScrollListeners(),this._fixedHeader()&&this._fixedControls()&&queueMicrotask(()=>{this._syncFixedControlsChromeHeight(),requestAnimationFrame(()=>this._syncFixedControlsChromeHeight())})}_escapeHtml(e){let t=document.createElement(`div`);return t.textContent=e,t.innerHTML}_getPageFromUrl(){if(!this._tableId)return null;let e=new URLSearchParams(window.location.search).get(`mui.${this._tableId}`);if(!e)return null;let t=parseInt(e,10);return isNaN(t)||t<1?null:t}_updatePageInUrl(e){if(!this._tableId)return;let t=new URL(window.location.href),n=t.searchParams;n.set(`mui.${this._tableId}`,e.toString()),e===1&&n.set(`mui.${this._tableId}`,`1`),window.history.replaceState({},``,t.toString())}_loadPageFromUrl(){if(!this._configuration||!this._tableId)return;let e=this._getPageFromUrl();e!==null&&(this._currentPage=e,this._offset=(this._currentPage-1)*this._perPage)}};customElements.get(`mint-resource-table`)||customElements.define(`mint-resource-table`,j);var M=550,N=12,P={passive:!0},F=class extends HTMLElement{constructor(...e){super(...e),this._table=null,this._anchor=null,this._popover=null,this._menuRoot=null,this._baseId=``,this._touchTimer=null,this._touchStart=null,this._slotObserver=null,this._scrollCloseTargets=[],this._onScrollClose=()=>{this._closePopover()},this._onContextMenu=e=>{let t=e,n=this._rowTargetFromEventTarget(t.target);n&&(t.preventDefault(),this._openAtRowIndex(n.index,t.clientX,t.clientY))},this._onTouchStart=e=>{let t=e;if(!t.touches.length)return;let n=this._rowTargetFromEventTarget(t.target);if(!n)return;let r=t.touches[0];this._touchStart={x:r.clientX,y:r.clientY,rowIndex:n.index},this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null);let i=this._longPressMs();this._touchTimer=window.setTimeout(()=>{this._touchTimer=null,this._touchStart&&=(this._openAtRowIndex(this._touchStart.rowIndex,this._touchStart.x,this._touchStart.y),null)},i)},this._onTouchMove=e=>{if(!this._touchStart||this._touchTimer===null)return;let t=e.touches[0];if(!t)return;let n=t.clientX-this._touchStart.x,r=t.clientY-this._touchStart.y;n*n+r*r>N*N&&(this._clearTouchTimer(),this._touchStart=null)},this._onTouchEnd=()=>{this._clearTouchTimer(),this._touchStart=null}}static get observedAttributes(){return[`for`,`long-press-ms`]}connectedCallback(){this.classList.add(`contents`),this._baseId=this.id?.trim()||`mint-rt-ctx-${Math.random().toString(36).slice(2,10)}`,this._anchor=document.createElement(`div`),this._anchor.id=`${this._baseId}-anchor`,this._anchor.setAttribute(`aria-hidden`,`true`),this._anchor.className=`pointer-events-none fixed z-0 h-px w-px overflow-hidden p-0 m-0 border-0 opacity-0`,document.body.appendChild(this._anchor),this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`data-mint-rt-ctx-internal`,``),this._popover.id=`${this._baseId}-popover`,this._popover.setAttribute(`trigger-id`,this._anchor.id),this._popover.setAttribute(`direction`,`down`),this._popover.setAttribute(`padding`,`0`),this._popover.setAttribute(`distance`,`6px`),this._menuRoot=document.createElement(`div`),this._menuRoot.className=`flex min-w-[11rem] flex-col gap-0.5 py-1`,this._popover.appendChild(this._menuRoot),this.appendChild(this._popover),this._slotObserver=new MutationObserver(()=>{this._hideMenuSlotSources()}),this._slotObserver.observe(this,{childList:!0}),queueMicrotask(()=>{this._hideMenuSlotSources(),this._bindTable()})}disconnectedCallback(){this._slotObserver?.disconnect(),this._slotObserver=null,this._unbindTable(),this._anchor?.remove(),this._anchor=null,this._popover?.remove(),this._popover=null,this._menuRoot=null}attributeChangedCallback(){this.isConnected&&this._bindTable()}_longPressMs(){let e=parseInt(this.getAttribute(`long-press-ms`)||``,10);return!Number.isNaN(e)&&e>100?e:M}_resolveTable(){let e=this.getAttribute(`for`)?.trim();if(e){let t=document.getElementById(e);return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:null}let t=this.previousElementSibling;return t&&t.tagName===`MINT-RESOURCE-TABLE`?t:this.parentElement?.querySelector?.(`mint-resource-table`)??null}_hideMenuSlotSources(){for(let e of Array.from(this.children))e===this._popover||e.hasAttribute(`data-mint-rt-ctx-internal`)||e.setAttribute(`hidden`,``)}_bindTable(){this._unbindTable(),this._table=this._resolveTable(),this._table&&(this._table.addEventListener(`contextmenu`,this._onContextMenu,!0),this._table.addEventListener(`touchstart`,this._onTouchStart,{passive:!0}),this._table.addEventListener(`touchmove`,this._onTouchMove,{passive:!0}),this._table.addEventListener(`touchend`,this._onTouchEnd,{passive:!0}),this._table.addEventListener(`touchcancel`,this._onTouchEnd,{passive:!0}))}_unbindTable(){this._closePopover(),this._table&&=(this._table.removeEventListener(`contextmenu`,this._onContextMenu,!0),this._table.removeEventListener(`touchstart`,this._onTouchStart),this._table.removeEventListener(`touchmove`,this._onTouchMove),this._table.removeEventListener(`touchend`,this._onTouchEnd),this._table.removeEventListener(`touchcancel`,this._onTouchEnd),null)}_rowTargetFromEventTarget(e){if(!e||!this._table)return null;let t=e.closest?.(`tr[data-row-index], li[data-row-index]`);if(!t||!this._table.contains(t)||t.hasAttribute(`data-mint-rt-spacer`)||t.getAttribute(`data-mint-rt-placeholder`)===`true`)return null;let n=t.getAttribute(`data-row-index`);if(n==null)return null;let r=parseInt(n,10);return Number.isNaN(r)?null:{index:r}}_clearTouchTimer(){this._touchTimer!==null&&(window.clearTimeout(this._touchTimer),this._touchTimer=null)}_positionAnchor(e,t){this._anchor&&(this._anchor.style.left=`${Math.round(e)}px`,this._anchor.style.top=`${Math.round(t)}px`)}_slotTemplateElements(){return Array.from(this.children).filter(e=>e!==this._popover&&e instanceof HTMLElement&&!e.hasAttribute(`data-mint-rt-ctx-internal`))}_elementIsScrollContainer(e){let t=getComputedStyle(e);return t.overflowX===`auto`||t.overflowX===`scroll`||t.overflowY===`auto`||t.overflowY===`scroll`}_collectScrollCloseTargets(e){let t=[],n=new Set,r=e=>{!e||n.has(e)||(n.add(e),t.push(e))};r(window),e.querySelectorAll(`[id^="mint-rt-vscroll-"]`).forEach(e=>{this._elementIsScrollContainer(e)&&r(e)});let i=e.querySelector(`mint-table`);for(;i&&i!==e;)this._elementIsScrollContainer(i)&&r(i),i=i.parentElement;return this._elementIsScrollContainer(e)&&r(e),t}_detachScrollCloseListeners(){for(let e of this._scrollCloseTargets)e.removeEventListener(`scroll`,this._onScrollClose,P);this._scrollCloseTargets=[]}_attachScrollCloseListeners(e){this._detachScrollCloseListeners(),this._scrollCloseTargets=this._collectScrollCloseTargets(e);for(let e of this._scrollCloseTargets)e.addEventListener(`scroll`,this._onScrollClose,P)}_closePopover(){if(this._detachScrollCloseListeners(),!this._popover?.hasAttribute(`open`))return;let e=this._popover;typeof e.close==`function`?e.close():this._popover.removeAttribute(`open`)}_openAtRowIndex(e,t,n){this._closePopover();let r=this._resolveTable();if(!r||typeof r.getRowByIndex!=`function`||!this._popover||!this._menuRoot)return;let i=this._popover,a=this._menuRoot,o=r.getRowByIndex(e);if(o===void 0)return;let s=this._slotTemplateElements();if(!s.length)return;this._positionAnchor(t,n),a.innerHTML=``,s.forEach(t=>{if(t.hasAttribute(`data-mint-rt-ctx-if-selection`)&&!(window.getSelection?.()?.toString?.()?.trim()??``))return;let n=t.cloneNode(!0);n.removeAttribute(`hidden`),n.addEventListener(`click`,t=>{t.stopPropagation();let r=n.getAttribute(`data-context-action`)||n.querySelector?.(`[data-context-action]`)?.getAttribute(`data-context-action`)||``,i=window.getSelection?.()?.toString?.()?.trim()??``;this.dispatchEvent(new CustomEvent(`context-action`,{bubbles:!0,composed:!0,detail:{action:r,row:o,rowIndex:e,selectedText:i}})),this._closePopover()}),a.appendChild(n);let r=n;typeof r.render==`function`&&queueMicrotask(()=>r.render())}),i.removeAttribute(`open`),i.offsetHeight,i.setAttribute(`open`,`true`);let c=i;typeof c.render==`function`&&queueMicrotask(()=>c.render());let l=this._resolveTable();l&&this._attachScrollCloseListeners(l)}};customElements.get(`mint-resource-table-context-menu`)||customElements.define(`mint-resource-table-context-menu`,F);var I=class extends HTMLElement{static get observedAttributes(){return[`id`,`heading`,`open`,`position`,`full-page`,`width`,`height`]}constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null,this._contentObserver=null,this._renderFrame=null}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(),this._observeContentMutations()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}getPosition(){let e=this.getAttribute(`position`)?.toLowerCase();return e===`top`||e===`bottom`||e===`left`||e===`right`?e:`right`}isFullPage(){return this.getAttribute(`full-page`)===`true`}getWidth(){return this.getAttribute(`width`)||`320px`}getHeight(){return this.getAttribute(`height`)||``}_normalizeCssValue(e){return/^\d+(\.\d+)?$/.test(e.trim())?`${e.trim()}px`:e.trim()}isOpen(){return this.getAttribute(`open`)===`true`}open(){this.setAttribute(`open`,`true`)}close(){this.removeAttribute(`open`)}render(){let e=this.getId(),t=this.getHeading(),n=this.isOpen(),r=this.getPosition(),i=this.isFullPage(),a=this.getHeight();e&&(this.id=e),this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 bg-black/50 transition-opacity duration-200 z-40`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._offCanvas||(this._offCanvas=document.createElement(`div`),this.appendChild(this._offCanvas));let o=this._getPositionClasses(r,i);this._offCanvas.className=o;let s=this._offCanvas.querySelector(`.off-canvas-content`);if(s||(s=document.createElement(`div`),s.className=`off-canvas-content bg-white dark:bg-mint-elevated dark:border dark:border-mint-divider shadow-xl flex flex-col pointer-events-auto`,s.style.transform=this._getTransformValue(r,!1),this._offCanvas.appendChild(s)),n?this._animateEnter():this._animateExit(),Array.from(s.classList).forEach(e=>{(e.startsWith(`w-`)||e.startsWith(`max-w-`)||e.startsWith(`md:w-`)||e.startsWith(`md:max-w-`)||e.startsWith(`sm:w-`)||e.startsWith(`sm:max-w-`))&&s.classList.remove(e)}),s.classList.remove(`h-full`,`max-h-[90vh]`,`max-h-screen`,`md:h-full`,`md:max-h-[90vh]`,`md:max-h-screen`,`sm:h-full`,`sm:max-h-[90vh]`),s.classList.remove(`has-custom-width`,`has-custom-height`),s.style.removeProperty(`--off-canvas-width`),s.style.removeProperty(`--off-canvas-height`),i)s.classList.add(`w-full`,`h-full`,`max-w-none`);else if(r===`top`||r===`bottom`)if(s.classList.add(`w-full`,`h-full`,`max-w-none`),a){let e=this._normalizeCssValue(a);s.style.setProperty(`--off-canvas-height`,e),s.classList.add(`has-custom-height`),this._ensureHeightStyle()}else s.classList.add(`md:max-h-[90vh]`,`md:h-auto`);else{s.classList.add(`w-full`,`h-full`,`max-w-none`);let e=this.getWidth(),t=this._normalizeCssValue(e);s.style.setProperty(`--off-canvas-width`,t),s.classList.add(`has-custom-width`),this._ensureWidthStyle()}this._header||(this._header=document.createElement(`div`),this._header.className=`flex items-center justify-between p-4 border-b border-gray-200 dark:border-mint-divider flex-shrink-0`,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 c=this._headingSlot.querySelector(`mint-text`);t?(c||(c=document.createElement(`mint-text`),c.setAttribute(`size`,`sub-heading`),c.setAttribute(`bold`,`true`),this._headingSlot.appendChild(c)),c.textContent=t):c&&c.remove(),Array.from(this.children).filter(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._headingSlot&&e.getAttribute(`slot`)===`heading`).forEach(e=>{this._headingSlot&&e.parentElement!==this._headingSlot&&this._headingSlot.appendChild(e)}),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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._bodySlot&&e.getAttribute(`slot`)===`body`).forEach(e=>{this._bodySlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._actionsSlot||(this._actionsSlot=document.createElement(`div`),this._actionsSlot.className=`p-4 border-t border-gray-200 dark:border-mint-divider flex-shrink-0`,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(e=>e!==this._overlay&&e!==this._offCanvas&&e!==this._actionsSlot&&e.getAttribute(`slot`)===`actions`).forEach(e=>{Array.from(e.children).forEach(e=>{e.parentElement!==l&&l.appendChild(e)}),e.parentElement&&e.remove()}),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._offCanvas&&e.getAttribute(`slot`)!==`heading`&&e.getAttribute(`slot`)!==`body`&&e.getAttribute(`slot`)!==`actions`&&e!==this._headingSlot&&e!==this._bodySlot&&e!==this._actionsSlot&&e.parentElement!==this._bodySlot&&this._bodySlot.appendChild(e)}),this._updateBackgroundColor()}_getPositionClasses(e,t){let n=`fixed z-50 pointer-events-none`;switch(e){case`top`:return`${n} inset-0 md:inset-x-0 md:top-0 md:bottom-auto ${t?`md:h-full`:`md:h-auto`}`;case`bottom`:return`${n} inset-0 md:inset-x-0 md:bottom-0 md:top-auto ${t?`md:h-full`:`md:h-auto`}`;case`left`:return`${n} inset-0 md:inset-y-0 md:left-0 md:right-auto ${t?`md:w-full`:`md:w-auto`}`;case`right`:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`;default:return`${n} inset-0 md:inset-y-0 md:right-0 md:left-auto ${t?`md:w-full`:`md:w-auto`}`}}_getTransformValue(e,t){if(t)switch(e){case`top`:return`translateY(0)`;case`bottom`:return`translateY(0)`;case`left`:return`translateX(0)`;case`right`:return`translateX(0)`;default:return`translateX(0)`}else switch(e){case`top`:return`translateY(-100%)`;case`bottom`:return`translateY(100%)`;case`left`:return`translateX(-100%)`;case`right`:return`translateX(100%)`;default:return`translateX(100%)`}}_updateBackgroundColor(){if(!this._offCanvas)return;let e=document.documentElement.classList.contains(`dark`),t=this._offCanvas.querySelector(`.off-canvas-content`);t&&(e?(t.classList.remove(`bg-white`),t.classList.add(`bg-mint-elevated`,`border`,`border-mint-divider`)):(t.classList.remove(`bg-mint-elevated`,`border`,`border-mint-divider`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_animateEnter(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e)return;let t=this.getPosition();e.style.transform=this._getTransformValue(t,!1),e.style.transition=`transform 300ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=this._getTransformValue(t,!0)})})}_animateExit(){let e=this._offCanvas?.querySelector(`.off-canvas-content`);if(!e){this.classList.add(`hidden`);return}let t=this.getPosition();e.style.transition=`transform 300ms ease-in`,e.style.transform=this._getTransformValue(t,!1),setTimeout(()=>{this.classList.add(`hidden`),e.style.transform=``,e.style.transition=``},300)}_ensureWidthStyle(){if(!document.getElementById(`off-canvas-width-style`)){let e=document.createElement(`style`);e.id=`off-canvas-width-style`,e.textContent=`
|
|
84
84
|
@media (min-width: 768px) {
|
|
85
85
|
.off-canvas-content.has-custom-width {
|
|
86
86
|
width: min(var(--off-canvas-width), 100vw) !important;
|
|
@@ -94,7 +94,7 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
94
94
|
max-height: 100% !important;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
`,document.head.appendChild(e)}}};customElements.get(`mint-off-canvas`)||customElements.define(`mint-off-canvas`,M);var N=class extends HTMLElement{static get observedAttributes(){return[`active`,`disabled`,`target`]}constructor(){super(),this._clickHandler=null}connectedCallback(){this.render(),this.setupEventListeners()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getTarget(){return this.getAttribute(`target`)||``}isActive(){let e=this.getAttribute(`active`);return e!==null&&e!==`false`}isDisabled(){return this.getAttribute(`disabled`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.setAttribute(`active`,`false`)}render(){let e=this.isActive(),t=this.isDisabled();this.className=``,this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`inline-block`,`cursor-pointer`,`px-4`,`py-1.5`,`text-sm`,`font-medium`,`rounded-lg`,`border`,`text-gray-700`,`dark:text-gray-300`);let n=this.closest(`mint-tab-list`)?.getAttribute(`position`)||`top`,r=n===`left`||n===`right`;t?(this.classList.add(`opacity-60`,`cursor-not-allowed`,`pointer-events-none`,`bg-gray-50`,`dark:bg-mint-elevated`,`border-gray-300`,`dark:border-mint-divider`,`text-gray-400`,`dark:text-gray-500`),this.classList.remove(`cursor-pointer`)):e?(this.classList.add(`bg-white`,`dark:bg-mint-elevated`,`border-gray-200`,`dark:border-mint-divider`,`text-gray-900`,`dark:text-gray-100`,`shadow-sm`,`relative`,`z-10`),r?n===`left`?this.classList.add(`mr-[-1px]`):this.classList.add(`ml-[-1px]`):this.classList.add(`mb-[-1px]`)):this.classList.add(`bg-gray-100`,`dark:bg-mint-elevated`,`border-gray-200`,`dark:border-mint-divider`,`text-gray-600`,`dark:text-gray-400`,`hover:bg-gray-50`,`dark:hover:bg-mint-hover`)}setupEventListeners(){this.isDisabled()||this._clickHandler||(this._clickHandler=this.handleClick.bind(this),this.addEventListener(`click`,this._clickHandler))}removeEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null)}handleClick(e){if(this.isDisabled()){e.preventDefault(),e.stopPropagation();return}e.__mintTabsSynthetic||(e.stopPropagation(),this.dispatchEvent(new CustomEvent(`tab-click`,{detail:{tab:this,target:this.getTarget()},bubbles:!0,cancelable:!0,composed:!0})))}};customElements.get(`mint-tab`)||customElements.define(`mint-tab`,N);var P=class extends HTMLElement{static get observedAttributes(){return[`position`]}constructor(){super()}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getPosition(){return this.getAttribute(`position`)||`top`}render(){let e=this.getPosition();this.classList.remove(`flex`,`inline-flex`,`flex-row`,`flex-col`,`gap-1`,`gap-2`,`pb-0`,`pr-0`,`pl-0`,`mb-0`,`mr-0`,`ml-0`,`self-start`),this.classList.add(`box-border`,`m-0`,`p-1`,`border`,`bg-gray-100`,`dark:bg-mint-elevated`,`dark:border-mint-divider`,`border-gray-200`,`w-auto`,`rounded-lg`,`gap-2`),e===`top`?this.classList.add(`inline-flex`,`flex-row`,`mb-0`,`self-start`):e===`left`?this.classList.add(`flex`,`flex-col`,`mr-0`):e===`right`&&this.classList.add(`flex`,`flex-col`,`ml-0`)}};customElements.get(`mint-tab-list`)||customElements.define(`mint-tab-list`,P);var F=class extends HTMLElement{static get observedAttributes(){return[`id`]}constructor(){super()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`,`w-full`),this.render(),this.checkInitialVisibility()}attributeChangedCallback(e,t,n){t!==n&&e===`id`&&(this.render(),this.checkInitialVisibility())}getId(){return this.getAttribute(`id`)||``}show(){this.style.display=`block`}hide(){this.style.display=`none`}checkInitialVisibility(){let e=this.closest(`mint-tabs`);if(!e){this.style.display=`none`;return}let t=e.querySelectorAll(`mint-tab`),n=!1;t.forEach(e=>{let t=e.getAttribute(`active`),r=e.getAttribute(`target`),i=this.getId();t===`true`&&r===i&&(n=!0)}),!n&&t.length>0&&t[0].getAttribute(`target`)===this.getId()&&!e.querySelector(`mint-tab[active="true"]`)&&(n=!0),n?this.style.display=`block`:this.style.display=`none`}render(){}};customElements.get(`mint-tab-content`)||customElements.define(`mint-tab-content`,F);var I=class extends HTMLElement{constructor(){super(),this._tabClickHandler=null,this._mutationObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`),this.render(),this.setupEventListeners(),this.setupMutationObserver(),this.initializeActiveTab()}disconnectedCallback(){this.removeEventListeners(),this._mutationObserver&&=(this._mutationObserver.disconnect(),null)}render(){let e=this.querySelector(`mint-tab-list`);if(this.querySelectorAll(`mint-tab-content`),!e){console.warn(`mint-tabs: mint-tab-list is required`);return}let t=e.getAttribute(`position`)||`top`;this.classList.remove(`flex`,`flex-row`,`flex-col`,`gap-4`,`gap-6`),t===`left`||t===`right`?(this.classList.add(`flex`,`flex-row`,`items-start`),t===`left`?(e.classList.add(`mr-4`,`flex-shrink-0`),e.classList.remove(`ml-4`)):(e.classList.add(`ml-4`,`flex-shrink-0`,`order-2`),e.classList.remove(`mr-4`),this.querySelectorAll(`mint-tab-content`).forEach(e=>{e.classList.add(`order-1`)}))):(this.classList.add(`flex`,`flex-col`),e.classList.remove(`mr-4`,`ml-4`,`flex-shrink-0`,`order-2`),this.querySelectorAll(`mint-tab-content`).forEach(e=>{e.classList.remove(`order-1`)}))}initializeActiveTab(){requestAnimationFrame(()=>{let e=this.querySelectorAll(`mint-tab`),t=null;if(e.forEach(e=>{e.getAttribute(`active`)===`true`&&(t=e)}),!t&&e.length>0&&(t=e[0],t.setAttribute(`active`,`true`)),t){let e=t.getAttribute(`target`);e?this.showContent(e):this.hideAllContent()}else this.hideAllContent();this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.checkInitialVisibility&&t.checkInitialVisibility()})})}hideAllContent(){this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.hide?t.hide():e.style.display=`none`})}showContent(e){this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.hide?t.hide():e.style.display=`none`});let t=this.querySelector(`mint-tab-content[id="${e}"]`);t&&(t.show?t.show():t.style.display=`block`)}setupEventListeners(){this._tabClickHandler||(this._tabClickHandler=this.handleTabClick.bind(this),this.addEventListener(`tab-click`,this._tabClickHandler))}removeEventListeners(){this._tabClickHandler&&=(this.removeEventListener(`tab-click`,this._tabClickHandler),null)}setupMutationObserver(){this._mutationObserver=new MutationObserver(()=>{this.render()});let e=this.querySelector(`mint-tab-list`);e&&this._mutationObserver.observe(e,{attributes:!0,attributeFilter:[`position`]})}handleTabClick(e){let t=e.detail?.tab,n=e.detail?.target;if(!t)return;let r=t.closest(`mint-tab-list`);r&&(r.querySelectorAll(`mint-tab`).forEach(e=>{let n=e;e===t?n.active=!0:n.active=!1}),n&&this.showContent(n))}};customElements.get(`mint-tabs`)||customElements.define(`mint-tabs`,I);var L=class e extends HTMLElement{static get observedAttributes(){return[`type`,`data`,`width`,`height`,`show-legend`,`show-grid`,`show-tooltip`,`curve-tension`]}static{this.MAX_CACHE_SIZE=100}constructor(){super(),this._chartContainer=null,this._svg=null,this._tooltip=null,this._chartType=`line`,this._chartData=null,this._width=800,this._height=400,this._padding={top:20,right:20,bottom:60,left:60},this._showLegend=!0,this._showGrid=!0,this._showTooltip=!0,this._curveTension=.5,this._dataObserver=null,this._darkModeObserver=null,this._tooltipHideTimeout=null,this._lastTooltipContent=``,this._activeXValue=null,this._pinnedXValue=null,this._tooltipAnimationFrame=null,this._cachedTooltipContent=new Map,this._cachedXPositions=new Map,this._verticalLine=null,this._plotPoints=new Map,this._resizeObserver=null,this._windowResizeHandler=null,this._pieChartTimeouts=new Set,this._pieChartTooltipShown=!1,this._pieChartClickOutsideHandler=null,this._pieChartGroup=null,this._chartClickOutsideHandler=null,this._chartTooltipScrollHandler=null,this._cachedBounds={bounds:null,dataHash:``},this._cachedYRange={range:null,dataHash:``},this._cachedXValues={values:null,dataHash:``},this._renderScheduled=!1,this._datasetVisibility=new Map,this._widthValue=`100%`,this._heightValue=400,this._defaultColors=[`#2563eb`,`#3b82f6`,`#0d9488`,`#7c3aed`,`#d97706`,`#059669`,`#dc2626`,`#c026d3`],this._legendHeight=0,this._rotatedLabelHeight=0}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this._getReactiveValue(this.data);e&&typeof e==`object`&&!Array.isArray(e)&&`datasets`in e&&(this._chartData=e),this._setupDataObserver(),this._setupDarkModeObserver(),this._setupResizeObserver(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.render()})})}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupDataObserver(){let e=null,t=0,n=()=>{if(!this.isConnected)return;let t=this._getReactiveValue(this.data),n=null;t&&typeof t==`object`&&!Array.isArray(t)&&`datasets`in t&&(n=t),n!==e&&n&&(e=n,this._chartData=n,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this.render())};requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n()})});let r=setInterval(()=>{if(!this.isConnected){clearInterval(r);return}if(n(),t++,t>50){clearInterval(r);let e=setInterval(()=>{if(!this.isConnected){clearInterval(e);return}n()},1e3);this._dataCheckInterval=e}},100);this._dataCheckInterval=r}_setupDarkModeObserver(){this._darkModeObserver=new MutationObserver(()=>{this.isConnected&&this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]})}disconnectedCallback(){if(this._tooltip&&this._tooltip.parentNode&&(this._tooltip.parentNode.removeChild(this._tooltip),this._tooltip=null),this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._pieChartTimeouts.forEach(e=>clearTimeout(e)),this._pieChartTimeouts.clear(),this._pieChartClickOutsideHandler&&=(document.removeEventListener(`click`,this._pieChartClickOutsideHandler,!0),null),this._chartClickOutsideHandler&&=(document.removeEventListener(`click`,this._chartClickOutsideHandler,!0),null),this._pieChartTooltipShown=!1,this._pieChartGroup=null,this._pinnedXValue=null,this._tooltipAnimationFrame!==null&&(cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=null),this._dataObserver&&=(this._dataObserver.disconnect(),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._dataCheckInterval&&=(clearInterval(this._dataCheckInterval),null),this._svg&&(this._chartTooltipMouseMove&&=(this._svg.removeEventListener(`mousemove`,this._chartTooltipMouseMove),null),this._chartTooltipMouseLeave&&=(this._svg.removeEventListener(`mouseleave`,this._chartTooltipMouseLeave),null),this._chartTooltipTouchStart&&=(this._svg.removeEventListener(`touchstart`,this._chartTooltipTouchStart),null),this._chartTooltipTouchMove&&=(this._svg.removeEventListener(`touchmove`,this._chartTooltipTouchMove),null),this._chartTooltipTouchEnd&&=(this._svg.removeEventListener(`touchend`,this._chartTooltipTouchEnd),null)),this._chartTooltipScrollHandler){window.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;)e.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement;this._chartTooltipScrollHandler=null}this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._windowResizeHandler&&=(window.removeEventListener(`resize`,this._windowResizeHandler),null),this._cachedTooltipContent.clear(),this._cachedXPositions.clear(),this._plotPoints.clear(),this._cachedBounds={bounds:null,dataHash:``},this._cachedYRange={range:null,dataHash:``},this._cachedXValues={values:null,dataHash:``}}_handleResize(){if(!this.isConnected)return;let e=this.getBoundingClientRect(),t=e.width||this.parentElement?.clientWidth||800,n=e.height||this.parentElement?.clientHeight||400,r=this._calculateDimension(this._widthValue,t,t),i=this._calculateDimension(this._heightValue,n,400);(r!==this._width||i!==this._height)&&(this._width=r,this._height=i,this.render())}_setupResizeObserver(){this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._windowResizeHandler&&=(window.removeEventListener(`resize`,this._windowResizeHandler),null);let e=null,t=()=>{e&&clearTimeout(e),e=window.setTimeout(()=>{this._handleResize()},100)};this._windowResizeHandler=t,this._resizeObserver=new ResizeObserver(()=>{t()}),this._resizeObserver.observe(this),window.addEventListener(`resize`,t)}attributeChangedCallback(e,t,n){t!==n&&(e===`data`&&this.data&&typeof this.data==`object`&&(this._chartData=this.data),(e===`width`||e===`height`)&&this.isConnected&&(t&&t.endsWith(`%`))!==(n&&n.endsWith(`%`))&&this._setupResizeObserver(),this.isConnected&&requestAnimationFrame(()=>{this.render()}))}get type(){let e=this.getAttribute(`type`)||`line`;return e===`line`||e===`bar`||e===`area`||e===`pie`?e:`line`}set type(e){this.setAttribute(`type`,e)}get data(){return this._chartData}set data(e){if(typeof e==`string`)try{this._chartData=JSON.parse(e)}catch(e){console.error(`mint-chart: Invalid data JSON`,e),this._chartData=null}else this._chartData=e;this.isConnected&&requestAnimationFrame(()=>{this.render()})}get width(){let e=this.getAttribute(`width`);if(!e)return this._widthValue;if(e.endsWith(`%`))return e;let t=parseInt(e,10);return isNaN(t)?this._widthValue:t}set width(e){this.setAttribute(`width`,e.toString())}get height(){let e=this.getAttribute(`height`);if(!e)return this._heightValue;if(e.endsWith(`%`))return e;let t=parseInt(e,10);return isNaN(t)?this._heightValue:t}set height(e){this.setAttribute(`height`,e.toString())}_calculateDimension(e,t,n){if(typeof e==`number`)return e;if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!isNaN(n))return t*n/100}return n}_scheduleRender(){this._renderScheduled||(this._renderScheduled=!0,requestAnimationFrame(()=>{this._renderScheduled=!1,this.render()}))}_isDatasetVisible(e,t){if(e.id){let t=this._datasetVisibility.get(e.id);if(t!==void 0)return t}return e.visible!==!1}_initializeDatasetVisibility(){this._chartData&&this._chartData.datasets.forEach((e,t)=>{e.id&&(this._datasetVisibility.has(e.id)||this._datasetVisibility.set(e.id,e.visible!==!1))})}render(){if(!this.isConnected)return;this._plotPoints.clear(),this._activeXValue=null,this._cachedTooltipContent?.clear(),this._cachedXPositions?.clear(),this._chartType=this.type;let e=this._getReactiveValue(this.data);if(e&&typeof e==`object`&&!Array.isArray(e)&&`datasets`in e&&(this._chartData=e),!this._chartData){let e=this.getAttribute(`data`);if(e)try{this._chartData=JSON.parse(e)}catch(e){console.error(`mint-chart: Invalid data JSON`,e),this._chartData=null}}this._widthValue=this.width,this._heightValue=this.height;let t=this.getBoundingClientRect(),n=t.width||this.parentElement?.clientWidth||800,r=t.height||this.parentElement?.clientHeight||400;this._width=this._calculateDimension(this._widthValue,n,n),this._height=this._calculateDimension(this._heightValue,r,400),this._showLegend=this.getAttribute(`show-legend`)!==`false`,this._showGrid=this.getAttribute(`show-grid`)!==`false`,this._showTooltip=this.getAttribute(`show-tooltip`)!==`false`;let i=this.getAttribute(`curve-tension`);if(i!==null){let e=parseFloat(i);this._curveTension=isNaN(e)?.5:Math.max(0,Math.min(1,e))}else this._curveTension=.5;if(!this._chartData||!this._chartData.datasets||this._chartData.datasets.length===0){this.innerHTML=`<div class="p-4 text-gray-500">No chart data provided</div>`;return}switch(this.innerHTML=``,this._chartContainer=document.createElement(`div`),this._chartContainer.className=`relative w-full`,typeof this._widthValue==`string`&&this._widthValue.endsWith(`%`)?this._chartContainer.style.width=this._widthValue:this._chartContainer.style.width=`${this._width}px`,typeof this._heightValue==`string`&&this._heightValue.endsWith(`%`)?this._chartContainer.style.height=this._heightValue:this._chartContainer.style.height=`${this._height}px`,this.appendChild(this._chartContainer),this._svg=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this._svg.setAttribute(`width`,this._width.toString()),this._svg.setAttribute(`height`,this._height.toString()),this._svg.setAttribute(`viewBox`,`0 0 ${this._width} ${this._height}`),this._svg.setAttribute(`class`,`w-full h-full`),this._chartContainer&&this._svg&&this._chartContainer.appendChild(this._svg),this._showTooltip&&this._createTooltip(),this._initializeDatasetVisibility(),this._calculateRotatedLabelHeight(),this._showLegend?this._legendHeight=this._calculateLegendHeight():this._legendHeight=0,this._showLegend&&this._renderLegend(),this._chartType!==`pie`&&this._pieChartClickOutsideHandler&&(document.removeEventListener(`click`,this._pieChartClickOutsideHandler,!0),this._pieChartClickOutsideHandler=null,this._pieChartTooltipShown=!1,this._pieChartGroup=null),this._pinnedXValue=null,this._chartType){case`line`:this._renderLineChart();break;case`bar`:this._renderBarChart();break;case`area`:this._renderAreaChart();break;case`pie`:this._renderPieChart();break}this._showTooltip&&this._chartType!==`pie`&&(this._setupChartTooltip(),this._setupTooltipScrollHandler()),this._createVerticalLine()}_createTooltip(){this._tooltip&&this._tooltip.parentNode&&this._tooltip.parentNode.removeChild(this._tooltip),this._tooltip=document.createElement(`div`),this._tooltip.className=`fixed pointer-events-none z-50 bg-gray-900 dark:bg-mint-elevated text-white text-xs rounded px-2 py-1 shadow-lg opacity-0`,this._tooltip.style.display=`none`,document.body.appendChild(this._tooltip)}_showTooltipAt(e,t,n){if(!this._tooltip)return;this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._lastTooltipContent!==n&&(this._tooltip.innerHTML=n,this._lastTooltipContent=n),(this._tooltip.style.display===`none`||this._tooltip.style.opacity===`0`)&&(this._tooltip.style.display=`block`,this._tooltip.style.opacity=`1`,this._tooltip.style.padding=`8px 12px`);let r=this._tooltip.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=e+10,s=t-r.height-8;o+r.width>i&&(o=e-r.width-10),o<0&&(o=10),s<0&&(s=t+20),s+r.height>a&&(s=t-r.height-8,s<0&&(s=10));let c=`${o}px`,l=`${s}px`;this._tooltip.style.left!==c&&(this._tooltip.style.left=c),this._tooltip.style.top!==l&&(this._tooltip.style.top=l)}_hideTooltip(){this._tooltip&&(this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._tooltip.style.opacity=`0`,this._tooltipHideTimeout=window.setTimeout(()=>{this._tooltip&&(this._tooltip.style.display=`none`),this._tooltipHideTimeout=null},200))}_createVerticalLine(){if(!this._svg)return;this._verticalLine&&this._verticalLine.parentNode&&this._verticalLine.parentNode.removeChild(this._verticalLine),this._verticalLine=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);let e=document.documentElement.classList.contains(`dark`);this._verticalLine.setAttribute(`stroke`,e?`#9ca3af`:`#6b7280`),this._verticalLine.setAttribute(`stroke-width`,`1`),this._verticalLine.setAttribute(`stroke-dasharray`,`4,2`),this._verticalLine.style.opacity=`0`,this._verticalLine.style.pointerEvents=`none`;let t=this._svg.querySelector(`.chart-legend`);t&&t.parentNode?t.parentNode.insertBefore(this._verticalLine,t):this._svg.appendChild(this._verticalLine)}_showVerticalLineAtX(e,t){if(!this._verticalLine)return;let n=this._chartType===`bar`?this._scaleXForBarChart(e,t):this._scaleX(e,t);this._verticalLine.setAttribute(`x1`,n.toString()),this._verticalLine.setAttribute(`y1`,t.y.toString()),this._verticalLine.setAttribute(`x2`,n.toString()),this._verticalLine.setAttribute(`y2`,(t.y+t.height).toString()),this._verticalLine.style.opacity=`1`}_hideVerticalLine(){this._verticalLine&&(this._verticalLine.style.opacity=`0`)}_showPlotPointsForX(e){this._plotPoints.forEach(e=>{e.forEach(e=>{e.style.opacity=`0`})});let t=String(e),n=this._plotPoints.get(t);n&&n.forEach(e=>{e.style.opacity=`1`})}_hidePlotPoints(){this._plotPoints.forEach(e=>{e.forEach(e=>{e.style.opacity=`0`})})}_calculateMaxYAxisLabelWidth(){if(!this._showGrid||!this._chartData)return 0;let e=document.createElement(`canvas`).getContext(`2d`);if(!e)return 60;e.font=`12px system-ui, -apple-system, sans-serif`;let t=this._showLegend?Math.max(this._legendHeight,60):0,n=this._height-t,r=Math.floor(n/35),i=Math.min(5,r),a=0;for(let t=0;t<=i;t++){let n=this._getYRange(),r=n.max-(n.max-n.min)/i*t,o=this._formatYAxisValue(r),s=e.measureText(o);a=Math.max(a,s.width)}return Math.ceil(a)+20}_getChartBounds(){let e=this._calculateMaxYAxisLabelWidth(),t=`${this._width}-${this._height}-${this._showGrid}-${this._showLegend}-${this._legendHeight}-${e}-${this._rotatedLabelHeight}`;if(this._cachedBounds.bounds&&this._cachedBounds.dataHash===t)return this._cachedBounds.bounds;let n=0,r=0;this._showGrid&&(n=e+10);let i=(this._rotatedLabelHeight>0?30:20)+this._rotatedLabelHeight+12,a=i;this._showLegend&&(a=i+20+Math.max(this._legendHeight,60));let o=this._height-0-n-0,s=o-a,c=1;if(s<100&&a>0){let e=o-100;e>0?(c=Math.min(1,e/a),c=Math.max(.5,c)):c=.5}r=a*c;let l=this._width*.3,u=n,d=1;n>l&&(d=l/n,u=l);let f={width:(this._width-u-0)*d,height:this._height-0-r,x:u,y:0};return this._cachedBounds={bounds:f,dataHash:t},f}_getAllDataPoints(){if(!this._chartData)return[];let e=[];return this._chartData.datasets.forEach((t,n)=>{this._isDatasetVisible(t,n)&&e.push(...t.data)}),e}_getXValues(){if(!this._chartData)return[];let e=JSON.stringify(this._chartData.labels)+JSON.stringify(this._chartData.datasets.map(e=>e.data.map(e=>e.x)));if(this._cachedXValues.values&&this._cachedXValues.dataHash===e)return this._cachedXValues.values;if(this._chartData.labels&&this._chartData.labels.length>0)return this._cachedXValues={values:this._chartData.labels,dataHash:e},this._chartData.labels;let t=new Set;this._chartData.datasets.forEach((e,n)=>{this._isDatasetVisible(e,n)&&e.data.forEach(e=>{t.add(e.x)})});let n=Array.from(t).sort((e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e-t;let n=String(e),r=String(t),i=/^([A-Za-z]{3})\s+(\d{4})$/,a=n.match(i),o=r.match(i);if(a&&o){let e=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],t=e.indexOf(a[1]),n=e.indexOf(o[1]),r=parseInt(a[2]),i=parseInt(o[2]);return r===i?t-n:r-i}return n.localeCompare(r)});return this._cachedXValues={values:n,dataHash:e},n}_getYRange(){if(!this._chartData)return{min:0,max:100};let e=JSON.stringify(this._chartData.datasets.map(e=>e.data.map(e=>e.y)));if(this._cachedYRange.range&&this._cachedYRange.dataHash===e)return this._cachedYRange.range;let t=this._getAllDataPoints();if(t.length===0){let t={min:0,max:100};return this._cachedYRange={range:t,dataHash:e},t}let n=t.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),a=(i-r)*.1,o={min:Math.max(0,r-a),max:i+a};return this._cachedYRange={range:o,dataHash:e},o}_hasDecimalValues(){return this._getAllDataPoints().some(e=>e.y%1!=0)}_formatValueByString(e,t){switch(t.toLowerCase()){case`currency`:case`currency-usd`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e);case`currency-eur`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`EUR`}).format(e);case`currency-gbp`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`GBP`}).format(e);case`number`:case`number-with-commas`:return new Intl.NumberFormat(`en-US`).format(e);case`percent`:return new Intl.NumberFormat(`en-US`,{style:`percent`,minimumFractionDigits:1}).format(e/100);default:return this._hasDecimalValues()&&e%1!=0?e.toFixed(1):Math.round(e).toString()}}_formatXAxisValue(e){if(this._chartData?.formatXAxis){if(typeof this._chartData.formatXAxis==`function`)return this._chartData.formatXAxis(e);if(typeof this._chartData.formatXAxis==`string`)return String(e)}return String(e)}_escapeHtmlForTooltip(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}_tooltipXHeadingHtml(e){return`<strong>${this._escapeHtmlForTooltip(this._formatXAxisValue(e))}</strong><br/>`}_formatYAxisValue(e){if(this._chartData?.formatYAxis){if(typeof this._chartData.formatYAxis==`function`)return this._chartData.formatYAxis(e);if(typeof this._chartData.formatYAxis==`string`)return this._formatValueByString(e,this._chartData.formatYAxis)}if(this._chartData?.datasets?.[0]?.formatValue){if(typeof this._chartData.datasets[0].formatValue==`function`)return this._chartData.datasets[0].formatValue(e);if(typeof this._chartData.datasets[0].formatValue==`string`)return this._formatValueByString(e,this._chartData.datasets[0].formatValue)}return this._hasDecimalValues()&&e%1!=0?e.toFixed(1):Math.round(e).toString()}_formatValue(e,t){if(t.formatValue){if(typeof t.formatValue==`function`)return t.formatValue(e);if(typeof t.formatValue==`string`)return this._formatValueByString(e,t.formatValue)}return String(e)}_getAllDatasetsAtX(e){if(!this._chartData)return[];let t=[];return this._chartData.datasets.forEach((n,r)=>{if(!this._isDatasetVisible(n,r))return;let i=n.data.find(t=>String(t.x)===String(e));if(i){let e=this._getDatasetColor(n,r),a=this._formatValue(i.y,n);t.push({name:n.name,value:i.y,color:e,formattedValue:a})}}),t}_findNearestXValue(e){if(!this._chartData)return null;let t=this._getChartBounds(),n=this._getXValues();if(n.length===0)return null;let r=this._chartType===`bar`,i=null,a=1/0;return n.forEach(n=>{let o=r?this._scaleXForBarChart(n,t):this._scaleX(n,t),s=Math.abs(e-o);s<a&&(a=s,i=n)}),i}_setupTooltipScrollHandler(){if(this._chartTooltipScrollHandler){window.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;)e.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement}this._chartTooltipScrollHandler=()=>{this._hideTooltip(),this._pinnedXValue=null},window.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;){let t=window.getComputedStyle(e),n=t.overflow,r=t.overflowY;(n===`auto`||n===`scroll`||r===`auto`||r===`scroll`)&&e.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement}}_setupChartTooltip(){if(!this._svg||!this._showTooltip)return;this._chartTooltipMouseMove&&this._svg.removeEventListener(`mousemove`,this._chartTooltipMouseMove),this._chartTooltipMouseLeave&&this._svg.removeEventListener(`mouseleave`,this._chartTooltipMouseLeave),this._chartTooltipClick&&this._svg.removeEventListener(`click`,this._chartTooltipClick),this._chartTooltipTouchStart&&this._svg.removeEventListener(`touchstart`,this._chartTooltipTouchStart),this._chartTooltipTouchMove&&this._svg.removeEventListener(`touchmove`,this._chartTooltipTouchMove),this._chartTooltipTouchEnd&&this._svg.removeEventListener(`touchend`,this._chartTooltipTouchEnd),this._cachedTooltipContent.clear(),this._cachedXPositions.clear();let t=this._getChartBounds(),n=0,r=0,i=i=>{!this._chartContainer||!this._svg||(n=i.clientX,r=i.clientY,this._tooltipAnimationFrame!==null&&cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=requestAnimationFrame(()=>{if(this._tooltipAnimationFrame=null,!this._svg)return;let i=this._svg.getBoundingClientRect(),a=n-i.left,o=r-i.top;if(a<t.x||a>t.x+t.width||o<t.y||o>t.y+t.height){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}let s=this._findNearestXValue(a);if(!s){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}if(this._pinnedXValue!==null&&this._pinnedXValue===s){let e=this._pinnedXValue,i=this._getAllDatasetsAtX(e);if(i.length>0){this._activeXValue=e,this._showPlotPointsForX(e),this._showVerticalLineAtX(e,t);let a=this._cachedTooltipContent.get(e);a||(a=this._tooltipXHeadingHtml(e),i.forEach(e=>{a+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
97
|
+
`,document.head.appendChild(e)}}};customElements.get(`mint-off-canvas`)||customElements.define(`mint-off-canvas`,I);var L=class extends HTMLElement{static get observedAttributes(){return[`active`,`disabled`,`target`]}constructor(){super(),this._clickHandler=null}connectedCallback(){this.render(),this.setupEventListeners()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getTarget(){return this.getAttribute(`target`)||``}isActive(){let e=this.getAttribute(`active`);return e!==null&&e!==`false`}isDisabled(){return this.getAttribute(`disabled`)===`true`}get active(){return this.isActive()}set active(e){e?this.setAttribute(`active`,`true`):this.setAttribute(`active`,`false`)}render(){let e=this.isActive(),t=this.isDisabled();this.className=``,this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`inline-block`,`cursor-pointer`,`px-4`,`py-1.5`,`text-sm`,`font-medium`,`rounded-lg`,`border`,`text-gray-700`,`dark:text-gray-300`);let n=this.closest(`mint-tab-list`)?.getAttribute(`position`)||`top`,r=n===`left`||n===`right`;t?(this.classList.add(`opacity-60`,`cursor-not-allowed`,`pointer-events-none`,`bg-gray-50`,`dark:bg-mint-elevated`,`border-gray-300`,`dark:border-mint-divider`,`text-gray-400`,`dark:text-gray-500`),this.classList.remove(`cursor-pointer`)):e?(this.classList.add(`bg-white`,`dark:bg-mint-elevated`,`border-gray-200`,`dark:border-mint-divider`,`text-gray-900`,`dark:text-gray-100`,`shadow-sm`,`relative`,`z-10`),r?n===`left`?this.classList.add(`mr-[-1px]`):this.classList.add(`ml-[-1px]`):this.classList.add(`mb-[-1px]`)):this.classList.add(`bg-gray-100`,`dark:bg-mint-elevated`,`border-gray-200`,`dark:border-mint-divider`,`text-gray-600`,`dark:text-gray-400`,`hover:bg-gray-50`,`dark:hover:bg-mint-hover`)}setupEventListeners(){this.isDisabled()||this._clickHandler||(this._clickHandler=this.handleClick.bind(this),this.addEventListener(`click`,this._clickHandler))}removeEventListeners(){this._clickHandler&&=(this.removeEventListener(`click`,this._clickHandler),null)}handleClick(e){if(this.isDisabled()){e.preventDefault(),e.stopPropagation();return}e.__mintTabsSynthetic||(e.stopPropagation(),this.dispatchEvent(new CustomEvent(`tab-click`,{detail:{tab:this,target:this.getTarget()},bubbles:!0,cancelable:!0,composed:!0})))}};customElements.get(`mint-tab`)||customElements.define(`mint-tab`,L);var R=class extends HTMLElement{static get observedAttributes(){return[`position`]}constructor(){super()}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getPosition(){return this.getAttribute(`position`)||`top`}render(){let e=this.getPosition();this.classList.remove(`flex`,`inline-flex`,`flex-row`,`flex-col`,`gap-1`,`gap-2`,`pb-0`,`pr-0`,`pl-0`,`mb-0`,`mr-0`,`ml-0`,`self-start`),this.classList.add(`box-border`,`m-0`,`p-1`,`border`,`bg-gray-100`,`dark:bg-mint-elevated`,`dark:border-mint-divider`,`border-gray-200`,`w-auto`,`rounded-lg`,`gap-2`),e===`top`?this.classList.add(`inline-flex`,`flex-row`,`mb-0`,`self-start`):e===`left`?this.classList.add(`flex`,`flex-col`,`mr-0`):e===`right`&&this.classList.add(`flex`,`flex-col`,`ml-0`)}};customElements.get(`mint-tab-list`)||customElements.define(`mint-tab-list`,R);var z=class extends HTMLElement{static get observedAttributes(){return[`id`]}constructor(){super()}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`,`w-full`),this.render(),this.checkInitialVisibility()}attributeChangedCallback(e,t,n){t!==n&&e===`id`&&(this.render(),this.checkInitialVisibility())}getId(){return this.getAttribute(`id`)||``}show(){this.style.display=`block`}hide(){this.style.display=`none`}checkInitialVisibility(){let e=this.closest(`mint-tabs`);if(!e){this.style.display=`none`;return}let t=e.querySelectorAll(`mint-tab`),n=!1;t.forEach(e=>{let t=e.getAttribute(`active`),r=e.getAttribute(`target`),i=this.getId();t===`true`&&r===i&&(n=!0)}),!n&&t.length>0&&t[0].getAttribute(`target`)===this.getId()&&!e.querySelector(`mint-tab[active="true"]`)&&(n=!0),n?this.style.display=`block`:this.style.display=`none`}render(){}};customElements.get(`mint-tab-content`)||customElements.define(`mint-tab-content`,z);var B=class extends HTMLElement{constructor(){super(),this._tabClickHandler=null,this._mutationObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`block`),this.render(),this.setupEventListeners(),this.setupMutationObserver(),this.initializeActiveTab()}disconnectedCallback(){this.removeEventListeners(),this._mutationObserver&&=(this._mutationObserver.disconnect(),null)}render(){let e=this.querySelector(`mint-tab-list`);if(this.querySelectorAll(`mint-tab-content`),!e){console.warn(`mint-tabs: mint-tab-list is required`);return}let t=e.getAttribute(`position`)||`top`;this.classList.remove(`flex`,`flex-row`,`flex-col`,`gap-4`,`gap-6`),t===`left`||t===`right`?(this.classList.add(`flex`,`flex-row`,`items-start`),t===`left`?(e.classList.add(`mr-4`,`flex-shrink-0`),e.classList.remove(`ml-4`)):(e.classList.add(`ml-4`,`flex-shrink-0`,`order-2`),e.classList.remove(`mr-4`),this.querySelectorAll(`mint-tab-content`).forEach(e=>{e.classList.add(`order-1`)}))):(this.classList.add(`flex`,`flex-col`),e.classList.remove(`mr-4`,`ml-4`,`flex-shrink-0`,`order-2`),this.querySelectorAll(`mint-tab-content`).forEach(e=>{e.classList.remove(`order-1`)}))}initializeActiveTab(){requestAnimationFrame(()=>{let e=this.querySelectorAll(`mint-tab`),t=null;if(e.forEach(e=>{e.getAttribute(`active`)===`true`&&(t=e)}),!t&&e.length>0&&(t=e[0],t.setAttribute(`active`,`true`)),t){let e=t.getAttribute(`target`);e?this.showContent(e):this.hideAllContent()}else this.hideAllContent();this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.checkInitialVisibility&&t.checkInitialVisibility()})})}hideAllContent(){this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.hide?t.hide():e.style.display=`none`})}showContent(e){this.querySelectorAll(`mint-tab-content`).forEach(e=>{let t=e;t.hide?t.hide():e.style.display=`none`});let t=this.querySelector(`mint-tab-content[id="${e}"]`);t&&(t.show?t.show():t.style.display=`block`)}setupEventListeners(){this._tabClickHandler||(this._tabClickHandler=this.handleTabClick.bind(this),this.addEventListener(`tab-click`,this._tabClickHandler))}removeEventListeners(){this._tabClickHandler&&=(this.removeEventListener(`tab-click`,this._tabClickHandler),null)}setupMutationObserver(){this._mutationObserver=new MutationObserver(()=>{this.render()});let e=this.querySelector(`mint-tab-list`);e&&this._mutationObserver.observe(e,{attributes:!0,attributeFilter:[`position`]})}handleTabClick(e){let t=e.detail?.tab,n=e.detail?.target;if(!t)return;let r=t.closest(`mint-tab-list`);r&&(r.querySelectorAll(`mint-tab`).forEach(e=>{let n=e;e===t?n.active=!0:n.active=!1}),n&&this.showContent(n))}};customElements.get(`mint-tabs`)||customElements.define(`mint-tabs`,B);var V=class e extends HTMLElement{static get observedAttributes(){return[`type`,`data`,`width`,`height`,`show-legend`,`show-grid`,`show-tooltip`,`curve-tension`]}static{this.MAX_CACHE_SIZE=100}constructor(){super(),this._chartContainer=null,this._svg=null,this._tooltip=null,this._chartType=`line`,this._chartData=null,this._width=800,this._height=400,this._padding={top:20,right:20,bottom:60,left:60},this._showLegend=!0,this._showGrid=!0,this._showTooltip=!0,this._curveTension=.5,this._dataObserver=null,this._darkModeObserver=null,this._tooltipHideTimeout=null,this._lastTooltipContent=``,this._activeXValue=null,this._pinnedXValue=null,this._tooltipAnimationFrame=null,this._cachedTooltipContent=new Map,this._cachedXPositions=new Map,this._verticalLine=null,this._plotPoints=new Map,this._resizeObserver=null,this._windowResizeHandler=null,this._pieChartTimeouts=new Set,this._pieChartTooltipShown=!1,this._pieChartClickOutsideHandler=null,this._pieChartGroup=null,this._chartClickOutsideHandler=null,this._chartTooltipScrollHandler=null,this._cachedBounds={bounds:null,dataHash:``},this._cachedYRange={range:null,dataHash:``},this._cachedXValues={values:null,dataHash:``},this._renderScheduled=!1,this._datasetVisibility=new Map,this._widthValue=`100%`,this._heightValue=400,this._defaultColors=[`#2563eb`,`#3b82f6`,`#0d9488`,`#7c3aed`,`#d97706`,`#059669`,`#dc2626`,`#c026d3`],this._legendHeight=0,this._rotatedLabelHeight=0}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`,`w-full`);let e=this._getReactiveValue(this.data);e&&typeof e==`object`&&!Array.isArray(e)&&`datasets`in e&&(this._chartData=e),this._setupDataObserver(),this._setupDarkModeObserver(),this._setupResizeObserver(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.render()})})}_getReactiveValue(e){if(!e||typeof e!=`object`)return e;if(`_value`in e||`__v_isRef`in e){if(e.value!==void 0)return e.value;if(`_value`in e)return e._value}return`__v_raw`in e||`__v_isReactive`in e||`__ob__`in e,e}_setupDataObserver(){let e=null,t=0,n=()=>{if(!this.isConnected)return;let t=this._getReactiveValue(this.data),n=null;t&&typeof t==`object`&&!Array.isArray(t)&&`datasets`in t&&(n=t),n!==e&&n&&(e=n,this._chartData=n,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this.render())};requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n()})});let r=setInterval(()=>{if(!this.isConnected){clearInterval(r);return}if(n(),t++,t>50){clearInterval(r);let e=setInterval(()=>{if(!this.isConnected){clearInterval(e);return}n()},1e3);this._dataCheckInterval=e}},100);this._dataCheckInterval=r}_setupDarkModeObserver(){this._darkModeObserver=new MutationObserver(()=>{this.isConnected&&this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]})}disconnectedCallback(){if(this._tooltip&&this._tooltip.parentNode&&(this._tooltip.parentNode.removeChild(this._tooltip),this._tooltip=null),this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._pieChartTimeouts.forEach(e=>clearTimeout(e)),this._pieChartTimeouts.clear(),this._pieChartClickOutsideHandler&&=(document.removeEventListener(`click`,this._pieChartClickOutsideHandler,!0),null),this._chartClickOutsideHandler&&=(document.removeEventListener(`click`,this._chartClickOutsideHandler,!0),null),this._pieChartTooltipShown=!1,this._pieChartGroup=null,this._pinnedXValue=null,this._tooltipAnimationFrame!==null&&(cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=null),this._dataObserver&&=(this._dataObserver.disconnect(),null),this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._dataCheckInterval&&=(clearInterval(this._dataCheckInterval),null),this._svg&&(this._chartTooltipMouseMove&&=(this._svg.removeEventListener(`mousemove`,this._chartTooltipMouseMove),null),this._chartTooltipMouseLeave&&=(this._svg.removeEventListener(`mouseleave`,this._chartTooltipMouseLeave),null),this._chartTooltipTouchStart&&=(this._svg.removeEventListener(`touchstart`,this._chartTooltipTouchStart),null),this._chartTooltipTouchMove&&=(this._svg.removeEventListener(`touchmove`,this._chartTooltipTouchMove),null),this._chartTooltipTouchEnd&&=(this._svg.removeEventListener(`touchend`,this._chartTooltipTouchEnd),null)),this._chartTooltipScrollHandler){window.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;)e.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement;this._chartTooltipScrollHandler=null}this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._windowResizeHandler&&=(window.removeEventListener(`resize`,this._windowResizeHandler),null),this._cachedTooltipContent.clear(),this._cachedXPositions.clear(),this._plotPoints.clear(),this._cachedBounds={bounds:null,dataHash:``},this._cachedYRange={range:null,dataHash:``},this._cachedXValues={values:null,dataHash:``}}_handleResize(){if(!this.isConnected)return;let e=this.getBoundingClientRect(),t=e.width||this.parentElement?.clientWidth||800,n=e.height||this.parentElement?.clientHeight||400,r=this._calculateDimension(this._widthValue,t,t),i=this._calculateDimension(this._heightValue,n,400);(r!==this._width||i!==this._height)&&(this._width=r,this._height=i,this.render())}_setupResizeObserver(){this._resizeObserver&&=(this._resizeObserver.disconnect(),null),this._windowResizeHandler&&=(window.removeEventListener(`resize`,this._windowResizeHandler),null);let e=null,t=()=>{e&&clearTimeout(e),e=window.setTimeout(()=>{this._handleResize()},100)};this._windowResizeHandler=t,this._resizeObserver=new ResizeObserver(()=>{t()}),this._resizeObserver.observe(this),window.addEventListener(`resize`,t)}attributeChangedCallback(e,t,n){t!==n&&(e===`data`&&this.data&&typeof this.data==`object`&&(this._chartData=this.data),(e===`width`||e===`height`)&&this.isConnected&&(t&&t.endsWith(`%`))!==(n&&n.endsWith(`%`))&&this._setupResizeObserver(),this.isConnected&&requestAnimationFrame(()=>{this.render()}))}get type(){let e=this.getAttribute(`type`)||`line`;return e===`line`||e===`bar`||e===`area`||e===`pie`?e:`line`}set type(e){this.setAttribute(`type`,e)}get data(){return this._chartData}set data(e){if(typeof e==`string`)try{this._chartData=JSON.parse(e)}catch(e){console.error(`mint-chart: Invalid data JSON`,e),this._chartData=null}else this._chartData=e;this.isConnected&&requestAnimationFrame(()=>{this.render()})}get width(){let e=this.getAttribute(`width`);if(!e)return this._widthValue;if(e.endsWith(`%`))return e;let t=parseInt(e,10);return isNaN(t)?this._widthValue:t}set width(e){this.setAttribute(`width`,e.toString())}get height(){let e=this.getAttribute(`height`);if(!e)return this._heightValue;if(e.endsWith(`%`))return e;let t=parseInt(e,10);return isNaN(t)?this._heightValue:t}set height(e){this.setAttribute(`height`,e.toString())}_calculateDimension(e,t,n){if(typeof e==`number`)return e;if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!isNaN(n))return t*n/100}return n}_scheduleRender(){this._renderScheduled||(this._renderScheduled=!0,requestAnimationFrame(()=>{this._renderScheduled=!1,this.render()}))}_isDatasetVisible(e,t){if(e.id){let t=this._datasetVisibility.get(e.id);if(t!==void 0)return t}return e.visible!==!1}_initializeDatasetVisibility(){this._chartData&&this._chartData.datasets.forEach((e,t)=>{e.id&&(this._datasetVisibility.has(e.id)||this._datasetVisibility.set(e.id,e.visible!==!1))})}render(){if(!this.isConnected)return;this._plotPoints.clear(),this._activeXValue=null,this._cachedTooltipContent?.clear(),this._cachedXPositions?.clear(),this._chartType=this.type;let e=this._getReactiveValue(this.data);if(e&&typeof e==`object`&&!Array.isArray(e)&&`datasets`in e&&(this._chartData=e),!this._chartData){let e=this.getAttribute(`data`);if(e)try{this._chartData=JSON.parse(e)}catch(e){console.error(`mint-chart: Invalid data JSON`,e),this._chartData=null}}this._widthValue=this.width,this._heightValue=this.height;let t=this.getBoundingClientRect(),n=t.width||this.parentElement?.clientWidth||800,r=t.height||this.parentElement?.clientHeight||400;this._width=this._calculateDimension(this._widthValue,n,n),this._height=this._calculateDimension(this._heightValue,r,400),this._showLegend=this.getAttribute(`show-legend`)!==`false`,this._showGrid=this.getAttribute(`show-grid`)!==`false`,this._showTooltip=this.getAttribute(`show-tooltip`)!==`false`;let i=this.getAttribute(`curve-tension`);if(i!==null){let e=parseFloat(i);this._curveTension=isNaN(e)?.5:Math.max(0,Math.min(1,e))}else this._curveTension=.5;if(!this._chartData||!this._chartData.datasets||this._chartData.datasets.length===0){this.innerHTML=`<div class="p-4 text-gray-500">No chart data provided</div>`;return}switch(this.innerHTML=``,this._chartContainer=document.createElement(`div`),this._chartContainer.className=`relative w-full`,typeof this._widthValue==`string`&&this._widthValue.endsWith(`%`)?this._chartContainer.style.width=this._widthValue:this._chartContainer.style.width=`${this._width}px`,typeof this._heightValue==`string`&&this._heightValue.endsWith(`%`)?this._chartContainer.style.height=this._heightValue:this._chartContainer.style.height=`${this._height}px`,this.appendChild(this._chartContainer),this._svg=document.createElementNS(`http://www.w3.org/2000/svg`,`svg`),this._svg.setAttribute(`width`,this._width.toString()),this._svg.setAttribute(`height`,this._height.toString()),this._svg.setAttribute(`viewBox`,`0 0 ${this._width} ${this._height}`),this._svg.setAttribute(`class`,`w-full h-full`),this._chartContainer&&this._svg&&this._chartContainer.appendChild(this._svg),this._showTooltip&&this._createTooltip(),this._initializeDatasetVisibility(),this._calculateRotatedLabelHeight(),this._showLegend?this._legendHeight=this._calculateLegendHeight():this._legendHeight=0,this._showLegend&&this._renderLegend(),this._chartType!==`pie`&&this._pieChartClickOutsideHandler&&(document.removeEventListener(`click`,this._pieChartClickOutsideHandler,!0),this._pieChartClickOutsideHandler=null,this._pieChartTooltipShown=!1,this._pieChartGroup=null),this._pinnedXValue=null,this._chartType){case`line`:this._renderLineChart();break;case`bar`:this._renderBarChart();break;case`area`:this._renderAreaChart();break;case`pie`:this._renderPieChart();break}this._showTooltip&&this._chartType!==`pie`&&(this._setupChartTooltip(),this._setupTooltipScrollHandler()),this._createVerticalLine()}_createTooltip(){this._tooltip&&this._tooltip.parentNode&&this._tooltip.parentNode.removeChild(this._tooltip),this._tooltip=document.createElement(`div`),this._tooltip.className=`fixed pointer-events-none z-50 bg-gray-900 dark:bg-mint-elevated text-white text-xs rounded px-2 py-1 shadow-lg opacity-0`,this._tooltip.style.display=`none`,document.body.appendChild(this._tooltip)}_showTooltipAt(e,t,n){if(!this._tooltip)return;this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._lastTooltipContent!==n&&(this._tooltip.innerHTML=n,this._lastTooltipContent=n),(this._tooltip.style.display===`none`||this._tooltip.style.opacity===`0`)&&(this._tooltip.style.display=`block`,this._tooltip.style.opacity=`1`,this._tooltip.style.padding=`8px 12px`);let r=this._tooltip.getBoundingClientRect(),i=window.innerWidth,a=window.innerHeight,o=e+10,s=t-r.height-8;o+r.width>i&&(o=e-r.width-10),o<0&&(o=10),s<0&&(s=t+20),s+r.height>a&&(s=t-r.height-8,s<0&&(s=10));let c=`${o}px`,l=`${s}px`;this._tooltip.style.left!==c&&(this._tooltip.style.left=c),this._tooltip.style.top!==l&&(this._tooltip.style.top=l)}_hideTooltip(){this._tooltip&&(this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._tooltip.style.opacity=`0`,this._tooltipHideTimeout=window.setTimeout(()=>{this._tooltip&&(this._tooltip.style.display=`none`),this._tooltipHideTimeout=null},200))}_createVerticalLine(){if(!this._svg)return;this._verticalLine&&this._verticalLine.parentNode&&this._verticalLine.parentNode.removeChild(this._verticalLine),this._verticalLine=document.createElementNS(`http://www.w3.org/2000/svg`,`line`);let e=document.documentElement.classList.contains(`dark`);this._verticalLine.setAttribute(`stroke`,e?`#9ca3af`:`#6b7280`),this._verticalLine.setAttribute(`stroke-width`,`1`),this._verticalLine.setAttribute(`stroke-dasharray`,`4,2`),this._verticalLine.style.opacity=`0`,this._verticalLine.style.pointerEvents=`none`;let t=this._svg.querySelector(`.chart-legend`);t&&t.parentNode?t.parentNode.insertBefore(this._verticalLine,t):this._svg.appendChild(this._verticalLine)}_showVerticalLineAtX(e,t){if(!this._verticalLine)return;let n=this._chartType===`bar`?this._scaleXForBarChart(e,t):this._scaleX(e,t);this._verticalLine.setAttribute(`x1`,n.toString()),this._verticalLine.setAttribute(`y1`,t.y.toString()),this._verticalLine.setAttribute(`x2`,n.toString()),this._verticalLine.setAttribute(`y2`,(t.y+t.height).toString()),this._verticalLine.style.opacity=`1`}_hideVerticalLine(){this._verticalLine&&(this._verticalLine.style.opacity=`0`)}_showPlotPointsForX(e){this._plotPoints.forEach(e=>{e.forEach(e=>{e.style.opacity=`0`})});let t=String(e),n=this._plotPoints.get(t);n&&n.forEach(e=>{e.style.opacity=`1`})}_hidePlotPoints(){this._plotPoints.forEach(e=>{e.forEach(e=>{e.style.opacity=`0`})})}_calculateMaxYAxisLabelWidth(){if(!this._showGrid||!this._chartData)return 0;let e=document.createElement(`canvas`).getContext(`2d`);if(!e)return 60;e.font=`12px system-ui, -apple-system, sans-serif`;let t=this._showLegend?Math.max(this._legendHeight,60):0,n=this._height-t,r=Math.floor(n/35),i=Math.min(5,r),a=0;for(let t=0;t<=i;t++){let n=this._getYRange(),r=n.max-(n.max-n.min)/i*t,o=this._formatYAxisValue(r),s=e.measureText(o);a=Math.max(a,s.width)}return Math.ceil(a)+20}_getChartBounds(){let e=this._calculateMaxYAxisLabelWidth(),t=`${this._width}-${this._height}-${this._showGrid}-${this._showLegend}-${this._legendHeight}-${e}-${this._rotatedLabelHeight}`;if(this._cachedBounds.bounds&&this._cachedBounds.dataHash===t)return this._cachedBounds.bounds;let n=0,r=0;this._showGrid&&(n=e+10);let i=(this._rotatedLabelHeight>0?30:20)+this._rotatedLabelHeight+12,a=i;this._showLegend&&(a=i+20+Math.max(this._legendHeight,60));let o=this._height-0-n-0,s=o-a,c=1;if(s<100&&a>0){let e=o-100;e>0?(c=Math.min(1,e/a),c=Math.max(.5,c)):c=.5}r=a*c;let l=this._width*.3,u=n,d=1;n>l&&(d=l/n,u=l);let f={width:(this._width-u-0)*d,height:this._height-0-r,x:u,y:0};return this._cachedBounds={bounds:f,dataHash:t},f}_getAllDataPoints(){if(!this._chartData)return[];let e=[];return this._chartData.datasets.forEach((t,n)=>{this._isDatasetVisible(t,n)&&e.push(...t.data)}),e}_getXValues(){if(!this._chartData)return[];let e=JSON.stringify(this._chartData.labels)+JSON.stringify(this._chartData.datasets.map(e=>e.data.map(e=>e.x)));if(this._cachedXValues.values&&this._cachedXValues.dataHash===e)return this._cachedXValues.values;if(this._chartData.labels&&this._chartData.labels.length>0)return this._cachedXValues={values:this._chartData.labels,dataHash:e},this._chartData.labels;let t=new Set;this._chartData.datasets.forEach((e,n)=>{this._isDatasetVisible(e,n)&&e.data.forEach(e=>{t.add(e.x)})});let n=Array.from(t).sort((e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e-t;let n=String(e),r=String(t),i=/^([A-Za-z]{3})\s+(\d{4})$/,a=n.match(i),o=r.match(i);if(a&&o){let e=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],t=e.indexOf(a[1]),n=e.indexOf(o[1]),r=parseInt(a[2]),i=parseInt(o[2]);return r===i?t-n:r-i}return n.localeCompare(r)});return this._cachedXValues={values:n,dataHash:e},n}_getYRange(){if(!this._chartData)return{min:0,max:100};let e=JSON.stringify(this._chartData.datasets.map(e=>e.data.map(e=>e.y)));if(this._cachedYRange.range&&this._cachedYRange.dataHash===e)return this._cachedYRange.range;let t=this._getAllDataPoints();if(t.length===0){let t={min:0,max:100};return this._cachedYRange={range:t,dataHash:e},t}let n=t.map(e=>e.y),r=Math.min(...n),i=Math.max(...n),a=(i-r)*.1,o={min:Math.max(0,r-a),max:i+a};return this._cachedYRange={range:o,dataHash:e},o}_hasDecimalValues(){return this._getAllDataPoints().some(e=>e.y%1!=0)}_formatValueByString(e,t){switch(t.toLowerCase()){case`currency`:case`currency-usd`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`USD`}).format(e);case`currency-eur`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`EUR`}).format(e);case`currency-gbp`:return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:`GBP`}).format(e);case`number`:case`number-with-commas`:return new Intl.NumberFormat(`en-US`).format(e);case`percent`:return new Intl.NumberFormat(`en-US`,{style:`percent`,minimumFractionDigits:1}).format(e/100);default:return this._hasDecimalValues()&&e%1!=0?e.toFixed(1):Math.round(e).toString()}}_formatXAxisValue(e){if(this._chartData?.formatXAxis){if(typeof this._chartData.formatXAxis==`function`)return this._chartData.formatXAxis(e);if(typeof this._chartData.formatXAxis==`string`)return String(e)}return String(e)}_escapeHtmlForTooltip(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}_tooltipXHeadingHtml(e){return`<strong>${this._escapeHtmlForTooltip(this._formatXAxisValue(e))}</strong><br/>`}_formatYAxisValue(e){if(this._chartData?.formatYAxis){if(typeof this._chartData.formatYAxis==`function`)return this._chartData.formatYAxis(e);if(typeof this._chartData.formatYAxis==`string`)return this._formatValueByString(e,this._chartData.formatYAxis)}if(this._chartData?.datasets?.[0]?.formatValue){if(typeof this._chartData.datasets[0].formatValue==`function`)return this._chartData.datasets[0].formatValue(e);if(typeof this._chartData.datasets[0].formatValue==`string`)return this._formatValueByString(e,this._chartData.datasets[0].formatValue)}return this._hasDecimalValues()&&e%1!=0?e.toFixed(1):Math.round(e).toString()}_formatValue(e,t){if(t.formatValue){if(typeof t.formatValue==`function`)return t.formatValue(e);if(typeof t.formatValue==`string`)return this._formatValueByString(e,t.formatValue)}return String(e)}_getAllDatasetsAtX(e){if(!this._chartData)return[];let t=[];return this._chartData.datasets.forEach((n,r)=>{if(!this._isDatasetVisible(n,r))return;let i=n.data.find(t=>String(t.x)===String(e));if(i){let e=this._getDatasetColor(n,r),a=this._formatValue(i.y,n);t.push({name:n.name,value:i.y,color:e,formattedValue:a})}}),t}_findNearestXValue(e){if(!this._chartData)return null;let t=this._getChartBounds(),n=this._getXValues();if(n.length===0)return null;let r=this._chartType===`bar`,i=null,a=1/0;return n.forEach(n=>{let o=r?this._scaleXForBarChart(n,t):this._scaleX(n,t),s=Math.abs(e-o);s<a&&(a=s,i=n)}),i}_setupTooltipScrollHandler(){if(this._chartTooltipScrollHandler){window.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;)e.removeEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement}this._chartTooltipScrollHandler=()=>{this._hideTooltip(),this._pinnedXValue=null},window.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0);let e=this.parentElement;for(;e;){let t=window.getComputedStyle(e),n=t.overflow,r=t.overflowY;(n===`auto`||n===`scroll`||r===`auto`||r===`scroll`)&&e.addEventListener(`scroll`,this._chartTooltipScrollHandler,!0),e=e.parentElement}}_setupChartTooltip(){if(!this._svg||!this._showTooltip)return;this._chartTooltipMouseMove&&this._svg.removeEventListener(`mousemove`,this._chartTooltipMouseMove),this._chartTooltipMouseLeave&&this._svg.removeEventListener(`mouseleave`,this._chartTooltipMouseLeave),this._chartTooltipClick&&this._svg.removeEventListener(`click`,this._chartTooltipClick),this._chartTooltipTouchStart&&this._svg.removeEventListener(`touchstart`,this._chartTooltipTouchStart),this._chartTooltipTouchMove&&this._svg.removeEventListener(`touchmove`,this._chartTooltipTouchMove),this._chartTooltipTouchEnd&&this._svg.removeEventListener(`touchend`,this._chartTooltipTouchEnd),this._cachedTooltipContent.clear(),this._cachedXPositions.clear();let t=this._getChartBounds(),n=0,r=0,i=i=>{!this._chartContainer||!this._svg||(n=i.clientX,r=i.clientY,this._tooltipAnimationFrame!==null&&cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=requestAnimationFrame(()=>{if(this._tooltipAnimationFrame=null,!this._svg)return;let i=this._svg.getBoundingClientRect(),a=n-i.left,o=r-i.top;if(a<t.x||a>t.x+t.width||o<t.y||o>t.y+t.height){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}let s=this._findNearestXValue(a);if(!s){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}if(this._pinnedXValue!==null&&this._pinnedXValue===s){let e=this._pinnedXValue,i=this._getAllDatasetsAtX(e);if(i.length>0){this._activeXValue=e,this._showPlotPointsForX(e),this._showVerticalLineAtX(e,t);let a=this._cachedTooltipContent.get(e);a||(a=this._tooltipXHeadingHtml(e),i.forEach(e=>{a+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
98
98
|
<span style="display: inline-block; width: 12px; height: 12px; background-color: ${e.color}; border-radius: 2px;"></span>
|
|
99
99
|
<span>${e.name}: ${e.formattedValue}</span>
|
|
100
100
|
</div>`}),this._cachedTooltipContent.set(e,a)),this._updateTooltipPosition(n,r),this._lastTooltipContent!==a&&this._showTooltipAt(n,r,a);return}}if(this._activeXValue===s){this._updateTooltipPosition(n,r);return}let c=this._getAllDatasetsAtX(s);if(c.length===0){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine();return}this._activeXValue=s,this._showPlotPointsForX(s),this._showVerticalLineAtX(s,t);let l=this._cachedTooltipContent.get(s);if(!l){if(l=this._tooltipXHeadingHtml(s),c.forEach(e=>{l+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
|
|
@@ -130,4 +130,4 @@ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{val
|
|
|
130
130
|
display: flex;
|
|
131
131
|
align-items: center;
|
|
132
132
|
height: 100%;
|
|
133
|
-
`,a.textContent=e.name,i.appendChild(a),t.appendChild(i)}),this._svg.appendChild(t),{height:this._legendHeight+50}}async addDataPoint(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data.push(t),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async batchAddDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,point:r}of e)this._chartData.datasets[n]&&(this._chartData.datasets[n].data.push(r),t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async updateDatasetData(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data=t,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async addDataset(e){return this._chartData?(this._chartData.datasets.push(e),e.id&&this._datasetVisibility.set(e.id,e.visible!==!1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))):(console.error(`Chart data not initialized`),Promise.reject(Error(`Chart data not initialized`)))}async removeDataset(e){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets.splice(e,1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async updateDataPoint(e,t,n){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):this._chartData.datasets[e].data[t]?(this._chartData.datasets[e].data[t]=n,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))):(console.error(`Data point at index ${t} does not exist`),Promise.reject(Error(`Data point at index ${t} does not exist`)))}async batchUpdateDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,pointIndex:r,point:i}of e)this._chartData.datasets[n]?.data[r]&&(this._chartData.datasets[n].data[r]=i,t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async removeDataPoint(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data.splice(t,1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async batchRemoveDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,pointIndex:r}of e)this._chartData.datasets[n]?.data[r]&&(this._chartData.datasets[n].data.splice(r,1),t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async showDataset(e){return this._datasetVisibility.set(e,!0),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async hideDataset(e){return this._datasetVisibility.set(e,!1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async toggleDataset(e){let t=!(this._datasetVisibility.get(e)??!0);return this._datasetVisibility.set(e,t),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),await new Promise(e=>requestAnimationFrame(()=>e())),t}isDatasetVisible(e){return this._datasetVisibility.get(e)}async downloadAsPNG(e=`chart.png`){if(!this._svg)return console.error(`Chart SVG not found`),Promise.reject(Error(`Chart SVG not found`));let t=this._svg.cloneNode(!0),n=this._width,r=this._height;t.querySelectorAll(`text`).forEach(e=>{let t=e.getAttribute(`font-family`);(!t||t.includes(`system-ui`)||t.includes(`apple-system`))&&e.setAttribute(`font-family`,`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`)}),t.setAttribute(`width`,n.toString()),t.setAttribute(`height`,r.toString()),t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),t.querySelectorAll(`foreignObject`).forEach(e=>{let t=e.querySelector(`div`);if(t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`text`),r=e.getAttribute(`x`)||`0`,i=e.getAttribute(`y`)||`0`;n.setAttribute(`x`,r),n.setAttribute(`y`,(parseFloat(i)+12).toString()),n.setAttribute(`fill`,t.style.color||`#374151`),n.setAttribute(`font-size`,`12`),n.setAttribute(`font-family`,t.style.fontFamily||`system-ui, -apple-system, sans-serif`),n.textContent=t.textContent||``,e.parentNode&&e.parentNode.replaceChild(n,e)}});let i=new XMLSerializer().serializeToString(t),a=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(i),o=new Image;return o.crossOrigin=`anonymous`,new Promise((t,i)=>{o.onload=()=>{setTimeout(()=>{let a=document.createElement(`canvas`);a.width=n+60,a.height=r+60;let s=a.getContext(`2d`);if(!s){console.error(`Could not get canvas context`),i(Error(`Could not get canvas context`));return}s.fillStyle=document.documentElement.classList.contains(`dark`)?`#111827`:`#ffffff`,s.fillRect(0,0,a.width,a.height),s.drawImage(o,30,30),a.toBlob(n=>{if(!n){console.error(`Could not create blob from canvas`),i(Error(`Could not create blob from canvas`));return}let r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),t()},`image/png`)},0)},o.onerror=()=>{console.error(`Error loading SVG image`),i(Error(`Error loading SVG image`))},o.src=a})}};customElements.get(`mint-chart`)||customElements.define(`mint-chart`,L);var R=class extends HTMLElement{constructor(...e){super(...e),this._trigger=null,this._submenuContainer=null,this._contentObserver=null,this._renderFrame=null}static get observedAttributes(){return[`label`,`icon`,`href`,`active`,`expanded`,`submenu-item`]}connectedCallback(){this.classList.add(`block`),this.render(),this._observeSubmenuMutations()}disconnectedCallback(){this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`active`&&this._isSubmenuItem()&&this._refreshDropdownAncestor())}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeSubmenuMutations(){this._contentObserver||=new MutationObserver(e=>{e.some(e=>[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].some(e=>e instanceof HTMLElement&&e.getAttribute(`slot`)===`submenu`))&&this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`],subtree:!1})}_refreshDropdownAncestor(){let e=this.parentElement;for(;e;){if(e.tagName===`MINT-SIDENAV-LINK`&&e!==this){e.render();break}e=e.parentElement}}_isActive(){return this.getAttribute(`active`)===`true`}_isExpanded(){return this.getAttribute(`expanded`)===`true`}_isSubmenuPanelVisible(){return this._isExpanded()||this._isActive()}_isSubmenuItem(){return this.getAttribute(`submenu-item`)===`true`}_getLabel(){return this.getAttribute(`label`)||``}_getIcon(){return this.getAttribute(`icon`)||``}_getHref(){return this.getAttribute(`href`)}_getBaseClasses(){let e=this._isActive()?`border-black/20 bg-black/5 text-black dark:border-white/20 dark:bg-white/10 dark:text-white`:`border-transparent text-gray-700 hover:bg-black/5 dark:text-gray-200 dark:hover:bg-white/10`;return[`w-full`,`cursor-pointer`,`rounded-lg`,`border`,`block`,this._isSubmenuItem()?`px-2 py-1.5`:`px-3 py-2`,`text-left`,`text-sm`,e].join(` `)}_hasSubmenu(){return this.querySelectorAll(`:scope > [slot="submenu"]`).length>0?!0:!!this._submenuContainer&&this._submenuContainer.children.length>0}_createRow(e,t){let n=document.createElement(`span`);if(this._isSubmenuItem(),n.className=`inline-flex w-full items-center justify-start gap-2`,t){let e=document.createElement(`mint-icon`);e.setAttribute(`name`,t),e.className=`h-4 w-4 shrink-0`,n.appendChild(e)}let r=document.createElement(`span`);return r.className=`inline truncate`,r.textContent=e,n.appendChild(r),n}_buildSimpleLink(){let e=this._getHref(),t=this._getLabel(),n=this._getIcon(),r=e?document.createElement(`a`):document.createElement(`button`);e?(r.setAttribute(`href`,e),r.setAttribute(`role`,`link`)):r.setAttribute(`type`,`button`),r.className=this._getBaseClasses(),r.setAttribute(`aria-label`,t||`Side navigation link`),r.appendChild(this._createRow(t,n)),this.replaceChildren(r),this._trigger=r}_emitAccordionExpand(){this.dispatchEvent(new CustomEvent(`mint-sidenav-accordion`,{bubbles:!0,composed:!0,detail:{source:this}}))}_setExpanded(e,t){this.setAttribute(`expanded`,String(e)),e&&t&&this._emitAccordionExpand()}_buildDropdownLink(){let e=this._getLabel(),t=this._getIcon(),n=this._getHref(),r=Array.from(this.querySelectorAll(`:scope > [slot="submenu"]`)),i=r.length>0?r:this._submenuContainer?Array.from(this._submenuContainer.children):[],a=document.createElement(`div`);a.className=`w-full`,this._submenuContainer=document.createElement(`div`),this._submenuContainer.id=`mint-sidenav-submenu-${Math.random().toString(36).slice(2,11)}`;let o=this._submenuContainer.id;if(this._submenuContainer.className=[`mint-sidenav-submenu`,`mt-1`,`ml-5`,`border-l`,`border-gray-200`,`pl-2`,`space-y-1`,`dark:border-mint-divider`,this._isSubmenuPanelVisible()?`block`:`hidden`].join(` `),i.forEach(e=>{e.setAttribute(`submenu-item`,`true`),e.setAttribute(`slot`,`submenu`),this._submenuContainer?.appendChild(e)}),n){let r=document.createElement(`div`);r.className=`flex w-full items-stretch gap-1`;let i=document.createElement(`a`);i.setAttribute(`href`,n),i.className=`${this._getBaseClasses()} hidden min-[1100px]:block`,i.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),i.setAttribute(`aria-controls`,o),this._isActive()?i.setAttribute(`aria-current`,`page`):i.removeAttribute(`aria-current`),i.appendChild(this._createRow(e,t)),i.addEventListener(`click`,()=>{this._setExpanded(!0,!0)});let s=document.createElement(`a`);s.setAttribute(`href`,n),s.className=`${this._getBaseClasses()} block min-w-0 min-[1100px]:hidden`,s.style.flex=`1 1 auto`,s.setAttribute(`aria-controls`,o),s.appendChild(this._createRow(e,t)),this._isActive()?s.setAttribute(`aria-current`,`page`):s.removeAttribute(`aria-current`);let c=document.createElement(`button`);c.type=`button`,c.className=[`inline-flex`,`items-center`,`justify-center`,`rounded-lg`,`border`,`border-transparent`,`px-2`,`text-gray-600`,`hover:bg-black/5`,`dark:text-gray-300`,`dark:hover:bg-white/10`,`min-[1100px]:hidden`].join(` `),c.setAttribute(`aria-label`,`Toggle ${e} submenu`),c.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),c.setAttribute(`aria-controls`,o),c.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=!this._isExpanded();this._setExpanded(t,t)});let l=document.createElement(`mint-icon`);l.setAttribute(`name`,`caret-down`),l.className=[`h-4`,`w-4`,`transition-transform`,`duration-200`,`ease-out`,this._isSubmenuPanelVisible()?`rotate-180`:`rotate-0`].join(` `),c.appendChild(l),r.appendChild(i),r.appendChild(s),r.appendChild(c),a.appendChild(r),this._trigger=i}else{let n=document.createElement(`button`);n.type=`button`,n.className=`${this._getBaseClasses()} block w-full`,n.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),n.setAttribute(`aria-controls`,o),n.appendChild(this._createRow(e,t)),n.onclick=()=>{let e=!this._isExpanded();this._setExpanded(e,e)},a.appendChild(n),this._trigger=n}a.appendChild(this._submenuContainer),this.replaceChildren(a)}render(){this._hasSubmenu()&&!this._isSubmenuItem()?this._buildDropdownLink():this._buildSimpleLink()}};customElements.get(`mint-sidenav-link`)||customElements.define(`mint-sidenav-link`,R);var z=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._title=null,this._titleLabel=null,this._titleCaret=null,this._list=null,this._titleClickHandler=null,this._listenerCounts=new Map}static get observedAttributes(){return[`name`]}get onMintNameClick(){return this._onMintNameClick}set onMintNameClick(e){this._onMintNameClick=e,this.render()}addEventListener(e,t,n){super.addEventListener(e,t,n),this._trackListener(e,1)}removeEventListener(e,t,n){super.removeEventListener(e,t,n),this._trackListener(e,-1)}connectedCallback(){this.classList.add(`block`),this.render()}disconnectedCallback(){this._title&&this._titleClickHandler&&(this._title.removeEventListener(`click`,this._titleClickHandler),this._title.removeEventListener(`keydown`,this._titleClickHandler))}attributeChangedCallback(e,t,n){t!==n&&this.render()}_getName(){return this.getAttribute(`name`)||``}_trackListener(e,t){if(e!==`mint-name-click`)return;let n=this._listenerCounts.get(e)||0,r=Math.max(0,n+t);this._listenerCounts.set(e,r),this.render()}_isNameInteractive(){return(this._listenerCounts.get(`mint-name-click`)||0)>0||typeof this._onMintNameClick==`function`}_emitNameClick(e){let t=new CustomEvent(`mint-name-click`,{detail:{name:this._getName(),originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(t),typeof this._onMintNameClick==`function`&&this._onMintNameClick(t)}render(){this._container||(this._container=document.createElement(`section`),this._container.className=`mb-4`,this.appendChild(this._container)),this._title||(this._title=document.createElement(`button`),this._title.setAttribute(`type`,`button`),this._title.className=`mb-2 w-full`,this._titleLabel=document.createElement(`mint-text`),this._titleLabel.setAttribute(`size`,`small`),this._titleLabel.setAttribute(`bold`,`true`),this._titleCaret=document.createElement(`mint-icon`),this._titleCaret.setAttribute(`name`,`caret-right`),this._titleCaret.className=`ml-auto inline-flex h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`,this._title.appendChild(this._titleLabel),this._title.appendChild(this._titleCaret),this._titleClickHandler=e=>{this._isNameInteractive()&&(e instanceof KeyboardEvent&&e.key!==`Enter`&&e.key!==` `||(e instanceof KeyboardEvent&&e.key===` `&&e.preventDefault(),this._emitNameClick(e)))},this._title.addEventListener(`click`,this._titleClickHandler),this._title.addEventListener(`keydown`,this._titleClickHandler),this._container.appendChild(this._title));let e=this._getName(),t=e.trim().length>0,n=this._isNameInteractive();this._titleLabel&&(this._titleLabel.textContent=e,this._titleLabel.className=`uppercase tracking-wide text-gray-500 dark:text-gray-400`),this._title&&(this._title.className=n?[`mb-2`,`w-full`,`inline-flex`,`items-center`,`gap-2`,`rounded-lg`,`border`,`border-transparent`,`px-3`,`py-2`,`text-left`,`hover:bg-black/5`,`dark:hover:bg-white/10`,`cursor-pointer`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-black/20`,`dark:focus-visible:ring-white/20`].join(` `):`mb-2 w-full inline-flex items-center gap-2 rounded-lg border border-transparent px-3 py-2 text-left cursor-default`,this._title.tabIndex=n?0:-1,this._title.disabled=!n,this._title.setAttribute(`aria-disabled`,String(!n))),this._titleCaret&&(this._titleCaret.style.display=n?``:`none`,this._titleCaret.setAttribute(`aria-hidden`,String(!n))),t?this._title.parentElement!==this._container&&this._container?.insertBefore(this._title,this._list):this._title.parentElement===this._container&&this._container?.removeChild(this._title),this._list||(this._list=document.createElement(`div`),this._list.className=`space-y-1`,this._container.appendChild(this._list)),Array.from(this.children).filter(e=>e!==this._container&&e.tagName===`MINT-SIDENAV-LINK`).forEach(e=>{this._list&&e.parentElement!==this._list&&this._list.appendChild(e)})}};customElements.get(`mint-sidenav-links`)||customElements.define(`mint-sidenav-links`,z);var B=class extends HTMLElement{static get observedAttributes(){return[`separated`]}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_isSeparated(){return this.getAttribute(`separated`)===`true`}render(){this.className=this._isSeparated()?`block w-full mt-2 border-t border-gray-200 pt-2 px-2 pb-2 dark:border-mint-divider`:`block w-full p-2`}};customElements.get(`mint-sidenav-action-links`)||customElements.define(`mint-sidenav-action-links`,B);var V=class extends HTMLElement{constructor(...e){super(...e),this._wrapper=null,this._trigger=null,this._popover=null,this._triggerId=``,this._contentObserver=null,this._renderFrame=null}static get observedAttributes(){return[`title`,`subtitle`]}connectedCallback(){this.classList.add(`block`),this._triggerId=this.id?`${this.id}-trigger`:`mint-sidenav-action-menu-${Math.random().toString(36).slice(2,9)}`,this.render(),this._observeContentMutations()}disconnectedCallback(){this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getTitle(){return this.getAttribute(`title`)||``}_getSubtitle(){return this.getAttribute(`subtitle`)||``}_createDefaultGroup(){let e=document.createElement(`mint-sidenav-action-links`),t=document.createElement(`div`);return t.appendChild(e),t}render(){let e=Array.from(this.children).filter(e=>e!==this._wrapper&&e.getAttribute(`slot`)===`action-links`);this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`relative`,this.appendChild(this._wrapper)),this._wrapper.innerHTML=``,this._trigger=document.createElement(`button`),this._trigger.type=`button`,this._trigger.id=this._triggerId,this._trigger.className=`flex w-full cursor-pointer items-center gap-3 rounded-xl border border-gray-200 bg-gray-50 px-3 py-2 text-left hover:bg-gray-100 dark:border-mint-divider dark:bg-white/5 dark:hover:bg-white/10`;let t=document.createElement(`div`);t.className=`inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gray-700 text-xs font-semibold text-white dark:bg-mint-nav`,t.textContent=this._getTitle().split(` `).map(e=>e[0]).join(``).slice(0,2).toUpperCase();let n=document.createElement(`div`);n.className=`min-w-0 flex-1`;let r=document.createElement(`mint-text`);r.setAttribute(`size`,`body`),r.setAttribute(`bold`,`true`),r.className=`truncate text-gray-900 dark:text-gray-100`,r.textContent=this._getTitle();let i=document.createElement(`mint-text`);i.setAttribute(`size`,`small`),i.setAttribute(`variant`,`muted`),i.className=`truncate`,i.textContent=this._getSubtitle(),n.appendChild(r),n.appendChild(i),this._trigger.appendChild(t),this._trigger.appendChild(n),this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`trigger-id`,this._triggerId),this._popover.setAttribute(`direction`,`right`),this._popover.setAttribute(`padding`,`0`);let a=document.createElement(`div`);a.className=`w-64`,e.length>0?e.forEach(e=>{e.setAttribute(`hidden`,`true`);let t=e.cloneNode(!0);t.removeAttribute(`hidden`),t.removeAttribute(`slot`),a.appendChild(t)}):a.appendChild(this._createDefaultGroup()),this._popover.appendChild(a),this._wrapper.appendChild(this._trigger),this._wrapper.appendChild(this._popover)}};customElements.get(`mint-sidenav-action-menu`)||customElements.define(`mint-sidenav-action-menu`,V);var H=`mint:url-change`;function U(){if(window.__mintUrlChangePatched)return;window.__mintUrlChangePatched=!0;let e=()=>{window.dispatchEvent(new Event(H))},t=t=>{let n=history[t].bind(history);history[t]=((...t)=>{let r=n(...t);return e(),r})};t(`pushState`),t(`replaceState`)}var W=class extends HTMLElement{constructor(...e){super(...e),this._backdrop=null,this._container=null,this._header=null,this._content=null,this._footer=null,this._escapeHandler=null,this._mediaQuery=null,this._mediaListener=null,this._accordionHandler=null,this._urlChangeHandler=null,this._contentObserver=null,this._renderFrame=null,this._onMobileNavNavigateClick=e=>{if(this._mediaQuery?.matches)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||!this._container?.contains(n))return;let r=n.getAttribute(`href`);!r||r===`#`||r.trim().toLowerCase().startsWith(`javascript:`)||this._isOpen()&&this.removeAttribute(`open`)}}static get observedAttributes(){return[`user-name`,`user-status`,`open`,`drawer-top-class`]}connectedCallback(){this.classList.add(`relative`,`block`,`shrink-0`,`w-0`,`overflow-visible`,`min-[1100px]:w-[17rem]`,`min-[1100px]:shrink-0`),this._attachEscapeListener(),this._attachMediaListener(),this._attachAccordionListener(),this._attachUrlChangeListener(),this._observeContentMutations(),this.render()}disconnectedCallback(){this._detachEscapeListener(),this._detachMediaListener(),this._detachAccordionListener(),this._detachUrlChangeListener(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_attachEscapeListener(){this._escapeHandler||(this._escapeHandler=e=>{e.key===`Escape`&&this.getAttribute(`open`)===`true`&&this.removeAttribute(`open`)},document.addEventListener(`keydown`,this._escapeHandler))}_detachEscapeListener(){this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler),null)}_attachMediaListener(){this._mediaListener||(this._mediaQuery=window.matchMedia(`(min-width: 1100px)`),this._mediaListener=()=>{this._mediaQuery?.matches&&this.removeAttribute(`open`)},this._mediaQuery.addEventListener(`change`,this._mediaListener))}_detachMediaListener(){this._mediaQuery&&this._mediaListener&&this._mediaQuery.removeEventListener(`change`,this._mediaListener),this._mediaQuery=null,this._mediaListener=null}_attachAccordionListener(){this._accordionHandler||(this._accordionHandler=e=>{let t=e.detail?.source;!(t instanceof HTMLElement)||t.tagName!==`MINT-SIDENAV-LINK`||this.contains(t)&&this.querySelectorAll(`mint-sidenav-link`).forEach(e=>{e!==t&&e.querySelector(`:scope .mint-sidenav-submenu`)&&e.setAttribute(`expanded`,`false`)})},this.addEventListener(`mint-sidenav-accordion`,this._accordionHandler))}_detachAccordionListener(){this._accordionHandler&&=(this.removeEventListener(`mint-sidenav-accordion`,this._accordionHandler),null)}_attachUrlChangeListener(){this._urlChangeHandler||(U(),this._urlChangeHandler=()=>{this._mediaQuery?.matches||this._isOpen()&&this.removeAttribute(`open`)},window.addEventListener(`popstate`,this._urlChangeHandler),window.addEventListener(`hashchange`,this._urlChangeHandler),window.addEventListener(H,this._urlChangeHandler))}_detachUrlChangeListener(){this._urlChangeHandler&&=(window.removeEventListener(`popstate`,this._urlChangeHandler),window.removeEventListener(`hashchange`,this._urlChangeHandler),window.removeEventListener(H,this._urlChangeHandler),null)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getUserName(){return this.getAttribute(`user-name`)||`Acme Inc`}getUserStatus(){return this.getAttribute(`user-status`)||`Enterprise`}_isOpen(){return this.getAttribute(`open`)===`true`}_ensureBackdrop(){this._backdrop||(this._backdrop=document.createElement(`div`),this._backdrop.setAttribute(`aria-hidden`,`true`),this._backdrop.addEventListener(`click`,()=>this.removeAttribute(`open`)),this.insertBefore(this._backdrop,this.firstChild))}_ensureContainer(){this._container||(this._container=document.createElement(`aside`),this._container.addEventListener(`click`,this._onMobileNavNavigateClick,!0),this.appendChild(this._container))}_syncShell(){let e=`max-[1099.98px]:top-14`,t=this._isOpen();if(this._backdrop&&(this._backdrop.className=[`fixed`,e,`left-0`,`right-0`,`bottom-0`,`z-40`,`bg-black/50`,`transition-opacity`,`duration-200`,`min-[1100px]:hidden`,t?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`].join(` `)),this._container){let n=t?`max-[1099.98px]:translate-x-0`:`max-[1099.98px]:-translate-x-full`;this._container.className=[`flex`,`min-h-0`,`flex-col`,`border-r`,`border-gray-200`,`bg-white`,`p-2`,`dark:border-mint-divider`,`dark:bg-mint-nav`,`w-[4.75rem]`,`max-[1099.98px]:fixed`,e,`max-[1099.98px]:bottom-0`,`max-[1099.98px]:left-0`,`max-[1099.98px]:z-50`,`max-[1099.98px]:h-auto`,`max-[1099.98px]:w-[17rem]`,`max-[1099.98px]:max-w-[85vw]`,`max-[1099.98px]:shadow-xl`,`max-[1099.98px]:transition-transform`,`max-[1099.98px]:duration-200`,`max-[1099.98px]:ease-out`,n,`min-[1100px]:fixed`,`min-[1100px]:left-0`,`min-[1100px]:top-14`,`min-[1100px]:bottom-0`,`min-[1100px]:z-[60]`,`min-[1100px]:w-[17rem]`,`min-[1100px]:p-3`,`min-[1100px]:shadow-none`].join(` `)}}_buildUserHeader(){if(!this._container)return;this._header||(this._header=document.createElement(`div`),this._header.className=`mb-4`,this._container.appendChild(this._header));let e=Array.from(this.querySelectorAll(`[slot="action-header"]`)).find(e=>e!==this._backdrop&&e!==this._container);if(e){this._header.replaceChildren(e);return}let t=document.createElement(`mint-sidenav-action-menu`);t.setAttribute(`title`,this.getUserName()),t.setAttribute(`subtitle`,this.getUserStatus()),this._header.replaceChildren(t)}_replaceSlottedChildren(e,t){let n=Array.from(this.querySelectorAll(`[slot="${t}"]`)).filter(e=>e!==this._container&&e!==this._backdrop);e.replaceChildren(...n)}_buildContent(){this._container&&(this._content||(this._content=document.createElement(`div`),this._content.className=`min-h-0 grow overflow-y-auto`,this._container.appendChild(this._content)),this._replaceSlottedChildren(this._content,`links`))}_buildFooter(){if(!this._container)return;this._footer||(this._footer=document.createElement(`div`),this._footer.className=`mt-auto border-t border-gray-200 py-3 dark:border-mint-divider`,this._container.appendChild(this._footer));let e=document.createElement(`div`);e.className=`space-y-1`,this._replaceSlottedChildren(e,`bottom-links`),this._footer.innerHTML=``,this._footer.appendChild(e)}render(){this._ensureBackdrop(),this._ensureContainer(),this._syncShell(),this._buildUserHeader(),this._buildContent(),this._buildFooter()}};customElements.get(`mint-side-navigation`)||customElements.define(`mint-side-navigation`,W);var G=class extends HTMLElement{constructor(...e){super(...e),this._bar=null,this._menuButton=null,this._logoLink=null,this._menuClickHandler=null,this._darkModeObserver=null,this._contentObserver=null,this._resizeHandler=null,this._desktopSearchInput=null,this._desktopSearchShell=null,this._mobileSearchButton=null,this._searchPanel=null,this._searchPanelInput=null,this._searchResultsWrap=null,this._searchStateWrap=null,this._searchDebounceId=null,this._searchAbortController=null,this._searchOpen=!1,this._searchQuery=``,this._globalKeydownHandler=null,this._docClickHandler=null,this._renderFrame=null}static get observedAttributes(){return[`logo-src`,`logo-src-light`,`logo-src-dark`,`logo-src-mobile`,`logo-src-mobile-light`,`logo-src-mobile-dark`,`logo-href`,`logo-alt`,`menu-target`,`search-endpoint`,`search-param`,`search-placeholder`]}connectedCallback(){this.classList.add(`relative`,`block`,`h-14`,`w-full`,`shrink-0`),this._observeDarkMode(),this._observeContentMutations(),this._attachResizeListener(),this._attachGlobalHandlers(),this.render()}disconnectedCallback(){this._menuButton&&this._menuClickHandler&&(this._menuButton.removeEventListener(`click`,this._menuClickHandler),this._menuClickHandler=null),this._disconnectDarkModeObserver(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._detachResizeListener(),this._detachGlobalHandlers(),this._cancelSearchDebounce(),this._abortSearch()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_isDarkMode(){return document.documentElement.classList.contains(`dark`)}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_getLogoSrc(){let e=this.getAttribute(`logo-src`)||``,t=this.getAttribute(`logo-src-light`)||``,n=this.getAttribute(`logo-src-dark`)||``,r=this.getAttribute(`logo-src-mobile`)||``,i=this.getAttribute(`logo-src-mobile-light`)||``,a=this.getAttribute(`logo-src-mobile-dark`)||``,o=this._isDarkMode(),s=this._isMobileViewport();return s&&o?a||r||n||t||e:s&&!o?i||r||t||n||e:o?n||t||e:t||n||e}_getLogoHref(){return this.getAttribute(`logo-href`)||`/`}_getLogoAlt(){return this.getAttribute(`logo-alt`)||`Home`}_getMenuTargetId(){return(this.getAttribute(`menu-target`)||``).replace(/^#/,``)}_getSearchEndpoint(){return(this.getAttribute(`search-endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getSearchPlaceholder(){return this.getAttribute(`search-placeholder`)||`Search`}_isSearchEnabled(){return!!this._getSearchEndpoint()}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`k`){e.preventDefault(),this._openSearch(!0);return}t===`escape`&&this._searchOpen&&this._closeSearch()},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docClickHandler||(this._docClickHandler=e=>{if(!this._searchOpen)return;let t=e.target;t&&(this.contains(t)||this._closeSearch())},document.addEventListener(`click`,this._docClickHandler))}_detachGlobalHandlers(){this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._docClickHandler&&=(document.removeEventListener(`click`,this._docClickHandler),null)}_cancelSearchDebounce(){this._searchDebounceId!==null&&(window.clearTimeout(this._searchDebounceId),this._searchDebounceId=null)}_abortSearch(){this._searchAbortController&&=(this._searchAbortController.abort(),null)}_openSearch(e=!1){if(this._isSearchEnabled()&&(this._searchOpen=!0,this._syncSearchPanelVisibility(),e)){let e=this._isMobileViewport()?this._searchPanelInput:this._desktopSearchInput;e?.focus(),e?.select()}}_closeSearch(){this._searchOpen=!1,this._syncSearchPanelVisibility()}_syncSearchPanelVisibility(){this._searchPanel&&(this._searchPanel.classList.toggle(`hidden`,!this._searchOpen),this._syncDesktopSearchOpenState(),this._positionSearchPanel())}_syncDesktopSearchOpenState(){this._desktopSearchShell&&(this._desktopSearchShell.classList.toggle(`rounded-b-none`,this._searchOpen),this._desktopSearchShell.classList.toggle(`border-b-transparent`,this._searchOpen))}_positionSearchPanel(){if(!this._searchPanel)return;if(this._isMobileViewport()||!this._desktopSearchShell){this._searchPanel.style.left=``,this._searchPanel.style.right=``,this._searchPanel.style.top=``,this._searchPanel.style.width=``,this._searchPanel.style.maxWidth=``,this._searchPanel.style.transform=``;return}let e=this._desktopSearchShell.getBoundingClientRect();this._searchPanel.style.left=`${e.left}px`,this._searchPanel.style.right=`auto`,this._searchPanel.style.top=`${e.bottom-1}px`,this._searchPanel.style.width=`${e.width}px`,this._searchPanel.style.maxWidth=`${e.width}px`,this._searchPanel.style.transform=`none`}_setSearchQuery(e){this._searchQuery=e,this._desktopSearchInput&&this._desktopSearchInput.value!==e&&(this._desktopSearchInput.value=e),this._searchPanelInput&&this._searchPanelInput.value!==e&&(this._searchPanelInput.value=e)}_normalizeResults(e){return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim()}}).slice(0,8)}_renderSearchState(e){this._searchStateWrap&&(this._searchStateWrap.textContent=e,this._searchStateWrap.classList.remove(`hidden`),this._searchResultsWrap&&(this._searchResultsWrap.innerHTML=``))}_renderSearchResults(e){if(!(!this._searchResultsWrap||!this._searchStateWrap)){if(this._searchResultsWrap.innerHTML=``,e.length===0){this._renderSearchState(`No results found`);return}this._searchStateWrap.classList.add(`hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`flex w-full cursor-pointer items-start gap-3 rounded-lg px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/10`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mt-0.5 h-4 w-4 text-gray-500 dark:text-gray-400`;let r=document.createElement(`div`);r.className=`min-w-0`;let i=document.createElement(`div`);if(i.className=`truncate text-sm font-semibold text-gray-900 dark:text-gray-100`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`truncate text-xs text-gray-500 dark:text-gray-400`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._searchQuery,result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._searchResultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getSearchEndpoint();if(!t)return;let n=e.trim();if(!n){this._renderSearchState(`Start typing to search`);return}this._abortSearch(),this._searchAbortController=new AbortController,this._renderSearchState(`Searching...`);let r=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${encodeURIComponent(this._getSearchParam())}=${encodeURIComponent(n)}`;fetch(r,{signal:this._searchAbortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._renderSearchResults(t)}).catch(e=>{e?.name!==`AbortError`&&this._renderSearchState(`Unable to load results`)})}_scheduleSearch(e){this._setSearchQuery(e),this._cancelSearchDebounce(),this._searchDebounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>this.render()),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_disconnectDarkModeObserver(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_attachResizeListener(){this._resizeHandler||(this._resizeHandler=()=>{this.render(),this._positionSearchPanel()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0}))}_detachResizeListener(){this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}_toggleMenuTarget(){let e=this._getMenuTargetId();if(!e)return;let t=document.getElementById(e);!t||t.tagName!==`MINT-SIDE-NAVIGATION`||(t.getAttribute(`open`)===`true`?t.removeAttribute(`open`):t.setAttribute(`open`,`true`))}render(){if(this._bar||(this._bar=document.createElement(`div`),this._bar.className=`fixed inset-x-0 top-0 z-50 flex h-14 w-full items-center gap-2 border-b border-gray-200 bg-white px-3 dark:border-mint-divider dark:bg-mint-nav`,this.appendChild(this._bar)),!this._menuButton){this._menuButton=document.createElement(`button`),this._menuButton.type=`button`,this._menuButton.className=`inline-flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-transparent text-gray-700 hover:bg-black/5 min-[1100px]:hidden dark:text-gray-200 dark:hover:bg-white/10`,this._menuButton.setAttribute(`aria-label`,`Open navigation menu`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`menu`),e.className=`h-5 w-5`,this._menuButton.appendChild(e),this._menuClickHandler=()=>this._toggleMenuTarget(),this._menuButton.addEventListener(`click`,this._menuClickHandler),this._bar.appendChild(this._menuButton)}let e=!!this._getMenuTargetId();this._menuButton.classList.toggle(`hidden`,!e),this._logoLink||(this._logoLink=document.createElement(`a`),this._logoLink.className=`flex h-8 w-40 shrink-0 items-center`,this._bar.appendChild(this._logoLink)),this._logoLink.href=this._getLogoHref(),this._logoLink.setAttribute(`aria-label`,this._getLogoAlt());let t=this._getLogoSrc();if(t){let e=document.createElement(`img`);e.className=`h-full w-full object-contain [aspect-ratio:5/1]`,e.decoding=`async`,e.src=t,e.alt=this._getLogoAlt(),this._logoLink.replaceChildren(e),this._logoLink.classList.remove(`pointer-events-none`,`opacity-40`)}else{this._logoLink.replaceChildren(),this._logoLink.classList.add(`pointer-events-none`,`opacity-40`);let e=document.createElement(`span`);e.className=`text-sm font-semibold text-gray-400 dark:text-gray-500`,e.textContent=`Logo`,this._logoLink.appendChild(e)}let n=Array.from(this.querySelectorAll(`[slot="center"]`)),r=n.length>0,i=this._isSearchEnabled()&&!r,a=this._bar.querySelector(`[data-mint-topnav-center]`);if(a||(a=document.createElement(`div`),a.setAttribute(`data-mint-topnav-center`,`true`),this._bar.appendChild(a)),a.className=r?`min-w-0 flex-1 px-2 min-[1100px]:flex min-[1100px]:justify-center min-[1100px]:px-4`:`max-[1099.98px]:hidden min-[1100px]:flex min-[1100px]:min-w-0 min-[1100px]:flex-1 min-[1100px]:justify-center min-[1100px]:px-4`,a.classList.toggle(`min-[1100px]:hidden`,!i&&!r),r&&(a.replaceChildren(...n),this._closeSearch()),i&&!this._desktopSearchInput){let e=document.createElement(`div`);e.className=`relative w-full max-w-xl rounded-xl border border-gray-300 bg-gray-50 px-3 py-2 dark:border-mint-divider dark:bg-mint-hover`,this._desktopSearchShell=e;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.className=`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500 dark:text-gray-400`,this._desktopSearchInput=document.createElement(`input`),this._desktopSearchInput.type=`search`,this._desktopSearchInput.className=`w-full bg-transparent pl-6 pr-20 text-sm text-gray-900 outline-none placeholder:text-gray-500 dark:text-gray-100 dark:placeholder:text-gray-400`,this._desktopSearchInput.placeholder=this._getSearchPlaceholder(),this._desktopSearchInput.addEventListener(`focus`,()=>this._openSearch(!1)),this._desktopSearchInput.addEventListener(`input`,e=>this._scheduleSearch(e.target.value));let n=document.createElement(`span`);n.className=`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gray-500 dark:text-gray-400`,n.textContent=`⌘K`,e.appendChild(t),e.appendChild(this._desktopSearchInput),e.appendChild(n),a.appendChild(e)}i&&this._desktopSearchInput&&(this._desktopSearchInput.placeholder=this._getSearchPlaceholder(),this._desktopSearchShell=this._desktopSearchInput.closest(`div`),this._syncDesktopSearchOpenState());let o=this._bar.querySelector(`[data-mint-topnav-mobile-spacer]`);o||(o=document.createElement(`div`),o.setAttribute(`data-mint-topnav-mobile-spacer`,`true`),o.className=`min-w-0 flex-1 min-[1100px]:hidden`,this._bar.appendChild(o));let s=Array.from(this.querySelectorAll(`[slot="actions"]`)),c=this._bar.querySelector(`[data-mint-topnav-actions]`);if(c||(c=document.createElement(`div`),c.setAttribute(`data-mint-topnav-actions`,`true`),c.className=`flex shrink-0 items-center gap-2`,this._bar.appendChild(c)),i&&!this._mobileSearchButton){this._mobileSearchButton=document.createElement(`button`),this._mobileSearchButton.type=`button`,this._mobileSearchButton.className=`inline-flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-transparent text-gray-700 hover:bg-black/5 min-[1100px]:hidden dark:text-gray-200 dark:hover:bg-white/10`,this._mobileSearchButton.setAttribute(`aria-label`,`Open search`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`search`),e.className=`h-5 w-5`,this._mobileSearchButton.appendChild(e),this._mobileSearchButton.addEventListener(`click`,()=>this._openSearch(!0)),c.insertBefore(this._mobileSearchButton,c.firstChild)}if(this._mobileSearchButton&&this._mobileSearchButton.classList.toggle(`hidden`,!i),c.replaceChildren(...s),i&&this._mobileSearchButton&&!s.includes(this._mobileSearchButton)&&c.insertBefore(this._mobileSearchButton,c.firstChild),i&&!this._searchPanel){this._searchPanel=document.createElement(`div`),this._searchPanel.className=`fixed left-0 right-0 top-14 z-[90] hidden p-3 min-[1100px]:p-0`;let e=document.createElement(`div`);e.className=`mx-auto w-full rounded-2xl border border-gray-200 bg-white shadow-xl dark:border-mint-divider dark:bg-mint-elevated min-[1100px]:rounded-t-none`;let t=document.createElement(`div`);t.className=`relative border-b border-gray-200 p-3 dark:border-mint-divider min-[1100px]:hidden`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`absolute left-6 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500 dark:text-gray-400`,this._searchPanelInput=document.createElement(`input`),this._searchPanelInput.type=`search`,this._searchPanelInput.className=`w-full rounded-lg border border-gray-300 bg-gray-50 py-2 pl-10 pr-3 text-sm text-gray-900 outline-none dark:border-mint-divider dark:bg-mint-hover dark:text-gray-100`,this._searchPanelInput.placeholder=this._getSearchPlaceholder(),this._searchPanelInput.addEventListener(`input`,e=>this._scheduleSearch(e.target.value)),t.appendChild(n),t.appendChild(this._searchPanelInput);let r=document.createElement(`div`);r.className=`flex flex-wrap gap-2 px-3 py-3`,[`Apps`,`Customers`,`Orders`,`Products`,`Sales channels`].forEach(e=>{let t=document.createElement(`span`);t.className=`rounded-full bg-gray-100 px-3 py-1 text-xs font-semibold text-gray-600 dark:bg-mint-hover dark:text-gray-300`,t.textContent=e,r.appendChild(t)}),this._searchStateWrap=document.createElement(`div`),this._searchStateWrap.className=`px-4 pb-4 text-sm text-gray-500 dark:text-gray-400`,this._searchStateWrap.textContent=`Start typing to search`,this._searchResultsWrap=document.createElement(`div`),this._searchResultsWrap.className=`max-h-[52vh] overflow-y-auto px-2 pb-2`,e.appendChild(t),e.appendChild(r),e.appendChild(this._searchStateWrap),e.appendChild(this._searchResultsWrap),this._searchPanel.appendChild(e),this.appendChild(this._searchPanel)}this._searchPanelInput&&(this._searchPanelInput.placeholder=this._getSearchPlaceholder()),this._syncSearchPanelVisibility(),this._positionSearchPanel()}};customElements.get(`mint-top-navigation`)||customElements.define(`mint-top-navigation`,G);var K=class e extends HTMLElement{constructor(...e){super(...e),this._shell=null,this._desktopInput=null,this._panel=null,this._panelInner=null,this._panelInput=null,this._panelFiltersWrap=null,this._panelFiltersMainRow=null,this._panelFiltersChips=null,this._panelFiltersShowAllWrap=null,this._panelFiltersShowAllBtn=null,this._panelFiltersMorePanel=null,this._filtersMoreOpen=!1,this._filterOverflowObserver=null,this._filterOverflowZeroWidthRetries=0,this._desktopFilterWrap=null,this._mobileFilterWrap=null,this._resultsWrap=null,this._stateWrap=null,this._customResultsWrap=null,this._query=``,this._searchOpen=!1,this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._debounceId=null,this._abortController=null,this._docPointerDownHandler=null,this._globalKeydownHandler=null,this._focusOutHandler=null,this._resizeHandler=null,this._desktopShortcutHint=null,this._panelSearchBar=null,this._contentObserver=null,this._renderFrame=null}static{this._filterMorePanelSeq=0}static{this._filterChipsOverflowMask=`linear-gradient(to right, #000 0%, #000 max(0%, calc(100% - 3.5rem)), transparent 100%)`}static get observedAttributes(){return[`endpoint`,`search-param`,`placeholder`,`filters`,`filter-param`,`open-shortcut`,`open-shortcut-hint`,`collapse-on-mobile`]}connectedCallback(){this.classList.add(`relative`,`block`,`w-full`,`max-w-xl`),this._attachGlobalHandlers(),this._attachFocusOutHandler(),this._attachResizeHandler(),this.render(),this._observeContentMutations()}disconnectedCallback(){this._docPointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._docPointerDownHandler,!0),null),this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null),this._focusOutHandler&&=(this.removeEventListener(`focusout`,this._focusOutHandler,!0),null),this._cancelDebounce(),this._abortSearch(),this._filterOverflowObserver&&=(this._filterOverflowObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getEndpoint(){return(this.getAttribute(`endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getPlaceholder(){return this.getAttribute(`placeholder`)||`Search`}_getFilterParam(){return(this.getAttribute(`filter-param`)||``).trim()}_getFilterOptions(){return(this.getAttribute(`filters`)||``).split(`,`).map(e=>e.trim()).filter(Boolean)}_hasSelectedFilters(){return this._selectedFilters.length>0}_getFilterChipOverflowReservePx(){let e=Math.max(1,this._getFilterOptions().length),t=this._hasSelectedFilters()?28:56;return Math.min(200,t+e*34)}_getFilterParamValue(){return this._selectedFilters.join(`,`)}_getFilterChipLabelText(){return this._selectedFilters.join(`, `)}_getCondensedFilterChipLabel(e=22){if(!this._hasSelectedFilters())return``;let[t=``]=this._selectedFilters,n=this._selectedFilters.length-1,r=Math.max(8,e-2),i=t;if(n<=0)return i.length<=r?i:`${i.slice(0,Math.max(1,r-3))}...`;let a=`${t}, and ${n} more`;return a.length<=r?a:`${a.slice(0,Math.max(1,r-3))}...`}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_collapseOnMobile(){let e=this.getAttribute(`collapse-on-mobile`);if(e===null)return!1;let t=e.trim().toLowerCase();return!(t===`false`||t===`0`||t===`off`||t===`none`)}_primarySearchInput(){return this._isMobileViewport()&&this._collapseOnMobile()?this._panelInput:this._desktopInput}_isApplePlatform(){return typeof navigator>`u`?!1:/Mac|iPhone|iPad|iPod/i.test(navigator.platform)||/Mac OS/i.test(navigator.userAgent)}_parseOpenShortcut(){let e=(this.getAttribute(`open-shortcut`)??`mod+k`).trim().toLowerCase();if(!e||e===`none`||e===`false`||e===`off`)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let t=e.split(`+`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let n=t[t.length-1],r=new Set(t.slice(0,-1).map(e=>e.toLowerCase()));return{disabled:!1,wantMod:r.has(`mod`),wantMeta:r.has(`meta`)||r.has(`cmd`)||r.has(`super`),wantCtrl:r.has(`ctrl`)||r.has(`control`),wantAlt:r.has(`alt`),wantShift:r.has(`shift`),key:n.toLowerCase()}}_eventKeyMatchesShortcutKey(e,t){let n=t.toLowerCase();return(e.key.length,e.key.toLowerCase())===n}_openShortcutMatches(e){let t=this._parseOpenShortcut();return t.disabled||!t.key||e.repeat||!this._eventKeyMatchesShortcutKey(e,t.key)||t.wantShift!==e.shiftKey||t.wantAlt!==e.altKey?!1:t.wantMod||t.wantMeta||t.wantCtrl?!(t.wantMod&&!(e.metaKey||e.ctrlKey)||t.wantMeta&&!e.metaKey||t.wantCtrl&&!e.ctrlKey):!!t.wantAlt}_getOpenShortcutHintText(){let e=this.getAttribute(`open-shortcut-hint`);if(e===`none`||e===`false`)return``;if(e!==null&&e.trim()!==``)return e.trim();let t=this._parseOpenShortcut();if(t.disabled)return``;let n=this._isApplePlatform(),r=[];t.wantMod&&r.push(n?`⌘`:`Ctrl`),t.wantMeta&&!t.wantMod&&r.push(n?`⌘`:`Meta`),t.wantCtrl&&!t.wantMod&&r.push(`Ctrl`),t.wantAlt&&r.push(`Alt`),t.wantShift&&r.push(`Shift`);let i=t.key.length===1?t.key.toUpperCase():t.key;return i?t.wantMod&&!t.wantMeta&&!t.wantCtrl&&!t.wantAlt&&!t.wantShift&&t.key.length===1?`${n?`⌘`:`Ctrl+`}${i}`:[...r,i].join(`+`):``}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{if(this._openShortcutMatches(e)){e.preventDefault(),this._openSearch(!0);return}if(e.key.toLowerCase()===`escape`&&this._searchOpen){if(this._filtersMoreOpen){this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput());return}this._closeSearch()}},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docPointerDownHandler||(this._docPointerDownHandler=e=>{if(!this._searchOpen)return;let t=e.composedPath();this._filtersMoreOpen&&this._panelFiltersWrap&&!t.includes(this._panelFiltersWrap)&&(this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput())),!(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner))&&this._closeSearch()},document.addEventListener(`pointerdown`,this._docPointerDownHandler,!0))}_attachResizeHandler(){this._resizeHandler||(this._resizeHandler=()=>{this._syncPanelVisibility(),this._syncFilterOverflow()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0}))}_attachFocusOutHandler(){this._focusOutHandler||(this._focusOutHandler=e=>{if(!this._searchOpen)return;let t=e.relatedTarget;t&&(this._shell&&this._shell.contains(t)||this._panelInner&&this._panelInner.contains(t)||this._closeSearch())},this.addEventListener(`focusout`,this._focusOutHandler,!0))}_emitSearchOpenChange(){this.dispatchEvent(new CustomEvent(`search-open-change`,{detail:{open:this._searchOpen},bubbles:!0,composed:!0}))}_openSearch(e=!1){this._getEndpoint()&&(this._searchOpen||(this._searchOpen=!0,this._syncPanelVisibility(),this._emitSearchOpenChange(),e&&this._primarySearchInput()?.focus()))}_closeSearch(){this._searchOpen&&(this._searchOpen=!1,this._filtersMoreOpen=!1,this._syncPanelVisibility(),this._emitSearchOpenChange())}_syncPanelVisibility(){if(!this._panel)return;let e=this._panelLayoutBaseClass();this._panel.className=this._searchOpen?e:`${e} hidden`,this._shell&&(this._shell.classList.toggle(`rounded-b-none`,this._searchOpen),this._shell.classList.toggle(`border-b-transparent`,this._searchOpen)),this._positionPanel(),this._searchOpen&&this._scheduleFilterOverflowSync()}_panelLayoutBaseClass(){return!this._isMobileViewport()||!this._collapseOnMobile()?`absolute left-0 right-0 top-full z-[90] p-0 -mt-[9px]`:`fixed left-0 right-0 top-12 z-[90] p-3`}_positionPanel(){this._panel&&(!this._isMobileViewport()||!this._collapseOnMobile())&&(this._panel.style.left=``,this._panel.style.right=``,this._panel.style.top=``,this._panel.style.width=``,this._panel.style.maxWidth=``,this._panel.style.transform=``)}_setQuery(e){let t=this._query;this._query=e,e!==t&&(this._selectedFilterBackspaceArmed=!1),this._desktopInput&&(this._desktopInput.value=e),this._panelInput&&(this._panelInput.value=e)}_cancelDebounce(){this._debounceId!==null&&(window.clearTimeout(this._debounceId),this._debounceId=null)}_abortSearch(){this._abortController&&=(this._abortController.abort(),null)}_normalizeResults(e){return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim(),parent:String(t.parent||t.type||t.entity||t.kind||t.category||``).trim()||void 0}}).slice(0,8)}_emitResultsChange(e,t){let n=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-results-change`,{detail:{query:this._query,filter:n,filters:[...this._selectedFilters],results:e,raw:t??null},bubbles:!0,composed:!0}))}_emitFilterChange(){let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-filter-change`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters]},bubbles:!0,composed:!0}))}_renderState(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`hidden`);return}this._stateWrap&&(this._stateWrap.textContent=e,this._stateWrap.classList.remove(`hidden`),this._resultsWrap&&(this._resultsWrap.classList.remove(`hidden`),this._resultsWrap.innerHTML=``))}_renderResults(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`hidden`);return}if(!(!this._resultsWrap||!this._stateWrap)){if(this._resultsWrap.innerHTML=``,e.length===0){this._renderState(`No results found`);return}this._stateWrap.classList.add(`hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`flex w-full cursor-pointer items-start gap-3 rounded-lg px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/10`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mt-0.5 h-4 w-4 text-gray-500 dark:text-gray-400`;let r=document.createElement(`div`);r.className=`min-w-0`;let i=document.createElement(`div`);if(i.className=`truncate text-sm font-semibold text-gray-900 dark:text-gray-100`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`truncate text-xs text-gray-500 dark:text-gray-400`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){t.preventDefault(),this._moveFocusInResults(e,1);return}if(t.key===`ArrowUp`){t.preventDefault(),this._moveFocusInResults(e,-1);return}}),e.addEventListener(`click`,()=>{let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters],result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._resultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getEndpoint();if(!t)return;let n=e.trim();if(!n){this._emitResultsChange([]),this._renderState(`Start typing to search`);return}this._abortSearch(),this._abortController=new AbortController,this._renderState(`Searching...`);let r=new URLSearchParams;r.set(this._getSearchParam(),n);let i=this._getFilterParam();i&&this._hasSelectedFilters()&&r.set(i,this._getFilterParamValue());let a=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${r.toString()}`;fetch(a,{signal:this._abortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._emitResultsChange(t,e),this._renderResults(t)}).catch(e=>{e?.name!==`AbortError`&&(this._emitResultsChange([]),this._renderState(`Unable to load results`))})}_scheduleSearch(e){this._setQuery(e),this._cancelDebounce(),this._debounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_getNativeInputValue(e){if(!e)return``;let t=e.querySelector(`input, textarea`);return t?t.value||``:e.value||``}_getCurrentInputValue(){let e=document.activeElement;return e&&this._desktopInput&&this._desktopInput.contains(e)?this._getNativeInputValue(this._desktopInput):e&&this._panelInput&&this._panelInput.contains(e)?this._getNativeInputValue(this._panelInput):this._getNativeInputValue(this._primarySearchInput())}_applyFilterSelectionChange(){let e=this._getCurrentInputValue();if(this._setQuery(e),this._emitFilterChange(),this.render(),e.trim()){this._scheduleSearch(e);return}this._cancelDebounce(),this._abortSearch(),this._emitResultsChange([]),this._renderState(`Start typing to search`)}_clearAllSelectedFilters(){this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange()}_popLastSelectedFilter(){this._selectedFilters.length!==0&&(this._selectedFilters.pop(),this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange())}_focusActiveInput(){let e=this._primarySearchInput();e&&requestAnimationFrame(()=>{e.focus()})}_focusHideFiltersControl(){let e=this._panelFiltersShowAllBtn;e&&(e.querySelector(`button`)??e).focus()}_getFilterChipElements(){return this._panelFiltersWrap?Array.from(this._panelFiltersWrap.querySelectorAll(`mint-chip`)):[]}_ensurePanelFiltersShell(){!this._panelFiltersWrap||this._panelFiltersMainRow||(this._panelFiltersWrap.replaceChildren(),this._panelFiltersWrap.className=`relative flex shrink-0 flex-col gap-2 px-3 pb-3 pt-5 min-w-0`,this._panelFiltersMainRow=document.createElement(`div`),this._panelFiltersMainRow.className=`flex min-w-0 w-full flex-nowrap items-center gap-2`,this._panelFiltersChips=document.createElement(`div`),this._panelFiltersChips.className=`flex min-w-0 flex-1 flex-nowrap items-center gap-2 overflow-x-hidden`,this._panelFiltersMorePanel=document.createElement(`div`),this._panelFiltersMorePanel.id=`mint-search-filter-more-${e._filterMorePanelSeq++}`,this._panelFiltersMorePanel.className=`hidden absolute left-0 right-0 top-full z-[95] mt-1 flex max-h-[40vh] flex-wrap gap-2 overflow-y-auto rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-mint-divider dark:bg-mint-elevated`,this._panelFiltersShowAllWrap=document.createElement(`div`),this._panelFiltersShowAllWrap.className=`relative flex min-h-0 min-w-0 shrink-0 items-center hidden`,this._panelFiltersShowAllBtn=document.createElement(`mint-button`),this._panelFiltersShowAllBtn.setAttribute(`type`,`button`),this._panelFiltersShowAllBtn.setAttribute(`variant`,`ghost`),this._panelFiltersShowAllBtn.setAttribute(`tone`,`neutral`),this._panelFiltersShowAllBtn.setAttribute(`size`,`small`),this._panelFiltersShowAllBtn.classList.add(`shrink-0`,`whitespace-nowrap`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,`false`),this._panelFiltersShowAllBtn.setAttribute(`aria-controls`,this._panelFiltersMorePanel.id),this._panelFiltersShowAllBtn.addEventListener(`click`,e=>{e.stopPropagation();let t=this._filtersMoreOpen;this._filtersMoreOpen=!this._filtersMoreOpen,this.render(),t&&requestAnimationFrame(()=>this._focusActiveInput())}),this._panelFiltersShowAllWrap.append(this._panelFiltersShowAllBtn),this._panelFiltersMainRow.append(this._panelFiltersChips,this._panelFiltersShowAllWrap),this._setPanelFiltersShowAllLabel(`Show all`),this._panelFiltersWrap.append(this._panelFiltersMainRow,this._panelFiltersMorePanel),typeof ResizeObserver<`u`&&!this._filterOverflowObserver&&(this._filterOverflowObserver=new ResizeObserver(()=>this._syncFilterOverflow()),this._filterOverflowObserver.observe(this._panelFiltersChips),this._filterOverflowObserver.observe(this._panelFiltersMainRow)))}_setPanelFiltersShowAllLabel(e){let t=this._panelFiltersShowAllBtn;if(!t)return;for(let e of Array.from(t.childNodes))e.nodeType===Node.TEXT_NODE&&e.remove();let n=t.querySelector(`button .mint-button-content`)||t.querySelector(`.mint-button-content`);if(n){n.textContent=e;return}let r=t.querySelector(`:scope > button`);if(r){r.replaceChildren(document.createTextNode(e)),t.render?.();return}t.firstElementChild||t.appendChild(document.createTextNode(e))}_scheduleFilterOverflowSync(){requestAnimationFrame(()=>{requestAnimationFrame(()=>this._syncFilterOverflow())})}_setFilterChipsEdgeFade(t){let n=this._panelFiltersChips;n&&(t?(n.style.maskImage=e._filterChipsOverflowMask,n.style.webkitMaskImage=e._filterChipsOverflowMask):(n.style.maskImage=``,n.style.webkitMaskImage=``))}_syncFilterOverflow(){if(!this._panelFiltersChips||!this._panelFiltersShowAllWrap||!this._panelFiltersShowAllBtn)return;if(this._filtersMoreOpen){this._panelFiltersShowAllWrap.classList.remove(`hidden`),this._filterOverflowZeroWidthRetries=0,this._setFilterChipsEdgeFade(!1);return}let e=this._panelFiltersChips.clientWidth;if(e===0&&this._searchOpen){this._filterOverflowZeroWidthRetries<10&&(this._filterOverflowZeroWidthRetries+=1,this._scheduleFilterOverflowSync()),this._setFilterChipsEdgeFade(!1);return}this._filterOverflowZeroWidthRetries=0;let t=this._panelFiltersChips.scrollWidth+this._getFilterChipOverflowReservePx()>e;this._panelFiltersShowAllWrap.classList.toggle(`hidden`,!t),this._setFilterChipsEdgeFade(t)}_getResultFocusableElements(){let e=this._customResultsWrap&&!this._customResultsWrap.classList.contains(`hidden`)?this._customResultsWrap:this._resultsWrap;return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`)):[]}_focusFirstChipOrResult(e=!1){let t=this._getFilterChipElements(),n=this._getResultFocusableElements();if(!e){(t[0]||n[0])?.focus();return}(n[n.length-1]||t[t.length-1])?.focus()}_moveFocusInResults(e,t){let n=this._getResultFocusableElements();if(n.length===0)return;let r=n.indexOf(e);if(r===-1)return;let i=n[r+t];if(i){i.focus();return}if(t===-1){let e=this._getFilterChipElements(),t=e[e.length-1];t?t.focus():this._focusActiveInput()}}_renderSelectedFilter(){let e=e=>{if(!e||(e.innerHTML=``,!this._hasSelectedFilters()))return;let t=document.createElement(`mint-chip`);t.setAttribute(`dismissable`,``),t.title=this._getFilterChipLabelText();let n=this._getCondensedFilterChipLabel();t.classList.add(`max-w-[min(20rem,85vw)]`,`whitespace-nowrap`,`overflow-hidden`,`text-ellipsis`,`text-xs`,`px-2`,`py-0.5`),t.style.fontSize=`0.75rem`,t.style.padding=`0.125rem 0.375rem`,t.style.height=`1.375rem`,t.style.lineHeight=`1`,t.style.whiteSpace=`nowrap`,t.style.overflow=`hidden`,t.style.textOverflow=`ellipsis`,this._selectedFilterBackspaceArmed&&t.classList.add(`ring-2`,`ring-brand-400`,`dark:ring-brand-300`),t.textContent=n,t.addEventListener(`dismiss`,e=>{e.stopPropagation(),this._clearAllSelectedFilters()}),e.appendChild(t)};e(this._desktopFilterWrap),e(this._mobileFilterWrap)}_bindInputHandlers(e){let t=()=>{this._scheduleSearch(this._getNativeInputValue(e))};e.addEventListener(`focusin`,()=>this._openSearch(!1)),e.addEventListener(`input`,t),e.addEventListener(`search`,t),e.addEventListener(`change`,t),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!1);return}if(t.key===`ArrowUp`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!0);return}if(t.key===`Tab`&&!t.shiftKey&&this._searchOpen){let e=this._getFilterChipElements(),n=this._getResultFocusableElements();if(e.length>0||n.length>0){t.preventDefault(),this._focusFirstChipOrResult(!1);return}}if(t.key!==`Backspace`)return;let n=this._getNativeInputValue(e);if(n!==this._query&&this._setQuery(n),!(n.length>0)&&this._hasSelectedFilters()){if(!this._selectedFilterBackspaceArmed){t.preventDefault(),this._selectedFilterBackspaceArmed=!0,this._renderSelectedFilter();return}t.preventDefault(),this._popLastSelectedFilter()}})}openSearch(e=!0){this._openSearch(e)}closeSearch(){this._closeSearch()}toggleSearch(e=!0){if(this._searchOpen){this._closeSearch();return}this._openSearch(e)}isSearchOpen(){return this._searchOpen}render(){let e=this._getEndpoint();if(this.classList.toggle(`hidden`,!e),!e)return;if(!this._shell){this._shell=document.createElement(`div`),this._shell.className=`relative z-[91] flex h-10 w-full`,this._desktopFilterWrap=document.createElement(`div`),this._desktopFilterWrap.className=`inline-flex shrink-0 max-w-[8.5rem]`,this._desktopFilterWrap.setAttribute(`slot`,`prepend`),this._desktopInput=document.createElement(`mint-input`),this._desktopInput.setAttribute(`type`,`search`),this._desktopInput.setAttribute(`icon`,`search`),this._desktopInput.className=`h-full min-w-0 flex-1`;let e=document.createElement(`span`);e.className=`shrink-0 text-xs text-gray-500 dark:text-gray-400`,e.setAttribute(`slot`,`append`),this._desktopShortcutHint=e,this._bindInputHandlers(this._desktopInput),this._desktopInput.appendChild(this._desktopFilterWrap),this._desktopInput.appendChild(e),this._shell.appendChild(this._desktopInput),this.appendChild(this._shell)}if(!this._panel){this._panel=document.createElement(`div`),this._panel.className=`absolute left-0 right-0 top-full z-[90] hidden p-0 -mt-[9px]`;let e=document.createElement(`div`);e.className=`mx-auto flex max-h-[calc(100dvh-4rem)] w-full flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl dark:border-mint-divider dark:bg-mint-elevated min-[1100px]:rounded-t-none min-[1100px]:border-t-0`,this._panelInner=e;let t=document.createElement(`div`);this._panelSearchBar=t,t.className=`hidden`,this._mobileFilterWrap=document.createElement(`div`),this._mobileFilterWrap.className=`inline-flex shrink-0 max-w-[8.5rem]`,this._mobileFilterWrap.setAttribute(`slot`,`prepend`),this._panelInput=document.createElement(`mint-input`),this._panelInput.setAttribute(`type`,`search`),this._panelInput.className=`min-w-0 flex-1`,this._bindInputHandlers(this._panelInput),this._panelInput.appendChild(this._mobileFilterWrap),t.appendChild(this._panelInput),this._customResultsWrap=document.createElement(`div`),this._customResultsWrap.className=`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,this._stateWrap=document.createElement(`div`),this._stateWrap.className=`px-4 pb-4 text-sm text-gray-500 dark:text-gray-400`,this._stateWrap.textContent=`Start typing to search`,this._resultsWrap=document.createElement(`div`),this._resultsWrap.className=`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,e.appendChild(t),this._panelFiltersWrap=document.createElement(`div`),e.appendChild(this._panelFiltersWrap),this._ensurePanelFiltersShell(),e.appendChild(this._customResultsWrap),e.appendChild(this._stateWrap),e.appendChild(this._resultsWrap),this._panel.appendChild(e),this.appendChild(this._panel)}let t=this._hasSelectedFilters()?``:this._getPlaceholder();if(this._desktopInput&&this._desktopInput.setAttribute(`placeholder`,t),this._panelInput&&this._panelInput.setAttribute(`placeholder`,t),this._desktopShortcutHint){let e=this._getOpenShortcutHintText();this._desktopShortcutHint.textContent=e,this._desktopShortcutHint.classList.toggle(`hidden`,!e)}if(this._panelFiltersWrap){this._ensurePanelFiltersShell();let e=this._getFilterOptions();this._selectedFilters=this._selectedFilters.filter(t=>e.includes(t));let t=e.length>0;t||(this._filtersMoreOpen=!1),this._panelFiltersWrap.classList.toggle(`hidden`,!t),this._stateWrap?.classList.toggle(`pt-4`,!t),this._resultsWrap?.classList.toggle(`pt-4`,!t),this._customResultsWrap?.classList.toggle(`pt-5`,!t),this._panelFiltersChips&&this._panelFiltersChips.replaceChildren(),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.replaceChildren();let n=this._filtersMoreOpen&&this._panelFiltersMorePanel?this._panelFiltersMorePanel:this._panelFiltersChips;for(let t of e){if(!n)break;let r=document.createElement(`mint-chip`),i=this._selectedFilters.includes(t);if(i&&r.classList.add(`ring-2`,`ring-inset`,`ring-brand-400`,`dark:ring-brand-300`),r.classList.add(`cursor-pointer`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-inset`,`focus-visible:ring-brand-400`,`inline-flex`,`items-center`,`gap-1`,`shrink-0`,`whitespace-nowrap`),i){let e=document.createElement(`span`);e.textContent=t;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`close`),n.className=`h-4 w-4 ml-2 shrink-0`,n.setAttribute(`aria-hidden`,`true`),r.append(e,n)}else r.textContent=t;r.tabIndex=0,r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,i?`Remove filter ${t}`:`Filter by ${t}`),r.dataset.mintSearchFilter=t,r.addEventListener(`pointerdown`,e=>{e.preventDefault()});let a=n=>{n&&n.stopPropagation();let r=this._filtersMoreOpen,i=this._selectedFilters.indexOf(t);i>=0?this._selectedFilters.splice(i,1):this._selectedFilters.push(t),this._selectedFilterBackspaceArmed=!1;let a=e.length>0&&this._selectedFilters.length===e.length,o=this._selectedFilters.length===0;r&&(a||o)&&(this._filtersMoreOpen=!1),this._emitFilterChange(),this._renderSelectedFilter(),this.render(),this._query.trim()&&this._scheduleSearch(this._query),r?a||o?this._focusActiveInput():requestAnimationFrame(()=>{this._getFilterChipElements().find(e=>e.dataset.mintSearchFilter===t)?.focus()}):this._focusActiveInput()};r.addEventListener(`click`,e=>a(e)),r.addEventListener(`keydown`,e=>{let t=this._getFilterChipElements(),n=t.indexOf(r);if(e.key===`Enter`||e.key===` `){e.preventDefault(),a(e);return}if(e.key===`ArrowRight`){e.preventDefault();let r=t[n+1];r&&r.focus();return}if(e.key===`ArrowLeft`){e.preventDefault();let r=t[n-1];r?r.focus():this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}if(e.key===`ArrowDown`){e.preventDefault(),this._getResultFocusableElements()[0]?.focus();return}if(e.key===`ArrowUp`){e.preventDefault(),this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}}),n.appendChild(r)}this._panelFiltersChips&&this._panelFiltersChips.classList.toggle(`hidden`,this._filtersMoreOpen),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.classList.toggle(`hidden`,!this._filtersMoreOpen),this._panelFiltersShowAllBtn&&(this._setPanelFiltersShowAllLabel(this._filtersMoreOpen?`Hide filters`:`Show all`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,this._filtersMoreOpen?`true`:`false`)),this._panelInner&&(this._filtersMoreOpen&&t?(this._panelInner.classList.remove(`overflow-hidden`),this._panelInner.classList.add(`overflow-visible`)):(this._panelInner.classList.remove(`overflow-visible`),this._panelInner.classList.add(`overflow-hidden`))),this._scheduleFilterOverflowSync()}if(this._customResultsWrap){Array.from(this.children).filter(e=>e===this._shell||e===this._panel?!1:e.getAttribute(`slot`)===`results`).forEach(e=>this._customResultsWrap.appendChild(e));let e=this._customResultsWrap.childElementCount>0;this._customResultsWrap.classList.toggle(`hidden`,!e),e?(this._stateWrap?.classList.add(`hidden`),this._resultsWrap?.classList.add(`hidden`)):this._resultsWrap?.classList.remove(`hidden`)}this._renderSelectedFilter(),this._syncResponsiveChrome(),this._syncPanelVisibility()}_syncResponsiveChrome(){let e=this._collapseOnMobile();this._shell&&(this._shell.className=e?`relative z-[91] hidden h-10 w-full min-[1100px]:flex`:`relative z-[91] flex h-10 w-full`),this._panelSearchBar&&(this._panelSearchBar.className=e?`flex shrink-0 items-center gap-2 border-b border-gray-200 p-3 dark:border-mint-divider min-[1100px]:hidden`:`hidden`)}};customElements.get(`mint-search`)||customElements.define(`mint-search`,K);var q=class extends HTMLElement{constructor(...e){super(...e),this._lastScrollY=0,this._scrollHandler=null}connectedCallback(){this.classList.add(`fixed`,`bottom-0`,`left-0`,`right-0`,`z-30`,`flex`,`w-full`,`items-stretch`,`justify-around`,`gap-1`,`border-t`,`border-gray-200`,`bg-white`,`px-1`,`pt-1`,`pb-[env(safe-area-inset-bottom,0px)]`,`min-[1100px]:hidden`,`transition-transform`,`duration-200`,`ease-out`,`translate-y-0`,`dark:border-mint-divider`,`dark:bg-mint-nav`),this.setAttribute(`role`,`navigation`),this.setAttribute(`aria-label`,`Primary`),this._lastScrollY=window.scrollY,this._attachScrollListener()}disconnectedCallback(){this._detachScrollListener()}_attachScrollListener(){this._scrollHandler||(this._scrollHandler=()=>{let e=window.scrollY;if(e<=8){this.classList.remove(`translate-y-full`),this.classList.add(`translate-y-0`),this._lastScrollY=e;return}let t=e-this._lastScrollY;Math.abs(t)<4||(t>0?(this.classList.remove(`translate-y-0`),this.classList.add(`translate-y-full`)):(this.classList.remove(`translate-y-full`),this.classList.add(`translate-y-0`)),this._lastScrollY=e)},window.addEventListener(`scroll`,this._scrollHandler,{passive:!0}))}_detachScrollListener(){this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}};customElements.get(`mint-bottom-navigation`)||customElements.define(`mint-bottom-navigation`,q);var J=class extends HTMLElement{constructor(...e){super(...e),this._root=null}static get observedAttributes(){return[`icon`,`label`,`href`,`active`]}connectedCallback(){this.classList.add(`contents`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_isActive(){return this.getAttribute(`active`)===`true`}_getLabel(){return this.getAttribute(`label`)||``}_getIcon(){return this.getAttribute(`icon`)||``}_getHref(){return this.getAttribute(`href`)}render(){let e=this._getHref(),t=this._getLabel(),n=this._getIcon(),r=this._isActive(),i=r?`text-gray-900 dark:text-gray-100`:`text-gray-600 hover:bg-black/5 dark:text-gray-300 dark:hover:bg-white/10`,a;e?(a=document.createElement(`a`),a.href=e):(a=document.createElement(`button`),a.type=`button`),a.className=`flex min-w-0 flex-1 flex-col items-center justify-center gap-1 rounded-lg px-1 py-2 text-center text-[11px] font-medium leading-tight ${i}`,a.setAttribute(`aria-current`,r?`page`:`false`),a.setAttribute(`aria-label`,t||`Navigation item`);let o=document.createElement(`span`);if(o.className=`inline-flex h-6 w-6 items-center justify-center`,n){let e=document.createElement(`mint-icon`);e.setAttribute(`name`,n),e.className=r?`h-6 w-6`:`h-6 w-6 opacity-90`,o.appendChild(e)}let s=document.createElement(`span`);s.className=`block w-full truncate`,s.textContent=t,a.appendChild(o),a.appendChild(s),this.replaceChildren(a),this._root=a}};customElements.get(`mint-bottom-nav-item`)||customElements.define(`mint-bottom-nav-item`,J),exports.Alert=E,exports.BackButton=l,exports.BottomNavItem=J,exports.BottomNavigation=q,exports.Button=r,exports.default=r,exports.Card=s,exports.Chart=L,exports.Checkbox=m,exports.Chip=C,exports.Choice=g,exports.Clickable=T,exports.DatePicker=v,exports.Dropzone=b,exports.Form=x,exports.Grid=d,exports.Icon=n,exports.Input=_,exports.Link=c,exports.Modal=f,exports.OffCanvas=M,exports.Page=u,exports.Popover=p,exports.ResourceTable=D,exports.Search=K,exports.Select=y,exports.SideNavigation=W,exports.SideNavigationActionLinks=B,exports.SideNavigationActionMenu=V,exports.SideNavigationLink=R,exports.SideNavigationLinks=z,exports.Spinner=t,exports.Stack=o,exports.Switch=i,exports.Tab=N,exports.TabContent=F,exports.TabList=P,exports.Table=S,exports.Tabs=I,exports.Tags=w,exports.Text=a,exports.TopNavigation=G;
|
|
133
|
+
`,a.textContent=e.name,i.appendChild(a),t.appendChild(i)}),this._svg.appendChild(t),{height:this._legendHeight+50}}async addDataPoint(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data.push(t),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async batchAddDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,point:r}of e)this._chartData.datasets[n]&&(this._chartData.datasets[n].data.push(r),t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async updateDatasetData(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data=t,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async addDataset(e){return this._chartData?(this._chartData.datasets.push(e),e.id&&this._datasetVisibility.set(e.id,e.visible!==!1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))):(console.error(`Chart data not initialized`),Promise.reject(Error(`Chart data not initialized`)))}async removeDataset(e){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets.splice(e,1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async updateDataPoint(e,t,n){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):this._chartData.datasets[e].data[t]?(this._chartData.datasets[e].data[t]=n,this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))):(console.error(`Data point at index ${t} does not exist`),Promise.reject(Error(`Data point at index ${t} does not exist`)))}async batchUpdateDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,pointIndex:r,point:i}of e)this._chartData.datasets[n]?.data[r]&&(this._chartData.datasets[n].data[r]=i,t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async removeDataPoint(e,t){return!this._chartData||!this._chartData.datasets[e]?(console.error(`Dataset at index ${e} does not exist`),Promise.reject(Error(`Dataset at index ${e} does not exist`))):(this._chartData.datasets[e].data.splice(t,1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async batchRemoveDataPoints(e){if(!this._chartData)return Promise.resolve();let t=!1;for(let{datasetIndex:n,pointIndex:r}of e)this._chartData.datasets[n]?.data[r]&&(this._chartData.datasets[n].data.splice(r,1),t=!0);return t&&(this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(e=>requestAnimationFrame(()=>e()))}async showDataset(e){return this._datasetVisibility.set(e,!0),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async hideDataset(e){return this._datasetVisibility.set(e,!1),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async toggleDataset(e){let t=!(this._datasetVisibility.get(e)??!0);return this._datasetVisibility.set(e,t),this._cachedBounds.dataHash=``,this._cachedYRange.dataHash=``,this._cachedXValues.dataHash=``,this._cachedTooltipContent.clear(),this._scheduleRender(),await new Promise(e=>requestAnimationFrame(()=>e())),t}isDatasetVisible(e){return this._datasetVisibility.get(e)}async downloadAsPNG(e=`chart.png`){if(!this._svg)return console.error(`Chart SVG not found`),Promise.reject(Error(`Chart SVG not found`));let t=this._svg.cloneNode(!0),n=this._width,r=this._height;t.querySelectorAll(`text`).forEach(e=>{let t=e.getAttribute(`font-family`);(!t||t.includes(`system-ui`)||t.includes(`apple-system`))&&e.setAttribute(`font-family`,`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`)}),t.setAttribute(`width`,n.toString()),t.setAttribute(`height`,r.toString()),t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),t.querySelectorAll(`foreignObject`).forEach(e=>{let t=e.querySelector(`div`);if(t){let n=document.createElementNS(`http://www.w3.org/2000/svg`,`text`),r=e.getAttribute(`x`)||`0`,i=e.getAttribute(`y`)||`0`;n.setAttribute(`x`,r),n.setAttribute(`y`,(parseFloat(i)+12).toString()),n.setAttribute(`fill`,t.style.color||`#374151`),n.setAttribute(`font-size`,`12`),n.setAttribute(`font-family`,t.style.fontFamily||`system-ui, -apple-system, sans-serif`),n.textContent=t.textContent||``,e.parentNode&&e.parentNode.replaceChild(n,e)}});let i=new XMLSerializer().serializeToString(t),a=`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(i),o=new Image;return o.crossOrigin=`anonymous`,new Promise((t,i)=>{o.onload=()=>{setTimeout(()=>{let a=document.createElement(`canvas`);a.width=n+60,a.height=r+60;let s=a.getContext(`2d`);if(!s){console.error(`Could not get canvas context`),i(Error(`Could not get canvas context`));return}s.fillStyle=document.documentElement.classList.contains(`dark`)?`#111827`:`#ffffff`,s.fillRect(0,0,a.width,a.height),s.drawImage(o,30,30),a.toBlob(n=>{if(!n){console.error(`Could not create blob from canvas`),i(Error(`Could not create blob from canvas`));return}let r=URL.createObjectURL(n),a=document.createElement(`a`);a.href=r,a.download=e,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(r),t()},`image/png`)},0)},o.onerror=()=>{console.error(`Error loading SVG image`),i(Error(`Error loading SVG image`))},o.src=a})}};customElements.get(`mint-chart`)||customElements.define(`mint-chart`,V);var H=class extends HTMLElement{constructor(...e){super(...e),this._trigger=null,this._submenuContainer=null,this._contentObserver=null,this._renderFrame=null}static get observedAttributes(){return[`label`,`icon`,`href`,`active`,`expanded`,`submenu-item`]}connectedCallback(){this.classList.add(`block`),this.render(),this._observeSubmenuMutations()}disconnectedCallback(){this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`active`&&this._isSubmenuItem()&&this._refreshDropdownAncestor())}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeSubmenuMutations(){this._contentObserver||=new MutationObserver(e=>{e.some(e=>[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].some(e=>e instanceof HTMLElement&&e.getAttribute(`slot`)===`submenu`))&&this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`],subtree:!1})}_refreshDropdownAncestor(){let e=this.parentElement;for(;e;){if(e.tagName===`MINT-SIDENAV-LINK`&&e!==this){e.render();break}e=e.parentElement}}_isActive(){return this.getAttribute(`active`)===`true`}_isExpanded(){return this.getAttribute(`expanded`)===`true`}_isSubmenuPanelVisible(){return this._isExpanded()||this._isActive()}_isSubmenuItem(){return this.getAttribute(`submenu-item`)===`true`}_getLabel(){return this.getAttribute(`label`)||``}_getIcon(){return this.getAttribute(`icon`)||``}_getHref(){return this.getAttribute(`href`)}_getBaseClasses(){let e=this._isActive()?`border-black/20 bg-black/5 text-black dark:border-white/20 dark:bg-white/10 dark:text-white`:`border-transparent text-gray-700 hover:bg-black/5 dark:text-gray-200 dark:hover:bg-white/10`;return[`w-full`,`cursor-pointer`,`rounded-lg`,`border`,`block`,this._isSubmenuItem()?`px-2 py-1.5`:`px-3 py-2`,`text-left`,`text-sm`,e].join(` `)}_hasSubmenu(){return this.querySelectorAll(`:scope > [slot="submenu"]`).length>0?!0:!!this._submenuContainer&&this._submenuContainer.children.length>0}_createRow(e,t){let n=document.createElement(`span`);if(this._isSubmenuItem(),n.className=`inline-flex w-full items-center justify-start gap-2`,t){let e=document.createElement(`mint-icon`);e.setAttribute(`name`,t),e.className=`h-4 w-4 shrink-0`,n.appendChild(e)}let r=document.createElement(`span`);return r.className=`inline truncate`,r.textContent=e,n.appendChild(r),n}_buildSimpleLink(){let e=this._getHref(),t=this._getLabel(),n=this._getIcon(),r=e?document.createElement(`a`):document.createElement(`button`);e?(r.setAttribute(`href`,e),r.setAttribute(`role`,`link`)):r.setAttribute(`type`,`button`),r.className=this._getBaseClasses(),r.setAttribute(`aria-label`,t||`Side navigation link`),r.appendChild(this._createRow(t,n)),this.replaceChildren(r),this._trigger=r}_emitAccordionExpand(){this.dispatchEvent(new CustomEvent(`mint-sidenav-accordion`,{bubbles:!0,composed:!0,detail:{source:this}}))}_setExpanded(e,t){this.setAttribute(`expanded`,String(e)),e&&t&&this._emitAccordionExpand()}_buildDropdownLink(){let e=this._getLabel(),t=this._getIcon(),n=this._getHref(),r=Array.from(this.querySelectorAll(`:scope > [slot="submenu"]`)),i=r.length>0?r:this._submenuContainer?Array.from(this._submenuContainer.children):[],a=document.createElement(`div`);a.className=`w-full`,this._submenuContainer=document.createElement(`div`),this._submenuContainer.id=`mint-sidenav-submenu-${Math.random().toString(36).slice(2,11)}`;let o=this._submenuContainer.id;if(this._submenuContainer.className=[`mint-sidenav-submenu`,`mt-1`,`ml-5`,`border-l`,`border-gray-200`,`pl-2`,`space-y-1`,`dark:border-mint-divider`,this._isSubmenuPanelVisible()?`block`:`hidden`].join(` `),i.forEach(e=>{e.setAttribute(`submenu-item`,`true`),e.setAttribute(`slot`,`submenu`),this._submenuContainer?.appendChild(e)}),n){let r=document.createElement(`div`);r.className=`flex w-full items-stretch gap-1`;let i=document.createElement(`a`);i.setAttribute(`href`,n),i.className=`${this._getBaseClasses()} hidden min-[1100px]:block`,i.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),i.setAttribute(`aria-controls`,o),this._isActive()?i.setAttribute(`aria-current`,`page`):i.removeAttribute(`aria-current`),i.appendChild(this._createRow(e,t)),i.addEventListener(`click`,()=>{this._setExpanded(!0,!0)});let s=document.createElement(`a`);s.setAttribute(`href`,n),s.className=`${this._getBaseClasses()} block min-w-0 min-[1100px]:hidden`,s.style.flex=`1 1 auto`,s.setAttribute(`aria-controls`,o),s.appendChild(this._createRow(e,t)),this._isActive()?s.setAttribute(`aria-current`,`page`):s.removeAttribute(`aria-current`);let c=document.createElement(`button`);c.type=`button`,c.className=[`inline-flex`,`items-center`,`justify-center`,`rounded-lg`,`border`,`border-transparent`,`px-2`,`text-gray-600`,`hover:bg-black/5`,`dark:text-gray-300`,`dark:hover:bg-white/10`,`min-[1100px]:hidden`].join(` `),c.setAttribute(`aria-label`,`Toggle ${e} submenu`),c.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),c.setAttribute(`aria-controls`,o),c.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation();let t=!this._isExpanded();this._setExpanded(t,t)});let l=document.createElement(`mint-icon`);l.setAttribute(`name`,`caret-down`),l.className=[`h-4`,`w-4`,`transition-transform`,`duration-200`,`ease-out`,this._isSubmenuPanelVisible()?`rotate-180`:`rotate-0`].join(` `),c.appendChild(l),r.appendChild(i),r.appendChild(s),r.appendChild(c),a.appendChild(r),this._trigger=i}else{let n=document.createElement(`button`);n.type=`button`,n.className=`${this._getBaseClasses()} block w-full`,n.setAttribute(`aria-expanded`,String(this._isSubmenuPanelVisible())),n.setAttribute(`aria-controls`,o),n.appendChild(this._createRow(e,t)),n.onclick=()=>{let e=!this._isExpanded();this._setExpanded(e,e)},a.appendChild(n),this._trigger=n}a.appendChild(this._submenuContainer),this.replaceChildren(a)}render(){this._hasSubmenu()&&!this._isSubmenuItem()?this._buildDropdownLink():this._buildSimpleLink()}};customElements.get(`mint-sidenav-link`)||customElements.define(`mint-sidenav-link`,H);var U=class extends HTMLElement{constructor(...e){super(...e),this._container=null,this._title=null,this._titleLabel=null,this._titleCaret=null,this._list=null,this._titleClickHandler=null,this._listenerCounts=new Map}static get observedAttributes(){return[`name`]}get onMintNameClick(){return this._onMintNameClick}set onMintNameClick(e){this._onMintNameClick=e,this.render()}addEventListener(e,t,n){super.addEventListener(e,t,n),this._trackListener(e,1)}removeEventListener(e,t,n){super.removeEventListener(e,t,n),this._trackListener(e,-1)}connectedCallback(){this.classList.add(`block`),this.render()}disconnectedCallback(){this._title&&this._titleClickHandler&&(this._title.removeEventListener(`click`,this._titleClickHandler),this._title.removeEventListener(`keydown`,this._titleClickHandler))}attributeChangedCallback(e,t,n){t!==n&&this.render()}_getName(){return this.getAttribute(`name`)||``}_trackListener(e,t){if(e!==`mint-name-click`)return;let n=this._listenerCounts.get(e)||0,r=Math.max(0,n+t);this._listenerCounts.set(e,r),this.render()}_isNameInteractive(){return(this._listenerCounts.get(`mint-name-click`)||0)>0||typeof this._onMintNameClick==`function`}_emitNameClick(e){let t=new CustomEvent(`mint-name-click`,{detail:{name:this._getName(),originalEvent:e},bubbles:!0,composed:!0});this.dispatchEvent(t),typeof this._onMintNameClick==`function`&&this._onMintNameClick(t)}render(){this._container||(this._container=document.createElement(`section`),this._container.className=`mb-4`,this.appendChild(this._container)),this._title||(this._title=document.createElement(`button`),this._title.setAttribute(`type`,`button`),this._title.className=`mb-2 w-full`,this._titleLabel=document.createElement(`mint-text`),this._titleLabel.setAttribute(`size`,`small`),this._titleLabel.setAttribute(`bold`,`true`),this._titleCaret=document.createElement(`mint-icon`),this._titleCaret.setAttribute(`name`,`caret-right`),this._titleCaret.className=`ml-auto inline-flex h-4 w-4 shrink-0 text-gray-500 dark:text-gray-400`,this._title.appendChild(this._titleLabel),this._title.appendChild(this._titleCaret),this._titleClickHandler=e=>{this._isNameInteractive()&&(e instanceof KeyboardEvent&&e.key!==`Enter`&&e.key!==` `||(e instanceof KeyboardEvent&&e.key===` `&&e.preventDefault(),this._emitNameClick(e)))},this._title.addEventListener(`click`,this._titleClickHandler),this._title.addEventListener(`keydown`,this._titleClickHandler),this._container.appendChild(this._title));let e=this._getName(),t=e.trim().length>0,n=this._isNameInteractive();this._titleLabel&&(this._titleLabel.textContent=e,this._titleLabel.className=`uppercase tracking-wide text-gray-500 dark:text-gray-400`),this._title&&(this._title.className=n?[`mb-2`,`w-full`,`inline-flex`,`items-center`,`gap-2`,`rounded-lg`,`border`,`border-transparent`,`px-3`,`py-2`,`text-left`,`hover:bg-black/5`,`dark:hover:bg-white/10`,`cursor-pointer`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-black/20`,`dark:focus-visible:ring-white/20`].join(` `):`mb-2 w-full inline-flex items-center gap-2 rounded-lg border border-transparent px-3 py-2 text-left cursor-default`,this._title.tabIndex=n?0:-1,this._title.disabled=!n,this._title.setAttribute(`aria-disabled`,String(!n))),this._titleCaret&&(this._titleCaret.style.display=n?``:`none`,this._titleCaret.setAttribute(`aria-hidden`,String(!n))),t?this._title.parentElement!==this._container&&this._container?.insertBefore(this._title,this._list):this._title.parentElement===this._container&&this._container?.removeChild(this._title),this._list||(this._list=document.createElement(`div`),this._list.className=`space-y-1`,this._container.appendChild(this._list)),Array.from(this.children).filter(e=>e!==this._container&&e.tagName===`MINT-SIDENAV-LINK`).forEach(e=>{this._list&&e.parentElement!==this._list&&this._list.appendChild(e)})}};customElements.get(`mint-sidenav-links`)||customElements.define(`mint-sidenav-links`,U);var W=class extends HTMLElement{static get observedAttributes(){return[`separated`]}connectedCallback(){this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_isSeparated(){return this.getAttribute(`separated`)===`true`}render(){this.className=this._isSeparated()?`block w-full mt-2 border-t border-gray-200 pt-2 px-2 pb-2 dark:border-mint-divider`:`block w-full p-2`}};customElements.get(`mint-sidenav-action-links`)||customElements.define(`mint-sidenav-action-links`,W);var G=class extends HTMLElement{constructor(...e){super(...e),this._wrapper=null,this._trigger=null,this._popover=null,this._triggerId=``,this._contentObserver=null,this._renderFrame=null}static get observedAttributes(){return[`title`,`subtitle`]}connectedCallback(){this.classList.add(`block`),this._triggerId=this.id?`${this.id}-trigger`:`mint-sidenav-action-menu-${Math.random().toString(36).slice(2,9)}`,this.render(),this._observeContentMutations()}disconnectedCallback(){this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getTitle(){return this.getAttribute(`title`)||``}_getSubtitle(){return this.getAttribute(`subtitle`)||``}_createDefaultGroup(){let e=document.createElement(`mint-sidenav-action-links`),t=document.createElement(`div`);return t.appendChild(e),t}render(){let e=Array.from(this.children).filter(e=>e!==this._wrapper&&e.getAttribute(`slot`)===`action-links`);this._wrapper||(this._wrapper=document.createElement(`div`),this._wrapper.className=`relative`,this.appendChild(this._wrapper)),this._wrapper.innerHTML=``,this._trigger=document.createElement(`button`),this._trigger.type=`button`,this._trigger.id=this._triggerId,this._trigger.className=`flex w-full cursor-pointer items-center gap-3 rounded-xl border border-gray-200 bg-gray-50 px-3 py-2 text-left hover:bg-gray-100 dark:border-mint-divider dark:bg-white/5 dark:hover:bg-white/10`;let t=document.createElement(`div`);t.className=`inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gray-700 text-xs font-semibold text-white dark:bg-mint-nav`,t.textContent=this._getTitle().split(` `).map(e=>e[0]).join(``).slice(0,2).toUpperCase();let n=document.createElement(`div`);n.className=`min-w-0 flex-1`;let r=document.createElement(`mint-text`);r.setAttribute(`size`,`body`),r.setAttribute(`bold`,`true`),r.className=`truncate text-gray-900 dark:text-gray-100`,r.textContent=this._getTitle();let i=document.createElement(`mint-text`);i.setAttribute(`size`,`small`),i.setAttribute(`variant`,`muted`),i.className=`truncate`,i.textContent=this._getSubtitle(),n.appendChild(r),n.appendChild(i),this._trigger.appendChild(t),this._trigger.appendChild(n),this._popover=document.createElement(`mint-popover`),this._popover.setAttribute(`trigger-id`,this._triggerId),this._popover.setAttribute(`direction`,`right`),this._popover.setAttribute(`padding`,`0`);let a=document.createElement(`div`);a.className=`w-64`,e.length>0?e.forEach(e=>{e.setAttribute(`hidden`,`true`);let t=e.cloneNode(!0);t.removeAttribute(`hidden`),t.removeAttribute(`slot`),a.appendChild(t)}):a.appendChild(this._createDefaultGroup()),this._popover.appendChild(a),this._wrapper.appendChild(this._trigger),this._wrapper.appendChild(this._popover)}};customElements.get(`mint-sidenav-action-menu`)||customElements.define(`mint-sidenav-action-menu`,G);var K=`mint:url-change`;function q(){if(window.__mintUrlChangePatched)return;window.__mintUrlChangePatched=!0;let e=()=>{window.dispatchEvent(new Event(K))},t=t=>{let n=history[t].bind(history);history[t]=((...t)=>{let r=n(...t);return e(),r})};t(`pushState`),t(`replaceState`)}var J=class extends HTMLElement{constructor(...e){super(...e),this._backdrop=null,this._container=null,this._header=null,this._content=null,this._footer=null,this._escapeHandler=null,this._mediaQuery=null,this._mediaListener=null,this._accordionHandler=null,this._urlChangeHandler=null,this._contentObserver=null,this._renderFrame=null,this._onMobileNavNavigateClick=e=>{if(this._mediaQuery?.matches)return;let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`a[href]`);if(!(n instanceof HTMLAnchorElement)||!this._container?.contains(n))return;let r=n.getAttribute(`href`);!r||r===`#`||r.trim().toLowerCase().startsWith(`javascript:`)||this._isOpen()&&this.removeAttribute(`open`)}}static get observedAttributes(){return[`user-name`,`user-status`,`open`,`drawer-top-class`]}connectedCallback(){this.classList.add(`relative`,`block`,`shrink-0`,`w-0`,`overflow-visible`,`min-[1100px]:w-[17rem]`,`min-[1100px]:shrink-0`),this._attachEscapeListener(),this._attachMediaListener(),this._attachAccordionListener(),this._attachUrlChangeListener(),this._observeContentMutations(),this.render()}disconnectedCallback(){this._detachEscapeListener(),this._detachMediaListener(),this._detachAccordionListener(),this._detachUrlChangeListener(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_attachEscapeListener(){this._escapeHandler||(this._escapeHandler=e=>{e.key===`Escape`&&this.getAttribute(`open`)===`true`&&this.removeAttribute(`open`)},document.addEventListener(`keydown`,this._escapeHandler))}_detachEscapeListener(){this._escapeHandler&&=(document.removeEventListener(`keydown`,this._escapeHandler),null)}_attachMediaListener(){this._mediaListener||(this._mediaQuery=window.matchMedia(`(min-width: 1100px)`),this._mediaListener=()=>{this._mediaQuery?.matches&&this.removeAttribute(`open`)},this._mediaQuery.addEventListener(`change`,this._mediaListener))}_detachMediaListener(){this._mediaQuery&&this._mediaListener&&this._mediaQuery.removeEventListener(`change`,this._mediaListener),this._mediaQuery=null,this._mediaListener=null}_attachAccordionListener(){this._accordionHandler||(this._accordionHandler=e=>{let t=e.detail?.source;!(t instanceof HTMLElement)||t.tagName!==`MINT-SIDENAV-LINK`||this.contains(t)&&this.querySelectorAll(`mint-sidenav-link`).forEach(e=>{e!==t&&e.querySelector(`:scope .mint-sidenav-submenu`)&&e.setAttribute(`expanded`,`false`)})},this.addEventListener(`mint-sidenav-accordion`,this._accordionHandler))}_detachAccordionListener(){this._accordionHandler&&=(this.removeEventListener(`mint-sidenav-accordion`,this._accordionHandler),null)}_attachUrlChangeListener(){this._urlChangeHandler||(q(),this._urlChangeHandler=()=>{this._mediaQuery?.matches||this._isOpen()&&this.removeAttribute(`open`)},window.addEventListener(`popstate`,this._urlChangeHandler),window.addEventListener(`hashchange`,this._urlChangeHandler),window.addEventListener(K,this._urlChangeHandler))}_detachUrlChangeListener(){this._urlChangeHandler&&=(window.removeEventListener(`popstate`,this._urlChangeHandler),window.removeEventListener(`hashchange`,this._urlChangeHandler),window.removeEventListener(K,this._urlChangeHandler),null)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}getUserName(){return this.getAttribute(`user-name`)||`Acme Inc`}getUserStatus(){return this.getAttribute(`user-status`)||`Enterprise`}_isOpen(){return this.getAttribute(`open`)===`true`}_ensureBackdrop(){this._backdrop||(this._backdrop=document.createElement(`div`),this._backdrop.setAttribute(`aria-hidden`,`true`),this._backdrop.addEventListener(`click`,()=>this.removeAttribute(`open`)),this.insertBefore(this._backdrop,this.firstChild))}_ensureContainer(){this._container||(this._container=document.createElement(`aside`),this._container.addEventListener(`click`,this._onMobileNavNavigateClick,!0),this.appendChild(this._container))}_syncShell(){let e=`max-[1099.98px]:top-14`,t=this._isOpen();if(this._backdrop&&(this._backdrop.className=[`fixed`,e,`left-0`,`right-0`,`bottom-0`,`z-40`,`bg-black/50`,`transition-opacity`,`duration-200`,`min-[1100px]:hidden`,t?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`].join(` `)),this._container){let n=t?`max-[1099.98px]:translate-x-0`:`max-[1099.98px]:-translate-x-full`;this._container.className=[`flex`,`min-h-0`,`flex-col`,`border-r`,`border-gray-200`,`bg-white`,`p-2`,`dark:border-mint-divider`,`dark:bg-mint-nav`,`w-[4.75rem]`,`max-[1099.98px]:fixed`,e,`max-[1099.98px]:bottom-0`,`max-[1099.98px]:left-0`,`max-[1099.98px]:z-50`,`max-[1099.98px]:h-auto`,`max-[1099.98px]:w-[17rem]`,`max-[1099.98px]:max-w-[85vw]`,`max-[1099.98px]:shadow-xl`,`max-[1099.98px]:transition-transform`,`max-[1099.98px]:duration-200`,`max-[1099.98px]:ease-out`,n,`min-[1100px]:fixed`,`min-[1100px]:left-0`,`min-[1100px]:top-14`,`min-[1100px]:bottom-0`,`min-[1100px]:z-[60]`,`min-[1100px]:w-[17rem]`,`min-[1100px]:p-3`,`min-[1100px]:shadow-none`].join(` `)}}_buildUserHeader(){if(!this._container)return;this._header||(this._header=document.createElement(`div`),this._header.className=`mb-4`,this._container.appendChild(this._header));let e=Array.from(this.querySelectorAll(`[slot="action-header"]`)).find(e=>e!==this._backdrop&&e!==this._container);if(e){this._header.replaceChildren(e);return}let t=document.createElement(`mint-sidenav-action-menu`);t.setAttribute(`title`,this.getUserName()),t.setAttribute(`subtitle`,this.getUserStatus()),this._header.replaceChildren(t)}_replaceSlottedChildren(e,t){let n=Array.from(this.querySelectorAll(`[slot="${t}"]`)).filter(e=>e!==this._container&&e!==this._backdrop);e.replaceChildren(...n)}_buildContent(){this._container&&(this._content||(this._content=document.createElement(`div`),this._content.className=`min-h-0 grow overflow-y-auto`,this._container.appendChild(this._content)),this._replaceSlottedChildren(this._content,`links`))}_buildFooter(){if(!this._container)return;this._footer||(this._footer=document.createElement(`div`),this._footer.className=`mt-auto border-t border-gray-200 py-3 dark:border-mint-divider`,this._container.appendChild(this._footer));let e=document.createElement(`div`);e.className=`space-y-1`,this._replaceSlottedChildren(e,`bottom-links`),this._footer.innerHTML=``,this._footer.appendChild(e)}render(){this._ensureBackdrop(),this._ensureContainer(),this._syncShell(),this._buildUserHeader(),this._buildContent(),this._buildFooter()}};customElements.get(`mint-side-navigation`)||customElements.define(`mint-side-navigation`,J);var Y=class extends HTMLElement{constructor(...e){super(...e),this._bar=null,this._menuButton=null,this._logoLink=null,this._menuClickHandler=null,this._darkModeObserver=null,this._contentObserver=null,this._resizeHandler=null,this._desktopSearchInput=null,this._desktopSearchShell=null,this._mobileSearchButton=null,this._searchPanel=null,this._searchPanelInput=null,this._searchResultsWrap=null,this._searchStateWrap=null,this._searchDebounceId=null,this._searchAbortController=null,this._searchOpen=!1,this._searchQuery=``,this._globalKeydownHandler=null,this._docClickHandler=null,this._renderFrame=null}static get observedAttributes(){return[`logo-src`,`logo-src-light`,`logo-src-dark`,`logo-src-mobile`,`logo-src-mobile-light`,`logo-src-mobile-dark`,`logo-href`,`logo-alt`,`menu-target`,`search-endpoint`,`search-param`,`search-placeholder`]}connectedCallback(){this.classList.add(`relative`,`block`,`h-14`,`w-full`,`shrink-0`),this._observeDarkMode(),this._observeContentMutations(),this._attachResizeListener(),this._attachGlobalHandlers(),this.render()}disconnectedCallback(){this._menuButton&&this._menuClickHandler&&(this._menuButton.removeEventListener(`click`,this._menuClickHandler),this._menuClickHandler=null),this._disconnectDarkModeObserver(),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null),this._detachResizeListener(),this._detachGlobalHandlers(),this._cancelSearchDebounce(),this._abortSearch()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_isDarkMode(){return document.documentElement.classList.contains(`dark`)}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_getLogoSrc(){let e=this.getAttribute(`logo-src`)||``,t=this.getAttribute(`logo-src-light`)||``,n=this.getAttribute(`logo-src-dark`)||``,r=this.getAttribute(`logo-src-mobile`)||``,i=this.getAttribute(`logo-src-mobile-light`)||``,a=this.getAttribute(`logo-src-mobile-dark`)||``,o=this._isDarkMode(),s=this._isMobileViewport();return s&&o?a||r||n||t||e:s&&!o?i||r||t||n||e:o?n||t||e:t||n||e}_getLogoHref(){return this.getAttribute(`logo-href`)||`/`}_getLogoAlt(){return this.getAttribute(`logo-alt`)||`Home`}_getMenuTargetId(){return(this.getAttribute(`menu-target`)||``).replace(/^#/,``)}_getSearchEndpoint(){return(this.getAttribute(`search-endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getSearchPlaceholder(){return this.getAttribute(`search-placeholder`)||`Search`}_isSearchEnabled(){return!!this._getSearchEndpoint()}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{let t=e.key.toLowerCase();if((e.metaKey||e.ctrlKey)&&t===`k`){e.preventDefault(),this._openSearch(!0);return}t===`escape`&&this._searchOpen&&this._closeSearch()},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docClickHandler||(this._docClickHandler=e=>{if(!this._searchOpen)return;let t=e.target;t&&(this.contains(t)||this._closeSearch())},document.addEventListener(`click`,this._docClickHandler))}_detachGlobalHandlers(){this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._docClickHandler&&=(document.removeEventListener(`click`,this._docClickHandler),null)}_cancelSearchDebounce(){this._searchDebounceId!==null&&(window.clearTimeout(this._searchDebounceId),this._searchDebounceId=null)}_abortSearch(){this._searchAbortController&&=(this._searchAbortController.abort(),null)}_openSearch(e=!1){if(this._isSearchEnabled()&&(this._searchOpen=!0,this._syncSearchPanelVisibility(),e)){let e=this._isMobileViewport()?this._searchPanelInput:this._desktopSearchInput;e?.focus(),e?.select()}}_closeSearch(){this._searchOpen=!1,this._syncSearchPanelVisibility()}_syncSearchPanelVisibility(){this._searchPanel&&(this._searchPanel.classList.toggle(`hidden`,!this._searchOpen),this._syncDesktopSearchOpenState(),this._positionSearchPanel())}_syncDesktopSearchOpenState(){this._desktopSearchShell&&(this._desktopSearchShell.classList.toggle(`rounded-b-none`,this._searchOpen),this._desktopSearchShell.classList.toggle(`border-b-transparent`,this._searchOpen))}_positionSearchPanel(){if(!this._searchPanel)return;if(this._isMobileViewport()||!this._desktopSearchShell){this._searchPanel.style.left=``,this._searchPanel.style.right=``,this._searchPanel.style.top=``,this._searchPanel.style.width=``,this._searchPanel.style.maxWidth=``,this._searchPanel.style.transform=``;return}let e=this._desktopSearchShell.getBoundingClientRect();this._searchPanel.style.left=`${e.left}px`,this._searchPanel.style.right=`auto`,this._searchPanel.style.top=`${e.bottom-1}px`,this._searchPanel.style.width=`${e.width}px`,this._searchPanel.style.maxWidth=`${e.width}px`,this._searchPanel.style.transform=`none`}_setSearchQuery(e){this._searchQuery=e,this._desktopSearchInput&&this._desktopSearchInput.value!==e&&(this._desktopSearchInput.value=e),this._searchPanelInput&&this._searchPanelInput.value!==e&&(this._searchPanelInput.value=e)}_normalizeResults(e){return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim()}}).slice(0,8)}_renderSearchState(e){this._searchStateWrap&&(this._searchStateWrap.textContent=e,this._searchStateWrap.classList.remove(`hidden`),this._searchResultsWrap&&(this._searchResultsWrap.innerHTML=``))}_renderSearchResults(e){if(!(!this._searchResultsWrap||!this._searchStateWrap)){if(this._searchResultsWrap.innerHTML=``,e.length===0){this._renderSearchState(`No results found`);return}this._searchStateWrap.classList.add(`hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`flex w-full cursor-pointer items-start gap-3 rounded-lg px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/10`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mt-0.5 h-4 w-4 text-gray-500 dark:text-gray-400`;let r=document.createElement(`div`);r.className=`min-w-0`;let i=document.createElement(`div`);if(i.className=`truncate text-sm font-semibold text-gray-900 dark:text-gray-100`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`truncate text-xs text-gray-500 dark:text-gray-400`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`click`,()=>{this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._searchQuery,result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._searchResultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getSearchEndpoint();if(!t)return;let n=e.trim();if(!n){this._renderSearchState(`Start typing to search`);return}this._abortSearch(),this._searchAbortController=new AbortController,this._renderSearchState(`Searching...`);let r=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${encodeURIComponent(this._getSearchParam())}=${encodeURIComponent(n)}`;fetch(r,{signal:this._searchAbortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._renderSearchResults(t)}).catch(e=>{e?.name!==`AbortError`&&this._renderSearchState(`Unable to load results`)})}_scheduleSearch(e){this._setSearchQuery(e),this._cancelSearchDebounce(),this._searchDebounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>this.render()),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_disconnectDarkModeObserver(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_attachResizeListener(){this._resizeHandler||(this._resizeHandler=()=>{this.render(),this._positionSearchPanel()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0}))}_detachResizeListener(){this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}_toggleMenuTarget(){let e=this._getMenuTargetId();if(!e)return;let t=document.getElementById(e);!t||t.tagName!==`MINT-SIDE-NAVIGATION`||(t.getAttribute(`open`)===`true`?t.removeAttribute(`open`):t.setAttribute(`open`,`true`))}render(){if(this._bar||(this._bar=document.createElement(`div`),this._bar.className=`fixed inset-x-0 top-0 z-50 flex h-14 w-full items-center gap-2 border-b border-gray-200 bg-white px-3 dark:border-mint-divider dark:bg-mint-nav`,this.appendChild(this._bar)),!this._menuButton){this._menuButton=document.createElement(`button`),this._menuButton.type=`button`,this._menuButton.className=`inline-flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-transparent text-gray-700 hover:bg-black/5 min-[1100px]:hidden dark:text-gray-200 dark:hover:bg-white/10`,this._menuButton.setAttribute(`aria-label`,`Open navigation menu`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`menu`),e.className=`h-5 w-5`,this._menuButton.appendChild(e),this._menuClickHandler=()=>this._toggleMenuTarget(),this._menuButton.addEventListener(`click`,this._menuClickHandler),this._bar.appendChild(this._menuButton)}let e=!!this._getMenuTargetId();this._menuButton.classList.toggle(`hidden`,!e),this._logoLink||(this._logoLink=document.createElement(`a`),this._logoLink.className=`flex h-8 w-40 shrink-0 items-center`,this._bar.appendChild(this._logoLink)),this._logoLink.href=this._getLogoHref(),this._logoLink.setAttribute(`aria-label`,this._getLogoAlt());let t=this._getLogoSrc();if(t){let e=document.createElement(`img`);e.className=`h-full w-full object-contain [aspect-ratio:5/1]`,e.decoding=`async`,e.src=t,e.alt=this._getLogoAlt(),this._logoLink.replaceChildren(e),this._logoLink.classList.remove(`pointer-events-none`,`opacity-40`)}else{this._logoLink.replaceChildren(),this._logoLink.classList.add(`pointer-events-none`,`opacity-40`);let e=document.createElement(`span`);e.className=`text-sm font-semibold text-gray-400 dark:text-gray-500`,e.textContent=`Logo`,this._logoLink.appendChild(e)}let n=Array.from(this.querySelectorAll(`[slot="center"]`)),r=n.length>0,i=this._isSearchEnabled()&&!r,a=this._bar.querySelector(`[data-mint-topnav-center]`);if(a||(a=document.createElement(`div`),a.setAttribute(`data-mint-topnav-center`,`true`),this._bar.appendChild(a)),a.className=r?`min-w-0 flex-1 px-2 min-[1100px]:flex min-[1100px]:justify-center min-[1100px]:px-4`:`max-[1099.98px]:hidden min-[1100px]:flex min-[1100px]:min-w-0 min-[1100px]:flex-1 min-[1100px]:justify-center min-[1100px]:px-4`,a.classList.toggle(`min-[1100px]:hidden`,!i&&!r),r&&(a.replaceChildren(...n),this._closeSearch()),i&&!this._desktopSearchInput){let e=document.createElement(`div`);e.className=`relative w-full max-w-xl rounded-xl border border-gray-300 bg-gray-50 px-3 py-2 dark:border-mint-divider dark:bg-mint-hover`,this._desktopSearchShell=e;let t=document.createElement(`mint-icon`);t.setAttribute(`name`,`search`),t.className=`absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500 dark:text-gray-400`,this._desktopSearchInput=document.createElement(`input`),this._desktopSearchInput.type=`search`,this._desktopSearchInput.className=`w-full bg-transparent pl-6 pr-20 text-sm text-gray-900 outline-none placeholder:text-gray-500 dark:text-gray-100 dark:placeholder:text-gray-400`,this._desktopSearchInput.placeholder=this._getSearchPlaceholder(),this._desktopSearchInput.addEventListener(`focus`,()=>this._openSearch(!1)),this._desktopSearchInput.addEventListener(`input`,e=>this._scheduleSearch(e.target.value));let n=document.createElement(`span`);n.className=`absolute right-3 top-1/2 -translate-y-1/2 text-xs text-gray-500 dark:text-gray-400`,n.textContent=`⌘K`,e.appendChild(t),e.appendChild(this._desktopSearchInput),e.appendChild(n),a.appendChild(e)}i&&this._desktopSearchInput&&(this._desktopSearchInput.placeholder=this._getSearchPlaceholder(),this._desktopSearchShell=this._desktopSearchInput.closest(`div`),this._syncDesktopSearchOpenState());let o=this._bar.querySelector(`[data-mint-topnav-mobile-spacer]`);o||(o=document.createElement(`div`),o.setAttribute(`data-mint-topnav-mobile-spacer`,`true`),o.className=`min-w-0 flex-1 min-[1100px]:hidden`,this._bar.appendChild(o));let s=Array.from(this.querySelectorAll(`[slot="actions"]`)),c=this._bar.querySelector(`[data-mint-topnav-actions]`);if(c||(c=document.createElement(`div`),c.setAttribute(`data-mint-topnav-actions`,`true`),c.className=`flex shrink-0 items-center gap-2`,this._bar.appendChild(c)),i&&!this._mobileSearchButton){this._mobileSearchButton=document.createElement(`button`),this._mobileSearchButton.type=`button`,this._mobileSearchButton.className=`inline-flex h-10 w-10 shrink-0 cursor-pointer items-center justify-center rounded-lg border border-transparent text-gray-700 hover:bg-black/5 min-[1100px]:hidden dark:text-gray-200 dark:hover:bg-white/10`,this._mobileSearchButton.setAttribute(`aria-label`,`Open search`);let e=document.createElement(`mint-icon`);e.setAttribute(`name`,`search`),e.className=`h-5 w-5`,this._mobileSearchButton.appendChild(e),this._mobileSearchButton.addEventListener(`click`,()=>this._openSearch(!0)),c.insertBefore(this._mobileSearchButton,c.firstChild)}if(this._mobileSearchButton&&this._mobileSearchButton.classList.toggle(`hidden`,!i),c.replaceChildren(...s),i&&this._mobileSearchButton&&!s.includes(this._mobileSearchButton)&&c.insertBefore(this._mobileSearchButton,c.firstChild),i&&!this._searchPanel){this._searchPanel=document.createElement(`div`),this._searchPanel.className=`fixed left-0 right-0 top-14 z-[90] hidden p-3 min-[1100px]:p-0`;let e=document.createElement(`div`);e.className=`mx-auto w-full rounded-2xl border border-gray-200 bg-white shadow-xl dark:border-mint-divider dark:bg-mint-elevated min-[1100px]:rounded-t-none`;let t=document.createElement(`div`);t.className=`relative border-b border-gray-200 p-3 dark:border-mint-divider min-[1100px]:hidden`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`absolute left-6 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-500 dark:text-gray-400`,this._searchPanelInput=document.createElement(`input`),this._searchPanelInput.type=`search`,this._searchPanelInput.className=`w-full rounded-lg border border-gray-300 bg-gray-50 py-2 pl-10 pr-3 text-sm text-gray-900 outline-none dark:border-mint-divider dark:bg-mint-hover dark:text-gray-100`,this._searchPanelInput.placeholder=this._getSearchPlaceholder(),this._searchPanelInput.addEventListener(`input`,e=>this._scheduleSearch(e.target.value)),t.appendChild(n),t.appendChild(this._searchPanelInput);let r=document.createElement(`div`);r.className=`flex flex-wrap gap-2 px-3 py-3`,[`Apps`,`Customers`,`Orders`,`Products`,`Sales channels`].forEach(e=>{let t=document.createElement(`span`);t.className=`rounded-full bg-gray-100 px-3 py-1 text-xs font-semibold text-gray-600 dark:bg-mint-hover dark:text-gray-300`,t.textContent=e,r.appendChild(t)}),this._searchStateWrap=document.createElement(`div`),this._searchStateWrap.className=`px-4 pb-4 text-sm text-gray-500 dark:text-gray-400`,this._searchStateWrap.textContent=`Start typing to search`,this._searchResultsWrap=document.createElement(`div`),this._searchResultsWrap.className=`max-h-[52vh] overflow-y-auto px-2 pb-2`,e.appendChild(t),e.appendChild(r),e.appendChild(this._searchStateWrap),e.appendChild(this._searchResultsWrap),this._searchPanel.appendChild(e),this.appendChild(this._searchPanel)}this._searchPanelInput&&(this._searchPanelInput.placeholder=this._getSearchPlaceholder()),this._syncSearchPanelVisibility(),this._positionSearchPanel()}};customElements.get(`mint-top-navigation`)||customElements.define(`mint-top-navigation`,Y);var X=class e extends HTMLElement{constructor(...e){super(...e),this._shell=null,this._desktopInput=null,this._panel=null,this._panelInner=null,this._panelInput=null,this._panelFiltersWrap=null,this._panelFiltersMainRow=null,this._panelFiltersChips=null,this._panelFiltersShowAllWrap=null,this._panelFiltersShowAllBtn=null,this._panelFiltersMorePanel=null,this._filtersMoreOpen=!1,this._filterOverflowObserver=null,this._filterOverflowZeroWidthRetries=0,this._desktopFilterWrap=null,this._mobileFilterWrap=null,this._resultsWrap=null,this._stateWrap=null,this._customResultsWrap=null,this._query=``,this._searchOpen=!1,this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._debounceId=null,this._abortController=null,this._docPointerDownHandler=null,this._globalKeydownHandler=null,this._focusOutHandler=null,this._resizeHandler=null,this._desktopShortcutHint=null,this._panelSearchBar=null,this._contentObserver=null,this._renderFrame=null}static{this._filterMorePanelSeq=0}static{this._filterChipsOverflowMask=`linear-gradient(to right, #000 0%, #000 max(0%, calc(100% - 3.5rem)), transparent 100%)`}static get observedAttributes(){return[`endpoint`,`search-param`,`placeholder`,`filters`,`filter-param`,`open-shortcut`,`open-shortcut-hint`,`collapse-on-mobile`]}connectedCallback(){this.classList.add(`relative`,`block`,`w-full`,`max-w-xl`),this._attachGlobalHandlers(),this._attachFocusOutHandler(),this._attachResizeHandler(),this.render(),this._observeContentMutations()}disconnectedCallback(){this._docPointerDownHandler&&=(document.removeEventListener(`pointerdown`,this._docPointerDownHandler,!0),null),this._globalKeydownHandler&&=(document.removeEventListener(`keydown`,this._globalKeydownHandler),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null),this._focusOutHandler&&=(this.removeEventListener(`focusout`,this._focusOutHandler,!0),null),this._cancelDebounce(),this._abortSearch(),this._filterOverflowObserver&&=(this._filterOverflowObserver.disconnect(),null),this._contentObserver&&=(this._contentObserver.disconnect(),null),this._renderFrame!==null&&(cancelAnimationFrame(this._renderFrame),this._renderFrame=null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}_scheduleRender(){this._renderFrame===null&&(this._renderFrame=requestAnimationFrame(()=>{this._renderFrame=null,this.render()}))}_observeContentMutations(){this._contentObserver||=new MutationObserver(()=>{this._scheduleRender()}),this._contentObserver.disconnect(),this._contentObserver.observe(this,{childList:!0,attributes:!0,attributeFilter:[`slot`]})}_getEndpoint(){return(this.getAttribute(`endpoint`)||``).trim()}_getSearchParam(){return(this.getAttribute(`search-param`)||`q`).trim()||`q`}_getPlaceholder(){return this.getAttribute(`placeholder`)||`Search`}_getFilterParam(){return(this.getAttribute(`filter-param`)||``).trim()}_getFilterOptions(){return(this.getAttribute(`filters`)||``).split(`,`).map(e=>e.trim()).filter(Boolean)}_hasSelectedFilters(){return this._selectedFilters.length>0}_getFilterChipOverflowReservePx(){let e=Math.max(1,this._getFilterOptions().length),t=this._hasSelectedFilters()?28:56;return Math.min(200,t+e*34)}_getFilterParamValue(){return this._selectedFilters.join(`,`)}_getFilterChipLabelText(){return this._selectedFilters.join(`, `)}_getCondensedFilterChipLabel(e=22){if(!this._hasSelectedFilters())return``;let[t=``]=this._selectedFilters,n=this._selectedFilters.length-1,r=Math.max(8,e-2),i=t;if(n<=0)return i.length<=r?i:`${i.slice(0,Math.max(1,r-3))}...`;let a=`${t}, and ${n} more`;return a.length<=r?a:`${a.slice(0,Math.max(1,r-3))}...`}_isMobileViewport(){return window.matchMedia(`(max-width: 1099.98px)`).matches}_collapseOnMobile(){let e=this.getAttribute(`collapse-on-mobile`);if(e===null)return!1;let t=e.trim().toLowerCase();return!(t===`false`||t===`0`||t===`off`||t===`none`)}_primarySearchInput(){return this._isMobileViewport()&&this._collapseOnMobile()?this._panelInput:this._desktopInput}_isApplePlatform(){return typeof navigator>`u`?!1:/Mac|iPhone|iPad|iPod/i.test(navigator.platform)||/Mac OS/i.test(navigator.userAgent)}_parseOpenShortcut(){let e=(this.getAttribute(`open-shortcut`)??`mod+k`).trim().toLowerCase();if(!e||e===`none`||e===`false`||e===`off`)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let t=e.split(`+`).map(e=>e.trim()).filter(Boolean);if(t.length===0)return{disabled:!0,wantMod:!1,wantMeta:!1,wantCtrl:!1,wantAlt:!1,wantShift:!1,key:``};let n=t[t.length-1],r=new Set(t.slice(0,-1).map(e=>e.toLowerCase()));return{disabled:!1,wantMod:r.has(`mod`),wantMeta:r.has(`meta`)||r.has(`cmd`)||r.has(`super`),wantCtrl:r.has(`ctrl`)||r.has(`control`),wantAlt:r.has(`alt`),wantShift:r.has(`shift`),key:n.toLowerCase()}}_eventKeyMatchesShortcutKey(e,t){let n=t.toLowerCase();return(e.key.length,e.key.toLowerCase())===n}_openShortcutMatches(e){let t=this._parseOpenShortcut();return t.disabled||!t.key||e.repeat||!this._eventKeyMatchesShortcutKey(e,t.key)||t.wantShift!==e.shiftKey||t.wantAlt!==e.altKey?!1:t.wantMod||t.wantMeta||t.wantCtrl?!(t.wantMod&&!(e.metaKey||e.ctrlKey)||t.wantMeta&&!e.metaKey||t.wantCtrl&&!e.ctrlKey):!!t.wantAlt}_getOpenShortcutHintText(){let e=this.getAttribute(`open-shortcut-hint`);if(e===`none`||e===`false`)return``;if(e!==null&&e.trim()!==``)return e.trim();let t=this._parseOpenShortcut();if(t.disabled)return``;let n=this._isApplePlatform(),r=[];t.wantMod&&r.push(n?`⌘`:`Ctrl`),t.wantMeta&&!t.wantMod&&r.push(n?`⌘`:`Meta`),t.wantCtrl&&!t.wantMod&&r.push(`Ctrl`),t.wantAlt&&r.push(`Alt`),t.wantShift&&r.push(`Shift`);let i=t.key.length===1?t.key.toUpperCase():t.key;return i?t.wantMod&&!t.wantMeta&&!t.wantCtrl&&!t.wantAlt&&!t.wantShift&&t.key.length===1?`${n?`⌘`:`Ctrl+`}${i}`:[...r,i].join(`+`):``}_attachGlobalHandlers(){this._globalKeydownHandler||(this._globalKeydownHandler=e=>{if(this._openShortcutMatches(e)){e.preventDefault(),this._openSearch(!0);return}if(e.key.toLowerCase()===`escape`&&this._searchOpen){if(this._filtersMoreOpen){this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput());return}this._closeSearch()}},document.addEventListener(`keydown`,this._globalKeydownHandler)),this._docPointerDownHandler||(this._docPointerDownHandler=e=>{if(!this._searchOpen)return;let t=e.composedPath();this._filtersMoreOpen&&this._panelFiltersWrap&&!t.includes(this._panelFiltersWrap)&&(this._filtersMoreOpen=!1,this.render(),requestAnimationFrame(()=>this._focusActiveInput())),!(this._shell&&t.includes(this._shell)||this._panelInner&&t.includes(this._panelInner))&&this._closeSearch()},document.addEventListener(`pointerdown`,this._docPointerDownHandler,!0))}_attachResizeHandler(){this._resizeHandler||(this._resizeHandler=()=>{this._syncPanelVisibility(),this._syncFilterOverflow()},window.addEventListener(`resize`,this._resizeHandler,{passive:!0}))}_attachFocusOutHandler(){this._focusOutHandler||(this._focusOutHandler=e=>{if(!this._searchOpen)return;let t=e.relatedTarget;t&&(this._shell&&this._shell.contains(t)||this._panelInner&&this._panelInner.contains(t)||this._closeSearch())},this.addEventListener(`focusout`,this._focusOutHandler,!0))}_emitSearchOpenChange(){this.dispatchEvent(new CustomEvent(`search-open-change`,{detail:{open:this._searchOpen},bubbles:!0,composed:!0}))}_openSearch(e=!1){this._getEndpoint()&&(this._searchOpen||(this._searchOpen=!0,this._syncPanelVisibility(),this._emitSearchOpenChange(),e&&this._primarySearchInput()?.focus()))}_closeSearch(){this._searchOpen&&(this._searchOpen=!1,this._filtersMoreOpen=!1,this._syncPanelVisibility(),this._emitSearchOpenChange())}_syncPanelVisibility(){if(!this._panel)return;let e=this._panelLayoutBaseClass();this._panel.className=this._searchOpen?e:`${e} hidden`,this._shell&&(this._shell.classList.toggle(`rounded-b-none`,this._searchOpen),this._shell.classList.toggle(`border-b-transparent`,this._searchOpen)),this._positionPanel(),this._searchOpen&&this._scheduleFilterOverflowSync()}_panelLayoutBaseClass(){return!this._isMobileViewport()||!this._collapseOnMobile()?`absolute left-0 right-0 top-full z-[90] p-0 -mt-[9px]`:`fixed left-0 right-0 top-12 z-[90] p-3`}_positionPanel(){this._panel&&(!this._isMobileViewport()||!this._collapseOnMobile())&&(this._panel.style.left=``,this._panel.style.right=``,this._panel.style.top=``,this._panel.style.width=``,this._panel.style.maxWidth=``,this._panel.style.transform=``)}_setQuery(e){let t=this._query;this._query=e,e!==t&&(this._selectedFilterBackspaceArmed=!1),this._desktopInput&&(this._desktopInput.value=e),this._panelInput&&(this._panelInput.value=e)}_cancelDebounce(){this._debounceId!==null&&(window.clearTimeout(this._debounceId),this._debounceId=null)}_abortSearch(){this._abortController&&=(this._abortController.abort(),null)}_normalizeResults(e){return(e=>{if(Array.isArray(e))return e;if(!e||typeof e!=`object`)return[];let t=e;for(let e of[`results`,`items`,`data`,`products`]){let n=t[e];if(Array.isArray(n))return n}return[]})(e).map(e=>{let t=e||{};return{title:String(t.title||t.name||t.label||t.email||t.id||``).trim()||`Untitled`,subtitle:String(t.description||t.category||t.username||``).trim(),parent:String(t.parent||t.type||t.entity||t.kind||t.category||``).trim()||void 0}}).slice(0,8)}_emitResultsChange(e,t){let n=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-results-change`,{detail:{query:this._query,filter:n,filters:[...this._selectedFilters],results:e,raw:t??null},bubbles:!0,composed:!0}))}_emitFilterChange(){let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-filter-change`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters]},bubbles:!0,composed:!0}))}_renderState(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`hidden`);return}this._stateWrap&&(this._stateWrap.textContent=e,this._stateWrap.classList.remove(`hidden`),this._resultsWrap&&(this._resultsWrap.classList.remove(`hidden`),this._resultsWrap.innerHTML=``))}_renderResults(e){if(this._customResultsWrap&&this._customResultsWrap.childElementCount>0){this._stateWrap&&this._stateWrap.classList.add(`hidden`),this._resultsWrap&&this._resultsWrap.classList.add(`hidden`);return}if(!(!this._resultsWrap||!this._stateWrap)){if(this._resultsWrap.innerHTML=``,e.length===0){this._renderState(`No results found`);return}this._stateWrap.classList.add(`hidden`);for(let t of e){let e=document.createElement(`button`);e.type=`button`,e.className=`flex w-full cursor-pointer items-start gap-3 rounded-lg px-3 py-2 text-left hover:bg-gray-100 dark:hover:bg-white/10`;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`search`),n.className=`mt-0.5 h-4 w-4 text-gray-500 dark:text-gray-400`;let r=document.createElement(`div`);r.className=`min-w-0`;let i=document.createElement(`div`);if(i.className=`truncate text-sm font-semibold text-gray-900 dark:text-gray-100`,i.textContent=t.title,r.appendChild(i),t.subtitle){let e=document.createElement(`div`);e.className=`truncate text-xs text-gray-500 dark:text-gray-400`,e.textContent=t.subtitle,r.appendChild(e)}e.appendChild(n),e.appendChild(r),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){t.preventDefault(),this._moveFocusInResults(e,1);return}if(t.key===`ArrowUp`){t.preventDefault(),this._moveFocusInResults(e,-1);return}}),e.addEventListener(`click`,()=>{let e=this._hasSelectedFilters()?this._getFilterParamValue():null;this.dispatchEvent(new CustomEvent(`search-select`,{detail:{query:this._query,filter:e,filters:[...this._selectedFilters],result:t},bubbles:!0,composed:!0})),this._closeSearch()}),this._resultsWrap.appendChild(e)}}}_fetchSearchResults(e){let t=this._getEndpoint();if(!t)return;let n=e.trim();if(!n){this._emitResultsChange([]),this._renderState(`Start typing to search`);return}this._abortSearch(),this._abortController=new AbortController,this._renderState(`Searching...`);let r=new URLSearchParams;r.set(this._getSearchParam(),n);let i=this._getFilterParam();i&&this._hasSelectedFilters()&&r.set(i,this._getFilterParamValue());let a=t.includes(`{query}`)?t.replace(`{query}`,encodeURIComponent(n)):`${t}${t.includes(`?`)?`&`:`?`}${r.toString()}`;fetch(a,{signal:this._abortController.signal}).then(e=>{if(!e.ok)throw Error(`Request failed: ${e.status}`);return e.json()}).then(e=>{let t=this._normalizeResults(e);this._emitResultsChange(t,e),this._renderResults(t)}).catch(e=>{e?.name!==`AbortError`&&(this._emitResultsChange([]),this._renderState(`Unable to load results`))})}_scheduleSearch(e){this._setQuery(e),this._cancelDebounce(),this._debounceId=window.setTimeout(()=>this._fetchSearchResults(e),220)}_getNativeInputValue(e){if(!e)return``;let t=e.querySelector(`input, textarea`);return t?t.value||``:e.value||``}_getCurrentInputValue(){let e=document.activeElement;return e&&this._desktopInput&&this._desktopInput.contains(e)?this._getNativeInputValue(this._desktopInput):e&&this._panelInput&&this._panelInput.contains(e)?this._getNativeInputValue(this._panelInput):this._getNativeInputValue(this._primarySearchInput())}_applyFilterSelectionChange(){let e=this._getCurrentInputValue();if(this._setQuery(e),this._emitFilterChange(),this.render(),e.trim()){this._scheduleSearch(e);return}this._cancelDebounce(),this._abortSearch(),this._emitResultsChange([]),this._renderState(`Start typing to search`)}_clearAllSelectedFilters(){this._selectedFilters=[],this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange()}_popLastSelectedFilter(){this._selectedFilters.length!==0&&(this._selectedFilters.pop(),this._selectedFilterBackspaceArmed=!1,this._applyFilterSelectionChange())}_focusActiveInput(){let e=this._primarySearchInput();e&&requestAnimationFrame(()=>{e.focus()})}_focusHideFiltersControl(){let e=this._panelFiltersShowAllBtn;e&&(e.querySelector(`button`)??e).focus()}_getFilterChipElements(){return this._panelFiltersWrap?Array.from(this._panelFiltersWrap.querySelectorAll(`mint-chip`)):[]}_ensurePanelFiltersShell(){!this._panelFiltersWrap||this._panelFiltersMainRow||(this._panelFiltersWrap.replaceChildren(),this._panelFiltersWrap.className=`relative flex shrink-0 flex-col gap-2 px-3 pb-3 pt-5 min-w-0`,this._panelFiltersMainRow=document.createElement(`div`),this._panelFiltersMainRow.className=`flex min-w-0 w-full flex-nowrap items-center gap-2`,this._panelFiltersChips=document.createElement(`div`),this._panelFiltersChips.className=`flex min-w-0 flex-1 flex-nowrap items-center gap-2 overflow-x-hidden`,this._panelFiltersMorePanel=document.createElement(`div`),this._panelFiltersMorePanel.id=`mint-search-filter-more-${e._filterMorePanelSeq++}`,this._panelFiltersMorePanel.className=`hidden absolute left-0 right-0 top-full z-[95] mt-1 flex max-h-[40vh] flex-wrap gap-2 overflow-y-auto rounded-lg border border-gray-200 bg-white p-2 shadow-lg dark:border-mint-divider dark:bg-mint-elevated`,this._panelFiltersShowAllWrap=document.createElement(`div`),this._panelFiltersShowAllWrap.className=`relative flex min-h-0 min-w-0 shrink-0 items-center hidden`,this._panelFiltersShowAllBtn=document.createElement(`mint-button`),this._panelFiltersShowAllBtn.setAttribute(`type`,`button`),this._panelFiltersShowAllBtn.setAttribute(`variant`,`ghost`),this._panelFiltersShowAllBtn.setAttribute(`tone`,`neutral`),this._panelFiltersShowAllBtn.setAttribute(`size`,`small`),this._panelFiltersShowAllBtn.classList.add(`shrink-0`,`whitespace-nowrap`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,`false`),this._panelFiltersShowAllBtn.setAttribute(`aria-controls`,this._panelFiltersMorePanel.id),this._panelFiltersShowAllBtn.addEventListener(`click`,e=>{e.stopPropagation();let t=this._filtersMoreOpen;this._filtersMoreOpen=!this._filtersMoreOpen,this.render(),t&&requestAnimationFrame(()=>this._focusActiveInput())}),this._panelFiltersShowAllWrap.append(this._panelFiltersShowAllBtn),this._panelFiltersMainRow.append(this._panelFiltersChips,this._panelFiltersShowAllWrap),this._setPanelFiltersShowAllLabel(`Show all`),this._panelFiltersWrap.append(this._panelFiltersMainRow,this._panelFiltersMorePanel),typeof ResizeObserver<`u`&&!this._filterOverflowObserver&&(this._filterOverflowObserver=new ResizeObserver(()=>this._syncFilterOverflow()),this._filterOverflowObserver.observe(this._panelFiltersChips),this._filterOverflowObserver.observe(this._panelFiltersMainRow)))}_setPanelFiltersShowAllLabel(e){let t=this._panelFiltersShowAllBtn;if(!t)return;for(let e of Array.from(t.childNodes))e.nodeType===Node.TEXT_NODE&&e.remove();let n=t.querySelector(`button .mint-button-content`)||t.querySelector(`.mint-button-content`);if(n){n.textContent=e;return}let r=t.querySelector(`:scope > button`);if(r){r.replaceChildren(document.createTextNode(e)),t.render?.();return}t.firstElementChild||t.appendChild(document.createTextNode(e))}_scheduleFilterOverflowSync(){requestAnimationFrame(()=>{requestAnimationFrame(()=>this._syncFilterOverflow())})}_setFilterChipsEdgeFade(t){let n=this._panelFiltersChips;n&&(t?(n.style.maskImage=e._filterChipsOverflowMask,n.style.webkitMaskImage=e._filterChipsOverflowMask):(n.style.maskImage=``,n.style.webkitMaskImage=``))}_syncFilterOverflow(){if(!this._panelFiltersChips||!this._panelFiltersShowAllWrap||!this._panelFiltersShowAllBtn)return;if(this._filtersMoreOpen){this._panelFiltersShowAllWrap.classList.remove(`hidden`),this._filterOverflowZeroWidthRetries=0,this._setFilterChipsEdgeFade(!1);return}let e=this._panelFiltersChips.clientWidth;if(e===0&&this._searchOpen){this._filterOverflowZeroWidthRetries<10&&(this._filterOverflowZeroWidthRetries+=1,this._scheduleFilterOverflowSync()),this._setFilterChipsEdgeFade(!1);return}this._filterOverflowZeroWidthRetries=0;let t=this._panelFiltersChips.scrollWidth+this._getFilterChipOverflowReservePx()>e;this._panelFiltersShowAllWrap.classList.toggle(`hidden`,!t),this._setFilterChipsEdgeFade(t)}_getResultFocusableElements(){let e=this._customResultsWrap&&!this._customResultsWrap.classList.contains(`hidden`)?this._customResultsWrap:this._resultsWrap;return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], [tabindex]:not([tabindex="-1"]), input:not([disabled]), select:not([disabled]), textarea:not([disabled])`)):[]}_focusFirstChipOrResult(e=!1){let t=this._getFilterChipElements(),n=this._getResultFocusableElements();if(!e){(t[0]||n[0])?.focus();return}(n[n.length-1]||t[t.length-1])?.focus()}_moveFocusInResults(e,t){let n=this._getResultFocusableElements();if(n.length===0)return;let r=n.indexOf(e);if(r===-1)return;let i=n[r+t];if(i){i.focus();return}if(t===-1){let e=this._getFilterChipElements(),t=e[e.length-1];t?t.focus():this._focusActiveInput()}}_renderSelectedFilter(){let e=e=>{if(!e||(e.innerHTML=``,!this._hasSelectedFilters()))return;let t=document.createElement(`mint-chip`);t.setAttribute(`dismissable`,``),t.title=this._getFilterChipLabelText();let n=this._getCondensedFilterChipLabel();t.classList.add(`max-w-[min(20rem,85vw)]`,`whitespace-nowrap`,`overflow-hidden`,`text-ellipsis`,`text-xs`,`px-2`,`py-0.5`),t.style.fontSize=`0.75rem`,t.style.padding=`0.125rem 0.375rem`,t.style.height=`1.375rem`,t.style.lineHeight=`1`,t.style.whiteSpace=`nowrap`,t.style.overflow=`hidden`,t.style.textOverflow=`ellipsis`,this._selectedFilterBackspaceArmed&&t.classList.add(`ring-2`,`ring-brand-400`,`dark:ring-brand-300`),t.textContent=n,t.addEventListener(`dismiss`,e=>{e.stopPropagation(),this._clearAllSelectedFilters()}),e.appendChild(t)};e(this._desktopFilterWrap),e(this._mobileFilterWrap)}_bindInputHandlers(e){let t=()=>{this._scheduleSearch(this._getNativeInputValue(e))};e.addEventListener(`focusin`,()=>this._openSearch(!1)),e.addEventListener(`input`,t),e.addEventListener(`search`,t),e.addEventListener(`change`,t),e.addEventListener(`keydown`,t=>{if(t.key===`ArrowDown`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!1);return}if(t.key===`ArrowUp`){this._searchOpen||this._openSearch(!1),t.preventDefault(),this._focusFirstChipOrResult(!0);return}if(t.key===`Tab`&&!t.shiftKey&&this._searchOpen){let e=this._getFilterChipElements(),n=this._getResultFocusableElements();if(e.length>0||n.length>0){t.preventDefault(),this._focusFirstChipOrResult(!1);return}}if(t.key!==`Backspace`)return;let n=this._getNativeInputValue(e);if(n!==this._query&&this._setQuery(n),!(n.length>0)&&this._hasSelectedFilters()){if(!this._selectedFilterBackspaceArmed){t.preventDefault(),this._selectedFilterBackspaceArmed=!0,this._renderSelectedFilter();return}t.preventDefault(),this._popLastSelectedFilter()}})}openSearch(e=!0){this._openSearch(e)}closeSearch(){this._closeSearch()}toggleSearch(e=!0){if(this._searchOpen){this._closeSearch();return}this._openSearch(e)}isSearchOpen(){return this._searchOpen}render(){let e=this._getEndpoint();if(this.classList.toggle(`hidden`,!e),!e)return;if(!this._shell){this._shell=document.createElement(`div`),this._shell.className=`relative z-[91] flex h-10 w-full`,this._desktopFilterWrap=document.createElement(`div`),this._desktopFilterWrap.className=`inline-flex shrink-0 max-w-[8.5rem]`,this._desktopFilterWrap.setAttribute(`slot`,`prepend`),this._desktopInput=document.createElement(`mint-input`),this._desktopInput.setAttribute(`type`,`search`),this._desktopInput.setAttribute(`icon`,`search`),this._desktopInput.className=`h-full min-w-0 flex-1`;let e=document.createElement(`span`);e.className=`shrink-0 text-xs text-gray-500 dark:text-gray-400`,e.setAttribute(`slot`,`append`),this._desktopShortcutHint=e,this._bindInputHandlers(this._desktopInput),this._desktopInput.appendChild(this._desktopFilterWrap),this._desktopInput.appendChild(e),this._shell.appendChild(this._desktopInput),this.appendChild(this._shell)}if(!this._panel){this._panel=document.createElement(`div`),this._panel.className=`absolute left-0 right-0 top-full z-[90] hidden p-0 -mt-[9px]`;let e=document.createElement(`div`);e.className=`mx-auto flex max-h-[calc(100dvh-4rem)] w-full flex-col overflow-hidden rounded-2xl border border-gray-200 bg-white shadow-xl dark:border-mint-divider dark:bg-mint-elevated min-[1100px]:rounded-t-none min-[1100px]:border-t-0`,this._panelInner=e;let t=document.createElement(`div`);this._panelSearchBar=t,t.className=`hidden`,this._mobileFilterWrap=document.createElement(`div`),this._mobileFilterWrap.className=`inline-flex shrink-0 max-w-[8.5rem]`,this._mobileFilterWrap.setAttribute(`slot`,`prepend`),this._panelInput=document.createElement(`mint-input`),this._panelInput.setAttribute(`type`,`search`),this._panelInput.className=`min-w-0 flex-1`,this._bindInputHandlers(this._panelInput),this._panelInput.appendChild(this._mobileFilterWrap),t.appendChild(this._panelInput),this._customResultsWrap=document.createElement(`div`),this._customResultsWrap.className=`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,this._stateWrap=document.createElement(`div`),this._stateWrap.className=`px-4 pb-4 text-sm text-gray-500 dark:text-gray-400`,this._stateWrap.textContent=`Start typing to search`,this._resultsWrap=document.createElement(`div`),this._resultsWrap.className=`min-h-0 flex-1 overflow-y-auto px-2 pb-2`,e.appendChild(t),this._panelFiltersWrap=document.createElement(`div`),e.appendChild(this._panelFiltersWrap),this._ensurePanelFiltersShell(),e.appendChild(this._customResultsWrap),e.appendChild(this._stateWrap),e.appendChild(this._resultsWrap),this._panel.appendChild(e),this.appendChild(this._panel)}let t=this._hasSelectedFilters()?``:this._getPlaceholder();if(this._desktopInput&&this._desktopInput.setAttribute(`placeholder`,t),this._panelInput&&this._panelInput.setAttribute(`placeholder`,t),this._desktopShortcutHint){let e=this._getOpenShortcutHintText();this._desktopShortcutHint.textContent=e,this._desktopShortcutHint.classList.toggle(`hidden`,!e)}if(this._panelFiltersWrap){this._ensurePanelFiltersShell();let e=this._getFilterOptions();this._selectedFilters=this._selectedFilters.filter(t=>e.includes(t));let t=e.length>0;t||(this._filtersMoreOpen=!1),this._panelFiltersWrap.classList.toggle(`hidden`,!t),this._stateWrap?.classList.toggle(`pt-4`,!t),this._resultsWrap?.classList.toggle(`pt-4`,!t),this._customResultsWrap?.classList.toggle(`pt-5`,!t),this._panelFiltersChips&&this._panelFiltersChips.replaceChildren(),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.replaceChildren();let n=this._filtersMoreOpen&&this._panelFiltersMorePanel?this._panelFiltersMorePanel:this._panelFiltersChips;for(let t of e){if(!n)break;let r=document.createElement(`mint-chip`),i=this._selectedFilters.includes(t);if(i&&r.classList.add(`ring-2`,`ring-inset`,`ring-brand-400`,`dark:ring-brand-300`),r.classList.add(`cursor-pointer`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-inset`,`focus-visible:ring-brand-400`,`inline-flex`,`items-center`,`gap-1`,`shrink-0`,`whitespace-nowrap`),i){let e=document.createElement(`span`);e.textContent=t;let n=document.createElement(`mint-icon`);n.setAttribute(`name`,`close`),n.className=`h-4 w-4 ml-2 shrink-0`,n.setAttribute(`aria-hidden`,`true`),r.append(e,n)}else r.textContent=t;r.tabIndex=0,r.setAttribute(`role`,`button`),r.setAttribute(`aria-label`,i?`Remove filter ${t}`:`Filter by ${t}`),r.dataset.mintSearchFilter=t,r.addEventListener(`pointerdown`,e=>{e.preventDefault()});let a=n=>{n&&n.stopPropagation();let r=this._filtersMoreOpen,i=this._selectedFilters.indexOf(t);i>=0?this._selectedFilters.splice(i,1):this._selectedFilters.push(t),this._selectedFilterBackspaceArmed=!1;let a=e.length>0&&this._selectedFilters.length===e.length,o=this._selectedFilters.length===0;r&&(a||o)&&(this._filtersMoreOpen=!1),this._emitFilterChange(),this._renderSelectedFilter(),this.render(),this._query.trim()&&this._scheduleSearch(this._query),r?a||o?this._focusActiveInput():requestAnimationFrame(()=>{this._getFilterChipElements().find(e=>e.dataset.mintSearchFilter===t)?.focus()}):this._focusActiveInput()};r.addEventListener(`click`,e=>a(e)),r.addEventListener(`keydown`,e=>{let t=this._getFilterChipElements(),n=t.indexOf(r);if(e.key===`Enter`||e.key===` `){e.preventDefault(),a(e);return}if(e.key===`ArrowRight`){e.preventDefault();let r=t[n+1];r&&r.focus();return}if(e.key===`ArrowLeft`){e.preventDefault();let r=t[n-1];r?r.focus():this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}if(e.key===`ArrowDown`){e.preventDefault(),this._getResultFocusableElements()[0]?.focus();return}if(e.key===`ArrowUp`){e.preventDefault(),this._filtersMoreOpen?this._focusHideFiltersControl():this._focusActiveInput();return}}),n.appendChild(r)}this._panelFiltersChips&&this._panelFiltersChips.classList.toggle(`hidden`,this._filtersMoreOpen),this._panelFiltersMorePanel&&this._panelFiltersMorePanel.classList.toggle(`hidden`,!this._filtersMoreOpen),this._panelFiltersShowAllBtn&&(this._setPanelFiltersShowAllLabel(this._filtersMoreOpen?`Hide filters`:`Show all`),this._panelFiltersShowAllBtn.setAttribute(`aria-expanded`,this._filtersMoreOpen?`true`:`false`)),this._panelInner&&(this._filtersMoreOpen&&t?(this._panelInner.classList.remove(`overflow-hidden`),this._panelInner.classList.add(`overflow-visible`)):(this._panelInner.classList.remove(`overflow-visible`),this._panelInner.classList.add(`overflow-hidden`))),this._scheduleFilterOverflowSync()}if(this._customResultsWrap){Array.from(this.children).filter(e=>e===this._shell||e===this._panel?!1:e.getAttribute(`slot`)===`results`).forEach(e=>this._customResultsWrap.appendChild(e));let e=this._customResultsWrap.childElementCount>0;this._customResultsWrap.classList.toggle(`hidden`,!e),e?(this._stateWrap?.classList.add(`hidden`),this._resultsWrap?.classList.add(`hidden`)):this._resultsWrap?.classList.remove(`hidden`)}this._renderSelectedFilter(),this._syncResponsiveChrome(),this._syncPanelVisibility()}_syncResponsiveChrome(){let e=this._collapseOnMobile();this._shell&&(this._shell.className=e?`relative z-[91] hidden h-10 w-full min-[1100px]:flex`:`relative z-[91] flex h-10 w-full`),this._panelSearchBar&&(this._panelSearchBar.className=e?`flex shrink-0 items-center gap-2 border-b border-gray-200 p-3 dark:border-mint-divider min-[1100px]:hidden`:`hidden`)}};customElements.get(`mint-search`)||customElements.define(`mint-search`,X);var Z=class extends HTMLElement{constructor(...e){super(...e),this._lastScrollY=0,this._scrollHandler=null}connectedCallback(){this.classList.add(`fixed`,`bottom-0`,`left-0`,`right-0`,`z-30`,`flex`,`w-full`,`items-stretch`,`justify-around`,`gap-1`,`border-t`,`border-gray-200`,`bg-white`,`px-1`,`pt-1`,`pb-[env(safe-area-inset-bottom,0px)]`,`min-[1100px]:hidden`,`transition-transform`,`duration-200`,`ease-out`,`translate-y-0`,`dark:border-mint-divider`,`dark:bg-mint-nav`),this.setAttribute(`role`,`navigation`),this.setAttribute(`aria-label`,`Primary`),this._lastScrollY=window.scrollY,this._attachScrollListener()}disconnectedCallback(){this._detachScrollListener()}_attachScrollListener(){this._scrollHandler||(this._scrollHandler=()=>{let e=window.scrollY;if(e<=8){this.classList.remove(`translate-y-full`),this.classList.add(`translate-y-0`),this._lastScrollY=e;return}let t=e-this._lastScrollY;Math.abs(t)<4||(t>0?(this.classList.remove(`translate-y-0`),this.classList.add(`translate-y-full`)):(this.classList.remove(`translate-y-full`),this.classList.add(`translate-y-0`)),this._lastScrollY=e)},window.addEventListener(`scroll`,this._scrollHandler,{passive:!0}))}_detachScrollListener(){this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler),null)}};customElements.get(`mint-bottom-navigation`)||customElements.define(`mint-bottom-navigation`,Z);var Q=class extends HTMLElement{constructor(...e){super(...e),this._root=null}static get observedAttributes(){return[`icon`,`label`,`href`,`active`]}connectedCallback(){this.classList.add(`contents`),this.render()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_isActive(){return this.getAttribute(`active`)===`true`}_getLabel(){return this.getAttribute(`label`)||``}_getIcon(){return this.getAttribute(`icon`)||``}_getHref(){return this.getAttribute(`href`)}render(){let e=this._getHref(),t=this._getLabel(),n=this._getIcon(),r=this._isActive(),i=r?`text-gray-900 dark:text-gray-100`:`text-gray-600 hover:bg-black/5 dark:text-gray-300 dark:hover:bg-white/10`,a;e?(a=document.createElement(`a`),a.href=e):(a=document.createElement(`button`),a.type=`button`),a.className=`flex min-w-0 flex-1 flex-col items-center justify-center gap-1 rounded-lg px-1 py-2 text-center text-[11px] font-medium leading-tight ${i}`,a.setAttribute(`aria-current`,r?`page`:`false`),a.setAttribute(`aria-label`,t||`Navigation item`);let o=document.createElement(`span`);if(o.className=`inline-flex h-6 w-6 items-center justify-center`,n){let e=document.createElement(`mint-icon`);e.setAttribute(`name`,n),e.className=r?`h-6 w-6`:`h-6 w-6 opacity-90`,o.appendChild(e)}let s=document.createElement(`span`);s.className=`block w-full truncate`,s.textContent=t,a.appendChild(o),a.appendChild(s),this.replaceChildren(a),this._root=a}};customElements.get(`mint-bottom-nav-item`)||customElements.define(`mint-bottom-nav-item`,Q),exports.Alert=A,exports.BackButton=p,exports.BottomNavItem=Q,exports.BottomNavigation=Z,exports.Button=r,exports.default=r,exports.Card=d,exports.Chart=V,exports.Checkbox=v,exports.Chip=D,exports.Choice=b,exports.Clickable=k,exports.DatePicker=S,exports.Dropzone=w,exports.Form=T,exports.Grid=h,exports.Icon=n,exports.Input=x,exports.Link=f,exports.Modal=g,exports.OffCanvas=I,exports.Page=m,exports.Popover=_,exports.ResourceTable=j,exports.Search=X,exports.Select=C,exports.SideNavigation=J,exports.SideNavigationActionLinks=W,exports.SideNavigationActionMenu=G,exports.SideNavigationLink=H,exports.SideNavigationLinks=U,exports.Sortable=u,exports.Spinner=t,exports.Stack=o,exports.Switch=i,exports.Tab=L,exports.TabContent=z,exports.TabList=R,exports.Table=E,exports.Tabs=B,exports.Tags=O,exports.Text=a,exports.TopNavigation=Y;
|