@customafk/lunas-ui 0.2.0 → 0.2.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 (195) hide show
  1. package/dist/button-B2FJrOBP.mjs +2 -0
  2. package/dist/button-B2FJrOBP.mjs.map +1 -0
  3. package/dist/{button-D0YsVKtm.d.cts → button-BnFROtRM.d.cts} +3 -3
  4. package/dist/button-CYw2AqT0.cjs +2 -0
  5. package/dist/button-CYw2AqT0.cjs.map +1 -0
  6. package/dist/{button-L3Ts3X9d.d.mts → button-IfNjnUO-.d.mts} +3 -3
  7. package/dist/{calendar-D3hTjPxn.mjs → calendar-Bt6qXSZb.mjs} +2 -2
  8. package/dist/{calendar-D3hTjPxn.mjs.map → calendar-Bt6qXSZb.mjs.map} +1 -1
  9. package/dist/{calendar-CO20ceyB.cjs → calendar-BwWfk_Zk.cjs} +2 -2
  10. package/dist/{calendar-CO20ceyB.cjs.map → calendar-BwWfk_Zk.cjs.map} +1 -1
  11. package/dist/cards/grid-product-card.cjs +1 -1
  12. package/dist/cards/grid-product-card.mjs +1 -1
  13. package/dist/cards/product-card.cjs +1 -1
  14. package/dist/cards/product-card.mjs +1 -1
  15. package/dist/data-display/statistic.d.cts +2 -2
  16. package/dist/{dialog-C3T_1iTB.d.cts → dialog-CyLgmqny.d.cts} +12 -12
  17. package/dist/{dialog-COoKGA4Q.d.mts → dialog-lFDfcYPP.d.mts} +12 -12
  18. package/dist/dialogs/detail-dialog/components/sidebar.cjs +1 -1
  19. package/dist/dialogs/detail-dialog/components/sidebar.d.cts +26 -26
  20. package/dist/dialogs/detail-dialog/components/sidebar.d.mts +24 -24
  21. package/dist/dialogs/detail-dialog/components/sidebar.mjs +1 -1
  22. package/dist/dialogs/detail-dialog/index.cjs +1 -1
  23. package/dist/dialogs/detail-dialog/index.mjs +1 -1
  24. package/dist/features/descriptions/index.d.cts +4 -4
  25. package/dist/features/search-modal/index.d.cts +2 -2
  26. package/dist/features/search-modal/index.d.mts +2 -2
  27. package/dist/features/tables/index.cjs +1 -1
  28. package/dist/features/tables/index.d.cts +1 -1
  29. package/dist/features/tables/index.d.mts +23 -23
  30. package/dist/features/tables/index.mjs +1 -1
  31. package/dist/features/tanstack-form/index.cjs +1 -1
  32. package/dist/features/tanstack-form/index.cjs.map +1 -1
  33. package/dist/features/tanstack-form/index.d.cts +224 -224
  34. package/dist/features/tanstack-form/index.d.mts +224 -224
  35. package/dist/features/tanstack-form/index.mjs +1 -1
  36. package/dist/features/tanstack-form/index.mjs.map +1 -1
  37. package/dist/{input-C9dS5env.d.mts → input-Bm0YXroi.d.cts} +6 -6
  38. package/dist/{input-C3M7uZqX.d.cts → input-CLlVXOR2.d.mts} +6 -6
  39. package/dist/layouts/cms-layout/index.cjs +1 -1
  40. package/dist/layouts/cms-layout/index.mjs +1 -1
  41. package/dist/layouts/flex.d.cts +2 -2
  42. package/dist/layouts/flex.d.mts +2 -2
  43. package/dist/layouts/payment-layout/index.cjs +1 -1
  44. package/dist/layouts/payment-layout/index.mjs +1 -1
  45. package/dist/pages/FeatureDeveloping.cjs +1 -1
  46. package/dist/pages/FeatureDeveloping.d.cts +2 -2
  47. package/dist/pages/FeatureDeveloping.d.mts +2 -2
  48. package/dist/pages/FeatureDeveloping.mjs +1 -1
  49. package/dist/pages/FeatureFixing.cjs +1 -1
  50. package/dist/pages/FeatureFixing.d.cts +2 -2
  51. package/dist/pages/FeatureFixing.d.mts +2 -2
  52. package/dist/pages/FeatureFixing.mjs +1 -1
  53. package/dist/pages/NotAuthorized.cjs +1 -1
  54. package/dist/pages/NotAuthorized.d.cts +2 -2
  55. package/dist/pages/NotAuthorized.d.mts +2 -2
  56. package/dist/pages/NotAuthorized.mjs +1 -1
  57. package/dist/pages/NotFound.cjs +1 -1
  58. package/dist/pages/NotFound.d.cts +2 -2
  59. package/dist/pages/NotFound.d.mts +2 -2
  60. package/dist/pages/NotFound.mjs +1 -1
  61. package/dist/typography/paragraph.d.cts +5 -5
  62. package/dist/typography/paragraph.d.mts +5 -5
  63. package/dist/typography/title.d.cts +2 -2
  64. package/dist/typography/title.d.mts +2 -2
  65. package/dist/ui/alert-dialog.d.cts +12 -12
  66. package/dist/ui/alert-dialog.d.mts +12 -12
  67. package/dist/ui/alert.d.cts +4 -4
  68. package/dist/ui/alert.d.mts +4 -4
  69. package/dist/ui/aspect-ratio.d.cts +2 -2
  70. package/dist/ui/aspect-ratio.d.mts +2 -2
  71. package/dist/ui/avatar.d.cts +4 -4
  72. package/dist/ui/avatar.d.mts +4 -4
  73. package/dist/ui/badge.d.cts +4 -4
  74. package/dist/ui/badge.d.mts +4 -4
  75. package/dist/ui/breadcrumb.d.cts +8 -8
  76. package/dist/ui/breadcrumb.d.mts +8 -8
  77. package/dist/ui/button-group.d.cts +6 -6
  78. package/dist/ui/button-group.d.mts +6 -6
  79. package/dist/ui/button.cjs +1 -1
  80. package/dist/ui/button.d.cts +1 -1
  81. package/dist/ui/button.d.mts +1 -1
  82. package/dist/ui/button.mjs +1 -1
  83. package/dist/ui/buttons/add-new.cjs +1 -1
  84. package/dist/ui/buttons/add-new.mjs +1 -1
  85. package/dist/ui/buttons/edit.cjs +1 -1
  86. package/dist/ui/buttons/edit.mjs +1 -1
  87. package/dist/ui/buttons/refresh.cjs +1 -1
  88. package/dist/ui/buttons/refresh.mjs +1 -1
  89. package/dist/ui/buttons/trash.cjs +1 -1
  90. package/dist/ui/buttons/trash.mjs +1 -1
  91. package/dist/ui/buttons/upload-image.cjs +1 -1
  92. package/dist/ui/buttons/upload-image.mjs +1 -1
  93. package/dist/ui/calendar.cjs +1 -1
  94. package/dist/ui/calendar.d.cts +4 -4
  95. package/dist/ui/calendar.d.mts +4 -4
  96. package/dist/ui/calendar.mjs +1 -1
  97. package/dist/ui/card.d.cts +8 -8
  98. package/dist/ui/card.d.mts +8 -8
  99. package/dist/ui/carousel.cjs +1 -1
  100. package/dist/ui/carousel.d.cts +7 -7
  101. package/dist/ui/carousel.d.mts +7 -7
  102. package/dist/ui/carousel.mjs +1 -1
  103. package/dist/ui/checkbox.d.cts +2 -2
  104. package/dist/ui/checkbox.d.mts +2 -2
  105. package/dist/ui/collapsible.d.cts +4 -4
  106. package/dist/ui/collapsible.d.mts +4 -4
  107. package/dist/ui/command.d.cts +11 -11
  108. package/dist/ui/command.d.mts +11 -11
  109. package/dist/ui/context-menu.d.cts +16 -16
  110. package/dist/ui/context-menu.d.mts +16 -16
  111. package/dist/ui/dialog.d.cts +1 -1
  112. package/dist/ui/dialog.d.mts +1 -1
  113. package/dist/ui/drawer.d.cts +11 -11
  114. package/dist/ui/drawer.d.mts +11 -11
  115. package/dist/ui/dropdown-menu.d.cts +16 -16
  116. package/dist/ui/dropdown-menu.d.mts +16 -16
  117. package/dist/ui/empty.d.cts +9 -9
  118. package/dist/ui/empty.d.mts +9 -9
  119. package/dist/ui/field.d.cts +13 -13
  120. package/dist/ui/field.d.mts +24 -24
  121. package/dist/ui/file-uploader.cjs +1 -1
  122. package/dist/ui/file-uploader.d.cts +2 -2
  123. package/dist/ui/file-uploader.d.mts +2 -2
  124. package/dist/ui/file-uploader.mjs +1 -1
  125. package/dist/ui/form.d.cts +7 -7
  126. package/dist/ui/form.d.mts +11 -11
  127. package/dist/ui/hover-card.d.cts +4 -4
  128. package/dist/ui/hover-card.d.mts +4 -4
  129. package/dist/ui/input-otp.d.cts +5 -5
  130. package/dist/ui/input-otp.d.mts +5 -5
  131. package/dist/ui/input.d.cts +1 -1
  132. package/dist/ui/input.d.mts +1 -1
  133. package/dist/ui/inputs/search-input.d.cts +3 -3
  134. package/dist/ui/inputs/search-input.d.mts +3 -3
  135. package/dist/ui/item.d.cts +14 -14
  136. package/dist/ui/item.d.mts +14 -14
  137. package/dist/ui/label.d.cts +2 -2
  138. package/dist/ui/label.d.mts +2 -2
  139. package/dist/ui/menubar.d.cts +17 -17
  140. package/dist/ui/menubar.d.mts +17 -17
  141. package/dist/ui/multi-select.cjs +1 -1
  142. package/dist/ui/multi-select.d.cts +2 -2
  143. package/dist/ui/multi-select.d.mts +3 -3
  144. package/dist/ui/multi-select.mjs +1 -1
  145. package/dist/ui/navigation-menu.d.cts +9 -9
  146. package/dist/ui/navigation-menu.d.mts +11 -11
  147. package/dist/ui/pagination.d.cts +9 -9
  148. package/dist/ui/pagination.d.mts +9 -9
  149. package/dist/ui/popover.d.cts +6 -6
  150. package/dist/ui/popover.d.mts +6 -6
  151. package/dist/ui/progress.d.cts +2 -2
  152. package/dist/ui/progress.d.mts +2 -2
  153. package/dist/ui/radio-group.d.cts +3 -3
  154. package/dist/ui/radio-group.d.mts +3 -3
  155. package/dist/ui/resizable.d.cts +9 -9
  156. package/dist/ui/resizable.d.mts +9 -9
  157. package/dist/ui/scroll-area.d.cts +3 -3
  158. package/dist/ui/scroll-area.d.mts +3 -3
  159. package/dist/ui/select.d.cts +9 -9
  160. package/dist/ui/select.d.mts +9 -9
  161. package/dist/ui/separator.d.cts +2 -2
  162. package/dist/ui/separator.d.mts +2 -2
  163. package/dist/ui/sheet.d.cts +9 -9
  164. package/dist/ui/sheet.d.mts +9 -9
  165. package/dist/ui/sidebar.cjs +1 -1
  166. package/dist/ui/sidebar.d.cts +26 -26
  167. package/dist/ui/sidebar.d.mts +28 -28
  168. package/dist/ui/sidebar.mjs +1 -1
  169. package/dist/ui/skeleton.d.cts +2 -2
  170. package/dist/ui/skeleton.d.mts +2 -2
  171. package/dist/ui/slider.d.cts +2 -2
  172. package/dist/ui/slider.d.mts +2 -2
  173. package/dist/ui/sonner.d.cts +2 -2
  174. package/dist/ui/sonner.d.mts +2 -2
  175. package/dist/ui/spinner.d.cts +2 -2
  176. package/dist/ui/spinner.d.mts +2 -2
  177. package/dist/ui/switch.d.cts +2 -2
  178. package/dist/ui/switch.d.mts +2 -2
  179. package/dist/ui/table.d.cts +9 -9
  180. package/dist/ui/table.d.mts +18 -18
  181. package/dist/ui/tabs.d.cts +5 -5
  182. package/dist/ui/tabs.d.mts +5 -5
  183. package/dist/ui/textarea.d.cts +2 -2
  184. package/dist/ui/textarea.d.mts +2 -2
  185. package/dist/ui/toggle-group.d.cts +3 -3
  186. package/dist/ui/toggle-group.d.mts +3 -3
  187. package/dist/ui/toggle.d.cts +2 -2
  188. package/dist/ui/toggle.d.mts +4 -4
  189. package/dist/ui/tooltip.d.cts +5 -5
  190. package/dist/ui/tooltip.d.mts +5 -5
  191. package/package.json +1 -1
  192. package/dist/button-6-3G2PiR.mjs +0 -2
  193. package/dist/button-6-3G2PiR.mjs.map +0 -1
  194. package/dist/button-D0WaocKO.cjs +0 -2
  195. package/dist/button-D0WaocKO.cjs.map +0 -1
