monobill-mintui 0.3.76 → 0.4.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.
Files changed (292) hide show
  1. package/README.md +175 -207
  2. package/dist/icons/edit.svg +1 -1
  3. package/dist/index.cjs +41 -174
  4. package/dist/index.js +2729 -9179
  5. package/package.json +62 -40
  6. package/dist/caret-right-BsS-59-c.cjs +0 -1
  7. package/dist/caret-right-DsNN5Epe.js +0 -83
  8. package/dist/components/alert/Alert.d.ts +0 -32
  9. package/dist/components/alert/Alert.d.ts.map +0 -1
  10. package/dist/components/alert/index.d.ts +0 -3
  11. package/dist/components/alert/index.d.ts.map +0 -1
  12. package/dist/components/back-button/BackButton.d.ts +0 -18
  13. package/dist/components/back-button/BackButton.d.ts.map +0 -1
  14. package/dist/components/back-button/index.d.ts +0 -3
  15. package/dist/components/back-button/index.d.ts.map +0 -1
  16. package/dist/components/button/Button.d.ts +0 -44
  17. package/dist/components/button/Button.d.ts.map +0 -1
  18. package/dist/components/button/index.d.ts +0 -3
  19. package/dist/components/button/index.d.ts.map +0 -1
  20. package/dist/components/card/Card.d.ts +0 -17
  21. package/dist/components/card/Card.d.ts.map +0 -1
  22. package/dist/components/card/index.d.ts +0 -3
  23. package/dist/components/card/index.d.ts.map +0 -1
  24. package/dist/components/chart/Chart.d.ts +0 -277
  25. package/dist/components/chart/Chart.d.ts.map +0 -1
  26. package/dist/components/chart/index.d.ts +0 -3
  27. package/dist/components/chart/index.d.ts.map +0 -1
  28. package/dist/components/checkbox/Checkbox.d.ts +0 -41
  29. package/dist/components/checkbox/Checkbox.d.ts.map +0 -1
  30. package/dist/components/checkbox/index.d.ts +0 -3
  31. package/dist/components/checkbox/index.d.ts.map +0 -1
  32. package/dist/components/chip/Chip.d.ts +0 -15
  33. package/dist/components/chip/Chip.d.ts.map +0 -1
  34. package/dist/components/chip/index.d.ts +0 -3
  35. package/dist/components/chip/index.d.ts.map +0 -1
  36. package/dist/components/choice/Choice.d.ts +0 -27
  37. package/dist/components/choice/Choice.d.ts.map +0 -1
  38. package/dist/components/choice/ChoiceOption.d.ts +0 -30
  39. package/dist/components/choice/ChoiceOption.d.ts.map +0 -1
  40. package/dist/components/choice/index.d.ts +0 -5
  41. package/dist/components/choice/index.d.ts.map +0 -1
  42. package/dist/components/clickable/Clickable.d.ts +0 -14
  43. package/dist/components/clickable/Clickable.d.ts.map +0 -1
  44. package/dist/components/clickable/index.d.ts +0 -3
  45. package/dist/components/clickable/index.d.ts.map +0 -1
  46. package/dist/components/date-picker/DatePicker.d.ts +0 -130
  47. package/dist/components/date-picker/DatePicker.d.ts.map +0 -1
  48. package/dist/components/date-picker/index.d.ts +0 -3
  49. package/dist/components/date-picker/index.d.ts.map +0 -1
  50. package/dist/components/dropzone/Dropzone.d.ts +0 -59
  51. package/dist/components/dropzone/Dropzone.d.ts.map +0 -1
  52. package/dist/components/dropzone/index.d.ts +0 -3
  53. package/dist/components/dropzone/index.d.ts.map +0 -1
  54. package/dist/components/form/Form.d.ts +0 -106
  55. package/dist/components/form/Form.d.ts.map +0 -1
  56. package/dist/components/form/index.d.ts +0 -3
  57. package/dist/components/form/index.d.ts.map +0 -1
  58. package/dist/components/grid/Grid.d.ts +0 -16
  59. package/dist/components/grid/Grid.d.ts.map +0 -1
  60. package/dist/components/grid/index.d.ts +0 -3
  61. package/dist/components/grid/index.d.ts.map +0 -1
  62. package/dist/components/icon/Icon.d.ts +0 -15
  63. package/dist/components/icon/Icon.d.ts.map +0 -1
  64. package/dist/components/icon/build-icons.d.ts +0 -2
  65. package/dist/components/icon/build-icons.d.ts.map +0 -1
  66. package/dist/components/icon/icons/archive.d.ts +0 -3
  67. package/dist/components/icon/icons/archive.d.ts.map +0 -1
  68. package/dist/components/icon/icons/arrow-down.d.ts +0 -3
  69. package/dist/components/icon/icons/arrow-down.d.ts.map +0 -1
  70. package/dist/components/icon/icons/arrow-left.d.ts +0 -3
  71. package/dist/components/icon/icons/arrow-left.d.ts.map +0 -1
  72. package/dist/components/icon/icons/arrow-right.d.ts +0 -3
  73. package/dist/components/icon/icons/arrow-right.d.ts.map +0 -1
  74. package/dist/components/icon/icons/arrow-up.d.ts +0 -3
  75. package/dist/components/icon/icons/arrow-up.d.ts.map +0 -1
  76. package/dist/components/icon/icons/attach.d.ts +0 -3
  77. package/dist/components/icon/icons/attach.d.ts.map +0 -1
  78. package/dist/components/icon/icons/barcode.d.ts +0 -3
  79. package/dist/components/icon/icons/barcode.d.ts.map +0 -1
  80. package/dist/components/icon/icons/bookmark.d.ts +0 -3
  81. package/dist/components/icon/icons/bookmark.d.ts.map +0 -1
  82. package/dist/components/icon/icons/calendar-day.d.ts +0 -3
  83. package/dist/components/icon/icons/calendar-day.d.ts.map +0 -1
  84. package/dist/components/icon/icons/calendar-empty.d.ts +0 -3
  85. package/dist/components/icon/icons/calendar-empty.d.ts.map +0 -1
  86. package/dist/components/icon/icons/calendar-week.d.ts +0 -3
  87. package/dist/components/icon/icons/calendar-week.d.ts.map +0 -1
  88. package/dist/components/icon/icons/calendar.d.ts +0 -3
  89. package/dist/components/icon/icons/calendar.d.ts.map +0 -1
  90. package/dist/components/icon/icons/caret-down.d.ts +0 -3
  91. package/dist/components/icon/icons/caret-down.d.ts.map +0 -1
  92. package/dist/components/icon/icons/caret-left.d.ts +0 -3
  93. package/dist/components/icon/icons/caret-left.d.ts.map +0 -1
  94. package/dist/components/icon/icons/caret-right.d.ts +0 -3
  95. package/dist/components/icon/icons/caret-right.d.ts.map +0 -1
  96. package/dist/components/icon/icons/caret-up.d.ts +0 -3
  97. package/dist/components/icon/icons/caret-up.d.ts.map +0 -1
  98. package/dist/components/icon/icons/chat.d.ts +0 -3
  99. package/dist/components/icon/icons/chat.d.ts.map +0 -1
  100. package/dist/components/icon/icons/check.d.ts +0 -3
  101. package/dist/components/icon/icons/check.d.ts.map +0 -1
  102. package/dist/components/icon/icons/clock.d.ts +0 -3
  103. package/dist/components/icon/icons/clock.d.ts.map +0 -1
  104. package/dist/components/icon/icons/close.d.ts +0 -3
  105. package/dist/components/icon/icons/close.d.ts.map +0 -1
  106. package/dist/components/icon/icons/copy.d.ts +0 -3
  107. package/dist/components/icon/icons/copy.d.ts.map +0 -1
  108. package/dist/components/icon/icons/delete.d.ts +0 -3
  109. package/dist/components/icon/icons/delete.d.ts.map +0 -1
  110. package/dist/components/icon/icons/documentation.d.ts +0 -3
  111. package/dist/components/icon/icons/documentation.d.ts.map +0 -1
  112. package/dist/components/icon/icons/download.d.ts +0 -3
  113. package/dist/components/icon/icons/download.d.ts.map +0 -1
  114. package/dist/components/icon/icons/duplicate.d.ts +0 -3
  115. package/dist/components/icon/icons/duplicate.d.ts.map +0 -1
  116. package/dist/components/icon/icons/edit.d.ts +0 -3
  117. package/dist/components/icon/icons/edit.d.ts.map +0 -1
  118. package/dist/components/icon/icons/ellipsis.d.ts +0 -3
  119. package/dist/components/icon/icons/ellipsis.d.ts.map +0 -1
  120. package/dist/components/icon/icons/error.d.ts +0 -3
  121. package/dist/components/icon/icons/error.d.ts.map +0 -1
  122. package/dist/components/icon/icons/external-link.d.ts +0 -3
  123. package/dist/components/icon/icons/external-link.d.ts.map +0 -1
  124. package/dist/components/icon/icons/file.d.ts +0 -3
  125. package/dist/components/icon/icons/file.d.ts.map +0 -1
  126. package/dist/components/icon/icons/filter.d.ts +0 -3
  127. package/dist/components/icon/icons/filter.d.ts.map +0 -1
  128. package/dist/components/icon/icons/folder.d.ts +0 -3
  129. package/dist/components/icon/icons/folder.d.ts.map +0 -1
  130. package/dist/components/icon/icons/grid.d.ts +0 -3
  131. package/dist/components/icon/icons/grid.d.ts.map +0 -1
  132. package/dist/components/icon/icons/help.d.ts +0 -3
  133. package/dist/components/icon/icons/help.d.ts.map +0 -1
  134. package/dist/components/icon/icons/home.d.ts +0 -3
  135. package/dist/components/icon/icons/home.d.ts.map +0 -1
  136. package/dist/components/icon/icons/image.d.ts +0 -3
  137. package/dist/components/icon/icons/image.d.ts.map +0 -1
  138. package/dist/components/icon/icons/index.cjs +0 -4
  139. package/dist/components/icon/icons/index.d.ts +0 -75
  140. package/dist/components/icon/icons/index.d.ts.map +0 -1
  141. package/dist/components/icon/icons/index.js +0 -689
  142. package/dist/components/icon/icons/info.d.ts +0 -3
  143. package/dist/components/icon/icons/info.d.ts.map +0 -1
  144. package/dist/components/icon/icons/language.d.ts +0 -3
  145. package/dist/components/icon/icons/language.d.ts.map +0 -1
  146. package/dist/components/icon/icons/link.d.ts +0 -3
  147. package/dist/components/icon/icons/link.d.ts.map +0 -1
  148. package/dist/components/icon/icons/list.d.ts +0 -3
  149. package/dist/components/icon/icons/list.d.ts.map +0 -1
  150. package/dist/components/icon/icons/location.d.ts +0 -3
  151. package/dist/components/icon/icons/location.d.ts.map +0 -1
  152. package/dist/components/icon/icons/lock.d.ts +0 -3
  153. package/dist/components/icon/icons/lock.d.ts.map +0 -1
  154. package/dist/components/icon/icons/login.d.ts +0 -3
  155. package/dist/components/icon/icons/login.d.ts.map +0 -1
  156. package/dist/components/icon/icons/logout.d.ts +0 -3
  157. package/dist/components/icon/icons/logout.d.ts.map +0 -1
  158. package/dist/components/icon/icons/mail.d.ts +0 -3
  159. package/dist/components/icon/icons/mail.d.ts.map +0 -1
  160. package/dist/components/icon/icons/map.d.ts +0 -3
  161. package/dist/components/icon/icons/map.d.ts.map +0 -1
  162. package/dist/components/icon/icons/menu.d.ts +0 -3
  163. package/dist/components/icon/icons/menu.d.ts.map +0 -1
  164. package/dist/components/icon/icons/moon.d.ts +0 -3
  165. package/dist/components/icon/icons/moon.d.ts.map +0 -1
  166. package/dist/components/icon/icons/notifications.d.ts +0 -3
  167. package/dist/components/icon/icons/notifications.d.ts.map +0 -1
  168. package/dist/components/icon/icons/paste.d.ts +0 -3
  169. package/dist/components/icon/icons/paste.d.ts.map +0 -1
  170. package/dist/components/icon/icons/pin.d.ts +0 -3
  171. package/dist/components/icon/icons/pin.d.ts.map +0 -1
  172. package/dist/components/icon/icons/plus.d.ts +0 -3
  173. package/dist/components/icon/icons/plus.d.ts.map +0 -1
  174. package/dist/components/icon/icons/print.d.ts +0 -3
  175. package/dist/components/icon/icons/print.d.ts.map +0 -1
  176. package/dist/components/icon/icons/refresh.d.ts +0 -3
  177. package/dist/components/icon/icons/refresh.d.ts.map +0 -1
  178. package/dist/components/icon/icons/remove.d.ts +0 -3
  179. package/dist/components/icon/icons/remove.d.ts.map +0 -1
  180. package/dist/components/icon/icons/save.d.ts +0 -3
  181. package/dist/components/icon/icons/save.d.ts.map +0 -1
  182. package/dist/components/icon/icons/search.d.ts +0 -3
  183. package/dist/components/icon/icons/search.d.ts.map +0 -1
  184. package/dist/components/icon/icons/settings.d.ts +0 -3
  185. package/dist/components/icon/icons/settings.d.ts.map +0 -1
  186. package/dist/components/icon/icons/share.d.ts +0 -3
  187. package/dist/components/icon/icons/share.d.ts.map +0 -1
  188. package/dist/components/icon/icons/sort-arrows.d.ts +0 -3
  189. package/dist/components/icon/icons/sort-arrows.d.ts.map +0 -1
  190. package/dist/components/icon/icons/sort.d.ts +0 -3
  191. package/dist/components/icon/icons/sort.d.ts.map +0 -1
  192. package/dist/components/icon/icons/star.d.ts +0 -3
  193. package/dist/components/icon/icons/star.d.ts.map +0 -1
  194. package/dist/components/icon/icons/success.d.ts +0 -3
  195. package/dist/components/icon/icons/success.d.ts.map +0 -1
  196. package/dist/components/icon/icons/sun.d.ts +0 -3
  197. package/dist/components/icon/icons/sun.d.ts.map +0 -1
  198. package/dist/components/icon/icons/table.d.ts +0 -3
  199. package/dist/components/icon/icons/table.d.ts.map +0 -1
  200. package/dist/components/icon/icons/tag.d.ts +0 -3
  201. package/dist/components/icon/icons/tag.d.ts.map +0 -1
  202. package/dist/components/icon/icons/trash.d.ts +0 -3
  203. package/dist/components/icon/icons/trash.d.ts.map +0 -1
  204. package/dist/components/icon/icons/unlock.d.ts +0 -3
  205. package/dist/components/icon/icons/unlock.d.ts.map +0 -1
  206. package/dist/components/icon/icons/upload.d.ts +0 -3
  207. package/dist/components/icon/icons/upload.d.ts.map +0 -1
  208. package/dist/components/icon/icons/user-add.d.ts +0 -3
  209. package/dist/components/icon/icons/user-add.d.ts.map +0 -1
  210. package/dist/components/icon/icons/user.d.ts +0 -3
  211. package/dist/components/icon/icons/user.d.ts.map +0 -1
  212. package/dist/components/icon/icons/users.d.ts +0 -3
  213. package/dist/components/icon/icons/users.d.ts.map +0 -1
  214. package/dist/components/icon/icons/video.d.ts +0 -3
  215. package/dist/components/icon/icons/video.d.ts.map +0 -1
  216. package/dist/components/icon/icons/warning.d.ts +0 -3
  217. package/dist/components/icon/icons/warning.d.ts.map +0 -1
  218. package/dist/components/icon/index.d.ts +0 -3
  219. package/dist/components/icon/index.d.ts.map +0 -1
  220. package/dist/components/icon/registry.d.ts +0 -15
  221. package/dist/components/icon/registry.d.ts.map +0 -1
  222. package/dist/components/input/Input.d.ts +0 -56
  223. package/dist/components/input/Input.d.ts.map +0 -1
  224. package/dist/components/input/index.d.ts +0 -3
  225. package/dist/components/input/index.d.ts.map +0 -1
  226. package/dist/components/link/Link.d.ts +0 -16
  227. package/dist/components/link/Link.d.ts.map +0 -1
  228. package/dist/components/link/index.d.ts +0 -3
  229. package/dist/components/link/index.d.ts.map +0 -1
  230. package/dist/components/modal/Modal.d.ts +0 -32
  231. package/dist/components/modal/Modal.d.ts.map +0 -1
  232. package/dist/components/modal/index.d.ts +0 -3
  233. package/dist/components/modal/index.d.ts.map +0 -1
  234. package/dist/components/off-canvas/OffCanvas.d.ts +0 -42
  235. package/dist/components/off-canvas/OffCanvas.d.ts.map +0 -1
  236. package/dist/components/off-canvas/index.d.ts +0 -3
  237. package/dist/components/off-canvas/index.d.ts.map +0 -1
  238. package/dist/components/page/Page.d.ts +0 -29
  239. package/dist/components/page/Page.d.ts.map +0 -1
  240. package/dist/components/page/index.d.ts +0 -3
  241. package/dist/components/page/index.d.ts.map +0 -1
  242. package/dist/components/popover/Popover.d.ts +0 -48
  243. package/dist/components/popover/Popover.d.ts.map +0 -1
  244. package/dist/components/popover/index.d.ts +0 -3
  245. package/dist/components/popover/index.d.ts.map +0 -1
  246. package/dist/components/resource-table/ResourceTable.d.ts +0 -159
  247. package/dist/components/resource-table/ResourceTable.d.ts.map +0 -1
  248. package/dist/components/resource-table/index.d.ts +0 -3
  249. package/dist/components/resource-table/index.d.ts.map +0 -1
  250. package/dist/components/select/Select.d.ts +0 -34
  251. package/dist/components/select/Select.d.ts.map +0 -1
  252. package/dist/components/select/index.d.ts +0 -3
  253. package/dist/components/select/index.d.ts.map +0 -1
  254. package/dist/components/spinner/Spinner.d.ts +0 -13
  255. package/dist/components/spinner/Spinner.d.ts.map +0 -1
  256. package/dist/components/spinner/index.d.ts +0 -3
  257. package/dist/components/spinner/index.d.ts.map +0 -1
  258. package/dist/components/stack/Stack.d.ts +0 -20
  259. package/dist/components/stack/Stack.d.ts.map +0 -1
  260. package/dist/components/stack/index.d.ts +0 -3
  261. package/dist/components/stack/index.d.ts.map +0 -1
  262. package/dist/components/switch/Switch.d.ts +0 -32
  263. package/dist/components/switch/Switch.d.ts.map +0 -1
  264. package/dist/components/switch/index.d.ts +0 -3
  265. package/dist/components/switch/index.d.ts.map +0 -1
  266. package/dist/components/table/Table.d.ts +0 -15
  267. package/dist/components/table/Table.d.ts.map +0 -1
  268. package/dist/components/table/index.d.ts +0 -3
  269. package/dist/components/table/index.d.ts.map +0 -1
  270. package/dist/components/tabs/Tab.d.ts +0 -19
  271. package/dist/components/tabs/Tab.d.ts.map +0 -1
  272. package/dist/components/tabs/TabContent.d.ts +0 -13
  273. package/dist/components/tabs/TabContent.d.ts.map +0 -1
  274. package/dist/components/tabs/TabList.d.ts +0 -12
  275. package/dist/components/tabs/TabList.d.ts.map +0 -1
  276. package/dist/components/tabs/Tabs.d.ts +0 -20
  277. package/dist/components/tabs/Tabs.d.ts.map +0 -1
  278. package/dist/components/tabs/index.d.ts +0 -9
  279. package/dist/components/tabs/index.d.ts.map +0 -1
  280. package/dist/components/tags/Tags.d.ts +0 -57
  281. package/dist/components/tags/Tags.d.ts.map +0 -1
  282. package/dist/components/tags/index.d.ts +0 -3
  283. package/dist/components/tags/index.d.ts.map +0 -1
  284. package/dist/components/text/Text.d.ts +0 -25
  285. package/dist/components/text/Text.d.ts.map +0 -1
  286. package/dist/components/text/index.d.ts +0 -3
  287. package/dist/components/text/index.d.ts.map +0 -1
  288. package/dist/icons/sort-arrows.svg +0 -3
  289. package/dist/index.d.ts +0 -63
  290. package/dist/index.d.ts.map +0 -1
  291. package/tailwind.preset.cjs +0 -24
  292. package/tailwind.preset.js +0 -24
package/dist/index.cjs CHANGED
@@ -1,17 +1,48 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const $t=require("./caret-right-BsS-59-c.cjs");class lt extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["size","data-button-variant","data-button-tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getSize(){const t=this.getAttribute("size")||"default",e={default:"w-4 h-4",large:"w-16 h-16"};return e[t]||e.default}render(){const t=this.getSize(),e=this.getAttribute("size")||"default",i=!!(this.style.width&&this.style.height),s=this.getAttribute("data-button-variant"),n=document.documentElement.classList.contains("dark");let r;if(i){const c=this.getAttribute("data-button-tone")||"neutral";s==="solid"?c==="neutral"?r=n?"#ffffff":"#0f172a":r="#ffffff":r=n?"#ffffff":"#0f172a"}else r=n?"#e2e8f0":"#0f172a";const a=e==="large"?"2":"4",o=!!(this.style.width&&this.style.height),l=`
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=class extends HTMLElement{static get observedAttributes(){return[`size`,`data-button-variant`,`data-button-tone`]}constructor(){super(),this._darkModeObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._observeDarkMode()}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`]}))}getSize(){let e=this.getAttribute(`size`)||`default`,t={default:`w-4 h-4`,large:`w-16 h-16`};return t[e]||t.default}render(){let e=this.getSize(),t=this.getAttribute(`size`)||`default`,n=this.style.width&&this.style.height,r=this.getAttribute(`data-button-variant`),i=document.documentElement.classList.contains(`dark`),a;if(n){let e=this.getAttribute(`data-button-tone`)||`neutral`;a=r===`solid`?e===`neutral`?i?`#ffffff`:`#0f172a`:`#ffffff`:i?`#ffffff`:`#0f172a`}else a=i?`#e2e8f0`:`#0f172a`;let o=t===`large`?`2`:`4`,s=this.style.width&&this.style.height;this.innerHTML=`
2
2
  <svg
3
3
  xmlns="http://www.w3.org/2000/svg"
4
4
  fill="none"
5
5
  viewBox="0 0 24 24"
6
- class="animate-spin ${o?"":t}"
7
- style="${o?`width: ${this.style.width}; height: ${this.style.height}; animation-duration: 0.8s;`:"animation-duration: 0.8s;"}"
6
+ class="mint-spinner-rotate ${s?``:e}"
7
+ style="${s?`width: ${this.style.width}; height: ${this.style.height};`:``} --mint-spinner-rotate-duration: 0.8s; --mint-spinner-dash-duration: 1.2s;"
8
8
  >
9
+ <style>
10
+ @keyframes mint-spinner-rotate {
11
+ to { transform: rotate(360deg); }
12
+ }
13
+
14
+ @keyframes mint-spinner-dash-array {
15
+ 0% { stroke-dasharray: 0 62.83; }
16
+ 25% { stroke-dasharray: 15.7 47.13; }
17
+ 50% { stroke-dasharray: 31.4 31.4; }
18
+ 75% { stroke-dasharray: 15.7 47.13; }
19
+ 100% { stroke-dasharray: 0 62.83; }
20
+ }
21
+
22
+ @keyframes mint-spinner-dash-offset {
23
+ 0% { stroke-dashoffset: 0; }
24
+ 100% { stroke-dashoffset: -62.83; }
25
+ }
26
+
27
+ .mint-spinner-rotate {
28
+ transform-origin: 50% 50%;
29
+ transform-box: fill-box;
30
+ animation: mint-spinner-rotate var(--mint-spinner-rotate-duration, 0.8s) linear infinite;
31
+ }
32
+
33
+ .mint-spinner-progress {
34
+ animation:
35
+ mint-spinner-dash-array var(--mint-spinner-dash-duration, 1.2s) ease-in-out infinite,
36
+ mint-spinner-dash-offset var(--mint-spinner-dash-duration, 1.2s) linear infinite;
37
+ }
38
+ </style>
39
+
9
40
  <circle
10
41
  cx="12"
11
42
  cy="12"
12
43
  r="10"
13
- stroke="${r}"
14
- stroke-width="${a}"
44
+ stroke="${a}"
45
+ stroke-width="${o}"
15
46
  opacity="0.25"
16
47
  class="opacity-25"
17
48
  ></circle>
@@ -19,178 +50,14 @@
19
50
  cx="12"
20
51
  cy="12"
21
52
  r="10"
22
- stroke="${r}"
23
- stroke-width="${a}"
53
+ stroke="${a}"
54
+ stroke-width="${o}"
24
55
  stroke-linecap="round"
25
56
  fill="none"
26
57
  opacity="0.75"
27
58
  stroke-dasharray="0 62.83"
28
59
  stroke-dashoffset="0"
29
- >
30
- <animate
31
- attributeName="stroke-dasharray"
32
- values="0 62.83;15.7 47.13;31.4 31.4;15.7 47.13;0 62.83"
33
- dur="1.2s"
34
- repeatCount="indefinite"
35
- ></animate>
36
- <animate
37
- attributeName="stroke-dashoffset"
38
- values="0;-62.83"
39
- dur="1.2s"
40
- repeatCount="indefinite"
41
- ></animate>
42
- </circle>
60
+ class="mint-spinner-progress"
61
+ />
43
62
  </svg>
44
- `;this.innerHTML=l.trim()}}customElements.get("mint-spinner")||customElements.define("mint-spinner",lt);class ct extends HTMLElement{constructor(){super(),this._darkModeObserver=null}static get observedAttributes(){return["name"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","inline-flex","items-center","leading-none"),this.render(),this._observeDarkMode()}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(t=>{for(const e of t)if(e.type==="attributes"&&e.attributeName==="class"){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getName(){return this.getAttribute("name")||""}generateSVGMarkup(t){if(t.customSvg)return t.customSvg;let e;return t.fill&&t.strokeWidth?e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="none" stroke="currentColor" stroke-width="${t.strokeWidth}" stroke-linecap="${t.strokeLinecap||"round"}" stroke-linejoin="${t.strokeLinejoin||"round"}">
45
- <path d="${t.path}" />
46
- </svg>`:t.fill?t.viewBox==="0 0 512 512"?e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
47
- <g transform="scale(0.046875)">
48
- <path d="${t.path}" />
49
- </g>
50
- </svg>`:e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="currentColor">
51
- <path d="${t.path}" />
52
- </svg>`:e=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${t.viewBox}" fill="none" stroke="currentColor" stroke-width="${t.strokeWidth||"2"}" stroke-linecap="${t.strokeLinecap||"round"}" stroke-linejoin="${t.strokeLinejoin||"round"}">
53
- <path d="${t.path}" />
54
- </svg>`,e}render(){var l,c,h;const t=this.getName();if(!t){this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const e=$t.getIcon(t);if(!e){console.warn(`Icon "${t}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${t}'`),this.innerHTML="",this.style.maskImage="",this.style.webkitMaskImage="",this.style.backgroundColor="";return}const i=this.closest("mint-button")||((l=this.parentElement)==null?void 0:l.closest("mint-button")),s=this.closest("mint-switch")||((c=this.parentElement)==null?void 0:c.closest("mint-switch")),n=this.closest("mint-select")||((h=this.parentElement)==null?void 0:h.closest("mint-select"));if(!Array.from(this.classList).some(p=>p.startsWith("w-")||p.startsWith("h-"))&&!n){let p;s?p="w-3 h-3":i?p="w-[1em] h-[1em]":p="w-[1.3em] h-[1.3em]",this.classList.remove("w-4","h-4","w-5","h-5","w-[1em]","h-[1em]","w-[1.3em]","h-[1.3em]","w-3","h-3","w-[0.875em]","h-[0.875em]"),p.split(" ").forEach(d=>{d&&this.classList.add(d)})}const a=this.generateSVGMarkup(e);this.innerHTML=a,this.style.maskImage="",this.style.webkitMaskImage="",this.style.maskSize="",this.style.webkitMaskSize="",this.style.maskRepeat="",this.style.webkitMaskRepeat="",this.style.maskPosition="",this.style.webkitMaskPosition="",this.style.backgroundColor="",this.style.aspectRatio="1 / 1";const o=this.querySelector("svg");if(o&&(o.style.width="100%",o.style.height="100%"),s)this.classList.remove("text-gray-100","text-gray-900"),this.classList.add("text-gray-900");else if(i)this.classList.remove("text-gray-100","text-gray-900");else{const d=document.documentElement.classList.contains("dark")?"text-gray-100":"text-gray-900";this.classList.remove("text-gray-100","text-gray-900"),this.classList.add(d)}}}customElements.get("mint-icon")||customElements.define("mint-icon",ct);const et=class et extends HTMLElement{constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1,this._handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleMouseUp=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleMouseLeave=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add("mint-button-active")},this._handleTouchEnd=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))},this._handleTouchCancel=()=>{this._button&&(this.isActive()||this._button.classList.remove("mint-button-active"))}}static get observedAttributes(){return["variant","tone","disabled","loading","button-type","type","full-width","icon-position","icon","active","align"]}connectedCallback(){if(!et._activeShadowStyleInjected){const t=document.createElement("style");t.textContent=`
55
- mint-button[data-variant="link"] .mint-button-active {
56
- box-shadow: none !important;
57
- }
58
- `,document.head.appendChild(t),et._activeShadowStyleInjected=!0}this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add("w-full")}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getVariant(){return this.getAttribute("variant")||"solid"}getTone(){return this.getAttribute("tone")||"neutral"}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}getType(){const t=this.getAttribute("type"),e=this.getAttribute("button-type");return(t||e||"default")==="submit"?"submit":"button"}isFullWidth(){return this.getAttribute("full-width")==="true"}isActive(){return this.getAttribute("active")==="true"}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.removeAttribute("active")}getIconPosition(){return this.getAttribute("icon-position")||"left"}getIcon(){return this.getAttribute("icon")||""}getAlignment(){const t=this.getAttribute("align");return t==="left"||t==="center"||t==="right"?t:"center"}isIconOnly(){var i,s,n,r,a;if(!(this.getIcon()||((i=this._button)==null?void 0:i.querySelector('[slot="icon"], .mint-button-icon, mint-icon'))))return!1;const e=(s=this._button)==null?void 0:s.querySelector(".mint-button-content");if(e&&((n=e.textContent)!=null&&n.trim()))return!1;if(this._button)for(let o=this._button.firstChild;o;o=o.nextSibling){if(o.nodeType===Node.TEXT_NODE&&((r=o.textContent)!=null&&r.trim()))return!1;if(o.nodeType===Node.ELEMENT_NODE){const l=o;if(l.tagName!=="MINT-ICON"&&l.tagName!=="MINT-SPINNER"&&!l.querySelector("mint-spinner")&&!l.hasAttribute("slot")&&l.className!=="mint-button-icon"&&!(l.className==="mr-2"&&l.querySelector("mint-spinner"))&&(a=l.textContent)!=null&&a.trim())return!1}}return!0}getActiveStateClasses(){const t=this.getVariant(),e=this.getTone(),i=`${t}-${e}`;return{"solid-action":["!bg-slate-900","dark:!bg-slate-700","hover:!bg-slate-900","dark:hover:!bg-slate-700","!border-t-slate-900","!border-l-slate-900","!border-r-slate-600","!border-b-slate-600","dark:!border-t-slate-700","dark:!border-l-slate-700","dark:!border-r-slate-500","dark:!border-b-slate-500"],"solid-neutral":["!bg-gray-100","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","!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-gray-700","dark:!border-b-gray-700"],"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-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-neutral":["!bg-gray-50","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","!text-gray-900","dark:!text-white","hover:!bg-gray-50","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","hover:!text-gray-900","dark:hover:!text-white"],"ghost-info":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-warning":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"ghost-danger":["!bg-gray-100","!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:!bg-gray-800","hover:!bg-gray-100","dark:hover:!bg-gray-800","hover:!shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]"],"link-action":["!text-slate-900","dark:!text-slate-300","hover:!text-slate-900","dark:hover:!text-slate-300"],"link-neutral":["!text-gray-950","dark:!text-gray-200","hover:!text-gray-950","dark:hover:!text-gray-200"],"link-info":["!text-blue-900","dark:!text-blue-200","hover:!text-blue-900","dark:hover:!text-blue-200"],"link-warning":["!text-amber-900","dark:!text-amber-200","hover:!text-amber-900","dark:hover:!text-amber-200"],"link-danger":["!text-red-900","dark:!text-red-200","hover:!text-red-900","dark:hover:!text-red-200"]}[i]||[]}getButtonClasses(){const t=this.isIconOnly(),e=this.getVariant(),i=this.getAlignment();let s="justify-center";i==="left"?s="justify-start":i==="right"&&(s="justify-end");const n=["inline-flex","items-center",s,"font-medium","rounded-lg","box-border",...t?["p-1.5","aspect-square","w-[2.25rem]","h-[2.25rem]"]:["px-3.5","py-1.5","min-h-[2.25rem]"],"text-sm","transition-all","duration-100","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"],r=this.getTone(),a={"solid-action":["bg-slate-800","dark:bg-slate-600","text-white","hover:bg-slate-950","dark:hover:bg-slate-700","active:bg-slate-900","dark:active:bg-slate-700","disabled:active:bg-slate-800","dark:disabled:active:bg-slate-600","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","border-2","border-t-slate-600","border-l-slate-600","border-r-slate-900","border-b-slate-900","dark:border-t-slate-500","dark:border-l-slate-500","dark:border-r-slate-700","dark:border-b-slate-700","active:border-t-slate-900","active:border-l-slate-900","active:border-r-slate-600","active:border-b-slate-600","dark:active:border-t-slate-700","dark:active:border-l-slate-700","dark:active:border-r-slate-500","dark:active:border-b-slate-500","disabled:active:border-t-slate-600","disabled:active:border-l-slate-600","disabled:active:border-r-slate-900","disabled:active:border-b-slate-900","dark:disabled:active:border-t-slate-500","dark:disabled:active:border-l-slate-500","dark:disabled:active:border-r-slate-700","dark:disabled:active:border-b-slate-700",'[&[data-loading="true"]:active]:border-t-slate-600','[&[data-loading="true"]:active]:border-l-slate-600','[&[data-loading="true"]:active]:border-r-slate-900','[&[data-loading="true"]:active]:border-b-slate-900','[&[data-loading="true"]:active]:dark:border-t-slate-500','[&[data-loading="true"]:active]:dark:border-l-slate-500','[&[data-loading="true"]:active]:dark:border-r-slate-700','[&[data-loading="true"]:active]:dark:border-b-slate-700'],"solid-neutral":["bg-white","dark:bg-gray-900","text-gray-900","dark:text-white","hover:bg-gray-50","dark:hover:bg-gray-800","active:bg-gray-100","dark:active:bg-gray-800","disabled:active:bg-white","dark:disabled:active:bg-gray-900","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-gray-700","dark:border-b-gray-700","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-gray-700","dark:active:border-b-gray-700","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-gray-700","dark:disabled:active:border-l-gray-700","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-gray-700','[&[data-loading="true"]:active]:dark:border-l-gray-700','[&[data-loading="true"]:active]:dark:border-r-gray-950','[&[data-loading="true"]:active]:dark:border-b-gray-950'],"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'],"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'],"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'],"ghost-action":["bg-transparent","text-slate-800","dark:text-slate-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-neutral":["bg-transparent","text-gray-700","dark:text-gray-200","active:bg-gray-50","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","active:text-gray-900","dark:active:text-white","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-info":["bg-transparent","text-blue-800","dark:text-blue-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-warning":["bg-transparent","text-amber-800","dark:text-amber-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"ghost-danger":["bg-transparent","text-red-800","dark:text-red-400","active:bg-gray-100","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]","dark:active:bg-gray-800","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-action":["bg-transparent","text-slate-800","dark:text-slate-400","hover:text-slate-950","dark:hover:text-slate-200","active:text-slate-900","dark:active:text-slate-300","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-neutral":["bg-transparent","text-gray-700","dark:text-gray-300","hover:text-gray-900","dark:hover:text-gray-100","active:text-gray-950","dark:active:text-gray-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-info":["bg-transparent","text-blue-800","dark:text-blue-400","hover:text-blue-950","dark:hover:text-blue-300","active:text-blue-900","dark:active:text-blue-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-warning":["bg-transparent","text-amber-800","dark:text-amber-400","hover:text-amber-950","dark:hover:text-amber-300","active:text-amber-900","dark:active:text-amber-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"],"link-danger":["bg-transparent","text-red-800","dark:text-red-400","hover:text-red-950","dark:hover:text-red-300","active:text-red-900","dark:active:text-red-200","disabled:active:bg-transparent","dark:disabled:active:bg-transparent","disabled:active:shadow-none","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","shadow-none","hover:shadow-none","border-2","border-transparent"]},o=`${e}-${r}`,l=a[o]||a["solid-neutral"],c=[...n,...l];if(this.isActive()){const h=this.getActiveStateClasses();c.push(...h)}return this.isFullWidth()&&c.push("w-full"),c.join(" ")}render(){var h,p,d,u,m,f;const t=this.isDisabled()||this.isLoading(),e=this.getType();if(!this._button){for(this._button=document.createElement("button");this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=e,this._button.disabled=t;let i=this._button.querySelector("mint-spinner");const s=this.isLoading();if(s)if(i)i.setAttribute("data-button-variant",this.getVariant()),i.setAttribute("data-button-tone",this.getTone()),"render"in i&&typeof i.render=="function"&&i.render();else{const g=document.createElement("span");g.className="mr-2 inline-flex items-center";const _=document.createElement("mint-spinner");_.setAttribute("size","default"),_.setAttribute("data-button-variant",this.getVariant()),_.setAttribute("data-button-tone",this.getTone()),_.style.width="0.875rem",_.style.height="0.875rem",g.appendChild(_),this._button.insertBefore(g,this._button.firstChild)}else i&&((h=i.parentElement)==null||h.remove());for(;this.firstChild&&this.firstChild!==this._button;)this._button.appendChild(this.firstChild);const n=this.getIcon();let r=this._button.querySelector('[slot="icon"], .mint-button-icon, mint-icon');n?(r&&r.tagName!=="MINT-ICON"&&(r.remove(),r=null),!r||r.tagName!=="MINT-ICON"?(r=document.createElement("mint-icon"),r.setAttribute("name",n),r.className="mint-button-icon"):r.setAttribute("name",n)):r&&r.tagName==="MINT-ICON"&&(r.remove(),r=null),r||(r=this._button.querySelector('[slot="icon"], .mint-button-icon'));const a=this.getIconPosition();let o=this._button.querySelector(".mint-button-content");if(o){const g=r&&r.tagName==="MINT-ICON";if(r&&!r.parentElement){const _=(u=this._button.querySelector("mint-spinner"))==null?void 0:u.parentElement;g||a==="left"?_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o):o.insertAdjacentElement("afterend",r)}else if(r&&(g||a==="left")&&r.nextSibling!==o){r.remove();const _=(m=this._button.querySelector("mint-spinner"))==null?void 0:m.parentElement;_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,o)}else r&&!g&&a==="right"&&r.previousSibling!==o&&(r.remove(),o.insertAdjacentElement("afterend",r))}else{const g=[];for(let _=this._button.firstChild;_;_=_.nextSibling){if(_.nodeType!==Node.ELEMENT_NODE){g.push(_);continue}const b=_;b.tagName!=="MINT-SPINNER"&&!b.querySelector("mint-spinner")&&_!==r&&!b.hasAttribute("slot")&&!(b.className==="mr-2"&&b.querySelector("mint-spinner"))&&g.push(_)}if(g.length>0){o=document.createElement("span"),o.className="mint-button-content inline-flex items-center",g.forEach(b=>{o.appendChild(b)});const _=(p=this._button.querySelector("mint-spinner"))==null?void 0:p.parentElement;r&&a==="left"?_?(_.insertAdjacentElement("afterend",r),r.insertAdjacentElement("afterend",o)):(this._button.insertBefore(r,this._button.firstChild),r.insertAdjacentElement("afterend",o)):r&&a==="right"?_?(_.insertAdjacentElement("afterend",o),o.insertAdjacentElement("afterend",r)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement("afterend",r)):_?_.insertAdjacentElement("afterend",o):this._button.insertBefore(o,this._button.firstChild)}else if(r&&r.tagName==="MINT-ICON"&&!r.parentElement){const _=(d=this._button.querySelector("mint-spinner"))==null?void 0:d.parentElement;_?_.insertAdjacentElement("afterend",r):this._button.insertBefore(r,this._button.firstChild)}}const l=this.isIconOnly();if(r&&(r.classList.contains("mint-button-icon")||r.classList.add("mint-button-icon"),s?r.style.display="none":r.style.display="",r.classList.remove("mr-1.5","ml-1.5"),l?r.tagName==="MINT-ICON"?(r.style.width="1em",r.style.height="1em",r.style.maxWidth="1em",r.style.maxHeight="1em",r.style.flexShrink="0"):(r.style.maxWidth="1em",r.style.maxHeight="1em",r.style.flexShrink="0",r.tagName==="svg"&&(r.style.width="1em",r.style.height="1em")):a==="left"?r.classList.add("mr-1.5"):r.classList.add("ml-1.5")),s){const g=(f=this._button.querySelector("mint-spinner"))==null?void 0:f.parentElement;g&&(l?(g.classList.remove("mr-2"),g.classList.add("mr-0")):g.classList.contains("mr-2")||(g.classList.remove("mr-0"),g.classList.add("mr-2")))}const c=this.getButtonClasses();this._button.className=c,this.setAttribute("data-variant",this.getVariant()),this.setAttribute("data-tone",this.getTone()),this._button.setAttribute("data-variant",this.getVariant()),s?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")}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),this._clickHandler&&this._button.addEventListener("click",this._clickHandler,!0),this._button.addEventListener("mousedown",this._handleMouseDown),this._button.addEventListener("mouseup",this._handleMouseUp),this._button.addEventListener("mouseleave",this._handleMouseLeave),this._button.addEventListener("touchstart",this._handleTouchStart),this._button.addEventListener("touchend",this._handleTouchEnd),this._button.addEventListener("touchcancel",this._handleTouchCancel))}removeEventListeners(){this._button&&(this._clickHandler&&(this._button.removeEventListener("click",this._clickHandler,!0),this._clickHandler=null),this._button.removeEventListener("mousedown",this._handleMouseDown),this._button.removeEventListener("mouseup",this._handleMouseUp),this._button.removeEventListener("mouseleave",this._handleMouseLeave),this._button.removeEventListener("touchstart",this._handleTouchStart),this._button.removeEventListener("touchend",this._handleTouchEnd),this._button.removeEventListener("touchcancel",this._handleTouchCancel))}handleClick(t){if(this.isDisabled()||this.isLoading()){t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation();return}if(this.getType()==="submit"){this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0}));return}if(t.stopPropagation(),t.stopImmediatePropagation(),this._isHandlingClick){t.preventDefault();return}this._isHandlingClick=!0,t.preventDefault(),this.dispatchEvent(new CustomEvent("click",{detail:{originalEvent:t},bubbles:!0,cancelable:!0,composed:!0})),requestAnimationFrame(()=>{this._isHandlingClick=!1})}};et._activeShadowStyleInjected=!1;let st=et;customElements.get("mint-button")||customElements.define("mint-button",st);class ht extends HTMLElement{constructor(){super(),this._button=null,this._checked=!1}static get observedAttributes(){return["checked","disabled","label","icon","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");const t=this.getAttribute("checked");this._checked=t==="true",this.render()}_getSwitchContainer(){let t=this.querySelector(".mint-switch-container");return t||(t=document.createElement("div"),t.className="mint-switch-container flex items-center gap-2",this.insertBefore(t,this.firstChild)),t}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.getAttribute("loading")==="true"}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i==="true"),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked","true"):this.setAttribute("checked","false"),this._checked=!!t,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(){const t=this.hasError(),e=["relative","inline-flex","items-center","rounded-full","h-5","w-10","border","transition-colors","duration-200","ease-in-out","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]","disabled:opacity-50","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-950","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-700 dark:border-slate-500"]:["bg-slate-200","dark:bg-slate-400",t?"border-red-300 dark:border-red-300":"border-slate-300 dark:border-slate-500"];return[...e,...i].join(" ")}getThumbClasses(){const t=["relative","inline-block","rounded-full","bg-white","dark:bg-gray-50","h-4","w-4","shadow-lg","transform","transition-transform","duration-200","ease-in-out","pointer-events-none","overflow-hidden"],e=this._checked?"translate-x-5":"translate-x-0.5";return[...t,e].join(" ")}getIconClasses(){return["absolute","inset-0","flex","items-center","justify-center","pointer-events-none"].join(" ")}render(){const t=this.isLoading(),e=this.getSwitchClasses(),i=this.getThumbClasses(),s=this.getLabel(),n=this.getInfo(),r=this.getIcon(),a=this.getAttribute("id")||`mint-switch-${Math.random().toString(36).substr(2,9)}`;this.getAttribute("id")||this.setAttribute("id",a);const o=this._getSwitchContainer();this._button?this._button.parentElement!==o&&o.appendChild(this._button):(this._button=document.createElement("button"),o.appendChild(this._button),this.setupEventListeners());let l=o.querySelector(".mint-switch-label");s?(l||(l=document.createElement("label"),l.className="mint-switch-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",this._button&&this._button.parentElement===o?o.insertBefore(l,this._button.nextSibling):o.appendChild(l)),l.textContent=s,l.setAttribute("for",a),this.isDisabled()?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove(),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.id=a,this._button.setAttribute("aria-checked",String(this._checked)),this._button.setAttribute("aria-label",s||"Toggle switch"),this._button.setAttribute("role","switch"),this._button.type="button";let c=this._button.querySelector("span");c||(c=document.createElement("span"),this._button.appendChild(c)),c.className=i;const h=c.querySelector("span");if(r){let d=h;d||(d=document.createElement("span"),d.className=this.getIconClasses(),c.appendChild(d));let u=d.querySelector("mint-icon");u||(u=document.createElement("mint-icon"),d.appendChild(u)),u.setAttribute("name",r)}else h&&h.remove();let p=this.querySelector(".mint-switch-info");n?(p||(p=document.createElement("span"),p.className="mint-switch-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",o&&o.parentElement===this?this.insertBefore(p,o.nextSibling):this.appendChild(p)),p.textContent=n,this.isDisabled()?p.classList.add("opacity-40"):p.classList.remove("opacity-40")):p&&p.remove(),this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this._button&&this._button.addEventListener("click",this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener("click",this.handleToggle.bind(this))}handleToggle(t){if(!this.isDisabled()){this.checked=!this._checked;const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("toggle",{detail:{checked:this._checked},bubbles:!0,cancelable:!0}))}}_renderSkeleton(t){const e=this._getSwitchContainer(),i=this.getLabel(),s=this.getInfo();let n=e.querySelector(".mint-switch-skeleton-container"),r=this.querySelector(".mint-switch-info-skeleton");if(t){e.classList.contains("relative")||e.classList.add("relative"),n||(n=document.createElement("div"),n.className="mint-switch-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",e.appendChild(n));let a=n.querySelector(".mint-switch-skeleton-box");if(a||(a=document.createElement("div"),a.className="mint-switch-skeleton-box flex-shrink-0 w-10 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(a)),i){let l=n.querySelector(".mint-switch-skeleton-label");l||(l=document.createElement("div"),l.className="mint-switch-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",n.appendChild(l))}else{const l=n.querySelector(".mint-switch-skeleton-label");l&&l.remove()}n.style.display="flex",this._button&&(this._button.style.visibility="hidden",this._button.style.pointerEvents="none");const o=e.querySelector(".mint-switch-label");if(o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),s){r||(r=document.createElement("div"),r.className="mint-switch-info-skeleton h-3 w-32 rounded bg-gray-200 dark:bg-gray-700 animate-pulse mt-2",e&&e.parentElement===this?this.insertBefore(r,e.nextSibling):this.appendChild(r)),r.style.display="block";const l=this.querySelector(".mint-switch-info");l&&(l.style.display="none")}else r&&(r.style.display="none")}else{n&&(n.style.display="none"),r&&(r.style.display="none"),this._button&&(this._button.style.visibility="visible",this._button.style.pointerEvents="auto");const a=e.querySelector(".mint-switch-label");a&&(a.style.visibility="visible",a.style.pointerEvents="auto");const o=this.querySelector(".mint-switch-info");o&&(o.style.display="")}}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-switch-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-switch-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove(),this._button&&(this._button.className=this.getSwitchClasses())}}customElements.get("mint-switch")||customElements.define("mint-switch",ht);class dt extends HTMLElement{constructor(){super(),this._darkModeObserver=null,this._userClasses=new Set}static get observedAttributes(){return["variant","size","bold","underline","strike","italic","display","inline"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline"),this._captureUserClasses(),this.render(),this._observeDarkMode()}_captureUserClasses(){Array.from(this.classList).forEach(e=>this._userClasses.add(e))}attributeChangedCallback(t,e,i){e!==i&&this.render()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this.render()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}getVariant(){return this.getAttribute("variant")||"default"}getSize(){return this.getAttribute("size")||"regular"}isBold(){return this.getAttribute("bold")==="true"}isUnderline(){return this.getAttribute("underline")==="true"}isStrike(){return this.getAttribute("strike")==="true"}isItalic(){return this.getAttribute("italic")==="true"}getDisplay(){const t=this.getAttribute("display");return t||(this.getAttribute("inline")==="true"?"inline-block":"block")}getTextClasses(){const t=this.getSize(),e=this.getVariant(),i=document.documentElement.classList.contains("dark"),s={heading:["font-semibold"],"sub-heading":["font-medium"],regular:[]},n={default:i?["text-gray-100"]:["text-gray-900"],muted:i?["text-gray-400"]:["text-gray-400"],danger:i?["text-red-400"]:["text-red-600"],success:i?["text-green-400"]:["text-green-600"]},r=[];this.isBold()&&r.push("font-bold"),this.isUnderline()&&r.push("underline"),this.isStrike()&&r.push("line-through"),this.isItalic()&&r.push("italic");const a=this.getDisplay();return[a==="block"?"block":a==="inline"?"inline":"inline-block",...s[t]||s.regular,...n[e]||n.default,...r].join(" ")}render(){const t=this.getSize(),e=["text-gray-100","text-gray-900","text-gray-400","text-red-400","text-red-600","text-green-400","text-green-600"],i=["text-2xl","text-lg","text-sm"];i.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)}),e.forEach(l=>{this.classList.remove(l),this._userClasses.delete(l)});const s=this.getTextClasses().split(" ").filter(l=>l.trim());Array.from(this.classList).forEach(l=>{!e.includes(l)&&!i.includes(l)&&this._userClasses.add(l)});const r=[...new Set([...s,...Array.from(this._userClasses)])];this.className=r.join(" ");const a={heading:"clamp(1.25rem, 2.5vw + 0.5rem, 1.5rem)","sub-heading":"clamp(1rem, 1.5vw + 0.5rem, 1.125rem)",regular:"clamp(0.875rem, 1vw + 0.5rem, 0.875rem)"},o=a[t]||a.regular;this.style.setProperty("font-size",o)}}customElements.get("mint-text")||customElements.define("mint-text",dt);class ut extends HTMLElement{constructor(){super(),this._childObserver=null}static get observedAttributes(){return["direction","text-align","gap"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this.getTextAlign()&&this._observeChildren()}attributeChangedCallback(t,e,i){e!==i&&(this.render(),t==="text-align"&&this._observeChildren())}_observeChildren(){this._childObserver||(this._childObserver=new MutationObserver(()=>{const t=this.getTextAlign();t&&this._applyTextAlignToChildren(t)}),this._childObserver.observe(this,{childList:!0,subtree:!1}))}disconnectedCallback(){this._childObserver&&(this._childObserver.disconnect(),this._childObserver=null)}getDirection(){return(this.getAttribute("direction")||"vertical")==="horizontal"?"horizontal":"vertical"}getGap(){const t=this.getAttribute("gap")||"3";return parseFloat(t)}getTextAlign(){const t=this.getAttribute("text-align")||"";return["left","center","right","justify"].includes(t)?t:""}getStackClasses(){const t=this.getDirection(),e=this.getTextAlign(),i=this.getGap(),s=["flex",t==="horizontal"?"flex-row":"flex-col",`gap-${i}`];return e&&(s.push(`text-${e}`),s.push(`[&>*]:text-${e}`),s.push(`[&>*_.mint-button-content]:text-${e}`),e==="left"?(s.push("[&>mint-button]:!justify-start"),s.push("[&>mint-button>button]:!justify-start")):e==="right"?(s.push("[&>mint-button]:!justify-end"),s.push("[&>mint-button>button]:!justify-end")):e==="center"&&(s.push("[&>mint-button]:!justify-center"),s.push("[&>mint-button>button]:!justify-center"))),s.join(" ")}render(){const t=this.getStackClasses(),e=this.getTextAlign();["flex","flex-row","flex-col","gap-1","gap-2","gap-3","text-left","text-center","text-right","text-justify","[&>*]:text-left","[&>*]:text-center","[&>*]:text-right","[&>*]:text-justify","[&>*_.mint-button-content]:text-left","[&>*_.mint-button-content]:text-center","[&>*_.mint-button-content]:text-right","[&>*_.mint-button-content]:text-justify","[&>mint-button]:!justify-start","[&>mint-button]:!justify-center","[&>mint-button]:!justify-end","[&>mint-button>button]:!justify-start","[&>mint-button>button]:!justify-center","[&>mint-button>button]:!justify-end"].forEach(n=>this.classList.remove(n)),t.split(" ").forEach(n=>{n&&this.classList.add(n)}),["box-border","m-0","p-0","border-0","align-baseline","block"].forEach(n=>{this.classList.contains(n)||this.classList.add(n)}),e?this._applyTextAlignToChildren(e):this._removeTextAlignFromChildren()}_applyTextAlignToChildren(t){Array.from(this.children).forEach(i=>{if(i.tagName==="MINT-BUTTON"){const s=i.querySelector("button");if(s){s.classList.remove("justify-start","justify-center","justify-end"),t==="left"?s.classList.add("justify-start"):t==="right"?s.classList.add("justify-end"):t==="center"&&s.classList.add("justify-center");const n=s.querySelector(".mint-button-content");n&&(n.classList.remove("text-left","text-center","text-right","text-justify"),n.classList.add(`text-${t}`))}}else i.classList.remove("text-left","text-center","text-right","text-justify"),i.classList.add(`text-${t}`)})}_removeTextAlignFromChildren(){Array.from(this.children).forEach(e=>{if(e.tagName==="MINT-BUTTON"){const i=e.querySelector("button");if(i){i.classList.remove("justify-start","justify-end"),i.classList.add("justify-center");const s=i.querySelector(".mint-button-content");s&&s.classList.remove("text-left","text-center","text-right","text-justify")}}else e.classList.remove("text-left","text-center","text-right","text-justify")})}}customElements.get("mint-stack")||customElements.define("mint-stack",ut);class pt extends HTMLElement{constructor(){super(),this._headingElement=null}static get observedAttributes(){return["heading"]}connectedCallback(){this.classList.add("box-border","m-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}hasPaddingClass(){return Array.from(this.classList).some(e=>/^p-\d+|^px-|^py-|^pt-|^pb-|^pl-|^pr-/.test(e))}render(){this.classList.add("rounded-lg","shadow","bg-white","dark:bg-gray-900","border","border-gray-200","dark:border-gray-700","overflow-hidden","transition-colors","duration-200","mb-6"),this.hasPaddingClass()||this.classList.add("p-4");const t=this.getHeading();t?(this._headingElement||(this._headingElement=document.createElement("mint-text"),this._headingElement.setAttribute("size","sub-heading"),this.insertBefore(this._headingElement,this.firstChild)),this._headingElement.textContent=t):this._headingElement&&this._headingElement.parentNode&&(this._headingElement.remove(),this._headingElement=null)}}customElements.get("mint-card")||customElements.define("mint-card",pt);class ft extends HTMLElement{constructor(){super(),this._link=null,this._contentObserver=null}static get observedAttributes(){return["href","target"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._observeContent()}disconnectedCallback(){this._contentObserver&&(this._contentObserver.disconnect(),this._contentObserver=null)}_observeContent(){this._contentObserver||(this._contentObserver=new MutationObserver(()=>{this._link&&this._link.querySelectorAll("mint-text").forEach(e=>{e.classList.contains("underline")||e.classList.add("underline")})}),this._contentObserver.observe(this,{childList:!0,subtree:!0}))}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHref(){return this.getAttribute("href")||"#"}getTarget(){return this.getAttribute("target")||""}hasIcon(){var t;return!!(this.querySelector("mint-icon")||(t=this._link)!=null&&t.querySelector("mint-icon"))}render(){const t=this.getHref(),e=this.getTarget();if(!this._link){for(this._link=document.createElement("a");this.firstChild;)this._link.appendChild(this.firstChild);this.appendChild(this._link)}this._link.href=t,e?(this._link.target=e,e==="_blank"&&(this._link.rel="noopener noreferrer")):(this._link.removeAttribute("target"),this._link.removeAttribute("rel"));const i=this.hasIcon(),s=["text-slate-800","dark:text-slate-200","underline","hover:text-slate-950","dark:hover:text-slate-100","transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"];i&&s.push("inline-flex","items-center","gap-2"),this._link.className=s.join(" "),this._link.querySelectorAll("mint-text").forEach(a=>{a.classList.contains("underline")||a.classList.add("underline")}),["box-border","m-0","p-0","border-0","align-baseline","inline-block"].forEach(a=>{this.classList.contains(a)||this.classList.add(a)})}}customElements.get("mint-link")||customElements.define("mint-link",ft);class gt extends HTMLElement{constructor(){super(),this._button=null}static get observedAttributes(){return["href","fallback-href"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","flex","items-center","justify-center"),this.render()}disconnectedCallback(){}attributeChangedCallback(t,e,i){e!==i&&this.render()}getFallbackHref(){return this.getAttribute("fallback-href")||this.getAttribute("href")||"/"}_getTargetUrl(){const t=document.referrer,e=window.location.origin;if(t)try{const i=new URL(t);if(i.origin===e)return i.pathname+i.search}catch{}return this.getFallbackHref()}handleClick(t){t.preventDefault(),t.stopPropagation();const e=this._getTargetUrl(),i=document.referrer,s=i&&(()=>{try{return new URL(i).origin===window.location.origin}catch{return!1}})(),n=new CustomEvent("back",{detail:{url:e,isFromReferrer:s,referrer:i||null,fallbackHref:this.getFallbackHref()},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n)}render(){this._button||(this._button=document.createElement("mint-button"),this._button.setAttribute("variant","neutral"),this._button.setAttribute("icon","arrow-left"),this._button.addEventListener("click",t=>this.handleClick(t)),this.appendChild(this._button))}}customElements.get("mint-back-button")||customElements.define("mint-back-button",gt);class mt extends HTMLElement{constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null,this._backButton=null,this._backButtonHandler=null}static get observedAttributes(){return["heading","fallback-href","show-back-button","containered"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render(),this._observeDarkMode(),this._setupBackButtonListener()}attributeChangedCallback(t,e,i){e!==i&&(t==="containered"&&this._applyContainerClasses(),this.render())}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._removeBackButtonListener()}getHeading(){return this.getAttribute("heading")||""}getFallbackHref(){return this.getAttribute("fallback-href")||"/"}shouldShowBackButton(){return this.getAttribute("show-back-button")==="true"}render(){const t=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement("div"),this.appendChild(this._pageContainer)),this._applyContainerClasses(),this._header||(this._header=document.createElement("div"),this._header.className="flex justify-between mb-8",this._pageContainer.appendChild(this._header)),this._titleElement||(this._titleElement=document.createElement("div"),this._titleElement.className="flex gap-4 min-w-0 flex-1",this._header.appendChild(this._titleElement));let e=this._titleElement.querySelector("mint-back-button");if(this.shouldShowBackButton()){e||(e=document.createElement("mint-back-button"),this._titleElement.insertBefore(e,this._titleElement.firstChild));const r=this.getFallbackHref();e.setAttribute("fallback-href",r),this._backButton=e}else e&&(e.remove(),e=null,this._backButton=null);t?(this._headingText?(this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._headingText.previousSibling!==e&&this._titleElement.insertBefore(this._headingText,e.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement("mint-text"),this._headingText.setAttribute("size","heading"),this._headingText.setAttribute("bold","true"),this._headingText.classList.add("truncate","min-w-0"),e&&e.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,e.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=t):this._headingText&&(this._headingText.remove(),this._headingText=null),this._actionsSlot?this._actionsSlot.classList.contains("ml-4")||this._actionsSlot.classList.add("ml-4"):(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="flex gap-2 items-center ml-4",this._actionsSlot.setAttribute("slot","actions"),this._header.appendChild(this._actionsSlot)),Array.from(this.children).filter(r=>r!==this._pageContainer&&r!==this._actionsSlot&&r.getAttribute("slot")==="actions").forEach(r=>{this._actionsSlot&&r.parentElement!==this._actionsSlot&&this._actionsSlot.appendChild(r)}),this._bodySlot||(this._bodySlot=document.createElement("div"),this._pageContainer.appendChild(this._bodySlot)),Array.from(this.children).forEach(r=>{r!==this._pageContainer&&r.getAttribute("slot")!=="actions"&&r!==this._actionsSlot&&r!==this._header&&r!==this._bodySlot&&r!==this._headingText&&r.parentElement!==this._bodySlot&&r.parentElement!==this._pageContainer&&this._bodySlot.appendChild(r)}),this._updateBackgroundColor()}_applyContainerClasses(){if(!this._pageContainer)return;this._pageContainer.classList.add("min-h-screen","p-8","transition-colors","duration-200"),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(){if(!this._pageContainer)return;document.documentElement.classList.contains("dark")?(this._pageContainer.classList.remove("bg-gray-20"),this._pageContainer.classList.add("bg-gray-900")):(this._pageContainer.classList.remove("bg-gray-900"),this._pageContainer.classList.add("bg-gray-20"))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_setupBackButtonListener(){this._backButtonHandler||(this._backButtonHandler=t=>{const e=t.target;if(e&&e.tagName==="MINT-BACK-BUTTON"){t.stopPropagation();const i=new CustomEvent("back",{detail:t.detail,bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(i)}}),this.addEventListener("back",this._backButtonHandler,!0)}_removeBackButtonListener(){this._backButtonHandler&&(this.removeEventListener("back",this._backButtonHandler,!0),this._backButtonHandler=null)}}customElements.get("mint-page")||customElements.define("mint-page",mt);class _t extends HTMLElement{static get observedAttributes(){return["columns","sm","md","lg","xl","gap"]}constructor(){super()}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getColumns(){return this.getAttribute("columns")||"1"}getSm(){return this.getAttribute("sm")}getMd(){return this.getAttribute("md")}getLg(){return this.getAttribute("lg")}getXl(){return this.getAttribute("xl")}getGap(){return"3"}getGridClasses(){const t=["grid"],e=this.getColumns();t.push(`grid-cols-${e}`);const i=this.getSm();i&&t.push(`sm:grid-cols-${i}`);const s=this.getMd();s&&t.push(`md:grid-cols-${s}`);const n=this.getLg();n&&t.push(`lg:grid-cols-${n}`);const r=this.getXl();r&&t.push(`xl:grid-cols-${r}`);const a=this.getGap();return t.push(`gap-${a}`),t}render(){Array.from(this.classList).filter(i=>i.startsWith("grid-cols-")||i.startsWith("sm:grid-cols-")||i.startsWith("md:grid-cols-")||i.startsWith("lg:grid-cols-")||i.startsWith("xl:grid-cols-")||i.startsWith("gap-")).forEach(i=>this.classList.remove(i)),this.classList.contains("grid")||this.classList.add("grid"),this.getGridClasses().forEach(i=>{i&&i!=="grid"&&this.classList.add(i)})}}customElements.get("mint-grid")||customElements.define("mint-grid",_t);class bt extends HTMLElement{constructor(){super(),this._overlay=null,this._modal=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}isOpen(){return this.getAttribute("open")==="true"}open(){this.setAttribute("open","true")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen();if(t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement("div"),this._modal.className="fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50",this.appendChild(this._modal)),i){let h=this._modal.querySelector(".modal-content");h||(h=document.createElement("div"),h.className="modal-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(h)),this._animateEnter()}else this._animateExit();let s=this._modal.querySelector(".modal-content");s||(s=document.createElement("div"),s.className="modal-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform",this._modal.appendChild(s)),this._header||(this._header=document.createElement("div"),this._header.className="flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700",s.appendChild(this._header)),this._headingSlot||(this._headingSlot=document.createElement("div"),this._headingSlot.className="flex-1",this._headingSlot.setAttribute("slot","heading"),this._header.appendChild(this._headingSlot));let n=this._headingSlot.querySelector("mint-text");e?(n||(n=document.createElement("mint-text"),n.setAttribute("size","sub-heading"),n.setAttribute("bold","true"),this._headingSlot.appendChild(n)),n.textContent=e):n&&n.remove(),Array.from(this.children).filter(h=>h!==this._overlay&&h!==this._modal&&h!==this._headingSlot&&h.getAttribute("slot")==="heading").forEach(h=>{this._headingSlot&&h.parentElement!==this._headingSlot&&this._headingSlot.appendChild(h)}),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(h=>h!==this._overlay&&h!==this._modal&&h!==this._bodySlot&&h.getAttribute("slot")==="body").forEach(h=>{this._bodySlot&&h.parentElement!==this._bodySlot&&this._bodySlot.appendChild(h)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700",this._actionsSlot.setAttribute("slot","actions"),s.appendChild(this._actionsSlot));let o=this._actionsSlot.querySelector("mint-stack");o||(o=document.createElement("mint-stack"),o.setAttribute("direction","horizontal"),o.className="justify-end",this._actionsSlot.appendChild(o)),Array.from(this.children).filter(h=>h!==this._overlay&&h!==this._modal&&h!==this._actionsSlot&&h.getAttribute("slot")==="actions").forEach(h=>{Array.from(h.children).forEach(d=>{d.parentElement!==o&&o.appendChild(d)}),h.parentElement&&h.remove()}),Array.from(this.children).forEach(h=>{h!==this._overlay&&h!==this._modal&&h.getAttribute("slot")!=="heading"&&h.getAttribute("slot")!=="body"&&h.getAttribute("slot")!=="actions"&&h!==this._headingSlot&&h!==this._bodySlot&&h!==this._actionsSlot&&h.parentElement!==this._bodySlot&&this._bodySlot.appendChild(h)}),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._modal)return;const t=document.documentElement.classList.contains("dark"),e=this._modal.querySelector(".modal-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-900","border","border-gray-700")):(e.classList.remove("bg-gray-900","border","border-gray-700"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");t&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})}))}_animateExit(){var e;const t=(e=this._modal)==null?void 0:e.querySelector(".modal-content");if(!t){this.classList.add("hidden");return}t.style.transition="all 200ms ease-in",t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.opacity="",t.style.transition=""},200)}}customElements.get("mint-modal")||customElements.define("mint-modal",bt);class vt extends HTMLElement{constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._hoverCloseTimeout=null,this._scrollHandler=null,this._resizeHandler=null}static get observedAttributes(){return["id","direction","open","trigger-id","padding","hover"]}connectedCallback(){const t=this._isInsideModal()?"z-[60]":"z-50";this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","top-0","left-0",t,"pointer-events-none"),this.isOpen()||this.classList.add("hidden"),this.render(),this._setupTrigger(),this._observeDarkMode()}_isInsideModal(){let t=this;for(;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}if(this._triggerElement)for(t=this._triggerElement;t;){if(t.tagName==="MINT-MODAL")return!0;t=t.parentElement}return!1}disconnectedCallback(){this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&this._triggerElement.removeAttribute("active"),this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler),this._clickOutsideHandler=null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}attributeChangedCallback(t,e,i){if(e!==i){if(this.isConnected){const s=this._isInsideModal()?"z-[60]":"z-50";this.classList.remove("z-50","z-[60]"),this.classList.add(s)}this.render(),(t==="trigger-id"||t==="hover")&&this._setupTrigger(),t==="open"&&this.isOpen()&&this._closeOtherPopovers()}}getId(){return this.getAttribute("id")||""}getPadding(){const t=this.getAttribute("padding")||"4";return{0:"p-0","0.5":"p-0.5",1:"p-1","1.5":"p-1.5",2:"p-2","2.5":"p-2.5",3:"p-3","3.5":"p-3.5",4:"p-4",5:"p-5",6:"p-6",8:"p-8",10:"p-10",12:"p-12",16:"p-16",20:"p-20",24:"p-24"}[t]||"p-4"}getDirection(){return this.getAttribute("direction")||"down"}getTriggerId(){return this.getAttribute("trigger-id")||""}isHoverEnabled(){return this.getAttribute("hover")==="true"}isOpen(){return this.getAttribute("open")==="true"}open(){this.setAttribute("open","true")}close(){this.removeAttribute("open")}_setupTrigger(){const t=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener("click",this._triggerClickHandler,!0),this._triggerClickHandler=null),this._removeHoverListeners(),t&&(this._triggerElement=document.getElementById(t),this._triggerElement?(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners()):setTimeout(()=>{this._triggerElement=document.getElementById(t),this._triggerElement&&(this._attachTriggerListener(),this.isHoverEnabled()&&this._attachHoverListeners())},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){const t=this;this._triggerClickHandler=function(e){e.stopImmediatePropagation(),e.preventDefault(),t.getAttribute("open")==="true"?t.removeAttribute("open"):t.setAttribute("open","true")},this._triggerElement.addEventListener("click",this._triggerClickHandler,!0)}}_attachHoverListeners(){if(!this.isHoverEnabled()||!this._triggerElement)return;this._removeHoverListeners();const t=this;this._triggerHoverEnterHandler=function(){t._cancelHoverClose(),t.open()},this._triggerHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._triggerElement.addEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement.addEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&(this._popoverHoverEnterHandler=function(){t._cancelHoverClose()},this._popoverHoverLeaveHandler=function(e){var s;const i=e.relatedTarget;i&&(t.contains(i)||(s=t._triggerElement)!=null&&s.contains(i))||t._scheduleHoverClose()},this._popover.addEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover.addEventListener("mouseleave",this._popoverHoverLeaveHandler))}_removeHoverListeners(){this._triggerElement&&this._triggerHoverEnterHandler&&this._triggerElement.removeEventListener("mouseenter",this._triggerHoverEnterHandler),this._triggerElement&&this._triggerHoverLeaveHandler&&this._triggerElement.removeEventListener("mouseleave",this._triggerHoverLeaveHandler),this._popover&&this._popoverHoverEnterHandler&&this._popover.removeEventListener("mouseenter",this._popoverHoverEnterHandler),this._popover&&this._popoverHoverLeaveHandler&&this._popover.removeEventListener("mouseleave",this._popoverHoverLeaveHandler),this._triggerHoverEnterHandler=null,this._triggerHoverLeaveHandler=null,this._popoverHoverEnterHandler=null,this._popoverHoverLeaveHandler=null,this._cancelHoverClose()}_scheduleHoverClose(){this._cancelHoverClose(),this._hoverCloseTimeout=window.setTimeout(()=>{this._isHovering()||this.close()},120)}_cancelHoverClose(){this._hoverCloseTimeout!==null&&(clearTimeout(this._hoverCloseTimeout),this._hoverCloseTimeout=null)}_isHovering(){const t=this._triggerElement?this._triggerElement.matches(":hover"):!1,e=this._popover?this._popover.matches(":hover"):!1;return t||e}_calculatePosition(){if(!this._triggerElement||!this._popover)return{top:0,left:0,direction:"down"};const t=this._triggerElement.getBoundingClientRect(),e=this._popover.querySelector(".popover-content");if(!e)return{top:0,left:0,direction:"down"};this.classList.contains("hidden")&&(this.classList.remove("hidden"),this._popover.style.visibility="hidden");const s=e.getBoundingClientRect(),n=window.innerWidth,r=window.innerHeight,a=8;let o=this.getDirection(),l=0,c=0;switch(o){case"down":if(l=t.bottom+a,c=t.left+t.width/2-s.width/2,l+s.height>r){const h=t.top-s.height-a;h>=0?(o="up",l=h):(l=Math.max(0,r-s.height-a),l+s.height>r&&(l=0))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"up":if(l=t.top-s.height-a,c=t.left+t.width/2-s.width/2,l<0){const h=t.bottom+a;h+s.height<=r?(o="down",l=h):(l=Math.min(r-s.height-a,r-s.height),l<0&&(l=r-s.height))}c<0&&(c=a),c+s.width>n&&(c=Math.max(a,n-s.width-a),c+s.width>n&&(c=n-s.width));break;case"right":if(l=t.top+t.height/2-s.height/2,c=t.right+a,c+s.width>n){const h=t.left-s.width-a;h>=0?(o="left",c=h):(c=Math.max(0,n-s.width-a),c+s.width>n&&(c=n-s.width))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break;case"left":if(l=t.top+t.height/2-s.height/2,c=t.left-s.width-a,c<0){const h=t.right+a;h+s.width<=n?(o="right",c=h):(c=Math.min(n-s.width-a,n-s.width),c<0&&(c=0))}l<0&&(l=a),l+s.height>r&&(l=Math.max(a,r-s.height-a),l+s.height>r&&(l=r-s.height));break}return{top:l,left:c,direction:o}}render(){const t=this.getId(),e=this.isOpen(),i=this.getPadding();if(t&&(this.id=t),e){if(this.classList.remove("hidden"),this.style.pointerEvents="auto",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.setAttribute("active","true");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),!this._clickOutsideHandler){const r=this;this._clickOutsideHandler=function(a){const o=a.composedPath(),l=o.includes(r);if(!(r._triggerElement&&o.includes(r._triggerElement))&&!l){r.close();return}},setTimeout(()=>{document.addEventListener("click",this._clickOutsideHandler,!1)},100)}}else this.classList.add("hidden"),this.style.pointerEvents="none",this._triggerElement&&this._triggerElement.tagName==="MINT-BUTTON"&&requestAnimationFrame(()=>{this._triggerElement.removeAttribute("active");const r=this._triggerElement;typeof r.render=="function"&&requestAnimationFrame(()=>{r.render()})}),this._clickOutsideHandler&&(document.removeEventListener("click",this._clickOutsideHandler,!1),this._clickOutsideHandler=null);if(this._overlay){const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`}else{this._overlay=document.createElement("div");const r=this._isInsideModal()?"z-[55]":"z-40";this._overlay.className=`fixed inset-0 pointer-events-none ${r}`,this.appendChild(this._overlay)}if(this._popover){const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`}else{this._popover=document.createElement("div");const r=this._isInsideModal()?"z-[60]":"z-50";this._popover.className=`fixed ${r} pointer-events-auto`,this.appendChild(this._popover)}this.isHoverEnabled()&&this._attachHoverListeners();let s=this._popover.querySelector(".popover-content");if(!s)s=document.createElement("div"),s.className=`popover-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 rounded-lg shadow-xl ${i} transition-all duration-200 ease-out transform`,this._popover.appendChild(s);else{const r=s.className.split(" "),a=["p-0","p-0.5","p-1","p-1.5","p-2","p-2.5","p-3","p-3.5","p-4","p-5","p-6","p-8","p-10","p-12","p-16","p-20","p-24"],o=r.filter(l=>!a.includes(l));s.className=[...o,i].join(" ")}Array.from(this.children).forEach(r=>{r!==this._overlay&&r!==this._popover&&r.parentElement===this&&s.appendChild(r)}),e?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(s):(this._popover.style.top="50%",this._popover.style.left="50%",this._popover.style.transform="translate(-50%, -50%)",this._popover.style.visibility="visible",this._popover.style.display="block",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",s.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{s.style.transform="scale(1) translateY(0)",s.style.opacity="1"})}))):!e&&s&&(this._removePositionListeners(),s.style.opacity!=="0"&&s.style.opacity!==""&&(s.style.transition="all 200ms ease-in",s.style.transform="scale(0.97) translateY(10px)",s.style.opacity="0",setTimeout(()=>{s.style.transform="",s.style.opacity="",s.style.transition="",this._popover.style.visibility="",this._popover.style.display=""},200))),this._updateBackgroundColor()}_updateBackgroundColor(){if(!this._popover)return;const t=document.documentElement.classList.contains("dark"),e=this._popover.querySelector(".popover-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-900","border","border-gray-700")):(e.classList.remove("bg-gray-900","border","border-gray-700"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_updatePosition(t){if(!this._triggerElement||!this._popover)return;const e=this._popover.style.visibility!=="hidden";e||(this._popover.style.visibility="hidden",this._popover.style.display="block",this._popover.style.top="0",this._popover.style.left="0"),this._popover.offsetHeight;const i=this._calculatePosition();this._popover.style.top=`${i.top}px`,this._popover.style.left=`${i.left}px`,e||(this._popover.style.visibility="visible",t&&(!t.style.opacity||t.style.opacity==="")&&(t.style.transform="scale(0.97) translateY(10px)",t.style.opacity="0",t.style.transition="all 200ms ease-out",requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform="scale(1) translateY(0)",t.style.opacity="1"})})))}_setupPositionListeners(){if(!this._scrollHandler&&this.isOpen()){const t=this;this._scrollHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("scroll",this._scrollHandler,!0)}if(!this._resizeHandler&&this.isOpen()){const t=this;this._resizeHandler=function(){if(t.isOpen()&&t._popover){const e=t._popover.querySelector(".popover-content");e&&t._updatePosition(e)}},window.addEventListener("resize",this._resizeHandler)}}_removePositionListeners(){this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler,!0),this._scrollHandler=null),this._resizeHandler&&(window.removeEventListener("resize",this._resizeHandler),this._resizeHandler=null)}_closeOtherPopovers(){Array.from(document.querySelectorAll("mint-popover[open]")).forEach(e=>{if(e!==this){const i=e;typeof i.close=="function"?i.close():e.removeAttribute("open")}})}}customElements.get("mint-popover")||customElements.define("mint-popover",vt);class yt extends HTMLElement{constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null,this._changeHandler=null,this._mousedownHandler=null,this._mouseupHandler=null,this._mouseleaveHandler=null,this._touchstartHandler=null,this._touchendHandler=null,this._focusHandler=null,this._blurHandler=null}static get observedAttributes(){return["checked","disabled","label","info","id","name","value","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-flex","items-start","gap-2");const t=this.getAttribute("checked");this._checked=t==="true",this.render()}disconnectedCallback(){this.removeEventListeners()}isLoading(){return this.getAttribute("loading")==="true"}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i==="true",this._checkbox&&(this._checkbox.checked=this._checked)),e!==i){if(t==="error"||t==="error-message"){this._renderErrorState();return}if(t==="loading"){this.render();return}this.render(),t==="checked"&&this._checkbox&&this.updateVisualState()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{t?this.setAttribute("checked","true"):this.setAttribute("checked","false"),this._checked=!!t,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(){const t=this.hasError(),e=["relative","inline-flex","items-center","justify-center","flex-shrink-0","w-5","h-5","rounded","border-2","transition-all","duration-200","outline-none","focus:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500","cursor-pointer","disabled:opacity-40","disabled:cursor-not-allowed"],i=this._checked?["bg-slate-800","dark:bg-slate-600",t?"border-red-300 dark:border-red-300":"border-slate-800 dark:border-slate-600"]:["bg-white","dark:bg-gray-700",t?"border-red-300 dark:border-red-300":"border-gray-300 dark:border-gray-500"];return[...e,...i].join(" ")}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.isDisabled();let n=this.querySelector(".mint-checkbox-container");n||(n=document.createElement("div"),n.className="mint-checkbox-container relative inline-flex items-start gap-2",this.insertBefore(n,this.firstChild));let r=this.querySelector(".mint-checkbox-wrapper");r?r.parentElement!==n&&n.appendChild(r):(r=document.createElement("div"),r.className="mint-checkbox-wrapper",n.appendChild(r)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement("input"),this._checkbox.type="checkbox",r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className="absolute inset-0 w-full h-full opacity-0 cursor-pointer",this._checkbox.style.cssText="position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;",this._checkbox.checked=this._checked,this._checkbox.disabled=s,this._changeHandler||this.setupEventListeners();const a=this.getId();a?this._checkbox.id=a:this._checkbox.removeAttribute("id");const o=this.getName();o?this._checkbox.name=o:this._checkbox.removeAttribute("name");const l=this.getValue();l?this._checkbox.value=l:this._checkbox.removeAttribute("value"),e?this._checkbox.setAttribute("aria-label",e):this._checkbox.removeAttribute("aria-label"),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.cursor="pointer",r.style.pointerEvents="auto",this._checkbox.style.pointerEvents="auto";const c=r;c._wrapperClickHandler||(c._wrapperClickHandler=u=>{u.target===r&&!s&&(u.preventDefault(),u.stopPropagation(),this.toggle())},r.addEventListener("click",c._wrapperClickHandler));let h=r.querySelector("mint-icon");h||(h=document.createElement("mint-icon"),h.setAttribute("name","check"),h.className="w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto",h.style.transition="opacity 200ms ease-out, transform 200ms ease-out",h.style.zIndex="1",r.appendChild(h)),this.updateVisualState();let p=this.querySelector(".mint-checkbox-label-container");const d=this.querySelector(".mint-checkbox-container");if(e||i){p?d&&p.parentElement!==d&&d.appendChild(p):(p=document.createElement("div"),p.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",d?d.appendChild(p):this.appendChild(p));let u=p.querySelector(".mint-checkbox-label");e?(u||(u=document.createElement("span"),u.className="mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none",p.insertBefore(u,p.firstChild)),u.textContent=e,s?u.classList.add("opacity-40"):u.classList.remove("opacity-40")):u&&u.remove();let m=p.querySelector(".mint-checkbox-info");if(i?(m||(m=document.createElement("span"),m.className="mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none",p.appendChild(m)),m.textContent=i,s?m.classList.add("opacity-40"):m.classList.remove("opacity-40")):m&&m.remove(),s)p.style.cursor="default",p._clickHandler&&(p.removeEventListener("click",p._clickHandler),p._clickHandler=null);else{p.style.cursor="pointer";const f=p._clickHandler;f&&p.removeEventListener("click",f),p._clickHandler=g=>{this._checkbox&&(g.target===this._checkbox||this._checkbox.contains(g.target)||g.composedPath().includes(this._checkbox))||this.toggle()},p.addEventListener("click",p._clickHandler)}}else p&&p.remove();this._renderErrorState(),this._renderSkeleton(t)}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=t=>{t.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.setAttribute("checked","true"):this.setAttribute("checked","false"),this.updateVisualState();const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0}));const i=new CustomEvent("change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(i)},this._checkbox.addEventListener("change",this._changeHandler),this._mousedownHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._mouseupHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._mouseleaveHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("mousedown",this._mousedownHandler),this._checkbox.addEventListener("mouseup",this._mouseupHandler),this._checkbox.addEventListener("mouseleave",this._mouseleaveHandler),this._focusHandler=t=>{const e=this.querySelector(".mint-checkbox-wrapper");e&&this._checkbox&&requestAnimationFrame(()=>{this._checkbox&&this._checkbox.matches(":focus-visible")&&(e==null||e.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{const t=this.querySelector(".mint-checkbox-wrapper");t&&t.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._checkbox.addEventListener("focus",this._focusHandler),this._checkbox.addEventListener("blur",this._blurHandler),this._touchstartHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&!this.isDisabled()&&(e.classList.add("mint-checkbox-active"),this._checked?(e.style.backgroundColor="rgb(15 23 42)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.3)"):(e.style.backgroundColor="rgb(243 244 246)",e.style.boxShadow="inset 0 2px 4px rgba(0, 0, 0, 0.1)"),document.documentElement.classList.contains("dark")&&(this._checked?e.style.backgroundColor="rgb(51 65 85)":e.style.backgroundColor="rgb(31 41 55)"))},this._touchendHandler=t=>{t.stopPropagation();const e=this.querySelector(".mint-checkbox-wrapper");e&&(e.classList.remove("mint-checkbox-active"),e.style.backgroundColor="",e.style.boxShadow="")},this._checkbox.addEventListener("touchstart",this._touchstartHandler),this._checkbox.addEventListener("touchend",this._touchendHandler))}removeEventListeners(){this._checkbox&&(this._changeHandler&&(this._checkbox.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._mousedownHandler&&(this._checkbox.removeEventListener("mousedown",this._mousedownHandler),this._mousedownHandler=null),this._mouseupHandler&&(this._checkbox.removeEventListener("mouseup",this._mouseupHandler),this._mouseupHandler=null),this._mouseleaveHandler&&(this._checkbox.removeEventListener("mouseleave",this._mouseleaveHandler),this._mouseleaveHandler=null),this._touchstartHandler&&(this._checkbox.removeEventListener("touchstart",this._touchstartHandler),this._touchstartHandler=null),this._touchendHandler&&(this._checkbox.removeEventListener("touchend",this._touchendHandler),this._touchendHandler=null),this._focusHandler&&(this._checkbox.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._checkbox.removeEventListener("blur",this._blurHandler),this._blurHandler=null));const t=this.querySelector(".mint-checkbox-wrapper");if(t){const e=t;e._wrapperClickHandler&&(t.removeEventListener("click",e._wrapperClickHandler),e._wrapperClickHandler=null)}}updateVisualState(){const t=this.querySelector(".mint-checkbox-wrapper"),e=t==null?void 0:t.querySelector("mint-icon");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"scale(1)":"scale(0.8)"),t&&(t.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,t.classList.contains("mint-checkbox-active")||(t.style.backgroundColor="",t.style.boxShadow=""))}toggle(){if(this._checkbox&&!this.isDisabled()){this._checkbox.checked=!this._checked,this._checked=this._checkbox.checked,this._checked?this.setAttribute("checked","true"):this.setAttribute("checked","false"),this.updateVisualState(),this.dispatchEvent(new CustomEvent("input",{detail:{checked:this._checked},bubbles:!0,cancelable:!0,composed:!0}));const t=new CustomEvent("change",{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}_renderSkeleton(t){let e=this.querySelector(".mint-checkbox-skeleton-container");const i=this.querySelector(".mint-checkbox-container"),s=this.querySelector(".mint-checkbox-wrapper"),n=this.querySelector(".mint-checkbox-label-container");if(t){e||(e=document.createElement("div"),e.className="mint-checkbox-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e)));let r=e.querySelector(".mint-checkbox-skeleton-box");if(r||(r=document.createElement("div"),r.className="mint-checkbox-skeleton-box flex-shrink-0 w-5 h-5 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(r)),n){let a=e.querySelector(".mint-checkbox-skeleton-label");a||(a=document.createElement("div"),a.className="mint-checkbox-skeleton-label h-4 w-24 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(a))}e.style.display="flex",s&&(s.style.visibility="hidden",s.style.pointerEvents="none"),n&&(n.style.visibility="hidden",n.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.visibility="visible",s.style.pointerEvents="auto"),n&&(n.style.visibility="visible",n.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-checkbox-label-container");!i&&t&&e&&(i=document.createElement("div"),i.className="mint-checkbox-label-container flex flex-col gap-0.5 flex-1",this.appendChild(i));let s=this.querySelector(".mint-checkbox-error");t&&e?(s?(s.classList.add("block","w-full"),s.style.display="block",(i&&s.parentElement!==i||i&&s.parentElement===i)&&i.appendChild(s)):(s=document.createElement("div"),s.className="mint-checkbox-error text-xs text-red-600 dark:text-red-400 block w-full",s.style.display="block",i?i.appendChild(s):this.appendChild(s)),s.textContent=e):s&&s.remove();const n=this.querySelector(".mint-checkbox-wrapper");n&&(n.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`)}}customElements.get("mint-checkbox")||customElements.define("mint-checkbox",yt);class Vt extends HTMLElement{constructor(){super(),this._radio=null,this._checked=!1,this._changeHandler=null,this._clickHandler=null,this._focusHandler=null,this._blurHandler=null,this._keydownHandler=null}static get observedAttributes(){return["value","checked","disabled","loading","info"]}connectedCallback(){this.classList.add("inline-flex","items-start","gap-2","cursor-pointer","select-none");const t=this.getAttribute("checked");this._checked=t!==null&&t!=="false",this.render(),this._setupClickHandler()}disconnectedCallback(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._radio&&(this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._focusHandler&&(this._radio.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._radio.removeEventListener("blur",this._blurHandler),this._blurHandler=null),this._keydownHandler&&(this._radio.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null))}isLoading(){return this.getAttribute("loading")==="true"}attributeChangedCallback(t,e,i){if(t==="checked"&&(this._checked=i==="true",this._radio&&(this._radio.checked=this._checked),this._updateVisualState()),e!==i){if(t==="loading"){this.render();return}if(t==="info"){this.render();return}this.render()}}get checked(){try{return this._checked||!1}catch{return!1}}set checked(t){try{this._checked=!!t,t?this.setAttribute("checked","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(){const e=this.getAttribute("disabled")==="true",i=this.closest("mint-choice"),n=(i==null?void 0:i.getAttribute("disabled"))==="true";return e||n}_setupClickHandler(){this._clickHandler||(this._clickHandler=t=>{t.target!==this._radio&&(this.isDisabled()||this._radio&&(this._radio.click(),requestAnimationFrame(()=>{if(this._radio&&this._radio.checked!==this._checked){this._checked=this._radio.checked,this._checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const e=this.closest("mint-choice");e&&e.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))}})))},this.addEventListener("click",this._clickHandler))}render(){var m;const t=this.isLoading(),e=this.isDisabled(),i=this.getValue(),s=this.closest("mint-choice"),n=(s==null?void 0:s.getAttribute("name"))||"";let r="";const a=this.querySelector(".mint-choice-option-label");if(a)r=((m=a.textContent)==null?void 0:m.trim())||"";else{const f=this.querySelector(".mint-choice-option-label-container");Array.from(this.childNodes).forEach(g=>{var _;if(g!==f&&g.nodeType===Node.TEXT_NODE){const b=(_=g.textContent)==null?void 0:_.trim();b&&(r+=b)}})}const o=this.querySelectorAll(".mint-choice-option-wrapper");let l=null;if(o.length>0&&(this._radio&&(l=Array.from(o).find(f=>f.contains(this._radio))),l||(l=o[0]),o.forEach((f,g)=>{f!==l&&f.remove()})),l||(l=document.createElement("div"),l.className="mint-choice-option-wrapper",l.style.position="relative",this.insertBefore(l,this.firstChild)),l.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`,l.style.position="relative",this.querySelectorAll('input[type="radio"]').forEach(f=>{f!==this._radio&&f.remove()}),this._radio)this._radio.parentElement!==l&&l.appendChild(this._radio),this._radio&&this._changeHandler&&(this._radio.removeEventListener("change",this._changeHandler),this._radio.addEventListener("change",this._changeHandler)),this._radio&&(this._focusHandler||(this._focusHandler=f=>{const g=this.querySelector(".mint-choice-option-wrapper");g&&!this.isDisabled()&&g.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._blurHandler||(this._blurHandler=()=>{const f=this.querySelector(".mint-choice-option-wrapper");f&&f.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")}),this._keydownHandler||(this._keydownHandler=f=>{this.isDisabled()||(f.key==="ArrowDown"||f.key==="ArrowRight"?(f.preventDefault(),this._focusNextOption()):(f.key==="ArrowUp"||f.key==="ArrowLeft")&&(f.preventDefault(),this._focusPreviousOption()))}),this._radio.removeEventListener("focus",this._focusHandler),this._radio.removeEventListener("blur",this._blurHandler),this._radio.removeEventListener("keydown",this._keydownHandler),this._radio.addEventListener("focus",this._focusHandler),this._radio.addEventListener("blur",this._blurHandler),this._radio.addEventListener("keydown",this._keydownHandler));else{this._radio=document.createElement("input"),this._radio.type="radio",this._radio.className="sr-only",this._radio.style.position="absolute",this._radio.style.width="1px",this._radio.style.height="1px",this._radio.style.padding="0",this._radio.style.margin="-1px",this._radio.style.overflow="hidden",this._radio.style.clip="rect(0, 0, 0, 0)",this._radio.style.whiteSpace="nowrap",this._radio.style.border="0",l.appendChild(this._radio),this._changeHandler=g=>{const _=this._checked;this._checked=this._radio.checked,this._checked?this.setAttribute("checked","true"):this.removeAttribute("checked"),this._updateVisualState(),this._updateGroupState();const b=this.closest("mint-choice");_!==this._checked&&b&&setTimeout(()=>{b.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0}))},0)},this._radio.addEventListener("change",this._changeHandler);const f=()=>{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._radio.addEventListener("click",f),this._focusHandler=g=>{const _=this.querySelector(".mint-choice-option-wrapper");_&&!this.isDisabled()&&_.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("focus",this._focusHandler),this._blurHandler=()=>{const g=this.querySelector(".mint-choice-option-wrapper");g&&g.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._radio.addEventListener("blur",this._blurHandler),this._keydownHandler=g=>{this.isDisabled()||(g.key==="ArrowDown"||g.key==="ArrowRight"?(g.preventDefault(),this._focusNextOption()):(g.key==="ArrowUp"||g.key==="ArrowLeft")&&(g.preventDefault(),this._focusPreviousOption()))},this._radio.addEventListener("keydown",this._keydownHandler)}this._radio.name=n,this._radio.value=i,this._radio.checked!==this._checked?(this._checked=this._radio.checked,this._checked?this.setAttribute("checked","true"):this.setAttribute("checked","false")):this._radio.checked=this._checked,this._radio.disabled=e,e?this._radio.setAttribute("tabindex","-1"):this._radio.removeAttribute("tabindex"),r?this._radio.setAttribute("aria-label",r):this._radio.removeAttribute("aria-label"),l.querySelectorAll(".mint-choice-option-indicator").forEach((f,g)=>{g>0&&f.remove()});let p=l.querySelector(".mint-choice-option-indicator");p||(p=document.createElement("div"),p.className="mint-choice-option-indicator",l.appendChild(p)),p.className="mint-choice-option-indicator w-2 h-2 rounded-full bg-white transition-all duration-200 pointer-events-none",p.style.position="absolute",p.style.top="50%",p.style.left="50%",p.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)",p.style.opacity=this._checked?"1":"0",this._updateVisualState(),this._renderSkeleton(t);const d=this.getInfo();let u=this.querySelector(".mint-choice-option-label-container");if(r||d){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(_=>{var b;_.nodeType===Node.TEXT_NODE&&((b=_.textContent)!=null&&b.trim())&&_!==u&&(_.textContent="")}));let f=u.querySelector(".mint-choice-option-label");r?(f||(f=document.createElement("span"),f.className="mint-choice-option-label",u.appendChild(f)),f.className=`mint-choice-option-label text-sm text-gray-900 dark:text-gray-100 ${e?"opacity-40":""}`,f.textContent=r):f&&f.remove();let g=u.querySelector(".mint-choice-option-info");d?(g||(g=document.createElement("span"),g.className="mint-choice-option-info text-xs text-gray-500 dark:text-gray-400 select-none",u.appendChild(g)),g.textContent=d,e?g.classList.add("opacity-40"):g.classList.remove("opacity-40")):g&&g.remove()}else u&&u.remove();e?(this.classList.add("cursor-not-allowed"),this.classList.remove("cursor-pointer")):(this.classList.add("cursor-pointer"),this.classList.remove("cursor-not-allowed")),this._updateVisualState()}_getWrapperClasses(){const t=this.isDisabled(),e=["inline-flex","items-center","justify-center","w-[1rem]","h-[1rem]","rounded-full","border-2","transition-all","duration-200","flex-shrink-0","mt-0.5"];return t&&e.push("opacity-40","cursor-not-allowed"),this._checked?e.push("bg-slate-800","dark:bg-slate-600","border-slate-800","dark:border-slate-600"):e.push("bg-white","dark:bg-gray-900","border-gray-300","dark:border-gray-500"),e.join(" ")}_updateVisualState(){const t=this.querySelector(".mint-choice-option-wrapper");t&&(t.className=`mint-choice-option-wrapper ${this._getWrapperClasses()}`);const e=this.querySelector(".mint-choice-option-indicator");e&&(e.style.opacity=this._checked?"1":"0",e.style.transform=this._checked?"translate(-50%, -50%) scale(1)":"translate(-50%, -50%) scale(0)")}_renderSkeleton(t){let e=this.querySelector(".mint-choice-option-skeleton-container");const i=this.querySelector(".mint-choice-option-wrapper");if(t){e||(e=document.createElement("div"),e.className="mint-choice-option-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center gap-2",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-choice-option-skeleton-radio");if(s||(s=document.createElement("div"),s.className="mint-choice-option-skeleton-radio flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="hidden"),r&&(r.style.visibility="hidden"),i.style.pointerEvents="none"}}else{if(e&&(e.style.display="none"),i){const n=i.querySelector('input[type="radio"]'),r=i.querySelector(".mint-choice-option-indicator");n&&(n.style.visibility="visible"),r&&(r.style.visibility="visible"),i.style.pointerEvents="auto"}const s=this.querySelector(".mint-choice-option-label");s&&!(i!=null&&i.contains(s))&&(s.style.visibility="visible",s.style.pointerEvents="auto")}}_updateGroupState(){var e;if(!((e=this._radio)!=null&&e.name))return;document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`).forEach(i=>{if(i===this._radio)return;const s=i.closest("mint-choice-option");s&&s!==this&&(s._checked=i.checked,i.checked?s.setAttribute("checked","true"):s.removeAttribute("checked"),s._updateVisualState())})}_focusNextOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>=0&&e<t.length-1?i=t[e+1]:t.length>0&&(i=t[0]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked","true"),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}_focusPreviousOption(){var s;if(!((s=this._radio)!=null&&s.name))return;const t=Array.from(document.querySelectorAll(`input[type="radio"][name="${this._radio.name}"]`)).filter(n=>!n.disabled),e=t.indexOf(this._radio);let i=null;if(e>0?i=t[e-1]:t.length>0&&(i=t[t.length-1]),i){const n=i.closest("mint-choice-option");if(i.checked=!0,n){const r=n._checked;if(n._checked=!0,n.setAttribute("checked","true"),n._changeHandler){const o=new Event("change",{bubbles:!0});n._changeHandler.call(n,o)}else n._updateVisualState(),n._updateGroupState();const a=n.closest("mint-choice");a&&!r&&setTimeout(()=>{a.dispatchEvent(new CustomEvent("choice-change",{detail:{checked:!0,value:n.getValue()},bubbles:!0,cancelable:!0}))},0)}i.focus(),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}customElements.get("mint-choice-option")||customElements.define("mint-choice-option",Vt);class kt extends HTMLElement{constructor(){super(),this._optionsContainer=null}static get observedAttributes(){return["label","name","info","error","error-message","id","disabled","required","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","block","w-full"),this.render(),this.addEventListener("choice-change",t=>{var r;const i=((r=t.detail)==null?void 0:r.value)||this.getValue();(this.getAttribute("value")||"")!==i&&(i?this.setAttribute("value",i):this.removeAttribute("value"));const n=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(n),this.dispatchEvent(new CustomEvent("input",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:i},bubbles:!0,cancelable:!0,composed:!0}))})}disconnectedCallback(){}isLoading(){return this.hasAttribute("loading")}attributeChangedCallback(t,e,i){e!==i&&(t==="error"||t==="error-message"?this._renderErrorState():t==="loading"?(this.render(),this.querySelectorAll("mint-choice-option").forEach(n=>{this.isLoading()?n.setAttribute("loading","true"):n.removeAttribute("loading")})):(this.render(),t==="name"&&this.querySelectorAll("mint-choice-option").forEach(n=>{typeof n.render=="function"&&n.render()})))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}getName(){return this.getAttribute("name")||""}hasError(){return this.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(){const t=this.querySelector('input[type="radio"]:checked');return(t==null?void 0:t.value)||""}setValue(t){const e=this.querySelectorAll("mint-choice-option");e.forEach(i=>{if((i.getAttribute("value")||"")===t){const n=i;n.checked=!0;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!0,r.dispatchEvent(new Event("change",{bubbles:!0})))}else{const n=i;n.checked=!1;const r=i.querySelector('input[type="radio"]');r&&(r.checked=!1)}}),requestAnimationFrame(()=>{e.forEach(i=>{typeof i._updateVisualState=="function"&&i._updateVisualState();const s=i.querySelector('input[type="radio"]');if(s){const n=i;s.checked!==n.checked&&(s.checked=n.checked)}})})}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getId()||`mint-choice-${Math.random().toString(36).substr(2,9)}`;this.getId()||this.setAttribute("id",s);const n=this.isDisabled();let r=this.querySelector(".mint-choice-label-container");if(e||i){r||(r=document.createElement("div"),r.className="mint-choice-label-container flex flex-col gap-0.5 mb-2",this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-choice-label");e?(l||(l=document.createElement("label"),l.className="mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.insertBefore(l,r.firstChild)),l.textContent=e,l.setAttribute("for",s),n?l.classList.add("opacity-40"):l.classList.remove("opacity-40")):l&&l.remove();let c=r.querySelector(".mint-choice-info");i?(c||(c=document.createElement("span"),c.className="mint-choice-info text-xs text-gray-500 dark:text-gray-400 select-none",r.appendChild(c)),c.textContent=i,n?c.classList.add("opacity-40"):c.classList.remove("opacity-40")):c&&c.remove()}else r&&r.remove();let a=this.querySelector(".mint-choice-options-wrapper");if(!a){a=document.createElement("div"),a.className="mint-choice-options-wrapper relative";const l=this.querySelector(".mint-choice-label-container");l&&l.parentElement===this?this.insertBefore(a,l.nextSibling):this.insertBefore(a,this.firstChild)}this._optionsContainer?this._optionsContainer.parentElement!==a&&a.appendChild(this._optionsContainer):(this._optionsContainer=document.createElement("div"),this._optionsContainer.className="mint-choice-options-container flex flex-col gap-3",a.appendChild(this._optionsContainer)),Array.from(this.children).filter(l=>l.tagName==="MINT-CHOICE-OPTION"&&l.parentElement!==this._optionsContainer).forEach(l=>{this._optionsContainer.appendChild(l)}),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-choice-skeleton-container");const i=this.querySelector(".mint-choice-options-wrapper"),s=this.querySelector(".mint-choice-options-container");if(t){if(e||(e=document.createElement("div"),e.className="mint-choice-skeleton-container absolute inset-0 z-10 pointer-events-none flex flex-col gap-3",i?i.appendChild(e):(this.style.position="relative",this.appendChild(e))),e.querySelectorAll(".mint-choice-option-skeleton").length===0)for(let r=0;r<3;r++){const a=document.createElement("div");a.className="mint-choice-option-skeleton flex items-center gap-3";const o=document.createElement("div");o.className="flex-shrink-0 w-5 h-5 rounded-full bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(o);const l=document.createElement("div");l.className="h-4 w-20 rounded bg-gray-200 dark:bg-gray-700 animate-pulse",a.appendChild(l),e.appendChild(a)}e.style.display="flex",s&&(s.style.opacity="0",s.style.pointerEvents="none")}else e&&(e.style.display="none"),s&&(s.style.opacity="1",s.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-choice-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-choice-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-choice")||customElements.define("mint-choice",kt);class xt extends HTMLElement{constructor(){super(),this._input=null,this._textarea=null,this._element=null,this._wrapper=null,this._icon=null,this._colorPicker=null,this._colorTextInput=null,this._colorContainer=null,this._colorPickerWrapper=null,this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null,this._focusHandler=null,this._blurHandler=null,this._clickHandler=null,this._clickOutsideHandler=null}static get observedAttributes(){return["type","placeholder","value","disabled","id","name","required","readonly","rows","icon","label","info","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._element&&(this._element.className=this.getInputClasses()),this._colorTextInput&&(this._colorTextInput.className=this.getInputClasses());return}if(t==="loading"){this.render();return}this.render()}}getType(){return this.getAttribute("type")||"text"}getRows(){const t=this.getAttribute("rows");return t?parseInt(t,10):3}_getNormalizedType(){const t=this.getType();return t==="datetime"?"datetime-local":t==="money"?"text":t==="textarea"?"textarea":t}_isTextarea(){return this.getType()==="textarea"}_isMoney(){return this.getType()==="money"}_isColor(){return this.getType()==="color"}_isNumber(){return this.getType()==="number"}getPlaceholder(){return this.getAttribute("placeholder")||""}getValue(){var t,e,i;return this._isColor()?((t=this._colorPicker)==null?void 0:t.value)||((e=this._colorTextInput)==null?void 0:e.value)||this.getAttribute("value")||"#000000":((i=this._element)==null?void 0:i.value)||this.getAttribute("value")||""}set value(t){try{this._isColor()?(this._colorPicker&&(this._colorPicker.value=t||"#000000"),this._colorTextInput&&(this._colorTextInput.value=t||"#000000")):this._element&&(this._element.value=t),t?this.setAttribute("value",t):this.removeAttribute("value")}catch{}}get value(){try{return this.getValue()||""}catch{return""}}isDisabled(){return this.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(){const t=this._isTextarea(),e=!!this.getIcon(),i=this._isColor(),s=this._isNumber(),n=this.hasError(),r=["w-full",e||i?"pl-10":"px-3.5",e||i?"pr-3.5":s?"pr-10":"",t?"py-2":"py-1.5",t?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-900","text-gray-900","dark:text-white",t?"transition-colors transition-opacity":"transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","readonly:cursor-default",t?"resize-y":"",s?"[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none":""],a=["border-2",n?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700"],o=["focus-visible:ring-2","focus-visible:ring-offset-1",n?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...r,...a,...o].filter(Boolean).join(" ")}isLoading(){return this.getAttribute("loading")==="true"}render(){var b,v,y,x,D;this.getType();const t=this._getNormalizedType(),e=this._isTextarea(),i=this._isMoney(),s=this._isColor(),n=this.getPlaceholder(),r=this.isDisabled(),a=this.isReadonly(),o=this.isRequired(),l=this.getId(),c=this.getName(),h=this.getAttribute("value")||(s?"#000000":""),p=this.getRows(),d=this.getIcon(),u=this.getLabel(),m=this.getInfo(),f=this.isLoading();if(this._renderSkeleton(f),s){this._input&&(this._input.remove(),this._input=null),this._textarea&&(this._textarea.remove(),this._textarea=null),this._wrapper||(this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper)),this._colorContainer&&(this._colorContainer.remove(),this._colorContainer=null),this._colorPickerWrapper&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null),this._colorPickerWrapper||(this._colorPickerWrapper=document.createElement("div"),this._colorPickerWrapper.className="mint-color-picker-wrapper absolute left-[.65rem] top-1/2 -translate-y-1/2 w-6 h-6 rounded cursor-pointer disabled:opacity-40 disabled:cursor-not-allowed outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",this._colorPickerWrapper.style.backgroundColor=h||"#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=k=>{this._colorPickerWrapper&&this._colorPicker&&this._colorPicker.matches(":focus-visible")&&requestAnimationFrame(()=>{var C;this._colorPicker&&this._colorPicker.matches(":focus-visible")&&((C=this._colorPickerWrapper)==null||C.classList.add("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500"))})},this._blurHandler=()=>{this._colorPickerWrapper&&this._colorPickerWrapper.classList.remove("ring-2","ring-offset-1","ring-gray-400","dark:ring-gray-500")},this._colorPicker.addEventListener("focus",this._focusHandler),this._colorPicker.addEventListener("blur",this._blurHandler),this._colorPicker.addEventListener("input",()=>{var C;const k=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=k),this._colorTextInput&&(this._colorTextInput.value=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("input",{detail:{value:k},bubbles:!0,cancelable:!0}))}),this._colorPicker.addEventListener("change",()=>{var C;const k=((C=this._colorPicker)==null?void 0:C.value)||"#000000";this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("change",{detail:{value:k},bubbles:!0,cancelable:!0}))})),this._colorTextInput||(this._colorTextInput=document.createElement("input"),this._colorTextInput.type="text",this._colorTextInput.className=this.getInputClasses(),this._colorTextInput.placeholder=n||"#000000",this._colorTextInput.pattern="^#[0-9A-Fa-f]{6}$",this._wrapper.appendChild(this._colorTextInput),this._colorTextInput.addEventListener("input",()=>{var C;const k=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(k)&&(this._colorPicker&&(this._colorPicker.value=k),this.setAttribute("value",k),this.dispatchEvent(new CustomEvent("input",{detail:{value:k},bubbles:!0,cancelable:!0})))}),this._colorTextInput.addEventListener("blur",()=>{var C,A;const k=((C=this._colorTextInput)==null?void 0:C.value)||"";/^#[0-9A-Fa-f]{6}$/.test(k)?(this._colorPicker&&(this._colorPicker.value=k),this.setAttribute("value",k)):this._colorPicker&&this._colorTextInput&&(this._colorTextInput.value=this._colorPicker.value),this.dispatchEvent(new CustomEvent("change",{detail:{value:((A=this._colorPicker)==null?void 0:A.value)||"#000000"},bubbles:!0,cancelable:!0}))}));const w=h||"#000000";if(this._colorPicker&&this._colorPicker.value!==w&&(this._colorPicker.value=w),this._colorPickerWrapper&&(this._colorPickerWrapper.style.backgroundColor=w),this._colorTextInput&&this._colorTextInput.value!==w&&(this._colorTextInput.value=w),this._colorPicker&&(this._colorPicker.disabled=r),this._colorPickerWrapper&&(r?(this._colorPickerWrapper.classList.add("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.remove("cursor-pointer")):(this._colorPickerWrapper.classList.remove("opacity-40","cursor-not-allowed"),this._colorPickerWrapper.classList.add("cursor-pointer"))),this._colorTextInput&&(this._colorTextInput.disabled=r,this._colorTextInput.readOnly=a,this._colorTextInput.required=o),this._colorTextInput){const k=this._colorTextInput;l?k.id=l:k.removeAttribute("id"),c?k.name=c:k.removeAttribute("name"),k.setAttribute("aria-invalid",this.hasError()?"true":"false"),this._element=k}this._renderErrorState();let S=this.querySelector(".mint-input-label-container");if(u||m){S||(S=document.createElement("div"),S.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(S,this._wrapper):this.insertBefore(S,this.firstChild));let k=S.querySelector(".mint-input-label");if(u){k||(k=document.createElement("label"),k.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",S.insertBefore(k,S.firstChild)),k.textContent=u;const A=l||((b=this._colorTextInput)==null?void 0:b.id);if(A)k.setAttribute("for",A);else{const M=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._colorTextInput&&(this._colorTextInput.id=M),k.setAttribute("for",M)}r?k.classList.add("opacity-40"):k.classList.remove("opacity-40")}else k&&k.remove();let C=S.querySelector(".mint-input-info");m?(C||(C=document.createElement("span"),C.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",S.appendChild(C)),C.textContent=m,r?C.classList.add("opacity-40"):C.classList.remove("opacity-40")):C&&C.remove()}else S&&S.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&&!s&&(this._colorPickerWrapper.remove(),this._colorPickerWrapper=null,this._colorPicker=null,this._colorTextInput=null),d&&!e?this._icon?this._icon.setAttribute("name",d):(this._icon=document.createElement("mint-icon"),this._icon.setAttribute("name",d),this._icon.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",this._wrapper.appendChild(this._icon)):this._icon&&(this._icon.remove(),this._icon=null),this._isNumber()&&!e){if(!this._numberSpinnerContainer){this._numberSpinnerContainer=document.createElement("div"),this._numberSpinnerContainer.className="absolute right-1 top-1/2 -translate-y-1/2 flex flex-col h-8 pointer-events-none",this._wrapper.appendChild(this._numberSpinnerContainer),this._numberIncrementButton=document.createElement("button"),this._numberIncrementButton.type="button",this._numberIncrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const w=document.createElement("mint-icon");w.setAttribute("name","caret-up"),w.className="w-[1rem] h-[1rem]",this._numberIncrementButton.appendChild(w),this._numberSpinnerContainer.appendChild(this._numberIncrementButton),this._numberDecrementButton=document.createElement("button"),this._numberDecrementButton.type="button",this._numberDecrementButton.className="flex items-center justify-center w-5 h-4 text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-40 disabled:cursor-not-allowed transition-colors pointer-events-auto bg-gray-100 dark:bg-gray-600 active:bg-gray-200 dark:active:bg-gray-500 rounded";const S=document.createElement("mint-icon");S.setAttribute("name","caret-down"),S.className="w-[1rem] h-[1rem]",this._numberDecrementButton.appendChild(S),this._numberSpinnerContainer.appendChild(this._numberDecrementButton),this._numberIncrementButton.addEventListener("click",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const C=parseFloat(this._input.value)||0,A=parseFloat(this._input.step)||1,M=this._input.min?parseFloat(this._input.min):void 0,T=this._input.max?parseFloat(this._input.max):void 0;let L=C+A;T!==void 0&&L>T&&(L=T),M!==void 0&&L<M&&(L=M),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}}),this._numberDecrementButton.addEventListener("click",k=>{if(k.preventDefault(),k.stopPropagation(),this._input&&!this._input.disabled&&!this._input.readOnly){const C=parseFloat(this._input.value)||0,A=parseFloat(this._input.step)||1,M=this._input.min?parseFloat(this._input.min):void 0,T=this._input.max?parseFloat(this._input.max):void 0;let L=C-A;M!==void 0&&L<M&&(L=M),T!==void 0&&L>T&&(L=T),this._input.value=L.toString(),this.setAttribute("value",L.toString()),this._input.dispatchEvent(new Event("input",{bubbles:!0})),this._input.dispatchEvent(new Event("change",{bubbles:!0}))}})}this._numberIncrementButton&&(this._numberIncrementButton.disabled=r||a),this._numberDecrementButton&&(this._numberDecrementButton.disabled=r||a)}else this._numberSpinnerContainer&&(this._numberSpinnerContainer.remove(),this._numberSpinnerContainer=null,this._numberIncrementButton=null,this._numberDecrementButton=null);if(e){if(this._input&&(this._input.remove(),this._input=null),this._textarea||(this._textarea=document.createElement("textarea"),this._wrapper.appendChild(this._textarea),this.setupEventListeners()),this._element=this._textarea,this._textarea.placeholder=n,this._textarea.disabled=r,this._textarea.readOnly=a,this._textarea.required=o,this._textarea.rows=p,this._textarea.setAttribute("aria-invalid",this.hasError()?"true":"false"),h!==this._textarea.value&&(this._textarea.value=h),l?this._textarea.id=l:this._textarea.removeAttribute("id"),c?this._textarea.name=c:this._textarea.removeAttribute("name"),this._textarea.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const w=this.firstChild.textContent;w&&!this._textarea.value&&(this._textarea.value=w.trim()),this.removeChild(this.firstChild)}}else if(this._textarea&&(this._textarea.remove(),this._textarea=null),this._input||(this._input=document.createElement("input"),this._wrapper.appendChild(this._input),this.setupEventListeners()),this._element=this._input,this._input.type=t,this._input.placeholder=n,this._input.disabled=r,this._input.readOnly=a,this._input.required=o,this._input.setAttribute("aria-invalid",this.hasError()?"true":"false"),i?(this._input.inputMode="decimal",this._input.pattern="[0-9]*\\.?[0-9]*"):(this._input.removeAttribute("inputmode"),this._input.removeAttribute("pattern")),h!==this._input.value&&(this._input.value=h),l?this._input.id=l:this._input.removeAttribute("id"),c?this._input.name=c:this._input.removeAttribute("name"),this._input.className=this.getInputClasses(),this.firstChild&&this.firstChild!==this._wrapper&&this.firstChild.nodeType===Node.TEXT_NODE){const w=this.firstChild.textContent;w&&!this._input.value&&(this._input.value=w.trim()),this.removeChild(this.firstChild)}let _=this.querySelector(".mint-input-label-container");if(u||m){_||(_=document.createElement("div"),_.className="mint-input-label-container flex flex-col gap-0.5 mb-[.25rem]",this._wrapper&&this._wrapper.parentElement===this?this.insertBefore(_,this._wrapper):this.insertBefore(_,this.firstChild));let w=_.querySelector(".mint-input-label");if(u){w||(w=document.createElement("label"),w.className="mint-input-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",_.insertBefore(w,_.firstChild)),w.textContent=u;const k=l||((v=this._element)==null?void 0:v.id)||((y=this._colorTextInput)==null?void 0:y.id)||((x=this._input)==null?void 0:x.id)||((D=this._textarea)==null?void 0:D.id);if(k)w.setAttribute("for",k);else{const C=`mint-input-${Math.random().toString(36).substr(2,9)}`;this._element?this._element.id=C:this._colorTextInput?this._colorTextInput.id=C:this._input?this._input.id=C:this._textarea&&(this._textarea.id=C),w.setAttribute("for",C)}r?w.classList.add("opacity-40"):w.classList.remove("opacity-40")}else w&&w.remove();let S=_.querySelector(".mint-input-info");m?(S||(S=document.createElement("span"),S.className="mint-input-info text-xs text-gray-500 dark:text-gray-400 select-none",_.appendChild(S)),S.textContent=m,r?S.classList.add("opacity-40"):S.classList.remove("opacity-40")):S&&S.remove()}else _&&_.remove();this._renderErrorState(),this._renderSkeleton(f)}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-input-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-input-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}setupEventListeners(){this._element&&(this._element.addEventListener("input",()=>{var i;const t=((i=this._element)==null?void 0:i.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value");const e=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e),this.dispatchEvent(new CustomEvent("input",{detail:{value:t},bubbles:!0,cancelable:!0,composed:!0}))}),this._element.addEventListener("blur",()=>{var e;const t=((e=this._element)==null?void 0:e.value)||"";t?this.setAttribute("value",t):this.removeAttribute("value"),this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,cancelable:!0}))}))}removeEventListeners(){this._colorPicker&&(this._focusHandler&&(this._colorPicker.removeEventListener("focus",this._focusHandler),this._focusHandler=null),this._blurHandler&&(this._colorPicker.removeEventListener("blur",this._blurHandler),this._blurHandler=null))}focus(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.focus():(t=this._element)==null||t.focus()}blur(){var t;this._isColor()&&this._colorTextInput?this._colorTextInput.blur():(t=this._element)==null||t.blur()}_renderSkeleton(t){let e=this.querySelector(".mint-input-skeleton-container");const i=this._wrapper||this.querySelector(".relative.w-full");if(t){e||(e=document.createElement("div"),e.className="mint-input-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-input-skeleton");if(!s){s=document.createElement("div"),s.className="mint-input-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this._isTextarea(),r=this.getRows();if(n){const a=r*24+12;s.style.height=`${a}px`}else s.style.height="2.2rem";e.appendChild(s)}e.style.display="block",this._element&&(this._element.style.opacity="0",this._element.style.pointerEvents="none"),this._colorTextInput&&(this._colorTextInput.style.opacity="0",this._colorTextInput.style.pointerEvents="none")}else e&&(e.style.display="none"),this._element&&(this._element.style.opacity="1",this._element.style.pointerEvents="auto"),this._colorTextInput&&(this._colorTextInput.style.opacity="1",this._colorTextInput.style.pointerEvents="auto")}}customElements.get("mint-input")||customElements.define("mint-input",xt);class Et extends HTMLElement{constructor(){super(),this._input=null,this._textInput=null,this._popover=null,this._calendarContainer=null,this._iconButton=null,this._hiddenInput=null,this._startPartInputs=[],this._endPartInputs=[],this._displayEl=null,this._inputsWrapperEl=null,this._fieldsContainer=null,this._resetHandler=null,this._isInputMode=!1,this._currentMonth=new Date().getMonth(),this._currentYear=new Date().getFullYear(),this._viewMode="calendar",this._selectedStartDate=null,this._selectedEndDate=null,this._isRange=!1,this._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}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"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._setupPopoverWithRetry(),this._attachFormResetListener()}disconnectedCallback(){if(this._popoverObserver&&(this._popoverObserver.disconnect(),this._popoverObserver=null),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._removeFocusTrap(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}isLoading(){return this.getAttribute("loading")==="true"}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){const s=this.hasError(),n=this.getErrorMessage();this._applyErrorVisuals(s,n,this.isDisabled());return}if(t==="loading"){this.render();return}if(t==="mode"||t==="format"){const s=this.getMode();s==="month"?this._viewMode="month":s==="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(t){t?(this.setAttribute("value",t),this._textInput&&(this._textInput.value=t),this._parseValue(t)):(this.removeAttribute("value"),this._textInput&&(this._textInput.value=""),this._selectedStartDate=null,this._selectedEndDate=null),this._buildCalendar(),this._updateDisplayText()}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{this.setValue(t||"")}catch{}}getFormat(){return this.getAttribute("format")||"mm/dd/yyyy"}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}isDisabled(){return this.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(){const t=this.getAttribute("disabled-dates");if(!t)return[];try{const e=JSON.parse(t),i=this.getFormat();return e.map(s=>this._parseDateString(s,i)).filter(s=>s!==null)}catch{return[]}}getDisabledDateStrings(){const t=this.getAttribute("disabled-dates");if(!t)return[];try{return JSON.parse(t)}catch{return[]}}disableDate(t){const e=this.getFormat(),i=this.getDisabledDateStrings(),s=Array.isArray(t)?t:[t],n=[];for(const r of s){const a=this._parseDateString(r,e);if(a){const o=this._formatDate(a,e);i.includes(o)||n.push(o)}}if(n.length>0){const r=[...i,...n];this.setAttribute("disabled-dates",JSON.stringify(r)),this._buildCalendar()}}enableDate(t){const e=this.getFormat(),i=this.getDisabledDateStrings(),s=Array.isArray(t)?t:[t],n=[];for(const r of s){const a=this._parseDateString(r,e);if(a){const o=this._formatDate(a,e);n.push(o)}}if(n.length>0){const r=i.filter(a=>!n.includes(a));r.length===0?this.removeAttribute("disabled-dates"):this.setAttribute("disabled-dates",JSON.stringify(r)),this._buildCalendar()}}getSelectionMode(){const t=this.getAttribute("selection-mode");return t==="week"||t==="month"?t:"day"}getMode(){const t=this.getAttribute("mode");if(t==="month"||t==="year")return t;const e=this.getFormat().toLowerCase(),i=e.includes("d"),s=e.includes("m");return!i&&!s?"year":!i&&s?"month":"default"}getWeekStartDay(){var i;const t=(i=this.getAttribute("week-start-day"))==null?void 0:i.toLowerCase();return{sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6}[t||"sunday"]??0}getDisplayFormat(){return this.getAttribute("display-format")||"F j, Y"}getShortcuts(){const t=this.getAttribute("shortcuts");if(!t)return[];try{const e=JSON.parse(t);if(Array.isArray(e))return e.map(i=>({label:i.label,action:this._createShortcutAction(i.action)}))}catch{const i=t.trim();if(i&&typeof window[i]=="function"){const s=window[i]();if(Array.isArray(s))return s.map(n=>({label:n.label,action:typeof n.action=="function"?n.action:this._createShortcutAction(n.action)}))}}return[]}_createShortcutAction(t){return typeof t=="function"?t:typeof t=="string"&&typeof window[t]=="function"?window[t]:()=>null}_getDefaultShortcuts(){const t=[{label:"Today",action:()=>new Date}];return this._isRange&&t.push({label:"This Week",action:()=>{const e=new Date,i=e.getDay(),s=new Date(e);s.setDate(e.getDate()-i),s.setHours(0,0,0,0);const n=new Date(s);return n.setDate(s.getDate()+6),n.setHours(23,59,59,999),{start:s,end:n}}},{label:"This Month",action:()=>{const e=new Date,i=new Date(e.getFullYear(),e.getMonth(),1),s=new Date(e.getFullYear(),e.getMonth()+1,0);return s.setHours(23,59,59,999),{start:i,end:s}}}),t}_getFormatTokens(t){const e=[];let i=0;const s=t.toLowerCase();for(;i<s.length;){const n=s[i];if(n==="d"||n==="m"||n==="y"){let r=1,a=i+1;for(;a<s.length&&s[a]===n;)r++,a++;e.push({type:"part",part:n,len:r}),i=a}else e.push({type:"sep",value:t[i]}),i++}return e}_createPartInput(t,e,i,s,n){const r=document.createElement("input");return r.type="text",r.inputMode="numeric",r.pattern="\\d*",r.maxLength=t,r.placeholder=e,r.className="bg-transparent border-none outline-none text-center text-sm font-medium p-0 m-0 focus:outline-none focus:ring-0 disabled:opacity-40 disabled:cursor-not-allowed",r.disabled=i||s,r.readOnly=s,r.required=n,t===4?r.className+=" w-[40px]":t===2&&(r.className+=" w-[30px]"),r}_buildValueFromParts(t,e){let i=0;return e.map(s=>{var r;if(s.type==="sep")return s.value;const n=((r=t[i])==null?void 0:r.value)||"";return i++,n}).join("")}_applyDateToParts(t,e,i,s){if(!e.length)return;if(!t){e.forEach(o=>o.value="");return}const n=this._formatDate(t,s);let r=0,a=0;i.forEach(o=>{if(o.type==="sep")r+=o.value.length;else{const l=n.substr(r,o.len);e[a]&&(e[a].value=l),a++,r+=o.len}})}_syncHiddenInput(){if(!this._hiddenInput)return;const t=this.getFormat(),e=this._getFormatTokens(t),i=this._buildValueFromParts(this._startPartInputs,e);if(this._isRange){const s=this._buildValueFromParts(this._endPartInputs,e);this._hiddenInput.value=s?`${i} - ${s}`:i}else this._hiddenInput.value=i}_focusNext(t,e){if(e+1<t.length){const i=t[e+1];i.focus(),i.setSelectionRange(0,i.value.length)}}_focusPrev(t,e){if(e-1>=0){const i=t[e-1];i.focus(),i.setSelectionRange(i.value.length,i.value.length)}}_attachPartInputHandlers(t,e,i){t.forEach((s,n)=>{const r=s.maxLength||2;s.addEventListener("input",()=>{s.value=s.value.replace(/\D/g,"").slice(0,r),s.value.length>=r&&this._focusNext(t,n),this._syncHiddenInput()}),s.addEventListener("keydown",a=>{a.key==="Backspace"&&s.selectionStart===0&&s.selectionEnd===0&&this._focusPrev(t,n),a.key==="ArrowLeft"&&s.selectionStart===0&&s.selectionEnd===0&&(this._focusPrev(t,n),a.preventDefault()),a.key==="ArrowRight"&&s.selectionStart===s.value.length&&s.selectionEnd===s.value.length&&(this._focusNext(t,n),a.preventDefault())}),s.addEventListener("blur",a=>{this._syncHiddenInput();const o=a.relatedTarget,l=o&&(this._startPartInputs.includes(o)||this._endPartInputs.includes(o));setTimeout(()=>{var h;if(!(this._startPartInputs.some(p=>p===document.activeElement)||this._endPartInputs.some(p=>p===document.activeElement))&&(l||this._handleBlur(((h=this._hiddenInput)==null?void 0:h.value)||""),this._exitInputMode(),!l&&this._hiddenInput)){const p=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:a.relatedTarget});this._hiddenInput.dispatchEvent(p)}},0)})})}_splitRangeInput(t,e){const i=t.split(/\s*-\s*/);return i.length>=2?[i[0],i.slice(1).join("-")]:[t]}_parseValue(t){const e=this.getFormat(),i=this._getFormatTokens(e),s=this.getSelectionMode();if(this._isRange||s==="week"||s==="month"){const[r,a]=this._splitRangeInput(t,e),o=r?this._parseDateString(r,e):null,l=a?this._parseDateString(a,e):null;if(o&&l){const[c,h]=o<=l?[o,l]:[l,o];this._selectedStartDate=c,this._selectedEndDate=h,this._currentMonth=c.getMonth(),this._currentYear=c.getFullYear()}else o&&(this._selectedStartDate=o,this._selectedEndDate=null,this._currentMonth=o.getMonth(),this._currentYear=o.getFullYear());this._applyDateToParts(this._selectedStartDate,this._startPartInputs,i,e),this._applyDateToParts(this._selectedEndDate,this._endPartInputs,i,e)}else{const r=this._parseDateString(t,e);r&&!isNaN(r.getTime())?(this._selectedStartDate=r,this._selectedEndDate=null,this._currentMonth=r.getMonth(),this._currentYear=r.getFullYear(),this._applyDateToParts(r,this._startPartInputs,i,e)):this._applyDateToParts(null,this._startPartInputs,i,e)}this._syncHiddenInput(),this._updateDisplayText()}_parseDateString(t,e){const i=/[\/\-\.\s]+/;if(i.test(t)){const b=t.split(i).filter(y=>y.length>0),v=e.split(/[\/\-\.\s]+/).filter(y=>y.length>0);if(b.length===v.length){let y=0,x=0,D=0;for(let k=0;k<v.length;k++){const C=v[k].toLowerCase(),A=b[k];if(C.includes("d"))y=parseInt(A,10);else if(C.includes("m"))x=parseInt(A,10)-1;else if(C.includes("y")){let M=parseInt(A,10);const T=C.length,L=A.length;L===2&&T===4?M=Math.floor(new Date().getFullYear()/100)*100+M:L===2&&T===2&&(M=Math.floor(new Date().getFullYear()/100)*100+M),D=M}}const w=v.some(k=>k.toLowerCase().includes("d")),S=v.some(k=>k.toLowerCase().includes("m"));if(w||(y=1),S||(x=0),x>=0&&x<=11&&D){const k=new Date(D,x,y);if(!isNaN(k.getTime()))return w&&k.getDate()!==y||k.getMonth()!==x||k.getFullYear()!==D?null:k}}}const n=t.replace(/[\/\-\.]/g,""),r=e.replace(/[\/\-\.]/g,"").toLowerCase();let a=r.indexOf("d"),o=r.indexOf("m"),l=r.indexOf("y");const c=[{char:"d",index:a},{char:"m",index:o},{char:"y",index:l}].sort((b,v)=>b.index-v.index);let h=0,p=0,d=0,u=0;r.length,n.length;for(const b of c)if(b.char==="d"){const v=r.lastIndexOf("d")-r.indexOf("d")+1,y=n.substr(u,v);if(y.length===0)return null;h=parseInt(y,10),u+=y.length}else if(b.char==="m"){const v=r.lastIndexOf("m")-r.indexOf("m")+1,y=n.substr(u,v);if(y.length===0)return null;p=parseInt(y,10)-1,u+=y.length}else if(b.char==="y"){const v=r.lastIndexOf("y")-r.indexOf("y")+1,y=n.substr(u),x=Math.min(v,y.length),D=y.substr(0,x);if(D.length===0)return null;let w=parseInt(D,10);x===2&&v===4?w=Math.floor(new Date().getFullYear()/100)*100+w:x===2&&v===2&&(w=Math.floor(new Date().getFullYear()/100)*100+w),d=w,u+=x}const m=e.toLowerCase(),f=m.includes("d"),g=m.includes("m");if(f||(h=1),g||(p=0),p<0||p>11||!d)return null;const _=new Date(d,p,h);return isNaN(_.getTime())||f&&_.getDate()!==h||_.getMonth()!==p||_.getFullYear()!==d?null:_}_formatDate(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=e.toLowerCase();let a=e;return r.includes("dd")?a=a.replace(/dd/gi,String(i).padStart(2,"0")):r.includes("d")&&(a=a.replace(/d/gi,String(i))),r.includes("mm")?a=a.replace(/mm/gi,String(s).padStart(2,"0")):r.includes("m")&&(a=a.replace(/m/gi,String(s))),r.includes("yyyy")?a=a.replace(/yyyy/gi,String(n)):r.includes("yy")&&(a=a.replace(/yy/gi,String(n).substr(2))),a}_formatDatePhp(t,e){const i=t.getDate(),s=t.getMonth()+1,n=t.getFullYear(),r=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],o=["January","February","March","April","May","June","July","August","September","October","November","December"],l=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],c=(d,u=2)=>d.toString().padStart(u,"0"),h=d=>{const u=d%10,m=d%100;return u===1&&m!==11?"st":u===2&&m!==12?"nd":u===3&&m!==13?"rd":"th"};let p="";for(let d=0;d<e.length;d++){const u=e[d];if(u==="\\"&&d+1<e.length){p+=e[d+1],d++;continue}switch(u){case"Y":p+=n.toString();break;case"y":p+=n.toString().slice(-2);break;case"m":p+=c(s);break;case"n":p+=s.toString();break;case"M":p+=l[s-1];break;case"F":p+=o[s-1];break;case"d":p+=c(i);break;case"j":p+=i.toString();break;case"D":p+=a[t.getDay()];break;case"l":p+=r[t.getDay()];break;case"S":p+=h(i);break;default:p+=u;break}}return p}_validateDateString(t,e){const i=this._parseDateString(t,e);return i!==null&&!isNaN(i.getTime())}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.getValue(),n=this.isDisabled(),r=this.isReadonly(),a=this.isRequired(),o=this.getId(),l=this.getName(),c=this.getFormat(),h=this.hasError(),p=this.getErrorMessage(),d=this.getSelectionMode();this._isRange=this.isRange()||d==="week"||d==="month",this._input||(this._input=document.createElement("div"),this._input.className="relative w-full",this.appendChild(this._input));let u=this.querySelector(".mint-date-picker-label-container");if(e||i){u||(u=document.createElement("div"),u.className="mint-date-picker-label-container flex flex-col gap-0.5 mb-[.25rem]",this.contains(this._input)?this.insertBefore(u,this._input):this.appendChild(u));let v=u.querySelector(".mint-date-picker-label");e?(v||(v=document.createElement("label"),v.className="mint-date-picker-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",u.insertBefore(v,u.firstChild)),v.textContent=e,o&&this._textInput&&v.setAttribute("for",o)):v&&v.remove();let y=u.querySelector(".mint-date-picker-info");i?(y||(y=document.createElement("span"),y.className="mint-date-picker-info text-xs text-gray-500 dark:text-gray-400 select-none",u.appendChild(y)),y.textContent=i):y&&y.remove()}else u&&u.remove();this._hiddenInput||(this._hiddenInput=document.createElement("input"),this._hiddenInput.type="hidden",this._hiddenInput.value=s||"",this._textInput=this._hiddenInput,this._input.appendChild(this._hiddenInput)),o&&(this._hiddenInput.id=o),l&&(this._hiddenInput.name=l),this._hiddenInput.value=s||"",this._hiddenInput.setAttribute("aria-invalid",h?"true":"false");let m=this._input.querySelector(".mint-date-fields");m||(m=document.createElement("div"),this._input.appendChild(m)),this._fieldsContainer=m,this._applyErrorVisuals(h,p,n),m.innerHTML="",this._displayEl=document.createElement("div");const f=r?"select-text":"select-none";this._displayEl.className=`flex-1 text-gray-900 dark:text-white ${r?"cursor-default":"cursor-text"} ${f} focus:outline-none`,this._displayEl.tabIndex=n||r?-1:0,this._displayEl.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._displayEl.addEventListener("keydown",v=>{n||r||(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),this._enterInputMode())}),this._inputsWrapperEl=document.createElement("div"),this._isRange?this._inputsWrapperEl.className="flex items-center gap-1 w-full":this._inputsWrapperEl.className="flex items-center gap-1 w-full";const g=this._getFormatTokens(c);this._startPartInputs=[],this._endPartInputs=[];const _=v=>{const y=document.createDocumentFragment();return g.forEach(x=>{if(x.type==="sep"){const D=document.createElement("span");D.textContent=x.value,D.className="text-gray-400 dark:text-gray-500 select-none",y.appendChild(D)}else{const D=x.part==="d"?"dd":x.part==="m"?"mm":x.len===2?"yy":"yyyy",w=this._createPartInput(x.len,D,n,r,a);v==="start"?this._startPartInputs.push(w):this._endPartInputs.push(w),y.appendChild(w)}}),y};if(this._isRange){const v=document.createElement("div");v.className="flex items-center gap-1 flex-shrink-0",v.appendChild(_("start")),this._inputsWrapperEl.appendChild(v);const y=document.createElement("span");y.textContent=" - ",y.className="text-gray-400 dark:text-gray-500 select-none flex-shrink-0",this._inputsWrapperEl.appendChild(y);const x=document.createElement("div");x.className="flex items-center gap-1 flex-shrink-0",x.appendChild(_("end")),this._inputsWrapperEl.appendChild(x)}else this._inputsWrapperEl.appendChild(_("start"));const b=document.createElement("div");if(b.className="flex flex-col w-full",this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none",b.appendChild(this._displayEl),b.appendChild(this._inputsWrapperEl),m.appendChild(b),this._isRange&&this._inputsWrapperEl&&this._setupContainerObserver(),m.addEventListener("click",()=>{this._isInputMode||n||r||this._enterInputMode()}),this._attachPartInputHandlers(this._startPartInputs,g,m),this._isRange&&this._attachPartInputHandlers(this._endPartInputs,g,m),this._parseValue(s),this._syncHiddenInput(),this._updateDisplayText(),this._iconButton)this._iconButton.disabled=n||r,!n&&!r?this._iconButton.tabIndex=0:this._iconButton.tabIndex=-1;else{this._iconButton=document.createElement("button"),this._iconButton.type="button",this._iconButton.tabIndex=0,this._iconButton.className="absolute left-2 top-[.55rem] text-gray-400 dark:text-gray-500 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer z-10 focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 pointer-events-auto disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center rounded-sm";const v=`date-icon-${Math.random().toString(36).substr(2,9)}`;this._iconButton.id=v;const y=document.createElement("mint-icon");y.setAttribute("name","calendar"),y.className="w-4 h-4 pointer-events-none",this._iconButton.appendChild(y),this._iconButton.addEventListener("click",()=>{n||r||this._enterInputMode()}),this._input.prepend(this._iconButton),this._iconButton.disabled=n||r}this._renderErrorState(h,p),this._renderSkeleton(t)}_renderErrorState(t,e){let i=this.querySelector(".mint-date-picker-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-date-picker-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_applyErrorVisuals(t,e,i){if(this._renderErrorState(t,e),this._fieldsContainer){const s=this._getFieldContainerClass(t,i);this._fieldsContainer.className=s}this._hiddenInput&&this._hiddenInput.setAttribute("aria-invalid",t?"true":"false")}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this.setValue(""),this._clearPartInputs(this._startPartInputs),this._clearPartInputs(this._endPartInputs),this._isInputMode=!1,this._updateDisplayText(),this._applyErrorVisuals(!1,"",this.isDisabled())},t.addEventListener("reset",this._resetHandler))}_clearPartInputs(t){t.forEach(e=>{e.value=""})}_getFieldContainerClass(t,e){return["mint-date-fields relative w-full pl-10 pr-3.5 py-1.5 min-h-[2rem] text-sm font-medium rounded-lg box-border bg-white dark:bg-gray-900 dark:border dark:border-gray-700 text-gray-900 dark:text-white","border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","transition-all duration-200 outline-none focus-within:ring-2 focus-within:ring-offset-1",t?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","flex items-center gap-1"].join(" ")+(e?" opacity-40 cursor-not-allowed":"")}_handleInputChange(t){}_cleanInputValue(t,e){return t}_handleBlur(t){const e=this.getFormat(),i=this.getSelectionMode(),s=this._isRange||i==="week"||i==="month";if(!t){this.setValue(""),this._updateDisplayText();return}if(s){const[n,r]=this._splitRangeInput(t,e),a=n?this._parseDateString(n,e):null,o=r?this._parseDateString(r,e):null;if(a&&o){const[l,c]=a<=o?[a,o]:[o,a],h=this._formatDate(l,e),p=this._formatDate(c,e),d=`${h} - ${p}`;this.setValue(d),this._applyDateToParts(l,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(c,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=l,this._selectedEndDate=c,this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}else if(a){const l=this._formatDate(a,e);this.setValue(l),this._applyDateToParts(a,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=a,this._selectedEndDate=null,this._currentMonth=a.getMonth(),this._currentYear=a.getFullYear()}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._applyDateToParts(null,this._endPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}else if(this._validateDateString(t,e)){const n=this._parseDateString(t,e);if(n){const r=this._formatDate(n,e);this.setValue(r),this._applyDateToParts(n,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=n,this._selectedEndDate=null,this._currentMonth=n.getMonth(),this._currentYear=n.getFullYear()}}else this.setValue(""),this._applyDateToParts(null,this._startPartInputs,this._getFormatTokens(e),e),this._selectedStartDate=null,this._selectedEndDate=null}_setupPopoverWithRetry(t=0){if(!this._iconButton){t<10&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)});return}const e=10,i=this._iconButton.id;i&&this._iconButton.isConnected?document.getElementById(i)?this._createPopover(i):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)}):t<e&&requestAnimationFrame(()=>{this._setupPopoverWithRetry(t+1)})}_createPopover(t){if(!t)return;if(!document.getElementById(t)){setTimeout(()=>{this._createPopover(t)},50);return}if(this._popover){if(this._popover.getAttribute("trigger-id")!==t){this._popover.setAttribute("trigger-id",t);const s=this._popover;typeof s._setupTrigger=="function"&&s._setupTrigger()}this._buildCalendar()}else{this._popover=document.createElement("mint-popover"),this._popover.setAttribute("direction","down"),this._popover.setAttribute("padding","0");const i=this.closest("mint-modal"),s=this.closest("mint-off-canvas");i||s?document.body.appendChild(this._popover):this.parentNode?this.parentNode.insertBefore(this._popover,this.nextSibling):document.body.appendChild(this._popover),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._popover&&this._popover.isConnected&&(this._popover.setAttribute("trigger-id",t),this._popoverObserver||(this._popoverObserver=new MutationObserver(n=>{n.forEach(r=>{var a;if(r.type==="attributes"&&r.attributeName==="open")if((a=this._popover)==null?void 0:a.hasAttribute("open"))requestAnimationFrame(()=>{this._buildCalendar();const l=this._popover;typeof l.render=="function"&&l.render(),this._setupFocusTrap()});else{if(this._removeFocusTrap(),this._iconButton&&!this._iconButton.disabled&&requestAnimationFrame(()=>{var l;(l=this._iconButton)==null||l.focus()}),this._viewMode="calendar",this._selectedStartDate)this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();else{const l=new Date;this._currentMonth=l.getMonth(),this._currentYear=l.getFullYear()}requestAnimationFrame(()=>{this._buildCalendar()}),this._hiddenInput&&(this._syncHiddenInput(),setTimeout(()=>{var c;const l=new FocusEvent("blur",{bubbles:!0,cancelable:!0,relatedTarget:null});(c=this._hiddenInput)==null||c.dispatchEvent(l)},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-gray-900 dark:border dark:border-gray-700 rounded-lg p-4 w-[22rem] md:w-auto md:min-w-[28rem]";const t=this.getMode();t==="month"&&this._viewMode==="calendar"?this._viewMode="month":t==="year"&&this._viewMode==="calendar"?this._viewMode="year":t==="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();const e=this._popover.querySelector(".popover-content");if(e){for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(this._calendarContainer)}else this._popover.appendChild(this._calendarContainer)}_buildCalendarView(){if(!this._calendarContainer)return;const t=this._getDaysInMonth(this._currentMonth,this._currentYear),e=this._getFirstDayOfMonth(this._currentMonth,this._currentYear),i=["January","February","March","April","May","June","July","August","September","October","November","December"],s=this.getWeekStartDay(),n=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],r=[...n.slice(s),...n.slice(0,s)],a=this.getShortcuts(),o=a.length>0;this._calendarContainer.className=o?"mint-date-calendar bg-white dark:bg-gray-900 dark:border dark:border-gray-700 rounded-lg p-4 w-[18rem] md:w-auto md:min-w-[28rem]":"mint-date-calendar bg-white dark:bg-gray-900 dark:border dark:border-gray-700 rounded-lg p-4 w-[18rem] md:min-w-[18rem]";const l=document.createElement("div");l.className="flex flex-col md:flex-row md:gap-6 md:items-start";const c=document.createElement("div");c.className="flex-1 min-w-0";const h=document.createElement("div");h.className="flex items-center justify-between mb-4";const p=document.createElement("button");p.type="button",p.tabIndex=0,p.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",p.setAttribute("data-keep-popover-open","true");const d=document.createElement("mint-icon");d.setAttribute("name","caret-left"),d.className="w-4 h-4",p.appendChild(d),p.addEventListener("click",()=>{const E=this._currentMonth,H=this._currentYear;this._currentMonth===0?(this._currentMonth=11,this._currentYear--):this._currentMonth--,this._buildCalendar(),this._dispatchMonthChangeEvent(E,H,this._currentMonth,this._currentYear)}),h.appendChild(p);const u=document.createElement("div");u.className="flex items-center gap-2";const m=document.createElement("button");m.type="button",m.tabIndex=0,m.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",m.setAttribute("data-keep-popover-open","true"),m.textContent=i[this._currentMonth];const f=()=>{const E=this.getMode();E!=="month"&&E!=="year"&&(this._viewMode="month",this._buildCalendar())};m.addEventListener("click",f),m.addEventListener("touchend",E=>{E.preventDefault(),f()},{passive:!1}),u.appendChild(m);const 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 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",g.setAttribute("data-keep-popover-open","true"),g.textContent=String(this._currentYear),g.addEventListener("click",()=>{this.getMode()!=="year"&&(this._viewMode="year",this._buildCalendar())}),u.appendChild(g),h.appendChild(u);const _=document.createElement("button");_.type="button",_.tabIndex=0,_.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors flex items-center focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",_.setAttribute("data-keep-popover-open","true");const b=document.createElement("mint-icon");b.setAttribute("name","caret-right"),b.className="w-4 h-4",_.appendChild(b);const v=()=>{const E=this._currentMonth,H=this._currentYear;this._currentMonth===11?(this._currentMonth=0,this._currentYear++):this._currentMonth++,this._buildCalendar(),this._dispatchMonthChangeEvent(E,H,this._currentMonth,this._currentYear)};_.addEventListener("click",v),_.addEventListener("touchend",E=>{E.preventDefault(),v()},{passive:!1}),h.appendChild(_);const y=document.createElement("div");y.className="grid grid-cols-7 mb-2",r.forEach(E=>{const H=document.createElement("div");H.className="text-xs font-medium text-gray-500 dark:text-gray-400 text-center py-1",H.textContent=E,y.appendChild(H)});const x=document.createElement("div");x.className="grid grid-cols-7";const D=this.getMin()?this._parseDateString(this.getMin(),this.getFormat()):null,w=this.getMax()?this._parseDateString(this.getMax(),this.getFormat()):null;this.getDisabledDates();const S=this._currentMonth===0?11:this._currentMonth-1,k=this._currentMonth===0?this._currentYear-1:this._currentYear,C=this._getDaysInMonth(S,k),A=this._currentMonth===11?0:this._currentMonth+1,M=this._currentMonth===11?this._currentYear+1:this._currentYear,T=e+t,I=Math.ceil(T/7)*7-T,$=(E,H,N)=>{const V=this._isToday(E),Y=this._isDateSelected(E),j=this._isDateInRange(E),X=D&&E<D||w&&E>w||this._isDateDisabled(E);let q="rounded-md";const W=this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate,K=W&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._selectedStartDate:W&&this._hoveredDate?this._hoveredDate:null,B=W&&this._selectedStartDate&&this._hoveredDate&&this._selectedStartDate<this._hoveredDate?this._hoveredDate:W&&this._selectedStartDate?this._selectedStartDate:null,U=K!==null&&this._isSameDate(E,K),O=B!==null&&this._isSameDate(E,B),Z=this._hoveredDate!==null&&this._isSameDate(E,this._hoveredDate),G=W&&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){const z=this._isSameDate(E,this._selectedStartDate),tt=this._isSameDate(E,this._selectedEndDate);z&&tt?q="rounded-md":z?q="rounded-l-md":tt?q="rounded-r-md":j&&(q="rounded-none")}else W&&(U||O)&&G?U&&O?q="rounded-md":U?q="rounded-l-md":O&&(q="rounded-r-md"):Y&&!this._isRange||Y&&this._isRange&&!this._selectedEndDate?q="rounded-md":j&&W&&G&&(q="rounded-none");const R=document.createElement("button");R.type="button",R.disabled=!!X,R.tabIndex=X?-1:0;let Q=`w-full h-8 ${q} border-0 text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500`;const at=Y||W&&Z&&G;return N?Q+=at?" bg-slate-800 dark:bg-slate-600 text-white":j?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":V?" text-gray-900 dark:text-gray-100 font-semibold":" text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700":Q+=at?" bg-slate-800 dark:bg-slate-600 text-white":j?" bg-slate-100 dark:bg-slate-700 text-slate-800 dark:text-slate-200":" text-gray-400 dark:text-gray-500 hover:bg-gray-100 dark:hover:bg-gray-700",Q+=X?" opacity-40 cursor-not-allowed":"",R.className=Q,R.textContent=H.toString(),X||(R.addEventListener("click",z=>{z.preventDefault(),z.stopPropagation(),this._handleDateClick(E)}),R.addEventListener("touchstart",z=>{z.preventDefault(),z.stopPropagation(),this._isTouchActive=!0,this._touchStartDate=E,this._touchStartElement=R,R.classList.add("active","bg-gray-200","dark:bg-gray-600")},{passive:!1}),R.addEventListener("touchend",z=>{z.preventDefault(),z.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}),R.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&&!X&&(R.addEventListener("mouseenter",()=>{this._isHandlingClick||this._isTouchActive||this._isDateDisabled(E)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,E))&&(this._hoveredDate=E,this._buildCalendar())}),R.addEventListener("touchmove",z=>{if(!this._isTouchActive||!this._touchStartDate)return;const tt=z.touches[0];let J=document.elementFromPoint(tt.clientX,tt.clientY);for(;J&&!J.classList.contains("mint-date-picker-day");)J=J.parentElement;if(J&&J!==R){const ot=J.getAttribute("data-date");if(ot){const nt=new Date(ot);this._isDateDisabled(nt)||(!this._hoveredDate||!this._isSameDate(this._hoveredDate,nt))&&(this._hoveredDate=nt,this._buildCalendar())}}},{passive:!0}))),R};for(let E=e-1;E>=0;E--){const H=C-E,N=new Date(k,S,H),V=$(N,H,!1);x.appendChild(V)}for(let E=1;E<=t;E++){const H=new Date(this._currentYear,this._currentMonth,E),N=$(H,E,!0);x.appendChild(N)}for(let E=1;E<=I;E++){const H=new Date(M,A,E),N=$(H,E,!1);x.appendChild(N)}if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&(x.addEventListener("mouseleave",()=>{this._isTouchActive||(this._hoveredDate=null,this._buildCalendar())}),x.addEventListener("touchend",E=>{const H=E.changedTouches[0],N=document.elementFromPoint(H.clientX,H.clientY);N&&!x.contains(N)&&(this._hoveredDate=null,this._buildCalendar())},{passive:!0})),o){const E=document.createElement("div");E.className="mb-4 pb-4 border-b border-gray-200 dark:border-gray-700 md:mb-0 md:pb-0 md:border-b-0 md:border-r md:border-r-gray-200 dark:md:border-r-gray-700 md:pr-6 md:mr-0 md:w-32 md:flex-shrink-0 md:h-full md:flex md:flex-col";const H=document.createElement("div");H.className="relative md:relative md:flex-1 md:min-h-0";const 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");const V=document.createElement("style");V.textContent=`
59
- .mint-date-shortcuts-row::-webkit-scrollbar {
60
- display: none;
61
- }
62
- @media (min-width: 768px) {
63
- .mint-date-shortcuts-row {
64
- height: 17rem;
65
- overflow-y: auto;
66
- }
67
- .mint-date-shortcuts-row::-webkit-scrollbar {
68
- display: block;
69
- width: 4px;
70
- }
71
- .mint-date-shortcuts-row::-webkit-scrollbar-track {
72
- background: transparent;
73
- }
74
- .mint-date-shortcuts-row::-webkit-scrollbar-thumb {
75
- background: rgba(0, 0, 0, 0.2);
76
- border-radius: 2px;
77
- }
78
- .dark .mint-date-shortcuts-row::-webkit-scrollbar-thumb {
79
- background: rgba(255, 255, 255, 0.2);
80
- }
81
- }
82
- `,N.classList.add("mint-date-shortcuts-row"),document.head.querySelector("style[data-mint-date-shortcuts]")||(V.setAttribute("data-mint-date-shortcuts","true"),document.head.appendChild(V));const Y=document.createElement("div");Y.className="absolute left-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-r from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200 md:hidden",H.appendChild(Y);const j=document.createElement("div");j.className="absolute right-0 top-0 bottom-0 w-8 pointer-events-none z-10 bg-gradient-to-l from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200 md:hidden",H.appendChild(j);const X=document.createElement("div");X.className="hidden md:block absolute top-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-b from-white dark:from-gray-800 to-transparent opacity-0 transition-opacity duration-200",H.appendChild(X);const q=document.createElement("div");q.className="hidden md:block absolute bottom-0 left-0 right-0 h-8 pointer-events-none z-10 bg-gradient-to-t from-white dark:from-gray-800 to-transparent opacity-100 transition-opacity duration-200",H.appendChild(q);const W=()=>{if(window.innerWidth>=768){const B=N.scrollTop,U=N.scrollHeight,O=N.clientHeight;B>0?X.style.opacity="1":X.style.opacity="0",B+O<U-1?q.style.opacity="1":q.style.opacity="0",Y.style.opacity="0",j.style.opacity="0"}else{const B=N.scrollLeft,U=N.scrollWidth,O=N.clientWidth;B>0?Y.style.opacity="1":Y.style.opacity="0",B+O<U-1?j.style.opacity="1":j.style.opacity="0",X.style.opacity="0",q.style.opacity="0"}};N.addEventListener("scroll",W),window.addEventListener("resize",W),setTimeout(W,0),a.forEach(K=>{const B=document.createElement("button");B.type="button",B.tabIndex=0,B.className="px-3 py-1.5 text-xs font-medium rounded-md bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-200 dark:hover:bg-gray-600 transition-colors whitespace-nowrap flex-shrink-0 md:w-full md:text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",B.textContent=K.label,B.setAttribute("data-keep-popover-open","true");const U=()=>{const O=K.action();if(O){if(this._isRange&&"start"in O&&"end"in O){this._selectedStartDate=O.start,this._selectedEndDate=O.end;const Z=this.getFormat(),G=this._formatDate(O.start,Z),R=this._formatDate(O.end,Z),Q=`${G} - ${R}`;this.setValue(Q),this._currentMonth=O.start.getMonth(),this._currentYear=O.start.getFullYear()}else if(O instanceof Date){this._selectedStartDate=O,this._selectedEndDate=null;const Z=this.getFormat(),G=this._formatDate(O,Z);this.setValue(G),this._currentMonth=O.getMonth(),this._currentYear=O.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}))}};B.addEventListener("click",U),B.addEventListener("touchend",O=>{O.preventDefault(),U()},{passive:!1}),N.appendChild(B)}),H.appendChild(N),E.appendChild(H),l.appendChild(E)}c.appendChild(h),c.appendChild(y),c.appendChild(x),l.appendChild(c),this._calendarContainer.appendChild(l)}_buildMonthView(){if(!this._calendarContainer)return;const t=["January","February","March","April","May","June","July","August","September","October","November","December"],e=document.createElement("div");e.className="flex items-center justify-between mb-4";const i=document.createElement("button");i.type="button",i.tabIndex=0,i.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",i.setAttribute("data-keep-popover-open","true");const s=document.createElement("mint-icon");s.setAttribute("name","caret-left"),s.className="w-4 h-4",i.appendChild(s);const n=()=>{const p=this._currentMonth,d=this._currentYear;this._currentYear--,this._buildCalendar(),this._dispatchMonthChangeEvent(p,d,this._currentMonth,this._currentYear)};i.addEventListener("click",n),i.addEventListener("touchend",p=>{p.preventDefault(),n()},{passive:!1}),e.appendChild(i);const r=document.createElement("button");r.type="button",r.tabIndex=0,r.className="text-sm font-medium text-gray-900 dark:text-gray-100 hover:text-gray-600 dark:hover:text-gray-300 cursor-pointer transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 rounded px-1",r.setAttribute("data-keep-popover-open","true"),r.textContent=String(this._currentYear);const a=()=>{this.getMode()!=="year"&&(this._viewMode="year",this._buildCalendar())};r.addEventListener("click",a),r.addEventListener("touchend",p=>{p.preventDefault(),a()},{passive:!1}),e.appendChild(r);const o=document.createElement("button");o.type="button",o.tabIndex=0,o.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",o.setAttribute("data-keep-popover-open","true");const l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",o.appendChild(l);const c=()=>{const p=this._currentMonth,d=this._currentYear;this._currentYear++,this._buildCalendar(),this._dispatchMonthChangeEvent(p,d,this._currentMonth,this._currentYear)};o.addEventListener("click",c),o.addEventListener("touchend",p=>{p.preventDefault(),c()},{passive:!1}),e.appendChild(o);const h=document.createElement("div");h.className="grid grid-cols-3 gap-2",t.forEach((p,d)=>{const u=document.createElement("button");u.type="button",u.tabIndex=0,u.setAttribute("data-keep-popover-open","true");const m=this._currentMonth===d;u.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${m?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,u.textContent=p;const f=()=>{if(this.getMode()==="month"){const _=new Date(this._currentYear,d,1),b=this.getFormat(),v=this._formatDate(_,b);this.setValue(v),this._selectedStartDate=_,this._selectedEndDate=null;const y=this._currentMonth,x=this._currentYear;this._currentMonth=d,this._dispatchMonthChangeEvent(y,x,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{const _=this._currentMonth,b=this._currentYear;this._currentMonth=d,this._viewMode="calendar",this._buildCalendar(),this._dispatchMonthChangeEvent(_,b,this._currentMonth,this._currentYear)}};u.addEventListener("click",f),u.addEventListener("touchend",g=>{g.preventDefault(),f()},{passive:!1}),h.appendChild(u)}),this._calendarContainer.appendChild(e),this._calendarContainer.appendChild(h)}_buildYearView(){if(!this._calendarContainer)return;const t=this._currentYear-6,e=this._currentYear+6,i=document.createElement("div");i.className="flex items-center justify-between mb-4";const s=document.createElement("button");s.type="button",s.tabIndex=0,s.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",s.setAttribute("data-keep-popover-open","true");const n=document.createElement("mint-icon");n.setAttribute("name","caret-left"),n.className="w-4 h-4",s.appendChild(n);const r=()=>{const p=this._currentMonth,d=this._currentYear;this._currentYear-=12,this._buildCalendar(),this._dispatchMonthChangeEvent(p,d,this._currentMonth,this._currentYear)};s.addEventListener("click",r),s.addEventListener("touchend",p=>{p.preventDefault(),r()},{passive:!1}),i.appendChild(s);const a=document.createElement("div");a.className="text-sm font-medium text-gray-900 dark:text-gray-100",a.textContent=`${t} - ${e}`,i.appendChild(a);const o=document.createElement("button");o.type="button",o.tabIndex=0,o.className="p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-700 text-gray-600 dark:text-gray-300 transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500",o.setAttribute("data-keep-popover-open","true");const l=document.createElement("mint-icon");l.setAttribute("name","caret-right"),l.className="w-4 h-4",o.appendChild(l);const c=()=>{const p=this._currentMonth,d=this._currentYear;this._currentYear+=12,this._buildCalendar(),this._dispatchMonthChangeEvent(p,d,this._currentMonth,this._currentYear)};o.addEventListener("click",c),o.addEventListener("touchend",p=>{p.preventDefault(),c()},{passive:!1}),i.appendChild(o);const h=document.createElement("div");h.className="grid grid-cols-3 gap-2";for(let p=t;p<=e;p++){const d=document.createElement("button");d.type="button",d.tabIndex=0,d.setAttribute("data-keep-popover-open","true");const u=this._currentYear===p;d.className=`p-2 rounded text-sm font-medium transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500 ${u?"bg-slate-800 dark:bg-slate-600 text-white":"text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700"}`,d.textContent=String(p),d.addEventListener("click",()=>{const m=this.getMode();if(m==="year"){const f=new Date(p,0,1),g=this.getFormat(),_=this._formatDate(f,g);this.setValue(_),this._selectedStartDate=f,this._selectedEndDate=null;const b=this._currentMonth,v=this._currentYear;this._currentYear=p,this._currentMonth=0,this._dispatchMonthChangeEvent(b,v,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(m==="month"){const f=this._currentMonth,g=this._currentYear;this._currentYear=p,this._viewMode="month",this._buildCalendar(),this._dispatchMonthChangeEvent(f,g,this._currentMonth,this._currentYear)}else{const f=this._currentMonth,g=this._currentYear;this._currentYear=p,this._viewMode="calendar",this._buildCalendar(),this._dispatchMonthChangeEvent(f,g,this._currentMonth,this._currentYear)}}),h.appendChild(d)}this._calendarContainer.appendChild(i),this._calendarContainer.appendChild(h)}_getDaysInMonth(t,e){return new Date(e,t+1,0).getDate()}_getFirstDayOfMonth(t,e){const i=this.getWeekStartDay(),s=new Date(e,t,1).getDay();return s>=i?s-i:7-(i-s)}_isToday(t){const e=new Date;return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateSelected(t){const e=this.getSelectionMode();return this._isRange||e==="week"||e==="month"?this._selectedStartDate&&this._selectedEndDate?this._isSameDate(t,this._selectedStartDate)||this._isSameDate(t,this._selectedEndDate):this._isRange&&this._selectedStartDate&&!this._selectedEndDate?this._isSameDate(t,this._selectedStartDate):!1:this._selectedStartDate!==null&&this._isSameDate(t,this._selectedStartDate)}_isDateInRange(t){const e=this.getSelectionMode();if((this._isRange||e==="week"||e==="month")&&this._selectedStartDate&&this._selectedEndDate)return this._rangeIncludesDisabledDates(this._selectedStartDate,this._selectedEndDate)?!1:t>=this._selectedStartDate&&t<=this._selectedEndDate;if(this._isRange&&this._selectedStartDate&&!this._selectedEndDate&&this._hoveredDate){const i=this._selectedStartDate<this._hoveredDate?this._selectedStartDate:this._hoveredDate,s=this._selectedStartDate<this._hoveredDate?this._hoveredDate:this._selectedStartDate;if(this._rangeIncludesDisabledDates(i,s)){const n=this._findFirstDisabledDateInRange(i,s);return n?this._selectedStartDate<this._hoveredDate?t>=i&&t<n&&!this._isSameDate(t,i):t>n&&t<=s&&!this._isSameDate(t,s):!1}return t>=i&&t<=s&&!this._isSameDate(t,i)&&!this._isSameDate(t,s)}return!1}_rangeIncludesDisabledDates(t,e){const i=this.getDisabledDates(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(e.getFullYear(),e.getMonth(),e.getDate());return i.some(r=>{const a=new Date(r.getFullYear(),r.getMonth(),r.getDate());return a>=s&&a<=n})}_findFirstDisabledDateInRange(t,e){const i=this.getDisabledDates(),s=new Date(t.getFullYear(),t.getMonth(),t.getDate()),n=new Date(e.getFullYear(),e.getMonth(),e.getDate()),r=i.map(a=>new Date(a.getFullYear(),a.getMonth(),a.getDate())).filter(a=>a>=s&&a<=n).sort((a,o)=>a.getTime()-o.getTime());return r.length>0?r[0]:null}_hasIncompleteRange(){return this._isRange&&this._selectedStartDate!==null&&this._selectedEndDate===null}_isSameDate(t,e){return t.getDate()===e.getDate()&&t.getMonth()===e.getMonth()&&t.getFullYear()===e.getFullYear()}_isDateDisabled(t){return this.getDisabledDates().some(i=>this._isSameDate(t,i))}_dispatchMonthChangeEvent(t,e,i,s){(t!==i||e!==s)&&this.dispatchEvent(new CustomEvent("month-change",{detail:{month:i,year:s,oldMonth:t,oldYear:e},bubbles:!0,cancelable:!0,composed:!0}))}_dispatchDateChangeEvent(){const t=this.getFormat(),i={value:this.getValue()};this._selectedStartDate&&(i.startDate=this._selectedStartDate,i.startDateFormatted=this._formatDate(this._selectedStartDate,t)),this._selectedEndDate&&(i.endDate=this._selectedEndDate,i.endDateFormatted=this._formatDate(this._selectedEndDate,t)),this.dispatchEvent(new CustomEvent("date-change",{detail:i,bubbles:!0,cancelable:!0,composed:!0}))}_setupContainerObserver(){if(this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),!this._inputsWrapperEl)return;const t=400,e=s=>{this._inputsWrapperEl&&(s<t?(this._inputsWrapperEl.classList.add("flex-wrap"),this._inputsWrapperEl.classList.remove("flex-nowrap")):(this._inputsWrapperEl.classList.remove("flex-wrap"),this._inputsWrapperEl.classList.add("flex-nowrap")))},i=this._inputsWrapperEl.offsetWidth||this.offsetWidth;e(i),this._resizeObserver=new ResizeObserver(s=>{for(const n of s){const r=n.contentRect.width;e(r)}}),this._resizeObserver.observe(this)}_getWeekStart(t){const e=this.getWeekStartDay(),i=t.getDay();let s;i>=e?s=i-e:s=7-(e-i);const n=new Date(t);return n.setDate(t.getDate()-s),n.setHours(0,0,0,0),n}_getWeekEnd(t){const e=this._getWeekStart(t),i=new Date(e);return i.setDate(e.getDate()+6),i.setHours(23,59,59,999),i}_getMonthStart(t){const e=new Date(t.getFullYear(),t.getMonth(),1);return e.setHours(0,0,0,0),e}_getMonthEnd(t){const e=new Date(t.getFullYear(),t.getMonth()+1,0);return e.setHours(23,59,59,999),e}_handleDateClick(t){this._isHandlingClick=!0;try{const e=this.getFormat(),i=this.getSelectionMode();let s,n;if(i==="week"?(s=this._getWeekStart(t),n=this._getWeekEnd(t)):i==="month"?(s=this._getMonthStart(t),n=this._getMonthEnd(t)):(s=t,n=t),this.isRange()||i==="week"||i==="month")if(i==="week"||i==="month"){if(this._rangeIncludesDisabledDates(s,n)){this._buildCalendar();return}this._selectedStartDate=s,this._selectedEndDate=n;const o=this._formatDate(this._selectedStartDate,e),l=this._formatDate(this._selectedEndDate,e),c=`${o} - ${l}`;this.setValue(c),this._textInput&&(this._textInput.value=c),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else if(this._hoveredDate=null,this._selectedStartDate===null){if(this._isDateDisabled(s)){this._buildCalendar();return}this._selectedStartDate=new Date(s.getFullYear(),s.getMonth(),s.getDate()),this._selectedEndDate=null,this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear(),this._hoveredDate=null,this._buildCalendar()}else if(this._selectedEndDate===null){const o=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=this._selectedStartDate?new Date(this._selectedStartDate.getFullYear(),this._selectedStartDate.getMonth(),this._selectedStartDate.getDate()):null;let c,h;if(l&&o<l?(c=o,h=l):(c=l,h=o),this._rangeIncludesDisabledDates(c,h)){this._buildCalendar();return}l&&o<l?(this._selectedEndDate=l,this._selectedStartDate=o):(this._selectedEndDate=o,l&&(this._selectedStartDate=l)),this._currentMonth=this._selectedStartDate.getMonth(),this._currentYear=this._selectedStartDate.getFullYear();const p=this._formatDate(this._selectedStartDate,e),d=this._formatDate(this._selectedEndDate,e),u=`${p} - ${d}`;this.setAttribute("value",u),this._textInput&&(this._textInput.value=u),this._hiddenInput&&(this._hiddenInput.value=u),this._updateDisplayText(),this._buildCalendar(),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}else this._selectedStartDate=s,this._selectedEndDate=null;else{this._selectedStartDate=s,this._selectedEndDate=null;const o=this._formatDate(s,e);this.setValue(o),this._textInput&&(this._textInput.value=o),this._popover&&typeof this._popover.close=="function"&&this._popover.close()}this._buildCalendar(),this._updateDisplayText(),this._exitInputMode();const a=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(a),this.dispatchEvent(new CustomEvent("input",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:this.getValue()},bubbles:!0,cancelable:!0,composed:!0})),this._dispatchDateChangeEvent()}finally{this._isHandlingClick=!1}}_updateDisplayText(){if(!this._displayEl)return;const t=this.getDisplayFormat(),e=this.getSelectionMode(),i=this._isRange||e==="week"||e==="month";let s="";i?this._selectedStartDate&&this._selectedEndDate?s=`${this._formatDatePhp(this._selectedStartDate,t)} - ${this._formatDatePhp(this._selectedEndDate,t)}`:this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)):this._selectedStartDate&&(s=this._formatDatePhp(this._selectedStartDate,t)),s?(this._displayEl.textContent=s,this._displayEl.classList.remove("text-gray-400","dark:text-gray-500"),this._displayEl.classList.add("text-gray-900","dark:text-white")):(this._displayEl.textContent="Select date",this._displayEl.classList.add("text-gray-400","dark:text-gray-500"),this._displayEl.classList.remove("text-gray-900","dark:text-white")),this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display=this._isInputMode?"none":"flex",this._inputsWrapperEl.style.display=this._isInputMode?"flex":"none")}_enterInputMode(){if(!this._isInputMode&&!(this.isReadonly()||this.isDisabled())&&(this._isInputMode=!0,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="none",this._inputsWrapperEl.style.display="flex"),this._startPartInputs.length>0)){const t=this._startPartInputs[0];requestAnimationFrame(()=>{t.focus();try{t.setSelectionRange(0,t.value.length)}catch{}})}}_exitInputMode(){this._isInputMode&&(this._isInputMode=!1,this._displayEl&&this._inputsWrapperEl&&(this._displayEl.style.display="flex",this._inputsWrapperEl.style.display="none"),this._updateDisplayText())}_renderSkeleton(t){let e=this.querySelector(".mint-date-picker-skeleton-container");const i=this._fieldsContainer,s=this._input;if(t){e||(e=document.createElement("div"),e.className="mint-date-picker-skeleton-container absolute inset-0 z-10 pointer-events-none",s?(s.classList.contains("relative")||s.classList.add("relative"),s.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let n=e.querySelector(".mint-date-picker-skeleton");n||(n=document.createElement("div"),n.className="mint-date-picker-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",n.style.height="2.25rem",e.appendChild(n)),e.style.display="block",i&&(i.style.visibility="hidden",i.style.pointerEvents="none"),this._displayEl&&(this._displayEl.style.visibility="hidden",this._displayEl.style.pointerEvents="none")}else e&&(e.style.display="none"),i&&(i.style.visibility="visible",i.style.pointerEvents="auto"),this._displayEl&&(this._displayEl.style.visibility="visible",this._displayEl.style.pointerEvents="auto")}_getFocusableElements(){if(!this._calendarContainer)return[];const t=["button:not([disabled])","a[href]",'input:not([disabled]):not([type="hidden"])',"select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");return Array.from(this._calendarContainer.querySelectorAll(t)).filter(i=>{const s=window.getComputedStyle(i);return s.display!=="none"&&s.visibility!=="hidden"})}_setupFocusTrap(){if(!this._popover||!this._popover.hasAttribute("open"))return;this._removeFocusTrap();const t=this;this._focusTrapHandler=function(e){var o;if(e.key!=="Tab")return;if(!t._popover||!t._popover.hasAttribute("open")){t._removeFocusTrap();return}const i=t._getFocusableElements();if(i.length===0)return;const s=i[0],n=i[i.length-1],r=document.activeElement;if(!(((o=t._calendarContainer)==null?void 0:o.contains(r))||!1)){e.preventDefault(),s.focus();return}if(e.shiftKey&&r===s){e.preventDefault(),n.focus();return}if(!e.shiftKey&&r===n){e.preventDefault(),s.focus();return}},this._escapeHandler=function(e){(e.key==="Escape"||e.key==="Esc")&&t._popover&&t._popover.hasAttribute("open")&&(e.preventDefault(),e.stopPropagation(),typeof t._popover.close=="function"&&t._popover.close())},document.addEventListener("keydown",this._focusTrapHandler,!0),document.addEventListener("keydown",this._escapeHandler,!0),requestAnimationFrame(()=>{const e=this._getFocusableElements();e.length>0&&e[0].focus()})}_removeFocusTrap(){this._focusTrapHandler&&(document.removeEventListener("keydown",this._focusTrapHandler,!0),this._focusTrapHandler=null),this._escapeHandler&&(document.removeEventListener("keydown",this._escapeHandler,!0),this._escapeHandler=null)}}customElements.get("mint-date-picker")||customElements.define("mint-date-picker",Et);class wt extends HTMLElement{constructor(){super(),this._select=null,this._wrapper=null,this._caretUpIcon=null,this._caretDownIcon=null,this._changeHandler=null,this._optionObserver=null,this._childrenObserver=null}static get observedAttributes(){return["name","value","disabled","id","required","label","info","error","error-message","multiple","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block","w-full"),this.getLabel()||console.error('mint-select: The "label" attribute is required. Please provide a label for the select.'),this.render(),this._childrenObserver&&this._childrenObserver.disconnect(),this._childrenObserver=new MutationObserver(e=>{e.some(s=>{const n=Array.from(s.addedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP"))||Array.from(s.removedNodes).some(a=>a.nodeType===Node.ELEMENT_NODE&&(a.tagName==="OPTION"||a.tagName==="OPTGROUP")),r=s.type==="attributes"&&s.target.nodeType===Node.ELEMENT_NODE&&(s.target.tagName==="OPTION"||s.target.tagName==="OPTGROUP");return n||r})&&requestAnimationFrame(()=>{this.render()})}),this._childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value","selected","disabled"]})}disconnectedCallback(){this._select&&this._changeHandler&&(this._select.removeEventListener("change",this._changeHandler),this._changeHandler=null),this._optionObserver&&(this._optionObserver.disconnect(),this._optionObserver=null),this._childrenObserver&&(this._childrenObserver.disconnect(),this._childrenObserver=null)}isLoading(){return this.getAttribute("loading")==="true"}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._renderErrorState(),this._select&&(this._select.className=this.getSelectClasses(),this._select.setAttribute("aria-invalid",this.hasError()?"true":"false"));return}if(t==="loading"){this.render();return}if(t==="value"){this._select&&(this._select.value=i||"");return}this.render()}}getName(){return this.getAttribute("name")||""}getValue(){return this.hasAttribute("value")?this.getAttribute("value")||"":this._select?this._select.value:""}setValue(t){const e=t||"";this.setAttribute("value",e),this._select&&(this._select.value=e)}get value(){try{return this.getValue()||""}catch{return""}}set value(t){try{const e=t||"";(this.getAttribute("value")||"")!==e&&this.setAttribute("value",e),this._select&&requestAnimationFrame(()=>{this._select&&(e===""||Array.from(this._select.options).some(n=>n.value===e))&&this._select.value!==e&&(this._select.value=e)})}catch{}}isDisabled(){return this.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(){const t=this.hasError(),e=this.isMultiple(),i=["w-full","px-3.5",e?"pr-3.5":"pr-10",e?"py-2":"py-1.5",e?"min-h-[6rem]":"min-h-[2rem]","text-sm","font-medium","rounded-lg","box-border","bg-white","dark:bg-gray-900","text-gray-900","dark:text-white","transition-all","duration-200","outline-none","focus:outline-none","disabled:opacity-40","disabled:cursor-not-allowed","appearance-none","bg-no-repeat","bg-right","cursor-pointer"],s=["border-2",t?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700"],n=["focus-visible:ring-2","focus-visible:ring-offset-1",t?"focus-visible:ring-red-400 dark:focus-visible:ring-red-500":"focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500"];return[...i,...s,...n].filter(Boolean).join(" ")}render(){const t=this.isLoading(),e=[];this._select&&Array.from(this._select.children).forEach(d=>{(d.tagName==="OPTION"||d.tagName==="OPTGROUP")&&e.push(d.cloneNode(!0))});const i=Array.from(this.children).filter(d=>d.tagName==="OPTION"||d.tagName==="OPTGROUP").map(d=>d.cloneNode(!0));for(;this.firstChild;)this.removeChild(this.firstChild);this._wrapper=null,this._select=null;const s=this.getLabel(),n=this.getInfo(),r=this.getId(),a=this.getName(),o=this.getValue(),l=this.isDisabled(),c=this.isMultiple(),h=this.hasError();if(s){const d=document.createElement("label");d.className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",r&&d.setAttribute("for",r);const u=document.createTextNode(s);d.appendChild(u),this.appendChild(d)}this._wrapper=document.createElement("div"),this._wrapper.className="relative w-full",this.appendChild(this._wrapper),this._select=document.createElement("select"),this._select.className=this.getSelectClasses(),r&&(this._select.id=r),a&&(this._select.name=a),l&&(this._select.disabled=!0),c&&(this._select.multiple=!0),this._select.setAttribute("aria-invalid",h?"true":"false");const p=i.length>0?i:e;if(p.length>0&&p.forEach(d=>{this._select.appendChild(d)}),this._select.options.length===0){const d=document.createElement("option");d.value="",d.textContent="Select an option",d.disabled=!0,d.selected=!0,this._select.appendChild(d)}if(this._select.value=o||"",this._changeHandler&&this._select&&this._select.removeEventListener("change",this._changeHandler),this._changeHandler=d=>{const m=d.target.value;(this.getAttribute("value")||"")!==m&&(m?this.setAttribute("value",m):this.removeAttribute("value"));const g=new Event("input",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(g),this.dispatchEvent(new CustomEvent("input",{detail:{value:m},bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{value:m},bubbles:!0,cancelable:!0,composed:!0}))},this._select.addEventListener("change",this._changeHandler),this._optionObserver&&this._optionObserver.disconnect(),this._optionObserver=new MutationObserver(()=>{const d=this.getAttribute("value")||this.value||"";this._select&&d&&requestAnimationFrame(()=>{this._select&&Array.from(this._select.options).some(m=>m.value===d)&&this._select.value!==d&&(this._select.value=d)})}),this._optionObserver.observe(this._select,{childList:!0,subtree:!0}),this._wrapper.appendChild(this._select),c)this._caretUpIcon=null,this._caretDownIcon=null;else{const d=document.createElement("div");d.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]",d.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]",d.appendChild(this._caretDownIcon),this._wrapper.appendChild(d)}if(n){const d=document.createElement("div");d.className="mt-1 text-xs text-gray-500 dark:text-gray-400",d.textContent=n,this.appendChild(d)}this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){let e=this.querySelector(".mint-select-skeleton-container");const i=this._wrapper;if(t){e||(e=document.createElement("div"),e.className="mint-select-skeleton-container absolute inset-0 z-10 pointer-events-none",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-select-skeleton");if(!s){s=document.createElement("div"),s.className="mint-select-skeleton w-full rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse";const n=this.isMultiple();s.style.height=n?"6rem":"2.25rem",e.appendChild(s)}e.style.display="block",this._select&&(this._select.style.opacity="0",this._select.style.pointerEvents="none")}else e&&(e.style.display="none"),this._select&&(this._select.style.opacity="1",this._select.style.pointerEvents="auto")}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-select-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-select-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}}customElements.get("mint-select")||customElements.define("mint-select",wt);class Ct extends HTMLElement{constructor(){super(),this._dropzone=null,this._fileInput=null,this._previewContainer=null,this._isDragging=!1,this._wasDragging=!1,this._isUpdatingFiles=!1,this._listenersInitialized=!1,this._selectedFiles=[],this._previewUrls=[],this._resetHandler=null}static get observedAttributes(){return["label","accept","multiple","width","height","disabled","name","error","error-message","loading"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","inline-block"),this.render(),this._attachFormResetListener()}disconnectedCallback(){if(this.removeEventListeners(),this._cleanupPreviewUrls(),this._resetHandler){const t=this.closest("form");t&&t.removeEventListener("reset",this._resetHandler),this._resetHandler=null}}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){this._updateDragStateClass(),this._renderErrorState(this.hasError(),this.getErrorMessage());return}if(t==="loading"){this.render();return}this.render()}}getLabel(){return this.getAttribute("label")||""}getAccept(){return this.getAttribute("accept")||""}isMultiple(){return this.getAttribute("multiple")==="true"}getWidth(){return this.getAttribute("width")||"200px"}getHeight(){return this.getAttribute("height")||"200px"}_renderSkeleton(t){let e=this.querySelector(".mint-dropzone-skeleton-container");const i=this._dropzone;if(t){e||(e=document.createElement("div"),e.className="mint-dropzone-skeleton-container absolute inset-0 z-10 pointer-events-none flex items-center justify-center",i?(i.classList.contains("relative")||i.classList.add("relative"),i.appendChild(e)):(this.style.position="relative",this.appendChild(e)));let s=e.querySelector(".mint-dropzone-skeleton");if(s||(s=document.createElement("div"),s.className="mint-dropzone-skeleton rounded-lg border-2 border-dashed border-gray-300 dark:border-gray-600 bg-gray-200 dark:bg-gray-700 animate-pulse",s.style.width="100%",s.style.height="100%",e.appendChild(s)),e.style.display="flex",i){const n=i.querySelector(".mint-dropzone-icon"),r=i.querySelector(".mint-dropzone-label"),a=i.querySelector(".mint-dropzone-previews-wrapper"),o=this._fileInput;if(n){const l=n;l.style.visibility="hidden",l.style.pointerEvents="none"}if(r){const l=r;l.style.visibility="hidden",l.style.pointerEvents="none"}if(a){const l=a;l.style.visibility="hidden",l.style.pointerEvents="none"}o&&(o.style.visibility="hidden",o.style.pointerEvents="none"),i.style.pointerEvents="none"}}else if(e&&(e.style.display="none"),i){const s=i.querySelector(".mint-dropzone-icon"),n=i.querySelector(".mint-dropzone-label"),r=i.querySelector(".mint-dropzone-previews-wrapper"),a=this._fileInput;if(s){const o=s;o.style.visibility="visible",o.style.pointerEvents="auto"}if(n){const o=n;o.style.visibility="visible",o.style.pointerEvents="auto"}if(r){const o=r;o.style.visibility="visible",o.style.pointerEvents="auto"}a&&(a.style.visibility="visible",a.style.pointerEvents="auto"),i.style.pointerEvents="auto"}}getName(){return this.getAttribute("name")||""}hasError(){return this.getAttribute("error")==="true"}getErrorMessage(){return this.getAttribute("error-message")||""}isDisabled(){return this.getAttribute("disabled")==="true"}isLoading(){return this.getAttribute("loading")==="true"}render(){const t=this.isLoading(),e=this.getLabel(),i=this.getAccept(),s=this.isMultiple(),n=this.isDisabled(),r=this.getWidth(),a=this.getHeight(),o=this.getName(),l=this.hasError(),c=this.getErrorMessage();this._dropzone||(this._dropzone=document.createElement("div"),this.appendChild(this._dropzone)),this._updateDragStateClass(),this._dropzone.setAttribute("aria-invalid",l?"true":"false"),n?(this._dropzone.setAttribute("tabindex","-1"),this._dropzone.removeAttribute("role")):(this._dropzone.setAttribute("tabindex","0"),this._dropzone.setAttribute("role","button"),this._dropzone.setAttribute("aria-label",e||"File upload dropzone")),this._dropzone.style.width=r,this._dropzone.style.height=a,this._dropzone.style.minWidth=r,this._dropzone.style.minHeight=a,this._fileInput||(this._fileInput=document.createElement("input"),this._fileInput.type="file",this._fileInput.style.display="none",this._fileInput.setAttribute("tabindex","-1"),this._fileInput.setAttribute("aria-hidden","true"),this._dropzone.appendChild(this._fileInput)),this._fileInput.accept=i,this._fileInput.multiple=s,this._fileInput.disabled=n,o?this._fileInput.name=o:this._fileInput.removeAttribute("name"),this._fileInput.setAttribute("aria-invalid",l?"true":"false");const h=this._dropzone.querySelector(".mint-dropzone-icon"),p=this._dropzone.querySelector(".mint-dropzone-label");h&&h.remove(),p&&p.remove();const d=document.createElement("div");d.className="mint-dropzone-icon flex items-center justify-center mt-2 mb-2 flex-shrink-0";const u=document.createElement("mint-icon");if(u.setAttribute("name","upload"),u.className="w-12 h-12 text-gray-400 dark:text-gray-500",d.appendChild(u),this._dropzone.appendChild(d),e){const m=document.createElement("div");m.className="mint-dropzone-label text-sm font-medium text-gray-600 dark:text-gray-400 text-center px-4 flex-shrink-0",m.textContent=e,this._dropzone.appendChild(m)}this.setupEventListeners(),this._renderErrorState(l,c),this._renderPreviews(),this._renderSkeleton(t)}_updateDragState(){this._dropzone&&this._updateDragStateClass()}_renderErrorState(t,e){let i=this.querySelector(".mint-dropzone-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-dropzone-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_updateDragStateClass(){if(!this._dropzone)return;const t=this.isDisabled(),e=this.hasError(),n=`relative border-2 border-dashed rounded-lg transition-all duration-200 flex flex-col items-center ${this._selectedFiles.length>0?"justify-start":"justify-center"} cursor-pointer overflow-hidden`,r=this._isDragging?"border-gray-400 dark:border-gray-500 bg-gray-50 dark:bg-gray-900 dark:border-gray-700":"border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-900 dark:border-gray-700 hover:border-gray-400 dark:hover:border-gray-500",a=e?"border-red-300 dark:border-red-300 bg-red-50/50 dark:bg-red-900/30":"",o=t?"opacity-40 cursor-not-allowed":"",l="focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-1 focus-visible:ring-gray-400 dark:focus-visible:ring-gray-500";this._dropzone.className=`${n} ${e?a:r} ${o} ${l}`.trim()}setupEventListeners(){this._listenersInitialized||(this._listenersInitialized=!0,this.removeEventListeners(),!(!this._dropzone||!this._fileInput||this.isDisabled())&&(this._onDropzoneClick||(this._onDropzoneClick=t=>{if(!(this.isDisabled()||!this._fileInput)&&t.target!==this._fileInput&&(t.stopPropagation(),t.preventDefault(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onDragOver||(this._onDragOver=t=>{t.preventDefault(),t.stopPropagation(),this.isDisabled()||this._isDragging||(this._isDragging=!0,this._wasDragging=!0,this._updateDragState())}),this._onDragLeave||(this._onDragLeave=t=>{var i;t.preventDefault(),t.stopPropagation();const e=(i=this._dropzone)==null?void 0:i.getBoundingClientRect();e&&(t.clientX<e.left||t.clientX>e.right||t.clientY<e.top||t.clientY>e.bottom)&&this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState())}),this._onDrop||(this._onDrop=t=>{var i;if(t.preventDefault(),t.stopPropagation(),this._isDragging&&(this._isDragging=!1,this._wasDragging=!1,this._updateDragState()),this.isDisabled())return;const e=(i=t.dataTransfer)==null?void 0:i.files;e&&e.length>0&&this._handleFiles(e)}),this._onFileInputInput||(this._onFileInputInput=t=>{t.stopImmediatePropagation(),t.stopPropagation()}),this._onKeyDown||(this._onKeyDown=t=>{if(!(this.isDisabled()||!this._fileInput)&&(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),t.stopPropagation(),t.isTrusted))try{this._fileInput.click()}catch(e){console.debug("File chooser blocked:",e)}}),this._onFocus||(this._onFocus=t=>{this._dropzone&&!this.isDisabled()&&this._dropzone.classList.add("focus-visible:ring-2")}),this._onBlur||(this._onBlur=t=>{this._dropzone}),this._onFileInputChange||(this._onFileInputChange=t=>{if(t.stopImmediatePropagation(),t.stopPropagation(),this._isUpdatingFiles)return;const i=t.target.files;if(i&&i.length>0){const s=this.getAccept(),n=this.isMultiple(),r=[],a=[];for(let o=0;o<i.length;o++){const l=i[o];this._isFileAccepted(l,s)?r.push(l):a.push(l)}if(!n&&r.length>1&&(a.push(...r.slice(1)),r.splice(1)),a.length>0){const o=new CustomEvent("dropRejected",{detail:{files:a,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(o)}r.length>0&&this._applyValidFiles(r)}}),this._dropzone.addEventListener("click",this._onDropzoneClick),this._dropzone.addEventListener("dragover",this._onDragOver),this._dropzone.addEventListener("dragleave",this._onDragLeave),this._dropzone.addEventListener("drop",this._onDrop),this._dropzone.addEventListener("keydown",this._onKeyDown),this._dropzone.addEventListener("focus",this._onFocus),this._dropzone.addEventListener("blur",this._onBlur),this._fileInput.addEventListener("change",this._onFileInputChange),this._fileInput.addEventListener("input",this._onFileInputInput,!0)))}removeEventListeners(){this._dropzone&&(this._onDropzoneClick&&this._dropzone.removeEventListener("click",this._onDropzoneClick),this._onDragOver&&this._dropzone.removeEventListener("dragover",this._onDragOver),this._onDragLeave&&this._dropzone.removeEventListener("dragleave",this._onDragLeave),this._onDrop&&this._dropzone.removeEventListener("drop",this._onDrop),this._onKeyDown&&this._dropzone.removeEventListener("keydown",this._onKeyDown),this._onFocus&&this._dropzone.removeEventListener("focus",this._onFocus),this._onBlur&&this._dropzone.removeEventListener("blur",this._onBlur)),this._fileInput&&(this._onFileInputChange&&this._fileInput.removeEventListener("change",this._onFileInputChange),this._onFileInputInput&&this._fileInput.removeEventListener("input",this._onFileInputInput,!0)),this._isDragging=!1,this._listenersInitialized=!1}_handleFiles(t){const e=this.getAccept(),i=this.isMultiple(),s=[],n=[];for(let r=0;r<t.length;r++){const a=t[r];this._isFileAccepted(a,e)?s.push(a):n.push(a)}if(!i&&s.length>1&&(n.push(...s.slice(1)),s.splice(1)),n.length>0){const r=new CustomEvent("dropRejected",{detail:{files:n,reason:"File type not accepted or multiple files not allowed"},bubbles:!0,cancelable:!0});this.dispatchEvent(r)}s.length>0&&this._applyValidFiles(s)}_isFileAccepted(t,e){var s;if(!e)return!0;const i=e.split(",").map(n=>n.trim().toLowerCase());for(const n of i)if(n.startsWith(".")){if("."+((s=t.name.split(".").pop())==null?void 0:s.toLowerCase())===n)return!0}else if(n.includes("/*")){const r=n.split("/")[0],a=t.type.split("/")[0];if(r===a)return!0}else if(t.type===n)return!0;return!1}_dispatchEvent(t,e){const i=e.target,s=new CustomEvent(t,{detail:{files:i.files?Array.from(i.files):[],value:i.value||""},bubbles:!0,cancelable:!0});this.dispatchEvent(s)}_dispatchSelectionEvents(){const e={files:[...this._selectedFiles],value:""};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,cancelable:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,cancelable:!0,composed:!0}))}_syncFileInputFromSelected(){if(!this._fileInput)return;const t=new DataTransfer;this._selectedFiles.forEach(e=>{try{t.items.add(e)}catch(i){console.warn("Failed to add file to DataTransfer:",i)}}),this._isUpdatingFiles=!0;try{this._fileInput.files=t.files}catch(e){console.warn("Failed to set files on input:",e)}setTimeout(()=>{this._isUpdatingFiles=!1},0)}get files(){var t;return this._syncFileInputFromSelected(),((t=this._fileInput)==null?void 0:t.files)||null}syncFiles(){this._syncFileInputFromSelected()}_renderPreviews(){if(!this._dropzone)return;if(this._previewContainer&&(this._cleanupPreviewUrls(),this._previewContainer.remove()),this._selectedFiles.length===0){this._previewContainer=null,this._updateDragStateClass();return}const t=document.createElement("div");t.className="mint-dropzone-previews-wrapper mt-3 w-full relative max-h-48";const e=document.createElement("div");e.className="mint-dropzone-previews w-full flex flex-col gap-2 max-h-48 overflow-y-auto overflow-x-hidden px-2 pb-2",this._selectedFiles.forEach((l,c)=>{const h=document.createElement("div");if(h.className="flex items-center gap-3 p-2 rounded border border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-900",l.type.startsWith("image/")){const m=document.createElement("img");m.className="w-12 h-12 object-cover rounded border border-gray-200 dark:border-gray-700";const f=URL.createObjectURL(l);this._previewUrls.push(f),m.src=f,h.appendChild(m)}else{const m=document.createElement("mint-icon");m.setAttribute("name","attach"),m.className="w-5 h-5 text-gray-500 dark:text-gray-300",h.appendChild(m)}const p=document.createElement("div");p.className="flex-1 text-sm text-gray-800 dark:text-gray-100 truncate",p.textContent=l.name,h.appendChild(p);const d=document.createElement("button");d.type="button",d.className="text-gray-500 hover:bg-red-100 dark:hover:bg-red-900/30 transition-colors flex items-center justify-center w-6 h-6 rounded-full";const u=document.createElement("mint-icon");u.setAttribute("name","close"),u.className="w-4 h-4",d.appendChild(u),d.addEventListener("click",m=>{m.preventDefault(),m.stopPropagation(),this._removeFileAt(c)}),h.appendChild(d),e.appendChild(h)});const i=this.hasError(),s=this._isDragging;let n="from-white dark:from-gray-700";i?n="from-red-50 dark:from-red-900/30":s&&(n="from-gray-50 dark:from-gray-800");const r=document.createElement("div");r.className=`absolute top-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-b ${n} to-transparent opacity-0 transition-opacity duration-200`,t.appendChild(r);const a=document.createElement("div");a.className=`absolute bottom-0 left-0 right-0 h-4 pointer-events-none z-10 bg-gradient-to-t ${n} to-transparent opacity-100 transition-opacity duration-200`,t.appendChild(a);const o=()=>{const l=e.scrollTop,c=e.scrollHeight,h=e.clientHeight;l>0?r.style.opacity="1":r.style.opacity="0",l+h<c-1?a.style.opacity="1":a.style.opacity="0"};o(),e.addEventListener("scroll",o),t.appendChild(e),this._previewContainer=t,this._dropzone.appendChild(t),this._updateDragStateClass()}_removeFileAt(t){if(t<0||t>=this._selectedFiles.length)return;const[e]=this._selectedFiles.splice(t,1);e&&this._cleanupPreviewUrls(),this._syncFileInputFromSelected(),this._renderPreviews(),this._dispatchSelectionEvents()}_cleanupPreviewUrls(){this._previewUrls.forEach(t=>URL.revokeObjectURL(t)),this._previewUrls=[]}_attachFormResetListener(){const t=this.closest("form");!t||this._resetHandler||(this._resetHandler=()=>{this._selectedFiles=[],this._syncFileInputFromSelected(),this._renderPreviews(),this._cleanupPreviewUrls()},t.addEventListener("reset",this._resetHandler))}_applyValidFiles(t){if(this.isMultiple()){const i=t.filter(s=>!this._isDuplicateFile(s));this._selectedFiles.push(...i)}else this._selectedFiles=[t[0]];this._syncFileInputFromSelected(),this._selectedFiles.length>0&&(this.removeAttribute("error"),this.removeAttribute("error-message"),this._fileInput&&this._fileInput.removeAttribute("aria-invalid")),this._renderPreviews(),this._dispatchSelectionEvents()}_isDuplicateFile(t){return this._selectedFiles.some(e=>e.name===t.name&&e.size===t.size&&e.lastModified===t.lastModified)}}customElements.get("mint-dropzone")||customElements.define("mint-dropzone",Ct);class At extends HTMLElement{constructor(){super(),this._form=null,this._submitHandler=null,this._hostSubmitHandler=null,this._errors={},this._fieldBlurHandlers=new Map,this._fieldChangeHandlers=new Map,this._observer=null,this._formData=null,this._headers=null,this._buttonStates=new Map,this._reactiveDataProxy=null,this._reactiveDataObserver=null,this._lastDataSnapshot=null}static get observedAttributes(){return["action","method","enctype","data-form-data","loading","headers"]}connectedCallback(){this._render(),this._ensureSubmitHandler(),this._setupBlurValidation();const t=this.getAttribute("headers");t&&this._parseHeaders(t),requestAnimationFrame(()=>{requestAnimationFrame(()=>{if(this._formData)this._isReactiveObject(this._formData)?this._setupReactiveDataObserver(this._formData):this._lastDataSnapshot||(this._lastDataSnapshot=this._createDataSnapshot(this._formData)),this._applyFormData();else{const e=this.getAttribute("data-form-data");e&&(this._parseFormData(e),this._applyFormData())}this._propagateLoadingState()})})}disconnectedCallback(){this._form&&this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._hostSubmitHandler&&this.removeEventListener("submit",this._hostSubmitHandler),this._cleanupBlurValidation(),this._stopReactiveDataObserver()}reset(){this._clearErrors(),this._formData?this._applyFormData():this.clear()}clear(){this._clearErrors(),this._form&&this._form.reset(),this._resetCustomFields()}attributeChangedCallback(t,e,i){t==="form-data"?(this._parseFormData(i),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})):t==="headers"?this._parseHeaders(i):t==="loading"?this.isConnected&&this._form?requestAnimationFrame(()=>{this._propagateLoadingState()}):this._propagateLoadingState():this._applyFormAttributes()}get data(){return this._formData}set data(t){this._stopReactiveDataObserver(),this._reactiveDataProxy=null,this._lastDataSnapshot=null,t&&typeof t=="object"&&!Array.isArray(t)?(this._formData=t,this._isReactiveObject(t)?this._setupReactiveDataObserver(t):this._lastDataSnapshot=this._createDataSnapshot(t)):t==null?this._formData=null:this._parseFormData(t),this.isConnected&&this._form&&requestAnimationFrame(()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{this._applyFormData()})})})}get headers(){return this._headers}set headers(t){if(t&&typeof t=="object"&&!Array.isArray(t))this._headers=t;else if(t==null)this._headers=null;else if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_render(){if(this.classList.add("block","w-full"),!this._form){for(this._form=document.createElement("form"),this._form.noValidate=!0;this.firstChild;)this._form.appendChild(this.firstChild);this.appendChild(this._form)}this._ensureSubmitHandler(),this._applyFormAttributes()}_ensureSubmitHandler(){this._form&&(this._submitHandler&&this._form.removeEventListener("submit",this._submitHandler,!0),this._submitHandler=t=>{t.preventDefault(),t.stopImmediatePropagation(),this._handleSubmit(t)},this._form.addEventListener("submit",this._submitHandler,!0))}_applyFormAttributes(){if(!this._form)return;const t=this.getAttribute("action")||"",e=this.getAttribute("method")||"",i=this.getAttribute("enctype")||"application/x-www-form-urlencoded";t&&(this._form.action=t),e&&(this._form.method=e),this._form.enctype=i}async _handleSubmit(t){var c;if(t.preventDefault(),!this._form)return;this._clearErrors(),this._syncDropzoneFiles();const e=this._collectValidationRules(),i=new FormData(this._form);let s=this._formDataToValues(i);if(this._formData){const h=this._getReactiveValue(this._formData);h&&typeof h=="object"&&!Array.isArray(h)&&(s={...this._extractReactiveData(h),...s})}if(!this._validate(s,e)){this.dispatchEvent(new CustomEvent("invalid",{detail:{errors:this._errors},bubbles:!0,cancelable:!0,composed:!0}));return}const r=new CustomEvent("submit",{detail:{formData:i,values:s,form:this},bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(r),r.form=this;const a=new CustomEvent("mintFormSubmit",{detail:{formData:i,values:s,form:this},bubbles:!0,cancelable:!0,composed:!0});if(a.form=this,this.dispatchEvent(a),r.defaultPrevented||a.defaultPrevented)return;const o=this.getAttribute("action"),l=this.getAttribute("method");if(!(!o||!l)){this._setButtonsSubmitting();try{const h=await this._submitData(i,s);this.dispatchEvent(new CustomEvent("submitsuccess",{detail:h,bubbles:!0,cancelable:!0}))}catch(h){(h==null?void 0:h.status)===422&&((c=h==null?void 0:h.data)!=null&&c.errors)&&this._applyServerErrors(h.data.errors),this.dispatchEvent(new CustomEvent("submiterror",{detail:{error:h},bubbles:!0,cancelable:!0}))}finally{this._restoreButtonsState()}}}async _submitData(t,e){var h,p,d;const i=this.getAttribute("action"),s=this.getAttribute("method"),n=this.getAttribute("enctype")||"application/x-www-form-urlencoded";if(!i)return{status:0,ok:!0,data:{values:e}};const r=Array.from(t.values()).some(u=>u instanceof File);let a=null;const o={};let l=i;if(typeof window<"u"&&((d=(p=(h=window.mintForm)==null?void 0:h.defaults)==null?void 0:p.headers)!=null&&d.common)&&Object.assign(o,window.mintForm.defaults.headers.common),this._headers&&Object.assign(o,this._headers),s==="GET"){const u=new URLSearchParams;t.forEach((m,f)=>{m instanceof File||u.append(f,String(m))}),l+=(i.includes("?")?"&":"?")+u.toString()}else if(n==="multipart/form-data"||r)a=t;else if(n==="application/json")a=JSON.stringify(e),o["Content-Type"]="application/json";else{const u=new URLSearchParams;t.forEach((m,f)=>{m instanceof File||u.append(f,String(m))}),a=u,o["Content-Type"]="application/x-www-form-urlencoded"}if(typeof fetch=="function")try{const u=await fetch(l,{method:s||"POST",body:s==="GET"?null:a,headers:o}),m=await u.text().catch(()=>"");let f=m;try{f=JSON.parse(m)}catch{}if(!u.ok){const _={status:u.status,data:f,response:{status:u.status,data:f}};throw await this._applyErrorInterceptors(_)}const g={status:u.status,ok:u.ok,data:f};return await this._applySuccessInterceptors(g)}catch(u){if(u.response)throw u;const m={status:u.status||0,data:u.data||u.message||"Network error",response:{status:u.status||0,data:u.data||u.message||"Network error"}};throw await this._applyErrorInterceptors(m)}const c=this;return await new Promise(async(u,m)=>{const f=new XMLHttpRequest;f.open(s||"POST",l,!0),Object.entries(o).forEach(([g,_])=>f.setRequestHeader(g,_)),f.onload=async function(){const{status:g,responseText:_}=f;if(g>=200&&g<300){let b=_;try{b=JSON.parse(_)}catch{}try{const v={status:g,ok:!0,data:b},y=await c._applySuccessInterceptors(v);u(y)}catch(v){m(v)}}else{let b=_;try{b=JSON.parse(_)}catch{}try{const v={status:g,data:b,response:{status:g,data:b}},y=await c._applyErrorInterceptors(v);m(y)}catch(v){m(v)}}},f.onerror=async function(){try{const g={status:f.status||0,data:f.responseText||"Network error",response:{status:f.status||0,data:f.responseText||"Network error"}},_=await c._applyErrorInterceptors(g);m(_)}catch(g){m(g)}},f.send(s==="GET"?null:a)})}async _applySuccessInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return t;let e=t;const i=window.mintForm.interceptors.response.handlers;for(const a of i)a.fulfilled&&(e=await a.fulfilled(e));return e}async _applyErrorInterceptors(t){var s,n,r;if(typeof window>"u"||!((r=(n=(s=window.mintForm)==null?void 0:s.interceptors)==null?void 0:n.response)!=null&&r.handlers))return Promise.reject(t);let e=t;const i=window.mintForm.interceptors.response.handlers;for(let a=i.length-1;a>=0;a--){const o=i[a];if(o.rejected)try{if(e=await o.rejected(e),e!==void 0)return e}catch(l){e=l}}return Promise.reject(e)}_formDataToValues(t){const e={};return t.forEach((i,s)=>{i instanceof File?(e[s]||(e[s]=[]),e[s].push(i)):s in e?Array.isArray(e[s])?(e[s].length>0&&e[s][0]instanceof File,e[s].push(i)):e[s]=[e[s],i]:e[s]=i}),this._form&&(Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(r=>{const a=r.getAttribute("name");if(a&&typeof r.files<"u"&&r.files){const o=r.files;if(o.length>0){const l=Array.from(o);e[a]&&Array.isArray(e[a])?l.forEach(c=>{e[a].some(p=>p.name===c.name&&p.size===c.size&&p.lastModified===c.lastModified)||e[a].push(c)}):e[a]=l}}}),Array.from(this._form.querySelectorAll('input[type="file"][name]')).forEach(r=>{const a=r.name;if(a&&r.files&&r.files.length>0){const o=Array.from(r.files);e[a]&&Array.isArray(e[a])?o.forEach(l=>{e[a].some(h=>h.name===l.name&&h.size===l.size&&h.lastModified===l.lastModified)||e[a].push(l)}):e[a]=o}}),Array.from(this._form.querySelectorAll("mint-tags[name]")).forEach(r=>{const a=r.getAttribute("name");if(a){let o=[];if(typeof r.tags<"u"?o=r.tags:typeof r.getTags=="function"&&(o=r.getTags()),Array.isArray(o)&&o.length>0){const l=o.map(c=>typeof c=="string"?c:(c==null?void 0:c.value)||(c==null?void 0:c.label)||"").filter(c=>c.trim()!=="");e[a]=l}else e[a]=[]}})),e}_collectValidationRules(){const t={};return this._form&&Array.from(this._form.querySelectorAll("[name][validation]")).forEach(i=>{const s=i.getAttribute("name")||"",n=i.getAttribute("validation");if(!s||!n)return;const r=this._parseRules(n);r.length&&(t[s]=r)}),t}_parseRules(t){if(!t)return[];try{const e=t.replace(/'/g,'"'),i=JSON.parse(e);if(Array.isArray(i))return i.map(s=>String(s))}catch{}return t.split(",").map(e=>e.trim()).filter(Boolean)}_validate(t,e){let i=!0;return this._errors={},Object.entries(e||{}).forEach(([s,n])=>{const r=Array.isArray(n)?n:[n],a=this._getFieldElements(s),o=this._extractFieldValue(a),l=this._validateRules(o,r);l?(i=!1,this._errors[s]=l,this._flagFieldError(a,l)):this._clearFieldError(a)}),i}_validateField(t){const e=this._collectValidationRules();if(!e[t])return;const i=e[t],s=Array.isArray(i)?i:[i],n=this._getFieldElements(t),r=this._extractFieldValue(n),a=this._validateRules(r,s);a?(this._errors[t]=a,this._flagFieldError(n,a)):(this._clearFieldError(n),delete this._errors[t])}_validateRules(t,e){for(const i of e){const[s,n]=i.split(":");switch(s){case"required":{if(t==null||typeof t=="string"&&t.trim()===""||t instanceof FileList&&t.length===0||Array.isArray(t)&&t.length===0)return"This field is required.";break}case"string":{if(typeof t!="string")return"Must be a string.";break}case"email":{if(typeof t=="string"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t.trim()))return"Enter a valid email.";break}case"number":{const r=Number(t);if(Number.isNaN(r))return"Must be a number.";break}case"min":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length<r)return`Must be at least ${r} characters.`;if(Array.isArray(t)&&t.length<r)return`Select at least ${r}.`;if(t instanceof FileList&&t.length<r)return`Upload at least ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)<r)return`Must be at least ${r}.`;break}case"max":{const r=Number(n);if(Number.isNaN(r))break;if(typeof t=="string"&&t.trim().length>r)return`Must be at most ${r} characters.`;if(Array.isArray(t)&&t.length>r)return`Select no more than ${r}.`;if(t instanceof FileList&&t.length>r)return`Upload no more than ${r} files.`;if(t!=null&&!Number.isNaN(Number(t))&&Number(t)>r)return`Must be at most ${r}.`;break}}}return null}_getFieldElements(t){if(!this._form)return[];const e=Array.from(this._form.querySelectorAll(`[name="${t}"]`)),i=e.filter(r=>r.tagName==="MINT-SELECT");if(i.length>0){const r=[];return i.forEach(a=>{const o=a.querySelector('select[name="'+t+'"]');o&&r.push(o)}),e.filter(a=>a.tagName!=="MINT-SELECT").concat(r)}if(e.filter(r=>r.tagName==="MINT-TAGS").length>0)return e.filter(r=>r.tagName!=="INPUT"||!r.closest("mint-tags"));const n=e.filter(r=>r.tagName==="INPUT"&&r.closest("mint-tags"));if(n.length>0){const r=[];return n.forEach(a=>{const o=a.closest("mint-tags");o&&!r.includes(o)&&r.push(o)}),e.filter(a=>a.tagName!=="INPUT"||!a.closest("mint-tags")).concat(r)}return e}_extractFieldValue(t){if(t.length===0)return"";const e=t.find(s=>s instanceof HTMLSelectElement);if(e)return e.value;if(t.length>1){const s=t.filter(a=>a instanceof HTMLInputElement);if(s.length>0&&s.length===t.length){const a=s.filter(o=>o.checked);if(s.every(o=>o.type==="radio"))return a.length>0?a[0].value||"on":"";if(s.every(o=>o.type==="checkbox"))return a.map(o=>o.value||"on")}const n=t.filter(a=>a.tagName==="MINT-CHOICE");if(n.length>0&&n.length===t.length){const a=n.find(o=>typeof o.getValue=="function"?o.getValue()!=="":o.querySelector("mint-choice-option[checked]")!==null);if(a){if(typeof a.getValue=="function")return a.getValue();const o=a.querySelector("mint-choice-option[checked]");if(o)return o.getAttribute("value")||""}return""}const r=t.filter(a=>a.tagName==="MINT-CHECKBOX");if(r.length>0&&r.length===t.length)return r.filter(o=>typeof o.checked<"u"?o.checked:o.hasAttribute("checked")).map(o=>o.getAttribute("value")||"on")}const i=t[0];if(i instanceof HTMLInputElement)return i.type==="file"?i.files:i.type==="checkbox"||i.type==="radio"?i.checked?i.value||"on":"":i.value;if(i instanceof HTMLTextAreaElement)return i.value;if(i.tagName==="MINT-SELECT"){const s=i.querySelector("select");if(s)return s.value;if(typeof i.getValue=="function"){const r=i.getValue();if(r!=null&&r!=="")return r}const n=i.getAttribute("value");return n||""}if(i.tagName==="MINT-DROPZONE"&&typeof i.files<"u")return i.files;if(i.tagName==="MINT-TAGS"){let s=null;return typeof i.tags<"u"?s=i.tags:typeof i.getTags=="function"&&(s=i.getTags()),Array.isArray(s)?s.map(r=>typeof r=="string"?r:(r==null?void 0:r.value)||(r==null?void 0:r.label)||"").filter(r=>r.trim()!==""):[]}return i.tagName==="MINT-CHECKBOX"||i.tagName==="MINT-SWITCH"?(typeof i.checked<"u"?i.checked:i.hasAttribute("checked"))?i.getAttribute("value")||"on":"":i.tagName==="MINT-CHOICE"?(typeof i.getValue=="function"?i.getValue():"")||"":typeof i.value<"u"?i.value:i.getAttribute("value")||""}_flagFieldError(t,e){t.length!==0&&t.forEach(i=>{(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)&&i.setAttribute("aria-invalid","true");const s=this._resolveHost(i);s&&(s.setAttribute("error","true"),s.setAttribute("error-message",e),s.setAttribute("data-mint-form-error","true"))})}_clearFieldError(t){t.length!==0&&t.forEach(e=>{(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)&&e.removeAttribute("aria-invalid");const i=this._resolveHost(e);i&&(i.removeAttribute("error"),i.removeAttribute("error-message"),i.removeAttribute("data-mint-form-error"))})}_clearErrors(){this.querySelectorAll("[data-mint-form-error]").forEach(t=>{const e=t;e.removeAttribute("error"),e.removeAttribute("error-message"),e.removeAttribute("data-mint-form-error")}),this._form&&this._form.querySelectorAll('[aria-invalid="true"]').forEach(t=>{t.removeAttribute("aria-invalid")}),this._errors={}}setFormErrors(t){this._applyServerErrors(t)}_applyServerErrors(t){this._clearErrors(),Object.entries(t).forEach(([e,i])=>{const s=Array.isArray(i)?i[0]||"Validation error":i||"Validation error",n=this._getFieldElements(e);n.length>0&&(this._errors[e]=s,this._flagFieldError(n,s))})}_parseFormData(t){if(!t){this._formData=null;return}if(typeof t=="object"&&!Array.isArray(t)){this._formData=t;return}if(typeof t=="string")try{this._formData=JSON.parse(t)}catch{this._formData=null}else this._formData=null}_parseHeaders(t){if(!t){this._headers=null;return}if(typeof t=="string")try{this._headers=JSON.parse(t)}catch{this._headers=null}else this._headers=null}_applyFormData(){if(!this._formData||!this._form)return;const t=this._getReactiveValue(this._formData);if(!t||typeof t!="object"||Array.isArray(t))return;const e=()=>{Object.entries(t).forEach(([i,s])=>{const n=this._getFieldElements(i);if(n.length===0){setTimeout(()=>{const r=this._getFieldElements(i);r.length>0&&this._applyValueToField(r,i,s)},300);return}this._applyValueToField(n,i,s)})};requestAnimationFrame(()=>{requestAnimationFrame(()=>{e()})})}_applyValueToField(t,e,i){t.forEach(s=>{var r;const n=s.tagName;try{if(n==="MINT-INPUT")typeof s.value<"u"&&(s.value=i||"");else if(n==="MINT-DATE-PICKER")typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-SELECT"||n==="SELECT")n==="SELECT"?(r=s.closest("mint-select"))==null||r.setValue(i||""):typeof s.setValue=="function"&&s.setValue(i||"");else if(n==="MINT-CHOICE")typeof s.setValue=="function"?s.setValue(i||""):s.querySelectorAll("mint-choice-option").forEach(o=>{o.checked=o.getAttribute("value")===i});else if(n==="MINT-CHECKBOX"||n==="MINT-SWITCH"){const a=i===!0||i==="true"||i==="on"||i===1||i==="1";typeof s.checked<"u"?s.checked=a:a?s.setAttribute("checked","true"):s.removeAttribute("checked")}else n==="MINT-TAGS"?Array.isArray(i)&&typeof s.tags<"u"&&(s.tags=i.map(a=>typeof a=="string"?{value:a,label:a,dismissable:!0}:a)):s instanceof HTMLInputElement?s.type==="checkbox"||s.type==="radio"?s.checked=i===!0||i==="true"||i==="on"||i===1||i==="1":s.value=i||"":(s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement)&&(s.value=i||"")}catch(a){console.warn(`Failed to set value for field ${e}:`,a)}})}_resetCustomFields(){this.querySelectorAll("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags").forEach(e=>{var s,n;e.removeAttribute("error"),e.removeAttribute("error-message");const i=e.tagName;if(i==="MINT-INPUT")try{e.value=""}catch{}else if(i==="MINT-DATE-PICKER")try{(s=e.setValue)==null||s.call(e,"")}catch{}else if(i==="MINT-SELECT")try{(n=e.setValue)==null||n.call(e,"")}catch{}else if(i==="MINT-DROPZONE"){const r=e.querySelector('input[type="file"]');r&&(r.value="")}else if(i==="MINT-CHECKBOX"||i==="MINT-SWITCH")try{if(typeof e.checked<"u")e.checked=!1;else{e.removeAttribute("checked");const r=e.querySelector('input[type="checkbox"], input[type="radio"]');r&&(r.checked=!1)}}catch{}else if(i==="MINT-CHOICE")try{typeof e.setValue=="function"?e.setValue(""):e.querySelectorAll("mint-choice-option").forEach(a=>{a.checked=!1})}catch{}else if(i==="MINT-TAGS")try{e.tags=[]}catch{}})}_resolveHost(t){if(t.tagName==="MINT-CHOICE-OPTION"){const i=t.closest("mint-choice");if(i)return i}const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");return e||t}_setupBlurValidation(){if(!this._form)return;const t=i=>{const s=i.target;if(!s)return;const n=this._findFieldElement(s);if(!n)return;const r=this._getFieldName(n);if(!r||!this._collectValidationRules()[r])return;const o=this._extractFieldValue([n]),l=o!=null&&(typeof o=="string"?o.trim()!=="":o instanceof FileList||Array.isArray(o)?o.length>0:!0),c=n.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&(s.hasAttribute("aria-invalid")||s.closest("[data-mint-form-error]")),h=!!n.closest("mint-tags"),p=n.tagName==="MINT-CHECKBOX"||n.tagName==="MINT-SWITCH"||n.tagName==="MINT-CHOICE"||s instanceof HTMLElement&&(s.closest("mint-checkbox, mint-switch, mint-choice")||s.closest("mint-choice-option")),d=n.tagName==="MINT-DATE-PICKER"||s instanceof HTMLElement&&s.closest("mint-date-picker");(l||c||h||p||d)&&setTimeout(()=>{this._validateField(r)},0)};this._form.addEventListener("blur",t,!0),this._fieldBlurHandlers.set(this._form,t);const e=i=>{const s=i.target;if(!s)return;if(i.type==="tags-change"&&s.tagName==="MINT-TAGS"){const c=s,h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(s instanceof HTMLSelectElement||s.tagName==="MINT-SELECT"||s.closest("mint-select")){const c=this._findFieldElement(s);if(!c)return;const h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(i.type==="choice-change"&&s.tagName==="MINT-CHOICE"){const c=s,h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}if(s instanceof HTMLInputElement&&s.type==="checkbox"||s.tagName==="MINT-CHECKBOX"||s.tagName==="MINT-SWITCH"||s.closest("mint-checkbox, mint-switch")){const c=this._findFieldElement(s);if(!c)return;const h=this._getFieldName(c);if(!h||!this._collectValidationRules()[h])return;setTimeout(()=>{this._validateField(h)},0);return}const a=this._findFieldElement(s);if(!a)return;const o=this._getFieldName(a);!o||!this._collectValidationRules()[o]||(a.hasAttribute("data-mint-form-error")||s instanceof HTMLElement&&s.hasAttribute("aria-invalid"))&&setTimeout(()=>{this._validateField(o)},0)};this._form.addEventListener("change",e,!0),this._form.addEventListener("tags-change",e,!0),this._form.addEventListener("choice-change",e,!0),this._fieldChangeHandlers.set(this._form,e)}_findFieldElement(t){if(t.hasAttribute("name")&&(t.tagName.startsWith("MINT-")||t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement))return t;const e=t.closest("mint-input, mint-date-picker, mint-select, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags");if(e&&e.hasAttribute("name"))return e;if((t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.hasAttribute("name"))return t;let i=t;for(;i&&i!==this._form;){if(i.hasAttribute("name"))return i;i=i.parentElement}return null}_getFieldName(t){return t.hasAttribute("name")||t.tagName.startsWith("MINT-")?t.getAttribute("name"):(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement)&&t.name||null}_cleanupBlurValidation(){if(this._form&&this._fieldBlurHandlers.has(this._form)){const t=this._fieldBlurHandlers.get(this._form);t&&this._form.removeEventListener("blur",t,!0),this._fieldBlurHandlers.delete(this._form)}if(this._form&&this._fieldChangeHandlers.has(this._form)){const t=this._fieldChangeHandlers.get(this._form);t&&(this._form.removeEventListener("change",t,!0),this._form.removeEventListener("tags-change",t,!0),this._form.removeEventListener("choice-change",t,!0)),this._fieldChangeHandlers.delete(this._form)}this._observer&&(this._observer.disconnect(),this._observer=null)}_syncDropzoneFiles(){if(!this._form)return;Array.from(this._form.querySelectorAll("mint-dropzone[name]")).forEach(e=>{typeof e.syncFiles=="function"&&e.syncFiles()})}_propagateLoadingState(){if(!this._form)return;const t=this.getAttribute("loading"),e=t!==null&&t!=="false";Array.from(this._form.querySelectorAll("mint-input, mint-select, mint-date-picker, mint-dropzone, mint-checkbox, mint-choice, mint-switch, mint-tags")).forEach(s=>{e?s.setAttribute("loading","true"):s.removeAttribute("loading"),typeof s.render=="function"&&s.render()})}_setButtonsSubmitting(){if(!this._form)return;this._buttonStates.clear();const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=i.getAttribute("disabled")==="true",n=i.getAttribute("loading")==="true";this._buttonStates.set(i,{disabled:s,loading:n});const a=(i.getAttribute("type")||i.getAttribute("button-type")||"default")==="submit";s||i.setAttribute("disabled","true"),a&&i.setAttribute("loading","true"),typeof i.render=="function"&&i.render()}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=i.disabled;this._buttonStates.set(i,{disabled:s,loading:!1}),s||(i.disabled=!0)})}_restoreButtonsState(){if(!this._form)return;const t=Array.from(this.querySelectorAll("mint-button")),e=Array.from(this.querySelectorAll("button"));t.forEach(i=>{const s=this._buttonStates.get(i);s&&(s.disabled?i.setAttribute("disabled","true"):i.removeAttribute("disabled"),s.loading?i.setAttribute("loading","true"):i.removeAttribute("loading"),typeof i.render=="function"&&i.render())}),e.forEach(i=>{if(i.closest("mint-button"))return;const s=this._buttonStates.get(i);s&&(i.disabled=s.disabled)}),this._buttonStates.clear()}_isReactiveObject(t){if(!t||typeof t!="object"||Array.isArray(t))return!1;if("__v_isRef"in t||"_value"in t||"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t)return!0;try{const e=t.toString();if(e==="[object Object]"||e.includes("Proxy")){const i=Object.keys(t)[0];if(i){const s=Object.getOwnPropertyDescriptor(t,i);if(s&&(s.get||s.set))return!0}}}catch{return!0}return!0}_createDataSnapshot(t){try{const e=this._extractReactiveData(t);return JSON.parse(JSON.stringify(e))}catch{return{...this._extractReactiveData(t)}}}_extractReactiveData(t){if(!t||typeof t!="object")return t;if(Array.isArray(t))return t.map(i=>this._extractReactiveData(i));const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e)){const i={};for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(i[s]=this._extractReactiveData(e[s]));return i}return e}_hasDataChanged(t,e){try{return JSON.stringify(t)!==JSON.stringify(e)}catch{return!0}}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupReactiveDataObserver(t){if(this._stopReactiveDataObserver(),!this.isConnected)return;const e=this._getReactiveValue(t);if(e&&typeof e=="object"&&!Array.isArray(e))this._lastDataSnapshot=this._createDataSnapshot(e);else{this._lastDataSnapshot=null;return}const i=()=>{if(!this._formData||!this._lastDataSnapshot){this._stopReactiveDataObserver();return}const s=this._getReactiveValue(this._formData);if(s&&typeof s=="object"&&!Array.isArray(s)){const n=this._createDataSnapshot(s);this._hasDataChanged(n,this._lastDataSnapshot)&&(this._lastDataSnapshot=n,requestAnimationFrame(()=>{this._applyFormData()}))}this.isConnected&&this._formData?this._reactiveDataObserver=requestAnimationFrame(i):this._stopReactiveDataObserver()};this._reactiveDataObserver=requestAnimationFrame(i)}_stopReactiveDataObserver(){this._reactiveDataObserver!==null&&(cancelAnimationFrame(this._reactiveDataObserver),this._reactiveDataObserver=null),this._reactiveDataProxy=null,this._lastDataSnapshot=null}}customElements.get("mint-form")||customElements.define("mint-form",At);typeof window<"u"&&(window.mintForm=window.mintForm||{defaults:{headers:{common:{}}},interceptors:{response:{handlers:[]}}},window.mintForm.interceptors.response.use||(window.mintForm.interceptors.response.use=function(P,t){return window.mintForm.interceptors.response.handlers.push({fulfilled:P,rejected:t}),window.mintForm.interceptors.response.handlers.length-1}));class St extends HTMLElement{constructor(){super(...arguments),this._observer=null}static get observedAttributes(){return["collapse","scroll"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","align-baseline","block","w-full","overflow-x-auto"),this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._observeChanges(),this._applyStyles(),requestAnimationFrame(()=>{this._applyStyles(),setTimeout(()=>this._applyStyles(),0)})}disconnectedCallback(){this._observer&&(this._observer.disconnect(),this._observer=null)}attributeChangedCallback(){this.hasAttribute("collapse")&&!this.hasAttribute("scroll")&&this._ensureResponsiveStyles(),this._applyStyles()}_observeChanges(){this._observer=new MutationObserver(()=>this._applyStyles()),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!1})}_applyStyles(){this._observer&&this._observer.disconnect();const t=this.querySelector("table");if(!t){this._observer&&this._observeChanges();return}const e=this.hasAttribute("collapse")&&!this.hasAttribute("scroll"),i=this.hasAttribute("scroll");i?this.classList.add("relative"):this.classList.remove("relative");const s=[],n=t.querySelector("thead tr");n&&n.querySelectorAll("th").forEach(c=>s.push((c.textContent||"").trim())),this._setClasses(t,["w-full",i?"min-w-[1200px]":"","border-collapse","text-sm","font-medium","overflow-hidden"]);const r=t.querySelector("thead");if(r){this._setClasses(r,["bg-[#F7F7F7]","dark:bg-gray-800"]);const l=r.querySelectorAll("th");l.forEach((c,h)=>{const p=c.querySelector("mint-icon"),d=(p==null?void 0:p.getAttribute("name"))||"",u=p!==null&&d!=="ellipsis";this._setClasses(c,["text-left","font-semibold","text-gray-900","dark:text-white","px-3","py-2","border-b","border-gray-200","dark:border-gray-700"]),u&&c.classList.add("cursor-pointer","bg-[#F7F7F7]","dark:bg-gray-800","hover:bg-gray-100","dark:hover:bg-gray-700","transition-colors"),h===0&&c.classList.add("pl-6"),h===l.length-1&&c.classList.add("pr-6")})}const a=t.querySelector("tbody");if(a){const l=Array.from(a.querySelectorAll("tr"));l.forEach((c,h)=>{const p=c.hasAttribute("data-row-clickable");this._setClasses(c,["bg-white","dark:bg-gray-900","border-b","border-gray-200","dark:border-gray-700"]),p&&c.classList.add("cursor-pointer","hover:bg-gray-50","dark:hover:bg-gray-800","transition-colors"),h===l.length-1&&c.classList.remove("border-b");const d=c.querySelectorAll("td");d.forEach((u,m)=>{this._setClasses(u,["text-gray-900","dark:text-gray-100","px-3","py-2"]),m===0&&u.classList.add("pl-6"),m===d.length-1&&u.classList.add("pr-6"),e?this._applyMobileCell(u,s):this._restoreCell(u)})})}const o=t.querySelector("tfoot");o&&(this._setClasses(o,["bg-[#F7F7F7]","dark:bg-gray-800","font-semibold"]),o.querySelectorAll("td").forEach(c=>{this._setClasses(c,["text-gray-900","dark:text-gray-100","px-3","py-2","border-t","border-gray-200","dark:border-gray-700"]),this._restoreCell(c)})),this._observer&&this._observeChanges()}_applyMobileCell(t,e){if(t.closest("tfoot")||t.dataset.mtProcessed==="true")return;const i=e[t.cellIndex]||"",s={};Array.from(t.attributes).forEach(l=>{l.name.startsWith("data-")&&l.name!=="data-original"&&l.name!=="data-mt-processed"&&(s[l.name]=l.value)});const n=t.getAttribute("data-original"),r=n!==null?n:t.innerHTML;t.setAttribute("data-original",r),t.dataset.mtProcessed="true",t.innerHTML="";const a=document.createElement("span");a.className="mt-label font-semibold text-gray-700 dark:text-gray-200 hidden",a.textContent=i;const o=document.createElement("span");o.className="mt-value text-gray-900 dark:text-gray-100 text-right md:text-left w-full",o.innerHTML=r,t.appendChild(a),t.appendChild(o),Object.entries(s).forEach(([l,c])=>{t.setAttribute(l,c)})}_restoreCell(t){if(t.dataset.mtProcessed!=="true")return;const e={};Array.from(t.attributes).forEach(s=>{s.name.startsWith("data-")&&s.name!=="data-original"&&s.name!=="data-mt-processed"&&(e[s.name]=s.value)});const i=t.getAttribute("data-original")||"";t.dataset.mtProcessed="",t.innerHTML=i,Object.entries(e).forEach(([s,n])=>{t.setAttribute(s,n)})}_setClasses(t,e){t.className="",e.filter(Boolean).forEach(i=>t.classList.add(...i.split(" ")))}_ensureResponsiveStyles(){if(document.getElementById("mint-table-responsive-style"))return;const t=document.createElement("style");t.id="mint-table-responsive-style",t.textContent=`
83
- @media (max-width: 640px) {
84
- mint-table[collapse] {
85
- display: block;
86
- }
87
- mint-table[collapse] table {
88
- display: block;
89
- width: 100%;
90
- border-collapse: collapse;
91
- }
92
- mint-table[collapse] thead {
93
- display: none;
94
- }
95
- mint-table[collapse] tbody {
96
- display: block;
97
- width: 100%;
98
- }
99
- mint-table[collapse] tr {
100
- display: block;
101
- width: 100%;
102
- border-bottom: 1px solid #e5e7eb;
103
- padding: 0.5rem 0;
104
- }
105
- mint-table[collapse] tr:last-child {
106
- border-bottom: none;
107
- }
108
- mint-table[collapse] td,
109
- mint-table[collapse] th {
110
- display: flex;
111
- width: 100%;
112
- padding-top: 0.3rem !important;
113
- padding-bottom: 0.3rem !important;
114
- border: none;
115
- align-items: flex-start;
116
- justify-content: space-between;
117
- gap: 0.75rem;
118
- }
119
- mint-table[collapse] td .mt-label {
120
- display: inline-flex;
121
- flex: 1 1 50%;
122
- margin: 0;
123
- }
124
- mint-table[collapse] td .mt-value {
125
- display: inline-flex;
126
- flex: 1 1 50%;
127
- text-align: left;
128
- }
129
-
130
- /* Keep footer in normal table layout */
131
- mint-table[collapse] tfoot {
132
- display: table-footer-group;
133
- }
134
- mint-table[collapse] tfoot tr {
135
- display: table-row;
136
- border: none;
137
- padding: 0;
138
- }
139
- mint-table[collapse] tfoot td {
140
- display: table-cell;
141
- padding: 0.5rem 0.75rem;
142
- border: inherit;
143
- }
144
- }
145
- `,document.head.appendChild(t)}}customElements.get("mint-table")||customElements.define("mint-table",St);class Lt extends HTMLElement{constructor(){super(...arguments),this._root=null,this._textWrap=null,this._dismissBtn=null,this._clickHandler=null}static get observedAttributes(){return["dismissable"]}connectedCallback(){this._render()}disconnectedCallback(){this._dismissBtn&&this._clickHandler&&this._dismissBtn.removeEventListener("click",this._clickHandler)}attributeChangedCallback(){this._render()}_render(){var i;if(this.classList.add("inline-flex","items-center","gap-2","px-3","py-1","rounded-full","border","border-gray-200","dark:border-gray-700","bg-gray-100","dark:bg-gray-900","text-gray-900","dark:text-gray-100","text-sm","font-medium"),!this._root){for(this._root=document.createElement("div"),this._root.className="flex items-center gap-2 w-full",this._textWrap=document.createElement("span"),this._textWrap.className="inline-flex items-center min-w-[0.5rem]",this._textWrap.setAttribute("data-mt-chip-text","");this.firstChild;){const s=this.firstChild;if(s===this._root)break;this._textWrap.appendChild(s)}this._root.appendChild(this._textWrap),this.appendChild(this._root)}this.getAttribute("dismissable")==="true"?(this._dismissBtn||this._createDismissBtn(),this._dismissBtn&&!this._dismissBtn.isConnected&&((i=this._root)==null||i.appendChild(this._dismissBtn))):this._dismissBtn&&this._dismissBtn.parentElement===this._root&&this._dismissBtn.remove()}_createDismissBtn(){const t=document.createElement("button");t.type="button",t.setAttribute("aria-label","Dismiss"),t.className=["shrink-0","inline-flex","items-center","justify-center","w-5","h-5","rounded-full","text-gray-500","dark:text-gray-300","hover:text-gray-700","dark:hover:text-gray-100","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","transition-colors","duration-150","border-none","bg-transparent","cursor-pointer"].join(" ");const e=document.createElement("mint-icon");e.setAttribute("name","close"),e.className="w-3 h-3",t.appendChild(e),this._clickHandler=i=>{i.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0}))},t.addEventListener("click",this._clickHandler),this._dismissBtn=t}}customElements.get("mint-chip")||customElements.define("mint-chip",Lt);class Dt extends HTMLElement{constructor(){super(...arguments),this._container=null,this._chipsWrap=null,this._input=null,this._tags=[],this._placeholder="Add tag",this._dragIndex=null,this._dragChip=null,this._isPointerDragging=!1,this._pointerMoveHandler=null,this._pointerUpHandler=null}static get observedAttributes(){return["tags","placeholder","sortable","label","info","error","error-message","name","id","required","loading"]}connectedCallback(){this._parseAttrs(),this._render(),this._pointerMoveHandler||(this._pointerMoveHandler=t=>this._onPointerMove(t),window.addEventListener("pointermove",this._pointerMoveHandler)),this._pointerUpHandler||(this._pointerUpHandler=t=>this._onPointerUp(t),window.addEventListener("pointerup",this._pointerUpHandler),window.addEventListener("pointercancel",this._pointerUpHandler))}attributeChangedCallback(t,e,i){if(e!==i){if(t==="error"||t==="error-message"){if(this._renderErrorState(),this._container){const s=this.hasError(),n=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1.5","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-900","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=n.join(" ")}return}if(t==="loading"){this._parseAttrs(),this._render();return}this._parseAttrs(),this._render()}}set tags(t){this._tags=Array.isArray(t)?[...t]:[],this._syncAttr(),this._render()}get tags(){return[...this._tags]}_parseAttrs(){const t=this.getAttribute("tags");if(!t)return;try{const i=JSON.parse(t);Array.isArray(i)&&(this._tags=i)}catch(i){console.warn("mint-tags: failed to parse tags attribute",i)}const e=this.getAttribute("placeholder");e!==null&&(this._placeholder=e)}_syncAttr(){this.setAttribute("tags",JSON.stringify(this._tags))}getLabel(){return this.getAttribute("label")||""}getInfo(){return this.getAttribute("info")||""}hasError(){return this.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");const t=this.isLoading(),e=this.getLabel(),i=this.getInfo(),s=this.hasError(),n=this.getId()||`mint-tags-${Math.random().toString(36).substr(2,9)}`;if(this.getId()||this.setAttribute("id",n),this._container)this._input&&(this._input.placeholder=this._placeholder);else{this._container=document.createElement("div");const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" "),this._chipsWrap=document.createElement("div"),this._chipsWrap.className="flex flex-wrap items-center gap-2",this._chipsWrap.addEventListener("dragover",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._chipsWrap.addEventListener("drop",c=>{this.hasAttribute("sortable")&&c.preventDefault()}),this._input=document.createElement("input"),this._input.type="text",this._input.placeholder=this._placeholder,this._input.className=["min-w-[6rem]","flex-1","bg-transparent","border-none","outline-none","text-sm","text-gray-900","dark:text-gray-100","placeholder:text-gray-400","dark:placeholder:text-gray-500","p-1.5"].join(" "),this._input.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),this._addFromInput())}),this._container.appendChild(this._chipsWrap),this.appendChild(this._container)}if(this._container){const l=["flex","flex-wrap","items-center","gap-2","w-full","px-2","py-1","min-h-[2rem]","rounded-lg","border-2",s?"border-red-300 dark:border-red-300":"border-gray-200 dark:border-gray-700","bg-white","dark:bg-gray-800","focus-within:ring-2","focus-within:ring-offset-1",s?"focus-within:ring-red-400 dark:focus-within:ring-red-500":"focus-within:ring-gray-400 dark:focus-within:ring-gray-500","transition-colors","duration-200"];this._container.className=l.join(" ")}let r=this.querySelector(".mint-tags-label-container");if(e){r||(r=document.createElement("div"),r.className="mint-tags-label-container mb-[.25rem]",this._container&&this._container.parentElement===this?this.insertBefore(r,this._container):this.insertBefore(r,this.firstChild));let l=r.querySelector(".mint-tags-label");e?(l||(l=document.createElement("label"),l.className="mint-tags-label text-sm font-medium text-gray-900 dark:text-gray-100 select-none",r.appendChild(l)),l.textContent=e,l.setAttribute("for",n)):l&&l.remove()}else r&&r.remove();let a=this.querySelector(".mint-tags-info");i?(a||(a=document.createElement("span"),a.className="mint-tags-info text-xs text-gray-500 dark:text-gray-400 select-none mt-1 block",this._container&&this._container.parentElement===this?this.insertBefore(a,this._container.nextSibling):this.appendChild(a)),a.textContent=i):a&&a.remove();const o=this.getName();o?(this.setAttribute("name",o),this._input&&(this._input.name=o,this._input.id=n)):(this.removeAttribute("name"),this._input&&(this._input.removeAttribute("name"),this._input.id=n)),this._wireInputBackspace(),this._renderChips(),this._renderErrorState(),this._renderSkeleton(t)}_renderSkeleton(t){const e=this._container;if(!e)return;e.classList.contains("relative")||e.classList.add("relative");let i=e.querySelector(".mint-tags-skeleton");t?(i||(i=document.createElement("div"),i.className="mint-tags-skeleton absolute inset-0 z-10 pointer-events-none rounded-lg bg-gray-200 dark:bg-gray-700 animate-pulse",e.appendChild(i)),i.style.display="block",this._chipsWrap&&(this._chipsWrap.style.visibility="hidden",this._chipsWrap.style.pointerEvents="none"),this._input&&(this._input.style.visibility="hidden",this._input.style.pointerEvents="none")):(i&&(i.style.display="none"),this._chipsWrap&&(this._chipsWrap.style.visibility="visible",this._chipsWrap.style.pointerEvents="auto"),this._input&&(this._input.style.visibility="visible",this._input.style.pointerEvents="auto"))}_renderErrorState(){const t=this.hasError(),e=this.getErrorMessage();let i=this.querySelector(".mint-tags-error");t&&e?(i||(i=document.createElement("div"),i.className="mint-tags-error mt-1 text-xs text-red-600 dark:text-red-400",this.appendChild(i)),i.textContent=e):i&&i.remove()}_renderChips(){if(!this._chipsWrap)return;this._chipsWrap.innerHTML="";let t=0;this._tags.forEach(e=>{const i=document.createElement("mint-chip");i.dataset.index=String(t++),i.dataset.value=e.value,i.draggable=this.hasAttribute("sortable"),i.draggable&&i.classList.add("cursor-move"),e.dismissable&&(i.setAttribute("dismissable","true"),i.addEventListener("dismissed",()=>this._removeTag(e.value))),this._chipsWrap.appendChild(i);const s=i.querySelector("[data-mt-chip-text]");s&&(s.textContent=e.label||e.value),this._setupChipEvents(i,e),i.draggable&&(i.addEventListener("dragstart",n=>this._onDragStart(n,i)),i.addEventListener("dragover",n=>this._onDragOverChip(n,i)),i.addEventListener("drop",n=>this._onDrop(n)),i.addEventListener("dragend",()=>this._onDragEnd())),this.hasAttribute("sortable")&&i.addEventListener("pointerdown",n=>this._onPointerDown(n,i))}),this._input&&(this.hasAttribute("sortable")&&(this._input.addEventListener("dragover",e=>this._onDragOverInput(e)),this._input.addEventListener("drop",e=>this._onDrop(e)),this._input.addEventListener("dragend",()=>this._onDragEnd())),this._chipsWrap.appendChild(this._input))}_addFromInput(){if(!this._input)return;const t=this._input.value.trim();if(!t)return;if(this._tags.some(i=>i.value.toLowerCase()===t.toLowerCase())){this._input.value="";return}this._tags.push({value:t,label:t,dismissable:!0}),this._syncAttr(),this._renderChips(),this._emitChange(),this._input.value="",setTimeout(()=>{var i;(i=this._input)==null||i.focus()},10)}_removeTag(t){this._tags=this._tags.filter(e=>e.value!==t),this._syncAttr(),this._renderChips(),this._emitChange()}_emitChange(){this.dispatchEvent(new CustomEvent("tags-change",{bubbles:!0,composed:!0,detail:{tags:this.tags}}))}_focusLastChip(){var e;const t=(e=this._chipsWrap)==null?void 0:e.querySelectorAll("mint-chip");t&&t.length>0&&t[t.length-1].focus({preventScroll:!0})}_focusInput(){setTimeout(()=>{var t;(t=this._input)==null||t.focus({preventScroll:!0})},10)}_wireInputBackspace(){this._input&&this._input.addEventListener("keydown",t=>{var e;t.key==="Backspace"&&((e=this._input)==null?void 0:e.value)===""&&(t.preventDefault(),this._focusLastChip())})}_setupChipEvents(t,e){t.tabIndex=0,t.addEventListener("keydown",i=>{(i.key==="Backspace"||i.key==="Delete")&&e.dismissable&&(i.preventDefault(),this._removeTag(e.value),this._focusInput())})}_onDragStart(t,e){var i;this.hasAttribute("sortable")&&(this._dragChip=e,this._dragIndex=Number(e.dataset.index),(i=t.dataTransfer)==null||i.setData("text/plain",e.dataset.index||""),t.dataTransfer&&(t.dataTransfer.effectAllowed="move",t.dataTransfer.dropEffect="move"),e.classList.add("opacity-60"))}_reorderTags(t,e){if(t<0||e<0||t>=this._tags.length||e>=this._tags.length)return;const i=[...this._tags],[s]=i.splice(t,1);i.splice(e,0,s),this._tags=i,this._syncAttr(),this._renderChips(),this._emitChange()}_onDragOverInput(t){this.hasAttribute("sortable")&&(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),this._dragChip&&this._chipsWrap&&this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input))}_onDragOverChip(t,e){if(!this.hasAttribute("sortable")||(t.preventDefault(),t.dataTransfer&&(t.dataTransfer.dropEffect="move"),!this._dragChip||!this._chipsWrap)||e===this._dragChip)return;const i=e.getBoundingClientRect(),s=t.clientX,n=i.left+i.width*.5;if(s<n){if(this._dragChip.nextSibling===e)return;this._chipsWrap.insertBefore(this._dragChip,e)}else{if(e.nextSibling===this._dragChip)return;const r=e.nextSibling;r?this._chipsWrap.insertBefore(this._dragChip,r):this._chipsWrap.appendChild(this._dragChip)}}_onDrop(t){this.hasAttribute("sortable")&&t.preventDefault()}_onDragEnd(){this._dragChip&&this._dragChip.classList.remove("opacity-60"),this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}_syncOrderFromDom(){if(!this._chipsWrap)return;const t=Array.from(this._chipsWrap.querySelectorAll("mint-chip"));if(t.length===0)return;const e=[];t.forEach(i=>{const s=i.dataset.value;if(!s)return;const n=this._tags.find(r=>r.value===s);n&&e.push(n)}),e.length===this._tags.length&&(this._tags=e,this._syncAttr(),this._renderChips(),this._emitChange())}_onPointerDown(t,e){if(this.hasAttribute("sortable")&&t.pointerType!=="mouse"){this._isPointerDragging=!0,this._dragChip=e,this._dragIndex=Number(e.dataset.index);try{e.setPointerCapture(t.pointerId)}catch{}e.classList.add("opacity-60","select-none"),t.preventDefault()}}_onPointerMove(t){if(!this._isPointerDragging||!this._dragChip||!this._chipsWrap||t.pointerType==="mouse")return;const e=document.elementFromPoint(t.clientX,t.clientY);if(!e)return;const i=e.closest("mint-chip");if(i&&i!==this._dragChip){const s=i.getBoundingClientRect(),n=t.clientX,r=s.left+s.width*.5;if(n<r)this._dragChip.nextSibling!==i&&this._chipsWrap.insertBefore(this._dragChip,i);else if(i.nextSibling!==this._dragChip){const a=i.nextSibling;a?this._chipsWrap.insertBefore(this._dragChip,a):this._chipsWrap.appendChild(this._dragChip)}return}this._input&&e.closest("input")===this._input&&this._chipsWrap.insertBefore(this._dragChip,this._input)}_onPointerUp(t){if(this._isPointerDragging){if(this._isPointerDragging=!1,this._dragChip){try{this._dragChip.releasePointerCapture(t.pointerId)}catch{}this._dragChip.classList.remove("opacity-60","select-none")}this._syncOrderFromDom(),this._dragChip=null,this._dragIndex=null}}}customElements.get("mint-tags")||customElements.define("mint-tags",Dt);class Tt extends HTMLElement{constructor(){super(...arguments),this._clickHandler=null,this._keydownHandler=null}connectedCallback(){this._render(),this._setupEventListeners()}disconnectedCallback(){this._cleanupEventListeners()}_render(){this.classList.add("transition-colors","duration-200","focus-visible:outline-none","focus-visible:ring-2","focus-visible:ring-offset-1","focus-visible:ring-gray-400","dark:focus-visible:ring-gray-500","rounded"),this.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=t=>{if(this.getAttribute("disabled")==="true"){t.preventDefault(),t.stopPropagation();return}this._handleClick(t)},this._keydownHandler=t=>{if(t.key==="Enter"||t.key===" "){if(this.getAttribute("disabled")==="true"){t.preventDefault(),t.stopPropagation();return}t.preventDefault(),this._handleClick(t)}},this.addEventListener("click",this._clickHandler),this.addEventListener("keydown",this._keydownHandler)}_cleanupEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null),this._keydownHandler&&(this.removeEventListener("keydown",this._keydownHandler),this._keydownHandler=null)}_handleClick(t){this.dispatchEvent(new CustomEvent("clickable-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}static get observedAttributes(){return["disabled"]}attributeChangedCallback(t,e,i){t==="disabled"&&(i==="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",Tt);class Ht extends HTMLElement{constructor(){super(),this._headingElement=null,this._iconElement=null,this._dismissButton=null,this._headerWrapper=null,this._bodyWrapper=null,this._dismissHandler=null}static get observedAttributes(){return["heading","dismissable","tone"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block"),this.render()}disconnectedCallback(){this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getHeading(){return this.getAttribute("heading")||""}getTone(){const t=this.getAttribute("tone");return t==="info"||t==="success"||t==="warning"||t==="danger"?t:"info"}isDismissable(){return this.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-blue-600 dark:text-blue-400";case"success":return"text-green-600 dark:text-green-400";case"warning":return"text-yellow-600 dark:text-yellow-400";case"danger":return"text-red-600 dark:text-red-400";default:return"text-blue-600 dark:text-blue-400"}}getHeadingColorClasses(){return"text-gray-900 dark:text-gray-100"}getHeaderBackgroundClasses(){switch(this.getTone()){case"info":return"bg-blue-100 dark:bg-blue-900/30";case"success":return"bg-green-100 dark:bg-green-900/30";case"warning":return"bg-yellow-100 dark:bg-yellow-900/30";case"danger":return"bg-red-100 dark:bg-red-900/30";default:return"bg-blue-100 dark:bg-blue-900/30"}}getBorderClasses(){switch(this.getTone()){case"info":return"border-blue-200 dark:border-blue-800";case"success":return"border-green-200 dark:border-green-800";case"warning":return"border-yellow-200 dark:border-yellow-800";case"danger":return"border-red-200 dark:border-red-800";default:return"border-blue-200 dark:border-blue-800"}}getAriaLive(){return this.getTone()==="danger"?"assertive":"polite"}render(){const t=this.getTone(),e=this.getHeading(),i=this.isDismissable();this.className=`box-border m-0 p-0 border-0 align-baseline block rounded-lg border shadow-sm overflow-hidden transition-colors duration-200 ${this.getBorderClasses()}`;const s=this.getAriaLive();this.setAttribute("role","alert"),this.setAttribute("aria-live",s),t==="danger"?this.setAttribute("aria-atomic","true"):this.removeAttribute("aria-atomic");const n=[];for(this._bodyWrapper?Array.from(this._bodyWrapper.childNodes).forEach(a=>{n.push(a)}):Array.from(this.childNodes).forEach(r=>{r!==this._headerWrapper&&r!==this._bodyWrapper&&r!==this._iconElement&&r!==this._headingElement&&r!==this._dismissButton&&n.push(r)}),this._dismissButton&&this._dismissHandler&&this._dismissButton.removeEventListener("click",this._dismissHandler);this.firstChild;)this.removeChild(this.firstChild);if(this._headerWrapper=null,this._bodyWrapper=null,this._iconElement=null,this._headingElement=null,this._dismissButton=null,this._headerWrapper=document.createElement("div"),this._headerWrapper.className=`px-4 py-3 flex items-center gap-3 ${this.getHeaderBackgroundClasses()}`,this._iconElement=document.createElement("mint-icon"),this._iconElement.setAttribute("name",this.getIconName()),this._iconElement.className=`flex-shrink-0 w-5 h-5 ${this.getIconColorClasses()}`,this._headerWrapper.appendChild(this._iconElement),this._headingElement=document.createElement("mint-text"),this._headingElement.className=`font-semibold flex-1 ${this.getHeadingColorClasses()}`,this._headingElement.textContent=e||"",this._headerWrapper.appendChild(this._headingElement),i){this._dismissButton=document.createElement("button"),this._dismissButton.className="flex-shrink-0 p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 transition-colors",this._dismissButton.setAttribute("aria-label","Dismiss alert"),this._dismissButton.setAttribute("type","button");const r=document.createElement("mint-icon");r.setAttribute("name","close"),r.className="w-4 h-4 text-gray-700 dark:text-gray-300",this._dismissButton.appendChild(r),this._dismissHandler=a=>{a.preventDefault(),a.stopPropagation(),this.dispatchEvent(new CustomEvent("dismissed",{bubbles:!0,composed:!0})),this.remove()},this._dismissButton.addEventListener("click",this._dismissHandler),this._headerWrapper.appendChild(this._dismissButton)}this._bodyWrapper=document.createElement("div"),this._bodyWrapper.className="px-4 py-3 bg-white dark:bg-gray-900",n.forEach(r=>{this._bodyWrapper.appendChild(r)}),this.appendChild(this._headerWrapper),this.appendChild(this._bodyWrapper)}}customElements.get("mint-alert")||customElements.define("mint-alert",Ht);class Mt extends HTMLElement{constructor(){super(),this._configuration=null,this._rows=[],this._search="",this._currentPage=1,this._perPage=15,this._totalRows=0,this._lastPage=0,this._offset=0,this._rowsToShow=15,this._loaded=!1,this._fetching=!1,this._loading=!1,this._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}static get observedAttributes(){return["configuration"]}get inMintCard(){return this._inMintCard}get configuration(){return this._configuration}set configuration(t){t&&typeof t=="object"&&!Array.isArray(t)?(this._configuration=t,this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1,this._currentPage=1,this._offset=0,this._type==="provided"&&Array.isArray(this._configuration.data)&&(this._rows=[...this._configuration.data],this._totalRows=this._configuration.data.length),this._initializeColumns(),this._loadColumnVisibility(),this.isConnected&&this.render()):t==null?this._configuration=null:this._parseConfiguration()}connectedCallback(){var t,e;this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full"),this._inMintCard=((e=(t=this.parentElement)==null?void 0:t.tagName)==null?void 0:e.toLowerCase())==="mint-card",this._configuration||this._parseConfiguration(),this._initializeColumns(),this._loadColumnVisibility(),this._loadPageFromUrl(),this._attachRowClickHandler(),this.render()}disconnectedCallback(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._rowClickHandler&&(this.removeEventListener("click",this._rowClickHandler,!0),this._rowClickHandler=null),this._scrollHandler&&(window.removeEventListener("scroll",this._scrollHandler),this._scrollHandler=null)}attributeChangedCallback(t,e,i){t==="configuration"&&e!==i&&(!this._configuration||typeof i=="string")&&(this._parseConfiguration(),this.render())}refresh(){this._configuration&&(this._type==="ajax"?this._configuration.loadMore?(this._offset=0,this._currentPage=1,this._rowsToShow=this._perPage,this._rows=[],this._fetchData(void 0,!0,this._perPage,0)):this._fetchData(void 0,!0,this._perPage,this._offset):this.render())}_parseConfiguration(){const t=this.getAttribute("configuration");if(!t){console.error("mint-resource-table: configuration attribute is required");return}try{this._configuration=JSON.parse(t),this._tableId=this._configuration.id||`mint-resource-table-${Date.now()}`,this._perPage=this._configuration.perPage||15,this._rowsToShow=this._perPage,this._type=typeof this._configuration.data=="string"?"ajax":"provided",this._loaded=!1;const e=this._getPageFromUrl();this._currentPage=e||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(),this._loadColumnVisibility()}catch(e){console.error("mint-resource-table: Invalid configuration JSON",e)}}_getColumnVisibilityStorageKey(){return`mrtc-${this._tableId}`}_saveColumnVisibility(){if(!this._configuration)return;const t={};this._configuration.columns.forEach((e,i)=>{t[i]=e.hidden||!1});try{localStorage.setItem(this._getColumnVisibilityStorageKey(),JSON.stringify(t))}catch(e){console.warn("Failed to save column visibility to localStorage:",e)}}_loadColumnVisibility(){if(this._configuration)try{const t=localStorage.getItem(this._getColumnVisibilityStorageKey());if(t){const e=JSON.parse(t);this._configuration.columns.forEach((i,s)=>{e[s]!==void 0&&(i.hidden=e[s])})}}catch(t){console.warn("Failed to load column visibility from localStorage:",t)}}_initializeColumns(){this._configuration&&(this._searchColumns=[],this._exportColumns={},this._columns=[],this._configuration.columns.forEach(t=>{t.searchable&&t.data&&this._searchColumns.push(t.data),t.export&&t.data&&(this._exportColumns[t.data]=t.label),t.data&&this._columns.push(t.data)}),this._configuration.sortBy||(this._configuration.sortBy="id"),this._configuration.sort||(this._configuration.sort="asc"))}async _fetchData(t,e=!0,i,s){var o,l,c,h,p,d,u,m;if(!this._configuration)return;const n=t||(typeof this._configuration.data=="string"?this._configuration.data:null);if(!n||this._fetching||this._loading)return;e&&(this._fetching=!0,this._loaded?this._updatePagination():this.render()),this._loading=!0;const r=i||this._perPage,a=s!==void 0?s:this._offset;try{const f=new URLSearchParams({perPage:r.toString(),offset:a.toString(),search:this._search,sortBy:this._configuration.sortBy||"id",sort:this._configuration.sort||"asc",searchColumns:this._searchColumns.join(","),columns:this._columns.join(",")}),g={};this._configuration.headers&&(g.headers=this._configuration.headers);const _=await fetch(`${n}?${f.toString()}`,g);if(!_.ok)throw new Error(`HTTP error! status: ${_.status}`);const b=await _.json(),v=((o=b.content)==null?void 0:o.rows)||[],y=((l=b.content)==null?void 0:l.total)||0;if(this._configuration.loadMore&&a!==0)this._rows=this._rows.concat(v);else{let S=v;this._configuration.predefinedData?(S=[...this._configuration.predefinedData,...v],this._totalRows=y+this._configuration.predefinedData.length):this._totalRows=y,this._rows=S}const x=Math.floor(a/r)+1;this._configuration.loadMore||(((c=b.content)==null?void 0:c.current_page)!==void 0&&b.content.current_page===x?this._currentPage=b.content.current_page:this._currentPage=x,this._offset=(this._currentPage-1)*r),this._lastPage=((h=b.content)==null?void 0:h.last_page)||1,this._fetching=!1,this._loaded=!0,this._loading=!1,this._fetchError=null,this._searching=!1;const D=this._sorting;if(D&&this._updateSortIcons(),this._sorting=!1,this._sortingColumn=null,D&&this._updateSortIcons(),this.dispatchEvent(new CustomEvent("loaded",{detail:{rows:this._rows}})),this._updateSearchIcon(),(d=(p=this.querySelector(`#${this._tableId}`))==null?void 0:p.closest("table"))==null?void 0:d.querySelector("tbody")){if(D){const k=this._loading,C=this._fetching;this._loading=!1,this._fetching=!1,this._updateTableBody(),this._loading=k,this._fetching=C}else this._updateTableBody();const S=this._loadingPage;this._loadingPage=null,this._updatePagination(),setTimeout(()=>{var C;const k=(C=this.querySelector("nav"))==null?void 0:C.closest(".flex.justify-end");k&&k.querySelectorAll('mint-button[data-action="page"]').forEach(A=>{"render"in A&&typeof A.render=="function"&&A.render()})},0)}else this.render()}catch(f){this._fetching=!1,this._loading=!1,this._loadingPage=null,this._loaded=!0,this._searching=!1,this._fetchError=f instanceof Error?f.message:"Failed to fetch data",console.error("mint-resource-table: Error fetching data",f),this._updateSearchIcon(),((m=(u=this.querySelector(`#${this._tableId}`))==null?void 0:u.closest("table"))==null?void 0:m.querySelector("tbody"))?(this._updateTableBody(),this._loadingPage=null,this._updatePagination()):this.render()}}_getRows(){if(!this._configuration)return[];if(this._type==="ajax")return this._rows;let t=[...this._rows];const e=this._configuration.sortBy||"id",i=this._configuration.sort||"asc";if(this._search){const s=this._search.toLowerCase().trim().split(/\s+/);t=t.filter(n=>{const r=Object.values(n).map(a=>String(a).toLowerCase()).join(" ");return s.every(a=>r.includes(a))})}if(t.sort((s,n)=>{const r=s[e],a=n[e];if(r==null&&a==null)return 0;if(r==null)return 1;if(a==null)return-1;const o=typeof r=="number"?r:typeof r=="string"&&!isNaN(Number(r))&&r.trim()!==""?Number(r):null,l=typeof a=="number"?a:typeof a=="string"&&!isNaN(Number(a))&&a.trim()!==""?Number(a):null;if(o!==null&&l!==null){const d=o-l;return i==="asc"?d:-d}const c=r instanceof Date?r:typeof r=="string"?new Date(r):null,h=a instanceof Date?a:typeof a=="string"?new Date(a):null;if(c&&h&&!isNaN(c.getTime())&&!isNaN(h.getTime())){const d=c.getTime()-h.getTime();return i==="asc"?d:-d}const p=String(r).localeCompare(String(a),void 0,{numeric:!0,sensitivity:"base"});return i==="asc"?p:-p}),this._perPage){const s=Math.ceil(t.length/this._perPage);this._lastPage=s,t.forEach((n,r)=>{n.page=Math.ceil((r+1)/this._perPage)}),this._currentPage>s&&s>0&&(this._currentPage=s)}return this._configuration.loadMore?t.slice(0,this._rowsToShow):t.filter(s=>!this._perPage||s.page===this._currentPage)}_toggleSort(t){var i;if(!this._configuration||!t.data||!t.sortable)return;const e=t.data;if(this._sortTimeoutId!==null&&(clearTimeout(this._sortTimeoutId),this._sortTimeoutId=null),this._sorting=!0,this._sortingColumn=t,this._updateSortIcons(),this._type==="ajax")this._sortTimeoutId=window.setTimeout(()=>{var n;if(this._sortTimeoutId=null,!this._configuration||!e||!t.sortable)return;let s=this._configuration.sort||"asc";((n=this._configuration.sortBy)==null?void 0:n.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._updateSortIcons(),this._offset=0,this._currentPage=1,this._configuration.loadMore&&(this._rowsToShow=this._perPage),this._fetching=!1,this._loading=!1,this._configuration.loadMore?this._fetchData(void 0,!1,this._perPage,0):this._fetchData(void 0,!1,this._perPage,0)},10);else{let s=this._configuration.sort||"asc";((i=this._configuration.sortBy)==null?void 0:i.toLowerCase())===e.toLowerCase()&&(s=s==="desc"?"asc":"desc"),this._configuration.sort=s,this._configuration.sortBy=e,this._currentPage=1,this._sorting=!1,this._sortingColumn=null,this._updateSortIcons(),this.render()}}_getSortClass(t){var e,i,s,n,r;return this._sorting&&this._sortingColumn===t?"spinner":((i=(e=this._configuration)==null?void 0:e.sortBy)==null?void 0:i.toLowerCase())===((s=t.data)==null?void 0:s.toLowerCase())?((r=(n=this._configuration)==null?void 0:n.sort)==null?void 0:r.toLowerCase())==="desc"?"caret-down":"caret-up":""}_updateSortIcons(){this._configuration&&this._configuration.columns.forEach((t,e)=>{if(!t.sortable||t.hidden)return;const i=this.querySelector(`th[data-column-key="${e}"]`);if(!i)return;const s=i.querySelector(".ml-2.flex.items-center");if(!s)return;const n=s.querySelector("mint-icon"),r=s.querySelector("mint-spinner"),a=this._getSortClass(t);if(a==="spinner"){if(n&&n.remove(),!r){const o=document.createElement("mint-spinner");o.className="w-4 h-4",s.appendChild(o)}}else if(r&&r.remove(),n)n.setAttribute("name",a),n.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`;else{const o=document.createElement("mint-icon");o.setAttribute("name",a),o.className=`w-4 h-4 ${a==="sort-arrows"?"text-gray-400":""}`,s.appendChild(o)}})}_showFetchingState(){}_triggerSearch(){this._searchTimeoutId&&clearTimeout(this._searchTimeoutId),this._searching=!0,this._type==="ajax"&&this._updateSearchIcon(),this._type!=="ajax"&&(this._currentPage=1),this._updateTableBody(),this._type!=="ajax"&&this._updatePagination(),this._searchTimeoutId=window.setTimeout(()=>{this._type==="ajax"?(this._offset=0,this._fetchData(void 0,!1,this._perPage,0)):this._searching=!1},400)}_updateSearchIcon(){const t=this.querySelector(`#search-${this._tableId}`);if(!t)return;const e=this._type==="ajax"&&(this._searching||this._fetching);setTimeout(()=>{const i=t.querySelector(".relative")||t.querySelector("div");if(!i)return;const s=i.querySelector("mint-icon"),n=i.querySelector("mint-spinner");if(e){if(s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",s.replaceWith(r)}else if(!s&&!n){const r=document.createElement("mint-spinner");r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 pointer-events-none",i.appendChild(r)}}else if(n){t.getAttribute("icon")||t.setAttribute("icon","search");const r=document.createElement("mint-icon");r.setAttribute("name","search"),r.className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-500 pointer-events-none",n.replaceWith(r)}},0)}_updateTableBody(){var a,o;if(!this._configuration)return;const t=this._getRows(),e=(o=(a=this.querySelector(`#${this._tableId}`))==null?void 0:a.closest("table"))==null?void 0:o.querySelector("tbody");if(!e){this.render();return}const i=this.querySelector(`#search-${this._tableId}`),s=document.activeElement===i||(i==null?void 0:i.querySelector("input"))===document.activeElement,n=this._search;let r="";if(!((this._fetching||this._loading)&&!this._loaded&&!this._sorting)&&(t.forEach((l,c)=>{const h=typeof this._configuration.onRowClick=="function",p=h?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";r+=`<tr data-row-index="${c}" ${h?'data-row-clickable="true"':""}${p?` class="${p}"`:""}>`,this._configuration.columns.forEach((d,u)=>{if(d.hidden)return;const m=!d.show||d.show(this,l);if(r+=`<td style="${this._getStyle(d)}" class="${this._getClasses(d,!0)}">`,m)if(d.raw)if(d.action)(!d.action.show||d.action.show(this,l))&&(r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(d)}">${d.action.label}</mint-button>`);else if(d.actions)if(d.actionStyle!=="buttons"){const f=`actions-popover-${this._tableId}-${c}`,g=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${g}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${f}" trigger-id="${g}" direction="down">`,d.actions.forEach((_,b)=>{if(!_.show||_.show(this,l)){const v=typeof _.label=="function"?_.label(this,l):_.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(d)}">${v}</div>`}}),r+="</mint-popover>"}else d.actions.forEach((f,g)=>{if(!f.show||f.show(this,l)){const _=f.label?typeof f.label=="function"?f.label(this,l):f.label:"",b=f.icon?` icon="${this._escapeHtml(f.icon)}"`:"",v=f.tone?` tone="${this._escapeHtml(f.tone)}"`:"";r+=`<mint-button variant="link" class="${f.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${g}" data-column-key="${this._configuration.columns.indexOf(d)}"${b}${v}>`,_&&(r+=this._escapeHtml(String(_))),r+="</mint-button>"}});else typeof d.format=="function"?r+=d.format(this,l):d.data&&(r+=this._escapeHtml(String(l[d.data]||"")));else if(d.action){if(!d.action.show||d.action.show(this,l)){const f=typeof d.action.label=="function"?d.action.label(this,l):d.action.label;r+=`<mint-button variant="solid" data-action="column-action" data-row-index="${c}" data-column-key="${this._configuration.columns.indexOf(d)}">${this._escapeHtml(String(f))}</mint-button>`}}else if(d.actions)if(d.actionStyle!=="buttons"){const f=`actions-popover-${this._tableId}-${c}`,g=`actions-button-${this._tableId}-${c}`;r+=`<mint-button id="${g}" variant="link" icon="ellipsis">`,r+="</mint-button>",r+=`<mint-popover id="${f}" trigger-id="${g}" direction="down">`,d.actions.forEach((_,b)=>{if(!_.show||_.show(this,l)){const v=typeof _.label=="function"?_.label(this,l):_.label;r+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${c}" data-action-index="${b}" data-column-key="${this._configuration.columns.indexOf(d)}">${v}</div>`}}),r+="</mint-popover>"}else d.actions.forEach((f,g)=>{if(!f.show||f.show(this,l)){const _=f.label?typeof f.label=="function"?f.label(this,l):f.label:"",b=f.icon?` icon="${this._escapeHtml(f.icon)}"`:"",v=f.tone?` tone="${this._escapeHtml(f.tone)}"`:"";r+=`<mint-button variant="link" class="${f.classes||""}" data-action="row-action" data-row-index="${c}" data-action-index="${g}" data-column-key="${this._configuration.columns.indexOf(d)}"${b}${v}>`,_&&(r+=this._escapeHtml(String(_))),r+="</mint-button>"}});else typeof d.format=="function"?r+=this._escapeHtml(d.format(this,l)):d.data&&(r+=this._escapeHtml(String(l[d.data]||"")));r+="</td>"}),r+="</tr>"}),t.length===0&&(this._fetchError?r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:r+=`<tr><td colspan="${this._configuration.columns.filter(l=>!l.hidden).length}" class="text-center py-8">No records found.</td></tr>`),e.innerHTML=r,this._attachTableEventListeners(),this._attachRowClickHandler(),s&&i)){const l=i.querySelector("input")||i._element;l?(l.value=n,setTimeout(()=>{l.focus(),l.setSelectionRange(n.length,n.length)},0)):i.value!==void 0&&(i.value=n,setTimeout(()=>{i.focus()},0))}}_updatePagination(){var l,c;if(!this._configuration)return;const t=this._lastPage||Math.ceil(this._rows.length/this._perPage);if(!this._configuration.perPage||this._configuration.loadMore||t<=1){const h=(l=this.querySelector("nav"))==null?void 0:l.closest(".flex.justify-end");h&&h.remove();return}let e=(c=this.querySelector("nav"))==null?void 0:c.closest(".flex.justify-end");if(!e){const h=this.querySelector("mint-table");if(!h){this.render();return}e=document.createElement("div"),e.className="flex justify-end "+(this._inMintCard?"p-3.5":"mt-4"),h.insertAdjacentElement("afterend",e)}let i="<nav>";i+='<ul class="flex gap-1">';const s=this._currentPage===1||this._loading||this._fetching;i+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${s?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;const n=t>=10,r=Math.max(1,this._currentPage-1),a=Math.min(t,this._currentPage+1);if(n){for(let d=1;d<=3;d++){const u=this._currentPage===d,m=this._loadingPage===d,f=u?' active="true"':"",g=this._loading||this._fetching?' disabled="true"':"",_=m?' loading="true"':"",b=m?"":`${d}`;i+=`<li><mint-button variant="solid" size="sm"${f}${g}${_} data-action="page" data-page="${d}">${b}</mint-button></li>`}const h=a<=3,p=r>=t-2;if(!h&&!p){r>4&&(i+='<li><span class="px-2">...</span></li>');for(let d=r;d<=a;d++){if(d<=3)continue;const u=this._currentPage===d,m=this._loadingPage===d,f=u?' active="true"':"",g=this._loading||this._fetching?' disabled="true"':"",_=m?' loading="true"':"",b=m?"":`${d}`;i+=`<li><mint-button variant="solid" size="sm"${f}${g}${_} data-action="page" data-page="${d}">${b}</mint-button></li>`}a<t-3&&(i+='<li><span class="px-2">...</span></li>')}else(h&&!p||!h&&p&&t-2>4)&&(i+='<li><span class="px-2">...</span></li>');for(let d=t-2;d<=t;d++){if(d<=3||!h&&!p&&d>=r&&d<=a)continue;const u=this._currentPage===d,m=this._loadingPage===d,f=u?' active="true"':"",g=this._loading||this._fetching?' disabled="true"':"",_=m?' loading="true"':"",b=m?"":`${d}`;i+=`<li><mint-button variant="solid" size="sm"${f}${g}${_} data-action="page" data-page="${d}">${b}</mint-button></li>`}}else for(let h=1;h<=t;h++){const p=this._currentPage===h,d=this._loadingPage===h,u=p?' active="true"':"",m=this._loading||this._fetching?' disabled="true"':"",f=d?' loading="true"':"",g=d?"":`${h}`;i+=`<li><mint-button variant="solid" size="sm"${u}${m}${f} data-action="page" data-page="${h}">${g}</mint-button></li>`}const o=this._currentPage>=t||this._loading||this._fetching;i+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${o?'disabled="true"':""} data-action="page-next"></mint-button></li>`,i+="</ul>",i+="</nav>",e.innerHTML=i,setTimeout(()=>{this._attachPaginationListeners(),e.querySelectorAll('mint-button[data-action="page"]').forEach(h=>{var m,f;const p=h.getAttribute("data-page"),d=p&&this._loadingPage===parseInt(p),u=h._button||h.querySelector("button");if(u)if(d){const g=[],_=document.createTreeWalker(u,NodeFilter.SHOW_TEXT,null);let b;for(;b=_.nextNode();)g.push(b);g.forEach(x=>{var D;return(D=x.parentNode)==null?void 0:D.removeChild(x)});const v=u.querySelector(".mint-button-content");if(v){const x=(m=v.textContent)==null?void 0:m.trim();x&&/^\d+$/.test(x)&&v.remove()}const y=u.querySelector("span.mr-2");y&&y.querySelector("mint-spinner")&&(y.classList.remove("mr-2"),y.classList.add("mr-0"))}else{const g=(f=u.textContent)==null?void 0:f.trim();if(!g||!/^\d+$/.test(g)){const _=p||"",b=u.querySelector("mint-spinner");u.innerHTML="",b&&u.appendChild(b),u.appendChild(document.createTextNode(_))}}if("render"in h&&typeof h.render=="function"&&(h.render(),d&&u)){const g=u.querySelector("span.mr-2");g&&g.querySelector("mint-spinner")&&(g.classList.remove("mr-2"),g.classList.add("mr-0"))}}),e.querySelectorAll('mint-button[data-action="page-prev"], mint-button[data-action="page-next"]').forEach(h=>{"render"in h&&typeof h.render=="function"&&h.render()}),this._loadingPage!==null&&!this._loading&&!this._fetching&&this._updatePagination()},0)}_loadMore(){this._loading||this._fetching||!(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)||(this._offset+=this._perPage,this._currentPage+=1,this._rowsToShow+=this._perPage,this._type==="ajax"?this._fetchData():this.render())}_goToPage(t){const e=this._lastPage||Math.ceil(this._rows.length/this._perPage);t>e&&(t=e),t<1&&(t=1),t!==this._currentPage&&(this._currentPage=t,this._offset=(t-1)*this._perPage,this._updatePageInUrl(t),this._type==="ajax"?(this._loadingPage=t,this._updatePagination(),this._fetchData()):this.render())}_handleButtonClick(t){if(this._configuration)switch(t.type){case"export":break;case"print":window.print();break;case"csv":this._downloadCSV();break;default:t.onClick&&t.onClick(this);break}}_downloadCSV(){if(!this._configuration)return;const t=this.querySelector("table");if(!t)return;const e=t.querySelectorAll("tr");let i="data:text/csv;charset=utf-8,";e.forEach(r=>{const a=[];r.querySelectorAll("th, td").forEach(o=>{var c;const l=o.getAttribute("colspan");if(l)for(let h=0;h<parseInt(l)-1;h++)a.push("");a.push('"'+((c=o.textContent)==null?void 0:c.trim().replace(/"/g,'""'))+'"')}),i+=a.join(",")+`
146
- `});const s=encodeURI(i),n=document.createElement("a");n.setAttribute("href",s),n.setAttribute("download",`${this._configuration.export_name||this._tableId}.csv`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}_columnChange(t,e){const i=t.target.checked;e.hidden=!i,this._saveColumnVisibility();const s=`edit-columns-popover-${this._tableId}`,n=this.querySelector(`#${s}`),r=n==null?void 0:n.hasAttribute("open");this.render(),r&&n&&requestAnimationFrame(()=>{const a=this.querySelector(`#${s}`);a&&typeof a.open=="function"&&a.open()})}_getStyle(t){let e="";return(t.nowrap||t.actions)&&(e+="white-space: nowrap;"),t.offsetLeft&&(e+=`left: ${t.offsetLeft} !important;`),t.offsetRight&&(e+=`right: ${t.offsetRight} !important;`),t.width&&(e+=`min-width: ${t.width}px; max-width: ${t.width}px;`),e}_getClasses(t,e=!1){const i=[];return t.class&&i.push(t.class.trim()),t.sortable&&!e&&i.push("cursor-pointer"),t.stickLeft&&i.push("sticky-left"),t.stickRight&&i.push("sticky-right"),i.join(" ")}render(){if(!this._configuration){this.innerHTML='<div class="p-4 text-red-500">Error: Invalid configuration</div>';return}const t=!this._loaded||this._rows.length>0||this._search.length>0||this._searching,e=this._getRows(),i=this._lastPage||Math.ceil(this._rows.length/this._perPage);let s="";if(t){if(s+='<div class="flex '+(this._inMintCard?"p-3.5":"mb-3")+'">',s+='<div class="flex-grow-1 flex-1">',s+='<div class="flex gap-2 items-center">',this._configuration.showSearch!==!1){const r=`search-${this._tableId}`;s+=`<mint-input id="${r}" type="search" label="" placeholder="Search..." class="flex-1" icon="search" value="${this._escapeHtml(this._search)}"></mint-input>`}if(this._configuration.buttons&&this._configuration.buttons.forEach(r=>{const a=r.icon?` icon="${this._escapeHtml(r.icon)}"`:"",o=r.tone?` tone="${this._escapeHtml(r.tone)}"`:"";s+=`<mint-button variant="solid" class="${r.class||""}" data-button-type="${r.type||"custom"}"${a}${o}>`,r.label&&(s+=this._escapeHtml(r.label)),s+="</mint-button>"}),s+="</div>",s+="</div>",this._configuration.editColumns!==!1&&this._configuration.columns.some(a=>!a.actions&&a.editable!==!1)){const a=`edit-columns-popover-${this._tableId}`,o=`edit-columns-button-${this._tableId}`;s+='<div class="ml-2">',s+=`<mint-button id="${o}" variant="solid" icon="edit"></mint-button>`,s+=`<mint-popover id="${a}" trigger-id="${o}" direction="down">`,this._configuration.columns.forEach(l=>{!l.actions&&l.editable!==!1&&(s+='<div class="p-2">',s+=`<mint-checkbox label="${l.label}" ${l.hidden?"":"checked"} data-column-key="${this._configuration.columns.indexOf(l)}"></mint-checkbox>`,s+="</div>")}),s+="</mint-popover>",s+="</div>"}s+="</div>"}if(this._type==="ajax"&&!this._loaded&&!this._fetchError&&!this._sorting){s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{r.hidden||(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1&&(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable&&(s+='<div class="ml-2 flex items-center">',s+='<mint-icon name="" class="w-4 h-4 text-gray-400"></mint-icon>',s+="</div>"),s+="</div>"),s+="</th>")}),s+="</tr></thead>",s+="<tbody>";for(let r=0;r<4;r++)s+="<tr>",this._configuration.columns.forEach(a=>{a.hidden||(s+=`<td style="${this._getStyle(a)}" class="${this._getClasses(a,!0)}">`,s+='<div class="h-4 bg-gray-200 dark:bg-gray-700 rounded animate-pulse"></div>',s+="</td>")}),s+="</tr>";if(s+="</tbody>",s+="</table>",s+="</mint-table>",this._configuration.perPage&&!this._configuration.loadMore&&(i>1||this._lastPage>0)){const r=this._lastPage>0?this._lastPage:i;if(r>1){s+='<div class="flex justify-end '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<nav>",s+='<ul class="flex gap-1">',s+=`<li><mint-button variant="solid" size="sm" icon="caret-left" ${this._currentPage===1?'disabled="true"':""} data-action="page-prev"></mint-button></li>`;for(let a=1;a<=Math.min(2,r);a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}if(r>2&&(s+='<li><span class="px-2">...</span></li>'),this._currentPage>2&&this._currentPage<r-1&&(s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage-1}">${this._currentPage-1}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" disabled="true" data-action="page" data-page="${this._currentPage}">${this._currentPage}</mint-button></li>`,s+=`<li><mint-button variant="solid" size="sm" data-action="page" data-page="${this._currentPage+1}">${this._currentPage+1}</mint-button></li>`),r>2)for(let a=Math.max(r-1,this._currentPage+2);a<=r;a++){const l=this._currentPage===a?' disabled="true"':"";s+=`<li><mint-button variant="solid" size="sm"${l} data-action="page" data-page="${a}">${a}</mint-button></li>`}s+=`<li><mint-button variant="solid" size="sm" icon="caret-right" ${this._currentPage>=r?'disabled="true"':""} data-action="page-next"></mint-button></li>`,s+="</ul>",s+="</nav>",s+="</div>"}}}else e.length>0||this._search.length>0||this._searching||this._fetchError?(s+='<mint-table class="table-section'+(this._inMintCard?" rounded-t-none":"")+'">',s+=`<table id="${this._tableId}">`,s+="<thead><tr>",this._configuration.columns.forEach((r,a)=>{if(!r.hidden){if(s+=`<th width="${r.width||""}" style="${this._getStyle(r)}" class="${this._getClasses(r)}" data-column-key="${a}">`,r.showLabel!==!1){if(s+='<div class="flex items-center">',s+=`<div class="flex-1">${r.raw?r.label:this._escapeHtml(r.label)}</div>`,r.sortable){s+='<div class="ml-2 flex items-center">';const o=this._getSortClass(r);o==="spinner"?s+='<mint-spinner class="w-4 h-4"></mint-spinner>':s+=`<mint-icon name="${o}" class="w-4 h-4 ${o==="sort-arrows"?"text-gray-400":""}"></mint-icon>`,s+="</div>"}s+="</div>"}s+="</th>"}}),s+="</tr></thead>",s+="<tbody>",!this._fetching&&!this._loading&&e.forEach((r,a)=>{const o=typeof this._configuration.onRowClick=="function",l=o?"cursor-pointer hover:bg-gray-50 dark:hover:bg-gray-800 transition-colors":"";s+=`<tr data-row-index="${a}" ${o?'data-row-clickable="true"':""}${l?` class="${l}"`:""}>`,this._configuration.columns.forEach((c,h)=>{if(c.hidden)return;const p=!c.show||c.show(this,r);if(s+=`<td style="${this._getStyle(c)}" class="${this._getClasses(c,!0)}">`,p)if(c.raw)if(c.action){if(!c.action.show||c.action.show(this,r)){const d=typeof c.action.label=="function"?c.action.label(this,r):c.action.label;s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(d))}</mint-button>`}}else if(c.actions)if(c.actionStyle!=="buttons"){const d=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${d}" trigger-id="${u}" direction="down">`,c.actions.forEach((m,f)=>{if(!m.show||m.show(this,r)){const g=typeof m.label=="function"?m.label(this,r):m.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${f}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((d,u)=>{if(!d.show||d.show(this,r)){const m=d.label?typeof d.label=="function"?d.label(this,r):d.label:"",f=d.icon?` icon="${this._escapeHtml(d.icon)}"`:"",g=d.tone?` tone="${this._escapeHtml(d.tone)}"`:"";s+=`<mint-button variant="link" class="${d.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${f}${g}>`,m&&(s+=this._escapeHtml(String(m))),s+="</mint-button>"}});else typeof c.format=="function"?s+=c.format(this,r):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));else if(c.action)(!c.action.show||c.action.show(this,r))&&(s+=`<mint-button variant="solid" data-action="column-action" data-row-index="${a}" data-column-key="${this._configuration.columns.indexOf(c)}">${c.action.label}</mint-button>`);else if(c.actions)if(c.actionStyle!=="buttons"){const d=`actions-popover-${this._tableId}-${a}`,u=`actions-button-${this._tableId}-${a}`;s+=`<mint-button id="${u}" variant="link" icon="ellipsis">`,s+="</mint-button>",s+=`<mint-popover id="${d}" trigger-id="${u}" direction="down">`,c.actions.forEach((m,f)=>{if(!m.show||m.show(this,r)){const g=typeof m.label=="function"?m.label(this,r):m.label;s+=`<div class="p-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700" data-action="row-action" data-row-index="${a}" data-action-index="${f}" data-column-key="${this._configuration.columns.indexOf(c)}">${this._escapeHtml(String(g))}</div>`}}),s+="</mint-popover>"}else c.actions.forEach((d,u)=>{if(!d.show||d.show(this,r)){const m=d.label?typeof d.label=="function"?d.label(this,r):d.label:"",f=d.icon?` icon="${this._escapeHtml(d.icon)}"`:"",g=d.tone?` tone="${this._escapeHtml(d.tone)}"`:"";s+=`<mint-button variant="link" class="${d.classes||""}" data-action="row-action" data-row-index="${a}" data-action-index="${u}" data-column-key="${this._configuration.columns.indexOf(c)}"${f}${g}>`,m&&(s+=this._escapeHtml(String(m))),s+="</mint-button>"}});else typeof c.format=="function"?s+=this._escapeHtml(c.format(this,r)):c.data&&(s+=this._escapeHtml(String(r[c.data]||"")));s+="</td>"}),s+="</tr>"}),!this._fetching&&!this._loading&&e.length===0&&(this._fetchError?s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8 text-red-500 dark:text-red-400">Failed to load data: ${this._escapeHtml(this._fetchError)}</td></tr>`:s+=`<tr><td colspan="${this._configuration.columns.filter(r=>!r.hidden).length}" class="text-center py-8">No records found.</td></tr>`),s+="</tbody>",s+="</table>",this._configuration.loadMore&&(this._loading||this._fetching?(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+="<mint-spinner></mint-spinner>",s+="</div>"):(this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows)&&(s+='<div class="flex justify-center '+(this._inMintCard?"p-3.5":"mt-4")+'">',s+='<mint-button variant="ghost" data-action="load-more">Load more</mint-button>',s+="</div>")),s+="</mint-table>"):s+='<slot name="empty"></slot>';this.innerHTML=s,this._updatePagination(),this.querySelectorAll("mint-button[data-action]").forEach(r=>{r.render&&r.render()}),this.querySelectorAll("mint-button[data-button-type]").forEach(r=>{r.render&&r.render()}),this._attachEventListeners(),this._type==="ajax"&&!this._loaded&&!this._fetching&&!this._loading&&this._fetchData()}_attachRowClickHandler(){this._rowClickHandler&&this.removeEventListener("click",this._rowClickHandler,!0);const t=e=>{var l;const i=e.target;if(i.tagName==="MINT-BUTTON"||i.tagName==="BUTTON"||i.closest("mint-button")||i.closest("button")||i.closest("mint-popover")||i.closest("[data-action]"))return;const s=i.closest('tr[data-row-clickable="true"]');if(!s)return;const n=s.getAttribute("data-row-index");if(!n)return;const r=parseInt(n),o=this._getRows()[r];!o||!((l=this._configuration)!=null&&l.onRowClick)||(this._configuration.onRowClick.length===1?this._configuration.onRowClick(o):this._configuration.onRowClick(this,o))};this.addEventListener("click",t,!0),this._rowClickHandler=t}_attachPaginationListeners(){this.querySelectorAll('[data-action="page"]').forEach(t=>{t.addEventListener("click",()=>{if(t.getAttribute("active")==="true")return;const e=parseInt(t.getAttribute("data-page")||"1");e!==this._currentPage&&this._goToPage(e)})}),this.querySelectorAll('[data-action="page-prev"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage-1)})}),this.querySelectorAll('[data-action="page-next"]').forEach(t=>{t.addEventListener("click",()=>{this._goToPage(this._currentPage+1)})})}_attachTableEventListeners(){this.querySelectorAll('[data-action="row-action"]').forEach(t=>{t.addEventListener("click",()=>{var o;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-action-index")||"0"),s=parseInt(t.getAttribute("data-column-key")||"0"),r=this._getRows()[e],a=(o=this._configuration)==null?void 0:o.columns[s];a&&a.actions&&a.actions[i]&&a.actions[i].onClick(this,r)})}),this.querySelectorAll('[data-action="column-action"]').forEach(t=>{t.addEventListener("click",()=>{var a;const e=parseInt(t.getAttribute("data-row-index")||"0"),i=parseInt(t.getAttribute("data-column-key")||"0"),n=this._getRows()[e],r=(a=this._configuration)==null?void 0:a.columns[i];r&&r.action&&r.action.onClick(this,n)})})}_attachEventListeners(){var e;const t=this.querySelector(`#search-${this._tableId}`);if(t){const i=t.querySelector("input")||t._element;i?i.addEventListener("input",s=>{this._search=s.target.value,this._triggerSearch()}):t.addEventListener("input",s=>{this._search=t.value||s.target.value||"",this._triggerSearch()})}if(this._attachTableEventListeners(),this._attachRowClickHandler(),this.querySelectorAll("th[data-column-key]").forEach(i=>{i.addEventListener("click",()=>{var r;const s=parseInt(i.getAttribute("data-column-key")||"0"),n=(r=this._configuration)==null?void 0:r.columns[s];n&&this._toggleSort(n)})}),this.querySelectorAll("[data-button-type]").forEach(i=>{i.addEventListener("click",()=>{var r,a;const s=i.getAttribute("data-button-type"),n=(a=(r=this._configuration)==null?void 0:r.buttons)==null?void 0:a.find(o=>(o.type||"custom")===s);n&&this._handleButtonClick(n)})}),this.querySelectorAll("mint-checkbox[data-column-key]").forEach(i=>{i.addEventListener("change",s=>{var a;s.stopPropagation();const n=parseInt(i.getAttribute("data-column-key")||"0"),r=(a=this._configuration)==null?void 0:a.columns[n];r&&this._columnChange(s,r)}),i.addEventListener("click",s=>{s.stopPropagation()})}),this._attachPaginationListeners(),this.querySelectorAll('[data-action="load-more"]').forEach(i=>{i.addEventListener("click",()=>{this._loadMore()})}),(e=this._configuration)!=null&&e.loadMore){this._scrollHandler&&window.removeEventListener("scroll",this._scrollHandler);const i=()=>{const s=window.pageYOffset||document.documentElement.scrollTop,n=window.innerHeight;if(document.documentElement.scrollHeight-s-n<=100){const a=this._type==="ajax"?this._lastPage>0&&this._currentPage<this._lastPage:this._totalRows>0&&this._rowsToShow<this._totalRows;!this._loading&&!this._fetching&&a&&this._loadMore()}};this._scrollHandler=i,window.addEventListener("scroll",i)}}_escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}_getPageFromUrl(){if(!this._tableId)return null;const e=new URLSearchParams(window.location.search).get(`mui.${this._tableId}`);if(!e)return null;const i=parseInt(e,10);return isNaN(i)||i<1?null:i}_updatePageInUrl(t){if(!this._tableId)return;const e=new URL(window.location.href),i=e.searchParams;i.set(`mui.${this._tableId}`,t.toString()),t===1&&i.set(`mui.${this._tableId}`,"1"),window.history.replaceState({},"",e.toString())}_loadPageFromUrl(){if(!this._configuration||!this._tableId)return;const t=this._getPageFromUrl();t!==null&&(this._currentPage=t,this._offset=(this._currentPage-1)*this._perPage)}}customElements.get("mint-resource-table")||customElements.define("mint-resource-table",Mt);class It extends HTMLElement{constructor(){super(),this._overlay=null,this._offCanvas=null,this._header=null,this._headingSlot=null,this._bodySlot=null,this._actionsSlot=null,this._closeButton=null,this._darkModeObserver=null}static get observedAttributes(){return["id","heading","open","position","full-page","width","height"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","fixed","inset-0","z-50"),this.isOpen()||this.classList.add("hidden"),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null)}attributeChangedCallback(t,e,i){e!==i&&this.render()}getId(){return this.getAttribute("id")||""}getHeading(){return this.getAttribute("heading")||""}getPosition(){var e;const t=(e=this.getAttribute("position"))==null?void 0:e.toLowerCase();return t==="top"||t==="bottom"||t==="left"||t==="right"?t:"right"}isFullPage(){return this.getAttribute("full-page")==="true"}getWidth(){return this.getAttribute("width")||"320px"}getHeight(){return this.getAttribute("height")||""}_normalizeCssValue(t){return/^\d+(\.\d+)?$/.test(t.trim())?`${t.trim()}px`:t.trim()}isOpen(){return this.getAttribute("open")==="true"}open(){this.setAttribute("open","true")}close(){this.removeAttribute("open")}render(){const t=this.getId(),e=this.getHeading(),i=this.isOpen(),s=this.getPosition(),n=this.isFullPage(),r=this.getHeight();t&&(this.id=t),this._overlay||(this._overlay=document.createElement("div"),this._overlay.className="fixed inset-0 bg-black bg-opacity-50 transition-opacity duration-200 z-40",this._overlay.addEventListener("click",()=>this.close()),this.appendChild(this._overlay)),this._offCanvas||(this._offCanvas=document.createElement("div"),this.appendChild(this._offCanvas));const a=this._getPositionClasses(s,n);this._offCanvas.className=a;let o=this._offCanvas.querySelector(".off-canvas-content");if(o||(o=document.createElement("div"),o.className="off-canvas-content bg-white dark:bg-gray-900 dark:border dark:border-gray-700 shadow-xl flex flex-col pointer-events-auto transition-all duration-300 ease-out",o.style.transform=this._getTransformValue(s,!1),this._offCanvas.appendChild(o)),i?this._animateEnter():this._animateExit(),Array.from(o.classList).forEach(f=>{(f.startsWith("w-")||f.startsWith("max-w-")||f.startsWith("md:w-")||f.startsWith("md:max-w-")||f.startsWith("sm:w-")||f.startsWith("sm:max-w-"))&&o.classList.remove(f)}),o.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]"),o.classList.remove("has-custom-width","has-custom-height"),o.style.removeProperty("--off-canvas-width"),o.style.removeProperty("--off-canvas-height"),n)o.classList.add("w-full","h-full","max-w-none");else if(s==="top"||s==="bottom")if(o.classList.add("w-full","h-full","max-w-none"),r){const f=this._normalizeCssValue(r);o.style.setProperty("--off-canvas-height",f),o.classList.add("has-custom-height"),this._ensureHeightStyle()}else o.classList.add("md:max-h-[90vh]","md:h-auto");else{o.classList.add("w-full","h-full","max-w-none");const f=this.getWidth(),g=this._normalizeCssValue(f);o.style.setProperty("--off-canvas-width",g),o.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-gray-700 flex-shrink-0",o.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");e?(c||(c=document.createElement("mint-text"),c.setAttribute("size","sub-heading"),c.setAttribute("bold","true"),this._headingSlot.appendChild(c)),c.textContent=e):c&&c.remove(),Array.from(this.children).filter(f=>f!==this._overlay&&f!==this._offCanvas&&f!==this._headingSlot&&f.getAttribute("slot")==="heading").forEach(f=>{this._headingSlot&&f.parentElement!==this._headingSlot&&this._headingSlot.appendChild(f)}),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"),o.appendChild(this._bodySlot)),Array.from(this.children).filter(f=>f!==this._overlay&&f!==this._offCanvas&&f!==this._bodySlot&&f.getAttribute("slot")==="body").forEach(f=>{this._bodySlot&&f.parentElement!==this._bodySlot&&this._bodySlot.appendChild(f)}),this._actionsSlot||(this._actionsSlot=document.createElement("div"),this._actionsSlot.className="p-4 border-t border-gray-200 dark:border-gray-700 flex-shrink-0",this._actionsSlot.setAttribute("slot","actions"),o.appendChild(this._actionsSlot));let d=this._actionsSlot.querySelector("mint-stack");d||(d=document.createElement("mint-stack"),d.setAttribute("direction","horizontal"),d.className="justify-end",this._actionsSlot.appendChild(d)),Array.from(this.children).filter(f=>f!==this._overlay&&f!==this._offCanvas&&f!==this._actionsSlot&&f.getAttribute("slot")==="actions").forEach(f=>{Array.from(f.children).forEach(_=>{_.parentElement!==d&&d.appendChild(_)}),f.parentElement&&f.remove()}),Array.from(this.children).forEach(f=>{f!==this._overlay&&f!==this._offCanvas&&f.getAttribute("slot")!=="heading"&&f.getAttribute("slot")!=="body"&&f.getAttribute("slot")!=="actions"&&f!==this._headingSlot&&f!==this._bodySlot&&f!==this._actionsSlot&&f.parentElement!==this._bodySlot&&this._bodySlot.appendChild(f)}),this._updateBackgroundColor()}_getPositionClasses(t,e){const i="fixed z-50 pointer-events-none transition-all duration-300 ease-out";switch(t){case"top":return`${i} inset-0 md:inset-x-0 md:top-0 md:bottom-auto ${e?"md:h-full":"md:h-auto"}`;case"bottom":return`${i} inset-0 md:inset-x-0 md:bottom-0 md:top-auto ${e?"md:h-full":"md:h-auto"}`;case"left":return`${i} inset-0 md:inset-y-0 md:left-0 md:right-auto ${e?"md:w-full":"md:w-auto"}`;case"right":return`${i} inset-0 md:inset-y-0 md:right-0 md:left-auto ${e?"md:w-full":"md:w-auto"}`;default:return`${i} inset-0 md:inset-y-0 md:right-0 md:left-auto ${e?"md:w-full":"md:w-auto"}`}}_getTransformValue(t,e){if(e)switch(t){case"top":return"translateY(0)";case"bottom":return"translateY(0)";case"left":return"translateX(0)";case"right":return"translateX(0)";default:return"translateX(0)"}else switch(t){case"top":return"translateY(-100%)";case"bottom":return"translateY(100%)";case"left":return"translateX(-100%)";case"right":return"translateX(100%)";default:return"translateX(100%)"}}_updateBackgroundColor(){if(!this._offCanvas)return;const t=document.documentElement.classList.contains("dark"),e=this._offCanvas.querySelector(".off-canvas-content");e&&(t?(e.classList.remove("bg-white"),e.classList.add("bg-gray-900","border","border-gray-700")):(e.classList.remove("bg-gray-900","border","border-gray-700"),e.classList.add("bg-white")))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}))}_animateEnter(){var i;const t=(i=this._offCanvas)==null?void 0:i.querySelector(".off-canvas-content");if(!t)return;const e=this.getPosition();t.style.transform=this._getTransformValue(e,!1),t.style.transition="transform 300ms ease-out",this.classList.remove("hidden"),requestAnimationFrame(()=>{requestAnimationFrame(()=>{t.style.transform=this._getTransformValue(e,!0)})})}_animateExit(){var i;const t=(i=this._offCanvas)==null?void 0:i.querySelector(".off-canvas-content");if(!t){this.classList.add("hidden");return}const e=this.getPosition();t.style.transition="transform 300ms ease-in",t.style.transform=this._getTransformValue(e,!1),setTimeout(()=>{this.classList.add("hidden"),t.style.transform="",t.style.transition=""},300)}_ensureWidthStyle(){if(!document.getElementById("off-canvas-width-style")){const t=document.createElement("style");t.id="off-canvas-width-style",t.textContent=`
147
- @media (min-width: 768px) {
148
- .off-canvas-content.has-custom-width {
149
- width: min(var(--off-canvas-width), 100vw) !important;
150
- max-width: 100% !important;
151
- }
152
- }
153
- `,document.head.appendChild(t)}}_ensureHeightStyle(){if(!document.getElementById("off-canvas-height-style")){const t=document.createElement("style");t.id="off-canvas-height-style",t.textContent=`
154
- @media (min-width: 768px) {
155
- .off-canvas-content.has-custom-height {
156
- height: min(var(--off-canvas-height), 100vh) !important;
157
- max-height: 100% !important;
158
- }
159
- }
160
- `,document.head.appendChild(t)}}}customElements.get("mint-off-canvas")||customElements.define("mint-off-canvas",It);class Nt extends HTMLElement{constructor(){super(),this._clickHandler=null}static get observedAttributes(){return["active","disabled","target"]}connectedCallback(){this.render(),this.setupEventListeners()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getTarget(){return this.getAttribute("target")||""}isActive(){const t=this.getAttribute("active");return t!==null&&t!=="false"}isDisabled(){return this.getAttribute("disabled")==="true"}get active(){return this.isActive()}set active(t){t?this.setAttribute("active","true"):this.setAttribute("active","false")}render(){const t=this.isActive(),e=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","transition-all","duration-200","rounded-lg","border","text-gray-700","dark:text-gray-300");const i=this.closest("mint-tab-list"),s=(i==null?void 0:i.getAttribute("position"))||"top",n=s==="left"||s==="right";e?(this.classList.add("opacity-60","cursor-not-allowed","pointer-events-none","bg-gray-50","dark:bg-gray-900","border-gray-300","dark:border-gray-700","text-gray-400","dark:text-gray-500"),this.classList.remove("cursor-pointer")):t?(this.classList.add("bg-white","dark:bg-gray-900","border-gray-200","dark:border-gray-700","text-gray-900","dark:text-gray-100","shadow-sm","relative","z-10"),n?s==="left"?this.classList.add("mr-[-1px]"):this.classList.add("ml-[-1px]"):this.classList.add("mb-[-1px]")):this.classList.add("bg-gray-100","dark:bg-gray-900","border-gray-200","dark:border-gray-700","text-gray-600","dark:text-gray-400","hover:bg-gray-50","dark:hover:bg-gray-600")}setupEventListeners(){this.isDisabled()||this._clickHandler||(this._clickHandler=this.handleClick.bind(this),this.addEventListener("click",this._clickHandler))}removeEventListeners(){this._clickHandler&&(this.removeEventListener("click",this._clickHandler),this._clickHandler=null)}handleClick(t){if(this.isDisabled()){t.preventDefault(),t.stopPropagation();return}t.__mintTabsSynthetic||(t.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",Nt);class Pt extends HTMLElement{static get observedAttributes(){return["position"]}constructor(){super()}connectedCallback(){this.render()}attributeChangedCallback(t,e,i){e!==i&&this.render()}getPosition(){return this.getAttribute("position")||"top"}render(){const t=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-gray-900","dark:border-gray-700","border-gray-200","w-auto","rounded-lg","gap-2"),t==="top"?this.classList.add("inline-flex","flex-row","mb-0","self-start"):t==="left"?this.classList.add("flex","flex-col","mr-0"):t==="right"&&this.classList.add("flex","flex-col","ml-0")}}customElements.get("mint-tab-list")||customElements.define("mint-tab-list",Pt);class Ft 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(t,e,i){e!==i&&t==="id"&&(this.render(),this.checkInitialVisibility())}getId(){return this.getAttribute("id")||""}show(){this.style.display="block"}hide(){this.style.display="none"}checkInitialVisibility(){const t=this.closest("mint-tabs");if(!t){this.style.display="none";return}const e=t.querySelectorAll("mint-tab");let i=!1;if(e.forEach(s=>{const n=s.getAttribute("active"),r=s.getAttribute("target"),a=this.getId();n==="true"&&r===a&&(i=!0)}),!i&&e.length>0){const n=e[0].getAttribute("target"),r=this.getId();n===r&&!t.querySelector('mint-tab[active="true"]')&&(i=!0)}i?this.style.display="block":this.style.display="none"}render(){}}customElements.get("mint-tab-content")||customElements.define("mint-tab-content",Ft);class Ot 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(),this._mutationObserver=null)}render(){const t=this.querySelector("mint-tab-list");if(this.querySelectorAll("mint-tab-content"),!t){console.warn("mint-tabs: mint-tab-list is required");return}const e=t.getAttribute("position")||"top";this.classList.remove("flex","flex-row","flex-col","gap-4","gap-6"),e==="left"||e==="right"?(this.classList.add("flex","flex-row","items-start"),e==="left"?(t.classList.add("mr-4","flex-shrink-0"),t.classList.remove("ml-4")):(t.classList.add("ml-4","flex-shrink-0","order-2"),t.classList.remove("mr-4"),this.querySelectorAll("mint-tab-content").forEach(s=>{s.classList.add("order-1")}))):(this.classList.add("flex","flex-col"),t.classList.remove("mr-4","ml-4","flex-shrink-0","order-2"),this.querySelectorAll("mint-tab-content").forEach(s=>{s.classList.remove("order-1")}))}initializeActiveTab(){requestAnimationFrame(()=>{const t=this.querySelectorAll("mint-tab");let e=null;if(t.forEach(s=>{s.getAttribute("active")==="true"&&(e=s)}),!e&&t.length>0&&(e=t[0],e.setAttribute("active","true")),e){const s=e.getAttribute("target");s?this.showContent(s):this.hideAllContent()}else this.hideAllContent();this.querySelectorAll("mint-tab-content").forEach(s=>{const n=s;n.checkInitialVisibility&&n.checkInitialVisibility()})})}hideAllContent(){this.querySelectorAll("mint-tab-content").forEach(e=>{const i=e;i.hide?i.hide():e.style.display="none"})}showContent(t){this.querySelectorAll("mint-tab-content").forEach(s=>{const n=s;n.hide?n.hide():s.style.display="none"});const i=this.querySelector(`mint-tab-content[id="${t}"]`);i&&(i.show?i.show():i.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),this._tabClickHandler=null)}setupMutationObserver(){this._mutationObserver=new MutationObserver(()=>{this.render()});const t=this.querySelector("mint-tab-list");t&&this._mutationObserver.observe(t,{attributes:!0,attributeFilter:["position"]})}handleTabClick(t){var r,a;const e=(r=t.detail)==null?void 0:r.tab,i=(a=t.detail)==null?void 0:a.target;if(!e)return;const s=e.closest("mint-tab-list");if(!s)return;s.querySelectorAll("mint-tab").forEach(o=>{const l=o;o===e?l.active=!0:l.active=!1}),i&&this.showContent(i)}}customElements.get("mint-tabs")||customElements.define("mint-tabs",Ot);const it=class it extends HTMLElement{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=.3,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=["#3b82f6","#ef4444","#10b981","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#f97316"],this._legendHeight=0,this._rotatedLabelHeight=0}static get observedAttributes(){return["type","data","width","height","show-legend","show-grid","show-tooltip","curve-tension"]}connectedCallback(){this.classList.add("box-border","m-0","p-0","border-0","align-baseline","block","w-full");let t=this._getReactiveValue(this.data);t&&typeof t=="object"&&!Array.isArray(t)&&"datasets"in t&&(this._chartData=t),this._setupDataObserver(),this._setupDarkModeObserver(),this._setupResizeObserver(),requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.render()})})}_getReactiveValue(t){if(!t||typeof t!="object")return t;if("_value"in t||"__v_isRef"in t){if(typeof t.value<"u")return t.value;if("_value"in t)return t._value}return"__v_raw"in t||"__v_isReactive"in t||"__ob__"in t,t}_setupDataObserver(){let t=null,e=0;const i=()=>{if(!this.isConnected)return;const n=this._getReactiveValue(this.data);let r=null;n&&typeof n=="object"&&!Array.isArray(n)&&"datasets"in n&&(r=n),r!==t&&r&&(t=r,this._chartData=r,this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this.render())};requestAnimationFrame(()=>{i(),requestAnimationFrame(()=>{i()})});const s=setInterval(()=>{if(!this.isConnected){clearInterval(s);return}if(i(),e++,e>50){clearInterval(s);const n=setInterval(()=>{if(!this.isConnected){clearInterval(n);return}i()},1e3);this._dataCheckInterval=n}},100);this._dataCheckInterval=s}_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(t=>clearTimeout(t)),this._pieChartTimeouts.clear(),this._pieChartClickOutsideHandler&&(document.removeEventListener("click",this._pieChartClickOutsideHandler,!0),this._pieChartClickOutsideHandler=null),this._chartClickOutsideHandler&&(document.removeEventListener("click",this._chartClickOutsideHandler,!0),this._chartClickOutsideHandler=null),this._pieChartTooltipShown=!1,this._pieChartGroup=null,this._pinnedXValue=null,this._tooltipAnimationFrame!==null&&(cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=null),this._dataObserver&&(this._dataObserver.disconnect(),this._dataObserver=null),this._darkModeObserver&&(this._darkModeObserver.disconnect(),this._darkModeObserver=null),this._dataCheckInterval&&(clearInterval(this._dataCheckInterval),this._dataCheckInterval=null),this._svg&&(this._chartTooltipMouseMove&&(this._svg.removeEventListener("mousemove",this._chartTooltipMouseMove),this._chartTooltipMouseMove=null),this._chartTooltipMouseLeave&&(this._svg.removeEventListener("mouseleave",this._chartTooltipMouseLeave),this._chartTooltipMouseLeave=null),this._chartTooltipTouchStart&&(this._svg.removeEventListener("touchstart",this._chartTooltipTouchStart),this._chartTooltipTouchStart=null),this._chartTooltipTouchMove&&(this._svg.removeEventListener("touchmove",this._chartTooltipTouchMove),this._chartTooltipTouchMove=null),this._chartTooltipTouchEnd&&(this._svg.removeEventListener("touchend",this._chartTooltipTouchEnd),this._chartTooltipTouchEnd=null)),this._chartTooltipScrollHandler){window.removeEventListener("scroll",this._chartTooltipScrollHandler,!0),this._chartContainer&&this._chartContainer.removeEventListener("scroll",this._chartTooltipScrollHandler,!0);let t=this.parentElement;for(;t;)t.removeEventListener("scroll",this._chartTooltipScrollHandler,!0),t=t.parentElement;this._chartTooltipScrollHandler=null}this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._windowResizeHandler&&(window.removeEventListener("resize",this._windowResizeHandler),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(){var r,a;if(!this.isConnected)return;const t=this.getBoundingClientRect(),e=t.width||((r=this.parentElement)==null?void 0:r.clientWidth)||800,i=t.height||((a=this.parentElement)==null?void 0:a.clientHeight)||400,s=this._calculateDimension(this._widthValue,e,e),n=this._calculateDimension(this._heightValue,i,400);(s!==this._width||n!==this._height)&&(this._width=s,this._height=n,this.render())}_setupResizeObserver(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=null),this._windowResizeHandler&&(window.removeEventListener("resize",this._windowResizeHandler),this._windowResizeHandler=null);let t=null;const e=()=>{t&&clearTimeout(t),t=window.setTimeout(()=>{this._handleResize()},100)};this._windowResizeHandler=e,this._resizeObserver=new ResizeObserver(()=>{e()}),this._resizeObserver.observe(this),window.addEventListener("resize",e)}attributeChangedCallback(t,e,i){if(e!==i){if(t==="data"&&this.data&&typeof this.data=="object"&&(this._chartData=this.data),(t==="width"||t==="height")&&this.isConnected){const s=e&&e.endsWith("%"),n=i&&i.endsWith("%");s!==n&&this._setupResizeObserver()}this.isConnected&&requestAnimationFrame(()=>{this.render()})}}get type(){const t=this.getAttribute("type")||"line";return t==="line"||t==="bar"||t==="area"||t==="pie"?t:"line"}set type(t){this.setAttribute("type",t)}get data(){return this._chartData}set data(t){if(typeof t=="string")try{this._chartData=JSON.parse(t)}catch(e){console.error("mint-chart: Invalid data JSON",e),this._chartData=null}else this._chartData=t;this.isConnected&&requestAnimationFrame(()=>{this.render()})}get width(){const t=this.getAttribute("width");if(!t)return this._widthValue;if(t.endsWith("%"))return t;const e=parseInt(t,10);return isNaN(e)?this._widthValue:e}set width(t){this.setAttribute("width",t.toString())}get height(){const t=this.getAttribute("height");if(!t)return this._heightValue;if(t.endsWith("%"))return t;const e=parseInt(t,10);return isNaN(e)?this._heightValue:e}set height(t){this.setAttribute("height",t.toString())}_calculateDimension(t,e,i){if(typeof t=="number")return t;if(typeof t=="string"&&t.endsWith("%")){const s=parseFloat(t);if(!isNaN(s))return e*s/100}return i}_scheduleRender(){this._renderScheduled||(this._renderScheduled=!0,requestAnimationFrame(()=>{this._renderScheduled=!1,this.render()}))}_isDatasetVisible(t,e){if(t.id){const i=this._datasetVisibility.get(t.id);if(i!==void 0)return i}return t.visible!==!1}_initializeDatasetVisibility(){this._chartData&&this._chartData.datasets.forEach((t,e)=>{t.id&&(this._datasetVisibility.has(t.id)||this._datasetVisibility.set(t.id,t.visible!==!1))})}render(){var r,a,o,l;if(!this.isConnected)return;this._plotPoints.clear(),this._activeXValue=null,(r=this._cachedTooltipContent)==null||r.clear(),(a=this._cachedXPositions)==null||a.clear(),this._chartType=this.type;let t=this._getReactiveValue(this.data);if(t&&typeof t=="object"&&!Array.isArray(t)&&"datasets"in t&&(this._chartData=t),!this._chartData){const c=this.getAttribute("data");if(c)try{this._chartData=JSON.parse(c)}catch(h){console.error("mint-chart: Invalid data JSON",h),this._chartData=null}}this._widthValue=this.width,this._heightValue=this.height;const e=this.getBoundingClientRect(),i=e.width||((o=this.parentElement)==null?void 0:o.clientWidth)||800,s=e.height||((l=this.parentElement)==null?void 0:l.clientHeight)||400;this._width=this._calculateDimension(this._widthValue,i,i),this._height=this._calculateDimension(this._heightValue,s,400),this._showLegend=this.getAttribute("show-legend")!=="false",this._showGrid=this.getAttribute("show-grid")!=="false",this._showTooltip=this.getAttribute("show-tooltip")!=="false";const n=this.getAttribute("curve-tension");if(n!==null){const c=parseFloat(n);this._curveTension=isNaN(c)?.3:Math.max(0,Math.min(1,c))}else this._curveTension=.3;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-gray-800 text-white text-xs rounded px-2 py-1 shadow-lg opacity-0 transition-opacity",this._tooltip.style.display="none",document.body.appendChild(this._tooltip)}_showTooltipAt(t,e,i){if(!this._tooltip)return;this._tooltipHideTimeout!==null&&(clearTimeout(this._tooltipHideTimeout),this._tooltipHideTimeout=null),this._lastTooltipContent!==i&&(this._tooltip.innerHTML=i,this._lastTooltipContent=i),(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");const n=this._tooltip.getBoundingClientRect(),r=window.innerWidth,a=window.innerHeight;let o=t+10,l=e-n.height-8;o+n.width>r&&(o=t-n.width-10),o<0&&(o=10),l<0&&(l=e+20),l+n.height>a&&(l=e-n.height-8,l<0&&(l=10));const c=`${o}px`,h=`${l}px`;this._tooltip.style.left!==c&&(this._tooltip.style.left=c),this._tooltip.style.top!==h&&(this._tooltip.style.top=h)}_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");const t=document.documentElement.classList.contains("dark");this._verticalLine.setAttribute("stroke",t?"#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";const e=this._svg.querySelector(".chart-legend");e&&e.parentNode?e.parentNode.insertBefore(this._verticalLine,e):this._svg.appendChild(this._verticalLine)}_showVerticalLineAtX(t,e){if(!this._verticalLine)return;const s=this._chartType==="bar"?this._scaleXForBarChart(t,e):this._scaleX(t,e);this._verticalLine.setAttribute("x1",s.toString()),this._verticalLine.setAttribute("y1",e.y.toString()),this._verticalLine.setAttribute("x2",s.toString()),this._verticalLine.setAttribute("y2",(e.y+e.height).toString()),this._verticalLine.style.opacity="1"}_hideVerticalLine(){this._verticalLine&&(this._verticalLine.style.opacity="0")}_showPlotPointsForX(t){this._plotPoints.forEach(s=>{s.forEach(n=>{n.style.opacity="0"})});const e=String(t),i=this._plotPoints.get(e);i&&i.forEach(s=>{s.style.opacity="1"})}_hidePlotPoints(){this._plotPoints.forEach(t=>{t.forEach(e=>{e.style.opacity="0"})})}_calculateMaxYAxisLabelWidth(){if(!this._showGrid||!this._chartData)return 0;const e=document.createElement("canvas").getContext("2d");if(!e)return 60;e.font="12px system-ui, -apple-system, sans-serif";const i=this._showLegend?Math.max(this._legendHeight,60):0,s=this._height-i,r=Math.floor(s/35),a=Math.min(5,r);let o=0;for(let l=0;l<=a;l++){const c=this._getYRange(),h=c.max-(c.max-c.min)/a*l,p=this._formatYAxisValue(h),d=e.measureText(p);o=Math.max(o,d.width)}return Math.ceil(o)+20}_getChartBounds(){const t=this._calculateMaxYAxisLabelWidth(),e=`${this._width}-${this._height}-${this._showGrid}-${this._showLegend}-${this._legendHeight}-${t}-${this._rotatedLabelHeight}`;if(this._cachedBounds.bounds&&this._cachedBounds.dataHash===e)return this._cachedBounds.bounds;let i=0,s=0,n=0,r=0;this._showGrid&&(i=t+10);const l=(this._rotatedLabelHeight>0?30:20)+this._rotatedLabelHeight+12;let c=l;this._showLegend&&(c=l+20+Math.max(this._legendHeight,60));const h=this._height-n-i-s,p=h-c,d=100;let u=1;if(p<d&&c>0){const b=h-d;b>0?(u=Math.min(1,b/c),u=Math.max(.5,u)):u=.5}r=c*u;const m=this._width*.3;let f=i,g=1;i>m&&(g=m/i,f=m);const _={width:(this._width-f-s)*g,height:this._height-n-r,x:f,y:n};return this._cachedBounds={bounds:_,dataHash:e},_}_getAllDataPoints(){if(!this._chartData)return[];const t=[];return this._chartData.datasets.forEach((e,i)=>{this._isDatasetVisible(e,i)&&t.push(...e.data)}),t}_getXValues(){if(!this._chartData)return[];const t=JSON.stringify(this._chartData.labels)+JSON.stringify(this._chartData.datasets.map(s=>s.data.map(n=>n.x)));if(this._cachedXValues.values&&this._cachedXValues.dataHash===t)return this._cachedXValues.values;if(this._chartData.labels&&this._chartData.labels.length>0)return this._cachedXValues={values:this._chartData.labels,dataHash:t},this._chartData.labels;const e=new Set;this._chartData.datasets.forEach((s,n)=>{this._isDatasetVisible(s,n)&&s.data.forEach(r=>{e.add(r.x)})});const i=Array.from(e).sort((s,n)=>{if(typeof s=="number"&&typeof n=="number")return s-n;const r=String(s),a=String(n),o=/^([A-Za-z]{3})\s+(\d{4})$/,l=r.match(o),c=a.match(o);if(l&&c){const h=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],p=h.indexOf(l[1]),d=h.indexOf(c[1]),u=parseInt(l[2]),m=parseInt(c[2]);return u!==m?u-m:p-d}return r.localeCompare(a)});return this._cachedXValues={values:i,dataHash:t},i}_getYRange(){if(!this._chartData)return{min:0,max:100};const t=JSON.stringify(this._chartData.datasets.map(o=>o.data.map(l=>l.y)));if(this._cachedYRange.range&&this._cachedYRange.dataHash===t)return this._cachedYRange.range;const e=this._getAllDataPoints();if(e.length===0){const o={min:0,max:100};return this._cachedYRange={range:o,dataHash:t},o}const i=e.map(o=>o.y),s=Math.min(...i),n=Math.max(...i),r=(n-s)*.1,a={min:Math.max(0,s-r),max:n+r};return this._cachedYRange={range:a,dataHash:t},a}_hasDecimalValues(){return this._getAllDataPoints().some(e=>e.y%1!==0)}_formatValueByString(t,e){switch(e.toLowerCase()){case"currency":case"currency-usd":return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(t);case"currency-eur":return new Intl.NumberFormat("en-US",{style:"currency",currency:"EUR"}).format(t);case"currency-gbp":return new Intl.NumberFormat("en-US",{style:"currency",currency:"GBP"}).format(t);case"number":case"number-with-commas":return new Intl.NumberFormat("en-US").format(t);case"percent":return new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:1}).format(t/100);default:return this._hasDecimalValues()&&t%1!==0?t.toFixed(1):Math.round(t).toString()}}_formatXAxisValue(t){var e;if((e=this._chartData)!=null&&e.formatXAxis){if(typeof this._chartData.formatXAxis=="function")return this._chartData.formatXAxis(t);if(typeof this._chartData.formatXAxis=="string")return String(t)}return String(t)}_formatYAxisValue(t){var i,s,n,r;if((i=this._chartData)!=null&&i.formatYAxis){if(typeof this._chartData.formatYAxis=="function")return this._chartData.formatYAxis(t);if(typeof this._chartData.formatYAxis=="string")return this._formatValueByString(t,this._chartData.formatYAxis)}if((r=(n=(s=this._chartData)==null?void 0:s.datasets)==null?void 0:n[0])!=null&&r.formatValue){if(typeof this._chartData.datasets[0].formatValue=="function")return this._chartData.datasets[0].formatValue(t);if(typeof this._chartData.datasets[0].formatValue=="string")return this._formatValueByString(t,this._chartData.datasets[0].formatValue)}return this._hasDecimalValues()&&t%1!==0?t.toFixed(1):Math.round(t).toString()}_formatValue(t,e){if(e.formatValue){if(typeof e.formatValue=="function")return e.formatValue(t);if(typeof e.formatValue=="string")return this._formatValueByString(t,e.formatValue)}return String(t)}_getAllDatasetsAtX(t){if(!this._chartData)return[];const e=[];return this._chartData.datasets.forEach((i,s)=>{if(!this._isDatasetVisible(i,s))return;const n=i.data.find(r=>String(r.x)===String(t));if(n){const r=this._getDatasetColor(i,s),a=this._formatValue(n.y,i);e.push({name:i.name,value:n.y,color:r,formattedValue:a})}}),e}_findNearestXValue(t){if(!this._chartData)return null;const e=this._getChartBounds(),i=this._getXValues();if(i.length===0)return null;const s=this._chartType==="bar";let n=null,r=1/0;return i.forEach(a=>{const o=s?this._scaleXForBarChart(a,e):this._scaleX(a,e),l=Math.abs(t-o);l<r&&(r=l,n=a)}),n}_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 t=this.parentElement;for(;t;){const e=window.getComputedStyle(t),i=e.overflow,s=e.overflowY;(i==="auto"||i==="scroll"||s==="auto"||s==="scroll")&&t.addEventListener("scroll",this._chartTooltipScrollHandler,!0),t=t.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();const t=this._getChartBounds();let e=0,i=0;const s=c=>{!this._chartContainer||!this._svg||(e=c.clientX,i=c.clientY,this._tooltipAnimationFrame!==null&&cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=requestAnimationFrame(()=>{if(this._tooltipAnimationFrame=null,!this._svg)return;const h=this._svg.getBoundingClientRect(),p=e-h.left,d=i-h.top;if(p<t.x||p>t.x+t.width||d<t.y||d>t.y+t.height){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}const u=this._findNearestXValue(p);if(!u){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;return}if(this._pinnedXValue!==null&&this._pinnedXValue===u){const g=this._pinnedXValue,_=this._getAllDatasetsAtX(g);if(_.length>0){this._activeXValue=g,this._showPlotPointsForX(g),this._showVerticalLineAtX(g,t);let b=this._cachedTooltipContent.get(g);b||(b=`<strong>${g}</strong><br/>`,_.forEach(v=>{b+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
161
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${v.color}; border-radius: 2px;"></span>
162
- <span>${v.name}: ${v.formattedValue}</span>
163
- </div>`}),this._cachedTooltipContent.set(g,b)),this._updateTooltipPosition(e,i),this._lastTooltipContent!==b&&this._showTooltipAt(e,i,b);return}}if(this._activeXValue===u){this._updateTooltipPosition(e,i);return}const m=this._getAllDatasetsAtX(u);if(m.length===0){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine();return}this._activeXValue=u,this._showPlotPointsForX(u),this._showVerticalLineAtX(u,t);let f=this._cachedTooltipContent.get(u);if(!f){if(f=`<strong>${u}</strong><br/>`,m.forEach(g=>{f+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
164
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${g.color}; border-radius: 2px;"></span>
165
- <span>${g.name}: ${g.formattedValue}</span>
166
- </div>`}),this._cachedTooltipContent.size>=it.MAX_CACHE_SIZE){const g=this._cachedTooltipContent.keys().next().value;g!==void 0&&this._cachedTooltipContent.delete(g)}this._cachedTooltipContent.set(u,f)}this._showTooltipAt(e,i,f)}))},n=()=>{this._tooltipAnimationFrame!==null&&(cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=null),this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null},r=c=>{if(!this._chartContainer||!this._svg)return;c.stopPropagation();const h=this._svg.getBoundingClientRect(),p=c.clientX-h.left,d=c.clientY-h.top;if(p<t.x||p>t.x+t.width||d<t.y||d>t.y+t.height)return;const u=this._findNearestXValue(p);if(u)if(this._pinnedXValue===u)this._pinnedXValue=null,this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;else{this._pinnedXValue=u,this._activeXValue=u;const m=this._getAllDatasetsAtX(u);if(m.length===0)return;this._showPlotPointsForX(u),this._showVerticalLineAtX(u,t);let f=this._cachedTooltipContent.get(u);f||(f=`<strong>${u}</strong><br/>`,m.forEach(g=>{f+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
167
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${g.color}; border-radius: 2px;"></span>
168
- <span>${g.name}: ${g.formattedValue}</span>
169
- </div>`}),this._cachedTooltipContent.set(u,f)),this._showTooltipAt(c.clientX,c.clientY,f)}},a=c=>{if(c.preventDefault(),!this._chartContainer||!this._svg)return;const h=c.touches[0];if(!h)return;const p=this._svg.getBoundingClientRect(),d=h.clientX-p.left,u=h.clientY-p.top;if(d<t.x||d>t.x+t.width||u<t.y||u>t.y+t.height){this._pinnedXValue===null&&(this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null);return}const m=this._findNearestXValue(d);if(!m){this._pinnedXValue===null&&(this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null);return}if(this._pinnedXValue===m)this._pinnedXValue=null,this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;else{this._pinnedXValue=m,this._activeXValue=m;const f=this._getAllDatasetsAtX(m);if(f.length===0)return;this._showPlotPointsForX(m),this._showVerticalLineAtX(m,t);let g=this._cachedTooltipContent.get(m);g||(g=`<strong>${m}</strong><br/>`,f.forEach(_=>{g+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
170
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${_.color}; border-radius: 2px;"></span>
171
- <span>${_.name}: ${_.formattedValue}</span>
172
- </div>`}),this._cachedTooltipContent.set(m,g)),this._showTooltipAt(h.clientX,h.clientY,g)}},o=c=>{if(c.preventDefault(),!this._chartContainer||!this._svg)return;const h=c.touches[0];h&&(this._tooltipAnimationFrame!==null&&cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=requestAnimationFrame(()=>{if(this._tooltipAnimationFrame=null,!this._svg)return;const p=this._svg.getBoundingClientRect(),d=h.clientX-p.left,u=h.clientY-p.top;if(d<t.x||d>t.x+t.width||u<t.y||u>t.y+t.height){if(this._pinnedXValue===null)this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null;else{const _=this._pinnedXValue,b=this._getAllDatasetsAtX(_);if(b.length>0){this._activeXValue=_,this._showPlotPointsForX(_),this._showVerticalLineAtX(_,t);let v=this._cachedTooltipContent.get(_);v||(v=`<strong>${_}</strong><br/>`,b.forEach(y=>{v+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
173
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${y.color}; border-radius: 2px;"></span>
174
- <span>${y.name}: ${y.formattedValue}</span>
175
- </div>`}),this._cachedTooltipContent.set(_,v)),this._updateTooltipPosition(h.clientX,h.clientY),this._lastTooltipContent!==v&&this._showTooltipAt(h.clientX,h.clientY,v)}}return}if(this._pinnedXValue!==null){const _=this._pinnedXValue,b=this._getAllDatasetsAtX(_);if(b.length>0){this._activeXValue=_,this._showPlotPointsForX(_),this._showVerticalLineAtX(_,t);let v=this._cachedTooltipContent.get(_);v||(v=`<strong>${_}</strong><br/>`,b.forEach(y=>{v+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
176
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${y.color}; border-radius: 2px;"></span>
177
- <span>${y.name}: ${y.formattedValue}</span>
178
- </div>`}),this._cachedTooltipContent.set(_,v)),this._updateTooltipPosition(h.clientX,h.clientY),this._lastTooltipContent!==v&&this._showTooltipAt(h.clientX,h.clientY,v);return}}const m=this._findNearestXValue(d);if(!m){this._pinnedXValue===null&&(this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null);return}if(this._activeXValue===m){this._updateTooltipPosition(h.clientX,h.clientY);return}const f=this._getAllDatasetsAtX(m);if(f.length===0){this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine();return}this._activeXValue=m,this._showPlotPointsForX(m),this._showVerticalLineAtX(m,t);let g=this._cachedTooltipContent.get(m);if(!g){if(g=`<strong>${m}</strong><br/>`,f.forEach(_=>{g+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
179
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${_.color}; border-radius: 2px;"></span>
180
- <span>${_.name}: ${_.formattedValue}</span>
181
- </div>`}),this._cachedTooltipContent.size>=it.MAX_CACHE_SIZE){const _=this._cachedTooltipContent.keys().next().value;_!==void 0&&this._cachedTooltipContent.delete(_)}this._cachedTooltipContent.set(m,g)}this._showTooltipAt(h.clientX,h.clientY,g)}))},l=()=>{this._tooltipAnimationFrame!==null&&(cancelAnimationFrame(this._tooltipAnimationFrame),this._tooltipAnimationFrame=null),this._pinnedXValue===null&&setTimeout(()=>{this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null},500)};this._chartClickOutsideHandler||(this._chartClickOutsideHandler=c=>{if(this._pinnedXValue===null)return;const h=c.target;this._svg&&!this._svg.contains(h)&&(this._pinnedXValue=null,this._hideTooltip(),this._hidePlotPoints(),this._hideVerticalLine(),this._activeXValue=null)},document.addEventListener("click",this._chartClickOutsideHandler,!0)),this._svg.addEventListener("mousemove",s),this._svg.addEventListener("mouseleave",n),this._svg.addEventListener("click",r),this._svg.addEventListener("touchstart",a,{passive:!1}),this._svg.addEventListener("touchmove",o,{passive:!1}),this._svg.addEventListener("touchend",l),this._chartTooltipMouseMove=s,this._chartTooltipMouseLeave=n,this._chartTooltipClick=r,this._chartTooltipTouchStart=a,this._chartTooltipTouchMove=o,this._chartTooltipTouchEnd=l}_updateTooltipPosition(t,e){if(!this._tooltip||this._tooltip.style.display==="none"||this._tooltip.style.opacity==="0")return;const i=this._tooltip.getBoundingClientRect(),s=window.innerWidth,n=window.innerHeight;let r=t+10,a=e-i.height-8;r+i.width>s&&(r=t-i.width-10),r<0&&(r=10),a<0&&(a=e+20),a+i.height>n&&(a=e-i.height-8,a<0&&(a=10));const o=`${r}px`,l=`${a}px`;this._tooltip.style.left!==o&&(this._tooltip.style.left=o),this._tooltip.style.top!==l&&(this._tooltip.style.top=l)}_scaleX(t,e){const i=this._getXValues();if(i.length===0)return e.x;const s=i.indexOf(t);if(s===-1)return e.x;const n=e.width/Math.max(1,i.length-1);return e.x+s*n}_scaleY(t,e){const i=this._getYRange();if(i.max===i.min)return e.y+e.height/2;const s=(t-i.min)/(i.max-i.min);return e.y+e.height-s*e.height}_getDatasetColor(t,e,i){return i!==void 0?t.color||this._defaultColors[i%this._defaultColors.length]:t.color||this._defaultColors[e%this._defaultColors.length]}_getContrastColor(t){const e=t.replace("#",""),i=parseInt(e.substring(0,2),16),s=parseInt(e.substring(2,4),16),n=parseInt(e.substring(4,6),16);return(.299*i+.587*s+.114*n)/255>.5?"#000000":"#ffffff"}_calculateRotatedLabelHeight(){if(this._rotatedLabelHeight=0,!this._chartData||!this._showGrid)return;const t=this._getXValues();if(t.length<=1)return;const e={width:this._width-(this._showGrid?60:0)-0,height:this._height-(this._showLegend?Math.max(this._legendHeight,60):0)-0,x:this._showGrid?60:0,y:0},i=this._chartType==="bar",s=[];t.forEach(c=>{const h=i?this._scaleXForBarChart(c,e):this._scaleX(c,e);s.push(h)});const r=document.createElement("canvas").getContext("2d");if(!r)return;r.font="12px system-ui, -apple-system, sans-serif";const a=[];t.forEach(c=>{const h=this._formatXAxisValue(c),p=r.measureText(h);a.push(p.width)});const o=80;let l=!0;for(let c=1;c<t.length;c++){const h=s[c]-s[c-1],p=a[c-1]/2+a[c]/2+10;if(h<Math.max(p,o)){l=!1;break}}if(!l){const c=Math.max(...a),h=12*1.2,p=(c+h)*.707;this._rotatedLabelHeight=Math.ceil(p)+10}}_renderGrid(t){if(!this._svg||!this._showGrid)return;const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("class","chart-grid");const i=this._getYRange(),n=Math.floor(t.height/35),r=Math.min(5,n);for(let u=0;u<=r;u++){const m=t.y+t.height/r*u,f=document.createElementNS("http://www.w3.org/2000/svg","line");f.setAttribute("x1",t.x.toString()),f.setAttribute("y1",m.toString()),f.setAttribute("x2",(t.x+t.width).toString()),f.setAttribute("y2",m.toString()),f.setAttribute("stroke","#e5e7eb"),f.setAttribute("stroke-width","1"),f.setAttribute("stroke-dasharray","2,2"),document.documentElement.classList.contains("dark")&&f.setAttribute("stroke","#374151"),e.appendChild(f);const g=i.max-(i.max-i.min)/r*u,_=document.createElementNS("http://www.w3.org/2000/svg","text");let b=5,v=m+4,y="start";u===0&&(v=m+12),_.setAttribute("x",b.toString()),_.setAttribute("y",v.toString()),_.setAttribute("text-anchor",y),_.setAttribute("fill","#6b7280"),_.setAttribute("font-size","12");const x=this._formatYAxisValue(g);_.textContent=x,document.documentElement.classList.contains("dark")&&_.setAttribute("fill","#9ca3af"),e.appendChild(_)}const a=this._getXValues();if(a.length===0){this._svg.appendChild(e);return}const o=this._chartType==="bar",l=[];a.forEach(u=>{const m=o?this._scaleXForBarChart(u,t):this._scaleX(u,t);l.push(m)});const h=document.createElement("canvas").getContext("2d");let p=!1,d=new Array(a.length).fill(!0);if(h&&a.length>1){h.font="12px system-ui, -apple-system, sans-serif";const u=[];a.forEach(g=>{const _=this._formatXAxisValue(g),b=h.measureText(_);u.push(b.width)});const m=80;let f=!0;for(let g=1;g<a.length;g++){const _=l[g]-l[g-1],b=u[g-1]/2+u[g]/2+10;if(_<Math.max(b,m)){f=!1;break}}if(!f){p=!0;const g=12*1.2;if(this._rotatedLabelHeight===0){const y=(Math.max(...u)+g)*.707;this._rotatedLabelHeight=Math.ceil(y)+10}const _=g*1.5;let b=!0;for(let v=1;v<a.length;v++)if(l[v]-l[v-1]<_){b=!1;break}if(!b){const v=_;d=new Array(a.length).fill(!1);let y=-1/0;a.length>0&&(d[0]=!0,y=l[0]);for(let x=1;x<a.length-1;x++){const D=l[x];D-y>=v&&(d[x]=!0,y=D)}if(a.length>1){const x=l[a.length-1];if(x-y>=v)d[a.length-1]=!0;else{for(;x-y<v;){let D=!1;for(let w=a.length-2;w>=0;w--)if(d[w]){if(d[w]=!1,w>0){for(let S=w-1;S>=0;S--)if(d[S]){y=l[S],D=!0;break}D||(y=l[0])}else y=l[0];D=!0;break}if(!D)break}x-y>=v&&(d[a.length-1]=!0)}}}}}else d=new Array(a.length).fill(!1),a.length>0&&(d[0]=!0),a.length>1&&(d[a.length-1]=!0),this._rotatedLabelHeight=0;p||(this._rotatedLabelHeight=0),a.forEach((u,m)=>{if(d[m]){const f=l[m],g=document.createElementNS("http://www.w3.org/2000/svg","line");g.setAttribute("x1",f.toString()),g.setAttribute("y1",t.y.toString()),g.setAttribute("x2",f.toString()),g.setAttribute("y2",(t.y+t.height).toString()),g.setAttribute("stroke","#e5e7eb"),g.setAttribute("stroke-width","1"),g.setAttribute("stroke-dasharray","2,2"),document.documentElement.classList.contains("dark")&&g.setAttribute("stroke","#374151"),e.appendChild(g);const _=document.createElementNS("http://www.w3.org/2000/svg","text");let b=f,v="middle";if(p){if(v="end",m===a.length-1){const L=document.createElement("canvas").getContext("2d");if(L){L.font="12px system-ui, -apple-system, sans-serif";const F=this._formatXAxisValue(u),E=L.measureText(F).width*.707,H=t.x+t.width+100;b=Math.min(f,H-E)}}}else if(m===0){const T=t.x;b=Math.max(f,T),v="start"}else if(m===a.length-1){const T=t.x+t.width;b=Math.min(f,T),v="end"}_.setAttribute("x",b.toString());const D=(this._rotatedLabelHeight>0?30:20)+this._rotatedLabelHeight+12;let w=D;this._showLegend&&(w=D+20+Math.max(this._legendHeight,60));const k=(this._height-t.y-t.height)/w,C=(p?30:20)*k;let A=t.y+t.height+C;_.setAttribute("y",A.toString()),_.setAttribute("text-anchor",v),_.setAttribute("fill","#6b7280"),_.setAttribute("font-size","12"),p&&_.setAttribute("transform",`rotate(-45 ${b} ${A})`);const M=this._formatXAxisValue(u);_.textContent=M,document.documentElement.classList.contains("dark")&&_.setAttribute("fill","#9ca3af"),e.appendChild(_)}}),this._svg.appendChild(e)}_renderLineChart(){if(!this._svg||!this._chartData)return;const t=this._getChartBounds();this._renderGrid(t);const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("class","chart-data");const i=document.createDocumentFragment();this._chartData.datasets.forEach((s,n)=>{if(!this._isDatasetVisible(s,n))return;const r=this._getDatasetColor(s,n),a=document.createElementNS("http://www.w3.org/2000/svg","path"),o=s.data.map(c=>({x:this._scaleX(c.x,t),y:this._scaleY(c.y,t)}));if(o.length===0)return;const l=[`M ${o[0].x} ${o[0].y}`];for(let c=1;c<o.length;c++)l.push(`L ${o[c].x} ${o[c].y}`);a.setAttribute("d",l.join(" ")),a.setAttribute("fill","none"),a.setAttribute("stroke",r),a.setAttribute("stroke-width","2"),a.setAttribute("stroke-linecap","round"),a.setAttribute("stroke-linejoin","round"),i.appendChild(a),s.data.forEach(c=>{const h=document.createElementNS("http://www.w3.org/2000/svg","circle"),p=this._scaleX(c.x,t),d=this._scaleY(c.y,t);h.setAttribute("cx",p.toString()),h.setAttribute("cy",d.toString()),h.setAttribute("r","4"),h.setAttribute("fill",r);const u=document.documentElement.classList.contains("dark");h.setAttribute("stroke",u?"#1f2937":"#fff"),h.setAttribute("stroke-width","2"),h.setAttribute("class","chart-point"),h.setAttribute("data-dataset",n.toString()),h.setAttribute("data-x",String(c.x)),h.setAttribute("data-y",c.y.toString()),h.setAttribute("data-name",s.name),h.style.opacity="0",h.style.pointerEvents="none";const m=String(c.x);this._plotPoints.has(m)||this._plotPoints.set(m,[]),this._plotPoints.get(m).push(h),i.appendChild(h)})}),e.appendChild(i),this._svg.appendChild(e)}_scaleXForBarChart(t,e){const i=this._getXValues();if(i.length===0)return e.x;const s=i.indexOf(t);if(s===-1)return e.x;const n=i.length+1,r=e.width/n;return e.x+(s+1)*r}_renderBarChart(){if(!this._svg||!this._chartData)return;const t=this._getChartBounds();this._renderGrid(t);const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("class","chart-data");const i=document.createDocumentFragment(),s=this._getXValues(),n=this._chartData.datasets.filter((f,g)=>this._isDatasetVisible(f,g)).length,r=s.length;if(r===0)return;const a=[];s.forEach(f=>{a.push(this._scaleXForBarChart(f,t))}),a.sort((f,g)=>f-g);let o=t.width;if(r>1)for(let f=0;f<a.length-1;f++){const g=a[f+1]-a[f];g>0&&g<o&&(o=g)}else o=t.width*.5;const l=o*.7,c=.2,h=(1+c)*n-c;let p=l/h,d=p*c,u=(p+d)*n-d;if(u>l){const f=l/u;p*=f,d=p*c,u=(p+d)*n-d}let m=0;this._chartData.datasets.forEach((f,g)=>{if(!this._isDatasetVisible(f,g))return;const _=this._getDatasetColor(f,g),v=-u/2+(p+d)*m;m++,f.data.forEach(y=>{const x=this._scaleXForBarChart(y.x,t),D=this._scaleY(y.y,t),w=t.y+t.height-D,S=x+v,k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("x",S.toString()),k.setAttribute("y",D.toString()),k.setAttribute("width",p.toString()),k.setAttribute("height",w.toString()),k.setAttribute("fill",_),k.setAttribute("rx","2"),k.setAttribute("class","chart-bar"),k.setAttribute("data-dataset",g.toString()),k.setAttribute("data-x",String(y.x)),k.setAttribute("data-y",y.y.toString()),k.setAttribute("data-name",f.name),k.style.cursor="pointer",this._showTooltip&&(k.addEventListener("mouseenter",C=>{const A=this._getAllDatasetsAtX(y.x);let M=`<strong>${y.x}</strong><br/>`;A.forEach(T=>{M+=`<div style="display: flex; align-items: center; gap: 6px; margin-top: 4px;">
182
- <span style="display: inline-block; width: 12px; height: 12px; background-color: ${T.color}; border-radius: 2px;"></span>
183
- <span>${T.name}: ${T.formattedValue}</span>
184
- </div>`}),this._showTooltipAt(C.clientX,C.clientY,M)}),k.addEventListener("mouseleave",()=>{this._hideTooltip()})),i.appendChild(k)})}),e.appendChild(i),this._svg.appendChild(e)}_renderAreaChart(){if(!this._svg||!this._chartData)return;const t=this._getChartBounds();this._renderGrid(t);const e=document.createElementNS("http://www.w3.org/2000/svg","g");e.setAttribute("class","chart-data");const i=document.createDocumentFragment();this._chartData.datasets.forEach((s,n)=>{if(!this._isDatasetVisible(s,n))return;const r=this._getDatasetColor(s,n),a=s.data.map(u=>({x:this._scaleX(u.x,t),y:this._scaleY(u.y,t)}));if(a.length===0)return;const o=t.y+t.height,l=[`M ${a[0].x} ${o}`,`L ${a[0].x} ${a[0].y}`];for(let u=1;u<a.length;u++)l.push(`L ${a[u].x} ${a[u].y}`);const c=a[a.length-1];l.push(`L ${c.x} ${o}`,"Z");const h=document.createElementNS("http://www.w3.org/2000/svg","path");h.setAttribute("d",l.join(" ")),h.setAttribute("fill",r),h.setAttribute("fill-opacity","0.3"),i.appendChild(h);const p=document.createElementNS("http://www.w3.org/2000/svg","path");if(a.length===0)return;const d=[`M ${a[0].x} ${a[0].y}`];for(let u=1;u<a.length;u++)d.push(`L ${a[u].x} ${a[u].y}`);p.setAttribute("d",d.join(" ")),p.setAttribute("fill","none"),p.setAttribute("stroke",r),p.setAttribute("stroke-width","2"),i.appendChild(p),s.data.forEach(u=>{const m=document.createElementNS("http://www.w3.org/2000/svg","circle"),f=this._scaleX(u.x,t),g=this._scaleY(u.y,t);m.setAttribute("cx",f.toString()),m.setAttribute("cy",g.toString()),m.setAttribute("r","4"),m.setAttribute("fill",r);const _=document.documentElement.classList.contains("dark");m.setAttribute("stroke",_?"#1f2937":"#fff"),m.setAttribute("stroke-width","2"),m.setAttribute("class","chart-point"),m.setAttribute("data-dataset",n.toString()),m.setAttribute("data-x",String(u.x)),m.setAttribute("data-y",u.y.toString()),m.setAttribute("data-name",s.name),m.style.opacity="0",m.style.pointerEvents="none";const b=String(u.x);this._plotPoints.has(b)||this._plotPoints.set(b,[]),this._plotPoints.get(b).push(m),i.appendChild(m)})}),e.appendChild(i),this._svg.appendChild(e)}_renderPieChart(){if(!this._svg||!this._chartData)return;const t=this._getChartBounds(),e=t.x+t.width/2,i=t.y+t.height/2,s=Math.min(t.width,t.height)/2-20,n=2,r=this._chartData.datasets[0];if(!r||!r.data||r.data.length===0)return;const a=r.data.reduce((h,p)=>h+p.y,0);if(a===0)return;const o=document.createElementNS("http://www.w3.org/2000/svg","g");o.setAttribute("class","chart-data"),this._pieChartGroup=o,this._pieChartClickOutsideHandler||(this._pieChartClickOutsideHandler=h=>{if(!this._pieChartTooltipShown)return;const p=h.target;this._pieChartGroup&&!this._pieChartGroup.contains(p)&&(this._pieChartTooltipShown=!1,this._hideTooltip())},document.addEventListener("click",this._pieChartClickOutsideHandler,!0));const l=document.createElementNS("http://www.w3.org/2000/svg","circle");l.setAttribute("cx",e.toString()),l.setAttribute("cy",i.toString()),l.setAttribute("r",s.toString()),l.setAttribute("fill","transparent"),l.setAttribute("pointer-events","none"),o.appendChild(l);let c=-Math.PI/2;r.data.forEach((h,p)=>{const d=h.y,u=d/a*100,m=d/a*2*Math.PI,f=h.color||this._getDatasetColor(r,0,p),g=document.createElementNS("http://www.w3.org/2000/svg","g");g.setAttribute("class","chart-pie-slice-group"),g.setAttribute("data-index",p.toString()),g.style.cursor="pointer",g.style.transition="transform 0.2s ease-out";const _=document.createElementNS("http://www.w3.org/2000/svg","path"),b=s+n,v=e+b*Math.cos(c),y=i+b*Math.sin(c),x=e+b*Math.cos(c+m),D=i+b*Math.sin(c+m),w=m>Math.PI?1:0,S=[`M ${e} ${i}`,`L ${v} ${y}`,`A ${b} ${b} 0 ${w} 1 ${x} ${D}`,"Z"].join(" ");_.setAttribute("d",S),_.setAttribute("fill",f),_.setAttribute("class","chart-pie-slice"),_.setAttribute("data-index",p.toString()),_.setAttribute("data-x",String(h.x)),_.setAttribute("data-y",h.y.toString()),_.setAttribute("data-name",r.name),_.setAttribute("data-percentage",u.toFixed(1)),g.appendChild(_);const k=c+m/2,C=10,A=Math.cos(k)*C,M=Math.sin(k)*C;let T=null,L=null,F=!1;if(g.__chartInstance=this,g.addEventListener("mouseenter",function(){if(L!==null&&(clearTimeout(L),L=null),!F){T!==null&&clearTimeout(T);const I=window.setTimeout(()=>{F=!0,this.setAttribute("transform",`translate(${A}, ${M})`),T=null,this.__chartInstance&&this.__chartInstance._pieChartTimeouts.delete(I)},150);T=I,this.__chartInstance&&this.__chartInstance._pieChartTimeouts.add(I)}}),g.addEventListener("mouseleave",function(){if(T!==null&&(clearTimeout(T),T=null),F){L!==null&&clearTimeout(L);const I=window.setTimeout(()=>{F=!1,this.setAttribute("transform","translate(0, 0)"),L=null,this.__chartInstance&&this.__chartInstance._pieChartTimeouts.delete(I)},200);L=I,this.__chartInstance&&this.__chartInstance._pieChartTimeouts.add(I)}}),g.addEventListener("click",function(){T!==null&&(clearTimeout(T),T=null),L!==null&&(clearTimeout(L),L=null),F=!0,this.setAttribute("transform",`translate(${A}, ${M})`)}),this._showTooltip){let I=null,$=null,E=!1;g.addEventListener("mouseenter",H=>{if($!==null&&(clearTimeout($),$=null),!E){I!==null&&clearTimeout(I);const N=window.setTimeout(()=>{E=!0,this._pieChartTooltipShown=!0;const V=this._formatValue(d,r),Y=`<strong>${h.x}</strong><br/>${r.name}: ${V}<br/>${u.toFixed(1)}%`;this._showTooltipAt(H.clientX,H.clientY,Y),I=null,this._pieChartTimeouts.delete(N)},150);I=N,this._pieChartTimeouts.add(N)}}),g.addEventListener("mouseleave",()=>{if(I!==null&&(clearTimeout(I),I=null),E){$!==null&&clearTimeout($);const H=window.setTimeout(()=>{E=!1,this._pieChartTooltipShown=!1,this._hideTooltip(),$=null,this._pieChartTimeouts.delete(H)},200);$=H,this._pieChartTimeouts.add(H)}}),g.addEventListener("click",H=>{H.stopPropagation(),I!==null&&(clearTimeout(I),I=null),$!==null&&(clearTimeout($),$=null),E=!0,this._pieChartTooltipShown=!0;const N=this._formatValue(d,r),V=`<strong>${h.x}</strong><br/>${r.name}: ${N}<br/>${u.toFixed(1)}%`;this._showTooltipAt(H.clientX,H.clientY,V)})}if(u>5){const I=c+m/2,$=s*.7,E=e+$*Math.cos(I),H=i+$*Math.sin(I),N=this._getContrastColor(f),V=document.createElementNS("http://www.w3.org/2000/svg","text");V.setAttribute("x",E.toString()),V.setAttribute("y",H.toString()),V.setAttribute("text-anchor","middle"),V.setAttribute("dominant-baseline","middle"),V.setAttribute("fill",N),V.setAttribute("font-size","12"),V.setAttribute("font-weight","500"),V.textContent=`${u.toFixed(1)}%`,g.appendChild(V)}o.appendChild(g),c+=m}),this._svg.appendChild(o)}_calculateLegendHeight(){if(!this._chartData)return 0;const t=32,e=20,i=6,s=8,n=150,r=this._width-40,a=[];this._chartType==="pie"&&this._chartData.datasets.length>0?this._chartData.datasets[0].data.forEach(p=>{a.push({name:String(p.x),row:0})}):this._chartData.datasets.forEach(h=>{a.push({name:h.name,row:0})});let o=0;const l=[];a.forEach(h=>{const p=Math.min(h.name.length*7.5,n),d=i*2+s+p;l[o]||(l[o]=[]),l[o].reduce((m,f)=>{const g=Math.min(f.name.length*7.5,n);return m+(i*2+s+g)+t},0)+d>r&&l[o].length>0&&(o++,l[o]=[]),h.row=o,l[o].push(h)});const c=Math.max(i*2,16);return l.length*(e+c)}_renderLegend(){if(!this._chartData||!this._svg)return{height:0};const t=this._svg.querySelector(".chart-legend");t&&t.remove();const e=document.createElementNS("http://www.w3.org/2000/svg","g");if(e.setAttribute("class","chart-legend"),!this._chartData)return{height:0};const i=this._chartData,s=32,n=20,r=6,a=8,o=150,l=this._width-40,c=[];if(this._chartType==="pie"&&i.datasets.length>0){const A=i.datasets[0];A.data.forEach((M,T)=>{const L=M.color||this._getDatasetColor(A,0,T),F=String(M.x);c.push({name:F,color:L,x:0,textX:0,row:0})})}else i.datasets.forEach((A,M)=>{if(!this._isDatasetVisible(A,M))return;const T=this._getDatasetColor(A,M);c.push({name:A.name,color:T,x:0,textX:0,row:0})});let h=0;const p=[];c.forEach(A=>{const M=Math.min(A.name.length*7.5,o),T=r*2+a+M;p[h]||(p[h]=[]),p[h].reduce((F,I)=>{const $=Math.min(I.name.length*7.5,o);return F+(r*2+a+$)+s},0)+T>l&&p[h].length>0&&(h++,p[h]=[]),A.row=h,p[h].push(A)}),p.forEach(A=>{const M=A.reduce((F,I)=>{const $=Math.min(I.name.length*7.5,o);return F+(r*2+a+$)},0)+(A.length-1)*s;let L=(this._width-M)/2;A.forEach(F=>{const I=Math.min(F.name.length*7.5,o);F.x=L,F.textX=L+r+a,L+=r*2+a+I+s})});const d=Math.max(r*2,16);p.length*(n+d);const u=this._getChartBounds(),m=this._rotatedLabelHeight>0?30:20,f=12,g=m+this._rotatedLabelHeight+f;let _=g;this._showLegend&&(_=g+20+Math.max(this._legendHeight,60));const b=this._height-u.y-u.height,v=_>0?b/_:1,y=(this._rotatedLabelHeight>0?30:20)*v,x=f*v,D=this._rotatedLabelHeight*v,S=u.y+u.height+y+(this._rotatedLabelHeight>0?D:x),k=20*v,C=S+k;return c.forEach(A=>{const T=C+A.row*(n+d)+d/2,L=document.createElementNS("http://www.w3.org/2000/svg","circle");L.setAttribute("cx",A.x.toString()),L.setAttribute("cy",T.toString()),L.setAttribute("r",r.toString()),L.setAttribute("fill",A.color),e.appendChild(L);const F=document.createElementNS("http://www.w3.org/2000/svg","foreignObject");F.setAttribute("x",A.textX.toString()),F.setAttribute("y",(T-12).toString()),F.setAttribute("width",o.toString()),F.setAttribute("height","24");const I=document.createElement("div");I.style.cssText=`
185
- font-size: 12px;
186
- font-family: system-ui, -apple-system, sans-serif;
187
- color: ${document.documentElement.classList.contains("dark")?"#d1d5db":"#374151"};
188
- line-height: 1.2;
189
- word-wrap: break-word;
190
- overflow-wrap: break-word;
191
- white-space: normal;
192
- max-width: ${o}px;
193
- display: flex;
194
- align-items: center;
195
- height: 100%;
196
- `,I.textContent=A.name,F.appendChild(I),e.appendChild(F)}),this._svg.appendChild(e),{height:this._legendHeight+50}}async addDataPoint(t,e){return!this._chartData||!this._chartData.datasets[t]?(console.error(`Dataset at index ${t} does not exist`),Promise.reject(new Error(`Dataset at index ${t} does not exist`))):(this._chartData.datasets[t].data.push(e),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(i=>requestAnimationFrame(()=>i())))}async batchAddDataPoints(t){if(!this._chartData)return Promise.resolve();let e=!1;for(const{datasetIndex:i,point:s}of t)this._chartData.datasets[i]&&(this._chartData.datasets[i].data.push(s),e=!0);return e&&(this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(i=>requestAnimationFrame(()=>i()))}async updateDatasetData(t,e){return!this._chartData||!this._chartData.datasets[t]?(console.error(`Dataset at index ${t} does not exist`),Promise.reject(new Error(`Dataset at index ${t} does not exist`))):(this._chartData.datasets[t].data=e,this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(i=>requestAnimationFrame(()=>i())))}async addDataset(t){return this._chartData?(this._chartData.datasets.push(t),t.id&&this._datasetVisibility.set(t.id,t.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(new Error("Chart data not initialized")))}async removeDataset(t){return!this._chartData||!this._chartData.datasets[t]?(console.error(`Dataset at index ${t} does not exist`),Promise.reject(new Error(`Dataset at index ${t} does not exist`))):(this._chartData.datasets.splice(t,1),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e())))}async updateDataPoint(t,e,i){return!this._chartData||!this._chartData.datasets[t]?(console.error(`Dataset at index ${t} does not exist`),Promise.reject(new Error(`Dataset at index ${t} does not exist`))):this._chartData.datasets[t].data[e]?(this._chartData.datasets[t].data[e]=i,this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(s=>requestAnimationFrame(()=>s()))):(console.error(`Data point at index ${e} does not exist`),Promise.reject(new Error(`Data point at index ${e} does not exist`)))}async batchUpdateDataPoints(t){var i;if(!this._chartData)return Promise.resolve();let e=!1;for(const{datasetIndex:s,pointIndex:n,point:r}of t)(i=this._chartData.datasets[s])!=null&&i.data[n]&&(this._chartData.datasets[s].data[n]=r,e=!0);return e&&(this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(s=>requestAnimationFrame(()=>s()))}async removeDataPoint(t,e){return!this._chartData||!this._chartData.datasets[t]?(console.error(`Dataset at index ${t} does not exist`),Promise.reject(new Error(`Dataset at index ${t} does not exist`))):(this._chartData.datasets[t].data.splice(e,1),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(i=>requestAnimationFrame(()=>i())))}async batchRemoveDataPoints(t){var i;if(!this._chartData)return Promise.resolve();let e=!1;for(const{datasetIndex:s,pointIndex:n}of t)(i=this._chartData.datasets[s])!=null&&i.data[n]&&(this._chartData.datasets[s].data.splice(n,1),e=!0);return e&&(this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender()),new Promise(s=>requestAnimationFrame(()=>s()))}async showDataset(t){return this._datasetVisibility.set(t,!0),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async hideDataset(t){return this._datasetVisibility.set(t,!1),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),new Promise(e=>requestAnimationFrame(()=>e()))}async toggleDataset(t){const i=!(this._datasetVisibility.get(t)??!0);return this._datasetVisibility.set(t,i),this._cachedBounds.dataHash="",this._cachedYRange.dataHash="",this._cachedXValues.dataHash="",this._cachedTooltipContent.clear(),this._scheduleRender(),await new Promise(s=>requestAnimationFrame(()=>s())),i}isDatasetVisible(t){return this._datasetVisibility.get(t)}async downloadAsPNG(t="chart.png"){if(!this._svg)return console.error("Chart SVG not found"),Promise.reject(new Error("Chart SVG not found"));const e=this._svg.cloneNode(!0),i=this._width,s=this._height,n='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';e.querySelectorAll("text").forEach(h=>{const p=h.getAttribute("font-family");(!p||p.includes("system-ui")||p.includes("apple-system"))&&h.setAttribute("font-family",n)}),e.setAttribute("width",i.toString()),e.setAttribute("height",s.toString()),e.setAttribute("xmlns","http://www.w3.org/2000/svg"),e.querySelectorAll("foreignObject").forEach(h=>{const p=h.querySelector("div");if(p){const d=document.createElementNS("http://www.w3.org/2000/svg","text"),u=h.getAttribute("x")||"0",m=h.getAttribute("y")||"0";d.setAttribute("x",u),d.setAttribute("y",(parseFloat(m)+12).toString()),d.setAttribute("fill",p.style.color||"#374151"),d.setAttribute("font-size","12"),d.setAttribute("font-family",p.style.fontFamily||"system-ui, -apple-system, sans-serif"),d.textContent=p.textContent||"",h.parentNode&&h.parentNode.replaceChild(d,h)}});const o=new XMLSerializer().serializeToString(e),l="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(o),c=new Image;return c.crossOrigin="anonymous",new Promise((h,p)=>{c.onload=()=>{setTimeout(()=>{const u=document.createElement("canvas");u.width=i+30*2,u.height=s+30*2;const m=u.getContext("2d");if(!m){console.error("Could not get canvas context"),p(new Error("Could not get canvas context"));return}const f=document.documentElement.classList.contains("dark");m.fillStyle=f?"#111827":"#ffffff",m.fillRect(0,0,u.width,u.height),m.drawImage(c,30,30),u.toBlob(g=>{if(!g){console.error("Could not create blob from canvas"),p(new Error("Could not create blob from canvas"));return}const _=URL.createObjectURL(g),b=document.createElement("a");b.href=_,b.download=t,document.body.appendChild(b),b.click(),document.body.removeChild(b),URL.revokeObjectURL(_),h()},"image/png")},0)},c.onerror=()=>{console.error("Error loading SVG image"),p(new Error("Error loading SVG image"))},c.src=l})}};it.MAX_CACHE_SIZE=100;let rt=it;customElements.get("mint-chart")||customElements.define("mint-chart",rt);exports.Alert=Ht;exports.BackButton=gt;exports.Button=st;exports.Card=pt;exports.Chart=rt;exports.Checkbox=yt;exports.Chip=Lt;exports.Choice=kt;exports.Clickable=Tt;exports.DatePicker=Et;exports.Dropzone=Ct;exports.Form=At;exports.Grid=_t;exports.Icon=ct;exports.Input=xt;exports.Link=ft;exports.Modal=bt;exports.OffCanvas=It;exports.Page=mt;exports.Popover=vt;exports.ResourceTable=Mt;exports.Select=wt;exports.Spinner=lt;exports.Stack=ut;exports.Switch=ht;exports.Tab=Nt;exports.TabContent=Ft;exports.TabList=Pt;exports.Table=St;exports.Tabs=Ot;exports.Tags=Dt;exports.Text=dt;exports.default=st;
63
+ `.trim()}};customElements.get(`mint-spinner`)||customElements.define(`mint-spinner`,e);var t=new Map;function n(e){t.set(e.name,e)}function r(e){return t.get(e)}var i=class extends HTMLElement{static get observedAttributes(){return[`name`]}constructor(){super(),this._darkModeObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`inline-flex`,`items-center`,`leading-none`),this.render(),this._observeDarkMode()}attributeChangedCallback(e,t,n){t!==n&&this.render()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){this.render();break}}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}getName(){return this.getAttribute(`name`)||``}getIconUrl(){let e=document.documentElement.getAttribute(`data-icon-base-url`)||document.querySelector(`meta[name="icon-base-url"]`)?.getAttribute(`content`);return e?`${e}/${this.getName()}.svg`:`/icons/${this.getName()}.svg`}render(){let e=this.getName();if(!e){this.innerHTML=``,this.style.maskImage=``,this.style.webkitMaskImage=``;return}if(!r(e)){console.warn(`Icon "${e}" not found. Make sure you've imported the icon: import '@monobill-mintui/icon/icons/${e}'`),this.innerHTML=``,this.style.maskImage=``,this.style.webkitMaskImage=``;return}let t=this.closest(`mint-button`)||this.parentElement?.closest(`mint-button`),n=this.closest(`mint-switch`)||this.parentElement?.closest(`mint-switch`),i;i=n?`w-3 h-3`:t?`w-5 h-5`:`w-[1.3em] h-[1.3em]`,this.classList.remove(`w-4`,`h-4`,`w-5`,`h-5`,`w-[1em]`,`h-[1em]`),i.split(` `).forEach(e=>{e&&this.classList.add(e)});let a=this.getIconUrl();if(this.style.maskImage=`url(${a})`,this.style.webkitMaskImage=`url(${a})`,this.style.maskSize=`contain`,this.style.webkitMaskSize=`contain`,this.style.maskRepeat=`no-repeat`,this.style.webkitMaskRepeat=`no-repeat`,this.style.maskPosition=`center`,this.style.webkitMaskPosition=`center`,this.style.aspectRatio=`1 / 1`,this.style.backgroundColor=`currentColor`,n)this.classList.remove(`text-gray-100`,`text-gray-900`),this.classList.add(`text-gray-900`);else if(t)this.classList.remove(`text-gray-100`,`text-gray-900`);else{let e=document.documentElement.classList.contains(`dark`)?`text-gray-100`:`text-gray-900`;this.classList.remove(`text-gray-100`,`text-gray-900`),this.classList.add(e)}this.innerHTML=``}};customElements.get(`mint-icon`)||customElements.define(`mint-icon`,i);var a={name:`plus`,viewBox:`0 0 24 24`,path:`M12 4v16m8-8H4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(a);var o={name:`user`,viewBox:`0 0 24 24`,path:`M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(o);var s={name:`trash`,viewBox:`0 0 24 24`,path:`M3 6h18m-2 0v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2`,strokeLinecap:`round`,strokeLinejoin:`round`};n(s);var c={name:`arrow-left`,viewBox:`0 0 24 24`,path:`M19 12H5m7-7l-7 7 7 7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(c);var ee={name:`home`,viewBox:`0 0 24 24`,path:`M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ee);var te={name:`search`,viewBox:`0 0 24 24`,path:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(te);var l={name:`notifications`,viewBox:`0 0 24 24`,path:`M15 17h5l-1.405-1.405A2.032 2.032 0 0118 14.158V11a6.002 6.002 0 00-4-5.659V5a2 2 0 10-4 0v.341C7.67 6.165 6 8.388 6 11v3.159c0 .538-.214 1.055-.595 1.436L4 17h5m6 0v1a3 3 0 11-6 0v-1m6 0H9`,strokeLinecap:`round`,strokeLinejoin:`round`};n(l);var u={name:`chat`,viewBox:`0 0 24 24`,path:`M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(u);var d={name:`help`,viewBox:`0 0 24 24`,path:`M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(d);var f={name:`documentation`,viewBox:`0 0 24 24`,path:`M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253`,strokeLinecap:`round`,strokeLinejoin:`round`};n(f);var p={name:`mail`,viewBox:`0 0 24 24`,path:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(p);var m={name:`settings`,viewBox:`0 0 24 24`,path:`M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z M15 12a3 3 0 11-6 0 3 3 0 016 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(m);var h={name:`language`,viewBox:`0 0 24 24`,path:`M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129`,strokeLinecap:`round`,strokeLinejoin:`round`};n(h);var g={name:`moon`,viewBox:`0 0 24 24`,path:`M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(g);var _={name:`sun`,viewBox:`0 0 24 24`,path:`M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(_);var v={name:`logout`,viewBox:`0 0 24 24`,path:`M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1`,strokeLinecap:`round`,strokeLinejoin:`round`};n(v);var y={name:`login`,viewBox:`0 0 24 24`,path:`M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1`,strokeLinecap:`round`,strokeLinejoin:`round`};n(y);var b={name:`user-add`,viewBox:`0 0 24 24`,path:`M18 9v3m0 0v3m0-3h3m-3 0h-3m-2-5a4 4 0 11-8 0 4 4 0 018 0zM3 20a6 6 0 0112 0v1H3v-1z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(b);var x={name:`calendar`,viewBox:`0 0 24 24`,path:`M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(x);var S={name:`clock`,viewBox:`0 0 24 24`,path:`M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(S);var C={name:`bookmark`,viewBox:`0 0 24 24`,path:`M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(C);var w={name:`star`,viewBox:`0 0 24 24`,path:`M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(w);var T={name:`pin`,viewBox:`0 0 24 24`,path:`M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(T);var E={name:`filter`,viewBox:`0 0 24 24`,path:`M3 6h18M3 12h18M3 18h18M6 6a2 2 0 11-4 0 2 2 0 014 0zM12 12a2 2 0 11-4 0 2 2 0 014 0zM16 18a2 2 0 11-4 0 2 2 0 014 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(E);var D={name:`sort`,viewBox:`0 0 24 24`,path:`M3 6h18M7 12h10m-7 6h4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(D);var O={name:`refresh`,viewBox:`0 0 24 24`,path:`M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15`,strokeLinecap:`round`,strokeLinejoin:`round`};n(O);var k={name:`share`,viewBox:`0 0 24 24`,path:`M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.368 2.684 3 3 0 00-5.368-2.684z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(k);var A={name:`upload`,viewBox:`0 0 24 24`,path:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`,strokeLinecap:`round`,strokeLinejoin:`round`};n(A);var j={name:`download`,viewBox:`0 0 24 24`,path:`M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(j);var M={name:`print`,viewBox:`0 0 24 24`,path:`M17 17h2a2 2 0 002-2v-4a2 2 0 00-2-2H5a2 2 0 00-2 2v4a2 2 0 002 2h2m2 4h6a2 2 0 002-2v-4a2 2 0 00-2-2H9a2 2 0 00-2 2v4a2 2 0 002 2zm8-12V5a2 2 0 00-2-2H9a2 2 0 00-2 2v4h10z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(M);var N={name:`attach`,viewBox:`0 0 24 24`,path:`M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13`,strokeLinecap:`round`,strokeLinejoin:`round`};n(N);var P={name:`edit`,viewBox:`0 0 24 24`,path:`M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(P);var F={name:`delete`,viewBox:`0 0 24 24`,path:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`,strokeLinecap:`round`,strokeLinejoin:`round`};n(F);var I={name:`save`,viewBox:`0 0 24 24`,path:`M8 7H5a2 2 0 00-2 2v9a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-3m-1 4l-3 3m0 0l-3-3m3 3V4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(I);var L={name:`duplicate`,viewBox:`0 0 24 24`,path:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(L);var R={name:`copy`,viewBox:`0 0 24 24`,path:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(R);var z={name:`paste`,viewBox:`0 0 24 24`,path:`M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2`,strokeLinecap:`round`,strokeLinejoin:`round`};n(z);var B={name:`remove`,viewBox:`0 0 24 24`,path:`M20 12H4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(B);var V={name:`check`,viewBox:`0 0 24 24`,path:`M5 13l4 4L19 7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(V);var H={name:`close`,viewBox:`0 0 24 24`,path:`M6 18L18 6M6 6l12 12`,strokeLinecap:`round`,strokeLinejoin:`round`};n(H);var U={name:`warning`,viewBox:`0 0 24 24`,path:`M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(U);var W={name:`error`,viewBox:`0 0 24 24`,path:`M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(W);var G={name:`success`,viewBox:`0 0 24 24`,path:`M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(G);var K={name:`info`,viewBox:`0 0 24 24`,path:`M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(K);var q={name:`folder`,viewBox:`0 0 24 24`,path:`M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(q);var J={name:`file`,viewBox:`0 0 24 24`,path:`M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(J);var ne={name:`archive`,viewBox:`0 0 24 24`,path:`M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ne);var Y={name:`image`,viewBox:`0 0 24 24`,path:`M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(Y);var X={name:`video`,viewBox:`0 0 24 24`,path:`M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(X);var Z={name:`link`,viewBox:`0 0 24 24`,path:`M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1`,strokeLinecap:`round`,strokeLinejoin:`round`};n(Z);var re={name:`external-link`,viewBox:`0 0 24 24`,path:`M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14`,strokeLinecap:`round`,strokeLinejoin:`round`};n(re);var ie={name:`grid`,viewBox:`0 0 24 24`,path:`M4 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2V6zM14 6a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V6zM4 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2H6a2 2 0 01-2-2v-2zM14 16a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ie);var ae={name:`list`,viewBox:`0 0 24 24`,path:`M8 6h13M5 6h.01M8 12h13M5 12h.01M8 18h13M5 18h.01`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ae);var oe={name:`menu`,viewBox:`0 0 24 24`,path:`M4 6h16M4 12h16M4 18h16`,strokeLinecap:`round`,strokeLinejoin:`round`};n(oe);var se={name:`ellipsis`,viewBox:`0 0 24 24`,path:`M5 12h.01M12 12h.01M19 12h.01M6 12a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0zm7 0a1 1 0 11-2 0 1 1 0 012 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(se);var ce={name:`arrow-right`,viewBox:`0 0 24 24`,path:`M14 5l7 7m0 0l-7 7m7-7H3`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ce);var le={name:`arrow-up`,viewBox:`0 0 24 24`,path:`M5 10l7-7m0 0l7 7m-7-7v18`,strokeLinecap:`round`,strokeLinejoin:`round`};n(le);var ue={name:`arrow-down`,viewBox:`0 0 24 24`,path:`M19 14l-7 7m0 0l-7-7m7 7V3`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ue);var de={name:`caret-left`,viewBox:`0 0 24 24`,path:`M15 19l-7-7 7-7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(de);var fe={name:`caret-right`,viewBox:`0 0 24 24`,path:`M9 5l7 7-7 7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(fe);var pe={name:`caret-up`,viewBox:`0 0 24 24`,path:`M5 15l7-7 7 7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(pe);var me={name:`caret-down`,viewBox:`0 0 24 24`,path:`M19 9l-7 7-7-7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(me);var he={name:`lock`,viewBox:`0 0 24 24`,path:`M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(he);var ge={name:`unlock`,viewBox:`0 0 24 24`,path:`M8 11V7a4 4 0 118 0m-4 8v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ge);var _e={name:`users`,viewBox:`0 0 24 24`,path:`M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(_e);var ve={name:`tag`,viewBox:`0 0 24 24`,path:`M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ve);var ye={name:`qr-code`,viewBox:`0 0 24 24`,path:`M4 3H9C10.1 3 11 3.9 11 5V10C11 11.1 10.1 12 9 12H4C2.9 12 2 11.1 2 10V5C2 3.9 2.9 3 4 3ZM4.75 4.5C4.34 4.5 4 4.84 4 5.25V9.75C4 10.16 4.34 10.5 4.75 10.5H8.25C8.66 10.5 9 10.16 9 9.75V5.25C9 4.84 8.66 4.5 8.25 4.5H4.75ZM15 3H20C21.1 3 22 3.9 22 5V10C22 11.1 21.1 12 20 12H15C13.9 12 13 11.1 13 10V5C13 3.9 13.9 3 15 3ZM15.75 4.5C15.34 4.5 15 4.84 15 5.25V9.75C15 10.16 15.34 10.5 15.75 10.5H19.25C19.66 10.5 20 10.16 20 9.75V5.25C20 4.84 19.66 4.5 19.25 4.5H15.75ZM4 13H9C10.1 13 11 13.9 11 15V20C11 21.1 10.1 22 9 22H4C2.9 22 2 21.1 2 20V15C2 13.9 2.9 13 4 13ZM4.75 14.5C4.34 14.5 4 14.84 4 15.25V19.75C4 20.16 4.34 20.5 4.75 20.5H8.25C8.66 20.5 9 20.16 9 19.75V15.25C9 14.84 8.66 14.5 8.25 14.5H4.75ZM13 13H16V16H19V19H16V22H13V19H16V16H13V13Z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(ye);var be={name:`barcode`,viewBox:`0 0 24 24`,path:`M3 4h1.5v16H3V4zM7 4h1v16H7V4zM11 4h1.5v16H11V4zM15.5 4h1v16h-1V4zM19.5 4h1.5v16h-1.5V4z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(be);var xe={name:`map`,viewBox:`0 0 24 24`,path:`M9 20l-5.447-2.724A1 1 0 013 16.382V5.618a1 1 0 011.447-.894L9 7m0 13l6-3m-6 3V7m6 10l4.553 2.276A1 1 0 0021 18.382V7.618a1 1 0 00-.553-.894L15 4m0 13V4m0 0L9 7`,strokeLinecap:`round`,strokeLinejoin:`round`};n(xe);var Se={name:`location`,viewBox:`0 0 24 24`,path:`M17.657 16.657L13.414 20.9a1.998 1.998 0 01-2.827 0l-4.244-4.243a8 8 0 1111.314 0z M15 11a3 3 0 11-6 0 3 3 0 016 0z`,strokeLinecap:`round`,strokeLinejoin:`round`};n(Se),n(a),n(o),n(s),n(c),n(ee),n(te),n(l),n(u),n(d),n(f),n(p),n(m),n(h),n(g),n(_),n(v),n(y),n(b),n(x),n(S),n(C),n(w),n(T),n(E),n(D),n(O),n(k),n(A),n(j),n(M),n(N),n(P),n(F),n(I),n(L),n(R),n(z),n(B),n(V),n(H),n(U),n(W),n(G),n(K),n(q),n(J),n(ne),n(Y),n(X),n(Z),n(re),n(ie),n(ae),n(oe),n(se),n(ce),n(le),n(ue),n(de),n(fe),n(pe),n(me),n(he),n(ge),n(_e),n(ve),n(ye),n(be),n(xe),n(Se);var Q=class extends HTMLElement{static get observedAttributes(){return[`variant`,`tone`,`disabled`,`loading`,`button-type`,`full-width`,`icon-position`,`icon`]}constructor(){super(),this._button=null,this._clickHandler=null,this._isHandlingClick=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`),this.render(),this._button&&this.setupEventListeners(),this.isFullWidth()&&this.classList.add(`w-full`)}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){t!==n&&this.render()}getVariant(){return this.getAttribute(`variant`)||`solid`}getTone(){return this.getAttribute(`tone`)||`neutral`}isDisabled(){return this.hasAttribute(`disabled`)}isLoading(){return this.hasAttribute(`loading`)}getType(){return(this.getAttribute(`button-type`)||`default`)===`submit`?`submit`:`button`}isFullWidth(){return this.hasAttribute(`full-width`)}getIconPosition(){return this.getAttribute(`icon-position`)||`left`}getIcon(){return this.getAttribute(`icon`)||``}isIconOnly(){if(!(this.getIcon()||this._button?.querySelector(`[slot="icon"], .mint-button-icon, 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()||e.nodeType===Node.ELEMENT_NODE&&e.tagName!==`MINT-ICON`&&e.tagName!==`MINT-SPINNER`&&!e.querySelector?.(`mint-spinner`)&&!e.hasAttribute?.(`slot`)&&e.className!==`mint-button-icon`&&!(e.className===`mr-2`&&e.querySelector(`mint-spinner`))&&e.textContent.trim())return!1}return!0}getButtonClasses(){let e=this.isIconOnly(),t=this.getVariant(),n=[`inline-flex`,`items-center`,`justify-center`,`font-medium`,`rounded-lg`,`box-border`,...e?[`p-1.5`,`aspect-square`,`w-[2rem]`,`h-[2rem]`]:[`px-3.5`,`py-1.5`,`min-h-[2rem]`],`text-sm`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`[&.mint-button-active>*]:scale-95`,`[&>*]:transition-transform`,`[&>*]:duration-100`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],r=this.getTone(),i={"solid-action":[`bg-slate-800`,`dark:bg-slate-600`,`text-white`,`hover:bg-slate-950`,`dark:hover:bg-slate-700`,`active:bg-slate-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-slate-700`,`disabled:active:bg-slate-800`,`dark:disabled:active:bg-slate-600`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-neutral":[`bg-white`,`dark:bg-gray-700`,`text-gray-900`,`dark:text-white`,`hover:bg-gray-50`,`dark:hover:bg-gray-600`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-white`,`dark:disabled:active:bg-gray-700`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-gray-200`,`dark:border-gray-600`],"solid-info":[`bg-blue-800`,`dark:bg-blue-600`,`text-white`,`hover:bg-blue-950`,`dark:hover:bg-blue-700`,`active:bg-blue-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-blue-700`,`disabled:active:bg-blue-800`,`dark:disabled:active:bg-blue-600`,`disabled:active:shadow-none`,`focus-visible:ring-blue-500`,`dark:focus-visible:ring-blue-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-warning":[`bg-amber-800`,`dark:bg-amber-600`,`text-white`,`hover:bg-amber-950`,`dark:hover:bg-amber-700`,`active:bg-amber-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-amber-700`,`disabled:active:bg-amber-800`,`dark:disabled:active:bg-amber-600`,`disabled:active:shadow-none`,`focus-visible:ring-amber-500`,`dark:focus-visible:ring-amber-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"solid-danger":[`bg-red-800`,`dark:bg-red-600`,`text-white`,`hover:bg-red-950`,`dark:hover:bg-red-700`,`active:bg-red-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-red-700`,`disabled:active:bg-red-800`,`dark:disabled:active:bg-red-600`,`disabled:active:shadow-none`,`focus-visible:ring-red-500`,`dark:focus-visible:ring-red-400`,`shadow-sm`,`hover:shadow`,`dark:shadow-gray-900/50`,`border-2`,`border-transparent`],"outline-action":[`bg-transparent`,`border-2`,`border-slate-700`,`dark:border-slate-500`,`text-slate-800`,`dark:text-slate-600`,`hover:bg-slate-800`,`dark:hover:bg-slate-600`,`hover:text-white`,`active:bg-slate-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-slate-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`shadow-none`,`hover:shadow-sm`],"outline-neutral":[`bg-transparent`,`border-2`,`border-gray-300`,`dark:border-gray-500`,`text-gray-700`,`dark:text-gray-200`,`hover:bg-white`,`dark:hover:bg-gray-700`,`hover:text-gray-900`,`dark:hover:text-white`,`active:bg-gray-50`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-sm`],"outline-info":[`bg-transparent`,`border-2`,`border-blue-700`,`dark:border-blue-500`,`text-blue-800`,`dark:text-blue-600`,`hover:bg-blue-800`,`dark:hover:bg-blue-600`,`hover:text-white`,`active:bg-blue-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-blue-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-blue-500`,`dark:focus-visible:ring-blue-400`,`shadow-none`,`hover:shadow-sm`],"outline-warning":[`bg-transparent`,`border-2`,`border-amber-700`,`dark:border-amber-500`,`text-amber-800`,`dark:text-amber-600`,`hover:bg-amber-800`,`dark:hover:bg-amber-600`,`hover:text-white`,`active:bg-amber-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-amber-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-amber-500`,`dark:focus-visible:ring-amber-400`,`shadow-none`,`hover:shadow-sm`],"outline-danger":[`bg-transparent`,`border-2`,`border-red-700`,`dark:border-red-500`,`text-red-800`,`dark:text-red-600`,`hover:bg-red-800`,`dark:hover:bg-red-600`,`hover:text-white`,`active:bg-red-900`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`dark:active:bg-red-700`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-red-500`,`dark:focus-visible:ring-red-400`,`shadow-none`,`hover:shadow-sm`],"ghost-action":[`bg-transparent`,`text-slate-800`,`dark:text-slate-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-neutral":[`bg-transparent`,`text-gray-700`,`dark:text-gray-200`,`active:bg-gray-50`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`active:text-gray-900`,`dark:active:text-white`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-info":[`bg-transparent`,`text-blue-800`,`dark:text-blue-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-warning":[`bg-transparent`,`text-amber-800`,`dark:text-amber-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"ghost-danger":[`bg-transparent`,`text-red-800`,`dark:text-red-400`,`active:bg-gray-100`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.1)]`,`dark:active:bg-gray-800`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-gray-400`,`dark:focus-visible:ring-gray-500`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`],"link-action":[`bg-transparent`,`text-slate-800`,`dark:text-slate-400`,`hover:text-slate-950`,`dark:hover:text-slate-200`,`active:text-slate-900`,`dark:active:text-slate-300`,`disabled:active:bg-transparent`,`dark:disabled:active:bg-transparent`,`disabled:active:shadow-none`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`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-blue-500`,`dark:focus-visible:ring-blue-400`,`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-amber-500`,`dark:focus-visible:ring-amber-400`,`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-red-500`,`dark:focus-visible:ring-red-400`,`shadow-none`,`hover:shadow-none`,`border-2`,`border-transparent`]},a=i[`${t}-${r}`]||i[`solid-neutral`],o=[...n,...a];return this.isFullWidth()&&o.push(`w-full`),o.join(` `)}render(){let e=this.isDisabled()||this.isLoading(),t=this.getType();if(!this._button){for(this._button=document.createElement(`button`);this.firstChild;)this._button.appendChild(this.firstChild);this.appendChild(this._button),this.setupEventListeners()}this._button.type=t,this._button.disabled=e;let n=this._button.querySelector(`mint-spinner`);if(this.isLoading())if(n)n.setAttribute(`data-button-variant`,this.getVariant()),n.setAttribute(`data-button-tone`,this.getTone()),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 r=this.getIcon(),i=this._button.querySelector(`[slot="icon"], .mint-button-icon, mint-icon`);r?(i&&i.tagName!==`MINT-ICON`&&(i.remove(),i=null),!i||i.tagName!==`MINT-ICON`?(i=document.createElement(`mint-icon`),i.setAttribute(`name`,r),i.className=`mint-button-icon`):i.setAttribute(`name`,r)):i&&i.tagName===`MINT-ICON`&&(i.remove(),i=null),i||=this._button.querySelector(`[slot="icon"], .mint-button-icon`);let a=this.getIconPosition(),o=this._button.querySelector(`.mint-button-content`);if(o){let e=i&&i.tagName===`MINT-ICON`;if(i&&!i.parentElement){let t=this._button.querySelector(`mint-spinner`)?.parentElement;e||a===`left`?t?t.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o):o.insertAdjacentElement(`afterend`,i)}else if(i&&(e||a===`left`)&&i.nextSibling!==o){i.remove();let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,o)}else i&&!e&&a===`right`&&i.previousSibling!==o&&(i.remove(),o.insertAdjacentElement(`afterend`,i))}else{let e=[];for(let t=this._button.firstChild;t;t=t.nextSibling)t.tagName!==`MINT-SPINNER`&&!t.querySelector?.(`mint-spinner`)&&t!==i&&!t.hasAttribute?.(`slot`)&&!(t.className===`mr-2`&&t.querySelector(`mint-spinner`))&&e.push(t);if(e.length>0){o=document.createElement(`span`),o.className=`mint-button-content inline-flex items-center`,e.forEach(e=>{o.appendChild(e)});let t=this._button.querySelector(`mint-spinner`)?.parentElement;i&&a===`left`?t?(t.insertAdjacentElement(`afterend`,i),i.insertAdjacentElement(`afterend`,o)):(this._button.insertBefore(i,this._button.firstChild),i.insertAdjacentElement(`afterend`,o)):i&&a===`right`?t?(t.insertAdjacentElement(`afterend`,o),o.insertAdjacentElement(`afterend`,i)):(this._button.insertBefore(o,this._button.firstChild),o.insertAdjacentElement(`afterend`,i)):t?t.insertAdjacentElement(`afterend`,o):this._button.insertBefore(o,this._button.firstChild)}else if(i&&i.tagName===`MINT-ICON`&&!i.parentElement){let e=this._button.querySelector(`mint-spinner`)?.parentElement;e?e.insertAdjacentElement(`afterend`,i):this._button.insertBefore(i,this._button.firstChild)}}let s=this.isIconOnly();i&&(i.classList.contains(`mint-button-icon`)||i.classList.add(`mint-button-icon`),i.classList.remove(`mr-1.5`,`ml-1.5`),s?i.tagName===`MINT-ICON`?(i.style.width=`1rem`,i.style.height=`1rem`,i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`):(i.style.maxWidth=`1rem`,i.style.maxHeight=`1rem`,i.style.flexShrink=`0`,i.tagName===`svg`&&(i.style.width=`1rem`,i.style.height=`1rem`)):a===`left`?i.classList.add(`mr-1.5`):i.classList.add(`ml-1.5`));let c=this.getButtonClasses();this._button.className=c}setupEventListeners(){this._button&&!this._clickHandler&&(this._clickHandler=this.handleClick.bind(this),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))}_handleMouseDown=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleMouseUp=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleMouseLeave=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchStart=()=>{this._button&&!this.isDisabled()&&!this.isLoading()&&this._button.classList.add(`mint-button-active`)};_handleTouchEnd=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};_handleTouchCancel=()=>{this._button&&this._button.classList.remove(`mint-button-active`)};handleClick(e){if(this.isDisabled()||this.isLoading()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();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`,Q);var Ce=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`icon`]}constructor(){super(),this._button=null,this._checked=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`,`flex`,`items-center`),this._checked=this.hasAttribute(`checked`),this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=n!==null),t!==n&&this.render()}get checked(){return this._checked}set checked(e){e?this.setAttribute(`checked`,``):this.removeAttribute(`checked`),this._checked=!!e,this.render()}isDisabled(){return this.hasAttribute(`disabled`)}getLabel(){return this.getAttribute(`label`)||``}getIcon(){return this.getAttribute(`icon`)||``}hasIcon(){return!!this.getIcon()}getSwitchClasses(){let e=[`relative`,`inline-flex`,`items-center`,`rounded-full`,`h-5`,`w-10`,`border`,`transition-colors`,`duration-200`,`ease-in-out`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`active:shadow-[inset_0_2px_4px_rgba(0,0,0,0.3)]`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],t=this._checked?[`bg-slate-950`,`dark:bg-slate-600`,`border-slate-700`,`dark:border-slate-500`]:[`bg-slate-200`,`dark:bg-slate-400`,`border-slate-300`,`dark:border-slate-500`];return[...e,...t].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.getSwitchClasses(),t=this.getThumbClasses(),n=this.getLabel(),r=this.getIcon();this._button||(this._button=document.createElement(`button`),this.appendChild(this._button),this.setupEventListeners()),this._button.className=e,this._button.disabled=this.isDisabled(),this._button.setAttribute(`aria-checked`,this._checked),this._button.setAttribute(`aria-label`,n),this._button.setAttribute(`role`,`switch`),this._button.type=`button`;let i=this._button.querySelector(`span`);i||(i=document.createElement(`span`),this._button.appendChild(i)),i.className=t;let a=i.querySelector(`span`);if(r){let e=a;e||(e=document.createElement(`span`),e.className=this.getIconClasses(),i.appendChild(e));let t=e.querySelector(`mint-icon`);t||(t=document.createElement(`mint-icon`),e.appendChild(t)),t.setAttribute(`name`,r)}else a&&a.remove()}setupEventListeners(){this._button&&this._button.addEventListener(`click`,this.handleToggle.bind(this))}removeEventListeners(){this._button&&this._button.removeEventListener(`click`,this.handleToggle.bind(this))}handleToggle(e){this.isDisabled()||(this.checked=!this._checked,this.dispatchEvent(new CustomEvent(`change`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent(`toggle`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0})))}};customElements.get(`mint-switch`)||customElements.define(`mint-switch`,Ce);var $=class extends HTMLElement{static get observedAttributes(){return[`variant`,`size`,`bold`,`underline`,`strike`,`italic`,`display`]}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.hasAttribute(`bold`)}isUnderline(){return this.hasAttribute(`underline`)}isStrike(){return this.hasAttribute(`strike`)}isItalic(){return this.hasAttribute(`italic`)}getDisplay(){return this.hasAttribute(`display`)?this.getAttribute(`display`):this.getSize()===`regular`?`inline-block`:`block`}getTextClasses(){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`,$);var we=class extends HTMLElement{static get observedAttributes(){return[`direction`,`text-align`]}constructor(){super()}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`}getTextAlign(){let e=this.getAttribute(`text-align`)||``;return[`left`,`center`,`right`,`justify`].includes(e)?e:``}getStackClasses(){let e=this.getDirection(),t=this.getTextAlign(),n=[`flex`,e===`horizontal`?`flex-row`:`flex-col`,`gap-3`];return t&&(n.push(`text-${t}`),n.push(`[&>*]:text-${t}`),n.push(`[&>*_.mint-button-content]:text-${t}`),t===`left`?(n.push(`[&>mint-button]:!justify-start`),n.push(`[&>mint-button>button]:!justify-start`)):t===`right`?(n.push(`[&>mint-button]:!justify-end`),n.push(`[&>mint-button>button]:!justify-end`)):t===`center`&&(n.push(`[&>mint-button]:!justify-center`),n.push(`[&>mint-button>button]:!justify-center`))),n.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`,we);var Te=class extends HTMLElement{static get observedAttributes(){return[]}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()}getCardClasses(){return[`rounded-lg`,`shadow`,`bg-white`,`dark:bg-gray-800`,`border`,`border-gray-200`,`dark:border-gray-700`,`overflow-hidden`,`transition-colors`,`duration-200`].join(` `)}render(){let e=this.getCardClasses();[`rounded-lg`,`shadow`,`bg-white`,`dark:bg-gray-800`,`border`,`border-gray-200`,`dark:border-gray-700`,`overflow-hidden`,`transition-colors`,`duration-200`].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)})}};customElements.get(`mint-card`)||customElements.define(`mint-card`,Te);var Ee=class extends HTMLElement{static get observedAttributes(){return[`href`,`target`]}constructor(){super(),this._link=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`,`transition-colors`,`duration-200`,`focus-visible:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`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`,Ee);var De=class extends HTMLElement{static get observedAttributes(){return[`href`,`fallback-href`]}constructor(){super(),this._historyDepth=0,this._maxBackAttempts=10,this._backAttempts=0}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-block`,`flex`,`items-center`,`justify-center`),this.render(),this._setupHistoryTracking()}attributeChangedCallback(e,t,n){t!==n&&this.render()}_setupHistoryTracking(){window.addEventListener(`popstate`,()=>{this._backAttempts=0}),this._historyDepth=window.history.length}getFallbackHref(){return this.getAttribute(`fallback-href`)||this.getAttribute(`href`)||`/`}handleClick(e){if(e.preventDefault(),e.stopPropagation(),window.history.length>1&&this._backAttempts<this._maxBackAttempts&&this._backAttempts===0){this._backAttempts++;let e=window.location.href,t=Date.now();window.history.back(),setTimeout(()=>{Date.now()-t,window.location.href===e?this._navigateToFallback():setTimeout(()=>{this._backAttempts=0},500)},200)}else this._navigateToFallback()}_navigateToFallback(){let e=this.getFallbackHref();if(this._backAttempts=0,e.startsWith(`/`)&&!e.startsWith(`//`)){let t=document.querySelector(`#app`).__vue_app__;if(t&&t.config&&t.config.globalProperties&&t.config.globalProperties.$router)try{t.config.globalProperties.$router.push(e);return}catch{}try{window.history.pushState({},``,e),window.dispatchEvent(new PopStateEvent(`popstate`));return}catch{}}window.location.href=e}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`,De);var Oe=class extends HTMLElement{static get observedAttributes(){return[`heading`,`fallback-href`,`show-back-button`]}constructor(){super(),this._pageContainer=null,this._header=null,this._titleElement=null,this._headingText=null,this._actionsSlot=null,this._bodySlot=null,this._darkModeObserver=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`block`),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}getHeading(){return this.getAttribute(`heading`)||``}getFallbackHref(){return this.getAttribute(`fallback-href`)||`/`}shouldShowBackButton(){return this.hasAttribute(`show-back-button`)}render(){let e=this.getHeading();this._pageContainer||(this._pageContainer=document.createElement(`div`),this._pageContainer.className=`min-h-screen p-8 transition-colors duration-200`,this.appendChild(this._pageContainer)),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)}else t&&=(t.remove(),null);e?(this._headingText?(this._headingText.classList.add(`truncate`,`min-w-0`),t&&t.parentElement===this._titleElement?this._headingText.previousSibling!==t&&this._titleElement.insertBefore(this._headingText,t.nextSibling):this._headingText.previousSibling&&this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)):(this._headingText=document.createElement(`mint-text`),this._headingText.setAttribute(`size`,`heading`),this._headingText.setAttribute(`bold`,``),this._headingText.classList.add(`truncate`,`min-w-0`),t&&t.parentElement===this._titleElement?this._titleElement.insertBefore(this._headingText,t.nextSibling):this._titleElement.insertBefore(this._headingText,this._titleElement.firstChild)),this._headingText.textContent=e):this._headingText&&=(this._headingText.remove(),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=>{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()}_updateBackgroundColor(){this._pageContainer&&(document.documentElement.classList.contains(`dark`)?(this._pageContainer.classList.remove(`bg-gray-50`),this._pageContainer.classList.add(`bg-gray-900`)):(this._pageContainer.classList.remove(`bg-gray-900`),this._pageContainer.classList.add(`bg-gray-50`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}};customElements.get(`mint-page`)||customElements.define(`mint-page`,Oe);var ke=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`)||null}getMd(){return this.getAttribute(`md`)||null}getLg(){return this.getAttribute(`lg`)||null}getXl(){return this.getAttribute(`xl`)||null}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`,ke);var Ae=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}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`fixed`,`inset-0`,`z-50`),this.isOpen()||this.classList.add(`hidden`),this.render(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null)}attributeChangedCallback(e,t,n){t!==n&&this.render()}getId(){return this.getAttribute(`id`)||``}getHeading(){return this.getAttribute(`heading`)||``}isOpen(){return this.hasAttribute(`open`)}open(){this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}render(){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 bg-opacity-50 transition-opacity duration-200 z-40`,this._overlay.addEventListener(`click`,()=>this.close()),this.appendChild(this._overlay)),this._modal||(this._modal=document.createElement(`div`),this._modal.className=`fixed inset-0 flex items-center justify-center p-2 pointer-events-none z-50`,this.appendChild(this._modal)),n){let e=this._modal.querySelector(`.modal-content`);e||(e=document.createElement(`div`),e.className=`modal-content bg-white dark:bg-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform`,this._modal.appendChild(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-gray-800 rounded-lg shadow-xl max-w-2xl w-full max-h-[90vh] flex flex-col pointer-events-auto transition-all duration-200 ease-out transform`,this._modal.appendChild(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-gray-700`,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`,``),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=>{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=>{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-gray-700`,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-gray-800`)):(t.classList.remove(`bg-gray-800`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_animateEnter(){let e=this._modal?.querySelector(`.modal-content`);e&&(e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,e.style.transition=`all 200ms ease-out`,this.classList.remove(`hidden`),requestAnimationFrame(()=>{requestAnimationFrame(()=>{e.style.transform=`scale(1) translateY(0)`,e.style.opacity=`1`})}))}_animateExit(){let e=this._modal?.querySelector(`.modal-content`);if(!e){this.classList.add(`hidden`);return}e.style.transition=`all 200ms ease-in`,e.style.transform=`scale(0.97) translateY(10px)`,e.style.opacity=`0`,setTimeout(()=>{this.classList.add(`hidden`),e.style.transform=``,e.style.opacity=``,e.style.transition=``},200)}};customElements.get(`mint-modal`)||customElements.define(`mint-modal`,Ae);var je=class extends HTMLElement{static get observedAttributes(){return[`id`,`direction`,`open`,`trigger-id`]}constructor(){super(),this._overlay=null,this._popover=null,this._triggerElement=null,this._darkModeObserver=null,this._clickOutsideHandler=null,this._triggerClickHandler=null,this._scrollHandler=null,this._resizeHandler=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._setupTrigger(),this._observeDarkMode()}disconnectedCallback(){this._darkModeObserver&&=(this._darkModeObserver.disconnect(),null),this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler),null),this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler),this._triggerClickHandler=null),this._scrollHandler&&=(window.removeEventListener(`scroll`,this._scrollHandler,!0),null),this._resizeHandler&&=(window.removeEventListener(`resize`,this._resizeHandler),null)}attributeChangedCallback(e,t,n){t!==n&&(this.render(),e===`trigger-id`&&this._setupTrigger())}getId(){return this.getAttribute(`id`)||``}getDirection(){return this.getAttribute(`direction`)||`down`}getTriggerId(){return this.getAttribute(`trigger-id`)||``}isOpen(){return this.hasAttribute(`open`)}open(){this.setAttribute(`open`,``)}close(){this.removeAttribute(`open`)}_setupTrigger(){let e=this.getTriggerId();this._triggerClickHandler&&this._triggerElement&&(this._triggerElement.removeEventListener(`click`,this._triggerClickHandler),this._triggerClickHandler=null),e&&(this._triggerElement=document.getElementById(e),this._triggerElement?this._attachTriggerListener():setTimeout(()=>{this._triggerElement=document.getElementById(e),this._triggerElement&&this._attachTriggerListener()},10))}_attachTriggerListener(){if(this._triggerElement&&!this._triggerClickHandler){let e=this;this._triggerClickHandler=function(t){t.stopImmediatePropagation(),t.preventDefault(),e.hasAttribute(`open`)?e.removeAttribute(`open`):e.setAttribute(`open`,``)},this._triggerElement.addEventListener(`click`,this._triggerClickHandler,!0)}}_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.getDirection(),o=0,s=0;switch(a){case`down`:if(o=e.bottom+8,s=e.left+e.width/2-n.width/2,o+n.height>i){let t=e.top-n.height-8;t>=0?(a=`up`,o=t):(o=Math.max(0,i-n.height-8),o+n.height>i&&(o=0))}s<0&&(s=8),s+n.width>r&&(s=Math.max(8,r-n.width-8),s+n.width>r&&(s=r-n.width));break;case`up`:if(o=e.top-n.height-8,s=e.left+e.width/2-n.width/2,o<0){let t=e.bottom+8;t+n.height<=i?(a=`down`,o=t):(o=Math.min(i-n.height-8,i-n.height),o<0&&(o=i-n.height))}s<0&&(s=8),s+n.width>r&&(s=Math.max(8,r-n.width-8),s+n.width>r&&(s=r-n.width));break;case`right`:if(o=e.top+e.height/2-n.height/2,s=e.right+8,s+n.width>r){let t=e.left-n.width-8;t>=0?(a=`left`,s=t):(s=Math.max(0,r-n.width-8),s+n.width>r&&(s=r-n.width))}o<0&&(o=8),o+n.height>i&&(o=Math.max(8,i-n.height-8),o+n.height>i&&(o=i-n.height));break;case`left`:if(o=e.top+e.height/2-n.height/2,s=e.left-n.width-8,s<0){let t=e.right+8;t+n.width<=r?(a=`right`,s=t):(s=Math.min(r-n.width-8,r-n.width),s<0&&(s=0))}o<0&&(o=8),o+n.height>i&&(o=Math.max(8,i-n.height-8),o+n.height>i&&(o=i-n.height));break}return{top:o,left:s,direction:a}}render(){let e=this.getId(),t=this.isOpen();if(e&&(this.id=e),t){if(this.classList.remove(`hidden`),this.style.pointerEvents=`auto`,!this._clickOutsideHandler){let e=this;this._clickOutsideHandler=function(t){let n=t.target,r=e._popover?.querySelector(`.popover-content`),i=r&&(r.contains(n)||r===n),a=n.closest(`button, a, [role="button"], mint-button, mint-link`)!==null;(!i||a)&&e.close()},setTimeout(()=>{document.addEventListener(`click`,this._clickOutsideHandler,!1)},100)}}else this.classList.add(`hidden`),this.style.pointerEvents=`none`,this._clickOutsideHandler&&=(document.removeEventListener(`click`,this._clickOutsideHandler,!0),null);this._overlay||(this._overlay=document.createElement(`div`),this._overlay.className=`fixed inset-0 pointer-events-none z-40`,this.appendChild(this._overlay)),this._popover||(this._popover=document.createElement(`div`),this._popover.className=`fixed z-50 pointer-events-auto`,this.appendChild(this._popover));let n=this._popover.querySelector(`.popover-content`);n||(n=document.createElement(`div`),n.className=`popover-content bg-white dark:bg-gray-800 rounded-lg shadow-xl p-4 transition-all duration-200 ease-out transform`,this._popover.appendChild(n)),Array.from(this.children).forEach(e=>{e!==this._overlay&&e!==this._popover&&e.parentElement===this&&n.appendChild(e)}),t?(this._triggerElement||this._setupTrigger(),this._setupPositionListeners(),this.offsetHeight,this._triggerElement?this._updatePosition(n):(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`,n.style.transform=`scale(0.97) translateY(10px)`,n.style.opacity=`0`,n.style.transition=`all 200ms ease-out`,requestAnimationFrame(()=>{requestAnimationFrame(()=>{n.style.transform=`scale(1) translateY(0)`,n.style.opacity=`1`})}))):!t&&n&&(this._removePositionListeners(),n.style.opacity!==`0`&&n.style.opacity!==``&&(n.style.transition=`all 200ms ease-in`,n.style.transform=`scale(0.97) translateY(10px)`,n.style.opacity=`0`,setTimeout(()=>{n.style.transform=``,n.style.opacity=``,n.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-gray-800`)):(t.classList.remove(`bg-gray-800`),t.classList.add(`bg-white`)))}_observeDarkMode(){this._darkModeObserver||(this._darkModeObserver=new MutationObserver(()=>{this._updateBackgroundColor()}),this._darkModeObserver.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}))}_updatePosition(e){if(!this._triggerElement||!this._popover)return;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=`all 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`);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`);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)}};customElements.get(`mint-popover`)||customElements.define(`mint-popover`,je);var Me=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`]}constructor(){super(),this._checkbox=null,this._checked=!1,this._clickHandler=null}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=n!==null&&n!==`false`,this._checkbox&&(this._checkbox.checked=this._checked)),t!==n&&(this.render(),e===`checked`&&this._checkbox&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute(`checked`,``):this.removeAttribute(`checked`),this._checked=!!e,this._checkbox&&(this._checkbox.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute(`disabled`)}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getValue(){return this.getAttribute(`value`)||``}getCheckboxClasses(){let e=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded`,`border-2`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`cursor-pointer`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],t=this._checked?[`bg-slate-800`,`dark:bg-slate-600`,`border-slate-800`,`dark:border-slate-600`]:[`bg-white`,`dark:bg-gray-700`,`border-gray-300`,`dark:border-gray-500`];return[...e,...t].join(` `)}render(){let e=this.getLabel(),t=this.getInfo(),n=this.isDisabled(),r=this.querySelector(`.mint-checkbox-wrapper`);r||(r=document.createElement(`div`),r.className=`mint-checkbox-wrapper`,this.insertBefore(r,this.firstChild)),this._checkbox?this._checkbox.parentElement!==r&&r.appendChild(this._checkbox):(this._checkbox=document.createElement(`input`),this._checkbox.type=`checkbox`,r.appendChild(this._checkbox),this.setupEventListeners()),this._checkbox.className=`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,this._checkbox.style.cssText=`position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 10; pointer-events: auto; margin: 0; padding: 0;`,this._checkbox.checked=this._checked,this._checkbox.disabled=n,this._changeHandler||this.setupEventListeners();let i=this.getId();i?this._checkbox.id=i:this._checkbox.removeAttribute(`id`);let a=this.getName();a?this._checkbox.name=a:this._checkbox.removeAttribute(`name`);let o=this.getValue();o?this._checkbox.value=o:this._checkbox.removeAttribute(`value`),e?this._checkbox.setAttribute(`aria-label`,e):this._checkbox.removeAttribute(`aria-label`),r.className=`mint-checkbox-wrapper ${this.getCheckboxClasses()}`,r.style.pointerEvents=`none`,this._checkbox.style.pointerEvents=`auto`;let s=r.querySelector(`mint-icon`);s||(s=document.createElement(`mint-icon`),s.setAttribute(`name`,`check`),s.className=`w-3.5 h-3.5 text-white pointer-events-none absolute inset-0 m-auto`,s.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,s.style.zIndex=`1`,r.appendChild(s)),this.updateVisualState();let c=this.querySelector(`.mint-checkbox-label-container`);if(e||t){c||(c=document.createElement(`div`),c.className=`mint-checkbox-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(c));let r=c.querySelector(`.mint-checkbox-label`);e?(r||(r=document.createElement(`span`),r.className=`mint-checkbox-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,c.insertBefore(r,c.firstChild)),r.textContent=e,n?r.classList.add(`opacity-50`):r.classList.remove(`opacity-50`)):r&&r.remove();let i=c.querySelector(`.mint-checkbox-info`);if(t?(i||(i=document.createElement(`span`),i.className=`mint-checkbox-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,c.appendChild(i)),i.textContent=t,n?i.classList.add(`opacity-50`):i.classList.remove(`opacity-50`)):i&&i.remove(),n)c.style.cursor=`default`,c._clickHandler&&(c.removeEventListener(`click`,c._clickHandler),c._clickHandler=null);else{c.style.cursor=`pointer`;let e=c._clickHandler;e&&c.removeEventListener(`click`,e),c._clickHandler=e=>{this._checkbox&&(e.target===this._checkbox||this._checkbox.contains(e.target)||e.composedPath().includes(this._checkbox))||this.toggle()},c.addEventListener(`click`,c._clickHandler)}}else c&&c.remove()}setupEventListeners(){this.removeEventListeners(),this._checkbox&&(this._changeHandler=e=>{e.stopPropagation(),this._checked=this._checkbox.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState();let t=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)},this._checkbox.addEventListener(`change`,this._changeHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-checkbox-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-checkbox-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._mouseupHandler=e=>{e.stopPropagation();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._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(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._touchendHandler=e=>{e.stopPropagation();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))}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.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState();let e=new CustomEvent(`change`,{detail:{checked:this._checked},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}}};customElements.get(`mint-checkbox`)||customElements.define(`mint-checkbox`,Me);var Ne=class extends HTMLElement{static get observedAttributes(){return[`checked`,`disabled`,`label`,`info`,`id`,`name`,`value`]}constructor(){super(),this._radio=null,this._checked=!1}connectedCallback(){this.classList.add(`box-border`,`m-0`,`p-0`,`border-0`,`align-baseline`,`inline-flex`,`items-start`,`gap-2`);let e=this.getAttribute(`checked`);this._checked=e!==null&&e!==`false`,this.render()}disconnectedCallback(){this.removeEventListeners()}attributeChangedCallback(e,t,n){e===`checked`&&(this._checked=n!==null&&n!==`false`,this._radio&&(this._radio.checked=this._checked)),t!==n&&(this.render(),e===`checked`&&this._radio&&this.updateVisualState())}get checked(){return this._checked}set checked(e){e?this.setAttribute(`checked`,``):this.removeAttribute(`checked`),this._checked=!!e,this._radio&&(this._radio.checked=this._checked),this.updateVisualState()}isDisabled(){return this.hasAttribute(`disabled`)}getLabel(){return this.getAttribute(`label`)||``}getInfo(){return this.getAttribute(`info`)||``}getId(){return this.getAttribute(`id`)||``}getName(){return this.getAttribute(`name`)||``}getValue(){return this.getAttribute(`value`)||``}getChoiceClasses(){let e=[`relative`,`inline-flex`,`items-center`,`justify-center`,`flex-shrink-0`,`w-5`,`h-5`,`rounded-full`,`border-2`,`transition-all`,`duration-200`,`outline-none`,`focus:outline-none`,`focus-visible:ring-2`,`focus-visible:ring-offset-2`,`focus-visible:ring-slate-500`,`dark:focus-visible:ring-slate-400`,`cursor-pointer`,`disabled:opacity-50`,`disabled:cursor-not-allowed`],t=this._checked?[`bg-slate-800`,`dark:bg-slate-600`,`border-slate-800`,`dark:border-slate-600`]:[`bg-white`,`dark:bg-gray-700`,`border-gray-300`,`dark:border-gray-500`];return[...e,...t].join(` `)}render(){let e=this.getLabel(),t=this.getInfo(),n=this.isDisabled(),r=this.querySelector(`.mint-choice-wrapper`);r||(r=document.createElement(`div`),r.className=`mint-choice-wrapper`,this.insertBefore(r,this.firstChild)),this._radio?this._radio.parentElement!==r&&r.appendChild(this._radio):(this._radio=document.createElement(`input`),this._radio.type=`radio`,r.appendChild(this._radio),this.setupEventListeners()),this._radio.className=`absolute inset-0 w-full h-full opacity-0 cursor-pointer`,this._radio.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._radio.checked=this._checked,this._radio.disabled=n,this._changeHandler||this.setupEventListeners();let i=this.getId();i?this._radio.id=i:this._radio.removeAttribute(`id`);let a=this.getName();a?this._radio.name=a:this._radio.removeAttribute(`name`);let o=this.getValue();o?this._radio.value=o:this._radio.removeAttribute(`value`),e?this._radio.setAttribute(`aria-label`,e):this._radio.removeAttribute(`aria-label`),r.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,r.style.pointerEvents=`none`,this._radio.style.pointerEvents=`auto`;let s=r.querySelector(`.mint-choice-indicator`);s||(s=document.createElement(`div`),s.className=`mint-choice-indicator w-2.5 h-2.5 rounded-full bg-white pointer-events-none absolute inset-0 m-auto`,s.style.transition=`opacity 200ms ease-out, transform 200ms ease-out`,s.style.zIndex=`1`,r.appendChild(s)),s.style.opacity=this._checked?`1`:`0`,s.style.transform=this._checked?`scale(1)`:`scale(0.8)`,this.updateVisualState();let c=this.querySelector(`.mint-choice-label-container`);if(e||t){c||(c=document.createElement(`div`),c.className=`mint-choice-label-container flex flex-col gap-0.5 flex-1`,this.appendChild(c));let r=c.querySelector(`.mint-choice-label`);e?(r||(r=document.createElement(`span`),r.className=`mint-choice-label text-sm font-medium text-gray-900 dark:text-gray-100 cursor-pointer select-none`,c.insertBefore(r,c.firstChild)),r.textContent=e,n?r.classList.add(`opacity-50`):r.classList.remove(`opacity-50`)):r&&r.remove();let i=c.querySelector(`.mint-choice-info`);if(t?(i||(i=document.createElement(`span`),i.className=`mint-choice-info text-xs text-gray-500 dark:text-gray-400 cursor-pointer select-none`,c.appendChild(i)),i.textContent=t,n?i.classList.add(`opacity-50`):i.classList.remove(`opacity-50`)):i&&i.remove(),n)c.style.cursor=`default`,c._clickHandler&&(c.removeEventListener(`click`,c._clickHandler),c._clickHandler=null);else{c.style.cursor=`pointer`;let e=c._clickHandler;e&&c.removeEventListener(`click`,e),c._clickHandler=e=>{this._radio&&(e.target===this._radio||this._radio.contains(e.target)||e.composedPath().includes(this._radio))||this.select()},c.addEventListener(`click`,c._clickHandler)}}else c&&c.remove()}setupEventListeners(){this.removeEventListeners(),this._radio&&(this._changeHandler=e=>{e.stopPropagation();let t=this._checked;if(this._checked=this._radio.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState(),this._checked){let e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}})}if(t!==this._checked){let e=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(e)}},this._radio.addEventListener(`change`,this._changeHandler),this._groupChangeHandler=e=>{e.target!==this._radio&&e.target.type===`radio`&&e.target.name===this._radio.name&&e.target.checked&&setTimeout(()=>{this._radio&&this._radio.checked!==this._checked&&(this._checked=this._radio.checked,this._checked?this.hasAttribute(`checked`)||this.setAttribute(`checked`,``):this.hasAttribute(`checked`)&&this.removeAttribute(`checked`),this.updateVisualState())},0)},document.addEventListener(`change`,this._groupChangeHandler,!0),this._clickHandler=e=>{let t=this._radio.name;t&&document.querySelectorAll(`input[type="radio"][name="${t}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}}),requestAnimationFrame(()=>{this._checked=this._radio.checked,this.updateVisualState()})},this._radio.addEventListener(`click`,this._clickHandler),this._mousedownHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-choice-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._mouseupHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._mouseleaveHandler=e=>{let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._radio.addEventListener(`mousedown`,this._mousedownHandler),this._radio.addEventListener(`mouseup`,this._mouseupHandler),this._radio.addEventListener(`mouseleave`,this._mouseleaveHandler),this._touchstartHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&!this.isDisabled()&&(t.classList.add(`mint-choice-active`),this._checked?(t.style.backgroundColor=`rgb(15 23 42)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.3)`):(t.style.backgroundColor=`rgb(243 244 246)`,t.style.boxShadow=`inset 0 2px 4px rgba(0, 0, 0, 0.1)`),document.documentElement.classList.contains(`dark`)&&(this._checked?t.style.backgroundColor=`rgb(51 65 85)`:t.style.backgroundColor=`rgb(31 41 55)`))},this._touchendHandler=e=>{e.stopPropagation();let t=this.querySelector(`.mint-choice-wrapper`);t&&(t.classList.remove(`mint-choice-active`),t.style.backgroundColor=``,t.style.boxShadow=``)},this._radio.addEventListener(`touchstart`,this._touchstartHandler),this._radio.addEventListener(`touchend`,this._touchendHandler))}removeEventListeners(){this._radio&&(this._changeHandler&&=(this._radio.removeEventListener(`change`,this._changeHandler),null),this._groupChangeHandler&&=(document.removeEventListener(`change`,this._groupChangeHandler),null),this._clickHandler&&=(this._radio.removeEventListener(`click`,this._clickHandler),null),this._mousedownHandler&&=(this._radio.removeEventListener(`mousedown`,this._mousedownHandler),null),this._mouseupHandler&&=(this._radio.removeEventListener(`mouseup`,this._mouseupHandler),null),this._mouseleaveHandler&&=(this._radio.removeEventListener(`mouseleave`,this._mouseleaveHandler),null),this._touchstartHandler&&=(this._radio.removeEventListener(`touchstart`,this._touchstartHandler),null),this._touchendHandler&&=(this._radio.removeEventListener(`touchend`,this._touchendHandler),null))}updateVisualState(){let e=this.querySelector(`.mint-choice-wrapper`),t=e?.querySelector(`.mint-choice-indicator`);t&&(t.style.opacity=this._checked?`1`:`0`,t.style.transform=this._checked?`scale(1)`:`scale(0.8)`),e&&(e.className=`mint-choice-wrapper ${this.getChoiceClasses()}`,e.classList.contains(`mint-choice-active`)||(e.style.backgroundColor=``,e.style.boxShadow=``))}select(){if(this._radio&&!this.isDisabled()){this._radio.checked=!0,this._radio.dispatchEvent(new Event(`change`,{bubbles:!0})),this._checked=!0,this.hasAttribute(`checked`)||this.setAttribute(`checked`,``);let e=this._radio.name;e&&document.querySelectorAll(`input[type="radio"][name="${e}"]`).forEach(e=>{if(e!==this._radio){let t=e.closest(`mint-choice`);t&&t.updateVisualState&&(t._checked=e.checked,e.checked?t.hasAttribute(`checked`)||t.setAttribute(`checked`,``):t.hasAttribute(`checked`)&&t.removeAttribute(`checked`),t.updateVisualState())}}),this.updateVisualState();let t=new CustomEvent(`change`,{detail:{checked:this._checked,value:this.getValue()},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}};customElements.get(`mint-choice`)||customElements.define(`mint-choice`,Ne),exports.Button=Q,exports.default=Q,exports.Card=Te,exports.Checkbox=Me,exports.Choice=Ne,exports.Grid=ke,exports.Icon=i,exports.Link=Ee,exports.Modal=Ae,exports.Page=Oe,exports.Popover=je,exports.Spinner=e,exports.Stack=we,exports.Switch=Ce,exports.Text=$;