@@ -1,2 +1,2 @@
1
- const e=require(`../../chunk-Bmb41Sf3.cjs`),t=require(`../../paragraph-B72bHMf7.cjs`);require(`../../button.variants-rdXrPUao.cjs`);const n=require(`../../button-D0WaocKO.cjs`),r=require(`../../flex-twCgWyx1.cjs`),i=require(`../../date-em5f7hCx.cjs`),a=require(`../../badge-cvLJyaCA.cjs`),o=require(`../../tooltip-DC6i1A25.cjs`),s=require(`../../avatar-aVxo69zP.cjs`),c=require(`../../separator-C3ip6sbh.cjs`),l=require(`../../dropdown-menu-BuyuU6uF.cjs`),u=require(`../../checkbox-C0fSWwmD.cjs`),d=require(`../../spinner-Chm_2fLr.cjs`),f=require(`../../resizable-mlGS6Zto.cjs`),p=require(`../../input-BFWWaN-v.cjs`);let m=require(`@customafk/react-toolkit/utils`),h=require(`react`),g=require(`react/jsx-runtime`),_=require(`lucide-react`),v=require(`@customafk/react-toolkit/color-hash`),y=require(`@tanstack/react-table`),b=require(`@tanstack/react-virtual`),x=require(`@customafk/react-toolkit/hooks/useDebounceCallback`);const S=()=>(0,g.jsxs)(`div`,{className:`flex gap-0 text-text-positive-weak`,children:[(0,g.jsx)(_.MinusIcon,{size:16}),(0,g.jsx)(_.MinusIcon,{size:16})]}),C=({label:e,onClick:t,onRemove:n})=>e?n?(0,g.jsxs)(`div`,{className:`flex w-fit gap-x-0.5 rounded-full border border-border py-1 pr-2 pl-3 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:[e,(0,g.jsx)(`button`,{className:`cursor-pointer text-text-positive-weak hover:text-text-positive-strong`,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.XIcon,{size:12})})]}):(0,g.jsx)(`button`,{className:`w-fit rounded-full border border-border px-3 py-1 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:e}):(0,g.jsx)(S,{}),w=({value:e})=>e==null?(0,g.jsx)(S,{}):e===!1?(0,g.jsx)(`div`,{className:`text-danger-strong`,children:(0,g.jsx)(_.XIcon,{})}):(0,g.jsx)(`div`,{className:`text-success-strong`,children:(0,g.jsx)(_.CheckIcon,{})}),ee=({date:e})=>e==null?(0,g.jsx)(S,{}):(0,g.jsx)(o.r,{children:(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{asChild:!0,children:(0,g.jsx)(a.t,{className:`h-fit`,children:(0,g.jsx)(i.t,{date:e,format:`medium`,className:`font-normal text-white`})})}),(0,g.jsx)(o.n,{className:`rounded px-2`,children:(0,g.jsx)(i.t,{date:e,format:`full`,showTime:!0,className:`font-medium text-text-negative text-xs`})})]})}),T=({content:e})=>e==null?(0,g.jsx)(S,{}):(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(t.t,{variant:`sm`,className:`line-clamp-2 whitespace-pre-line break-all`,children:e})}),(0,g.jsx)(o.n,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,g.jsx)(t.t,{variant:`xs`,className:`whitespace-pre-line text-wrap break-keep text-text-negative-weak`,children:e}),(0,g.jsxs)(`p`,{className:`w-full text-end`,children:[e.toString().length,` chars`]})]})})]}),E=({items:e=[]})=>(0,g.jsxs)(l.t,{children:[(0,g.jsx)(l.h,{asChild:!0,children:(0,g.jsx)(n.t,{size:`sm`,variant:`ghost`,color:`secondary`,className:`size-9 rounded-full`,children:(0,g.jsx)(_.MoreVerticalIcon,{})})}),(0,g.jsx)(l.r,{children:(0,g.jsx)(l.i,{children:e.map(e=>(0,g.jsx)(l.a,{className:`px-3`,onSelect:t=>{e.onClick(e.id),t.stopPropagation()},children:e.label},e.id))})})]}),D=({name:e})=>e?(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(t.t,{variant:`sm`,className:`line-clamp-2 w-full truncate text-wrap pb-px text-start`,children:e})}),(0,g.jsx)(o.n,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,g.jsx)(`p`,{className:`whitespace-pre-line text-wrap break-keep`,children:e}),(0,g.jsxs)(`p`,{className:`w-full text-end`,children:[e.length,` chars`]})]})})]}):(0,g.jsx)(S,{}),O=({href:e,label:t})=>(0,g.jsxs)(`a`,{href:e,target:`_blank`,className:`inline-flex items-center gap-1 truncate text-primary text-sm underline`,rel:`noopener noreferrer`,children:[(0,g.jsx)(`span`,{children:t||e}),(0,g.jsx)(_.ExternalLinkIcon,{size:14})]}),k=({value:e})=>(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{asChild:!0,children:(0,g.jsx)(`p`,{className:`font-number text-secondary-foreground text-sm tabular-nums`,children:e.replace(/(\d{3})(\d{3})(\d{4})/,`($1) $2-$3`)})}),(0,g.jsx)(o.n,{align:`start`,children:(0,g.jsx)(`p`,{className:`tabular-nums`,children:e.slice(1).replace(/(\d{2})(\d{3})(\d{4})/,`(00) (+84) ($1) $2-$3`)})})]}),A=({title:e,onClick:t})=>(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(n.t,{type:`button`,variant:`ghost`,color:`danger`,size:`icon`,onClick:(0,h.useCallback)(async e=>{e.preventDefault(),e.stopPropagation(),await t?.()},[t]),children:(0,g.jsx)(_.Trash2Icon,{})})}),(0,g.jsx)(o.n,{children:(0,g.jsx)(`p`,{children:e||`Remove item from list table`})})]}),j=(e,t,n)=>{let r=10**t;switch(n){case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:return Math.round(e*r)/r}},M=(0,h.memo)(({decimalSeparator:e=`.`,groupSeparator:t=`,`,prefix:n,suffix:i,precision:a,roundingMode:o=`round`,showTrailingZeros:s=!1,size:c=`lg`,value:l=0})=>{let u=(0,h.useMemo)(()=>{let e={};return typeof a==`number`&&a>=0&&s&&(e.minimumFractionDigits=a),e.maximumFractionDigits=a,e},[a,s]),d=(0,h.useCallback)(e=>{let t=e;return typeof a==`number`&&a>=0&&(t=j(e,a,o)),t.toLocaleString(`en-US`,u)},[o,u,a]),f=(0,h.useMemo)(()=>{if(typeof l==`number`)return Number.isNaN(l)||!Number.isFinite(l)?`N/A`:d(l);if(typeof l==`string`){let e=l.trim();if(!e)return`N/A`;let t=Number(e);return Number.isNaN(t)||!Number.isFinite(t)?`N/A`:d(t)}return`N/A`},[l,d]),p=(0,h.useMemo)(()=>e===`.`&&t===`,`?f:f.replace(/,/g,t).replace(/\./g,e),[f,e,t]);return p===`0`||p===`N/A`||!p?(0,g.jsx)(S,{}):(0,g.jsxs)(r.t,{padding:`none`,className:(0,m.cn)(`font-number text-lg text-secondary-foreground tabular-nums`,c===`xs`&&`text-xs`,c===`sm`&&`text-sm`,c===`md`&&`text-base`,c===`lg`&&`text-lg`,c===`xl`&&`text-xl`),children:[n,(0,g.jsx)(`p`,{children:p}),i]})});M.displayName=`UITableStatisticDisplay`;const N=({uuid:e,username:n,email:i})=>(0,g.jsxs)(r.t,{wrap:!1,gap:`sm`,padding:`none`,children:[!e&&(0,g.jsx)(s.t,{className:`size-10 shadow-card`,children:(0,g.jsx)(s.n,{className:`bg-muted-weak`,children:(0,g.jsx)(_.UserRoundIcon,{size:28,className:`text-text-negative`})})}),e&&(0,g.jsx)(s.t,{className:`size-10 shadow-card`,children:(0,g.jsx)(s.n,{style:{backgroundColor:v.colorHashLight.hex(e)},children:(0,g.jsx)(_.UserRoundIcon,{size:28,className:`text-white`})})}),(0,g.jsxs)(r.t,{vertical:!0,padding:`none`,gap:`none`,align:`start`,children:[(0,g.jsx)(t.t,{className:`font-medium text-sm text-text-positive-weak`,children:n??`Unknown User`}),(0,g.jsx)(t.t,{variant:`sm`,className:`mt-0! text-text-positive-weak text-xs`,children:i})]})]}),te=60,ne=60,re=20,ie=20,ae=(0,h.createContext)(null),oe=()=>{let e=(0,h.use)(ae);if(!e)throw Error(`useTableInnerWrapperContext must be used within a TableInnerWrapperProvider`);return e},se=(0,h.createContext)(null),ce=()=>{let e=(0,h.use)(se);if(!e)throw Error(`useTableInnerTableContext must be used within a TableInnerTableProvider`);return e},le=(0,h.createContext)(null),ue=()=>{let e=(0,h.use)(le);if(!e)throw Error(`useTableHeaderRowContext must be used within a TableHeaderRowProvider`);return e},de=(0,h.createContext)(null),fe=()=>{let e=(0,h.use)(de);if(!e)throw Error(`useTableBodyContext must be used within a TableBodyProvider`);return e},pe=(0,h.createContext)(null),me=()=>{let e=(0,h.use)(pe);if(!e)throw Error(`useTableRowContext must be used within a TableRowProvider`);return e},P=(0,h.createContext)(null),F=()=>{let e=(0,h.use)(P);if(!e)throw Error(`useTableContext must be used within a TableProvider`);return e},I=(0,h.memo)(({isPinned:e,onLeftPin:t,onRightPin:n,onUnpin:r,className:i})=>{let a=(0,h.useCallback)(()=>{t?.(`left`)},[t]),o=(0,h.useCallback)(()=>{n?.(`right`)},[n]),s=(0,h.useCallback)(()=>{r?.(!1)},[r]);return(0,g.jsxs)(l.t,{children:[(0,g.jsx)(l.h,{asChild:!0,children:(0,g.jsx)(`button`,{className:(0,m.cn)(`absolute right-2 z-10 p-0.5 opacity-0`,`cursor-pointer rounded-full transition-all`,`text-text-positive-weak`,`[&>svg]:size-4`,`group-hover:opacity-100`,`hover:bg-muted-muted hover:text-text-positive`,i),children:(0,g.jsx)(_.EllipsisVerticalIcon,{})})}),(0,g.jsx)(l.r,{align:`end`,className:`w-64 p-4`,children:(0,g.jsxs)(l.i,{className:`*:data-[slot=dropdown-menu-item]:rounded-xs *:data-[slot=dropdown-menu-item]:p-2`,children:[(0,g.jsx)(h.Activity,{mode:e?`visible`:`hidden`,children:(0,g.jsxs)(l.a,{onClick:s,children:[!!e&&`Unpin`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.PinOffIcon,{className:`size-4`})})]})}),(0,g.jsxs)(h.Activity,{mode:e?`hidden`:`visible`,children:[(0,g.jsxs)(l.a,{onClick:a,children:[e?`Unpin`:`Pin to Left`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.MoveLeftIcon,{className:`size-4`})})]}),(0,g.jsxs)(l.a,{onClick:o,children:[e?`Unpin`:`Pin to Right`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.MoveRightIcon,{className:`size-4`})})]})]})]})})]})});I.displayName=`UITableHeadCellOption`;const L=(0,h.memo)(({isPinned:e,isAllRowsSelected:t,style:n,onToggleAllRowsSelected:r,...i})=>{let a=(0,h.useCallback)(e=>{r?.(!!e)},[r]);return(0,g.jsx)(`th`,{slot:`table-header-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:(0,m.cn)(e?`sticky`:`relative`),...i,children:(0,g.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:(0,g.jsx)(u.t,{"aria-label":`Select All Rows`,checked:t,onCheckedChange:a})})})});L.displayName=`UITableHeadCellSelect`;const R=(0,h.memo)(({isEmpty:e,isFetching:t})=>!e&&!t?null:(0,g.jsxs)(`div`,{className:`sticky left-0 flex min-h-96 flex-1 items-center justify-center bg-transparent text-text-positive-weak opacity-100`,children:[t&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,g.jsx)(d.t,{className:`size-12`}),(0,g.jsx)(`p`,{children:`Loading data...`})]}),e&&!t&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,g.jsx)(_.BoxIcon,{strokeWidth:1,size:48}),(0,g.jsx)(`p`,{children:`No data available`})]})]}));R.displayName=`UITableEmptyDisplay`;const z=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`div`,{slot:`table-wrapper`,className:(0,m.cn)(`relative m-0 flex size-full flex-col flex-nowrap items-start justify-start gap-2`,e),...n,children:t}));z.displayName=`UITableWrapper`;const B=(0,h.memo)(({children:e,...t})=>{let{innerWrapperId:n}=oe();return(0,g.jsx)(`div`,{id:n,slot:`table-inner-wrapper`,className:`relative size-full overflow-auto border-b border-b-border border-l border-l-border bg-card`,...t,children:e})});B.displayName=`UITableInnerWrapper`;const V=(0,h.memo)(({children:e,...t})=>{let{table:n,innerTableId:r,totalSize:i}=ce(),a=(0,h.useRef)(null);return(0,h.useEffect)(()=>{if(!a.current)return;let e=n.getFlatHeaders(),t=new ResizeObserver(t=>{requestAnimationFrame(()=>{let r=t[0].target;if(r instanceof HTMLTableElement){let i=t[0];if(!i)return;let a=i.contentRect.width,{left:o=[],right:s=[]}=n.getState().columnPinning,c=0,l=0,u=0,d=e.map(e=>{let{id:t}=e,n=t===`select`||t===`actions`,r=o.includes(t)||s.includes(t),i=e.getSize(),a=e.column.columnDef.maxSize;return n?(c+=60,{id:t,isFlex:!1,width:60}):r?(c+=i,{id:t,isFlex:!1,width:i}):e.column.columnDef.size||i!==150?(u+=i,{id:t,isFlex:!1,width:i}):(l++,{id:t,isFlex:!0,maxSize:a})}),f=a-c-u,p=l>0?Math.max(0,Math.floor(f/l)):0;d.forEach(e=>{if(e.isFlex){let t=e.maxSize?Math.min(p,e.maxSize):p;r.style.setProperty(`--header-${e.id}-size`,`${t}`),r.style.setProperty(`--col-${e.id}-size`,`${t}`),e.maxSize&&r.style.setProperty(`--col-${e.id}-maxSize`,`${e.maxSize}`)}else r.style.setProperty(`--header-${e.id}-size`,`${e.width}`),r.style.setProperty(`--col-${e.id}-size`,`${e.width}`)})}})});return t.observe(a.current),()=>t.disconnect()},[n.getState().columnSizingInfo,n.getState().columnSizing,n.getState().columnPinning]),(0,g.jsx)(`table`,{id:r,ref:a,slot:`table-inner-table`,className:`grid w-full table-fixed caption-bottom border-collapse border-spacing-0 flex-col content-start [&_tfoot_td]:border-t`,style:{minWidth:i},...t,children:e})});V.displayName=`UITableInnerTable`;const H=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`thead`,{slot:`table-head`,className:(0,m.cn)(`sticky top-0 z-20 h-9 w-full`,`grid select-none bg-muted-bg-subtle`,`border-b border-b-border shadow`,`font-medium text-[13px] text-text-positive-weak`,`[&_tr:not(:last-child)_td]:border-b`,`[&_th]:inline-flex`,`[&_th]:items-center`,`[&_th]:transition-all`,`[&_th]:duration-300`,`[&_th]:whitespace-nowrap`,`[&_th]:border-border`,`[&_th]:last:border-r-0`,`[&_th]:first:border-l-0`,`[&_tr_th:not([data-pinned=false])]:bg-muted-bg-subtle`,e),...n,children:t}));H.displayName=`UITableHead`;const U=(0,h.memo)(({headerGroup:e,className:t,...n})=>{let{isAllRowsSelected:r,columnPinningState:i,leftPinnedHeaders:a,rightPinnedHeaders:o,onToggleAllRowsSelected:s}=ue(),c=o[0]?.id,l=a[a.length-1]?.id;return(0,g.jsx)(`tr`,{slot:`table-head-row`,className:(0,m.cn)(`flex`,t),...n,children:e.headers.map((e,t)=>{let n=e.column.getIsVisible(),a=i.left?.includes(e.id)?`left`:i.right?.includes(e.id)?`right`:!1;return e.id===`select`?(0,g.jsx)(L,{isPinned:a,isAllRowsSelected:r,onToggleAllRowsSelected:s},e.id):(0,g.jsx)(W,{isVisible:n,isPinned:a,isFirstCell:e.id===c,isLastCell:e.id===l,isOptionsVisible:![`select`,`actions`].includes(e.id),headerId:e.id,headerColumn:e.column,colSpan:e.colSpan,onColumnPin:e.column.pin,onToggleVisibility:e.column.toggleVisibility,children:(0,y.flexRender)(e.column.columnDef.header,e.getContext())},`${e.id}-${t}`)})})});U.displayName=`UITableHeadRow`;const W=(0,h.memo)(({isVisible:e=!0,isPinned:t=!1,isFirstCell:n=!1,isLastCell:r=!1,isOptionsVisible:i=!0,headerId:a,headerColumn:o,className:s,children:c,onColumnPin:l,onToggleVisibility:u,...d})=>{let f=(0,h.useMemo)(()=>t?20:void 0,[t]),p=(0,h.useMemo)(()=>{let e=o?.getStart?.(`left`);return t===`left`&&typeof e==`number`?`${e}px`:void 0},[t,o]),_=(0,h.useMemo)(()=>{let e=o?.getAfter?.(`right`);return t===`right`&&typeof e==`number`?`${e}px`:void 0},[t,o]),v=(0,h.useMemo)(()=>`calc(var(--header-${a}-size) * 1px)`,[a]),y=(0,h.useMemo)(()=>o?.columnDef.minSize?`calc(var(--col-${a}-minSize) * 1px)`:void 0,[a,o]),b=(0,h.useMemo)(()=>o?.columnDef.maxSize?`calc(var(--col-${a}-maxSize) * 1px)`:void 0,[a,o]);return(0,g.jsxs)(`th`,{slot:`table-head-cell`,"data-pinned":t,"data-header":a,style:{zIndex:f,left:p,right:_,width:v,minWidth:y,maxWidth:b},className:(0,m.cn)(`group flex`,t?`sticky`:`relative`,t===`left`&&r&&`border-r border-r-border`,t===`right`&&n&&`border-l border-l-border`,o?.columnDef.meta?.position===`center`&&`justify-center`,o?.columnDef.meta?.position===`end`&&`justify-end`,o?.columnDef.meta?.position===`start`&&`justify-start`,s),...d,children:[(0,g.jsx)(`div`,{className:`truncate pl-4`,children:c}),i&&(0,g.jsx)(I,{isPinned:t,isVisible:e,onLeftPin:l,onRightPin:l,onUnpin:l})]})});W.displayName=`UITableHeadCell`;const G=(0,h.memo)(({height:e,className:t,children:n,...r})=>{let{isFetching:i,isEmpty:a}=fe();return a||i?null:(0,g.jsx)(`tbody`,{slot:`table-body`,style:{height:e},className:(0,m.cn)(`relative w-full`,`grid`,`[&_tr]:absolute`,`[&_tr]:flex`,`[&_tr]:flex-none`,`[&_tr]:w-full`,`[&_tr]:cursor-pointer [&_tr]:focus:outline-none`,`[&_tr]:border-b [&_tr]:border-b-border`,`[&_td]:z-10`,`[&_td]:transition-all`,`[&_td]:duration-300`,`[&_td]:flex`,`[&_td]:flex-none`,`[&_td]:overflow-hidden`,`[&_td]:whitespace-nowrap`,`[&_td]:px-4`,`[&_td]:py-2.5`,`[&_td]:align-middle`,`[&_td]:border-border`,`[&_td]:data-[selected=true]:bg-muted-muted!`,`[&_td]:data-[selected=true]:hover:bg-muted-muted!`,`[&_td>div]:inline-flex`,`[&_td>div]:items-center`,`[&_td>div]:w-full`,`[&_td:not([data-pinned=false])]:z-20`,`[&_td:not([data-pinned=false])]:sticky`,`[&_td:not([data-pinned=false])]:bg-card`,`**:data-lastcell:border-r`,`**:data-firstcell:border-l`,t),...r,children:n})});G.displayName=`UITableBody`;const K=(0,h.memo)(({row:e,isSelected:t,virtualRowIndex:n,virtualRowStart:r,children:i,...a})=>{let{keyOfClickRow:o,isAllRowsSelected:s,columnPinningState:c,leftPinnedHeaders:l,rightPinnedHeaders:u,onClickRow:d}=me(),f=(0,h.useMemo)(()=>c.left??[],[c]),p=(0,h.useMemo)(()=>c.right??[],[c]),m=(0,h.useMemo)(()=>u?.[0]?.id,[u]),_=(0,h.useMemo)(()=>l?.[l.length-1]?.id,[l]),v=(0,h.useCallback)(t=>{let r=o?e.original?.[o]:void 0;d?.(n,typeof r==`string`||typeof r==`number`?r:void 0),t.preventDefault(),t.stopPropagation()},[o,d,e,n]);return(0,g.jsx)(`tr`,{slot:`table-row`,"data-index":n,style:{transform:`translateY(${r}px)`},className:`group`,onClick:v,...a,children:e.getVisibleCells().map((e,r)=>{let i=f.includes(e.column.id),a=p.includes(e.column.id),o=i?`left`:a?`right`:!1;return e.column.id===`actions`?(0,g.jsx)(J,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,virtualRowIndex:n,column:e.column,getContext:e.getContext},`${e.id}-${r}`):e.column.id===`select`?(0,g.jsx)(q,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isSelected:s||t,onToggleRowSelected:e.row.toggleSelected},`${e.id}-${r}`):(0,g.jsx)(Y,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isFirstCell:e.column.id===m,isLastCell:e.column.id===_,colId:e.column.id,position:e.column.columnDef.meta?.position??`start`,column:e.column,getContext:e.getContext},`${e.id}-${r}`)})})});K.displayName=`UITableRow`;const q=(0,h.memo)(({isPinned:e,isSelected:t=!1,className:n,onToggleRowSelected:r,...i})=>{let a=(0,h.useCallback)(e=>{r?.(!!e)},[r]);return(0,g.jsx)(`td`,{slot:`table-body-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:(0,m.cn)(`group-hover:bg-muted-bg-subtle!`,e?`sticky`:`relative`,n),...i,children:(0,g.jsx)(`div`,{"data-slot":`table-cell-inner`,className:`flex! w-full! items-center justify-center bg-transparent text-center align-middle`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:(0,g.jsx)(u.t,{"aria-label":`Select Row`,checked:t,onCheckedChange:a})})})});q.displayName=`UITableCellSelect`;const J=(0,h.memo)(({virtualRowIndex:e,column:t,getContext:n,className:r,...i})=>{let a=(0,h.useMemo)(()=>(0,y.flexRender)(t?.columnDef.cell,n()),[t,n]);return(0,g.jsx)(`td`,{"data-col":`actions`,"data-cell":e,className:`sticky inset-y-0 right-0 z-50 flex items-center pr-4 group-hover:bg-muted-bg-subtle!`,...i,children:a})});J.displayName=`UITableCellActions`;const Y=(0,h.memo)(({isPinned:e=!1,isFirstCell:t=!1,isLastCell:n=!1,colId:r,position:i=`start`,column:a,getContext:o,...s})=>{let{innerTableId:c,table:l}=ce(),u=(0,h.useRef)(document.querySelector(`table[id="${c}"]`)),d=(0,h.useRef)(null),f=(0,h.useMemo)(()=>{let t=a?.getStart(`left`);return e===`left`&&typeof t==`number`?`${t}px`:void 0},[e,a]),p=(0,h.useMemo)(()=>{let t=a?.getAfter(`right`);return e===`right`&&typeof t==`number`?`${t}px`:void 0},[e,a]),_=(0,h.useMemo)(()=>`calc(var(--col-${r}-size) * 1px)`,[r]),v=(0,h.useMemo)(()=>a?.columnDef.minSize?`calc(var(--col-${r}-minSize) * 1px)`:void 0,[r,a]),b=(0,h.useMemo)(()=>a?.columnDef.maxSize?`calc(var(--col-${r}-maxSize) * 1px)`:void 0,[r,a]),x=(0,h.useMemo)(()=>(0,y.flexRender)(a?.columnDef.cell,o()),[a,o]);return(0,h.useEffect)(()=>{if(!d.current)return;let e=d.current.scrollWidth,t=a?.getSize();t&&e>t&&u.current instanceof HTMLTableElement&&typeof r==`string`&&a?.columnDef.meta?.fitContent&&l.setColumnSizing(t=>({...t,[r]:e+32}))},[r,a,l]),(0,g.jsx)(`td`,{slot:`table-body-cell`,"data-pinned":e,"data-lastcell":n||void 0,"data-firstcell":t||void 0,style:{left:f,right:p,width:_,minWidth:v,maxWidth:b},className:`group-hover:bg-muted-bg-subtle!`,...s,children:(0,g.jsx)(`div`,{ref:d,slot:`table-body-cell-inner`,className:(0,m.cn)(i===`start`&&`justify-start`,i===`center`&&`justify-center`,i===`end`&&`justify-end`),children:x})})});Y.displayName=`UITableCell`;const he=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`tfoot`,{slot:`table-footer`,className:(0,m.cn)(`flex w-full justify-center border-border-weak border-t py-2 font-medium [&>tr]:last:border-b-0`,e),...n,children:t}));he.displayName=`UITableFooter`;const X=(0,h.memo)(({virtualRowIndex:e,virtualRowStart:t,fetchMoreData:n})=>{let{innerWrapperId:r}=oe(),i=(0,h.useRef)(document.querySelector(`div[id="${r}"]`)),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(`idle`),[c,l]=(0,h.useState)(0),u=(0,h.useCallback)(async()=>{try{s(`fetching`),await n?.(),s(`idle`)}catch(e){console.error(`Error fetching more data:`,e),s(`error`)}},[n]);return(0,h.useEffect)(()=>{if(!i.current)return;let e=new ResizeObserver(e=>{l(e[0].contentRect.width)});return e.observe(i.current),()=>e.disconnect()},[]),n?(0,g.jsx)(`tr`,{ref:a,"data-index":e,style:{transform:`translateY(${t}px)`,width:c},className:`sticky! left-0 h-10`,children:(0,g.jsx)(`td`,{className:`absolute left-0 flex w-full items-center justify-center text-xs`,children:(0,g.jsxs)(`button`,{type:`button`,disabled:o===`fetching`,className:(0,m.cn)(`flex cursor-pointer gap-x-0.5`,o===`fetching`&&`cursor-not-allowed`,o===`idle`&&`text-text-positive-weak hover:text-text-positive`,o===`error`&&`text-danger hover:text-danger-strong`),onClick:u,children:[o===`idle`&&(0,g.jsx)(_.ChevronDown,{className:`size-4`}),o===`fetching`&&(0,g.jsx)(d.t,{className:`size-4 animate-spin`}),o===`error`&&(0,g.jsx)(_.AlertTriangle,{className:`size-4 text-danger`}),o===`idle`&&`Load More`,o===`fetching`&&`Loading...`,o===`error`&&`Error! Retry?`]})})}):null});X.displayName=`UITableLoadMore`;const ge=()=>{let{table:e,isEmpty:t,isFetching:n,fetchMoreData:r}=F(),{rowSelectionState:i}=fe(),a=(0,h.useRef)(null),{rows:o}=e.getRowModel(),s=(0,b.useVirtualizer)({count:o.length+1,estimateSize:()=>40,getScrollElement:()=>a.current,measureElement:typeof window<`u`&&navigator.userAgent.indexOf(`Firefox`)===-1?e=>e?.getBoundingClientRect().height:void 0,overscan:2}),c=(0,h.useMemo)(()=>{let e=s.getTotalSize(),t=a.current?.clientHeight||0;return e<t?`${t}px`:`${e}px`},[s.getTotalSize()]);return(0,g.jsx)(f.r,{direction:`horizontal`,style:{direction:e.options.columnResizeDirection},className:`relative flex w-full max-w-full flex-1 gap-1 overflow-auto border-t border-t-border border-r border-r-border bg-slate-50 p-0 text-sm`,children:(0,g.jsx)(f.n,{className:`relative`,children:(0,g.jsxs)(B,{ref:a,children:[(0,g.jsxs)(V,{children:[(0,g.jsx)(H,{children:e.getHeaderGroups().map(e=>(0,g.jsx)(U,{headerGroup:e},e.id))}),(0,g.jsx)(G,{height:c,children:s.getVirtualItems().map(e=>{let t=o[e.index],n=Object.entries(i).some(([e,n])=>e===`${t?.id}`&&n);return t?(0,g.jsx)(K,{ref:s.measureElement,row:t,isSelected:n,virtualRowIndex:e.index,virtualRowStart:e.start},e.index):(0,g.jsx)(X,{virtualRowIndex:e.index,virtualRowStart:e.start,fetchMoreData:r},e.index)})})]}),(0,g.jsx)(R,{isEmpty:t,isFetching:n})]})})})},_e=({checked:e,title:t,onCheckedChange:n})=>(0,g.jsxs)(`div`,{className:`flex h-fit items-center gap-2`,children:[(0,g.jsx)(u.t,{checked:e,onCheckedChange:n}),(0,g.jsx)(`p`,{className:`text-sm`,children:t})]}),ve=()=>{let{table:e}=F(),[t,r]=(0,h.useState)(null);return(0,g.jsx)(f.n,{defaultSize:25,className:(0,m.cn)(`bg-card`,t===null?`max-w-8!`:`min-w-64`),children:(0,g.jsxs)(`div`,{className:`relative z-20 flex size-full bg-muted-bg-subtle`,children:[(0,g.jsxs)(`div`,{className:`flex-1`,children:[(0,g.jsx)(h.Activity,{mode:t===`columns`?`visible`:`hidden`,children:(0,g.jsxs)(`div`,{className:`flex size-full flex-col gap-2 p-4`,children:[(0,g.jsx)(`p`,{className:`px-2 font-medium`,children:`Columns Visibility`}),(0,g.jsx)(c.t,{}),(0,g.jsx)(`div`,{className:`flex flex-col gap-4 pt-4`,children:e.getAllColumns().map(e=>[`select`,`actions`].includes(e.id)?null:(0,g.jsx)(_e,{checked:e.getIsVisible(),title:String(e.columnDef.header),onCheckedChange:t=>e.toggleVisibility(!!t)},e.id))})]})}),(0,g.jsx)(h.Activity,{mode:t===`filters`?`visible`:`hidden`,children:(0,g.jsx)(`div`,{className:`flex size-full flex-col p-2`,children:(0,g.jsxs)(n.t,{variant:`outline`,color:`muted`,children:[(0,g.jsx)(_.ListFilterPlus,{}),`Add Filter`]})})})]}),(0,g.jsxs)(`div`,{className:`flex h-full flex-col border-border border-l bg-muted-bg-subtle text-sm`,children:[(0,g.jsxs)(`button`,{className:(0,m.cn)(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,t===`columns`&&`bg-card`),onClick:()=>r(t===`columns`?null:`columns`),children:[(0,g.jsx)(_.Columns4Icon,{size:18}),(0,g.jsx)(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Columns`})]}),(0,g.jsx)(c.t,{}),(0,g.jsxs)(`button`,{className:(0,m.cn)(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,t===`filters`&&`bg-card`),onClick:()=>r(t===`filters`?null:`filters`),children:[(0,g.jsx)(_.ListFilterIcon,{size:18}),(0,g.jsx)(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Filters`})]}),(0,g.jsx)(c.t,{})]})]})})},ye=(0,h.memo)(({innerWrapperId:e,children:t})=>{let n=(0,h.useMemo)(()=>({innerWrapperId:e}),[e]);return(0,g.jsx)(ae.Provider,{value:n,children:t})});ye.displayName=`UITableInnerWrapperProvider`;const be=(0,h.memo)(({table:e,innerTableId:t,totalSize:n,children:r})=>{let i=(0,h.useMemo)(()=>({table:e,innerTableId:t,totalSize:n}),[e,t,n]);return(0,g.jsx)(se.Provider,{value:i,children:r})});be.displayName=`UITableInnerTableProvider`;const xe=(0,h.memo)(({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i,children:a})=>{let o=(0,h.useMemo)(()=>({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i}),[e,t,n,r,i]);return(0,g.jsx)(le.Provider,{value:o,children:a})});xe.displayName=`UITableHeadRowProvider`;const Se=(0,h.memo)(({isFetching:e,isEmpty:t,rowSelectionState:n,children:r})=>{let i=(0,h.useMemo)(()=>({isFetching:e,isEmpty:t,rowSelectionState:n}),[e,t,n]);return(0,g.jsx)(de.Provider,{value:i,children:r})});Se.displayName=`UITableBodyProvider`;const Z=(0,h.memo)(({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a,children:o})=>{let s=(0,h.useMemo)(()=>({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a}),[e,t,n,r,i,a]);return(0,g.jsx)(pe.Provider,{value:s,children:o})});Z.displayName=`UITableRowProvider`;const Ce=({title:e,isFetching:t=!1,isRefetching:n=!1,data:r,columns:i,totalRows:a,leftPinnedColumns:o=[],rightPinnedColumns:s=[],keyOfClickRow:c,onClickRow:l,onRowSelection:u,onColumnPinning:d,fetchMoreData:f,children:p})=>{let m=(0,h.useId)(),_=(0,h.useId)(),[v,b]=(0,h.useState)({}),[x,S]=(0,h.useState)({right:s,left:[`select`,...o]}),[C,w]=(0,h.useState)({}),ee=(0,h.useCallback)(e=>(b(e),u?.(e instanceof Function?e(v):e),e),[v,u]),T=(0,h.useCallback)(e=>{S(e),d?.(e instanceof Function?e(x):e)},[x,d]),E=(0,y.useReactTable)({data:r,columns:i,state:{rowSelection:v,columnPinning:x,expanded:C},defaultColumn:{enableResizing:!1,size:void 0,minSize:void 0,maxSize:void 0},columnResizeMode:`onChange`,columnResizeDirection:`ltr`,enableColumnPinning:!0,enableRowSelection:!0,enableColumnResizing:!0,enableMultiRowSelection:!0,autoResetAll:!1,autoResetExpanded:!1,autoResetPageIndex:!1,getSubRows:e=>e.subRows,getCoreRowModel:(0,y.getCoreRowModel)(),getGroupedRowModel:(0,y.getGroupedRowModel)(),getExpandedRowModel:(0,y.getExpandedRowModel)(),onRowSelectionChange:ee,onColumnPinningChange:T,onExpandedChange:w}),D=(0,h.useMemo)(()=>{let{rows:e}=E.getRowModel();return e},[E.getRowModel().rows,E.getState().columnPinning]),O=(0,h.useMemo)(()=>!t&&D.length===0,[D,t]),k=(0,h.useMemo)(()=>({title:e,table:E,isEmpty:O,isFetching:t,isRefetching:n,totalRows:a,fetchMoreData:f}),[e,E,O,n,t,a,f,E.getState().columnPinning,E.getState().expanded]),A=(0,h.useMemo)(()=>E.getState(),[E.getState()]),j=(0,h.useMemo)(()=>E.getIsAllRowsSelected(),[E.getIsAllRowsSelected()]),M=(0,h.useMemo)(()=>A.rowSelection,[A.rowSelection]),N=(0,h.useMemo)(()=>A.columnPinning,[A.columnPinning]),te=(0,h.useMemo)(()=>E.getLeftHeaderGroups()[0]?.headers||[],[E.getState().columnPinning]),ne=(0,h.useMemo)(()=>E.getRightHeaderGroups()[0]?.headers||[],[E.getState().columnPinning]),re=(0,h.useMemo)(()=>E.getTotalSize(),[E.getTotalSize()]);return(0,g.jsx)(P.Provider,{value:k,children:(0,g.jsx)(ye,{innerWrapperId:m,children:(0,g.jsx)(be,{table:E,innerTableId:_,totalSize:re,children:(0,g.jsx)(xe,{isAllRowsSelected:j,columnPinningState:N,leftPinnedHeaders:te,rightPinnedHeaders:ne,onToggleAllRowsSelected:E.toggleAllRowsSelected,children:(0,g.jsx)(Se,{isFetching:t,isEmpty:O,rowSelectionState:M,children:(0,g.jsx)(Z,{keyOfClickRow:c,isAllRowsSelected:j,columnPinningState:N,leftPinnedHeaders:te,rightPinnedHeaders:ne,onClickRow:l,children:p})})})})})})},we=({onSearch:e,onChange:t,...n})=>{let r=(0,x.useDebounceCallback)(t=>{e?.(t)},500);return(0,g.jsxs)(`div`,{className:`relative w-full max-w-80 flex-1`,children:[(0,g.jsx)(p.t,{...n,size:`lg`,type:`search`,placeholder:`Search records...`,className:`flex-1 ps-9 pe-9`,onChange:e=>{t?.(e),r(e.target.value??``)}}),(0,g.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-text-positive-weak peer-disabled:opacity-50`,children:(0,g.jsx)(_.SearchIcon,{size:16})}),(0,g.jsx)(`button`,{className:`absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:z-10 focus-visible:border focus-visible:border-primary-strong focus-visible:ring-[3px] focus-visible:ring-primary-weak disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Submit search`,type:`submit`,children:(0,g.jsx)(_.ArrowRightIcon,{size:16,"aria-hidden":`true`})})]})},Q=({children:e,disabled:t,onClick:n})=>(0,g.jsx)(`button`,{type:`button`,disabled:t,className:`flex cursor-pointer items-center gap-x-1 rounded-sm border border-border bg-background p-2.5 text-sm text-text-positive-weak outline-none transition-all hover:shadow-card focus:border-border-emphasis focus:bg-muted-muted active:border-border-emphasis active:bg-muted-muted active:text-text-positive disabled:pointer-events-none disabled:cursor-default disabled:opacity-60 [&_svg]:size-3.5`,onClick:n,children:e}),Te=({onCreate:e,onDownload:t,onRefresh:n})=>(0,g.jsxs)(`div`,{className:`flex [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,children:[(0,g.jsx)(Q,{disabled:!e,onClick:t=>{e?.(),t.stopPropagation(),t.preventDefault()},children:(0,g.jsx)(_.CirclePlus,{})}),(0,g.jsx)(Q,{disabled:!n,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.RefreshCwIcon,{})}),(0,g.jsx)(Q,{disabled:!t,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.DownloadIcon,{})})]}),$=({children:e})=>{let{title:t}=F();return(0,g.jsxs)(`div`,{"data-slot":`table-tooltip`,className:`relative m-0 flex w-full flex-0 flex-col flex-wrap items-start space-y-2 p-0 px-2 text-sm`,children:[(0,g.jsx)(`h3`,{className:`font-semibold text-base text-text-positive`,children:t}),(0,g.jsx)(`div`,{className:`flex w-full flex-1 justify-between gap-x-2`,children:e})]})};$.displayName=`TableTooltip`,exports.UITableBadgeDisplay=C,exports.UITableBody=G,exports.UITableBooleanDisplay=w,exports.UITableCell=Y,exports.UITableCellActions=J,exports.UITableCellSelect=q,exports.UITableContainer=ge,exports.UITableDateDisplay=ee,exports.UITableDescriptionDisplay=T,exports.UITableEmptyDisplay=R,exports.UITableFilter=ve,exports.UITableFooter=he,exports.UITableHead=H,exports.UITableHeadCell=W,exports.UITableHeadCellOption=I,exports.UITableHeadCellSelect=L,exports.UITableHeadRow=U,exports.UITableInnerTable=V,exports.UITableInnerWrapper=B,exports.UITableLoadMore=X,exports.UITableMoreButton=E,exports.UITableNameDisplay=D,exports.UITablePermalink=O,exports.UITablePhoneNumberDisplay=k,exports.UITableProvider=Ce,exports.UITableRemoveButton=A,exports.UITableRow=K,exports.UITableStatisticDisplay=M,exports.UITableTooltip=$,exports.UITableTooltipActions=Te,exports.UITableTooltipFilter=we,exports.UITableUserDataDisplay=N,exports.UITableWrapper=z;
1
+ const e=require(`../../chunk-Bmb41Sf3.cjs`),t=require(`../../paragraph-B72bHMf7.cjs`);require(`../../button.variants-rdXrPUao.cjs`);const n=require(`../../button-CYw2AqT0.cjs`),r=require(`../../flex-twCgWyx1.cjs`),i=require(`../../date-em5f7hCx.cjs`),a=require(`../../badge-cvLJyaCA.cjs`),o=require(`../../tooltip-DC6i1A25.cjs`),s=require(`../../avatar-aVxo69zP.cjs`),c=require(`../../separator-C3ip6sbh.cjs`),l=require(`../../dropdown-menu-BuyuU6uF.cjs`),u=require(`../../checkbox-C0fSWwmD.cjs`),d=require(`../../spinner-Chm_2fLr.cjs`),f=require(`../../resizable-mlGS6Zto.cjs`),p=require(`../../input-BFWWaN-v.cjs`);let m=require(`@customafk/react-toolkit/utils`),h=require(`react`),g=require(`react/jsx-runtime`),_=require(`lucide-react`),v=require(`@customafk/react-toolkit/color-hash`),y=require(`@tanstack/react-table`),b=require(`@tanstack/react-virtual`),x=require(`@customafk/react-toolkit/hooks/useDebounceCallback`);const S=()=>(0,g.jsxs)(`div`,{className:`flex gap-0 text-text-positive-weak`,children:[(0,g.jsx)(_.MinusIcon,{size:16}),(0,g.jsx)(_.MinusIcon,{size:16})]}),C=({label:e,onClick:t,onRemove:n})=>e?n?(0,g.jsxs)(`div`,{className:`flex w-fit gap-x-0.5 rounded-full border border-border py-1 pr-2 pl-3 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:[e,(0,g.jsx)(`button`,{className:`cursor-pointer text-text-positive-weak hover:text-text-positive-strong`,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.XIcon,{size:12})})]}):(0,g.jsx)(`button`,{className:`w-fit rounded-full border border-border px-3 py-1 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:e}):(0,g.jsx)(S,{}),w=({value:e})=>e==null?(0,g.jsx)(S,{}):e===!1?(0,g.jsx)(`div`,{className:`text-danger-strong`,children:(0,g.jsx)(_.XIcon,{})}):(0,g.jsx)(`div`,{className:`text-success-strong`,children:(0,g.jsx)(_.CheckIcon,{})}),ee=({date:e})=>e==null?(0,g.jsx)(S,{}):(0,g.jsx)(o.r,{children:(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{asChild:!0,children:(0,g.jsx)(a.t,{className:`h-fit`,children:(0,g.jsx)(i.t,{date:e,format:`medium`,className:`font-normal text-white`})})}),(0,g.jsx)(o.n,{className:`rounded px-2`,children:(0,g.jsx)(i.t,{date:e,format:`full`,showTime:!0,className:`font-medium text-text-negative text-xs`})})]})}),T=({content:e})=>e==null?(0,g.jsx)(S,{}):(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(t.t,{variant:`sm`,className:`line-clamp-2 whitespace-pre-line break-all`,children:e})}),(0,g.jsx)(o.n,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,g.jsx)(t.t,{variant:`xs`,className:`whitespace-pre-line text-wrap break-keep text-text-negative-weak`,children:e}),(0,g.jsxs)(`p`,{className:`w-full text-end`,children:[e.toString().length,` chars`]})]})})]}),E=({items:e=[]})=>(0,g.jsxs)(l.t,{children:[(0,g.jsx)(l.h,{asChild:!0,children:(0,g.jsx)(n.t,{size:`sm`,variant:`ghost`,color:`secondary`,className:`size-9 rounded-full`,children:(0,g.jsx)(_.MoreVerticalIcon,{})})}),(0,g.jsx)(l.r,{children:(0,g.jsx)(l.i,{children:e.map(e=>(0,g.jsx)(l.a,{className:`px-3`,onSelect:t=>{e.onClick(e.id),t.stopPropagation()},children:e.label},e.id))})})]}),D=({name:e})=>e?(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(t.t,{variant:`sm`,className:`line-clamp-2 w-full truncate text-wrap pb-px text-start`,children:e})}),(0,g.jsx)(o.n,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:(0,g.jsxs)(`div`,{className:`flex flex-col gap-y-2`,children:[(0,g.jsx)(`p`,{className:`whitespace-pre-line text-wrap break-keep`,children:e}),(0,g.jsxs)(`p`,{className:`w-full text-end`,children:[e.length,` chars`]})]})})]}):(0,g.jsx)(S,{}),O=({href:e,label:t})=>(0,g.jsxs)(`a`,{href:e,target:`_blank`,className:`inline-flex items-center gap-1 truncate text-primary text-sm underline`,rel:`noopener noreferrer`,children:[(0,g.jsx)(`span`,{children:t||e}),(0,g.jsx)(_.ExternalLinkIcon,{size:14})]}),k=({value:e})=>(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{asChild:!0,children:(0,g.jsx)(`p`,{className:`font-number text-secondary-foreground text-sm tabular-nums`,children:e.replace(/(\d{3})(\d{3})(\d{4})/,`($1) $2-$3`)})}),(0,g.jsx)(o.n,{align:`start`,children:(0,g.jsx)(`p`,{className:`tabular-nums`,children:e.slice(1).replace(/(\d{2})(\d{3})(\d{4})/,`(00) (+84) ($1) $2-$3`)})})]}),A=({title:e,onClick:t})=>(0,g.jsxs)(o.t,{children:[(0,g.jsx)(o.i,{children:(0,g.jsx)(n.t,{type:`button`,variant:`ghost`,color:`danger`,size:`icon`,onClick:(0,h.useCallback)(async e=>{e.preventDefault(),e.stopPropagation(),await t?.()},[t]),children:(0,g.jsx)(_.Trash2Icon,{})})}),(0,g.jsx)(o.n,{children:(0,g.jsx)(`p`,{children:e||`Remove item from list table`})})]}),j=(e,t,n)=>{let r=10**t;switch(n){case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:return Math.round(e*r)/r}},M=(0,h.memo)(({decimalSeparator:e=`.`,groupSeparator:t=`,`,prefix:n,suffix:i,precision:a,roundingMode:o=`round`,showTrailingZeros:s=!1,size:c=`lg`,value:l=0})=>{let u=(0,h.useMemo)(()=>{let e={};return typeof a==`number`&&a>=0&&s&&(e.minimumFractionDigits=a),e.maximumFractionDigits=a,e},[a,s]),d=(0,h.useCallback)(e=>{let t=e;return typeof a==`number`&&a>=0&&(t=j(e,a,o)),t.toLocaleString(`en-US`,u)},[o,u,a]),f=(0,h.useMemo)(()=>{if(typeof l==`number`)return Number.isNaN(l)||!Number.isFinite(l)?`N/A`:d(l);if(typeof l==`string`){let e=l.trim();if(!e)return`N/A`;let t=Number(e);return Number.isNaN(t)||!Number.isFinite(t)?`N/A`:d(t)}return`N/A`},[l,d]),p=(0,h.useMemo)(()=>e===`.`&&t===`,`?f:f.replace(/,/g,t).replace(/\./g,e),[f,e,t]);return p===`0`||p===`N/A`||!p?(0,g.jsx)(S,{}):(0,g.jsxs)(r.t,{padding:`none`,className:(0,m.cn)(`font-number text-lg text-secondary-foreground tabular-nums`,c===`xs`&&`text-xs`,c===`sm`&&`text-sm`,c===`md`&&`text-base`,c===`lg`&&`text-lg`,c===`xl`&&`text-xl`),children:[n,(0,g.jsx)(`p`,{children:p}),i]})});M.displayName=`UITableStatisticDisplay`;const N=({uuid:e,username:n,email:i})=>(0,g.jsxs)(r.t,{wrap:!1,gap:`sm`,padding:`none`,children:[!e&&(0,g.jsx)(s.t,{className:`size-10 shadow-card`,children:(0,g.jsx)(s.n,{className:`bg-muted-weak`,children:(0,g.jsx)(_.UserRoundIcon,{size:28,className:`text-text-negative`})})}),e&&(0,g.jsx)(s.t,{className:`size-10 shadow-card`,children:(0,g.jsx)(s.n,{style:{backgroundColor:v.colorHashLight.hex(e)},children:(0,g.jsx)(_.UserRoundIcon,{size:28,className:`text-white`})})}),(0,g.jsxs)(r.t,{vertical:!0,padding:`none`,gap:`none`,align:`start`,children:[(0,g.jsx)(t.t,{className:`font-medium text-sm text-text-positive-weak`,children:n??`Unknown User`}),(0,g.jsx)(t.t,{variant:`sm`,className:`mt-0! text-text-positive-weak text-xs`,children:i})]})]}),te=60,ne=60,re=20,ie=20,ae=(0,h.createContext)(null),oe=()=>{let e=(0,h.use)(ae);if(!e)throw Error(`useTableInnerWrapperContext must be used within a TableInnerWrapperProvider`);return e},se=(0,h.createContext)(null),ce=()=>{let e=(0,h.use)(se);if(!e)throw Error(`useTableInnerTableContext must be used within a TableInnerTableProvider`);return e},le=(0,h.createContext)(null),ue=()=>{let e=(0,h.use)(le);if(!e)throw Error(`useTableHeaderRowContext must be used within a TableHeaderRowProvider`);return e},de=(0,h.createContext)(null),fe=()=>{let e=(0,h.use)(de);if(!e)throw Error(`useTableBodyContext must be used within a TableBodyProvider`);return e},pe=(0,h.createContext)(null),me=()=>{let e=(0,h.use)(pe);if(!e)throw Error(`useTableRowContext must be used within a TableRowProvider`);return e},P=(0,h.createContext)(null),F=()=>{let e=(0,h.use)(P);if(!e)throw Error(`useTableContext must be used within a TableProvider`);return e},I=(0,h.memo)(({isPinned:e,onLeftPin:t,onRightPin:n,onUnpin:r,className:i})=>{let a=(0,h.useCallback)(()=>{t?.(`left`)},[t]),o=(0,h.useCallback)(()=>{n?.(`right`)},[n]),s=(0,h.useCallback)(()=>{r?.(!1)},[r]);return(0,g.jsxs)(l.t,{children:[(0,g.jsx)(l.h,{asChild:!0,children:(0,g.jsx)(`button`,{className:(0,m.cn)(`absolute right-2 z-10 p-0.5 opacity-0`,`cursor-pointer rounded-full transition-all`,`text-text-positive-weak`,`[&>svg]:size-4`,`group-hover:opacity-100`,`hover:bg-muted-muted hover:text-text-positive`,i),children:(0,g.jsx)(_.EllipsisVerticalIcon,{})})}),(0,g.jsx)(l.r,{align:`end`,className:`w-64 p-4`,children:(0,g.jsxs)(l.i,{className:`*:data-[slot=dropdown-menu-item]:rounded-xs *:data-[slot=dropdown-menu-item]:p-2`,children:[(0,g.jsx)(h.Activity,{mode:e?`visible`:`hidden`,children:(0,g.jsxs)(l.a,{onClick:s,children:[!!e&&`Unpin`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.PinOffIcon,{className:`size-4`})})]})}),(0,g.jsxs)(h.Activity,{mode:e?`hidden`:`visible`,children:[(0,g.jsxs)(l.a,{onClick:a,children:[e?`Unpin`:`Pin to Left`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.MoveLeftIcon,{className:`size-4`})})]}),(0,g.jsxs)(l.a,{onClick:o,children:[e?`Unpin`:`Pin to Right`,(0,g.jsx)(l.d,{children:(0,g.jsx)(_.MoveRightIcon,{className:`size-4`})})]})]})]})})]})});I.displayName=`UITableHeadCellOption`;const L=(0,h.memo)(({isPinned:e,isAllRowsSelected:t,style:n,onToggleAllRowsSelected:r,...i})=>{let a=(0,h.useCallback)(e=>{r?.(!!e)},[r]);return(0,g.jsx)(`th`,{slot:`table-header-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:(0,m.cn)(e?`sticky`:`relative`),...i,children:(0,g.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:(0,g.jsx)(u.t,{"aria-label":`Select All Rows`,checked:t,onCheckedChange:a})})})});L.displayName=`UITableHeadCellSelect`;const R=(0,h.memo)(({isEmpty:e,isFetching:t})=>!e&&!t?null:(0,g.jsxs)(`div`,{className:`sticky left-0 flex min-h-96 flex-1 items-center justify-center bg-transparent text-text-positive-weak opacity-100`,children:[t&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,g.jsx)(d.t,{className:`size-12`}),(0,g.jsx)(`p`,{children:`Loading data...`})]}),e&&!t&&(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,g.jsx)(_.BoxIcon,{strokeWidth:1,size:48}),(0,g.jsx)(`p`,{children:`No data available`})]})]}));R.displayName=`UITableEmptyDisplay`;const z=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`div`,{slot:`table-wrapper`,className:(0,m.cn)(`relative m-0 flex size-full flex-col flex-nowrap items-start justify-start gap-2`,e),...n,children:t}));z.displayName=`UITableWrapper`;const B=(0,h.memo)(({children:e,...t})=>{let{innerWrapperId:n}=oe();return(0,g.jsx)(`div`,{id:n,slot:`table-inner-wrapper`,className:`relative size-full overflow-auto border-b border-b-border border-l border-l-border bg-card`,...t,children:e})});B.displayName=`UITableInnerWrapper`;const V=(0,h.memo)(({children:e,...t})=>{let{table:n,innerTableId:r,totalSize:i}=ce(),a=(0,h.useRef)(null);return(0,h.useEffect)(()=>{if(!a.current)return;let e=n.getFlatHeaders(),t=new ResizeObserver(t=>{requestAnimationFrame(()=>{let r=t[0].target;if(r instanceof HTMLTableElement){let i=t[0];if(!i)return;let a=i.contentRect.width,{left:o=[],right:s=[]}=n.getState().columnPinning,c=0,l=0,u=0,d=e.map(e=>{let{id:t}=e,n=t===`select`||t===`actions`,r=o.includes(t)||s.includes(t),i=e.getSize(),a=e.column.columnDef.maxSize;return n?(c+=60,{id:t,isFlex:!1,width:60}):r?(c+=i,{id:t,isFlex:!1,width:i}):e.column.columnDef.size||i!==150?(u+=i,{id:t,isFlex:!1,width:i}):(l++,{id:t,isFlex:!0,maxSize:a})}),f=a-c-u,p=l>0?Math.max(0,Math.floor(f/l)):0;d.forEach(e=>{if(e.isFlex){let t=e.maxSize?Math.min(p,e.maxSize):p;r.style.setProperty(`--header-${e.id}-size`,`${t}`),r.style.setProperty(`--col-${e.id}-size`,`${t}`),e.maxSize&&r.style.setProperty(`--col-${e.id}-maxSize`,`${e.maxSize}`)}else r.style.setProperty(`--header-${e.id}-size`,`${e.width}`),r.style.setProperty(`--col-${e.id}-size`,`${e.width}`)})}})});return t.observe(a.current),()=>t.disconnect()},[n.getState().columnSizingInfo,n.getState().columnSizing,n.getState().columnPinning]),(0,g.jsx)(`table`,{id:r,ref:a,slot:`table-inner-table`,className:`grid w-full table-fixed caption-bottom border-collapse border-spacing-0 flex-col content-start [&_tfoot_td]:border-t`,style:{minWidth:i},...t,children:e})});V.displayName=`UITableInnerTable`;const H=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`thead`,{slot:`table-head`,className:(0,m.cn)(`sticky top-0 z-20 h-9 w-full`,`grid select-none bg-muted-bg-subtle`,`border-b border-b-border shadow`,`font-medium text-[13px] text-text-positive-weak`,`[&_tr:not(:last-child)_td]:border-b`,`[&_th]:inline-flex`,`[&_th]:items-center`,`[&_th]:transition-all`,`[&_th]:duration-300`,`[&_th]:whitespace-nowrap`,`[&_th]:border-border`,`[&_th]:last:border-r-0`,`[&_th]:first:border-l-0`,`[&_tr_th:not([data-pinned=false])]:bg-muted-bg-subtle`,e),...n,children:t}));H.displayName=`UITableHead`;const U=(0,h.memo)(({headerGroup:e,className:t,...n})=>{let{isAllRowsSelected:r,columnPinningState:i,leftPinnedHeaders:a,rightPinnedHeaders:o,onToggleAllRowsSelected:s}=ue(),c=o[0]?.id,l=a[a.length-1]?.id;return(0,g.jsx)(`tr`,{slot:`table-head-row`,className:(0,m.cn)(`flex`,t),...n,children:e.headers.map((e,t)=>{let n=e.column.getIsVisible(),a=i.left?.includes(e.id)?`left`:i.right?.includes(e.id)?`right`:!1;return e.id===`select`?(0,g.jsx)(L,{isPinned:a,isAllRowsSelected:r,onToggleAllRowsSelected:s},e.id):(0,g.jsx)(W,{isVisible:n,isPinned:a,isFirstCell:e.id===c,isLastCell:e.id===l,isOptionsVisible:![`select`,`actions`].includes(e.id),headerId:e.id,headerColumn:e.column,colSpan:e.colSpan,onColumnPin:e.column.pin,onToggleVisibility:e.column.toggleVisibility,children:(0,y.flexRender)(e.column.columnDef.header,e.getContext())},`${e.id}-${t}`)})})});U.displayName=`UITableHeadRow`;const W=(0,h.memo)(({isVisible:e=!0,isPinned:t=!1,isFirstCell:n=!1,isLastCell:r=!1,isOptionsVisible:i=!0,headerId:a,headerColumn:o,className:s,children:c,onColumnPin:l,onToggleVisibility:u,...d})=>{let f=(0,h.useMemo)(()=>t?20:void 0,[t]),p=(0,h.useMemo)(()=>{let e=o?.getStart?.(`left`);return t===`left`&&typeof e==`number`?`${e}px`:void 0},[t,o]),_=(0,h.useMemo)(()=>{let e=o?.getAfter?.(`right`);return t===`right`&&typeof e==`number`?`${e}px`:void 0},[t,o]),v=(0,h.useMemo)(()=>`calc(var(--header-${a}-size) * 1px)`,[a]),y=(0,h.useMemo)(()=>o?.columnDef.minSize?`calc(var(--col-${a}-minSize) * 1px)`:void 0,[a,o]),b=(0,h.useMemo)(()=>o?.columnDef.maxSize?`calc(var(--col-${a}-maxSize) * 1px)`:void 0,[a,o]);return(0,g.jsxs)(`th`,{slot:`table-head-cell`,"data-pinned":t,"data-header":a,style:{zIndex:f,left:p,right:_,width:v,minWidth:y,maxWidth:b},className:(0,m.cn)(`group flex`,t?`sticky`:`relative`,t===`left`&&r&&`border-r border-r-border`,t===`right`&&n&&`border-l border-l-border`,o?.columnDef.meta?.position===`center`&&`justify-center`,o?.columnDef.meta?.position===`end`&&`justify-end`,o?.columnDef.meta?.position===`start`&&`justify-start`,s),...d,children:[(0,g.jsx)(`div`,{className:`truncate pl-4`,children:c}),i&&(0,g.jsx)(I,{isPinned:t,isVisible:e,onLeftPin:l,onRightPin:l,onUnpin:l})]})});W.displayName=`UITableHeadCell`;const G=(0,h.memo)(({height:e,className:t,children:n,...r})=>{let{isFetching:i,isEmpty:a}=fe();return a||i?null:(0,g.jsx)(`tbody`,{slot:`table-body`,style:{height:e},className:(0,m.cn)(`relative w-full`,`grid`,`[&_tr]:absolute`,`[&_tr]:flex`,`[&_tr]:flex-none`,`[&_tr]:w-full`,`[&_tr]:cursor-pointer [&_tr]:focus:outline-none`,`[&_tr]:border-b [&_tr]:border-b-border`,`[&_td]:z-10`,`[&_td]:transition-all`,`[&_td]:duration-300`,`[&_td]:flex`,`[&_td]:flex-none`,`[&_td]:overflow-hidden`,`[&_td]:whitespace-nowrap`,`[&_td]:px-4`,`[&_td]:py-2.5`,`[&_td]:align-middle`,`[&_td]:border-border`,`[&_td]:data-[selected=true]:bg-muted-muted!`,`[&_td]:data-[selected=true]:hover:bg-muted-muted!`,`[&_td>div]:inline-flex`,`[&_td>div]:items-center`,`[&_td>div]:w-full`,`[&_td:not([data-pinned=false])]:z-20`,`[&_td:not([data-pinned=false])]:sticky`,`[&_td:not([data-pinned=false])]:bg-card`,`**:data-lastcell:border-r`,`**:data-firstcell:border-l`,t),...r,children:n})});G.displayName=`UITableBody`;const K=(0,h.memo)(({row:e,isSelected:t,virtualRowIndex:n,virtualRowStart:r,children:i,...a})=>{let{keyOfClickRow:o,isAllRowsSelected:s,columnPinningState:c,leftPinnedHeaders:l,rightPinnedHeaders:u,onClickRow:d}=me(),f=(0,h.useMemo)(()=>c.left??[],[c]),p=(0,h.useMemo)(()=>c.right??[],[c]),m=(0,h.useMemo)(()=>u?.[0]?.id,[u]),_=(0,h.useMemo)(()=>l?.[l.length-1]?.id,[l]),v=(0,h.useCallback)(t=>{let r=o?e.original?.[o]:void 0;d?.(n,typeof r==`string`||typeof r==`number`?r:void 0),t.preventDefault(),t.stopPropagation()},[o,d,e,n]);return(0,g.jsx)(`tr`,{slot:`table-row`,"data-index":n,style:{transform:`translateY(${r}px)`},className:`group`,onClick:v,...a,children:e.getVisibleCells().map((e,r)=>{let i=f.includes(e.column.id),a=p.includes(e.column.id),o=i?`left`:a?`right`:!1;return e.column.id===`actions`?(0,g.jsx)(J,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,virtualRowIndex:n,column:e.column,getContext:e.getContext},`${e.id}-${r}`):e.column.id===`select`?(0,g.jsx)(q,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isSelected:s||t,onToggleRowSelected:e.row.toggleSelected},`${e.id}-${r}`):(0,g.jsx)(Y,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isFirstCell:e.column.id===m,isLastCell:e.column.id===_,colId:e.column.id,position:e.column.columnDef.meta?.position??`start`,column:e.column,getContext:e.getContext},`${e.id}-${r}`)})})});K.displayName=`UITableRow`;const q=(0,h.memo)(({isPinned:e,isSelected:t=!1,className:n,onToggleRowSelected:r,...i})=>{let a=(0,h.useCallback)(e=>{r?.(!!e)},[r]);return(0,g.jsx)(`td`,{slot:`table-body-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:(0,m.cn)(`group-hover:bg-muted-bg-subtle!`,e?`sticky`:`relative`,n),...i,children:(0,g.jsx)(`div`,{"data-slot":`table-cell-inner`,className:`flex! w-full! items-center justify-center bg-transparent text-center align-middle`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:(0,g.jsx)(u.t,{"aria-label":`Select Row`,checked:t,onCheckedChange:a})})})});q.displayName=`UITableCellSelect`;const J=(0,h.memo)(({virtualRowIndex:e,column:t,getContext:n,className:r,...i})=>{let a=(0,h.useMemo)(()=>(0,y.flexRender)(t?.columnDef.cell,n()),[t,n]);return(0,g.jsx)(`td`,{"data-col":`actions`,"data-cell":e,className:`sticky inset-y-0 right-0 z-50 flex items-center pr-4 group-hover:bg-muted-bg-subtle!`,...i,children:a})});J.displayName=`UITableCellActions`;const Y=(0,h.memo)(({isPinned:e=!1,isFirstCell:t=!1,isLastCell:n=!1,colId:r,position:i=`start`,column:a,getContext:o,...s})=>{let{innerTableId:c,table:l}=ce(),u=(0,h.useRef)(document.querySelector(`table[id="${c}"]`)),d=(0,h.useRef)(null),f=(0,h.useMemo)(()=>{let t=a?.getStart(`left`);return e===`left`&&typeof t==`number`?`${t}px`:void 0},[e,a]),p=(0,h.useMemo)(()=>{let t=a?.getAfter(`right`);return e===`right`&&typeof t==`number`?`${t}px`:void 0},[e,a]),_=(0,h.useMemo)(()=>`calc(var(--col-${r}-size) * 1px)`,[r]),v=(0,h.useMemo)(()=>a?.columnDef.minSize?`calc(var(--col-${r}-minSize) * 1px)`:void 0,[r,a]),b=(0,h.useMemo)(()=>a?.columnDef.maxSize?`calc(var(--col-${r}-maxSize) * 1px)`:void 0,[r,a]),x=(0,h.useMemo)(()=>(0,y.flexRender)(a?.columnDef.cell,o()),[a,o]);return(0,h.useEffect)(()=>{if(!d.current)return;let e=d.current.scrollWidth,t=a?.getSize();t&&e>t&&u.current instanceof HTMLTableElement&&typeof r==`string`&&a?.columnDef.meta?.fitContent&&l.setColumnSizing(t=>({...t,[r]:e+32}))},[r,a,l]),(0,g.jsx)(`td`,{slot:`table-body-cell`,"data-pinned":e,"data-lastcell":n||void 0,"data-firstcell":t||void 0,style:{left:f,right:p,width:_,minWidth:v,maxWidth:b},className:`group-hover:bg-muted-bg-subtle!`,...s,children:(0,g.jsx)(`div`,{ref:d,slot:`table-body-cell-inner`,className:(0,m.cn)(i===`start`&&`justify-start`,i===`center`&&`justify-center`,i===`end`&&`justify-end`),children:x})})});Y.displayName=`UITableCell`;const he=(0,h.memo)(({className:e,children:t,...n})=>(0,g.jsx)(`tfoot`,{slot:`table-footer`,className:(0,m.cn)(`flex w-full justify-center border-border-weak border-t py-2 font-medium [&>tr]:last:border-b-0`,e),...n,children:t}));he.displayName=`UITableFooter`;const X=(0,h.memo)(({virtualRowIndex:e,virtualRowStart:t,fetchMoreData:n})=>{let{innerWrapperId:r}=oe(),i=(0,h.useRef)(document.querySelector(`div[id="${r}"]`)),a=(0,h.useRef)(null),[o,s]=(0,h.useState)(`idle`),[c,l]=(0,h.useState)(0),u=(0,h.useCallback)(async()=>{try{s(`fetching`),await n?.(),s(`idle`)}catch(e){console.error(`Error fetching more data:`,e),s(`error`)}},[n]);return(0,h.useEffect)(()=>{if(!i.current)return;let e=new ResizeObserver(e=>{l(e[0].contentRect.width)});return e.observe(i.current),()=>e.disconnect()},[]),n?(0,g.jsx)(`tr`,{ref:a,"data-index":e,style:{transform:`translateY(${t}px)`,width:c},className:`sticky! left-0 h-10`,children:(0,g.jsx)(`td`,{className:`absolute left-0 flex w-full items-center justify-center text-xs`,children:(0,g.jsxs)(`button`,{type:`button`,disabled:o===`fetching`,className:(0,m.cn)(`flex cursor-pointer gap-x-0.5`,o===`fetching`&&`cursor-not-allowed`,o===`idle`&&`text-text-positive-weak hover:text-text-positive`,o===`error`&&`text-danger hover:text-danger-strong`),onClick:u,children:[o===`idle`&&(0,g.jsx)(_.ChevronDown,{className:`size-4`}),o===`fetching`&&(0,g.jsx)(d.t,{className:`size-4 animate-spin`}),o===`error`&&(0,g.jsx)(_.AlertTriangle,{className:`size-4 text-danger`}),o===`idle`&&`Load More`,o===`fetching`&&`Loading...`,o===`error`&&`Error! Retry?`]})})}):null});X.displayName=`UITableLoadMore`;const ge=()=>{let{table:e,isEmpty:t,isFetching:n,fetchMoreData:r}=F(),{rowSelectionState:i}=fe(),a=(0,h.useRef)(null),{rows:o}=e.getRowModel(),s=(0,b.useVirtualizer)({count:o.length+1,estimateSize:()=>40,getScrollElement:()=>a.current,measureElement:typeof window<`u`&&navigator.userAgent.indexOf(`Firefox`)===-1?e=>e?.getBoundingClientRect().height:void 0,overscan:2}),c=(0,h.useMemo)(()=>{let e=s.getTotalSize(),t=a.current?.clientHeight||0;return e<t?`${t}px`:`${e}px`},[s.getTotalSize()]);return(0,g.jsx)(f.r,{direction:`horizontal`,style:{direction:e.options.columnResizeDirection},className:`relative flex w-full max-w-full flex-1 gap-1 overflow-auto border-t border-t-border border-r border-r-border bg-slate-50 p-0 text-sm`,children:(0,g.jsx)(f.n,{className:`relative`,children:(0,g.jsxs)(B,{ref:a,children:[(0,g.jsxs)(V,{children:[(0,g.jsx)(H,{children:e.getHeaderGroups().map(e=>(0,g.jsx)(U,{headerGroup:e},e.id))}),(0,g.jsx)(G,{height:c,children:s.getVirtualItems().map(e=>{let t=o[e.index],n=Object.entries(i).some(([e,n])=>e===`${t?.id}`&&n);return t?(0,g.jsx)(K,{ref:s.measureElement,row:t,isSelected:n,virtualRowIndex:e.index,virtualRowStart:e.start},e.index):(0,g.jsx)(X,{virtualRowIndex:e.index,virtualRowStart:e.start,fetchMoreData:r},e.index)})})]}),(0,g.jsx)(R,{isEmpty:t,isFetching:n})]})})})},_e=({checked:e,title:t,onCheckedChange:n})=>(0,g.jsxs)(`div`,{className:`flex h-fit items-center gap-2`,children:[(0,g.jsx)(u.t,{checked:e,onCheckedChange:n}),(0,g.jsx)(`p`,{className:`text-sm`,children:t})]}),ve=()=>{let{table:e}=F(),[t,r]=(0,h.useState)(null);return(0,g.jsx)(f.n,{defaultSize:25,className:(0,m.cn)(`bg-card`,t===null?`max-w-8!`:`min-w-64`),children:(0,g.jsxs)(`div`,{className:`relative z-20 flex size-full bg-muted-bg-subtle`,children:[(0,g.jsxs)(`div`,{className:`flex-1`,children:[(0,g.jsx)(h.Activity,{mode:t===`columns`?`visible`:`hidden`,children:(0,g.jsxs)(`div`,{className:`flex size-full flex-col gap-2 p-4`,children:[(0,g.jsx)(`p`,{className:`px-2 font-medium`,children:`Columns Visibility`}),(0,g.jsx)(c.t,{}),(0,g.jsx)(`div`,{className:`flex flex-col gap-4 pt-4`,children:e.getAllColumns().map(e=>[`select`,`actions`].includes(e.id)?null:(0,g.jsx)(_e,{checked:e.getIsVisible(),title:String(e.columnDef.header),onCheckedChange:t=>e.toggleVisibility(!!t)},e.id))})]})}),(0,g.jsx)(h.Activity,{mode:t===`filters`?`visible`:`hidden`,children:(0,g.jsx)(`div`,{className:`flex size-full flex-col p-2`,children:(0,g.jsxs)(n.t,{variant:`outline`,color:`muted`,children:[(0,g.jsx)(_.ListFilterPlus,{}),`Add Filter`]})})})]}),(0,g.jsxs)(`div`,{className:`flex h-full flex-col border-border border-l bg-muted-bg-subtle text-sm`,children:[(0,g.jsxs)(`button`,{className:(0,m.cn)(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,t===`columns`&&`bg-card`),onClick:()=>r(t===`columns`?null:`columns`),children:[(0,g.jsx)(_.Columns4Icon,{size:18}),(0,g.jsx)(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Columns`})]}),(0,g.jsx)(c.t,{}),(0,g.jsxs)(`button`,{className:(0,m.cn)(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,t===`filters`&&`bg-card`),onClick:()=>r(t===`filters`?null:`filters`),children:[(0,g.jsx)(_.ListFilterIcon,{size:18}),(0,g.jsx)(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Filters`})]}),(0,g.jsx)(c.t,{})]})]})})},ye=(0,h.memo)(({innerWrapperId:e,children:t})=>{let n=(0,h.useMemo)(()=>({innerWrapperId:e}),[e]);return(0,g.jsx)(ae.Provider,{value:n,children:t})});ye.displayName=`UITableInnerWrapperProvider`;const be=(0,h.memo)(({table:e,innerTableId:t,totalSize:n,children:r})=>{let i=(0,h.useMemo)(()=>({table:e,innerTableId:t,totalSize:n}),[e,t,n]);return(0,g.jsx)(se.Provider,{value:i,children:r})});be.displayName=`UITableInnerTableProvider`;const xe=(0,h.memo)(({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i,children:a})=>{let o=(0,h.useMemo)(()=>({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i}),[e,t,n,r,i]);return(0,g.jsx)(le.Provider,{value:o,children:a})});xe.displayName=`UITableHeadRowProvider`;const Se=(0,h.memo)(({isFetching:e,isEmpty:t,rowSelectionState:n,children:r})=>{let i=(0,h.useMemo)(()=>({isFetching:e,isEmpty:t,rowSelectionState:n}),[e,t,n]);return(0,g.jsx)(de.Provider,{value:i,children:r})});Se.displayName=`UITableBodyProvider`;const Z=(0,h.memo)(({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a,children:o})=>{let s=(0,h.useMemo)(()=>({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a}),[e,t,n,r,i,a]);return(0,g.jsx)(pe.Provider,{value:s,children:o})});Z.displayName=`UITableRowProvider`;const Ce=({title:e,isFetching:t=!1,isRefetching:n=!1,data:r,columns:i,totalRows:a,leftPinnedColumns:o=[],rightPinnedColumns:s=[],keyOfClickRow:c,onClickRow:l,onRowSelection:u,onColumnPinning:d,fetchMoreData:f,children:p})=>{let m=(0,h.useId)(),_=(0,h.useId)(),[v,b]=(0,h.useState)({}),[x,S]=(0,h.useState)({right:s,left:[`select`,...o]}),[C,w]=(0,h.useState)({}),ee=(0,h.useCallback)(e=>(b(e),u?.(e instanceof Function?e(v):e),e),[v,u]),T=(0,h.useCallback)(e=>{S(e),d?.(e instanceof Function?e(x):e)},[x,d]),E=(0,y.useReactTable)({data:r,columns:i,state:{rowSelection:v,columnPinning:x,expanded:C},defaultColumn:{enableResizing:!1,size:void 0,minSize:void 0,maxSize:void 0},columnResizeMode:`onChange`,columnResizeDirection:`ltr`,enableColumnPinning:!0,enableRowSelection:!0,enableColumnResizing:!0,enableMultiRowSelection:!0,autoResetAll:!1,autoResetExpanded:!1,autoResetPageIndex:!1,getSubRows:e=>e.subRows,getCoreRowModel:(0,y.getCoreRowModel)(),getGroupedRowModel:(0,y.getGroupedRowModel)(),getExpandedRowModel:(0,y.getExpandedRowModel)(),onRowSelectionChange:ee,onColumnPinningChange:T,onExpandedChange:w}),D=(0,h.useMemo)(()=>{let{rows:e}=E.getRowModel();return e},[E.getRowModel().rows,E.getState().columnPinning]),O=(0,h.useMemo)(()=>!t&&D.length===0,[D,t]),k=(0,h.useMemo)(()=>({title:e,table:E,isEmpty:O,isFetching:t,isRefetching:n,totalRows:a,fetchMoreData:f}),[e,E,O,n,t,a,f,E.getState().columnPinning,E.getState().expanded]),A=(0,h.useMemo)(()=>E.getState(),[E.getState()]),j=(0,h.useMemo)(()=>E.getIsAllRowsSelected(),[E.getIsAllRowsSelected()]),M=(0,h.useMemo)(()=>A.rowSelection,[A.rowSelection]),N=(0,h.useMemo)(()=>A.columnPinning,[A.columnPinning]),te=(0,h.useMemo)(()=>E.getLeftHeaderGroups()[0]?.headers||[],[E.getState().columnPinning]),ne=(0,h.useMemo)(()=>E.getRightHeaderGroups()[0]?.headers||[],[E.getState().columnPinning]),re=(0,h.useMemo)(()=>E.getTotalSize(),[E.getTotalSize()]);return(0,g.jsx)(P.Provider,{value:k,children:(0,g.jsx)(ye,{innerWrapperId:m,children:(0,g.jsx)(be,{table:E,innerTableId:_,totalSize:re,children:(0,g.jsx)(xe,{isAllRowsSelected:j,columnPinningState:N,leftPinnedHeaders:te,rightPinnedHeaders:ne,onToggleAllRowsSelected:E.toggleAllRowsSelected,children:(0,g.jsx)(Se,{isFetching:t,isEmpty:O,rowSelectionState:M,children:(0,g.jsx)(Z,{keyOfClickRow:c,isAllRowsSelected:j,columnPinningState:N,leftPinnedHeaders:te,rightPinnedHeaders:ne,onClickRow:l,children:p})})})})})})},we=({onSearch:e,onChange:t,...n})=>{let r=(0,x.useDebounceCallback)(t=>{e?.(t)},500);return(0,g.jsxs)(`div`,{className:`relative w-full max-w-80 flex-1`,children:[(0,g.jsx)(p.t,{...n,size:`lg`,type:`search`,placeholder:`Search records...`,className:`flex-1 ps-9 pe-9`,onChange:e=>{t?.(e),r(e.target.value??``)}}),(0,g.jsx)(`div`,{className:`pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-text-positive-weak peer-disabled:opacity-50`,children:(0,g.jsx)(_.SearchIcon,{size:16})}),(0,g.jsx)(`button`,{className:`absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:z-10 focus-visible:border focus-visible:border-primary-strong focus-visible:ring-[3px] focus-visible:ring-primary-weak disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Submit search`,type:`submit`,children:(0,g.jsx)(_.ArrowRightIcon,{size:16,"aria-hidden":`true`})})]})},Q=({children:e,disabled:t,onClick:n})=>(0,g.jsx)(`button`,{type:`button`,disabled:t,className:`flex cursor-pointer items-center gap-x-1 rounded-sm border border-border bg-background p-2.5 text-sm text-text-positive-weak outline-none transition-all hover:shadow-card focus:border-border-emphasis focus:bg-muted-muted active:border-border-emphasis active:bg-muted-muted active:text-text-positive disabled:pointer-events-none disabled:cursor-default disabled:opacity-60 [&_svg]:size-3.5`,onClick:n,children:e}),Te=({onCreate:e,onDownload:t,onRefresh:n})=>(0,g.jsxs)(`div`,{className:`flex [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,children:[(0,g.jsx)(Q,{disabled:!e,onClick:t=>{e?.(),t.stopPropagation(),t.preventDefault()},children:(0,g.jsx)(_.CirclePlus,{})}),(0,g.jsx)(Q,{disabled:!n,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.RefreshCwIcon,{})}),(0,g.jsx)(Q,{disabled:!t,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:(0,g.jsx)(_.DownloadIcon,{})})]}),$=({children:e})=>{let{title:t}=F();return(0,g.jsxs)(`div`,{"data-slot":`table-tooltip`,className:`relative m-0 flex w-full flex-0 flex-col flex-wrap items-start space-y-2 p-0 px-2 text-sm`,children:[(0,g.jsx)(`h3`,{className:`font-semibold text-base text-text-positive`,children:t}),(0,g.jsx)(`div`,{className:`flex w-full flex-1 justify-between gap-x-2`,children:e})]})};$.displayName=`TableTooltip`,exports.UITableBadgeDisplay=C,exports.UITableBody=G,exports.UITableBooleanDisplay=w,exports.UITableCell=Y,exports.UITableCellActions=J,exports.UITableCellSelect=q,exports.UITableContainer=ge,exports.UITableDateDisplay=ee,exports.UITableDescriptionDisplay=T,exports.UITableEmptyDisplay=R,exports.UITableFilter=ve,exports.UITableFooter=he,exports.UITableHead=H,exports.UITableHeadCell=W,exports.UITableHeadCellOption=I,exports.UITableHeadCellSelect=L,exports.UITableHeadRow=U,exports.UITableInnerTable=V,exports.UITableInnerWrapper=B,exports.UITableLoadMore=X,exports.UITableMoreButton=E,exports.UITableNameDisplay=D,exports.UITablePermalink=O,exports.UITablePhoneNumberDisplay=k,exports.UITableProvider=Ce,exports.UITableRemoveButton=A,exports.UITableRow=K,exports.UITableStatisticDisplay=M,exports.UITableTooltip=$,exports.UITableTooltipActions=Te,exports.UITableTooltipFilter=we,exports.UITableUserDataDisplay=N,exports.UITableWrapper=z;
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1,5 +1,5 @@
1
1
  import { t as AnyEntity } from "../../types-Bd0JePtp.cjs";
2
- import { t as Input } from "../../input-C3M7uZqX.cjs";
2
+ import { t as Input } from "../../input-Bm0YXroi.cjs";
3
3
  import * as react_jsx_runtime346 from "react/jsx-runtime";
4
4
  import * as react267 from "react";
5
5
  import { AccessorKeyColumnDef, CellContext, Column, ColumnPinningPosition, ColumnPinningState, Header, HeaderGroup, Row, RowSelectionState, Table } from "@tanstack/react-table";
@@ -1,7 +1,7 @@
1
1
  import { t as AnyEntity } from "../../types-BpHcqlOI.mjs";
2
- import { t as Input } from "../../input-C9dS5env.mjs";
3
- import * as react267 from "react";
4
- import * as react_jsx_runtime346 from "react/jsx-runtime";
2
+ import { t as Input } from "../../input-CLlVXOR2.mjs";
3
+ import * as react255 from "react";
4
+ import * as react_jsx_runtime333 from "react/jsx-runtime";
5
5
  import { AccessorKeyColumnDef, CellContext, Column, ColumnPinningPosition, ColumnPinningState, Header, HeaderGroup, Row, RowSelectionState, Table } from "@tanstack/react-table";
6
6
  import { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
7
7
 
@@ -73,7 +73,7 @@ type Props$1 = {
73
73
  size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
74
74
  value: number | string | null | undefined;
75
75
  };
76
- declare const UITableStatisticDisplay: react267.MemoExoticComponent<({
76
+ declare const UITableStatisticDisplay: react255.MemoExoticComponent<({
77
77
  decimalSeparator,
78
78
  groupSeparator,
79
79
  prefix: Prefix,
@@ -83,7 +83,7 @@ declare const UITableStatisticDisplay: react267.MemoExoticComponent<({
83
83
  showTrailingZeros,
84
84
  size,
85
85
  value
86
- }: Props$1) => react_jsx_runtime346.JSX.Element>;
86
+ }: Props$1) => react_jsx_runtime333.JSX.Element>;
87
87
  //#endregion
88
88
  //#region packages/components/features/tables/components/atoms/user.d.ts
89
89
  type Props = {
@@ -236,28 +236,28 @@ type TableProviderProps<TData extends RowData<TData>, TKey extends keyof TData =
236
236
  };
237
237
  //#endregion
238
238
  //#region packages/components/features/tables/components/common.d.ts
239
- declare const UITableHeadCellOption: react267.NamedExoticComponent<TUITableHeadCellOption>;
240
- declare const UITableHeadCellSelect: react267.NamedExoticComponent<TUITableHeadCellSelect>;
241
- declare const UITableEmptyDisplay: react267.NamedExoticComponent<TUITableEmptyDisplay>;
242
- declare const UITableWrapper: react267.NamedExoticComponent<TUITableWrapper>;
243
- declare const UITableInnerWrapper: react267.NamedExoticComponent<TUITableInnerWrapper>;
244
- declare const UITableInnerTable: react267.NamedExoticComponent<TUITableInnerTable>;
245
- declare const UITableHead: react267.NamedExoticComponent<TUITableHead>;
246
- declare const UITableHeadRow: react267.NamedExoticComponent<TUITableHeadRow>;
247
- declare const UITableHeadCell: react267.NamedExoticComponent<TUITableHeadCell>;
248
- declare const UITableBody: react267.NamedExoticComponent<TUITableBody>;
249
- declare const UITableRow: react267.NamedExoticComponent<TUITableRow>;
250
- declare const UITableCellSelect: react267.NamedExoticComponent<TUITableCellSelect>;
251
- declare const UITableCellActions: react267.NamedExoticComponent<TUITableCellActions>;
252
- declare const UITableCell: react267.NamedExoticComponent<TUITableCell>;
253
- declare const UITableFooter: react267.NamedExoticComponent<TUITableFooter>;
254
- declare const UITableLoadMore: react267.NamedExoticComponent<TUITableLoadMore>;
239
+ declare const UITableHeadCellOption: react255.NamedExoticComponent<TUITableHeadCellOption>;
240
+ declare const UITableHeadCellSelect: react255.NamedExoticComponent<TUITableHeadCellSelect>;
241
+ declare const UITableEmptyDisplay: react255.NamedExoticComponent<TUITableEmptyDisplay>;
242
+ declare const UITableWrapper: react255.NamedExoticComponent<TUITableWrapper>;
243
+ declare const UITableInnerWrapper: react255.NamedExoticComponent<TUITableInnerWrapper>;
244
+ declare const UITableInnerTable: react255.NamedExoticComponent<TUITableInnerTable>;
245
+ declare const UITableHead: react255.NamedExoticComponent<TUITableHead>;
246
+ declare const UITableHeadRow: react255.NamedExoticComponent<TUITableHeadRow>;
247
+ declare const UITableHeadCell: react255.NamedExoticComponent<TUITableHeadCell>;
248
+ declare const UITableBody: react255.NamedExoticComponent<TUITableBody>;
249
+ declare const UITableRow: react255.NamedExoticComponent<TUITableRow>;
250
+ declare const UITableCellSelect: react255.NamedExoticComponent<TUITableCellSelect>;
251
+ declare const UITableCellActions: react255.NamedExoticComponent<TUITableCellActions>;
252
+ declare const UITableCell: react255.NamedExoticComponent<TUITableCell>;
253
+ declare const UITableFooter: react255.NamedExoticComponent<TUITableFooter>;
254
+ declare const UITableLoadMore: react255.NamedExoticComponent<TUITableLoadMore>;
255
255
  //#endregion
256
256
  //#region packages/components/features/tables/components/table.d.ts
257
257
  declare const UITableContainer: React.FC<React.PropsWithChildren>;
258
258
  //#endregion
259
259
  //#region packages/components/features/tables/components/table/filter.d.ts
260
- declare const UITableFilter: () => react_jsx_runtime346.JSX.Element;
260
+ declare const UITableFilter: () => react_jsx_runtime333.JSX.Element;
261
261
  //#endregion
262
262
  //#region packages/components/features/tables/components/table/provider.d.ts
263
263
  declare const UITableProvider: <TData extends RowData<TData> = RowData<AnyEntity>, TKey extends keyof TData = keyof TData, TColumns extends ReadonlyArray<TUITableColumn<TData>> = TUITableColumn<TData>[]>({
@@ -275,7 +275,7 @@ declare const UITableProvider: <TData extends RowData<TData> = RowData<AnyEntity
275
275
  onColumnPinning,
276
276
  fetchMoreData,
277
277
  children
278
- }: React.PropsWithChildren<TableProviderProps<TData, TKey, TColumns>>) => react_jsx_runtime346.JSX.Element;
278
+ }: React.PropsWithChildren<TableProviderProps<TData, TKey, TColumns>>) => react_jsx_runtime333.JSX.Element;
279
279
  //#endregion
280
280
  //#region packages/components/features/tables/components/table/tooltip.d.ts
281
281
  declare const UITableTooltipFilter: React.FC<Omit<React.ComponentProps<typeof Input>, 'className'> & {
@@ -1,2 +1,2 @@
1
- import{t as e}from"../../paragraph-moBSTPmT.mjs";import"../../button.variants-DuuH1O0_.mjs";import{t}from"../../button-6-3G2PiR.mjs";import{t as n}from"../../flex-BP8sTi70.mjs";import{t as r}from"../../date-By93kONr.mjs";import{t as i}from"../../badge-B4Fa7-J3.mjs";import{i as a,n as o,r as s,t as c}from"../../tooltip-B3dTcgcc.mjs";import{n as l,t as u}from"../../avatar-DReNH6rV.mjs";import{t as d}from"../../separator-Bf0gymN4.mjs";import{a as f,d as p,h as m,i as h,r as g,t as _}from"../../dropdown-menu-B8GUTfTp.mjs";import{t as v}from"../../checkbox-Bg2FiuQw.mjs";import{t as y}from"../../spinner-D1v3Bard.mjs";import{n as b,r as ee}from"../../resizable-DXHfkbaz.mjs";import{t as te}from"../../input-DBtIgQB6.mjs";import{cn as x}from"@customafk/react-toolkit/utils";import{Activity as S,createContext as C,memo as w,use as T,useCallback as E,useEffect as D,useId as ne,useMemo as O,useRef as k,useState as A}from"react";import{jsx as j,jsxs as M}from"react/jsx-runtime";import{AlertTriangle as N,ArrowRightIcon as P,BoxIcon as F,CheckIcon as re,ChevronDown as ie,CirclePlus as ae,Columns4Icon as oe,DownloadIcon as se,EllipsisVerticalIcon as ce,ExternalLinkIcon as le,ListFilterIcon as ue,ListFilterPlus as de,MinusIcon as fe,MoreVerticalIcon as pe,MoveLeftIcon as me,MoveRightIcon as he,PinOffIcon as ge,RefreshCwIcon as _e,SearchIcon as ve,Trash2Icon as ye,UserRoundIcon as be,XIcon as xe}from"lucide-react";import{colorHashLight as Se}from"@customafk/react-toolkit/color-hash";import{flexRender as I,getCoreRowModel as Ce,getExpandedRowModel as we,getGroupedRowModel as Te,useReactTable as Ee}from"@tanstack/react-table";import{useVirtualizer as De}from"@tanstack/react-virtual";import{useDebounceCallback as Oe}from"@customafk/react-toolkit/hooks/useDebounceCallback";const L=()=>M(`div`,{className:`flex gap-0 text-text-positive-weak`,children:[j(fe,{size:16}),j(fe,{size:16})]}),ke=({label:e,onClick:t,onRemove:n})=>e?n?M(`div`,{className:`flex w-fit gap-x-0.5 rounded-full border border-border py-1 pr-2 pl-3 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:[e,j(`button`,{className:`cursor-pointer text-text-positive-weak hover:text-text-positive-strong`,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:j(xe,{size:12})})]}):j(`button`,{className:`w-fit rounded-full border border-border px-3 py-1 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:e}):j(L,{}),Ae=({value:e})=>e==null?j(L,{}):e===!1?j(`div`,{className:`text-danger-strong`,children:j(xe,{})}):j(`div`,{className:`text-success-strong`,children:j(re,{})}),je=({date:e})=>e==null?j(L,{}):j(s,{children:M(c,{children:[j(a,{asChild:!0,children:j(i,{className:`h-fit`,children:j(r,{date:e,format:`medium`,className:`font-normal text-white`})})}),j(o,{className:`rounded px-2`,children:j(r,{date:e,format:`full`,showTime:!0,className:`font-medium text-text-negative text-xs`})})]})}),Me=({content:t})=>t==null?j(L,{}):M(c,{children:[j(a,{children:j(e,{variant:`sm`,className:`line-clamp-2 whitespace-pre-line break-all`,children:t})}),j(o,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:M(`div`,{className:`flex flex-col gap-y-2`,children:[j(e,{variant:`xs`,className:`whitespace-pre-line text-wrap break-keep text-text-negative-weak`,children:t}),M(`p`,{className:`w-full text-end`,children:[t.toString().length,` chars`]})]})})]}),Ne=({items:e=[]})=>M(_,{children:[j(m,{asChild:!0,children:j(t,{size:`sm`,variant:`ghost`,color:`secondary`,className:`size-9 rounded-full`,children:j(pe,{})})}),j(g,{children:j(h,{children:e.map(e=>j(f,{className:`px-3`,onSelect:t=>{e.onClick(e.id),t.stopPropagation()},children:e.label},e.id))})})]}),Pe=({name:t})=>t?M(c,{children:[j(a,{children:j(e,{variant:`sm`,className:`line-clamp-2 w-full truncate text-wrap pb-px text-start`,children:t})}),j(o,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:M(`div`,{className:`flex flex-col gap-y-2`,children:[j(`p`,{className:`whitespace-pre-line text-wrap break-keep`,children:t}),M(`p`,{className:`w-full text-end`,children:[t.length,` chars`]})]})})]}):j(L,{}),Fe=({href:e,label:t})=>M(`a`,{href:e,target:`_blank`,className:`inline-flex items-center gap-1 truncate text-primary text-sm underline`,rel:`noopener noreferrer`,children:[j(`span`,{children:t||e}),j(le,{size:14})]}),Ie=({value:e})=>M(c,{children:[j(a,{asChild:!0,children:j(`p`,{className:`font-number text-secondary-foreground text-sm tabular-nums`,children:e.replace(/(\d{3})(\d{3})(\d{4})/,`($1) $2-$3`)})}),j(o,{align:`start`,children:j(`p`,{className:`tabular-nums`,children:e.slice(1).replace(/(\d{2})(\d{3})(\d{4})/,`(00) (+84) ($1) $2-$3`)})})]}),Le=({title:e,onClick:n})=>M(c,{children:[j(a,{children:j(t,{type:`button`,variant:`ghost`,color:`danger`,size:`icon`,onClick:E(async e=>{e.preventDefault(),e.stopPropagation(),await n?.()},[n]),children:j(ye,{})})}),j(o,{children:j(`p`,{children:e||`Remove item from list table`})})]}),Re=(e,t,n)=>{let r=10**t;switch(n){case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:return Math.round(e*r)/r}},ze=w(({decimalSeparator:e=`.`,groupSeparator:t=`,`,prefix:r,suffix:i,precision:a,roundingMode:o=`round`,showTrailingZeros:s=!1,size:c=`lg`,value:l=0})=>{let u=O(()=>{let e={};return typeof a==`number`&&a>=0&&s&&(e.minimumFractionDigits=a),e.maximumFractionDigits=a,e},[a,s]),d=E(e=>{let t=e;return typeof a==`number`&&a>=0&&(t=Re(e,a,o)),t.toLocaleString(`en-US`,u)},[o,u,a]),f=O(()=>{if(typeof l==`number`)return Number.isNaN(l)||!Number.isFinite(l)?`N/A`:d(l);if(typeof l==`string`){let e=l.trim();if(!e)return`N/A`;let t=Number(e);return Number.isNaN(t)||!Number.isFinite(t)?`N/A`:d(t)}return`N/A`},[l,d]),p=O(()=>e===`.`&&t===`,`?f:f.replace(/,/g,t).replace(/\./g,e),[f,e,t]);return p===`0`||p===`N/A`||!p?j(L,{}):M(n,{padding:`none`,className:x(`font-number text-lg text-secondary-foreground tabular-nums`,c===`xs`&&`text-xs`,c===`sm`&&`text-sm`,c===`md`&&`text-base`,c===`lg`&&`text-lg`,c===`xl`&&`text-xl`),children:[r,j(`p`,{children:p}),i]})});ze.displayName=`UITableStatisticDisplay`;const Be=({uuid:t,username:r,email:i})=>M(n,{wrap:!1,gap:`sm`,padding:`none`,children:[!t&&j(u,{className:`size-10 shadow-card`,children:j(l,{className:`bg-muted-weak`,children:j(be,{size:28,className:`text-text-negative`})})}),t&&j(u,{className:`size-10 shadow-card`,children:j(l,{style:{backgroundColor:Se.hex(t)},children:j(be,{size:28,className:`text-white`})})}),M(n,{vertical:!0,padding:`none`,gap:`none`,align:`start`,children:[j(e,{className:`font-medium text-sm text-text-positive-weak`,children:r??`Unknown User`}),j(e,{variant:`sm`,className:`mt-0! text-text-positive-weak text-xs`,children:i})]})]}),Ve=C(null),He=()=>{let e=T(Ve);if(!e)throw Error(`useTableInnerWrapperContext must be used within a TableInnerWrapperProvider`);return e},Ue=C(null),We=()=>{let e=T(Ue);if(!e)throw Error(`useTableInnerTableContext must be used within a TableInnerTableProvider`);return e},Ge=C(null),Ke=()=>{let e=T(Ge);if(!e)throw Error(`useTableHeaderRowContext must be used within a TableHeaderRowProvider`);return e},qe=C(null),Je=()=>{let e=T(qe);if(!e)throw Error(`useTableBodyContext must be used within a TableBodyProvider`);return e},Ye=C(null),Xe=()=>{let e=T(Ye);if(!e)throw Error(`useTableRowContext must be used within a TableRowProvider`);return e},Ze=C(null),R=()=>{let e=T(Ze);if(!e)throw Error(`useTableContext must be used within a TableProvider`);return e},z=w(({isPinned:e,onLeftPin:t,onRightPin:n,onUnpin:r,className:i})=>{let a=E(()=>{t?.(`left`)},[t]),o=E(()=>{n?.(`right`)},[n]),s=E(()=>{r?.(!1)},[r]);return M(_,{children:[j(m,{asChild:!0,children:j(`button`,{className:x(`absolute right-2 z-10 p-0.5 opacity-0`,`cursor-pointer rounded-full transition-all`,`text-text-positive-weak`,`[&>svg]:size-4`,`group-hover:opacity-100`,`hover:bg-muted-muted hover:text-text-positive`,i),children:j(ce,{})})}),j(g,{align:`end`,className:`w-64 p-4`,children:M(h,{className:`*:data-[slot=dropdown-menu-item]:rounded-xs *:data-[slot=dropdown-menu-item]:p-2`,children:[j(S,{mode:e?`visible`:`hidden`,children:M(f,{onClick:s,children:[!!e&&`Unpin`,j(p,{children:j(ge,{className:`size-4`})})]})}),M(S,{mode:e?`hidden`:`visible`,children:[M(f,{onClick:a,children:[e?`Unpin`:`Pin to Left`,j(p,{children:j(me,{className:`size-4`})})]}),M(f,{onClick:o,children:[e?`Unpin`:`Pin to Right`,j(p,{children:j(he,{className:`size-4`})})]})]})]})})]})});z.displayName=`UITableHeadCellOption`;const B=w(({isPinned:e,isAllRowsSelected:t,style:n,onToggleAllRowsSelected:r,...i})=>{let a=E(e=>{r?.(!!e)},[r]);return j(`th`,{slot:`table-header-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:x(e?`sticky`:`relative`),...i,children:j(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:j(v,{"aria-label":`Select All Rows`,checked:t,onCheckedChange:a})})})});B.displayName=`UITableHeadCellSelect`;const V=w(({isEmpty:e,isFetching:t})=>!e&&!t?null:M(`div`,{className:`sticky left-0 flex min-h-96 flex-1 items-center justify-center bg-transparent text-text-positive-weak opacity-100`,children:[t&&M(`div`,{className:`flex flex-col items-center gap-1`,children:[j(y,{className:`size-12`}),j(`p`,{children:`Loading data...`})]}),e&&!t&&M(`div`,{className:`flex flex-col items-center gap-1`,children:[j(F,{strokeWidth:1,size:48}),j(`p`,{children:`No data available`})]})]}));V.displayName=`UITableEmptyDisplay`;const Qe=w(({className:e,children:t,...n})=>j(`div`,{slot:`table-wrapper`,className:x(`relative m-0 flex size-full flex-col flex-nowrap items-start justify-start gap-2`,e),...n,children:t}));Qe.displayName=`UITableWrapper`;const H=w(({children:e,...t})=>{let{innerWrapperId:n}=He();return j(`div`,{id:n,slot:`table-inner-wrapper`,className:`relative size-full overflow-auto border-b border-b-border border-l border-l-border bg-card`,...t,children:e})});H.displayName=`UITableInnerWrapper`;const U=w(({children:e,...t})=>{let{table:n,innerTableId:r,totalSize:i}=We(),a=k(null);return D(()=>{if(!a.current)return;let e=n.getFlatHeaders(),t=new ResizeObserver(t=>{requestAnimationFrame(()=>{let r=t[0].target;if(r instanceof HTMLTableElement){let i=t[0];if(!i)return;let a=i.contentRect.width,{left:o=[],right:s=[]}=n.getState().columnPinning,c=0,l=0,u=0,d=e.map(e=>{let{id:t}=e,n=t===`select`||t===`actions`,r=o.includes(t)||s.includes(t),i=e.getSize(),a=e.column.columnDef.maxSize;return n?(c+=60,{id:t,isFlex:!1,width:60}):r?(c+=i,{id:t,isFlex:!1,width:i}):e.column.columnDef.size||i!==150?(u+=i,{id:t,isFlex:!1,width:i}):(l++,{id:t,isFlex:!0,maxSize:a})}),f=a-c-u,p=l>0?Math.max(0,Math.floor(f/l)):0;d.forEach(e=>{if(e.isFlex){let t=e.maxSize?Math.min(p,e.maxSize):p;r.style.setProperty(`--header-${e.id}-size`,`${t}`),r.style.setProperty(`--col-${e.id}-size`,`${t}`),e.maxSize&&r.style.setProperty(`--col-${e.id}-maxSize`,`${e.maxSize}`)}else r.style.setProperty(`--header-${e.id}-size`,`${e.width}`),r.style.setProperty(`--col-${e.id}-size`,`${e.width}`)})}})});return t.observe(a.current),()=>t.disconnect()},[n.getState().columnSizingInfo,n.getState().columnSizing,n.getState().columnPinning]),j(`table`,{id:r,ref:a,slot:`table-inner-table`,className:`grid w-full table-fixed caption-bottom border-collapse border-spacing-0 flex-col content-start [&_tfoot_td]:border-t`,style:{minWidth:i},...t,children:e})});U.displayName=`UITableInnerTable`;const W=w(({className:e,children:t,...n})=>j(`thead`,{slot:`table-head`,className:x(`sticky top-0 z-20 h-9 w-full`,`grid select-none bg-muted-bg-subtle`,`border-b border-b-border shadow`,`font-medium text-[13px] text-text-positive-weak`,`[&_tr:not(:last-child)_td]:border-b`,`[&_th]:inline-flex`,`[&_th]:items-center`,`[&_th]:transition-all`,`[&_th]:duration-300`,`[&_th]:whitespace-nowrap`,`[&_th]:border-border`,`[&_th]:last:border-r-0`,`[&_th]:first:border-l-0`,`[&_tr_th:not([data-pinned=false])]:bg-muted-bg-subtle`,e),...n,children:t}));W.displayName=`UITableHead`;const G=w(({headerGroup:e,className:t,...n})=>{let{isAllRowsSelected:r,columnPinningState:i,leftPinnedHeaders:a,rightPinnedHeaders:o,onToggleAllRowsSelected:s}=Ke(),c=o[0]?.id,l=a[a.length-1]?.id;return j(`tr`,{slot:`table-head-row`,className:x(`flex`,t),...n,children:e.headers.map((e,t)=>{let n=e.column.getIsVisible(),a=i.left?.includes(e.id)?`left`:i.right?.includes(e.id)?`right`:!1;return e.id===`select`?j(B,{isPinned:a,isAllRowsSelected:r,onToggleAllRowsSelected:s},e.id):j(K,{isVisible:n,isPinned:a,isFirstCell:e.id===c,isLastCell:e.id===l,isOptionsVisible:![`select`,`actions`].includes(e.id),headerId:e.id,headerColumn:e.column,colSpan:e.colSpan,onColumnPin:e.column.pin,onToggleVisibility:e.column.toggleVisibility,children:I(e.column.columnDef.header,e.getContext())},`${e.id}-${t}`)})})});G.displayName=`UITableHeadRow`;const K=w(({isVisible:e=!0,isPinned:t=!1,isFirstCell:n=!1,isLastCell:r=!1,isOptionsVisible:i=!0,headerId:a,headerColumn:o,className:s,children:c,onColumnPin:l,onToggleVisibility:u,...d})=>{let f=O(()=>t?20:void 0,[t]),p=O(()=>{let e=o?.getStart?.(`left`);return t===`left`&&typeof e==`number`?`${e}px`:void 0},[t,o]),m=O(()=>{let e=o?.getAfter?.(`right`);return t===`right`&&typeof e==`number`?`${e}px`:void 0},[t,o]),h=O(()=>`calc(var(--header-${a}-size) * 1px)`,[a]),g=O(()=>o?.columnDef.minSize?`calc(var(--col-${a}-minSize) * 1px)`:void 0,[a,o]),_=O(()=>o?.columnDef.maxSize?`calc(var(--col-${a}-maxSize) * 1px)`:void 0,[a,o]);return M(`th`,{slot:`table-head-cell`,"data-pinned":t,"data-header":a,style:{zIndex:f,left:p,right:m,width:h,minWidth:g,maxWidth:_},className:x(`group flex`,t?`sticky`:`relative`,t===`left`&&r&&`border-r border-r-border`,t===`right`&&n&&`border-l border-l-border`,o?.columnDef.meta?.position===`center`&&`justify-center`,o?.columnDef.meta?.position===`end`&&`justify-end`,o?.columnDef.meta?.position===`start`&&`justify-start`,s),...d,children:[j(`div`,{className:`truncate pl-4`,children:c}),i&&j(z,{isPinned:t,isVisible:e,onLeftPin:l,onRightPin:l,onUnpin:l})]})});K.displayName=`UITableHeadCell`;const q=w(({height:e,className:t,children:n,...r})=>{let{isFetching:i,isEmpty:a}=Je();return a||i?null:j(`tbody`,{slot:`table-body`,style:{height:e},className:x(`relative w-full`,`grid`,`[&_tr]:absolute`,`[&_tr]:flex`,`[&_tr]:flex-none`,`[&_tr]:w-full`,`[&_tr]:cursor-pointer [&_tr]:focus:outline-none`,`[&_tr]:border-b [&_tr]:border-b-border`,`[&_td]:z-10`,`[&_td]:transition-all`,`[&_td]:duration-300`,`[&_td]:flex`,`[&_td]:flex-none`,`[&_td]:overflow-hidden`,`[&_td]:whitespace-nowrap`,`[&_td]:px-4`,`[&_td]:py-2.5`,`[&_td]:align-middle`,`[&_td]:border-border`,`[&_td]:data-[selected=true]:bg-muted-muted!`,`[&_td]:data-[selected=true]:hover:bg-muted-muted!`,`[&_td>div]:inline-flex`,`[&_td>div]:items-center`,`[&_td>div]:w-full`,`[&_td:not([data-pinned=false])]:z-20`,`[&_td:not([data-pinned=false])]:sticky`,`[&_td:not([data-pinned=false])]:bg-card`,`**:data-lastcell:border-r`,`**:data-firstcell:border-l`,t),...r,children:n})});q.displayName=`UITableBody`;const J=w(({row:e,isSelected:t,virtualRowIndex:n,virtualRowStart:r,children:i,...a})=>{let{keyOfClickRow:o,isAllRowsSelected:s,columnPinningState:c,leftPinnedHeaders:l,rightPinnedHeaders:u,onClickRow:d}=Xe(),f=O(()=>c.left??[],[c]),p=O(()=>c.right??[],[c]),m=O(()=>u?.[0]?.id,[u]),h=O(()=>l?.[l.length-1]?.id,[l]),g=E(t=>{let r=o?e.original?.[o]:void 0;d?.(n,typeof r==`string`||typeof r==`number`?r:void 0),t.preventDefault(),t.stopPropagation()},[o,d,e,n]);return j(`tr`,{slot:`table-row`,"data-index":n,style:{transform:`translateY(${r}px)`},className:`group`,onClick:g,...a,children:e.getVisibleCells().map((e,r)=>{let i=f.includes(e.column.id),a=p.includes(e.column.id),o=i?`left`:a?`right`:!1;return e.column.id===`actions`?j(X,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,virtualRowIndex:n,column:e.column,getContext:e.getContext},`${e.id}-${r}`):e.column.id===`select`?j(Y,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isSelected:s||t,onToggleRowSelected:e.row.toggleSelected},`${e.id}-${r}`):j(Z,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isFirstCell:e.column.id===m,isLastCell:e.column.id===h,colId:e.column.id,position:e.column.columnDef.meta?.position??`start`,column:e.column,getContext:e.getContext},`${e.id}-${r}`)})})});J.displayName=`UITableRow`;const Y=w(({isPinned:e,isSelected:t=!1,className:n,onToggleRowSelected:r,...i})=>{let a=E(e=>{r?.(!!e)},[r]);return j(`td`,{slot:`table-body-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:x(`group-hover:bg-muted-bg-subtle!`,e?`sticky`:`relative`,n),...i,children:j(`div`,{"data-slot":`table-cell-inner`,className:`flex! w-full! items-center justify-center bg-transparent text-center align-middle`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:j(v,{"aria-label":`Select Row`,checked:t,onCheckedChange:a})})})});Y.displayName=`UITableCellSelect`;const X=w(({virtualRowIndex:e,column:t,getContext:n,className:r,...i})=>{let a=O(()=>I(t?.columnDef.cell,n()),[t,n]);return j(`td`,{"data-col":`actions`,"data-cell":e,className:`sticky inset-y-0 right-0 z-50 flex items-center pr-4 group-hover:bg-muted-bg-subtle!`,...i,children:a})});X.displayName=`UITableCellActions`;const Z=w(({isPinned:e=!1,isFirstCell:t=!1,isLastCell:n=!1,colId:r,position:i=`start`,column:a,getContext:o,...s})=>{let{innerTableId:c,table:l}=We(),u=k(document.querySelector(`table[id="${c}"]`)),d=k(null),f=O(()=>{let t=a?.getStart(`left`);return e===`left`&&typeof t==`number`?`${t}px`:void 0},[e,a]),p=O(()=>{let t=a?.getAfter(`right`);return e===`right`&&typeof t==`number`?`${t}px`:void 0},[e,a]),m=O(()=>`calc(var(--col-${r}-size) * 1px)`,[r]),h=O(()=>a?.columnDef.minSize?`calc(var(--col-${r}-minSize) * 1px)`:void 0,[r,a]),g=O(()=>a?.columnDef.maxSize?`calc(var(--col-${r}-maxSize) * 1px)`:void 0,[r,a]),_=O(()=>I(a?.columnDef.cell,o()),[a,o]);return D(()=>{if(!d.current)return;let e=d.current.scrollWidth,t=a?.getSize();t&&e>t&&u.current instanceof HTMLTableElement&&typeof r==`string`&&a?.columnDef.meta?.fitContent&&l.setColumnSizing(t=>({...t,[r]:e+32}))},[r,a,l]),j(`td`,{slot:`table-body-cell`,"data-pinned":e,"data-lastcell":n||void 0,"data-firstcell":t||void 0,style:{left:f,right:p,width:m,minWidth:h,maxWidth:g},className:`group-hover:bg-muted-bg-subtle!`,...s,children:j(`div`,{ref:d,slot:`table-body-cell-inner`,className:x(i===`start`&&`justify-start`,i===`center`&&`justify-center`,i===`end`&&`justify-end`),children:_})})});Z.displayName=`UITableCell`;const $e=w(({className:e,children:t,...n})=>j(`tfoot`,{slot:`table-footer`,className:x(`flex w-full justify-center border-border-weak border-t py-2 font-medium [&>tr]:last:border-b-0`,e),...n,children:t}));$e.displayName=`UITableFooter`;const Q=w(({virtualRowIndex:e,virtualRowStart:t,fetchMoreData:n})=>{let{innerWrapperId:r}=He(),i=k(document.querySelector(`div[id="${r}"]`)),a=k(null),[o,s]=A(`idle`),[c,l]=A(0),u=E(async()=>{try{s(`fetching`),await n?.(),s(`idle`)}catch(e){console.error(`Error fetching more data:`,e),s(`error`)}},[n]);return D(()=>{if(!i.current)return;let e=new ResizeObserver(e=>{l(e[0].contentRect.width)});return e.observe(i.current),()=>e.disconnect()},[]),n?j(`tr`,{ref:a,"data-index":e,style:{transform:`translateY(${t}px)`,width:c},className:`sticky! left-0 h-10`,children:j(`td`,{className:`absolute left-0 flex w-full items-center justify-center text-xs`,children:M(`button`,{type:`button`,disabled:o===`fetching`,className:x(`flex cursor-pointer gap-x-0.5`,o===`fetching`&&`cursor-not-allowed`,o===`idle`&&`text-text-positive-weak hover:text-text-positive`,o===`error`&&`text-danger hover:text-danger-strong`),onClick:u,children:[o===`idle`&&j(ie,{className:`size-4`}),o===`fetching`&&j(y,{className:`size-4 animate-spin`}),o===`error`&&j(N,{className:`size-4 text-danger`}),o===`idle`&&`Load More`,o===`fetching`&&`Loading...`,o===`error`&&`Error! Retry?`]})})}):null});Q.displayName=`UITableLoadMore`;const et=()=>{let{table:e,isEmpty:t,isFetching:n,fetchMoreData:r}=R(),{rowSelectionState:i}=Je(),a=k(null),{rows:o}=e.getRowModel(),s=De({count:o.length+1,estimateSize:()=>40,getScrollElement:()=>a.current,measureElement:typeof window<`u`&&navigator.userAgent.indexOf(`Firefox`)===-1?e=>e?.getBoundingClientRect().height:void 0,overscan:2}),c=O(()=>{let e=s.getTotalSize(),t=a.current?.clientHeight||0;return e<t?`${t}px`:`${e}px`},[s.getTotalSize()]);return j(ee,{direction:`horizontal`,style:{direction:e.options.columnResizeDirection},className:`relative flex w-full max-w-full flex-1 gap-1 overflow-auto border-t border-t-border border-r border-r-border bg-slate-50 p-0 text-sm`,children:j(b,{className:`relative`,children:M(H,{ref:a,children:[M(U,{children:[j(W,{children:e.getHeaderGroups().map(e=>j(G,{headerGroup:e},e.id))}),j(q,{height:c,children:s.getVirtualItems().map(e=>{let t=o[e.index],n=Object.entries(i).some(([e,n])=>e===`${t?.id}`&&n);return t?j(J,{ref:s.measureElement,row:t,isSelected:n,virtualRowIndex:e.index,virtualRowStart:e.start},e.index):j(Q,{virtualRowIndex:e.index,virtualRowStart:e.start,fetchMoreData:r},e.index)})})]}),j(V,{isEmpty:t,isFetching:n})]})})})},tt=({checked:e,title:t,onCheckedChange:n})=>M(`div`,{className:`flex h-fit items-center gap-2`,children:[j(v,{checked:e,onCheckedChange:n}),j(`p`,{className:`text-sm`,children:t})]}),nt=()=>{let{table:e}=R(),[n,r]=A(null);return j(b,{defaultSize:25,className:x(`bg-card`,n===null?`max-w-8!`:`min-w-64`),children:M(`div`,{className:`relative z-20 flex size-full bg-muted-bg-subtle`,children:[M(`div`,{className:`flex-1`,children:[j(S,{mode:n===`columns`?`visible`:`hidden`,children:M(`div`,{className:`flex size-full flex-col gap-2 p-4`,children:[j(`p`,{className:`px-2 font-medium`,children:`Columns Visibility`}),j(d,{}),j(`div`,{className:`flex flex-col gap-4 pt-4`,children:e.getAllColumns().map(e=>[`select`,`actions`].includes(e.id)?null:j(tt,{checked:e.getIsVisible(),title:String(e.columnDef.header),onCheckedChange:t=>e.toggleVisibility(!!t)},e.id))})]})}),j(S,{mode:n===`filters`?`visible`:`hidden`,children:j(`div`,{className:`flex size-full flex-col p-2`,children:M(t,{variant:`outline`,color:`muted`,children:[j(de,{}),`Add Filter`]})})})]}),M(`div`,{className:`flex h-full flex-col border-border border-l bg-muted-bg-subtle text-sm`,children:[M(`button`,{className:x(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,n===`columns`&&`bg-card`),onClick:()=>r(n===`columns`?null:`columns`),children:[j(oe,{size:18}),j(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Columns`})]}),j(d,{}),M(`button`,{className:x(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,n===`filters`&&`bg-card`),onClick:()=>r(n===`filters`?null:`filters`),children:[j(ue,{size:18}),j(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Filters`})]}),j(d,{})]})]})})},rt=w(({innerWrapperId:e,children:t})=>{let n=O(()=>({innerWrapperId:e}),[e]);return j(Ve.Provider,{value:n,children:t})});rt.displayName=`UITableInnerWrapperProvider`;const it=w(({table:e,innerTableId:t,totalSize:n,children:r})=>{let i=O(()=>({table:e,innerTableId:t,totalSize:n}),[e,t,n]);return j(Ue.Provider,{value:i,children:r})});it.displayName=`UITableInnerTableProvider`;const at=w(({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i,children:a})=>{let o=O(()=>({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i}),[e,t,n,r,i]);return j(Ge.Provider,{value:o,children:a})});at.displayName=`UITableHeadRowProvider`;const ot=w(({isFetching:e,isEmpty:t,rowSelectionState:n,children:r})=>{let i=O(()=>({isFetching:e,isEmpty:t,rowSelectionState:n}),[e,t,n]);return j(qe.Provider,{value:i,children:r})});ot.displayName=`UITableBodyProvider`;const st=w(({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a,children:o})=>{let s=O(()=>({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a}),[e,t,n,r,i,a]);return j(Ye.Provider,{value:s,children:o})});st.displayName=`UITableRowProvider`;const ct=({title:e,isFetching:t=!1,isRefetching:n=!1,data:r,columns:i,totalRows:a,leftPinnedColumns:o=[],rightPinnedColumns:s=[],keyOfClickRow:c,onClickRow:l,onRowSelection:u,onColumnPinning:d,fetchMoreData:f,children:p})=>{let m=ne(),h=ne(),[g,_]=A({}),[v,y]=A({right:s,left:[`select`,...o]}),[b,ee]=A({}),te=E(e=>(_(e),u?.(e instanceof Function?e(g):e),e),[g,u]),x=E(e=>{y(e),d?.(e instanceof Function?e(v):e)},[v,d]),S=Ee({data:r,columns:i,state:{rowSelection:g,columnPinning:v,expanded:b},defaultColumn:{enableResizing:!1,size:void 0,minSize:void 0,maxSize:void 0},columnResizeMode:`onChange`,columnResizeDirection:`ltr`,enableColumnPinning:!0,enableRowSelection:!0,enableColumnResizing:!0,enableMultiRowSelection:!0,autoResetAll:!1,autoResetExpanded:!1,autoResetPageIndex:!1,getSubRows:e=>e.subRows,getCoreRowModel:Ce(),getGroupedRowModel:Te(),getExpandedRowModel:we(),onRowSelectionChange:te,onColumnPinningChange:x,onExpandedChange:ee}),C=O(()=>{let{rows:e}=S.getRowModel();return e},[S.getRowModel().rows,S.getState().columnPinning]),w=O(()=>!t&&C.length===0,[C,t]),T=O(()=>({title:e,table:S,isEmpty:w,isFetching:t,isRefetching:n,totalRows:a,fetchMoreData:f}),[e,S,w,n,t,a,f,S.getState().columnPinning,S.getState().expanded]),D=O(()=>S.getState(),[S.getState()]),k=O(()=>S.getIsAllRowsSelected(),[S.getIsAllRowsSelected()]),M=O(()=>D.rowSelection,[D.rowSelection]),N=O(()=>D.columnPinning,[D.columnPinning]),P=O(()=>S.getLeftHeaderGroups()[0]?.headers||[],[S.getState().columnPinning]),F=O(()=>S.getRightHeaderGroups()[0]?.headers||[],[S.getState().columnPinning]),re=O(()=>S.getTotalSize(),[S.getTotalSize()]);return j(Ze.Provider,{value:T,children:j(rt,{innerWrapperId:m,children:j(it,{table:S,innerTableId:h,totalSize:re,children:j(at,{isAllRowsSelected:k,columnPinningState:N,leftPinnedHeaders:P,rightPinnedHeaders:F,onToggleAllRowsSelected:S.toggleAllRowsSelected,children:j(ot,{isFetching:t,isEmpty:w,rowSelectionState:M,children:j(st,{keyOfClickRow:c,isAllRowsSelected:k,columnPinningState:N,leftPinnedHeaders:P,rightPinnedHeaders:F,onClickRow:l,children:p})})})})})})},lt=({onSearch:e,onChange:t,...n})=>{let r=Oe(t=>{e?.(t)},500);return M(`div`,{className:`relative w-full max-w-80 flex-1`,children:[j(te,{...n,size:`lg`,type:`search`,placeholder:`Search records...`,className:`flex-1 ps-9 pe-9`,onChange:e=>{t?.(e),r(e.target.value??``)}}),j(`div`,{className:`pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-text-positive-weak peer-disabled:opacity-50`,children:j(ve,{size:16})}),j(`button`,{className:`absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:z-10 focus-visible:border focus-visible:border-primary-strong focus-visible:ring-[3px] focus-visible:ring-primary-weak disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Submit search`,type:`submit`,children:j(P,{size:16,"aria-hidden":`true`})})]})},$=({children:e,disabled:t,onClick:n})=>j(`button`,{type:`button`,disabled:t,className:`flex cursor-pointer items-center gap-x-1 rounded-sm border border-border bg-background p-2.5 text-sm text-text-positive-weak outline-none transition-all hover:shadow-card focus:border-border-emphasis focus:bg-muted-muted active:border-border-emphasis active:bg-muted-muted active:text-text-positive disabled:pointer-events-none disabled:cursor-default disabled:opacity-60 [&_svg]:size-3.5`,onClick:n,children:e}),ut=({onCreate:e,onDownload:t,onRefresh:n})=>M(`div`,{className:`flex [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,children:[j($,{disabled:!e,onClick:t=>{e?.(),t.stopPropagation(),t.preventDefault()},children:j(ae,{})}),j($,{disabled:!n,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:j(_e,{})}),j($,{disabled:!t,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:j(se,{})})]}),dt=({children:e})=>{let{title:t}=R();return M(`div`,{"data-slot":`table-tooltip`,className:`relative m-0 flex w-full flex-0 flex-col flex-wrap items-start space-y-2 p-0 px-2 text-sm`,children:[j(`h3`,{className:`font-semibold text-base text-text-positive`,children:t}),j(`div`,{className:`flex w-full flex-1 justify-between gap-x-2`,children:e})]})};dt.displayName=`TableTooltip`;export{ke as UITableBadgeDisplay,q as UITableBody,Ae as UITableBooleanDisplay,Z as UITableCell,X as UITableCellActions,Y as UITableCellSelect,et as UITableContainer,je as UITableDateDisplay,Me as UITableDescriptionDisplay,V as UITableEmptyDisplay,nt as UITableFilter,$e as UITableFooter,W as UITableHead,K as UITableHeadCell,z as UITableHeadCellOption,B as UITableHeadCellSelect,G as UITableHeadRow,U as UITableInnerTable,H as UITableInnerWrapper,Q as UITableLoadMore,Ne as UITableMoreButton,Pe as UITableNameDisplay,Fe as UITablePermalink,Ie as UITablePhoneNumberDisplay,ct as UITableProvider,Le as UITableRemoveButton,J as UITableRow,ze as UITableStatisticDisplay,dt as UITableTooltip,ut as UITableTooltipActions,lt as UITableTooltipFilter,Be as UITableUserDataDisplay,Qe as UITableWrapper};
1
+ import{t as e}from"../../paragraph-moBSTPmT.mjs";import"../../button.variants-DuuH1O0_.mjs";import{t}from"../../button-B2FJrOBP.mjs";import{t as n}from"../../flex-BP8sTi70.mjs";import{t as r}from"../../date-By93kONr.mjs";import{t as i}from"../../badge-B4Fa7-J3.mjs";import{i as a,n as o,r as s,t as c}from"../../tooltip-B3dTcgcc.mjs";import{n as l,t as u}from"../../avatar-DReNH6rV.mjs";import{t as d}from"../../separator-Bf0gymN4.mjs";import{a as f,d as p,h as m,i as h,r as g,t as _}from"../../dropdown-menu-B8GUTfTp.mjs";import{t as v}from"../../checkbox-Bg2FiuQw.mjs";import{t as y}from"../../spinner-D1v3Bard.mjs";import{n as b,r as ee}from"../../resizable-DXHfkbaz.mjs";import{t as te}from"../../input-DBtIgQB6.mjs";import{cn as x}from"@customafk/react-toolkit/utils";import{Activity as S,createContext as C,memo as w,use as T,useCallback as E,useEffect as D,useId as ne,useMemo as O,useRef as k,useState as A}from"react";import{jsx as j,jsxs as M}from"react/jsx-runtime";import{AlertTriangle as N,ArrowRightIcon as P,BoxIcon as F,CheckIcon as re,ChevronDown as ie,CirclePlus as ae,Columns4Icon as oe,DownloadIcon as se,EllipsisVerticalIcon as ce,ExternalLinkIcon as le,ListFilterIcon as ue,ListFilterPlus as de,MinusIcon as fe,MoreVerticalIcon as pe,MoveLeftIcon as me,MoveRightIcon as he,PinOffIcon as ge,RefreshCwIcon as _e,SearchIcon as ve,Trash2Icon as ye,UserRoundIcon as be,XIcon as xe}from"lucide-react";import{colorHashLight as Se}from"@customafk/react-toolkit/color-hash";import{flexRender as I,getCoreRowModel as Ce,getExpandedRowModel as we,getGroupedRowModel as Te,useReactTable as Ee}from"@tanstack/react-table";import{useVirtualizer as De}from"@tanstack/react-virtual";import{useDebounceCallback as Oe}from"@customafk/react-toolkit/hooks/useDebounceCallback";const L=()=>M(`div`,{className:`flex gap-0 text-text-positive-weak`,children:[j(fe,{size:16}),j(fe,{size:16})]}),ke=({label:e,onClick:t,onRemove:n})=>e?n?M(`div`,{className:`flex w-fit gap-x-0.5 rounded-full border border-border py-1 pr-2 pl-3 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:[e,j(`button`,{className:`cursor-pointer text-text-positive-weak hover:text-text-positive-strong`,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:j(xe,{size:12})})]}):j(`button`,{className:`w-fit rounded-full border border-border px-3 py-1 text-text-positive text-xs shadow-xs`,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:e}):j(L,{}),Ae=({value:e})=>e==null?j(L,{}):e===!1?j(`div`,{className:`text-danger-strong`,children:j(xe,{})}):j(`div`,{className:`text-success-strong`,children:j(re,{})}),je=({date:e})=>e==null?j(L,{}):j(s,{children:M(c,{children:[j(a,{asChild:!0,children:j(i,{className:`h-fit`,children:j(r,{date:e,format:`medium`,className:`font-normal text-white`})})}),j(o,{className:`rounded px-2`,children:j(r,{date:e,format:`full`,showTime:!0,className:`font-medium text-text-negative text-xs`})})]})}),Me=({content:t})=>t==null?j(L,{}):M(c,{children:[j(a,{children:j(e,{variant:`sm`,className:`line-clamp-2 whitespace-pre-line break-all`,children:t})}),j(o,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:M(`div`,{className:`flex flex-col gap-y-2`,children:[j(e,{variant:`xs`,className:`whitespace-pre-line text-wrap break-keep text-text-negative-weak`,children:t}),M(`p`,{className:`w-full text-end`,children:[t.toString().length,` chars`]})]})})]}),Ne=({items:e=[]})=>M(_,{children:[j(m,{asChild:!0,children:j(t,{size:`sm`,variant:`ghost`,color:`secondary`,className:`size-9 rounded-full`,children:j(pe,{})})}),j(g,{children:j(h,{children:e.map(e=>j(f,{className:`px-3`,onSelect:t=>{e.onClick(e.id),t.stopPropagation()},children:e.label},e.id))})})]}),Pe=({name:t})=>t?M(c,{children:[j(a,{children:j(e,{variant:`sm`,className:`line-clamp-2 w-full truncate text-wrap pb-px text-start`,children:t})}),j(o,{align:`start`,className:`h-fit min-w-48 max-w-80 pt-4`,children:M(`div`,{className:`flex flex-col gap-y-2`,children:[j(`p`,{className:`whitespace-pre-line text-wrap break-keep`,children:t}),M(`p`,{className:`w-full text-end`,children:[t.length,` chars`]})]})})]}):j(L,{}),Fe=({href:e,label:t})=>M(`a`,{href:e,target:`_blank`,className:`inline-flex items-center gap-1 truncate text-primary text-sm underline`,rel:`noopener noreferrer`,children:[j(`span`,{children:t||e}),j(le,{size:14})]}),Ie=({value:e})=>M(c,{children:[j(a,{asChild:!0,children:j(`p`,{className:`font-number text-secondary-foreground text-sm tabular-nums`,children:e.replace(/(\d{3})(\d{3})(\d{4})/,`($1) $2-$3`)})}),j(o,{align:`start`,children:j(`p`,{className:`tabular-nums`,children:e.slice(1).replace(/(\d{2})(\d{3})(\d{4})/,`(00) (+84) ($1) $2-$3`)})})]}),Le=({title:e,onClick:n})=>M(c,{children:[j(a,{children:j(t,{type:`button`,variant:`ghost`,color:`danger`,size:`icon`,onClick:E(async e=>{e.preventDefault(),e.stopPropagation(),await n?.()},[n]),children:j(ye,{})})}),j(o,{children:j(`p`,{children:e||`Remove item from list table`})})]}),Re=(e,t,n)=>{let r=10**t;switch(n){case`floor`:return Math.floor(e*r)/r;case`ceil`:return Math.ceil(e*r)/r;default:return Math.round(e*r)/r}},ze=w(({decimalSeparator:e=`.`,groupSeparator:t=`,`,prefix:r,suffix:i,precision:a,roundingMode:o=`round`,showTrailingZeros:s=!1,size:c=`lg`,value:l=0})=>{let u=O(()=>{let e={};return typeof a==`number`&&a>=0&&s&&(e.minimumFractionDigits=a),e.maximumFractionDigits=a,e},[a,s]),d=E(e=>{let t=e;return typeof a==`number`&&a>=0&&(t=Re(e,a,o)),t.toLocaleString(`en-US`,u)},[o,u,a]),f=O(()=>{if(typeof l==`number`)return Number.isNaN(l)||!Number.isFinite(l)?`N/A`:d(l);if(typeof l==`string`){let e=l.trim();if(!e)return`N/A`;let t=Number(e);return Number.isNaN(t)||!Number.isFinite(t)?`N/A`:d(t)}return`N/A`},[l,d]),p=O(()=>e===`.`&&t===`,`?f:f.replace(/,/g,t).replace(/\./g,e),[f,e,t]);return p===`0`||p===`N/A`||!p?j(L,{}):M(n,{padding:`none`,className:x(`font-number text-lg text-secondary-foreground tabular-nums`,c===`xs`&&`text-xs`,c===`sm`&&`text-sm`,c===`md`&&`text-base`,c===`lg`&&`text-lg`,c===`xl`&&`text-xl`),children:[r,j(`p`,{children:p}),i]})});ze.displayName=`UITableStatisticDisplay`;const Be=({uuid:t,username:r,email:i})=>M(n,{wrap:!1,gap:`sm`,padding:`none`,children:[!t&&j(u,{className:`size-10 shadow-card`,children:j(l,{className:`bg-muted-weak`,children:j(be,{size:28,className:`text-text-negative`})})}),t&&j(u,{className:`size-10 shadow-card`,children:j(l,{style:{backgroundColor:Se.hex(t)},children:j(be,{size:28,className:`text-white`})})}),M(n,{vertical:!0,padding:`none`,gap:`none`,align:`start`,children:[j(e,{className:`font-medium text-sm text-text-positive-weak`,children:r??`Unknown User`}),j(e,{variant:`sm`,className:`mt-0! text-text-positive-weak text-xs`,children:i})]})]}),Ve=C(null),He=()=>{let e=T(Ve);if(!e)throw Error(`useTableInnerWrapperContext must be used within a TableInnerWrapperProvider`);return e},Ue=C(null),We=()=>{let e=T(Ue);if(!e)throw Error(`useTableInnerTableContext must be used within a TableInnerTableProvider`);return e},Ge=C(null),Ke=()=>{let e=T(Ge);if(!e)throw Error(`useTableHeaderRowContext must be used within a TableHeaderRowProvider`);return e},qe=C(null),Je=()=>{let e=T(qe);if(!e)throw Error(`useTableBodyContext must be used within a TableBodyProvider`);return e},Ye=C(null),Xe=()=>{let e=T(Ye);if(!e)throw Error(`useTableRowContext must be used within a TableRowProvider`);return e},Ze=C(null),R=()=>{let e=T(Ze);if(!e)throw Error(`useTableContext must be used within a TableProvider`);return e},z=w(({isPinned:e,onLeftPin:t,onRightPin:n,onUnpin:r,className:i})=>{let a=E(()=>{t?.(`left`)},[t]),o=E(()=>{n?.(`right`)},[n]),s=E(()=>{r?.(!1)},[r]);return M(_,{children:[j(m,{asChild:!0,children:j(`button`,{className:x(`absolute right-2 z-10 p-0.5 opacity-0`,`cursor-pointer rounded-full transition-all`,`text-text-positive-weak`,`[&>svg]:size-4`,`group-hover:opacity-100`,`hover:bg-muted-muted hover:text-text-positive`,i),children:j(ce,{})})}),j(g,{align:`end`,className:`w-64 p-4`,children:M(h,{className:`*:data-[slot=dropdown-menu-item]:rounded-xs *:data-[slot=dropdown-menu-item]:p-2`,children:[j(S,{mode:e?`visible`:`hidden`,children:M(f,{onClick:s,children:[!!e&&`Unpin`,j(p,{children:j(ge,{className:`size-4`})})]})}),M(S,{mode:e?`hidden`:`visible`,children:[M(f,{onClick:a,children:[e?`Unpin`:`Pin to Left`,j(p,{children:j(me,{className:`size-4`})})]}),M(f,{onClick:o,children:[e?`Unpin`:`Pin to Right`,j(p,{children:j(he,{className:`size-4`})})]})]})]})})]})});z.displayName=`UITableHeadCellOption`;const B=w(({isPinned:e,isAllRowsSelected:t,style:n,onToggleAllRowsSelected:r,...i})=>{let a=E(e=>{r?.(!!e)},[r]);return j(`th`,{slot:`table-header-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:x(e?`sticky`:`relative`),...i,children:j(`div`,{className:`absolute inset-0 flex items-center justify-center`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:j(v,{"aria-label":`Select All Rows`,checked:t,onCheckedChange:a})})})});B.displayName=`UITableHeadCellSelect`;const V=w(({isEmpty:e,isFetching:t})=>!e&&!t?null:M(`div`,{className:`sticky left-0 flex min-h-96 flex-1 items-center justify-center bg-transparent text-text-positive-weak opacity-100`,children:[t&&M(`div`,{className:`flex flex-col items-center gap-1`,children:[j(y,{className:`size-12`}),j(`p`,{children:`Loading data...`})]}),e&&!t&&M(`div`,{className:`flex flex-col items-center gap-1`,children:[j(F,{strokeWidth:1,size:48}),j(`p`,{children:`No data available`})]})]}));V.displayName=`UITableEmptyDisplay`;const Qe=w(({className:e,children:t,...n})=>j(`div`,{slot:`table-wrapper`,className:x(`relative m-0 flex size-full flex-col flex-nowrap items-start justify-start gap-2`,e),...n,children:t}));Qe.displayName=`UITableWrapper`;const H=w(({children:e,...t})=>{let{innerWrapperId:n}=He();return j(`div`,{id:n,slot:`table-inner-wrapper`,className:`relative size-full overflow-auto border-b border-b-border border-l border-l-border bg-card`,...t,children:e})});H.displayName=`UITableInnerWrapper`;const U=w(({children:e,...t})=>{let{table:n,innerTableId:r,totalSize:i}=We(),a=k(null);return D(()=>{if(!a.current)return;let e=n.getFlatHeaders(),t=new ResizeObserver(t=>{requestAnimationFrame(()=>{let r=t[0].target;if(r instanceof HTMLTableElement){let i=t[0];if(!i)return;let a=i.contentRect.width,{left:o=[],right:s=[]}=n.getState().columnPinning,c=0,l=0,u=0,d=e.map(e=>{let{id:t}=e,n=t===`select`||t===`actions`,r=o.includes(t)||s.includes(t),i=e.getSize(),a=e.column.columnDef.maxSize;return n?(c+=60,{id:t,isFlex:!1,width:60}):r?(c+=i,{id:t,isFlex:!1,width:i}):e.column.columnDef.size||i!==150?(u+=i,{id:t,isFlex:!1,width:i}):(l++,{id:t,isFlex:!0,maxSize:a})}),f=a-c-u,p=l>0?Math.max(0,Math.floor(f/l)):0;d.forEach(e=>{if(e.isFlex){let t=e.maxSize?Math.min(p,e.maxSize):p;r.style.setProperty(`--header-${e.id}-size`,`${t}`),r.style.setProperty(`--col-${e.id}-size`,`${t}`),e.maxSize&&r.style.setProperty(`--col-${e.id}-maxSize`,`${e.maxSize}`)}else r.style.setProperty(`--header-${e.id}-size`,`${e.width}`),r.style.setProperty(`--col-${e.id}-size`,`${e.width}`)})}})});return t.observe(a.current),()=>t.disconnect()},[n.getState().columnSizingInfo,n.getState().columnSizing,n.getState().columnPinning]),j(`table`,{id:r,ref:a,slot:`table-inner-table`,className:`grid w-full table-fixed caption-bottom border-collapse border-spacing-0 flex-col content-start [&_tfoot_td]:border-t`,style:{minWidth:i},...t,children:e})});U.displayName=`UITableInnerTable`;const W=w(({className:e,children:t,...n})=>j(`thead`,{slot:`table-head`,className:x(`sticky top-0 z-20 h-9 w-full`,`grid select-none bg-muted-bg-subtle`,`border-b border-b-border shadow`,`font-medium text-[13px] text-text-positive-weak`,`[&_tr:not(:last-child)_td]:border-b`,`[&_th]:inline-flex`,`[&_th]:items-center`,`[&_th]:transition-all`,`[&_th]:duration-300`,`[&_th]:whitespace-nowrap`,`[&_th]:border-border`,`[&_th]:last:border-r-0`,`[&_th]:first:border-l-0`,`[&_tr_th:not([data-pinned=false])]:bg-muted-bg-subtle`,e),...n,children:t}));W.displayName=`UITableHead`;const G=w(({headerGroup:e,className:t,...n})=>{let{isAllRowsSelected:r,columnPinningState:i,leftPinnedHeaders:a,rightPinnedHeaders:o,onToggleAllRowsSelected:s}=Ke(),c=o[0]?.id,l=a[a.length-1]?.id;return j(`tr`,{slot:`table-head-row`,className:x(`flex`,t),...n,children:e.headers.map((e,t)=>{let n=e.column.getIsVisible(),a=i.left?.includes(e.id)?`left`:i.right?.includes(e.id)?`right`:!1;return e.id===`select`?j(B,{isPinned:a,isAllRowsSelected:r,onToggleAllRowsSelected:s},e.id):j(K,{isVisible:n,isPinned:a,isFirstCell:e.id===c,isLastCell:e.id===l,isOptionsVisible:![`select`,`actions`].includes(e.id),headerId:e.id,headerColumn:e.column,colSpan:e.colSpan,onColumnPin:e.column.pin,onToggleVisibility:e.column.toggleVisibility,children:I(e.column.columnDef.header,e.getContext())},`${e.id}-${t}`)})})});G.displayName=`UITableHeadRow`;const K=w(({isVisible:e=!0,isPinned:t=!1,isFirstCell:n=!1,isLastCell:r=!1,isOptionsVisible:i=!0,headerId:a,headerColumn:o,className:s,children:c,onColumnPin:l,onToggleVisibility:u,...d})=>{let f=O(()=>t?20:void 0,[t]),p=O(()=>{let e=o?.getStart?.(`left`);return t===`left`&&typeof e==`number`?`${e}px`:void 0},[t,o]),m=O(()=>{let e=o?.getAfter?.(`right`);return t===`right`&&typeof e==`number`?`${e}px`:void 0},[t,o]),h=O(()=>`calc(var(--header-${a}-size) * 1px)`,[a]),g=O(()=>o?.columnDef.minSize?`calc(var(--col-${a}-minSize) * 1px)`:void 0,[a,o]),_=O(()=>o?.columnDef.maxSize?`calc(var(--col-${a}-maxSize) * 1px)`:void 0,[a,o]);return M(`th`,{slot:`table-head-cell`,"data-pinned":t,"data-header":a,style:{zIndex:f,left:p,right:m,width:h,minWidth:g,maxWidth:_},className:x(`group flex`,t?`sticky`:`relative`,t===`left`&&r&&`border-r border-r-border`,t===`right`&&n&&`border-l border-l-border`,o?.columnDef.meta?.position===`center`&&`justify-center`,o?.columnDef.meta?.position===`end`&&`justify-end`,o?.columnDef.meta?.position===`start`&&`justify-start`,s),...d,children:[j(`div`,{className:`truncate pl-4`,children:c}),i&&j(z,{isPinned:t,isVisible:e,onLeftPin:l,onRightPin:l,onUnpin:l})]})});K.displayName=`UITableHeadCell`;const q=w(({height:e,className:t,children:n,...r})=>{let{isFetching:i,isEmpty:a}=Je();return a||i?null:j(`tbody`,{slot:`table-body`,style:{height:e},className:x(`relative w-full`,`grid`,`[&_tr]:absolute`,`[&_tr]:flex`,`[&_tr]:flex-none`,`[&_tr]:w-full`,`[&_tr]:cursor-pointer [&_tr]:focus:outline-none`,`[&_tr]:border-b [&_tr]:border-b-border`,`[&_td]:z-10`,`[&_td]:transition-all`,`[&_td]:duration-300`,`[&_td]:flex`,`[&_td]:flex-none`,`[&_td]:overflow-hidden`,`[&_td]:whitespace-nowrap`,`[&_td]:px-4`,`[&_td]:py-2.5`,`[&_td]:align-middle`,`[&_td]:border-border`,`[&_td]:data-[selected=true]:bg-muted-muted!`,`[&_td]:data-[selected=true]:hover:bg-muted-muted!`,`[&_td>div]:inline-flex`,`[&_td>div]:items-center`,`[&_td>div]:w-full`,`[&_td:not([data-pinned=false])]:z-20`,`[&_td:not([data-pinned=false])]:sticky`,`[&_td:not([data-pinned=false])]:bg-card`,`**:data-lastcell:border-r`,`**:data-firstcell:border-l`,t),...r,children:n})});q.displayName=`UITableBody`;const J=w(({row:e,isSelected:t,virtualRowIndex:n,virtualRowStart:r,children:i,...a})=>{let{keyOfClickRow:o,isAllRowsSelected:s,columnPinningState:c,leftPinnedHeaders:l,rightPinnedHeaders:u,onClickRow:d}=Xe(),f=O(()=>c.left??[],[c]),p=O(()=>c.right??[],[c]),m=O(()=>u?.[0]?.id,[u]),h=O(()=>l?.[l.length-1]?.id,[l]),g=E(t=>{let r=o?e.original?.[o]:void 0;d?.(n,typeof r==`string`||typeof r==`number`?r:void 0),t.preventDefault(),t.stopPropagation()},[o,d,e,n]);return j(`tr`,{slot:`table-row`,"data-index":n,style:{transform:`translateY(${r}px)`},className:`group`,onClick:g,...a,children:e.getVisibleCells().map((e,r)=>{let i=f.includes(e.column.id),a=p.includes(e.column.id),o=i?`left`:a?`right`:!1;return e.column.id===`actions`?j(X,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,virtualRowIndex:n,column:e.column,getContext:e.getContext},`${e.id}-${r}`):e.column.id===`select`?j(Y,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isSelected:s||t,onToggleRowSelected:e.row.toggleSelected},`${e.id}-${r}`):j(Z,{"data-col":e.column.id,"data-cell":n,"data-selected":t||void 0,isPinned:o,isFirstCell:e.column.id===m,isLastCell:e.column.id===h,colId:e.column.id,position:e.column.columnDef.meta?.position??`start`,column:e.column,getContext:e.getContext},`${e.id}-${r}`)})})});J.displayName=`UITableRow`;const Y=w(({isPinned:e,isSelected:t=!1,className:n,onToggleRowSelected:r,...i})=>{let a=E(e=>{r?.(!!e)},[r]);return j(`td`,{slot:`table-body-cell`,"data-pinned":!0,style:{left:0,zIndex:20,width:60,maxWidth:60},className:x(`group-hover:bg-muted-bg-subtle!`,e?`sticky`:`relative`,n),...i,children:j(`div`,{"data-slot":`table-cell-inner`,className:`flex! w-full! items-center justify-center bg-transparent text-center align-middle`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:j(v,{"aria-label":`Select Row`,checked:t,onCheckedChange:a})})})});Y.displayName=`UITableCellSelect`;const X=w(({virtualRowIndex:e,column:t,getContext:n,className:r,...i})=>{let a=O(()=>I(t?.columnDef.cell,n()),[t,n]);return j(`td`,{"data-col":`actions`,"data-cell":e,className:`sticky inset-y-0 right-0 z-50 flex items-center pr-4 group-hover:bg-muted-bg-subtle!`,...i,children:a})});X.displayName=`UITableCellActions`;const Z=w(({isPinned:e=!1,isFirstCell:t=!1,isLastCell:n=!1,colId:r,position:i=`start`,column:a,getContext:o,...s})=>{let{innerTableId:c,table:l}=We(),u=k(document.querySelector(`table[id="${c}"]`)),d=k(null),f=O(()=>{let t=a?.getStart(`left`);return e===`left`&&typeof t==`number`?`${t}px`:void 0},[e,a]),p=O(()=>{let t=a?.getAfter(`right`);return e===`right`&&typeof t==`number`?`${t}px`:void 0},[e,a]),m=O(()=>`calc(var(--col-${r}-size) * 1px)`,[r]),h=O(()=>a?.columnDef.minSize?`calc(var(--col-${r}-minSize) * 1px)`:void 0,[r,a]),g=O(()=>a?.columnDef.maxSize?`calc(var(--col-${r}-maxSize) * 1px)`:void 0,[r,a]),_=O(()=>I(a?.columnDef.cell,o()),[a,o]);return D(()=>{if(!d.current)return;let e=d.current.scrollWidth,t=a?.getSize();t&&e>t&&u.current instanceof HTMLTableElement&&typeof r==`string`&&a?.columnDef.meta?.fitContent&&l.setColumnSizing(t=>({...t,[r]:e+32}))},[r,a,l]),j(`td`,{slot:`table-body-cell`,"data-pinned":e,"data-lastcell":n||void 0,"data-firstcell":t||void 0,style:{left:f,right:p,width:m,minWidth:h,maxWidth:g},className:`group-hover:bg-muted-bg-subtle!`,...s,children:j(`div`,{ref:d,slot:`table-body-cell-inner`,className:x(i===`start`&&`justify-start`,i===`center`&&`justify-center`,i===`end`&&`justify-end`),children:_})})});Z.displayName=`UITableCell`;const $e=w(({className:e,children:t,...n})=>j(`tfoot`,{slot:`table-footer`,className:x(`flex w-full justify-center border-border-weak border-t py-2 font-medium [&>tr]:last:border-b-0`,e),...n,children:t}));$e.displayName=`UITableFooter`;const Q=w(({virtualRowIndex:e,virtualRowStart:t,fetchMoreData:n})=>{let{innerWrapperId:r}=He(),i=k(document.querySelector(`div[id="${r}"]`)),a=k(null),[o,s]=A(`idle`),[c,l]=A(0),u=E(async()=>{try{s(`fetching`),await n?.(),s(`idle`)}catch(e){console.error(`Error fetching more data:`,e),s(`error`)}},[n]);return D(()=>{if(!i.current)return;let e=new ResizeObserver(e=>{l(e[0].contentRect.width)});return e.observe(i.current),()=>e.disconnect()},[]),n?j(`tr`,{ref:a,"data-index":e,style:{transform:`translateY(${t}px)`,width:c},className:`sticky! left-0 h-10`,children:j(`td`,{className:`absolute left-0 flex w-full items-center justify-center text-xs`,children:M(`button`,{type:`button`,disabled:o===`fetching`,className:x(`flex cursor-pointer gap-x-0.5`,o===`fetching`&&`cursor-not-allowed`,o===`idle`&&`text-text-positive-weak hover:text-text-positive`,o===`error`&&`text-danger hover:text-danger-strong`),onClick:u,children:[o===`idle`&&j(ie,{className:`size-4`}),o===`fetching`&&j(y,{className:`size-4 animate-spin`}),o===`error`&&j(N,{className:`size-4 text-danger`}),o===`idle`&&`Load More`,o===`fetching`&&`Loading...`,o===`error`&&`Error! Retry?`]})})}):null});Q.displayName=`UITableLoadMore`;const et=()=>{let{table:e,isEmpty:t,isFetching:n,fetchMoreData:r}=R(),{rowSelectionState:i}=Je(),a=k(null),{rows:o}=e.getRowModel(),s=De({count:o.length+1,estimateSize:()=>40,getScrollElement:()=>a.current,measureElement:typeof window<`u`&&navigator.userAgent.indexOf(`Firefox`)===-1?e=>e?.getBoundingClientRect().height:void 0,overscan:2}),c=O(()=>{let e=s.getTotalSize(),t=a.current?.clientHeight||0;return e<t?`${t}px`:`${e}px`},[s.getTotalSize()]);return j(ee,{direction:`horizontal`,style:{direction:e.options.columnResizeDirection},className:`relative flex w-full max-w-full flex-1 gap-1 overflow-auto border-t border-t-border border-r border-r-border bg-slate-50 p-0 text-sm`,children:j(b,{className:`relative`,children:M(H,{ref:a,children:[M(U,{children:[j(W,{children:e.getHeaderGroups().map(e=>j(G,{headerGroup:e},e.id))}),j(q,{height:c,children:s.getVirtualItems().map(e=>{let t=o[e.index],n=Object.entries(i).some(([e,n])=>e===`${t?.id}`&&n);return t?j(J,{ref:s.measureElement,row:t,isSelected:n,virtualRowIndex:e.index,virtualRowStart:e.start},e.index):j(Q,{virtualRowIndex:e.index,virtualRowStart:e.start,fetchMoreData:r},e.index)})})]}),j(V,{isEmpty:t,isFetching:n})]})})})},tt=({checked:e,title:t,onCheckedChange:n})=>M(`div`,{className:`flex h-fit items-center gap-2`,children:[j(v,{checked:e,onCheckedChange:n}),j(`p`,{className:`text-sm`,children:t})]}),nt=()=>{let{table:e}=R(),[n,r]=A(null);return j(b,{defaultSize:25,className:x(`bg-card`,n===null?`max-w-8!`:`min-w-64`),children:M(`div`,{className:`relative z-20 flex size-full bg-muted-bg-subtle`,children:[M(`div`,{className:`flex-1`,children:[j(S,{mode:n===`columns`?`visible`:`hidden`,children:M(`div`,{className:`flex size-full flex-col gap-2 p-4`,children:[j(`p`,{className:`px-2 font-medium`,children:`Columns Visibility`}),j(d,{}),j(`div`,{className:`flex flex-col gap-4 pt-4`,children:e.getAllColumns().map(e=>[`select`,`actions`].includes(e.id)?null:j(tt,{checked:e.getIsVisible(),title:String(e.columnDef.header),onCheckedChange:t=>e.toggleVisibility(!!t)},e.id))})]})}),j(S,{mode:n===`filters`?`visible`:`hidden`,children:j(`div`,{className:`flex size-full flex-col p-2`,children:M(t,{variant:`outline`,color:`muted`,children:[j(de,{}),`Add Filter`]})})})]}),M(`div`,{className:`flex h-full flex-col border-border border-l bg-muted-bg-subtle text-sm`,children:[M(`button`,{className:x(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,n===`columns`&&`bg-card`),onClick:()=>r(n===`columns`?null:`columns`),children:[j(oe,{size:18}),j(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Columns`})]}),j(d,{}),M(`button`,{className:x(`flex h-32 cursor-pointer flex-col items-center gap-y-2 p-2 py-4`,n===`filters`&&`bg-card`),onClick:()=>r(n===`filters`?null:`filters`),children:[j(ue,{size:18}),j(`span`,{className:`text-nowrap [writing-mode:vertical-lr]`,children:`Filters`})]}),j(d,{})]})]})})},rt=w(({innerWrapperId:e,children:t})=>{let n=O(()=>({innerWrapperId:e}),[e]);return j(Ve.Provider,{value:n,children:t})});rt.displayName=`UITableInnerWrapperProvider`;const it=w(({table:e,innerTableId:t,totalSize:n,children:r})=>{let i=O(()=>({table:e,innerTableId:t,totalSize:n}),[e,t,n]);return j(Ue.Provider,{value:i,children:r})});it.displayName=`UITableInnerTableProvider`;const at=w(({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i,children:a})=>{let o=O(()=>({isAllRowsSelected:e,columnPinningState:t,leftPinnedHeaders:n,rightPinnedHeaders:r,onToggleAllRowsSelected:i}),[e,t,n,r,i]);return j(Ge.Provider,{value:o,children:a})});at.displayName=`UITableHeadRowProvider`;const ot=w(({isFetching:e,isEmpty:t,rowSelectionState:n,children:r})=>{let i=O(()=>({isFetching:e,isEmpty:t,rowSelectionState:n}),[e,t,n]);return j(qe.Provider,{value:i,children:r})});ot.displayName=`UITableBodyProvider`;const st=w(({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a,children:o})=>{let s=O(()=>({keyOfClickRow:e,isAllRowsSelected:t,columnPinningState:n,leftPinnedHeaders:r,rightPinnedHeaders:i,onClickRow:a}),[e,t,n,r,i,a]);return j(Ye.Provider,{value:s,children:o})});st.displayName=`UITableRowProvider`;const ct=({title:e,isFetching:t=!1,isRefetching:n=!1,data:r,columns:i,totalRows:a,leftPinnedColumns:o=[],rightPinnedColumns:s=[],keyOfClickRow:c,onClickRow:l,onRowSelection:u,onColumnPinning:d,fetchMoreData:f,children:p})=>{let m=ne(),h=ne(),[g,_]=A({}),[v,y]=A({right:s,left:[`select`,...o]}),[b,ee]=A({}),te=E(e=>(_(e),u?.(e instanceof Function?e(g):e),e),[g,u]),x=E(e=>{y(e),d?.(e instanceof Function?e(v):e)},[v,d]),S=Ee({data:r,columns:i,state:{rowSelection:g,columnPinning:v,expanded:b},defaultColumn:{enableResizing:!1,size:void 0,minSize:void 0,maxSize:void 0},columnResizeMode:`onChange`,columnResizeDirection:`ltr`,enableColumnPinning:!0,enableRowSelection:!0,enableColumnResizing:!0,enableMultiRowSelection:!0,autoResetAll:!1,autoResetExpanded:!1,autoResetPageIndex:!1,getSubRows:e=>e.subRows,getCoreRowModel:Ce(),getGroupedRowModel:Te(),getExpandedRowModel:we(),onRowSelectionChange:te,onColumnPinningChange:x,onExpandedChange:ee}),C=O(()=>{let{rows:e}=S.getRowModel();return e},[S.getRowModel().rows,S.getState().columnPinning]),w=O(()=>!t&&C.length===0,[C,t]),T=O(()=>({title:e,table:S,isEmpty:w,isFetching:t,isRefetching:n,totalRows:a,fetchMoreData:f}),[e,S,w,n,t,a,f,S.getState().columnPinning,S.getState().expanded]),D=O(()=>S.getState(),[S.getState()]),k=O(()=>S.getIsAllRowsSelected(),[S.getIsAllRowsSelected()]),M=O(()=>D.rowSelection,[D.rowSelection]),N=O(()=>D.columnPinning,[D.columnPinning]),P=O(()=>S.getLeftHeaderGroups()[0]?.headers||[],[S.getState().columnPinning]),F=O(()=>S.getRightHeaderGroups()[0]?.headers||[],[S.getState().columnPinning]),re=O(()=>S.getTotalSize(),[S.getTotalSize()]);return j(Ze.Provider,{value:T,children:j(rt,{innerWrapperId:m,children:j(it,{table:S,innerTableId:h,totalSize:re,children:j(at,{isAllRowsSelected:k,columnPinningState:N,leftPinnedHeaders:P,rightPinnedHeaders:F,onToggleAllRowsSelected:S.toggleAllRowsSelected,children:j(ot,{isFetching:t,isEmpty:w,rowSelectionState:M,children:j(st,{keyOfClickRow:c,isAllRowsSelected:k,columnPinningState:N,leftPinnedHeaders:P,rightPinnedHeaders:F,onClickRow:l,children:p})})})})})})},lt=({onSearch:e,onChange:t,...n})=>{let r=Oe(t=>{e?.(t)},500);return M(`div`,{className:`relative w-full max-w-80 flex-1`,children:[j(te,{...n,size:`lg`,type:`search`,placeholder:`Search records...`,className:`flex-1 ps-9 pe-9`,onChange:e=>{t?.(e),r(e.target.value??``)}}),j(`div`,{className:`pointer-events-none absolute inset-y-0 start-0 flex items-center justify-center ps-3 text-text-positive-weak peer-disabled:opacity-50`,children:j(ve,{size:16})}),j(`button`,{className:`absolute inset-y-0 end-0 flex h-full w-9 items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:z-10 focus-visible:border focus-visible:border-primary-strong focus-visible:ring-[3px] focus-visible:ring-primary-weak disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,"aria-label":`Submit search`,type:`submit`,children:j(P,{size:16,"aria-hidden":`true`})})]})},$=({children:e,disabled:t,onClick:n})=>j(`button`,{type:`button`,disabled:t,className:`flex cursor-pointer items-center gap-x-1 rounded-sm border border-border bg-background p-2.5 text-sm text-text-positive-weak outline-none transition-all hover:shadow-card focus:border-border-emphasis focus:bg-muted-muted active:border-border-emphasis active:bg-muted-muted active:text-text-positive disabled:pointer-events-none disabled:cursor-default disabled:opacity-60 [&_svg]:size-3.5`,onClick:n,children:e}),ut=({onCreate:e,onDownload:t,onRefresh:n})=>M(`div`,{className:`flex [&>*:not(:first-child)]:rounded-l-none [&>*:not(:first-child)]:border-l-0 [&>*:not(:last-child)]:rounded-r-none`,children:[j($,{disabled:!e,onClick:t=>{e?.(),t.stopPropagation(),t.preventDefault()},children:j(ae,{})}),j($,{disabled:!n,onClick:e=>{n?.(),e.stopPropagation(),e.preventDefault()},children:j(_e,{})}),j($,{disabled:!t,onClick:e=>{t?.(),e.stopPropagation(),e.preventDefault()},children:j(se,{})})]}),dt=({children:e})=>{let{title:t}=R();return M(`div`,{"data-slot":`table-tooltip`,className:`relative m-0 flex w-full flex-0 flex-col flex-wrap items-start space-y-2 p-0 px-2 text-sm`,children:[j(`h3`,{className:`font-semibold text-base text-text-positive`,children:t}),j(`div`,{className:`flex w-full flex-1 justify-between gap-x-2`,children:e})]})};dt.displayName=`TableTooltip`;export{ke as UITableBadgeDisplay,q as UITableBody,Ae as UITableBooleanDisplay,Z as UITableCell,X as UITableCellActions,Y as UITableCellSelect,et as UITableContainer,je as UITableDateDisplay,Me as UITableDescriptionDisplay,V as UITableEmptyDisplay,nt as UITableFilter,$e as UITableFooter,W as UITableHead,K as UITableHeadCell,z as UITableHeadCellOption,B as UITableHeadCellSelect,G as UITableHeadRow,U as UITableInnerTable,H as UITableInnerWrapper,Q as UITableLoadMore,Ne as UITableMoreButton,Pe as UITableNameDisplay,Fe as UITablePermalink,Ie as UITablePhoneNumberDisplay,ct as UITableProvider,Le as UITableRemoveButton,J as UITableRow,ze as UITableStatisticDisplay,dt as UITableTooltip,ut as UITableTooltipActions,lt as UITableTooltipFilter,Be as UITableUserDataDisplay,Qe as UITableWrapper};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1,2 +1,2 @@
1
- const e=require(`../../chunk-Bmb41Sf3.cjs`);require(`../../heading-BEm5CCSE.cjs`),require(`../../paragraph-B72bHMf7.cjs`),require(`../../button.variants-rdXrPUao.cjs`);const t=require(`../../button-D0WaocKO.cjs`),n=require(`../../separator-C3ip6sbh.cjs`),r=require(`../../close-D_Ge7gnP.cjs`),i=require(`../../dialog-DjRiV5vR.cjs`),a=require(`../../checkbox-C0fSWwmD.cjs`),o=require(`../../input-BFWWaN-v.cjs`),s=require(`../../popover-DzDrgttC.cjs`),c=require(`../../calendar-CO20ceyB.cjs`),l=require(`../../radio-group-CBhRsUjN.cjs`),u=require(`../../select-2CgwiefV.cjs`),d=require(`../../textarea-COQoSVSc.cjs`);let f=require(`@customafk/react-toolkit/utils`),p=require(`class-variance-authority`),m=require(`react`),h=require(`react/jsx-runtime`),g=require(`lucide-react`),_=require(`@customafk/react-toolkit/date-fns`),v=require(`radix-ui`),y=require(`@tanstack/react-form`);const b=(0,p.cva)([`flex w-fit items-center justify-center rounded-full font-bold text-text-negative-strong`],{variants:{color:{default:`bg-primary-strong`,secondary:`bg-secondary-strong`,success:`bg-success-strong`,info:`bg-info-strong`,warning:`bg-warning-strong`,danger:`border border-danger-strong bg-linear-to-b from-danger-strong/90 via-danger-strong to-danger-strong/90`},size:{xs:`px-1.5 py-0.5 text-xs`,sm:`px-2 py-0.75 text-xs`,md:`px-2.5 py-0.75 text-sm`,lg:`px-3 py-1 text-sm`}},defaultVariants:{color:`default`,size:`sm`}}),x=({label:e,color:t,size:n,className:r,children:i})=>(0,h.jsx)(`div`,{"data-slot":`required-indicator`,className:b({color:t,size:n,className:r}),children:e||i});function S({className:e,children:t,...n}){return(0,h.jsxs)(v.Label.Root,{"data-slot":`label`,className:(0,f.cn)(`text-text-positive`,`flex w-full items-center justify-between`,`select-none font-medium text-sm/6 leading-none`,`group-data-[disabled=true]:pointer-events-none`,`group-data-[disabled=true]:opacity-50`,`peer-disabled:cursor-not-allowed`,`peer-disabled:opacity-50`,`aria-required:*:data-[slot=required-indicator]:inline-block`,e),...n,children:[t,(0,h.jsx)(x,{label:`Required`,color:`danger`,size:`sm`,className:`hidden`})]})}const C=(0,p.cva)(`group/field flex w-full gap-2 data-[invalid=true]:text-danger *:data-[slot=field-content]:gap-0`,{variants:{orientation:{vertical:[`flex-col *:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`*:data-[slot=field-label]:flex-auto`,`has-[>[data-slot=field-content]]:items-start`,`has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col *:w-full [&>.sr-only]:w-auto`,`@md/field-group:flex-row`,`@md/field-group:items-center`,`@md/field-group:gap-4`,`@md/field-group:*:w-auto`,`@md/field-group:*:data-[slot=field-content]:basis-1/2`,`@md/field-group:*:data-[slot=field-content-main]:basis-1/2`,`@md/field-group:*:data-[slot=field-label]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start`,`@md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}}),w=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`fieldset`,{"data-slot":`field-set`,className:(0,f.cn)(`flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,e),...t}));w.displayName=`FieldSet`;const T=(0,m.memo)(({className:e,variant:t=`legend`,...n})=>(0,h.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":t,className:(0,f.cn)(`mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,e),...n}));T.displayName=`FieldLegend`;const E=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-group`,className:(0,f.cn)(`group/field-group @container/field-group`,`flex flex-col gap-7`,`data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,e),...t}));E.displayName=`FieldGroup`;const D=(0,m.memo)(({className:e,orientation:t=`vertical`,...n})=>(0,h.jsx)(`div`,{"data-slot":`field`,"data-orientation":t,className:(0,f.cn)(C({orientation:t}),e),...n}));D.displayName=`Field`;const O=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-content`,className:(0,f.cn)(`group/field-content flex flex-col gap-1.5 leading-snug`,e),...t}));O.displayName=`FieldContent`;const k=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-content-main`,className:(0,f.cn)(`relative`,e),...t})),A=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(S,{"data-slot":`field-label`,className:(0,f.cn)(`group/field-label peer/field-label flex h-6 gap-1 font-medium leading-snug`,`has-[>[data-slot=field]]:w-full`,`has-[>[data-slot=field]]:flex-col`,`has-[>[data-slot=field]]:rounded-md`,`has-[>[data-slot=field]]:border`,`has-[>[data-slot=field]]:border-border`,`has-data-[state=checked]:border-primary`,`*:data-[slot=field]:p-4 group-data-[disabled=true]/field:opacity-50`,e),...t}));A.displayName=`FieldLabel`;const j=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-label`,className:(0,f.cn)(`flex w-fit items-center gap-2 font-medium text-sm leading-snug group-data-[disabled=true]/field:opacity-50`,e),...t}));j.displayName=`FieldTitle`;const M=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`p`,{"data-slot":`field-description`,className:(0,f.cn)(`nth-last-2:-mt-1 font-normal text-text-positive-weak text-xs leading-normal last:mt-0 [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4 [[data-variant=legend]+&]:-mt-1.5`,e),...t}));M.displayName=`FieldDescription`;const N=(0,m.memo)(({isShow:e=!0,className:t,...n})=>e===!1?null:(0,h.jsx)(`div`,{"data-slot":`field-note`,className:(0,f.cn)(`text-wrap rounded border border-primary-muted bg-primary-bg-subtle p-2 text-text-positive-weak text-xs`,t),...n}));N.displayName=`FieldNote`;const P=(0,m.memo)(({children:e,className:t,...r})=>(0,h.jsxs)(`div`,{"data-slot":`field-separator`,"data-content":!!e,className:(0,f.cn)(`relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2`,t),...r,children:[(0,h.jsx)(n.t,{className:`absolute inset-0 top-1/2`}),e&&(0,h.jsx)(`span`,{className:`relative mx-auto block w-fit bg-background px-2 text-text-positive-weak`,"data-slot":`field-separator-content`,children:e})]}));P.displayName=`FieldSeparator`;const F=(0,m.memo)(({className:e,children:t,errors:n,...r})=>{let i=(0,m.useMemo)(()=>t||(n?n?.length===1&&n[0]?.message?(0,h.jsx)(`div`,{className:`flex flex-row items-center justify-start gap-x-0.5`,children:(0,h.jsx)(`p`,{children:n[0]?.code===`invalid_type`?`Không đúng định dạng`:n[0].message})}):(0,h.jsx)(`ul`,{className:`flex list-none flex-col`,children:n.map(e=>typeof e==`string`?(0,h.jsx)(`li`,{children:e},e):e?.message?(0,h.jsx)(`li`,{children:e.message},e.message):null)}):null),[t,n]);return i?(0,h.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:(0,f.cn)(`w-full font-semibold text-danger-strong text-xs`,e),...r,children:i}):null});F.displayName=`FieldError`;const I=({label:e,description:t,options:n,helperText:r,orientation:i})=>{let o=Q(),s=(0,y.useStore)(o.form.store,({isSubmitting:e})=>e);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:i,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(N,{isShow:!!r,children:r})]}),(0,h.jsx)(k,{children:(0,h.jsx)(E,{className:`flex flex-col gap-y-2`,children:n.map(e=>(0,h.jsxs)(D,{orientation:`horizontal`,children:[(0,h.jsx)(a.t,{id:`${o.name}-${e.value}`,name:o.name,checked:o.state.value?.includes(e.value)??!1,disabled:s,onCheckedChange:t=>{if(t&&o.state.value!==null)o.pushValue(e.value);else if(t&&o.state.value===null)o.setValue([e.value]);else if(!t&&o.state.value!==null){let t=o.state.value.indexOf(e.value);t>-1&&o.removeValue(t)}else !t&&o.state.value===null&&o.setValue(null)}}),(0,h.jsx)(A,{htmlFor:`${o.name}-${e.value}`,className:`text-text-positive`,children:e.label})]},e.value))})})]}),(0,h.jsx)(P,{})]})},L=({label:e,description:n,placeholder:r,orientation:i=`responsive`,helperText:a,minDate:o,maxDate:l,required:u})=>{let d=Q(),p=(0,m.useMemo)(()=>u?d.state.value===null:!1,[u,d.state.value]),v=(0,m.useMemo)(()=>d.state.meta.isTouched&&!d.state.meta.isValid,[d.state.meta.isTouched,d.state.meta.isValid]);return(0,h.jsxs)(E,{className:`px-4`,children:[(0,h.jsxs)(D,{orientation:i,"data-invalid":v,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:d.name,"aria-required":p,children:e}),(0,h.jsx)(M,{children:n})]}),(0,h.jsxs)(k,{className:`flex flex-col space-y-1`,children:[(0,h.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,h.jsxs)(s.t,{children:[(0,h.jsx)(s.a,{asChild:!0,children:(0,h.jsxs)(t.t,{variant:`outline`,color:`muted`,size:`lg`,className:(0,f.cn)(`flex items-center justify-between rounded font-normal outline-border`,`hover:bg-transparent`,`focus:outline-1 focus:outline-primary-strong focus:ring-4 focus:ring-primary-weak`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-4`,`data-[state=open]:ring-primary-weak`,d.state.value===null&&`text-text-positive-muted`),children:[(0,h.jsx)(`p`,{children:d.state.value===null?r||`Select date`:(0,_.format)(d.state.value,`PPPP`)}),(0,h.jsx)(g.CalendarDaysIcon,{strokeWidth:1})]})}),(0,h.jsxs)(s.i,{align:`start`,side:`bottom`,className:`flex w-fit min-w-0 overflow-y-auto rounded p-0`,onBlur:d.handleBlur,children:[(0,h.jsxs)(`div`,{className:`flex h-full flex-col space-y-2 border-r border-r-border p-2 [&>button]:justify-start [&>button]:text-sm`,children:[(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfToday)())},children:`Today`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfTomorrow)())},children:`Tomorrow`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfYesterday)())},children:`Yesterday`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),3))},children:`Last 3 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),7))},children:`Last 7 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),30))},children:`Last 30 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.startOfMonth)((0,_.endOfToday)()))},children:`This Month`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.lastDayOfMonth)((0,_.endOfToday)()))},children:`Last Month`})]}),(0,h.jsx)(`div`,{className:`flex flex-1 flex-col`,children:(0,h.jsx)(`div`,{className:`min-w-73 border-b border-b-border p-2`,children:(0,h.jsx)(c.t,{mode:`single`,selected:d.state.value??void 0,hidden:{before:o??new Date(1900,0,1),after:l??new Date(2100,11,31)},onSelect:e=>{e&&d.handleChange(e)}})})})]})]})}),(0,h.jsx)(N,{isShow:!!a,children:a})]})]}),(0,h.jsx)(P,{})]})},R=({label:e,description:t,placeholder:n,helperText:r,orientation:i=`responsive`,showErrorMessage:a=!0,maxLength:s})=>{let{form:c,name:l,state:u,handleBlur:d,handleChange:p}=Q(),_=(0,y.useStore)(c.store,({isSubmitting:e})=>e),v=(0,m.useMemo)(()=>u.meta.isDirty&&u.meta.isTouched&&!u.meta.isValid,[u.meta.isDirty,u.meta.isTouched,u.meta.isValid]),b=(0,m.useCallback)(({target:{value:e}})=>{_||s&&e.length>s||p(e||null)},[_,s,p]),x=(0,m.useCallback)(()=>{_||p(null)},[_,p]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{"data-invalid":v,orientation:i,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:l,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{id:l,name:l,value:u.value===null?``:u.value,"aria-invalid":v,autoComplete:`email`,placeholder:n,className:(0,f.cn)(`pl-9`,_&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:d,onChange:b}),(0,h.jsx)(`div`,{className:`absolute top-0 left-0 flex size-9 items-center justify-center text-muted`,children:(0,h.jsx)(g.AtSignIcon,{size:14})}),(0,h.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:`absolute inset-e-0 inset-y-0 top-3 flex h-fit w-8 cursor-pointer items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:text-text-positive-strong`,onClick:x,children:(0,h.jsx)(g.XIcon,{size:14,"aria-hidden":`true`})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full items-start justify-start`,children:a&&u.meta.isDirty&&(0,h.jsx)(F,{errors:u.meta.errors})}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},z=e=>e?/^-?\d*\.?\d*$/:/^\d*\.?\d*$/,B=e=>Number(e).toLocaleString(),V=(e,t,n)=>{if(n===`none`)return e;let r=10**t,i=e*r;switch(n){case`up`:return Math.ceil(i)/r;case`down`:return Math.floor(i)/r;case`nearest`:return i%1<.1?Math.floor(i)/r:i%1>=.59?Math.ceil(i)/r:(Math.floor(i)+.5)/r;default:return e}},H=({disabled:e=!1,readOnly:t=!1,allowNegative:n=!1,numberAfterDecimalPoint:r=2,roundingRule:i=`none`,value:a=null,unitText:s,decimal:c,placeholder:l,precision:u,wrapperClassName:d,className:p,onChange:g,onValueChange:_,onFocus:v,onBlur:y,...b})=>{let x=(0,m.useRef)(null),S=(0,m.useRef)(null),[C,w]=(0,m.useState)(a?.toString()??null),T=(0,m.useMemo)(()=>c?.[1]??r,[c,r]),E=(0,m.useMemo)(()=>c&&c[0]-c[1],[c]),D=(0,m.useMemo)(()=>z(n),[n]),O=(0,m.useCallback)(e=>{if(!T||e===`-`)return!0;let[t,n=``]=e.split(`.`),r=t.startsWith(`-`)?t.length-1:t.length;return n.length<=T&&r<=(E??1/0)},[T,E]),k=(0,m.useCallback)(e=>{if(e===`0`)return`0`;if(!Number(e))return null;let[t,n=``]=V(parseFloat(e),Math.min(T-1,u||0),i).toString().split(`.`),r=B(t);return n?`${r}.${n}`:r},[T,u,i]),A=(0,m.useCallback)(e=>{let t=e===`0`,n=e===`-`||/^-0+(\.0+)?$/.test(e)||/^-0*\.$/.test(e);if(t){_?.(0),w(e);return}if(n){w(()=>(_?.(0),e));return}},[_]),j=(0,m.useCallback)(e=>{g?.(e);let{value:t}=e.target;if(t===``||t===void 0){_?.(null),w(null);return}A(t),!(!D.test(t)||!O(t))&&(_?.(parseFloat(t)||0),w(t))},[O,g,_,A,D]),M=(0,m.useCallback)(e=>{t||(v?.(e),w(e=>typeof e==`string`?e.replace(/,/g,``):null))},[t,v]),N=(0,m.useCallback)(e=>{t||(y?.(e),w(e=>e===null?null:e===`0`||e===`-`||/^-0+(\.0+)?$/.test(e)||/^-0*\.$/.test(e)?`0`:typeof e==`string`?k(e):null))},[t,k,y]);return(0,m.useEffect)(()=>{let e=document.activeElement===S.current;if(a==null||!D.test(a.toString())||!O(a.toString())){w(null);return}w(t=>e?t:k(a.toString()))},[k,a,O,D]),(0,m.useEffect)(()=>{if(!x.current||!S.current||!s)return;let e=x.current.offsetWidth;S.current.style.setProperty(`padding-right`,`${(e+10)/16}rem`)},[s]),(0,h.jsxs)(`div`,{className:(0,f.cn)(`relative`,d),children:[(0,h.jsx)(o.t,{...b,ref:S,value:C||(t?`0`:``),placeholder:l,disabled:e,readOnly:t,className:(0,f.cn)(`text-end font-number text-sm slashed-zero lining-nums tabular-nums`,t&&`bg-muted text-muted-foreground`,p),onChange:j,onFocus:M,onBlur:N}),s&&(0,h.jsx)(`span`,{ref:x,className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 text-muted-foreground text-sm`,children:s})]})},U=({label:e,description:t,placeholder:n,helperText:r,orientation:i=`responsive`,showErrorMessage:a=!0,rounding:o,decimalPlaces:s,percision:c,unit:l,required:u,allowNegative:d})=>{let p=Q(),_=(0,y.useStore)(p.form.store,({isSubmitting:e})=>e),v=(0,m.useMemo)(()=>p.state.meta.errors,[p.state.meta.errors]),b=(0,m.useMemo)(()=>u?p.state.value===null:!1,[u,p.state.value]),x=(0,m.useCallback)(e=>{_||p.handleChange(e)},[_,p.handleChange]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:i,"data-invalid":p.state.meta.isTouched&&!p.state.meta.isValid,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:p.name,"aria-required":b,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsxs)(`div`,{className:`relative w-full`,children:[(0,h.jsx)(H,{id:p.name,value:p.state.value,"aria-invalid":p.state.meta.isTouched&&!p.state.meta.isValid&&p.state.meta.isDirty,placeholder:n,roundingRule:o,numberAfterDecimalPoint:s,precision:c,unitText:l,allowNegative:d,className:(0,f.cn)(_&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:p.handleBlur,onValueChange:x}),_&&(0,h.jsx)(`div`,{className:`absolute inset-s-2 inset-y-0 top-2.5 text-muted-weak [&>svg]:size-3.5`,children:(0,h.jsx)(g.Loader2Icon,{className:`animate-spin text-primary-strong`})}),p.state.meta.isDirty&&a&&!!v.length&&(0,h.jsx)(`div`,{className:`absolute inset-s-2 inset-y-0 top-2.75 text-danger-strong [&>svg]:size-3.5`,children:(0,h.jsx)(g.BanIcon,{})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full flex-col items-end justify-end`,children:p.state.meta.isDirty&&a&&(0,h.jsx)(F,{errors:v})})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},W=({label:e,description:t,placeholder:n,orientation:r=`responsive`,helperText:i,showErrorMessage:a=!0})=>{let{form:s,name:c,state:l,handleBlur:u,handleChange:d}=Q(),f=(0,y.useStore)(s.store,({isSubmitting:e})=>e),[p,_]=(0,m.useState)(!1),v=(0,m.useMemo)(()=>l.meta.isTouched&&!l.meta.isValid,[l.meta.isTouched,l.meta.isValid]),b=(0,m.useCallback)(()=>_(e=>!e),[]),x=(0,m.useCallback)(({target:{value:e}})=>{f||d(e||null)},[f,d]);return(0,h.jsx)(E,{className:`gap-y-4 px-4`,children:(0,h.jsxs)(D,{"data-invalid":v,orientation:r,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:c,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{id:c,type:p?`text`:`password`,placeholder:n,value:l.value??``,"aria-invalid":v,autoComplete:`new-password`,onBlur:u,onChange:x}),(0,h.jsx)(`button`,{className:`absolute inset-y-0 inset-e-0 flex size-9 items-center justify-center rounded-e-md text-muted outline-none transition-[color,box-shadow] focus:z-10 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,type:`button`,onClick:b,"aria-label":p?`Hide password`:`Show password`,"aria-pressed":p,"aria-controls":`password`,children:p?(0,h.jsx)(g.EyeOffIcon,{size:16,"aria-hidden":`true`}):(0,h.jsx)(g.EyeIcon,{size:16,"aria-hidden":`true`})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full items-start justify-start`,children:a&&(0,h.jsx)(F,{errors:l.meta.errors})}),(0,h.jsx)(N,{isShow:!!i,children:i})]})]})})},G=({label:e,description:t,orientation:n,options:r,helperText:i})=>{let a=Q(),o=(0,y.useStore)(a.form.store,({isSubmitting:e})=>e);return(0,h.jsxs)(E,{className:`px-4`,children:[(0,h.jsxs)(D,{orientation:n,className:`flex-col gap-2`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(N,{isShow:!!i,children:i})]}),(0,h.jsx)(k,{children:(0,h.jsx)(l.t,{defaultValue:a.state.value??void 0,className:`w-full`,onValueChange:a.handleChange,children:r.map(e=>(0,h.jsx)(A,{className:(0,f.cn)(`h-fit`,a.state.value===e.value&&`border-primary-weak! bg-primary-bg-subtle`,o&&`pointer-events-none bg-muted-muted opacity-60`,a.state.value===e.value&&o&&`border-border-strong!`),children:(0,h.jsxs)(D,{orientation:`horizontal`,className:`justify-between rounded p-2!`,children:[(0,h.jsxs)(O,{className:`gap-1!`,children:[(0,h.jsx)(j,{children:e.label}),(0,h.jsx)(M,{className:`text-xs`,children:e.description})]}),(0,h.jsx)(l.n,{value:e.value})]})},e.value))})})]}),(0,h.jsx)(P,{})]})},K=({label:e,description:t,placeholder:n,orientation:r=`responsive`,options:i,helperText:a,required:o=!1})=>{let s=Q(),c=(0,m.useMemo)(()=>s.state.meta.isTouched&&!s.state.meta.isValid,[s.state.meta.isTouched,s.state.meta.isValid]),l=(0,m.useMemo)(()=>o?s.state.value===null:!1,[o,s.state.value]),d=(0,m.useMemo)(()=>s.state.meta.errors,[s.state.meta.errors]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:r,"data-invalid":s.state.meta.isTouched&&!s.state.meta.isValid,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:s.name,"aria-required":l,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{className:`flex flex-col`,children:[(0,h.jsxs)(u.t,{defaultValue:s.state.value||void 0,onValueChange:s.handleChange,children:[(0,h.jsx)(u.s,{"aria-invalid":c?`true`:void 0,onBlur:s.handleBlur,children:(0,h.jsx)(u.c,{placeholder:n})}),(0,h.jsxs)(u.n,{children:[!!i.length&&i.map(e=>(0,h.jsx)(u.i,{value:e.value,children:e.label},e.value)),!i.length&&(0,h.jsxs)(`div`,{className:`flex items-center justify-center gap-x-2 rounded border border-border bg-muted-muted px-4 py-6.5 text-center text-sm text-text-positive-weak`,children:[(0,h.jsx)(g.PackagePlusIcon,{strokeWidth:1}),`No options available`]})]})]}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full flex-col items-end justify-end`,children:(0,h.jsx)(F,{errors:d})}),(0,h.jsx)(N,{isShow:!!a,children:a})]})]}),(0,h.jsx)(P,{})]})};function q({className:e,...t}){return(0,h.jsx)(v.Switch.Root,{"data-slot":`switch`,className:(0,f.cn)(`peer`,`w-8 shrink-0 cursor-pointer items-center rounded-full shadow-xs transition-all`,`inline-flex h-5`,`focus-visible:border-primary-strong`,`focus-visible:ring-primary-weak`,`focus-visible:ring-4`,`disabled:cursor-not-allowed`,`disabled:opacity-50`,`-outline-offset-1 inset-shadow-2xs outline-1`,`data-[state=checked]:bg-primary`,`data-[state=checked]:outline-primary-strong`,`data-[state=unchecked]:bg-muted-weak`,`data-[state=unchecked]:outline-border`,`data-[state=unchecked]:[&_span]:size-4`,`data-[state=unchecked]:[&_span]:translate-x-0.5`,`data-[state=unchecked]:[&_span]:rtl:-translate-x-0.5`,e),...t,children:(0,h.jsx)(v.Switch.Thumb,{"data-slot":`switch-thumb`,className:(0,f.cn)(`block size-4 bg-card shadow-xs`,`pointer-events-none rounded-full ring-0 transition-transform`,`data-[state=checked]:translate-x-[calc(100%-3px)]`,`data-[state=unchecked]:translate-x-0`)})})}const J=({label:e,description:t,helperText:n})=>{let r=Q();return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:`vertical`,className:`relative justify-between gap-y-1`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(j,{className:`cursor-pointer`,children:(0,h.jsx)(`label`,{htmlFor:r.name,children:e})}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(q,{id:r.name,checked:r.state.value??!1,className:`absolute top-1 right-1`,onBlur:r.handleBlur,onCheckedChange:r.handleChange})]}),(0,h.jsx)(N,{isShow:!!n,children:n})]}),(0,h.jsx)(P,{})]})},ee=({label:e,description:t,placeholder:n,helperText:r,counter:i=!1,orientation:a=`responsive`,showClearButton:s=!1,showErrorMessage:c=!0,required:l=!1,maxLength:u})=>{let d=(0,m.useId)(),p=(0,m.useRef)(null),{form:_,name:v,state:b,handleBlur:x,handleChange:S}=Q(),C=(0,y.useStore)(_.store,({isSubmitting:e})=>e),w=s&&!C&&!!b.value&&!b.meta.errors.length,T=b.value?b.value.length:0,j=(0,m.useMemo)(()=>{if(!i)return``;let e=`character${[0,1].includes(T)?``:`s`}`;return i&&u?`${T} / ${u} character${T?`s`:``}`:`${T} ${e}`},[T,i,u]),I=b.meta.isDirty&&b.meta.isTouched&&!b.meta.isValid,L=l?b.value===null:!1,R=u&&T>=u*.8,z=u&&T>=u,B=(0,m.useCallback)(({target:{value:e}})=>{C||i&&u&&e.length>u||S(e||null)},[C,i,u,S]),V=(0,m.useCallback)(()=>{C||(S(null),p.current?.focus())},[C,S]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:a,"data-invalid":I,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{"aria-required":L,htmlFor:d,children:(0,h.jsxs)(`p`,{children:[e,l&&(0,h.jsx)(`span`,{className:`text-danger-strong`,children:` *`})]})}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{ref:p,id:d,name:v,value:b.value??``,"aria-invalid":I,autoComplete:`off`,placeholder:n,autoCapitalize:`none`,autoCorrect:`off`,className:(0,f.cn)(`pr-6`,C&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:x,onChange:B}),w&&(0,h.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:`absolute inset-e-0 inset-y-0 top-3 flex h-fit w-8 cursor-pointer items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:text-text-positive-intense [&>svg]:size-3.5`,onClick:V,children:(0,h.jsx)(g.XIcon,{"aria-hidden":`true`})}),C&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-muted-weak`,children:(0,h.jsx)(g.Loader2Icon,{size:14,className:`animate-spin text-primary-strong`})}),b.meta.isDirty&&c&&!!b.meta.errors.length&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-danger-strong`,children:(0,h.jsx)(g.BanIcon,{"aria-hidden":`true`,size:14})}),(0,h.jsxs)(`div`,{className:`my-1 flex w-full items-start justify-between gap-x-2`,children:[b.meta.isDirty&&c?(0,h.jsx)(F,{className:`flex-1`,errors:b.meta.errors}):(0,h.jsx)(`div`,{}),!!i&&(0,h.jsx)(`p`,{className:(0,f.cn)(`h-4 flex-0 text-nowrap text-end text-xs tabular-nums transition-colors`,z?`font-medium text-danger-strong`:R?`text-warning-strong`:`text-text-positive-weak`),children:j})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},te=(0,m.memo)(({label:e,description:t,placeholder:n,helperText:r,counter:i=!1,orientation:a=`responsive`,showErrorMessage:o=!0,required:s=!1,maxLength:c})=>{let l=(0,m.useId)(),{form:u,state:p,name:_,handleBlur:v,handleChange:b}=Q(),x=(0,y.useStore)(u.store,({isSubmitting:e})=>e),S=p.value?p.value.length:0,C=(0,m.useMemo)(()=>{if(!i)return``;let e=`character${[0,1].includes(S)?``:`s`}`;return i&&c?`${S} / ${c} character${S?`s`:``}`:`${S} ${e}`},[S,i,c]),w=p.meta.isDirty&&p.meta.isTouched&&!p.meta.isValid,T=s?p.value===null:!1,j=p.meta.errors,I=c&&S>=c*.8,L=c&&S>=c,R=(0,m.useCallback)(({target:{value:e}})=>{x||i&&c&&e.length>c||b(e||null)},[x,i,c,b]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:a,"data-invalid":w,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{"aria-required":T,htmlFor:l,children:(0,h.jsxs)(`p`,{children:[e,s&&(0,h.jsx)(`span`,{className:`text-danger-strong`,children:` *`})]})}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(d.t,{id:l,name:_,value:p.value===null?``:p.value,"aria-invalid":w,autoCapitalize:`none`,autoComplete:`off`,placeholder:n,className:(0,f.cn)(x&&`pointer-events-none bg-muted-muted opacity-60`),onChange:R,onBlur:v}),x&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-muted-weak`,children:(0,h.jsx)(g.Loader2Icon,{size:14,className:`animate-spin text-primary-strong`})}),p.meta.isDirty&&o&&!!j.length&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-danger-strong`,children:(0,h.jsx)(g.BanIcon,{size:14})}),(0,h.jsxs)(`div`,{className:`my-1 flex w-full items-start justify-between gap-x-2`,children:[p.meta.isDirty&&o?(0,h.jsx)(F,{className:`flex-1`,errors:p.meta.errors}):(0,h.jsx)(`div`,{}),!!i&&(0,h.jsx)(`p`,{className:(0,f.cn)(`h-4 flex-0 text-nowrap text-end text-xs tabular-nums transition-colors`,L?`font-medium text-danger-strong`:I?`text-warning-strong`:`text-text-positive-weak`),children:C})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})}),ne=({label:e,className:n})=>{let r=$(),i=(0,m.useCallback)(async()=>{await r.handleSubmit({submitAction:`submit`}),r.state.isSubmitSuccessful&&r.reset()},[r]);return(0,h.jsx)(r.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:r,isSubmitting:a})=>(0,h.jsx)(t.t,{type:`button`,size:`md`,disabled:r,isLoading:a,className:(0,f.cn)(`min-h-8 min-w-32`,n),onClick:i,children:e??`Submit`})})},re=({type:e=`create`})=>{let n=$();return(0,h.jsxs)(`div`,{className:`flex h-8 items-center justify-between`,children:[(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(t.t,{color:`muted`,variant:`outline`,type:`button`,size:`md`,disabled:e,className:`h-full min-w-32`,onClick:()=>n.reset(),children:`Cancel`})}),e===`create`&&(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:e,isSubmitting:r})=>(0,h.jsxs)(t.t,{type:`submit`,size:`md`,disabled:e,isLoading:r,className:`h-full min-w-32`,onClick:async()=>{await n.handleSubmit({submitAction:`create`}),n.state.isSubmitSuccessful&&n.reset()},children:[(0,h.jsx)(g.PlusIcon,{}),`Add New`]})}),e===`update`&&(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:e,isSubmitting:r})=>(0,h.jsxs)(t.t,{type:`submit`,size:`md`,disabled:e,isLoading:r,className:`h-full min-w-32`,onClick:async()=>{await n.handleSubmit({submitAction:`update`}),n.state.isSubmitSuccessful&&n.reset()},children:[(0,h.jsx)(g.ArrowDownToLine,{}),`Update`]})})]})};function Y({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,h.jsx)(v.Separator.Root,{"data-slot":`separator`,decorative:n,orientation:t,className:(0,f.cn)(`shrink-0 bg-border-weak`,`data-[orientation=horizontal]:h-px`,`data-[orientation=horizontal]:w-full`,`data-[orientation=vertical]:h-full`,`data-[orientation=vertical]:w-px`,e),...r})}const ie=({title:e,description:n,onDelete:r,children:i})=>(0,h.jsxs)(`section`,{"data-slot":`card-form`,className:`relative flex flex-col rounded-md bg-card pb-4 shadow-card ring-4 ring-border-weak`,children:[(0,h.jsxs)(`div`,{"data-slot":`card-form-header`,className:`flex flex-col space-y-1 p-4`,children:[(0,h.jsx)(`p`,{className:`font-semibold text-lg`,children:e}),!!n&&(0,h.jsx)(`p`,{className:`text-muted text-sm`,children:n})]}),(0,h.jsx)(Y,{}),(0,h.jsx)(`div`,{"data-slot":`card-form-main`,className:`flex flex-col space-y-4 py-4`,children:i}),!!r&&(0,h.jsxs)(t.t,{color:`danger`,variant:`outline`,size:`sm`,className:`absolute top-2 right-2`,onClick:e=>{r?.(),e.preventDefault(),e.stopPropagation()},children:[(0,h.jsx)(g.Trash2Icon,{}),`Remove`]})]}),ae=({children:e})=>(0,h.jsx)(`div`,{"data-slot":`section-form`,className:`flex flex-col space-y-4`,children:e}),X=({...e})=>(0,h.jsx)(`button`,{...e,type:`button`,className:`min-w-40 cursor-pointer rounded-sm border border-border bg-card px-4 py-2 font-semibold text-sm text-text-positive shadow-xs outline-none transition-all hover:opacity-90 focus:border-border focus:ring-3 focus:ring-border/80 focus:ring-offset-2 focus:drop-shadow-none disabled:pointer-events-none disabled:opacity-60 disabled:drop-shadow-none`,children:`Hủy`}),Z=({isSubmitting:e,submitText:t=`Submit`,...n})=>(0,h.jsx)(`button`,{...n,type:`button`,"data-loading":e?`true`:void 0,className:`relative min-h-9.5 min-w-40 cursor-pointer rounded-sm border border-primary-strong bg-primary px-4 py-2 font-semibold text-sm text-text-negative shadow-card outline-none transition-all hover:opacity-90 focus:border-transparent focus:ring-3 focus:ring-primary/80 focus:ring-offset-2 focus:drop-shadow-none disabled:pointer-events-none disabled:opacity-60 disabled:drop-shadow-none data-[loading=true]:pointer-events-none data-[loading=true]:opacity-80`,children:e?(0,h.jsx)(g.Loader2,{size:16,strokeWidth:3,className:`absolute top-1/2 left-1/2 z-10 -translate-x-1/2 -translate-y-1/2 animate-spin`}):t}),oe=({title:e,submitText:t,open:r,onOpenChange:a,children:o})=>{let s=$(),c=(0,m.useCallback)(e=>{e||s.reset(),a?.(e)},[s.reset,a]);return(0,h.jsx)(i.t,{open:r,onOpenChange:c,children:(0,h.jsxs)(i.c,{"data-slot":`dialog-portal`,children:[(0,h.jsx)(i.s,{}),(0,h.jsxs)(i.r,{className:`flex size-full max-h-dvh max-w-dvw flex-col gap-0 overflow-y-auto p-0 shadow-dialog sm:h-auto sm:max-h-[85dvh] sm:max-w-2xl sm:rounded-sm`,children:[(0,h.jsx)(`div`,{"data-slot":`dialog-header`,className:`flex flex-col items-center justify-center gap-2 px-4 py-6 text-center shadow-sm sm:text-left`,children:(0,h.jsx)(i.l,{"data-slot":`dialog-title`,children:e})}),(0,h.jsx)(n.t,{}),(0,h.jsx)(`div`,{"data-slot":`dialog-content`,className:`relative flex flex-col space-y-4 overflow-y-auto p-0 pt-6 max-sm:flex-1 sm:p-4`,children:o}),(0,h.jsx)(n.t,{}),(0,h.jsxs)(`div`,{"data-slot":`dialog-footer`,className:`flex flex-col-reverse items-center justify-between gap-2 px-6 py-4 shadow-sm sm:flex-row sm:justify-end max-sm:[&>button]:w-full`,children:[(0,h.jsx)(s.Subscribe,{selector:e=>({disabled:e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(X,{disabled:e,onClick:()=>{s.reset(),c(!1)}})}),(0,h.jsx)(s.Subscribe,{selector:e=>({isSubmitting:e.isSubmitting,disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit}),children:({isSubmitting:e,disabled:n})=>(0,h.jsx)(Z,{isSubmitting:e,disabled:n,submitText:t,onClick:()=>s.handleSubmit()})})]})]})]})})},se=({label:e,description:t,helperText:n,orientation:r=`responsive`,children:i})=>(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:r,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[i,(0,h.jsx)(N,{isShow:!!n,children:n})]})]}),(0,h.jsx)(P,{})]}),ce=({title:e,open:t,contentClassName:n,onOpenChange:i,children:a})=>{let o=$();return(0,h.jsx)(v.Dialog.Root,{"data-slot":`dialog`,open:t,onOpenChange:i,children:(0,h.jsxs)(v.Dialog.Portal,{"data-slot":`dialog-portal`,children:[(0,h.jsx)(v.Dialog.Overlay,{"data-slot":`dialog-overlay`,className:(0,f.cn)(`fixed inset-0 z-40 bg-black/50 backdrop-blur-sm`,`data-[state=open]:animate-in`,`data-[state=open]:fade-in`,`data-[state=closed]:animate-out`,`data-[state=closed]:fade-out`)}),(0,h.jsx)(v.Dialog.Content,{"data-slot":`dialog-content`,className:(0,f.cn)(`fixed top-4 right-4 z-50 h-[calc(100dvh-2rem)] min-w-sm max-w-xl rounded-md bg-background drop-shadow-lg`,`duration-300`,`data-[state=open]:animate-in`,`data-[state=open]:slide-in-from-right`,`data-[state=open]:fade-in`,`data-[state=closed]:animate-out`,`data-[state=closed]:slide-out-to-right`,`data-[state=closed]:fade-out`),children:(0,h.jsxs)(`section`,{className:`relative flex size-full flex-col`,children:[(0,h.jsx)(`header`,{className:`flex h-14 items-center border-border border-b px-4`,children:(0,h.jsx)(`h2`,{className:`font-semibold text-lg text-primary-strong`,children:e})}),(0,h.jsx)(`div`,{className:(0,f.cn)(`flex flex-1 flex-col overflow-y-auto py-4`,n),children:a}),(0,h.jsxs)(`div`,{className:`flex flex-col space-y-4 border-border border-t px-4 py-2`,children:[(0,h.jsx)(o.Subscribe,{selector:e=>({isSubmitting:e.isSubmitting,disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit}),children:({isSubmitting:e,disabled:t})=>(0,h.jsx)(Z,{isSubmitting:e,disabled:t,className:`w-full`,onClick:()=>o.handleSubmit()})}),(0,h.jsx)(o.Subscribe,{selector:e=>({disabled:e.isPristine||e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(X,{disabled:e,className:`w-full`,onClick:()=>{o.reset(),i?.(!1)}})})]}),(0,h.jsx)(v.Dialog.Close,{asChild:!0,children:(0,h.jsx)(r.t,{className:`absolute top-2 right-2`})})]})})]})})},le=({children:e})=>(0,h.jsx)(`header`,{"data-slot":`section-header`,className:`px-4 pt-2.5 pb-2 font-medium text-base text-text-positive`,children:e}),ue=({children:e})=>(0,h.jsx)(`main`,{"data-slot":`section-main`,className:`relative flex flex-col space-y-4 py-4`,children:e}),de=({title:e,children:t})=>(0,h.jsxs)(`section`,{"data-slot":`section-form`,className:`flex flex-col rounded-md bg-background shadow-card ring-4 ring-border-weak`,children:[(0,h.jsx)(le,{children:e}),(0,h.jsx)(Y,{}),(0,h.jsx)(ue,{children:t})]}),fe=({title:e,description:t,helperText:n})=>(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{className:`gap-0`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(T,{className:`mb-1`,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsx)(N,{isShow:!!n,children:n})]}),(0,h.jsx)(P,{})]}),{fieldContext:pe,formContext:me,useFieldContext:Q,useFormContext:$}=(0,y.createFormHookContexts)(),{useAppForm:he,withForm:ge,withFieldGroup:_e}=(0,y.createFormHook)({fieldContext:pe,formContext:me,fieldComponents:{TextField:ee,TextareaField:te,NumberField:U,EmailField:R,PasswordField:W,SelectField:K,DateField:L,SwitchField:J,RadioGroupField:G,CheckboxField:I,FieldGroup:E,Field:D,FieldContent:O,FieldLabel:A,FieldContentMain:k,FieldSeparator:P,FieldError:F},formComponents:{TanStackDialogForm:oe,TanStackPopoverForm:ce,TanStackContainerForm:ae,TanStackSectionForm:de,TanStackCardForm:ie,TanStackFieldGroup:se,TanStackTitleField:fe,TanStackActionsForm:re,TanStackActionSubmit:ne}});exports.Field=D,exports.FieldContent=O,exports.FieldContentMain=k,exports.FieldError=F,exports.FieldGroup=E,exports.FieldLabel=A,exports.FieldSeparator=P,exports.useTanStackFieldContext=Q,exports.useTanStackForm=he,exports.useTanStackFormContext=$,exports.withTanStackFieldGroup=_e,exports.withTanStackForm=ge;
1
+ const e=require(`../../chunk-Bmb41Sf3.cjs`);require(`../../heading-BEm5CCSE.cjs`),require(`../../paragraph-B72bHMf7.cjs`),require(`../../button.variants-rdXrPUao.cjs`);const t=require(`../../button-CYw2AqT0.cjs`),n=require(`../../separator-C3ip6sbh.cjs`),r=require(`../../close-D_Ge7gnP.cjs`),i=require(`../../dialog-DjRiV5vR.cjs`),a=require(`../../checkbox-C0fSWwmD.cjs`),o=require(`../../input-BFWWaN-v.cjs`),s=require(`../../popover-DzDrgttC.cjs`),c=require(`../../calendar-BwWfk_Zk.cjs`),l=require(`../../radio-group-CBhRsUjN.cjs`),u=require(`../../select-2CgwiefV.cjs`),d=require(`../../textarea-COQoSVSc.cjs`);let f=require(`@customafk/react-toolkit/utils`),p=require(`class-variance-authority`),m=require(`react`),h=require(`react/jsx-runtime`),g=require(`lucide-react`),_=require(`@customafk/react-toolkit/date-fns`),v=require(`radix-ui`),y=require(`@tanstack/react-form`);const b=(0,p.cva)([`flex w-fit items-center justify-center rounded-full font-bold text-text-negative-strong`],{variants:{color:{default:`bg-primary-strong`,secondary:`bg-secondary-strong`,success:`bg-success-strong`,info:`bg-info-strong`,warning:`bg-warning-strong`,danger:`border border-danger-strong bg-linear-to-b from-danger-strong/90 via-danger-strong to-danger-strong/90`},size:{xs:`px-1.5 py-0.5 text-xs`,sm:`px-2 py-0.75 text-xs`,md:`px-2.5 py-0.75 text-sm`,lg:`px-3 py-1 text-sm`}},defaultVariants:{color:`default`,size:`sm`}}),x=({label:e,color:t,size:n,className:r,children:i})=>(0,h.jsx)(`div`,{"data-slot":`required-indicator`,className:b({color:t,size:n,className:r}),children:e||i});function S({className:e,children:t,...n}){return(0,h.jsxs)(v.Label.Root,{"data-slot":`label`,className:(0,f.cn)(`text-text-positive`,`flex w-full items-center justify-between`,`select-none font-medium text-sm/6 leading-none`,`group-data-[disabled=true]:pointer-events-none`,`group-data-[disabled=true]:opacity-50`,`peer-disabled:cursor-not-allowed`,`peer-disabled:opacity-50`,`aria-required:*:data-[slot=required-indicator]:inline-block`,e),...n,children:[t,(0,h.jsx)(x,{label:`Required`,color:`danger`,size:`sm`,className:`hidden`})]})}const C=(0,p.cva)(`group/field flex w-full gap-2 data-[invalid=true]:text-danger *:data-[slot=field-content]:gap-0`,{variants:{orientation:{vertical:[`flex-col *:w-full [&>.sr-only]:w-auto`],horizontal:[`flex-row items-center`,`*:data-[slot=field-label]:flex-auto`,`has-[>[data-slot=field-content]]:items-start`,`has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`],responsive:[`flex-col *:w-full [&>.sr-only]:w-auto`,`@md/field-group:flex-row`,`@md/field-group:items-center`,`@md/field-group:gap-4`,`@md/field-group:*:w-auto`,`@md/field-group:*:data-[slot=field-content]:basis-1/2`,`@md/field-group:*:data-[slot=field-content-main]:basis-1/2`,`@md/field-group:*:data-[slot=field-label]:flex-auto`,`@md/field-group:has-[>[data-slot=field-content]]:items-start`,`@md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px`]}},defaultVariants:{orientation:`vertical`}}),w=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`fieldset`,{"data-slot":`field-set`,className:(0,f.cn)(`flex flex-col gap-6 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3`,e),...t}));w.displayName=`FieldSet`;const T=(0,m.memo)(({className:e,variant:t=`legend`,...n})=>(0,h.jsx)(`legend`,{"data-slot":`field-legend`,"data-variant":t,className:(0,f.cn)(`mb-3 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base`,e),...n}));T.displayName=`FieldLegend`;const E=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-group`,className:(0,f.cn)(`group/field-group @container/field-group`,`flex flex-col gap-7`,`data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4`,e),...t}));E.displayName=`FieldGroup`;const D=(0,m.memo)(({className:e,orientation:t=`vertical`,...n})=>(0,h.jsx)(`div`,{"data-slot":`field`,"data-orientation":t,className:(0,f.cn)(C({orientation:t}),e),...n}));D.displayName=`Field`;const O=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-content`,className:(0,f.cn)(`group/field-content flex flex-col gap-1.5 leading-snug`,e),...t}));O.displayName=`FieldContent`;const k=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-content-main`,className:(0,f.cn)(`relative`,e),...t})),A=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(S,{"data-slot":`field-label`,className:(0,f.cn)(`group/field-label peer/field-label flex h-6 gap-1 font-medium leading-snug`,`has-[>[data-slot=field]]:w-full`,`has-[>[data-slot=field]]:flex-col`,`has-[>[data-slot=field]]:rounded-md`,`has-[>[data-slot=field]]:border`,`has-[>[data-slot=field]]:border-border`,`has-data-[state=checked]:border-primary`,`*:data-[slot=field]:p-4 group-data-[disabled=true]/field:opacity-50`,e),...t}));A.displayName=`FieldLabel`;const j=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`div`,{"data-slot":`field-label`,className:(0,f.cn)(`flex w-fit items-center gap-2 font-medium text-sm leading-snug group-data-[disabled=true]/field:opacity-50`,e),...t}));j.displayName=`FieldTitle`;const M=(0,m.memo)(({className:e,...t})=>(0,h.jsx)(`p`,{"data-slot":`field-description`,className:(0,f.cn)(`nth-last-2:-mt-1 font-normal text-text-positive-weak text-xs leading-normal last:mt-0 [&>a:hover]:text-primary [&>a]:underline [&>a]:underline-offset-4 [[data-variant=legend]+&]:-mt-1.5`,e),...t}));M.displayName=`FieldDescription`;const N=(0,m.memo)(({isShow:e=!0,className:t,...n})=>e===!1?null:(0,h.jsx)(`div`,{"data-slot":`field-note`,className:(0,f.cn)(`text-wrap rounded border border-primary-muted bg-primary-bg-subtle p-2 text-text-positive-weak text-xs`,t),...n}));N.displayName=`FieldNote`;const P=(0,m.memo)(({children:e,className:t,...r})=>(0,h.jsxs)(`div`,{"data-slot":`field-separator`,"data-content":!!e,className:(0,f.cn)(`relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2`,t),...r,children:[(0,h.jsx)(n.t,{className:`absolute inset-0 top-1/2`}),e&&(0,h.jsx)(`span`,{className:`relative mx-auto block w-fit bg-background px-2 text-text-positive-weak`,"data-slot":`field-separator-content`,children:e})]}));P.displayName=`FieldSeparator`;const F=(0,m.memo)(({className:e,children:t,errors:n,...r})=>{let i=(0,m.useMemo)(()=>t||(n?n?.length===1&&n[0]?.message?(0,h.jsx)(`div`,{className:`flex flex-row items-center justify-start gap-x-0.5`,children:(0,h.jsx)(`p`,{children:n[0]?.code===`invalid_type`?`Không đúng định dạng`:n[0].message})}):(0,h.jsx)(`ul`,{className:`flex list-none flex-col`,children:n.map(e=>typeof e==`string`?(0,h.jsx)(`li`,{children:e},e):e?.message?(0,h.jsx)(`li`,{children:e.message},e.message):null)}):null),[t,n]);return i?(0,h.jsx)(`div`,{role:`alert`,"data-slot":`field-error`,className:(0,f.cn)(`w-full font-semibold text-danger-strong text-xs`,e),...r,children:i}):null});F.displayName=`FieldError`;const I=({label:e,description:t,options:n,helperText:r,orientation:i})=>{let o=Q(),s=(0,y.useStore)(o.form.store,({isSubmitting:e})=>e);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:i,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(N,{isShow:!!r,children:r})]}),(0,h.jsx)(k,{children:(0,h.jsx)(E,{className:`flex flex-col gap-y-2`,children:n.map(e=>(0,h.jsxs)(D,{orientation:`horizontal`,children:[(0,h.jsx)(a.t,{id:`${o.name}-${e.value}`,name:o.name,checked:o.state.value?.includes(e.value)??!1,disabled:s,onCheckedChange:t=>{if(t&&o.state.value!==null)o.pushValue(e.value);else if(t&&o.state.value===null)o.setValue([e.value]);else if(!t&&o.state.value!==null){let t=o.state.value.indexOf(e.value);t>-1&&o.removeValue(t)}else !t&&o.state.value===null&&o.setValue(null)}}),(0,h.jsx)(A,{htmlFor:`${o.name}-${e.value}`,className:`text-text-positive`,children:e.label})]},e.value))})})]}),(0,h.jsx)(P,{})]})},L=({label:e,description:n,placeholder:r,orientation:i=`responsive`,helperText:a,minDate:o,maxDate:l,required:u})=>{let d=Q(),p=(0,m.useMemo)(()=>u?d.state.value===null:!1,[u,d.state.value]),v=(0,m.useMemo)(()=>d.state.meta.isTouched&&!d.state.meta.isValid,[d.state.meta.isTouched,d.state.meta.isValid]);return(0,h.jsxs)(E,{className:`px-4`,children:[(0,h.jsxs)(D,{orientation:i,"data-invalid":v,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:d.name,"aria-required":p,children:e}),(0,h.jsx)(M,{children:n})]}),(0,h.jsxs)(k,{className:`flex flex-col space-y-1`,children:[(0,h.jsx)(`div`,{className:`flex w-full flex-col`,children:(0,h.jsxs)(s.t,{children:[(0,h.jsx)(s.a,{asChild:!0,children:(0,h.jsxs)(t.t,{variant:`outline`,color:`muted`,size:`lg`,className:(0,f.cn)(`flex items-center justify-between rounded font-normal outline-border`,`hover:bg-transparent`,`focus:outline-1 focus:outline-primary-strong focus:ring-4 focus:ring-primary-weak`,`data-[state=open]:text-text-positive-muted`,`data-[state=open]:outline-1`,`data-[state=open]:outline-primary-strong`,`data-[state=open]:ring-4`,`data-[state=open]:ring-primary-weak`,d.state.value===null&&`text-text-positive-muted`),children:[(0,h.jsx)(`p`,{children:d.state.value===null?r||`Select date`:(0,_.format)(d.state.value,`PPPP`)}),(0,h.jsx)(g.CalendarDaysIcon,{strokeWidth:1})]})}),(0,h.jsxs)(s.i,{align:`start`,side:`bottom`,className:`flex w-fit min-w-0 overflow-y-auto rounded p-0`,onBlur:d.handleBlur,children:[(0,h.jsxs)(`div`,{className:`flex h-full flex-col space-y-2 border-r border-r-border p-2 [&>button]:justify-start [&>button]:text-sm`,children:[(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfToday)())},children:`Today`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfTomorrow)())},children:`Tomorrow`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.endOfYesterday)())},children:`Yesterday`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),3))},children:`Last 3 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),7))},children:`Last 7 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.subDays)((0,_.endOfToday)(),30))},children:`Last 30 Days`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.startOfMonth)((0,_.endOfToday)()))},children:`This Month`}),(0,h.jsx)(t.t,{variant:`ghost`,color:`muted`,className:`w-32`,onClick:()=>{d.handleChange((0,_.lastDayOfMonth)((0,_.endOfToday)()))},children:`Last Month`})]}),(0,h.jsx)(`div`,{className:`flex flex-1 flex-col`,children:(0,h.jsx)(`div`,{className:`min-w-73 border-b border-b-border p-2`,children:(0,h.jsx)(c.t,{mode:`single`,selected:d.state.value??void 0,hidden:{before:o??new Date(1900,0,1),after:l??new Date(2100,11,31)},onSelect:e=>{e&&d.handleChange(e)}})})})]})]})}),(0,h.jsx)(N,{isShow:!!a,children:a})]})]}),(0,h.jsx)(P,{})]})},R=({label:e,description:t,placeholder:n,helperText:r,orientation:i=`responsive`,showErrorMessage:a=!0,maxLength:s})=>{let{form:c,name:l,state:u,handleBlur:d,handleChange:p}=Q(),_=(0,y.useStore)(c.store,({isSubmitting:e})=>e),v=(0,m.useMemo)(()=>u.meta.isDirty&&u.meta.isTouched&&!u.meta.isValid,[u.meta.isDirty,u.meta.isTouched,u.meta.isValid]),b=(0,m.useCallback)(({target:{value:e}})=>{_||s&&e.length>s||p(e||null)},[_,s,p]),x=(0,m.useCallback)(()=>{_||p(null)},[_,p]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{"data-invalid":v,orientation:i,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:l,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{id:l,name:l,value:u.value===null?``:u.value,"aria-invalid":v,autoComplete:`email`,placeholder:n,className:(0,f.cn)(`pl-9`,_&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:d,onChange:b}),(0,h.jsx)(`div`,{className:`absolute top-0 left-0 flex size-9 items-center justify-center text-muted`,children:(0,h.jsx)(g.AtSignIcon,{size:14})}),(0,h.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:`absolute inset-e-0 inset-y-0 top-3 flex h-fit w-8 cursor-pointer items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:text-text-positive-strong`,onClick:x,children:(0,h.jsx)(g.XIcon,{size:14,"aria-hidden":`true`})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full items-start justify-start`,children:a&&u.meta.isDirty&&(0,h.jsx)(F,{errors:u.meta.errors})}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},z=e=>e?/^-?\d*\.?\d*$/:/^\d*\.?\d*$/,B=e=>Number(e).toLocaleString(),V=(e,t,n)=>{if(n===`none`)return e;let r=10**t,i=e*r;switch(n){case`up`:return Math.ceil(i)/r;case`down`:return Math.floor(i)/r;case`nearest`:return i%1<.1?Math.floor(i)/r:i%1>=.59?Math.ceil(i)/r:(Math.floor(i)+.5)/r;default:return e}},H=({disabled:e=!1,readOnly:t=!1,allowNegative:n=!1,numberAfterDecimalPoint:r=2,roundingRule:i=`none`,value:a=null,unitText:s,decimal:c,placeholder:l,precision:u,wrapperClassName:d,className:p,onChange:g,onValueChange:_,onFocus:v,onBlur:y,...b})=>{let x=(0,m.useRef)(null),S=(0,m.useRef)(null),[C,w]=(0,m.useState)(a?.toString()??null),T=(0,m.useMemo)(()=>c?.[1]??r,[c,r]),E=(0,m.useMemo)(()=>c&&c[0]-c[1],[c]),D=(0,m.useMemo)(()=>z(n),[n]),O=(0,m.useCallback)(e=>{if(!T||e===`-`)return!0;let[t,n=``]=e.split(`.`),r=t.startsWith(`-`)?t.length-1:t.length;return n.length<=T&&r<=(E??1/0)},[T,E]),k=(0,m.useCallback)(e=>{if(e===`0`)return`0`;if(!Number(e))return null;let[t,n=``]=V(parseFloat(e),Math.min(T-1,u||0),i).toString().split(`.`),r=B(t);return n?`${r}.${n}`:r},[T,u,i]),A=(0,m.useCallback)(e=>{let t=e===`0`,n=e===`-`||/^-0+(\.0+)?$/.test(e)||/^-0*\.$/.test(e);if(t){_?.(0),w(e);return}if(n){w(()=>(_?.(0),e));return}},[_]),j=(0,m.useCallback)(e=>{g?.(e);let{value:t}=e.target;if(t===``||t===void 0){_?.(null),w(null);return}A(t),!(!D.test(t)||!O(t))&&(_?.(parseFloat(t)||0),w(t))},[O,g,_,A,D]),M=(0,m.useCallback)(e=>{t||(v?.(e),w(e=>typeof e==`string`?e.replace(/,/g,``):null))},[t,v]),N=(0,m.useCallback)(e=>{t||(y?.(e),w(e=>e===null?null:e===`0`||e===`-`||/^-0+(\.0+)?$/.test(e)||/^-0*\.$/.test(e)?`0`:typeof e==`string`?k(e):null))},[t,k,y]);return(0,m.useEffect)(()=>{let e=document.activeElement===S.current;if(a==null||!D.test(a.toString())||!O(a.toString())){w(null);return}w(t=>e?t:k(a.toString()))},[k,a,O,D]),(0,m.useEffect)(()=>{if(!x.current||!S.current||!s)return;let e=x.current.offsetWidth;S.current.style.setProperty(`padding-right`,`${(e+10)/16}rem`)},[s]),(0,h.jsxs)(`div`,{className:(0,f.cn)(`relative`,d),children:[(0,h.jsx)(o.t,{...b,ref:S,value:C||(t?`0`:``),placeholder:l,disabled:e,readOnly:t,className:(0,f.cn)(`text-end font-number text-sm slashed-zero lining-nums tabular-nums`,t&&`bg-muted text-muted-foreground`,p),onChange:j,onFocus:M,onBlur:N}),s&&(0,h.jsx)(`span`,{ref:x,className:`-translate-y-1/2 pointer-events-none absolute top-1/2 right-2 text-muted-foreground text-sm`,children:s})]})},U=({label:e,description:t,placeholder:n,helperText:r,orientation:i=`responsive`,showErrorMessage:a=!0,rounding:o,decimalPlaces:s,percision:c,unit:l,required:u,allowNegative:d})=>{let p=Q(),_=(0,y.useStore)(p.form.store,({isSubmitting:e})=>e),v=(0,m.useMemo)(()=>p.state.meta.errors,[p.state.meta.errors]),b=(0,m.useMemo)(()=>u?p.state.value===null:!1,[u,p.state.value]),x=(0,m.useCallback)(e=>{_||p.handleChange(e)},[_,p.handleChange]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:i,"data-invalid":p.state.meta.isTouched&&!p.state.meta.isValid,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:p.name,"aria-required":b,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsxs)(`div`,{className:`relative w-full`,children:[(0,h.jsx)(H,{id:p.name,value:p.state.value,"aria-invalid":p.state.meta.isTouched&&!p.state.meta.isValid&&p.state.meta.isDirty,placeholder:n,roundingRule:o,numberAfterDecimalPoint:s,precision:c,unitText:l,allowNegative:d,className:(0,f.cn)(_&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:p.handleBlur,onValueChange:x}),_&&(0,h.jsx)(`div`,{className:`absolute inset-s-2 inset-y-0 top-2.5 text-muted-weak [&>svg]:size-3.5`,children:(0,h.jsx)(g.Loader2Icon,{className:`animate-spin text-primary-strong`})}),p.state.meta.isDirty&&a&&!!v.length&&(0,h.jsx)(`div`,{className:`absolute inset-s-2 inset-y-0 top-2.75 text-danger-strong [&>svg]:size-3.5`,children:(0,h.jsx)(g.BanIcon,{})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full flex-col items-end justify-end`,children:p.state.meta.isDirty&&a&&(0,h.jsx)(F,{errors:v})})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},W=({label:e,description:t,placeholder:n,orientation:r=`responsive`,helperText:i,showErrorMessage:a=!0})=>{let{form:s,name:c,state:l,handleBlur:u,handleChange:d}=Q(),f=(0,y.useStore)(s.store,({isSubmitting:e})=>e),[p,_]=(0,m.useState)(!1),v=(0,m.useMemo)(()=>l.meta.isDirty&&l.meta.isTouched&&!l.meta.isValid,[l.meta.isDirty,l.meta.isTouched,l.meta.isValid]),b=(0,m.useCallback)(()=>_(e=>!e),[]),x=(0,m.useCallback)(({target:{value:e}})=>{f||d(e||null)},[f,d]);return(0,h.jsx)(E,{className:`gap-y-4 px-4`,children:(0,h.jsxs)(D,{"data-invalid":v,orientation:r,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:c,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{id:c,type:p?`text`:`password`,placeholder:n,value:l.value??``,"aria-invalid":v,autoComplete:`new-password`,onBlur:u,onChange:x}),(0,h.jsx)(`button`,{className:`absolute inset-e-0 inset-y-0 flex size-9 items-center justify-center rounded-e-md text-muted outline-none transition-[color,box-shadow] focus:z-10 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50`,type:`button`,onClick:b,"aria-label":p?`Hide password`:`Show password`,"aria-pressed":p,"aria-controls":`password`,children:p?(0,h.jsx)(g.EyeOffIcon,{size:16,"aria-hidden":`true`}):(0,h.jsx)(g.EyeIcon,{size:16,"aria-hidden":`true`})}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full items-start justify-start`,children:a&&l.meta.isDirty&&(0,h.jsx)(F,{errors:l.meta.errors})}),(0,h.jsx)(N,{isShow:!!i,children:i})]})]})})},G=({label:e,description:t,orientation:n,options:r,helperText:i})=>{let a=Q(),o=(0,y.useStore)(a.form.store,({isSubmitting:e})=>e);return(0,h.jsxs)(E,{className:`px-4`,children:[(0,h.jsxs)(D,{orientation:n,className:`flex-col gap-2`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(N,{isShow:!!i,children:i})]}),(0,h.jsx)(k,{children:(0,h.jsx)(l.t,{defaultValue:a.state.value??void 0,className:`w-full`,onValueChange:a.handleChange,children:r.map(e=>(0,h.jsx)(A,{className:(0,f.cn)(`h-fit`,a.state.value===e.value&&`border-primary-weak! bg-primary-bg-subtle`,o&&`pointer-events-none bg-muted-muted opacity-60`,a.state.value===e.value&&o&&`border-border-strong!`),children:(0,h.jsxs)(D,{orientation:`horizontal`,className:`justify-between rounded p-2!`,children:[(0,h.jsxs)(O,{className:`gap-1!`,children:[(0,h.jsx)(j,{children:e.label}),(0,h.jsx)(M,{className:`text-xs`,children:e.description})]}),(0,h.jsx)(l.n,{value:e.value})]})},e.value))})})]}),(0,h.jsx)(P,{})]})},K=({label:e,description:t,placeholder:n,orientation:r=`responsive`,options:i,helperText:a,required:o=!1})=>{let s=Q(),c=(0,m.useMemo)(()=>s.state.meta.isTouched&&!s.state.meta.isValid,[s.state.meta.isTouched,s.state.meta.isValid]),l=(0,m.useMemo)(()=>o?s.state.value===null:!1,[o,s.state.value]),d=(0,m.useMemo)(()=>s.state.meta.errors,[s.state.meta.errors]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:r,"data-invalid":s.state.meta.isTouched&&!s.state.meta.isValid,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{htmlFor:s.name,"aria-required":l,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{className:`flex flex-col`,children:[(0,h.jsxs)(u.t,{defaultValue:s.state.value||void 0,onValueChange:s.handleChange,children:[(0,h.jsx)(u.s,{"aria-invalid":c?`true`:void 0,onBlur:s.handleBlur,children:(0,h.jsx)(u.c,{placeholder:n})}),(0,h.jsxs)(u.n,{children:[!!i.length&&i.map(e=>(0,h.jsx)(u.i,{value:e.value,children:e.label},e.value)),!i.length&&(0,h.jsxs)(`div`,{className:`flex items-center justify-center gap-x-2 rounded border border-border bg-muted-muted px-4 py-6.5 text-center text-sm text-text-positive-weak`,children:[(0,h.jsx)(g.PackagePlusIcon,{strokeWidth:1}),`No options available`]})]})]}),(0,h.jsx)(`div`,{className:`mt-1 flex w-full flex-col items-end justify-end`,children:(0,h.jsx)(F,{errors:d})}),(0,h.jsx)(N,{isShow:!!a,children:a})]})]}),(0,h.jsx)(P,{})]})};function q({className:e,...t}){return(0,h.jsx)(v.Switch.Root,{"data-slot":`switch`,className:(0,f.cn)(`peer`,`w-8 shrink-0 cursor-pointer items-center rounded-full shadow-xs transition-all`,`inline-flex h-5`,`focus-visible:border-primary-strong`,`focus-visible:ring-primary-weak`,`focus-visible:ring-4`,`disabled:cursor-not-allowed`,`disabled:opacity-50`,`-outline-offset-1 inset-shadow-2xs outline-1`,`data-[state=checked]:bg-primary`,`data-[state=checked]:outline-primary-strong`,`data-[state=unchecked]:bg-muted-weak`,`data-[state=unchecked]:outline-border`,`data-[state=unchecked]:[&_span]:size-4`,`data-[state=unchecked]:[&_span]:translate-x-0.5`,`data-[state=unchecked]:[&_span]:rtl:-translate-x-0.5`,e),...t,children:(0,h.jsx)(v.Switch.Thumb,{"data-slot":`switch-thumb`,className:(0,f.cn)(`block size-4 bg-card shadow-xs`,`pointer-events-none rounded-full ring-0 transition-transform`,`data-[state=checked]:translate-x-[calc(100%-3px)]`,`data-[state=unchecked]:translate-x-0`)})})}const J=({label:e,description:t,helperText:n})=>{let r=Q();return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:`vertical`,className:`relative justify-between gap-y-1`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(j,{className:`cursor-pointer`,children:(0,h.jsx)(`label`,{htmlFor:r.name,children:e})}),(0,h.jsx)(M,{children:t}),(0,h.jsx)(q,{id:r.name,checked:r.state.value??!1,className:`absolute top-1 right-1`,onBlur:r.handleBlur,onCheckedChange:r.handleChange})]}),(0,h.jsx)(N,{isShow:!!n,children:n})]}),(0,h.jsx)(P,{})]})},ee=({label:e,description:t,placeholder:n,helperText:r,counter:i=!1,orientation:a=`responsive`,showClearButton:s=!1,showErrorMessage:c=!0,required:l=!1,maxLength:u})=>{let d=(0,m.useId)(),p=(0,m.useRef)(null),{form:_,name:v,state:b,handleBlur:x,handleChange:S}=Q(),C=(0,y.useStore)(_.store,({isSubmitting:e})=>e),w=s&&!C&&!!b.value&&!b.meta.errors.length,T=b.value?b.value.length:0,j=(0,m.useMemo)(()=>{if(!i)return``;let e=`character${[0,1].includes(T)?``:`s`}`;return i&&u?`${T} / ${u} character${T?`s`:``}`:`${T} ${e}`},[T,i,u]),I=b.meta.isDirty&&b.meta.isTouched&&!b.meta.isValid,L=l?b.value===null:!1,R=u&&T>=u*.8,z=u&&T>=u,B=(0,m.useCallback)(({target:{value:e}})=>{C||i&&u&&e.length>u||S(e||null)},[C,i,u,S]),V=(0,m.useCallback)(()=>{C||(S(null),p.current?.focus())},[C,S]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:a,"data-invalid":I,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{"aria-required":L,htmlFor:d,children:(0,h.jsxs)(`p`,{children:[e,l&&(0,h.jsx)(`span`,{className:`text-danger-strong`,children:` *`})]})}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(o.t,{ref:p,id:d,name:v,value:b.value??``,"aria-invalid":I,autoComplete:`off`,placeholder:n,autoCapitalize:`none`,autoCorrect:`off`,className:(0,f.cn)(`pr-6`,C&&`pointer-events-none bg-muted-muted opacity-60`),onBlur:x,onChange:B}),w&&(0,h.jsx)(`button`,{type:`button`,"aria-label":`Clear`,className:`absolute inset-e-0 inset-y-0 top-3 flex h-fit w-8 cursor-pointer items-center justify-center rounded-e-md text-text-positive-weak outline-none transition-[color,box-shadow] hover:text-text-positive focus:text-text-positive-intense [&>svg]:size-3.5`,onClick:V,children:(0,h.jsx)(g.XIcon,{"aria-hidden":`true`})}),C&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-muted-weak`,children:(0,h.jsx)(g.Loader2Icon,{size:14,className:`animate-spin text-primary-strong`})}),b.meta.isDirty&&c&&!!b.meta.errors.length&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-danger-strong`,children:(0,h.jsx)(g.BanIcon,{"aria-hidden":`true`,size:14})}),(0,h.jsxs)(`div`,{className:`my-1 flex w-full items-start justify-between gap-x-2`,children:[b.meta.isDirty&&c?(0,h.jsx)(F,{className:`flex-1`,errors:b.meta.errors}):(0,h.jsx)(`div`,{}),!!i&&(0,h.jsx)(`p`,{className:(0,f.cn)(`h-4 flex-0 text-nowrap text-end text-xs tabular-nums transition-colors`,z?`font-medium text-danger-strong`:R?`text-warning-strong`:`text-text-positive-weak`),children:j})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})},te=(0,m.memo)(({label:e,description:t,placeholder:n,helperText:r,counter:i=!1,orientation:a=`responsive`,showErrorMessage:o=!0,required:s=!1,maxLength:c})=>{let l=(0,m.useId)(),{form:u,state:p,name:_,handleBlur:v,handleChange:b}=Q(),x=(0,y.useStore)(u.store,({isSubmitting:e})=>e),S=p.value?p.value.length:0,C=(0,m.useMemo)(()=>{if(!i)return``;let e=`character${[0,1].includes(S)?``:`s`}`;return i&&c?`${S} / ${c} character${S?`s`:``}`:`${S} ${e}`},[S,i,c]),w=p.meta.isDirty&&p.meta.isTouched&&!p.meta.isValid,T=s?p.value===null:!1,j=p.meta.errors,I=c&&S>=c*.8,L=c&&S>=c,R=(0,m.useCallback)(({target:{value:e}})=>{x||i&&c&&e.length>c||b(e||null)},[x,i,c,b]);return(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:a,"data-invalid":w,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{"aria-required":T,htmlFor:l,children:(0,h.jsxs)(`p`,{children:[e,s&&(0,h.jsx)(`span`,{className:`text-danger-strong`,children:` *`})]})}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(d.t,{id:l,name:_,value:p.value===null?``:p.value,"aria-invalid":w,autoCapitalize:`none`,autoComplete:`off`,placeholder:n,className:(0,f.cn)(x&&`pointer-events-none bg-muted-muted opacity-60`),onChange:R,onBlur:v}),x&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-muted-weak`,children:(0,h.jsx)(g.Loader2Icon,{size:14,className:`animate-spin text-primary-strong`})}),p.meta.isDirty&&o&&!!j.length&&(0,h.jsx)(`div`,{className:`absolute inset-e-2 inset-y-0 top-2.5 text-danger-strong`,children:(0,h.jsx)(g.BanIcon,{size:14})}),(0,h.jsxs)(`div`,{className:`my-1 flex w-full items-start justify-between gap-x-2`,children:[p.meta.isDirty&&o?(0,h.jsx)(F,{className:`flex-1`,errors:p.meta.errors}):(0,h.jsx)(`div`,{}),!!i&&(0,h.jsx)(`p`,{className:(0,f.cn)(`h-4 flex-0 text-nowrap text-end text-xs tabular-nums transition-colors`,L?`font-medium text-danger-strong`:I?`text-warning-strong`:`text-text-positive-weak`),children:C})]}),(0,h.jsx)(N,{isShow:!!r,children:r})]})]}),(0,h.jsx)(P,{})]})}),ne=({label:e,className:n})=>{let r=$(),i=(0,m.useCallback)(async()=>{await r.handleSubmit({submitAction:`submit`}),r.state.isSubmitSuccessful&&r.reset()},[r]);return(0,h.jsx)(r.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:r,isSubmitting:a})=>(0,h.jsx)(t.t,{type:`button`,size:`md`,disabled:r,isLoading:a,className:(0,f.cn)(`min-h-8 min-w-32`,n),onClick:i,children:e??`Submit`})})},re=({type:e=`create`})=>{let n=$();return(0,h.jsxs)(`div`,{className:`flex h-8 items-center justify-between`,children:[(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(t.t,{color:`muted`,variant:`outline`,type:`button`,size:`md`,disabled:e,className:`h-full min-w-32`,onClick:()=>n.reset(),children:`Cancel`})}),e===`create`&&(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:e,isSubmitting:r})=>(0,h.jsxs)(t.t,{type:`submit`,size:`md`,disabled:e,isLoading:r,className:`h-full min-w-32`,onClick:async()=>{await n.handleSubmit({submitAction:`create`}),n.state.isSubmitSuccessful&&n.reset()},children:[(0,h.jsx)(g.PlusIcon,{}),`Add New`]})}),e===`update`&&(0,h.jsx)(n.Subscribe,{selector:e=>({disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit||e.isDefaultValue,isSubmitting:e.isSubmitting}),children:({disabled:e,isSubmitting:r})=>(0,h.jsxs)(t.t,{type:`submit`,size:`md`,disabled:e,isLoading:r,className:`h-full min-w-32`,onClick:async()=>{await n.handleSubmit({submitAction:`update`}),n.state.isSubmitSuccessful&&n.reset()},children:[(0,h.jsx)(g.ArrowDownToLine,{}),`Update`]})})]})};function Y({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,h.jsx)(v.Separator.Root,{"data-slot":`separator`,decorative:n,orientation:t,className:(0,f.cn)(`shrink-0 bg-border-weak`,`data-[orientation=horizontal]:h-px`,`data-[orientation=horizontal]:w-full`,`data-[orientation=vertical]:h-full`,`data-[orientation=vertical]:w-px`,e),...r})}const ie=({title:e,description:n,onDelete:r,children:i})=>(0,h.jsxs)(`section`,{"data-slot":`card-form`,className:`relative flex flex-col rounded-md bg-card pb-4 shadow-card ring-4 ring-border-weak`,children:[(0,h.jsxs)(`div`,{"data-slot":`card-form-header`,className:`flex flex-col space-y-1 p-4`,children:[(0,h.jsx)(`p`,{className:`font-semibold text-lg`,children:e}),!!n&&(0,h.jsx)(`p`,{className:`text-muted text-sm`,children:n})]}),(0,h.jsx)(Y,{}),(0,h.jsx)(`div`,{"data-slot":`card-form-main`,className:`flex flex-col space-y-4 py-4`,children:i}),!!r&&(0,h.jsxs)(t.t,{color:`danger`,variant:`outline`,size:`sm`,className:`absolute top-2 right-2`,onClick:e=>{r?.(),e.preventDefault(),e.stopPropagation()},children:[(0,h.jsx)(g.Trash2Icon,{}),`Remove`]})]}),ae=({children:e})=>(0,h.jsx)(`div`,{"data-slot":`section-form`,className:`flex flex-col space-y-4`,children:e}),X=({...e})=>(0,h.jsx)(`button`,{...e,type:`button`,className:`min-w-40 cursor-pointer rounded-sm border border-border bg-card px-4 py-2 font-semibold text-sm text-text-positive shadow-xs outline-none transition-all hover:opacity-90 focus:border-border focus:ring-3 focus:ring-border/80 focus:ring-offset-2 focus:drop-shadow-none disabled:pointer-events-none disabled:opacity-60 disabled:drop-shadow-none`,children:`Hủy`}),Z=({isSubmitting:e,submitText:t=`Submit`,...n})=>(0,h.jsx)(`button`,{...n,type:`button`,"data-loading":e?`true`:void 0,className:`relative min-h-9.5 min-w-40 cursor-pointer rounded-sm border border-primary-strong bg-primary px-4 py-2 font-semibold text-sm text-text-negative shadow-card outline-none transition-all hover:opacity-90 focus:border-transparent focus:ring-3 focus:ring-primary/80 focus:ring-offset-2 focus:drop-shadow-none disabled:pointer-events-none disabled:opacity-60 disabled:drop-shadow-none data-[loading=true]:pointer-events-none data-[loading=true]:opacity-80`,children:e?(0,h.jsx)(g.Loader2,{size:16,strokeWidth:3,className:`absolute top-1/2 left-1/2 z-10 -translate-x-1/2 -translate-y-1/2 animate-spin`}):t}),oe=({title:e,submitText:t,open:r,onOpenChange:a,children:o})=>{let s=$(),c=(0,m.useCallback)(e=>{e||s.reset(),a?.(e)},[s.reset,a]);return(0,h.jsx)(i.t,{open:r,onOpenChange:c,children:(0,h.jsxs)(i.c,{"data-slot":`dialog-portal`,children:[(0,h.jsx)(i.s,{}),(0,h.jsxs)(i.r,{className:`flex size-full max-h-dvh max-w-dvw flex-col gap-0 overflow-y-auto p-0 shadow-dialog sm:h-auto sm:max-h-[85dvh] sm:max-w-2xl sm:rounded-sm`,children:[(0,h.jsx)(`div`,{"data-slot":`dialog-header`,className:`flex flex-col items-center justify-center gap-2 px-4 py-6 text-center shadow-sm sm:text-left`,children:(0,h.jsx)(i.l,{"data-slot":`dialog-title`,children:e})}),(0,h.jsx)(n.t,{}),(0,h.jsx)(`div`,{"data-slot":`dialog-content`,className:`relative flex flex-col space-y-4 overflow-y-auto p-0 pt-6 max-sm:flex-1 sm:p-4`,children:o}),(0,h.jsx)(n.t,{}),(0,h.jsxs)(`div`,{"data-slot":`dialog-footer`,className:`flex flex-col-reverse items-center justify-between gap-2 px-6 py-4 shadow-sm sm:flex-row sm:justify-end max-sm:[&>button]:w-full`,children:[(0,h.jsx)(s.Subscribe,{selector:e=>({disabled:e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(X,{disabled:e,onClick:()=>{s.reset(),c(!1)}})}),(0,h.jsx)(s.Subscribe,{selector:e=>({isSubmitting:e.isSubmitting,disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit}),children:({isSubmitting:e,disabled:n})=>(0,h.jsx)(Z,{isSubmitting:e,disabled:n,submitText:t,onClick:()=>s.handleSubmit()})})]})]})]})})},se=({label:e,description:t,helperText:n,orientation:r=`responsive`,children:i})=>(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{orientation:r,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(A,{children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsxs)(k,{children:[i,(0,h.jsx)(N,{isShow:!!n,children:n})]})]}),(0,h.jsx)(P,{})]}),ce=({title:e,open:t,contentClassName:n,onOpenChange:i,children:a})=>{let o=$();return(0,h.jsx)(v.Dialog.Root,{"data-slot":`dialog`,open:t,onOpenChange:i,children:(0,h.jsxs)(v.Dialog.Portal,{"data-slot":`dialog-portal`,children:[(0,h.jsx)(v.Dialog.Overlay,{"data-slot":`dialog-overlay`,className:(0,f.cn)(`fixed inset-0 z-40 bg-black/50 backdrop-blur-sm`,`data-[state=open]:animate-in`,`data-[state=open]:fade-in`,`data-[state=closed]:animate-out`,`data-[state=closed]:fade-out`)}),(0,h.jsx)(v.Dialog.Content,{"data-slot":`dialog-content`,className:(0,f.cn)(`fixed top-4 right-4 z-50 h-[calc(100dvh-2rem)] min-w-sm max-w-xl rounded-md bg-background drop-shadow-lg`,`duration-300`,`data-[state=open]:animate-in`,`data-[state=open]:slide-in-from-right`,`data-[state=open]:fade-in`,`data-[state=closed]:animate-out`,`data-[state=closed]:slide-out-to-right`,`data-[state=closed]:fade-out`),children:(0,h.jsxs)(`section`,{className:`relative flex size-full flex-col`,children:[(0,h.jsx)(`header`,{className:`flex h-14 items-center border-border border-b px-4`,children:(0,h.jsx)(`h2`,{className:`font-semibold text-lg text-primary-strong`,children:e})}),(0,h.jsx)(`div`,{className:(0,f.cn)(`flex flex-1 flex-col overflow-y-auto py-4`,n),children:a}),(0,h.jsxs)(`div`,{className:`flex flex-col space-y-4 border-border border-t px-4 py-2`,children:[(0,h.jsx)(o.Subscribe,{selector:e=>({isSubmitting:e.isSubmitting,disabled:e.isPristine||!e.isValid||e.isValidating||e.isSubmitting||!e.canSubmit}),children:({isSubmitting:e,disabled:t})=>(0,h.jsx)(Z,{isSubmitting:e,disabled:t,className:`w-full`,onClick:()=>o.handleSubmit()})}),(0,h.jsx)(o.Subscribe,{selector:e=>({disabled:e.isPristine||e.isSubmitting}),children:({disabled:e})=>(0,h.jsx)(X,{disabled:e,className:`w-full`,onClick:()=>{o.reset(),i?.(!1)}})})]}),(0,h.jsx)(v.Dialog.Close,{asChild:!0,children:(0,h.jsx)(r.t,{className:`absolute top-2 right-2`})})]})})]})})},le=({children:e})=>(0,h.jsx)(`header`,{"data-slot":`section-header`,className:`px-4 pt-2.5 pb-2 font-medium text-base text-text-positive`,children:e}),ue=({children:e})=>(0,h.jsx)(`main`,{"data-slot":`section-main`,className:`relative flex flex-col space-y-4 py-4`,children:e}),de=({title:e,children:t})=>(0,h.jsxs)(`section`,{"data-slot":`section-form`,className:`flex flex-col rounded-md bg-background shadow-card ring-4 ring-border-weak`,children:[(0,h.jsx)(le,{children:e}),(0,h.jsx)(Y,{}),(0,h.jsx)(ue,{children:t})]}),fe=({title:e,description:t,helperText:n})=>(0,h.jsxs)(E,{className:`gap-y-4 px-4`,children:[(0,h.jsxs)(D,{className:`gap-0`,children:[(0,h.jsxs)(O,{children:[(0,h.jsx)(T,{className:`mb-1`,children:e}),(0,h.jsx)(M,{children:t})]}),(0,h.jsx)(N,{isShow:!!n,children:n})]}),(0,h.jsx)(P,{})]}),{fieldContext:pe,formContext:me,useFieldContext:Q,useFormContext:$}=(0,y.createFormHookContexts)(),{useAppForm:he,withForm:ge,withFieldGroup:_e}=(0,y.createFormHook)({fieldContext:pe,formContext:me,fieldComponents:{TextField:ee,TextareaField:te,NumberField:U,EmailField:R,PasswordField:W,SelectField:K,DateField:L,SwitchField:J,RadioGroupField:G,CheckboxField:I,FieldGroup:E,Field:D,FieldContent:O,FieldLabel:A,FieldContentMain:k,FieldSeparator:P,FieldError:F},formComponents:{TanStackDialogForm:oe,TanStackPopoverForm:ce,TanStackContainerForm:ae,TanStackSectionForm:de,TanStackCardForm:ie,TanStackFieldGroup:se,TanStackTitleField:fe,TanStackActionsForm:re,TanStackActionSubmit:ne}});exports.Field=D,exports.FieldContent=O,exports.FieldContentMain=k,exports.FieldError=F,exports.FieldGroup=E,exports.FieldLabel=A,exports.FieldSeparator=P,exports.useTanStackFieldContext=Q,exports.useTanStackForm=he,exports.useTanStackFormContext=$,exports.withTanStackFieldGroup=_e,exports.withTanStackForm=ge;
2
2
  //# sourceMappingURL=index.cjs.map