@wealthx/shadcn 1.0.2 → 1.2.0

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 (300) hide show
  1. package/.turbo/turbo-build.log +235 -138
  2. package/CHANGELOG.md +12 -0
  3. package/README.md +82 -0
  4. package/dist/{chunk-6OJF6XRN.mjs → chunk-24FUO7TD.mjs} +4 -8
  5. package/dist/{chunk-4AJ5HWHD.mjs → chunk-2I5S2AMY.mjs} +3 -3
  6. package/dist/chunk-2SF672SZ.mjs +161 -0
  7. package/dist/{chunk-GPRJQ24C.mjs → chunk-34NWQURD.mjs} +2 -2
  8. package/dist/{chunk-MQ72DIBH.mjs → chunk-3GF7OVTP.mjs} +14 -5
  9. package/dist/chunk-3WMX6KWS.mjs +245 -0
  10. package/dist/{chunk-PMKODV6M.mjs → chunk-462HMNO4.mjs} +6 -10
  11. package/dist/chunk-4CX4SBRO.mjs +153 -0
  12. package/dist/chunk-4MN6UQHG.mjs +443 -0
  13. package/dist/chunk-5QQVZTVZ.mjs +233 -0
  14. package/dist/{chunk-BGP2N52Z.mjs → chunk-66MI7Q4B.mjs} +5 -5
  15. package/dist/chunk-6FCGKSZX.mjs +268 -0
  16. package/dist/{chunk-CGOKTPXU.mjs → chunk-6JQFUE5I.mjs} +20 -23
  17. package/dist/{chunk-Z3MK2KKZ.mjs → chunk-7DHU4VGG.mjs} +7 -3
  18. package/dist/{chunk-VZ2NR7L3.mjs → chunk-7PYJD5JI.mjs} +35 -27
  19. package/dist/{chunk-JU2RUWHF.mjs → chunk-7XJHLGUV.mjs} +1 -1
  20. package/dist/{chunk-BMFN37JH.mjs → chunk-7YAU5CY6.mjs} +1 -1
  21. package/dist/chunk-A56YQQHG.mjs +402 -0
  22. package/dist/chunk-AH52LG6N.mjs +315 -0
  23. package/dist/{chunk-SLWCCURD.mjs → chunk-CLIN5525.mjs} +8 -4
  24. package/dist/{chunk-3VQNJ235.mjs → chunk-CSDO6VBW.mjs} +7 -0
  25. package/dist/chunk-D4ILTPOG.mjs +293 -0
  26. package/dist/{chunk-HS7TFG7V.mjs → chunk-D6ID6M4V.mjs} +1 -1
  27. package/dist/chunk-DOH3EHX7.mjs +378 -0
  28. package/dist/{chunk-MJIEMGRD.mjs → chunk-EFRENWEJ.mjs} +9 -17
  29. package/dist/chunk-ERGGHC2V.mjs +185 -0
  30. package/dist/{chunk-OXQQNQZI.mjs → chunk-FEZKMUCF.mjs} +10 -1
  31. package/dist/{chunk-55CEW76V.mjs → chunk-FH6QVUVZ.mjs} +1 -1
  32. package/dist/chunk-FMAXJ2SI.mjs +71 -0
  33. package/dist/chunk-FZIXGLMV.mjs +173 -0
  34. package/dist/{chunk-DS2AMHN2.mjs → chunk-GYMYRIZP.mjs} +2 -2
  35. package/dist/{chunk-KQDD5MU3.mjs → chunk-H45TKD34.mjs} +5 -5
  36. package/dist/{chunk-BBJBJSXQ.mjs → chunk-J5UICVJS.mjs} +1 -1
  37. package/dist/{chunk-RL772EH7.mjs → chunk-JHJHG4GO.mjs} +4 -12
  38. package/dist/chunk-KMCGSZTX.mjs +177 -0
  39. package/dist/{chunk-FHNT55I5.mjs → chunk-KUDCQ4FI.mjs} +4 -4
  40. package/dist/chunk-LE6YFY6D.mjs +209 -0
  41. package/dist/{chunk-HUVTPUV2.mjs → chunk-LLVQKSU3.mjs} +23 -19
  42. package/dist/{chunk-KKHTJNMM.mjs → chunk-MARPPFOJ.mjs} +8 -4
  43. package/dist/{chunk-6AFMNC42.mjs → chunk-N2PT566P.mjs} +15 -11
  44. package/dist/chunk-NLCKVHWB.mjs +161 -0
  45. package/dist/{chunk-YN5SYTOO.mjs → chunk-NQPOYKAQ.mjs} +9 -5
  46. package/dist/{chunk-ZZV5JVNW.mjs → chunk-NSLMILBT.mjs} +3 -7
  47. package/dist/chunk-NXA3CZ7A.mjs +248 -0
  48. package/dist/chunk-OGOYQ7BG.mjs +150 -0
  49. package/dist/{chunk-3NQGYJEZ.mjs → chunk-P6AM5V7O.mjs} +10 -18
  50. package/dist/{chunk-CZ3BW5GL.mjs → chunk-P76HMUI6.mjs} +5 -11
  51. package/dist/chunk-PCPLO5HT.mjs +671 -0
  52. package/dist/chunk-PG6K5XEC.mjs +475 -0
  53. package/dist/chunk-PJHPSRYD.mjs +234 -0
  54. package/dist/{chunk-DDPA2XXS.mjs → chunk-PMB3A7V3.mjs} +2 -2
  55. package/dist/chunk-PR6V5XKM.mjs +209 -0
  56. package/dist/{chunk-46OFHMQA.mjs → chunk-Q76O3RIQ.mjs} +10 -6
  57. package/dist/chunk-QVKWW6KE.mjs +272 -0
  58. package/dist/chunk-RGU7HOEC.mjs +140 -0
  59. package/dist/{chunk-JF4PHPD5.mjs → chunk-RGVKLTLH.mjs} +4 -4
  60. package/dist/{chunk-VG6UF6UT.mjs → chunk-RP3SQYA3.mjs} +2 -2
  61. package/dist/chunk-RRBS6D63.mjs +163 -0
  62. package/dist/chunk-SMQ3DG25.mjs +285 -0
  63. package/dist/chunk-SPJ5KXW7.mjs +199 -0
  64. package/dist/chunk-SYOD63OZ.mjs +225 -0
  65. package/dist/chunk-UFYSFDER.mjs +42 -0
  66. package/dist/chunk-VACKZOMY.mjs +190 -0
  67. package/dist/chunk-VLQZANBF.mjs +42 -0
  68. package/dist/chunk-WA6O6EUR.mjs +1885 -0
  69. package/dist/{chunk-E3K6O4FZ.mjs → chunk-WAZD7NFU.mjs} +5 -2
  70. package/dist/chunk-WG6JGJXB.mjs +165 -0
  71. package/dist/{chunk-I64K754C.mjs → chunk-WNGWBVLV.mjs} +2 -2
  72. package/dist/{chunk-3U7SD3MS.mjs → chunk-WOEHFRGB.mjs} +3 -3
  73. package/dist/{chunk-DKZRJOMF.mjs → chunk-XIRTEFKH.mjs} +12 -12
  74. package/dist/chunk-Y6DWJSKZ.mjs +79 -0
  75. package/dist/chunk-YKPROFLB.mjs +161 -0
  76. package/dist/{chunk-K76E2TQU.mjs → chunk-ZRO5JO3H.mjs} +107 -67
  77. package/dist/{chunk-VYMHBV6D.mjs → chunk-ZU4NV6RG.mjs} +5 -3
  78. package/dist/components/ui/accordion.js +40 -4
  79. package/dist/components/ui/accordion.mjs +2 -2
  80. package/dist/components/ui/add-column-modal.js +789 -0
  81. package/dist/components/ui/add-column-modal.mjs +17 -0
  82. package/dist/components/ui/add-lead-modal.js +647 -0
  83. package/dist/components/ui/add-lead-modal.mjs +16 -0
  84. package/dist/components/ui/ai-assistant-drawer.js +686 -0
  85. package/dist/components/ui/ai-assistant-drawer.mjs +16 -0
  86. package/dist/components/ui/alert-dialog.js +37 -5
  87. package/dist/components/ui/alert-dialog.mjs +4 -4
  88. package/dist/components/ui/alert.js +37 -11
  89. package/dist/components/ui/alert.mjs +2 -2
  90. package/dist/components/ui/avatar.js +36 -8
  91. package/dist/components/ui/avatar.mjs +2 -2
  92. package/dist/components/ui/backoffice-alert-history-chart.js +624 -0
  93. package/dist/components/ui/backoffice-alert-history-chart.mjs +16 -0
  94. package/dist/components/ui/backoffice-contact-history-chart.js +687 -0
  95. package/dist/components/ui/backoffice-contact-history-chart.mjs +16 -0
  96. package/dist/components/ui/badge.js +37 -2
  97. package/dist/components/ui/badge.mjs +2 -2
  98. package/dist/components/ui/borrowing-capacity-line-chart.js +639 -0
  99. package/dist/components/ui/borrowing-capacity-line-chart.mjs +16 -0
  100. package/dist/components/ui/button.js +35 -3
  101. package/dist/components/ui/button.mjs +2 -2
  102. package/dist/components/ui/calendar.js +43 -19
  103. package/dist/components/ui/calendar.mjs +3 -3
  104. package/dist/components/ui/card.js +40 -4
  105. package/dist/components/ui/card.mjs +2 -2
  106. package/dist/components/ui/cash-balance-line-chart.js +627 -0
  107. package/dist/components/ui/cash-balance-line-chart.mjs +16 -0
  108. package/dist/components/ui/cashflow-bar-chart.js +650 -0
  109. package/dist/components/ui/cashflow-bar-chart.mjs +16 -0
  110. package/dist/components/ui/checkbox.js +36 -5
  111. package/dist/components/ui/checkbox.mjs +2 -3
  112. package/dist/components/ui/chip.js +37 -2
  113. package/dist/components/ui/chip.mjs +3 -3
  114. package/dist/components/ui/combobox.js +280 -0
  115. package/dist/components/ui/combobox.mjs +28 -0
  116. package/dist/components/ui/data-table.js +160 -88
  117. package/dist/components/ui/data-table.mjs +10 -11
  118. package/dist/components/ui/date-picker.js +44 -20
  119. package/dist/components/ui/date-picker.mjs +6 -7
  120. package/dist/components/ui/dialog.js +44 -12
  121. package/dist/components/ui/dialog.mjs +4 -4
  122. package/dist/components/ui/drawer.js +46 -10
  123. package/dist/components/ui/drawer.mjs +3 -3
  124. package/dist/components/ui/dropdown-menu.js +40 -16
  125. package/dist/components/ui/dropdown-menu.mjs +3 -3
  126. package/dist/components/ui/empty.js +41 -5
  127. package/dist/components/ui/empty.mjs +2 -2
  128. package/dist/components/ui/expense-bar-chart.js +642 -0
  129. package/dist/components/ui/expense-bar-chart.mjs +16 -0
  130. package/dist/components/ui/field.js +53 -21
  131. package/dist/components/ui/field.mjs +4 -4
  132. package/dist/components/ui/financial-cards.js +1002 -0
  133. package/dist/components/ui/financial-cards.mjs +24 -0
  134. package/dist/components/ui/financial-drawers.js +637 -0
  135. package/dist/components/ui/financial-drawers.mjs +17 -0
  136. package/dist/components/ui/financial-primitives.js +218 -0
  137. package/dist/components/ui/financial-primitives.mjs +22 -0
  138. package/dist/components/ui/financial-sections.js +1422 -0
  139. package/dist/components/ui/financial-sections.mjs +30 -0
  140. package/dist/components/ui/form-primitives.js +682 -0
  141. package/dist/components/ui/form-primitives.mjs +19 -0
  142. package/dist/components/ui/income-bar-chart.js +641 -0
  143. package/dist/components/ui/income-bar-chart.mjs +16 -0
  144. package/dist/components/ui/input-group.js +43 -7
  145. package/dist/components/ui/input-group.mjs +5 -5
  146. package/dist/components/ui/input-otp.js +39 -3
  147. package/dist/components/ui/input-otp.mjs +2 -2
  148. package/dist/components/ui/input.js +34 -2
  149. package/dist/components/ui/input.mjs +2 -2
  150. package/dist/components/ui/kanban-column.js +1143 -0
  151. package/dist/components/ui/kanban-column.mjs +20 -0
  152. package/dist/components/ui/label.js +35 -7
  153. package/dist/components/ui/label.mjs +2 -2
  154. package/dist/components/ui/opportunity-card.js +960 -0
  155. package/dist/components/ui/opportunity-card.mjs +20 -0
  156. package/dist/components/ui/opportunity-edit-modals.js +3360 -0
  157. package/dist/components/ui/opportunity-edit-modals.mjs +37 -0
  158. package/dist/components/ui/opportunity-summary-tab.js +4365 -0
  159. package/dist/components/ui/opportunity-summary-tab.mjs +34 -0
  160. package/dist/components/ui/pagination.js +35 -3
  161. package/dist/components/ui/pagination.mjs +3 -3
  162. package/dist/components/ui/pipeline-alerts.js +103 -0
  163. package/dist/components/ui/pipeline-alerts.mjs +8 -0
  164. package/dist/components/ui/pipeline-board.js +1408 -0
  165. package/dist/components/ui/pipeline-board.mjs +24 -0
  166. package/dist/components/ui/pipeline-chart.js +216 -0
  167. package/dist/components/ui/pipeline-chart.mjs +10 -0
  168. package/dist/components/ui/pipeline-dialogs.js +1183 -0
  169. package/dist/components/ui/pipeline-dialogs.mjs +23 -0
  170. package/dist/components/ui/pipeline-primitives.js +300 -0
  171. package/dist/components/ui/pipeline-primitives.mjs +11 -0
  172. package/dist/components/ui/popover.js +45 -4
  173. package/dist/components/ui/popover.mjs +3 -3
  174. package/dist/components/ui/progress.js +33 -1
  175. package/dist/components/ui/progress.mjs +2 -2
  176. package/dist/components/ui/property-cashflow-doughnut-chart.js +523 -0
  177. package/dist/components/ui/property-cashflow-doughnut-chart.mjs +16 -0
  178. package/dist/components/ui/property-debt-equity-doughnut-chart.js +521 -0
  179. package/dist/components/ui/property-debt-equity-doughnut-chart.mjs +16 -0
  180. package/dist/components/ui/property-mobile-estimate-line-chart.js +682 -0
  181. package/dist/components/ui/property-mobile-estimate-line-chart.mjs +16 -0
  182. package/dist/components/ui/radio-group.js +33 -1
  183. package/dist/components/ui/radio-group.mjs +2 -2
  184. package/dist/components/ui/select.js +66 -26
  185. package/dist/components/ui/select.mjs +3 -3
  186. package/dist/components/ui/separator.js +33 -1
  187. package/dist/components/ui/separator.mjs +2 -2
  188. package/dist/components/ui/sheet.js +37 -9
  189. package/dist/components/ui/sheet.mjs +3 -3
  190. package/dist/components/ui/skeleton.js +33 -1
  191. package/dist/components/ui/skeleton.mjs +2 -2
  192. package/dist/components/ui/slider.js +86 -102
  193. package/dist/components/ui/slider.mjs +2 -2
  194. package/dist/components/ui/spinner.js +33 -1
  195. package/dist/components/ui/spinner.mjs +2 -2
  196. package/dist/components/ui/stage-timeline.js +579 -0
  197. package/dist/components/ui/stage-timeline.mjs +15 -0
  198. package/dist/components/ui/switch.js +37 -4
  199. package/dist/components/ui/switch.mjs +2 -3
  200. package/dist/components/ui/table.js +37 -5
  201. package/dist/components/ui/table.mjs +2 -2
  202. package/dist/components/ui/tabs.js +36 -12
  203. package/dist/components/ui/tabs.mjs +2 -2
  204. package/dist/components/ui/textarea.js +34 -2
  205. package/dist/components/ui/textarea.mjs +2 -2
  206. package/dist/components/ui/toggle-group.js +35 -4
  207. package/dist/components/ui/toggle-group.mjs +3 -4
  208. package/dist/components/ui/toggle.js +35 -4
  209. package/dist/components/ui/toggle.mjs +2 -3
  210. package/dist/components/ui/tooltip.js +51 -22
  211. package/dist/components/ui/tooltip.mjs +3 -3
  212. package/dist/components/ui/transactions-expense-categories-doughnut-chart.js +528 -0
  213. package/dist/components/ui/transactions-expense-categories-doughnut-chart.mjs +16 -0
  214. package/dist/components/ui/transactions-income-expense-bar-chart.js +516 -0
  215. package/dist/components/ui/transactions-income-expense-bar-chart.mjs +16 -0
  216. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.js +528 -0
  217. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.mjs +16 -0
  218. package/dist/index.js +11613 -2868
  219. package/dist/index.mjs +377 -164
  220. package/dist/lib/theme-provider.js +10 -1
  221. package/dist/lib/theme-provider.mjs +1 -1
  222. package/dist/lib/typography.js +8 -0
  223. package/dist/lib/typography.mjs +3 -1
  224. package/dist/lib/utils.js +33 -1
  225. package/dist/lib/utils.mjs +1 -1
  226. package/dist/styles.css +1 -1
  227. package/package.json +169 -6
  228. package/src/components/index.tsx +323 -13
  229. package/src/components/ui/accordion.tsx +6 -3
  230. package/src/components/ui/add-column-modal.tsx +339 -0
  231. package/src/components/ui/add-lead-modal.tsx +290 -0
  232. package/src/components/ui/ai-assistant-drawer.tsx +408 -0
  233. package/src/components/ui/alert-dialog.tsx +80 -54
  234. package/src/components/ui/alert.tsx +28 -28
  235. package/src/components/ui/avatar.tsx +30 -29
  236. package/src/components/ui/backoffice-alert-history-chart.tsx +260 -0
  237. package/src/components/ui/backoffice-contact-history-chart.tsx +325 -0
  238. package/src/components/ui/badge.tsx +17 -15
  239. package/src/components/ui/borrowing-capacity-line-chart.tsx +357 -0
  240. package/src/components/ui/button.tsx +30 -27
  241. package/src/components/ui/calendar.tsx +53 -67
  242. package/src/components/ui/card.tsx +27 -24
  243. package/src/components/ui/cash-balance-line-chart.tsx +302 -0
  244. package/src/components/ui/cashflow-bar-chart.tsx +363 -0
  245. package/src/components/ui/chart-shared.tsx +261 -0
  246. package/src/components/ui/checkbox.tsx +30 -26
  247. package/src/components/ui/combobox.tsx +223 -0
  248. package/src/components/ui/data-table.tsx +160 -99
  249. package/src/components/ui/date-picker.tsx +0 -2
  250. package/src/components/ui/dialog.tsx +70 -60
  251. package/src/components/ui/drawer.tsx +57 -48
  252. package/src/components/ui/dropdown-menu.tsx +90 -82
  253. package/src/components/ui/empty.tsx +31 -27
  254. package/src/components/ui/expense-bar-chart.tsx +296 -0
  255. package/src/components/ui/field.tsx +70 -62
  256. package/src/components/ui/financial-cards.tsx +830 -0
  257. package/src/components/ui/financial-drawers.tsx +339 -0
  258. package/src/components/ui/financial-primitives.tsx +331 -0
  259. package/src/components/ui/financial-sections.tsx +672 -0
  260. package/src/components/ui/form-primitives.tsx +536 -0
  261. package/src/components/ui/income-bar-chart.tsx +297 -0
  262. package/src/components/ui/input-group.tsx +41 -34
  263. package/src/components/ui/input-otp.tsx +29 -24
  264. package/src/components/ui/input.tsx +8 -8
  265. package/src/components/ui/kanban-column.tsx +333 -0
  266. package/src/components/ui/label.tsx +9 -12
  267. package/src/components/ui/opportunity-card.tsx +616 -0
  268. package/src/components/ui/opportunity-edit-modals.tsx +2528 -0
  269. package/src/components/ui/opportunity-summary-tab.tsx +579 -0
  270. package/src/components/ui/pipeline-alerts.tsx +74 -0
  271. package/src/components/ui/pipeline-board.tsx +268 -0
  272. package/src/components/ui/pipeline-chart.tsx +173 -0
  273. package/src/components/ui/pipeline-dialogs.tsx +303 -0
  274. package/src/components/ui/pipeline-primitives.tsx +108 -0
  275. package/src/components/ui/popover.tsx +41 -36
  276. package/src/components/ui/property-cashflow-doughnut-chart.tsx +188 -0
  277. package/src/components/ui/property-debt-equity-doughnut-chart.tsx +185 -0
  278. package/src/components/ui/property-mobile-estimate-line-chart.tsx +393 -0
  279. package/src/components/ui/select.tsx +65 -52
  280. package/src/components/ui/sheet.tsx +55 -52
  281. package/src/components/ui/slider.tsx +54 -77
  282. package/src/components/ui/stage-timeline.tsx +205 -0
  283. package/src/components/ui/switch.tsx +42 -29
  284. package/src/components/ui/table.tsx +28 -28
  285. package/src/components/ui/tabs.tsx +22 -28
  286. package/src/components/ui/textarea.tsx +8 -8
  287. package/src/components/ui/toggle-group.tsx +0 -2
  288. package/src/components/ui/toggle.tsx +13 -15
  289. package/src/components/ui/tooltip.tsx +30 -28
  290. package/src/components/ui/transactions-expense-categories-doughnut-chart.tsx +191 -0
  291. package/src/components/ui/transactions-income-expense-bar-chart.tsx +205 -0
  292. package/src/components/ui/transactions-liabilities-breakdown-doughnut-chart.tsx +191 -0
  293. package/src/lib/theme-provider.tsx +10 -0
  294. package/src/lib/typography.ts +9 -0
  295. package/src/lib/utils.ts +41 -3
  296. package/src/styles/globals.css +371 -124
  297. package/src/styles/styles-css.ts +1 -1
  298. package/tsup.config.ts +32 -0
  299. package/dist/chunk-K74JRTJR.mjs +0 -105
  300. package/dist/chunk-V7CNWJT3.mjs +0 -10
@@ -0,0 +1,1885 @@
1
+ import {
2
+ RadioGroup,
3
+ RadioGroupItem
4
+ } from "./chunk-7XJHLGUV.mjs";
5
+ import {
6
+ AddressAutocomplete,
7
+ CurrencyInputWithSlider,
8
+ OwnershipSplit
9
+ } from "./chunk-DOH3EHX7.mjs";
10
+ import {
11
+ Slider
12
+ } from "./chunk-Y6DWJSKZ.mjs";
13
+ import {
14
+ ToggleGroup,
15
+ ToggleGroupItem
16
+ } from "./chunk-PMB3A7V3.mjs";
17
+ import {
18
+ DatePicker
19
+ } from "./chunk-KUDCQ4FI.mjs";
20
+ import {
21
+ Textarea
22
+ } from "./chunk-34NWQURD.mjs";
23
+ import {
24
+ Accordion,
25
+ AccordionContent,
26
+ AccordionItem
27
+ } from "./chunk-MARPPFOJ.mjs";
28
+ import {
29
+ Select,
30
+ SelectContent,
31
+ SelectItem,
32
+ SelectTrigger,
33
+ SelectValue
34
+ } from "./chunk-7PYJD5JI.mjs";
35
+ import {
36
+ Label
37
+ } from "./chunk-NSLMILBT.mjs";
38
+ import {
39
+ Checkbox
40
+ } from "./chunk-RGVKLTLH.mjs";
41
+ import {
42
+ Input
43
+ } from "./chunk-GYMYRIZP.mjs";
44
+ import {
45
+ Dialog,
46
+ DialogContent,
47
+ DialogFooter,
48
+ DialogHeader,
49
+ DialogTitle
50
+ } from "./chunk-XIRTEFKH.mjs";
51
+ import {
52
+ Button
53
+ } from "./chunk-2I5S2AMY.mjs";
54
+ import {
55
+ cn
56
+ } from "./chunk-VLQZANBF.mjs";
57
+ import {
58
+ __spreadProps,
59
+ __spreadValues
60
+ } from "./chunk-FWCSY2DS.mjs";
61
+
62
+ // src/components/ui/opportunity-edit-modals.tsx
63
+ import * as React from "react";
64
+ import { ChevronDownIcon, Plus, Trash2 } from "lucide-react";
65
+ import { Accordion as AccordionPrimitive } from "@base-ui/react/accordion";
66
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
67
+ var LOAN_PURPOSES = [
68
+ "Purchase a home",
69
+ "Refinance my home loan",
70
+ "Buy an investment property",
71
+ "Refinance investment loan",
72
+ "Renovate/build",
73
+ "Equity release"
74
+ ];
75
+ var ASSET_TYPES = [
76
+ "Primary Residence",
77
+ "Investment Property",
78
+ "Holiday Home",
79
+ "Commercial Property",
80
+ "Rural Property",
81
+ "Cash & Savings",
82
+ "Term Deposit",
83
+ "Shares / ETFs",
84
+ "Managed Funds",
85
+ "Superannuation",
86
+ "Motor Vehicle",
87
+ "Business Equity",
88
+ "Cryptocurrency",
89
+ "Personal Belongings",
90
+ "Life Insurance",
91
+ "Trust Assets",
92
+ "SMSF",
93
+ "Bonds / Fixed Income",
94
+ "Other"
95
+ ];
96
+ var PROPERTY_ASSET_TYPES = /* @__PURE__ */ new Set([
97
+ "Primary Residence",
98
+ "Investment Property",
99
+ "Holiday Home",
100
+ "Commercial Property",
101
+ "Rural Property"
102
+ ]);
103
+ var PROPERTY_SUBTYPES = [
104
+ "House",
105
+ "Unit / Apartment",
106
+ "Townhouse",
107
+ "Land",
108
+ "Rural / Farm",
109
+ "Commercial"
110
+ ];
111
+ var PROPERTY_USED_AS = ["Owner Occupied", "Investment", "Vacant Land"];
112
+ var FINANCIAL_ACCOUNT_ASSET_TYPES = /* @__PURE__ */ new Set([
113
+ "Cash & Savings",
114
+ "Term Deposit"
115
+ ]);
116
+ var INVESTMENT_ASSET_TYPES = /* @__PURE__ */ new Set([
117
+ "Shares / ETFs",
118
+ "Managed Funds",
119
+ "Bonds / Fixed Income",
120
+ "Cryptocurrency"
121
+ ]);
122
+ var SUPER_ASSET_TYPES = /* @__PURE__ */ new Set(["Superannuation", "SMSF"]);
123
+ function assetFields(type) {
124
+ return {
125
+ isProperty: PROPERTY_ASSET_TYPES.has(type),
126
+ isVehicle: type === "Motor Vehicle",
127
+ isFinancialAccount: FINANCIAL_ACCOUNT_ASSET_TYPES.has(type),
128
+ isInvestment: INVESTMENT_ASSET_TYPES.has(type),
129
+ isSuper: SUPER_ASSET_TYPES.has(type),
130
+ isBusiness: type === "Business Equity",
131
+ isInsurance: type === "Life Insurance"
132
+ };
133
+ }
134
+ var PROPERTY_LOAN_DEBT_TYPES = /* @__PURE__ */ new Set([
135
+ "Home Loan (Owner Occupied)",
136
+ "Home Loan (Investment)",
137
+ "Construction Loan"
138
+ ]);
139
+ var GENERAL_LOAN_DEBT_TYPES = /* @__PURE__ */ new Set([
140
+ "Personal Loan",
141
+ "Business Loan",
142
+ "Overdraft",
143
+ "Line of Credit",
144
+ "Guarantor Liability"
145
+ ]);
146
+ var CARD_DEBT_TYPES = /* @__PURE__ */ new Set([
147
+ "Credit Card",
148
+ "Store Card",
149
+ "Buy Now Pay Later"
150
+ ]);
151
+ var VEHICLE_DEBT_TYPES = /* @__PURE__ */ new Set(["Car Loan", "Vehicle Lease"]);
152
+ function debtFields(type) {
153
+ return {
154
+ isPropertyLoan: PROPERTY_LOAN_DEBT_TYPES.has(type),
155
+ isGeneralLoan: GENERAL_LOAN_DEBT_TYPES.has(type),
156
+ isCard: CARD_DEBT_TYPES.has(type),
157
+ isVehicle: VEHICLE_DEBT_TYPES.has(type),
158
+ isHecs: type === "HECS / Student Debt",
159
+ isTax: type === "Tax Debt",
160
+ isGuarantor: type === "Guarantor Liability"
161
+ };
162
+ }
163
+ var DEBT_TYPES = [
164
+ "Home Loan (Owner Occupied)",
165
+ "Home Loan (Investment)",
166
+ "Construction Loan",
167
+ "Personal Loan",
168
+ "Car Loan",
169
+ "Credit Card",
170
+ "Store Card",
171
+ "HECS / Student Debt",
172
+ "Business Loan",
173
+ "Overdraft",
174
+ "Tax Debt",
175
+ "Buy Now Pay Later",
176
+ "Vehicle Lease",
177
+ "Guarantor Liability",
178
+ "Line of Credit",
179
+ "Other"
180
+ ];
181
+ var TITLE_OPTIONS = ["Mr", "Mrs", "Ms", "Dr", "Prof"];
182
+ var GENDER_OPTIONS = ["Male", "Female", "Non-binary", "Prefer not to say"];
183
+ var MARITAL_OPTIONS = [
184
+ "Single",
185
+ "Married",
186
+ "De facto",
187
+ "Divorced",
188
+ "Widowed"
189
+ ];
190
+ var CITIZEN_OPTIONS = [
191
+ "Australian Citizen",
192
+ "Permanent Resident",
193
+ "Temporary Resident",
194
+ "Foreign National"
195
+ ];
196
+ var RESIDENTIAL_STATUS_OPTIONS = [
197
+ "Own",
198
+ "Renting",
199
+ "Boarding",
200
+ "With Parents",
201
+ "Other"
202
+ ];
203
+ var PROPERTY_IN_TRUST_OPTIONS = ["None", "Yes - Discretionary", "Yes - Unit"];
204
+ var COMPANY_OWNERSHIP_OPTIONS = [
205
+ "None",
206
+ "Yes - Director",
207
+ "Yes - Shareholder"
208
+ ];
209
+ var INCOME_TYPES = [
210
+ "PAYG",
211
+ "Self-employed",
212
+ "Contractor",
213
+ "Casual",
214
+ "Commission",
215
+ "Government Benefits",
216
+ "Rental",
217
+ "Other"
218
+ ];
219
+ var EXPENSE_TYPES = [
220
+ "Groceries",
221
+ "Dining Out",
222
+ "Transport",
223
+ "Fuel",
224
+ "Utilities",
225
+ "Phone Plan",
226
+ "Internet",
227
+ "Medical",
228
+ "Entertainment",
229
+ "Clothing",
230
+ "Gym & Fitness",
231
+ "Subscriptions",
232
+ "Childcare",
233
+ "Education",
234
+ "Pet Care",
235
+ "Insurance",
236
+ "Council Rates",
237
+ "Body Corp / Strata",
238
+ "Home Maintenance",
239
+ "Travel & Holidays",
240
+ "Donations",
241
+ "Other"
242
+ ];
243
+ var PRIORITIES = [
244
+ "Maximize Borrow Amount",
245
+ "Cheapest Interest Rate",
246
+ "The Best Features",
247
+ "Major Lender",
248
+ "Small Lender",
249
+ "Regional Lender",
250
+ "Non-Bank Lender",
251
+ "Branch Network",
252
+ "Good Customer Service",
253
+ "Environmentally Friendly Lender"
254
+ ];
255
+ function FormField({
256
+ label,
257
+ children,
258
+ className
259
+ }) {
260
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-1.5", className), children: [
261
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
262
+ children
263
+ ] });
264
+ }
265
+ function ModalScroll({ children }) {
266
+ return /* @__PURE__ */ jsx("div", { className: "max-h-[65vh] overflow-y-auto flex flex-col gap-4 py-1 pr-1", children });
267
+ }
268
+ function FrequencyToggle({
269
+ value,
270
+ onValueChange
271
+ }) {
272
+ return /* @__PURE__ */ jsxs(
273
+ ToggleGroup,
274
+ {
275
+ variant: "outline",
276
+ value,
277
+ onValueChange: (val) => {
278
+ if (val === "Monthly" || val === "Weekly") {
279
+ onValueChange(val);
280
+ }
281
+ },
282
+ children: [
283
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "Monthly", size: "sm", children: "Monthly" }),
284
+ /* @__PURE__ */ jsx(ToggleGroupItem, { value: "Weekly", size: "sm", children: "Weekly" })
285
+ ]
286
+ }
287
+ );
288
+ }
289
+ function AccordionItemHeader({
290
+ label,
291
+ onRemove,
292
+ removeLabel = "Remove item"
293
+ }) {
294
+ return /* @__PURE__ */ jsxs(AccordionPrimitive.Header, { className: "flex items-center", children: [
295
+ /* @__PURE__ */ jsxs(
296
+ AccordionPrimitive.Trigger,
297
+ {
298
+ className: cn(
299
+ "flex flex-1 items-center justify-between gap-4 py-4 text-left",
300
+ "text-label-medium rounded-none outline-none transition-[color,opacity]",
301
+ "hover:underline focus-visible:ring-2 focus-visible:ring-foreground/30",
302
+ "[&[data-panel-open]>svg]:rotate-180"
303
+ ),
304
+ children: [
305
+ label,
306
+ /* @__PURE__ */ jsx(ChevronDownIcon, { className: "pointer-events-none size-4 shrink-0 text-muted-foreground transition-transform duration-200" })
307
+ ]
308
+ }
309
+ ),
310
+ /* @__PURE__ */ jsx(
311
+ "button",
312
+ {
313
+ type: "button",
314
+ onClick: onRemove,
315
+ className: "p-2 hover:bg-foreground/5 transition-colors",
316
+ "aria-label": removeLabel,
317
+ children: /* @__PURE__ */ jsx(Trash2, { className: "h-3.5 w-3.5 text-destructive" })
318
+ }
319
+ )
320
+ ] });
321
+ }
322
+ var LOAN_SCENARIO_DEFAULTS = {
323
+ loanPurpose: "",
324
+ propertyEstimate: 0,
325
+ cashEquity: 0,
326
+ loanAmount: 0,
327
+ loanDuration: 30,
328
+ knowsFeatures: "",
329
+ featureFixedRate: false,
330
+ featureVariableRate: false,
331
+ featureSplitLoan: false,
332
+ featureInterestOnly: false,
333
+ featureRedrawFacility: false,
334
+ feature100Offset: false,
335
+ priorities: [],
336
+ borrowOtherThanProperty: "",
337
+ concernedAboutRates: "",
338
+ considerFixedRate: "",
339
+ retirementAge: "",
340
+ anticipatedChanges: ""
341
+ };
342
+ var ABOUT_APPLICANT_DEFAULTS = {
343
+ title: "",
344
+ firstName: "",
345
+ lastName: "",
346
+ phone: "",
347
+ email: "",
348
+ dob: "",
349
+ gender: "",
350
+ maritalStatus: "",
351
+ numDependants: "",
352
+ dependants: [],
353
+ citizenStatus: "",
354
+ residentialAddress: "",
355
+ residentialStatus: "",
356
+ timeAtAddressYears: "",
357
+ timeAtAddressMonths: "",
358
+ previousAddress: "",
359
+ driversLicence: "",
360
+ passport: "",
361
+ propertyInTrust: "",
362
+ companyOwnership: ""
363
+ };
364
+ function makeDefaultIncomeItem() {
365
+ return {
366
+ id: `income-${Date.now()}-${Math.random()}`,
367
+ incomeType: "",
368
+ jobTitle: "",
369
+ startDate: "",
370
+ stillInPosition: true,
371
+ endDate: "",
372
+ companyName: "",
373
+ companyAddress: "",
374
+ incomeAmount: 0,
375
+ frequency: "Monthly",
376
+ companyType: ""
377
+ };
378
+ }
379
+ function makeDefaultAssetItem() {
380
+ return {
381
+ id: `asset-${Date.now()}-${Math.random()}`,
382
+ assetType: "",
383
+ value: 0,
384
+ mainShare: 100,
385
+ coShare: 0
386
+ };
387
+ }
388
+ function makeDefaultDebtItem() {
389
+ return {
390
+ id: `debt-${Date.now()}-${Math.random()}`,
391
+ debtType: "",
392
+ amountOwing: 0,
393
+ originalLoanAmount: 0,
394
+ repaymentAmount: 0,
395
+ repaymentFrequency: "Monthly",
396
+ interestRate: "",
397
+ details: "",
398
+ mainShare: 100,
399
+ coShare: 0
400
+ };
401
+ }
402
+ function makeDefaultExpenseItem() {
403
+ return {
404
+ id: `expense-${Date.now()}-${Math.random()}`,
405
+ expenseType: "",
406
+ amount: 0,
407
+ frequency: "Monthly",
408
+ mainShare: 100,
409
+ coShare: 0
410
+ };
411
+ }
412
+ function EditLoanScenarioModal({
413
+ open,
414
+ onOpenChange,
415
+ initialData,
416
+ onSave,
417
+ className
418
+ }) {
419
+ const [form, setForm] = React.useState(__spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData));
420
+ React.useEffect(() => {
421
+ if (open) {
422
+ setForm(__spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData));
423
+ }
424
+ }, [open]);
425
+ const set = (key, val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
426
+ const togglePriority = (priority) => {
427
+ setForm((prev) => {
428
+ const exists = prev.priorities.includes(priority);
429
+ if (exists) {
430
+ return __spreadProps(__spreadValues({}, prev), {
431
+ priorities: prev.priorities.filter((p) => p !== priority)
432
+ });
433
+ }
434
+ if (prev.priorities.length >= 3) return prev;
435
+ return __spreadProps(__spreadValues({}, prev), { priorities: [...prev.priorities, priority] });
436
+ });
437
+ };
438
+ const prioritiesAtMax = form.priorities.length >= 3;
439
+ const LOAN_FEATURES = [
440
+ { key: "featureFixedRate", label: "Fixed Rate" },
441
+ { key: "featureVariableRate", label: "Variable Rate" },
442
+ { key: "featureSplitLoan", label: "Split Loan" },
443
+ { key: "featureInterestOnly", label: "Interest Only" },
444
+ { key: "featureRedrawFacility", label: "Redraw Facility" },
445
+ { key: "feature100Offset", label: "100% Offset" }
446
+ ];
447
+ const YES_NO_FIELDS = [
448
+ {
449
+ key: "borrowOtherThanProperty",
450
+ label: "Do you intend to borrow money other than your property?"
451
+ },
452
+ {
453
+ key: "concernedAboutRates",
454
+ label: "Are you concerned about rising interest rates?"
455
+ },
456
+ {
457
+ key: "considerFixedRate",
458
+ label: "Would you consider taking a fixed rate?"
459
+ },
460
+ {
461
+ key: "anticipatedChanges",
462
+ label: "Anticipated changes impacting repayment?"
463
+ }
464
+ ];
465
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-lg", className), children: [
466
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Loan Scenario" }) }),
467
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
468
+ /* @__PURE__ */ jsx(FormField, { label: "What would you like to do?", children: /* @__PURE__ */ jsxs(
469
+ Select,
470
+ {
471
+ value: form.loanPurpose,
472
+ onValueChange: (val) => set("loanPurpose", val),
473
+ children: [
474
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select purpose" }) }),
475
+ /* @__PURE__ */ jsx(SelectContent, { children: LOAN_PURPOSES.map((p) => /* @__PURE__ */ jsx(SelectItem, { value: p, children: p }, p)) })
476
+ ]
477
+ }
478
+ ) }),
479
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
480
+ /* @__PURE__ */ jsx(FormField, { label: "Property Estimate", children: /* @__PURE__ */ jsx(
481
+ CurrencyInputWithSlider,
482
+ {
483
+ value: form.propertyEstimate,
484
+ min: 0,
485
+ max: 1e7,
486
+ step: 5e4,
487
+ onValueChange: (val) => set("propertyEstimate", val)
488
+ }
489
+ ) }),
490
+ /* @__PURE__ */ jsx(FormField, { label: "Cash/equity towards property", children: /* @__PURE__ */ jsx(
491
+ CurrencyInputWithSlider,
492
+ {
493
+ value: form.cashEquity,
494
+ min: 0,
495
+ max: 2e6,
496
+ step: 5e3,
497
+ onValueChange: (val) => set("cashEquity", val)
498
+ }
499
+ ) })
500
+ ] }),
501
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
502
+ /* @__PURE__ */ jsx(FormField, { label: "Loan Amount", children: /* @__PURE__ */ jsx(
503
+ CurrencyInputWithSlider,
504
+ {
505
+ value: form.loanAmount,
506
+ min: 0,
507
+ max: 5e6,
508
+ step: 1e4,
509
+ onValueChange: (val) => set("loanAmount", val)
510
+ }
511
+ ) }),
512
+ /* @__PURE__ */ jsx(FormField, { label: "Loan Duration", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
513
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
514
+ /* @__PURE__ */ jsx(
515
+ Input,
516
+ {
517
+ type: "number",
518
+ min: 1,
519
+ max: 40,
520
+ value: form.loanDuration,
521
+ onChange: (e) => {
522
+ const parsed = parseInt(e.target.value, 10);
523
+ if (!isNaN(parsed)) {
524
+ set("loanDuration", Math.min(40, Math.max(1, parsed)));
525
+ }
526
+ },
527
+ className: "flex-1"
528
+ }
529
+ ),
530
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: "years" })
531
+ ] }),
532
+ /* @__PURE__ */ jsx(
533
+ Slider,
534
+ {
535
+ min: 1,
536
+ max: 40,
537
+ step: 1,
538
+ value: form.loanDuration,
539
+ onValueChange: (val) => set("loanDuration", val)
540
+ }
541
+ )
542
+ ] }) })
543
+ ] }),
544
+ /* @__PURE__ */ jsx(FormField, { label: "Do you know what loan features you want?", children: /* @__PURE__ */ jsxs(
545
+ Select,
546
+ {
547
+ value: form.knowsFeatures,
548
+ onValueChange: (val) => set("knowsFeatures", val),
549
+ children: [
550
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
551
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
552
+ /* @__PURE__ */ jsx(SelectItem, { value: "Yes", children: "Yes" }),
553
+ /* @__PURE__ */ jsx(SelectItem, { value: "No", children: "No" })
554
+ ] })
555
+ ]
556
+ }
557
+ ) }),
558
+ form.knowsFeatures === "Yes" && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
559
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: "What features are important to you?" }),
560
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: LOAN_FEATURES.map(({ key, label }) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
561
+ /* @__PURE__ */ jsx(
562
+ Checkbox,
563
+ {
564
+ id: `feature-${key}`,
565
+ checked: form[key],
566
+ onCheckedChange: (checked) => set(key, checked === true)
567
+ }
568
+ ),
569
+ /* @__PURE__ */ jsx(
570
+ "label",
571
+ {
572
+ htmlFor: `feature-${key}`,
573
+ className: "text-sm cursor-pointer select-none",
574
+ children: label
575
+ }
576
+ )
577
+ ] }, key)) })
578
+ ] }),
579
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
580
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: "Top 3 Priorities (Select up to 3)" }),
581
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-2", children: PRIORITIES.map((priority) => {
582
+ const checked = form.priorities.includes(priority);
583
+ const disabled = prioritiesAtMax && !checked;
584
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
585
+ /* @__PURE__ */ jsx(
586
+ Checkbox,
587
+ {
588
+ id: `priority-${priority}`,
589
+ checked,
590
+ disabled,
591
+ onCheckedChange: () => togglePriority(priority)
592
+ }
593
+ ),
594
+ /* @__PURE__ */ jsx(
595
+ "label",
596
+ {
597
+ htmlFor: `priority-${priority}`,
598
+ className: cn(
599
+ "text-sm cursor-pointer select-none",
600
+ disabled && "opacity-40 cursor-not-allowed"
601
+ ),
602
+ children: priority
603
+ }
604
+ )
605
+ ] }, priority);
606
+ }) })
607
+ ] }),
608
+ YES_NO_FIELDS.map(({ key, label }) => /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
609
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
610
+ /* @__PURE__ */ jsx(
611
+ RadioGroup,
612
+ {
613
+ value: form[key],
614
+ onValueChange: (val) => {
615
+ if (val === "Yes" || val === "No") set(key, val);
616
+ },
617
+ className: "flex gap-4",
618
+ children: ["Yes", "No"].map((opt) => /* @__PURE__ */ jsxs(
619
+ "label",
620
+ {
621
+ className: "flex items-center gap-2 cursor-pointer select-none",
622
+ children: [
623
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: opt }),
624
+ /* @__PURE__ */ jsx("span", { className: "text-sm", children: opt })
625
+ ]
626
+ },
627
+ opt
628
+ ))
629
+ }
630
+ )
631
+ ] }, key)),
632
+ /* @__PURE__ */ jsx(FormField, { label: "What age are you planning to retire?", children: /* @__PURE__ */ jsx(
633
+ Input,
634
+ {
635
+ type: "number",
636
+ min: 0,
637
+ max: 100,
638
+ value: form.retirementAge,
639
+ onChange: (e) => set("retirementAge", e.target.value),
640
+ placeholder: "e.g. 65"
641
+ }
642
+ ) })
643
+ ] }),
644
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
645
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
646
+ /* @__PURE__ */ jsx(
647
+ Button,
648
+ {
649
+ onClick: () => {
650
+ onSave(form);
651
+ onOpenChange(false);
652
+ },
653
+ children: "Save"
654
+ }
655
+ )
656
+ ] })
657
+ ] }) });
658
+ }
659
+ function EditAssetsModal({
660
+ open,
661
+ onOpenChange,
662
+ initialItems = [],
663
+ onSave,
664
+ mainApplicantName = "Main Applicant",
665
+ coApplicantName = "Co-Applicant",
666
+ className
667
+ }) {
668
+ const [items, setItems] = React.useState(
669
+ initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
670
+ );
671
+ React.useEffect(() => {
672
+ if (open) {
673
+ setItems(
674
+ initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
675
+ );
676
+ }
677
+ }, [open]);
678
+ const updateItem = (id, key, val) => setItems(
679
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
680
+ );
681
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
682
+ const addItem = () => setItems((prev) => [...prev, makeDefaultAssetItem()]);
683
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
684
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-lg", className), children: [
685
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Assets" }) }),
686
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
687
+ /* @__PURE__ */ jsx(
688
+ Accordion,
689
+ {
690
+ multiple: true,
691
+ defaultValue: defaultOpenItems,
692
+ className: "w-full",
693
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
694
+ /* @__PURE__ */ jsx(
695
+ AccordionItemHeader,
696
+ {
697
+ label: `Asset ${index + 1} \u2014 ${item.assetType || "New Asset"}`,
698
+ onRemove: () => removeItem(item.id),
699
+ removeLabel: "Remove asset"
700
+ }
701
+ ),
702
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
703
+ /* @__PURE__ */ jsx(FormField, { label: "Asset Type", children: /* @__PURE__ */ jsxs(
704
+ Select,
705
+ {
706
+ value: item.assetType,
707
+ onValueChange: (val) => updateItem(item.id, "assetType", val),
708
+ children: [
709
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
710
+ /* @__PURE__ */ jsx(SelectContent, { children: ASSET_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
711
+ ]
712
+ }
713
+ ) }),
714
+ /* @__PURE__ */ jsx(FormField, { label: "Value", children: /* @__PURE__ */ jsx(
715
+ CurrencyInputWithSlider,
716
+ {
717
+ value: item.value,
718
+ min: 0,
719
+ max: 1e7,
720
+ step: 1e4,
721
+ onValueChange: (val) => updateItem(item.id, "value", val)
722
+ }
723
+ ) }),
724
+ (() => {
725
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
726
+ const f = assetFields(item.assetType);
727
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
728
+ f.isProperty && /* @__PURE__ */ jsxs(Fragment, { children: [
729
+ /* @__PURE__ */ jsx(FormField, { label: "Property Address", children: /* @__PURE__ */ jsx(
730
+ AddressAutocomplete,
731
+ {
732
+ value: (_a = item.address) != null ? _a : "",
733
+ onValueChange: (val) => updateItem(item.id, "address", val),
734
+ onSelect: (opt) => updateItem(item.id, "address", opt.label)
735
+ }
736
+ ) }),
737
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
738
+ /* @__PURE__ */ jsx(FormField, { label: "Property Type", children: /* @__PURE__ */ jsxs(
739
+ Select,
740
+ {
741
+ value: (_b = item.propertySubtype) != null ? _b : "",
742
+ onValueChange: (val) => updateItem(
743
+ item.id,
744
+ "propertySubtype",
745
+ val
746
+ ),
747
+ children: [
748
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
749
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_SUBTYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
750
+ ]
751
+ }
752
+ ) }),
753
+ /* @__PURE__ */ jsx(FormField, { label: "Used As", children: /* @__PURE__ */ jsxs(
754
+ Select,
755
+ {
756
+ value: (_c = item.usedAs) != null ? _c : "",
757
+ onValueChange: (val) => updateItem(item.id, "usedAs", val),
758
+ children: [
759
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
760
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_USED_AS.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
761
+ ]
762
+ }
763
+ ) })
764
+ ] })
765
+ ] }),
766
+ f.isVehicle && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
767
+ /* @__PURE__ */ jsx(FormField, { label: "Make", children: /* @__PURE__ */ jsx(
768
+ Input,
769
+ {
770
+ value: (_d = item.make) != null ? _d : "",
771
+ onChange: (e) => updateItem(item.id, "make", e.target.value),
772
+ placeholder: "e.g. Toyota"
773
+ }
774
+ ) }),
775
+ /* @__PURE__ */ jsx(FormField, { label: "Model", children: /* @__PURE__ */ jsx(
776
+ Input,
777
+ {
778
+ value: (_e = item.model) != null ? _e : "",
779
+ onChange: (e) => updateItem(item.id, "model", e.target.value),
780
+ placeholder: "e.g. Camry"
781
+ }
782
+ ) }),
783
+ /* @__PURE__ */ jsx(FormField, { label: "Year", children: /* @__PURE__ */ jsx(
784
+ Input,
785
+ {
786
+ type: "number",
787
+ min: 1900,
788
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
789
+ value: (_f = item.year) != null ? _f : "",
790
+ onChange: (e) => updateItem(item.id, "year", e.target.value),
791
+ placeholder: "e.g. 2022"
792
+ }
793
+ ) })
794
+ ] }),
795
+ (f.isFinancialAccount || f.isInvestment) && /* @__PURE__ */ jsx(FormField, { label: "Institution / Platform", children: /* @__PURE__ */ jsx(
796
+ Input,
797
+ {
798
+ value: (_g = item.institution) != null ? _g : "",
799
+ onChange: (e) => updateItem(
800
+ item.id,
801
+ "institution",
802
+ e.target.value
803
+ ),
804
+ placeholder: "e.g. CommBank, Vanguard"
805
+ }
806
+ ) }),
807
+ f.isSuper && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
808
+ /* @__PURE__ */ jsx(FormField, { label: "Fund Name", children: /* @__PURE__ */ jsx(
809
+ Input,
810
+ {
811
+ value: (_h = item.fundName) != null ? _h : "",
812
+ onChange: (e) => updateItem(
813
+ item.id,
814
+ "fundName",
815
+ e.target.value
816
+ ),
817
+ placeholder: "e.g. Australian Super"
818
+ }
819
+ ) }),
820
+ /* @__PURE__ */ jsx(FormField, { label: "Member Number", children: /* @__PURE__ */ jsx(
821
+ Input,
822
+ {
823
+ value: (_i = item.memberNumber) != null ? _i : "",
824
+ onChange: (e) => updateItem(
825
+ item.id,
826
+ "memberNumber",
827
+ e.target.value
828
+ ),
829
+ placeholder: "e.g. 1234567"
830
+ }
831
+ ) })
832
+ ] }),
833
+ f.isBusiness && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
834
+ /* @__PURE__ */ jsx(FormField, { label: "Business Name", children: /* @__PURE__ */ jsx(
835
+ Input,
836
+ {
837
+ value: (_j = item.businessName) != null ? _j : "",
838
+ onChange: (e) => updateItem(
839
+ item.id,
840
+ "businessName",
841
+ e.target.value
842
+ ),
843
+ placeholder: "e.g. Acme Pty Ltd"
844
+ }
845
+ ) }),
846
+ /* @__PURE__ */ jsx(FormField, { label: "ABN", children: /* @__PURE__ */ jsx(
847
+ Input,
848
+ {
849
+ value: (_k = item.abn) != null ? _k : "",
850
+ onChange: (e) => updateItem(item.id, "abn", e.target.value),
851
+ placeholder: "e.g. 12 345 678 901"
852
+ }
853
+ ) })
854
+ ] }),
855
+ f.isInsurance && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
856
+ /* @__PURE__ */ jsx(FormField, { label: "Insurer", children: /* @__PURE__ */ jsx(
857
+ Input,
858
+ {
859
+ value: (_l = item.insurer) != null ? _l : "",
860
+ onChange: (e) => updateItem(
861
+ item.id,
862
+ "insurer",
863
+ e.target.value
864
+ ),
865
+ placeholder: "e.g. TAL, AIA"
866
+ }
867
+ ) }),
868
+ /* @__PURE__ */ jsx(FormField, { label: "Policy Number", children: /* @__PURE__ */ jsx(
869
+ Input,
870
+ {
871
+ value: (_m = item.policyNumber) != null ? _m : "",
872
+ onChange: (e) => updateItem(
873
+ item.id,
874
+ "policyNumber",
875
+ e.target.value
876
+ ),
877
+ placeholder: "e.g. POL-123456"
878
+ }
879
+ ) })
880
+ ] })
881
+ ] });
882
+ })(),
883
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
884
+ OwnershipSplit,
885
+ {
886
+ owners: [
887
+ {
888
+ id: "main",
889
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
890
+ share: item.mainShare
891
+ },
892
+ {
893
+ id: "co",
894
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
895
+ share: item.coShare
896
+ }
897
+ ],
898
+ onOwnersChange: (owners) => {
899
+ var _a, _b, _c, _d;
900
+ updateItem(
901
+ item.id,
902
+ "mainShare",
903
+ (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : 50
904
+ );
905
+ updateItem(
906
+ item.id,
907
+ "coShare",
908
+ (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : 50
909
+ );
910
+ }
911
+ }
912
+ ) })
913
+ ] }) })
914
+ ] }, item.id))
915
+ }
916
+ ),
917
+ /* @__PURE__ */ jsxs(
918
+ Button,
919
+ {
920
+ variant: "outline",
921
+ onClick: addItem,
922
+ className: "w-full gap-1.5",
923
+ children: [
924
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
925
+ "Add More"
926
+ ]
927
+ }
928
+ )
929
+ ] }),
930
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
931
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
932
+ /* @__PURE__ */ jsx(
933
+ Button,
934
+ {
935
+ onClick: () => {
936
+ onSave(items);
937
+ onOpenChange(false);
938
+ },
939
+ children: "Save"
940
+ }
941
+ )
942
+ ] })
943
+ ] }) });
944
+ }
945
+ function EditDebtsModal({
946
+ open,
947
+ onOpenChange,
948
+ initialItems = [],
949
+ onSave,
950
+ mainApplicantName = "Main Applicant",
951
+ coApplicantName = "Co-Applicant",
952
+ className
953
+ }) {
954
+ const [items, setItems] = React.useState(
955
+ initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
956
+ );
957
+ React.useEffect(() => {
958
+ if (open) {
959
+ setItems(
960
+ initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
961
+ );
962
+ }
963
+ }, [open]);
964
+ const updateItem = (id, key, val) => setItems(
965
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
966
+ );
967
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
968
+ const addItem = () => setItems((prev) => [...prev, makeDefaultDebtItem()]);
969
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
970
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-xl", className), children: [
971
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsx(DialogTitle, { children: "Edit Debts" }) }),
972
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
973
+ /* @__PURE__ */ jsx(
974
+ Accordion,
975
+ {
976
+ multiple: true,
977
+ defaultValue: defaultOpenItems,
978
+ className: "w-full",
979
+ children: items.map((item) => {
980
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
981
+ const df = debtFields(item.debtType);
982
+ return /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
983
+ /* @__PURE__ */ jsx(
984
+ AccordionItemHeader,
985
+ {
986
+ label: item.debtType || "New Debt",
987
+ onRemove: () => removeItem(item.id),
988
+ removeLabel: "Remove debt"
989
+ }
990
+ ),
991
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
992
+ /* @__PURE__ */ jsx(FormField, { label: "Debt Type", children: /* @__PURE__ */ jsxs(
993
+ Select,
994
+ {
995
+ value: item.debtType,
996
+ onValueChange: (val) => updateItem(item.id, "debtType", val),
997
+ children: [
998
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
999
+ /* @__PURE__ */ jsx(SelectContent, { children: DEBT_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1000
+ ]
1001
+ }
1002
+ ) }),
1003
+ (df.isPropertyLoan || df.isGeneralLoan || df.isVehicle) && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1004
+ /* @__PURE__ */ jsx(FormField, { label: "Lender", children: /* @__PURE__ */ jsx(
1005
+ Input,
1006
+ {
1007
+ value: (_a = item.lender) != null ? _a : "",
1008
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
1009
+ placeholder: "e.g. CommBank"
1010
+ }
1011
+ ) }),
1012
+ /* @__PURE__ */ jsx(FormField, { label: "Account Number", children: /* @__PURE__ */ jsx(
1013
+ Input,
1014
+ {
1015
+ value: (_b = item.accountNumber) != null ? _b : "",
1016
+ onChange: (e) => updateItem(
1017
+ item.id,
1018
+ "accountNumber",
1019
+ e.target.value
1020
+ ),
1021
+ placeholder: "e.g. 123-456"
1022
+ }
1023
+ ) })
1024
+ ] }),
1025
+ df.isPropertyLoan && /* @__PURE__ */ jsx(FormField, { label: "Property Address", children: /* @__PURE__ */ jsx(
1026
+ AddressAutocomplete,
1027
+ {
1028
+ value: (_c = item.propertyAddress) != null ? _c : "",
1029
+ onValueChange: (val) => updateItem(item.id, "propertyAddress", val),
1030
+ onSelect: (opt) => updateItem(item.id, "propertyAddress", opt.label)
1031
+ }
1032
+ ) }),
1033
+ df.isVehicle && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-3 gap-4", children: [
1034
+ /* @__PURE__ */ jsx(FormField, { label: "Make", children: /* @__PURE__ */ jsx(
1035
+ Input,
1036
+ {
1037
+ value: (_d = item.vehicleMake) != null ? _d : "",
1038
+ onChange: (e) => updateItem(
1039
+ item.id,
1040
+ "vehicleMake",
1041
+ e.target.value
1042
+ ),
1043
+ placeholder: "e.g. Toyota"
1044
+ }
1045
+ ) }),
1046
+ /* @__PURE__ */ jsx(FormField, { label: "Model", children: /* @__PURE__ */ jsx(
1047
+ Input,
1048
+ {
1049
+ value: (_e = item.vehicleModel) != null ? _e : "",
1050
+ onChange: (e) => updateItem(
1051
+ item.id,
1052
+ "vehicleModel",
1053
+ e.target.value
1054
+ ),
1055
+ placeholder: "e.g. Camry"
1056
+ }
1057
+ ) }),
1058
+ /* @__PURE__ */ jsx(FormField, { label: "Year", children: /* @__PURE__ */ jsx(
1059
+ Input,
1060
+ {
1061
+ type: "number",
1062
+ min: 1900,
1063
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
1064
+ value: (_f = item.vehicleYear) != null ? _f : "",
1065
+ onChange: (e) => updateItem(
1066
+ item.id,
1067
+ "vehicleYear",
1068
+ e.target.value
1069
+ ),
1070
+ placeholder: "e.g. 2022"
1071
+ }
1072
+ ) })
1073
+ ] }),
1074
+ df.isCard && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1075
+ /* @__PURE__ */ jsx(FormField, { label: "Provider", children: /* @__PURE__ */ jsx(
1076
+ Input,
1077
+ {
1078
+ value: (_g = item.lender) != null ? _g : "",
1079
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
1080
+ placeholder: "e.g. ANZ, Afterpay"
1081
+ }
1082
+ ) }),
1083
+ /* @__PURE__ */ jsx(FormField, { label: "Credit Limit", children: /* @__PURE__ */ jsx(
1084
+ CurrencyInputWithSlider,
1085
+ {
1086
+ value: (_h = item.creditLimit) != null ? _h : 0,
1087
+ min: 0,
1088
+ max: 1e5,
1089
+ step: 500,
1090
+ onValueChange: (val) => updateItem(item.id, "creditLimit", val)
1091
+ }
1092
+ ) })
1093
+ ] }),
1094
+ df.isHecs && /* @__PURE__ */ jsx(FormField, { label: "Institution", children: /* @__PURE__ */ jsx(
1095
+ Input,
1096
+ {
1097
+ value: (_i = item.institution) != null ? _i : "",
1098
+ onChange: (e) => updateItem(item.id, "institution", e.target.value),
1099
+ placeholder: "e.g. University of Sydney"
1100
+ }
1101
+ ) }),
1102
+ df.isTax && /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1103
+ /* @__PURE__ */ jsx(FormField, { label: "Tax Year", children: /* @__PURE__ */ jsx(
1104
+ Input,
1105
+ {
1106
+ value: (_j = item.taxYear) != null ? _j : "",
1107
+ onChange: (e) => updateItem(item.id, "taxYear", e.target.value),
1108
+ placeholder: "e.g. 2023\u201324"
1109
+ }
1110
+ ) }),
1111
+ /* @__PURE__ */ jsx(FormField, { label: "ATO Reference", children: /* @__PURE__ */ jsx(
1112
+ Input,
1113
+ {
1114
+ value: (_k = item.referenceNumber) != null ? _k : "",
1115
+ onChange: (e) => updateItem(
1116
+ item.id,
1117
+ "referenceNumber",
1118
+ e.target.value
1119
+ ),
1120
+ placeholder: "e.g. 1234567890"
1121
+ }
1122
+ ) })
1123
+ ] }),
1124
+ df.isGuarantor && /* @__PURE__ */ jsx(FormField, { label: "Beneficiary (borrower's name)", children: /* @__PURE__ */ jsx(
1125
+ Input,
1126
+ {
1127
+ value: (_l = item.beneficiary) != null ? _l : "",
1128
+ onChange: (e) => updateItem(item.id, "beneficiary", e.target.value),
1129
+ placeholder: "e.g. Jane Smith"
1130
+ }
1131
+ ) }),
1132
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1133
+ /* @__PURE__ */ jsx(FormField, { label: "Amount Owing", children: /* @__PURE__ */ jsx(
1134
+ CurrencyInputWithSlider,
1135
+ {
1136
+ value: item.amountOwing,
1137
+ min: 0,
1138
+ max: 1e6,
1139
+ step: 1e3,
1140
+ onValueChange: (val) => updateItem(item.id, "amountOwing", val)
1141
+ }
1142
+ ) }),
1143
+ /* @__PURE__ */ jsx(FormField, { label: "Original Loan Amount", children: /* @__PURE__ */ jsx(
1144
+ CurrencyInputWithSlider,
1145
+ {
1146
+ value: item.originalLoanAmount,
1147
+ min: 0,
1148
+ max: 1e6,
1149
+ step: 1e3,
1150
+ onValueChange: (val) => updateItem(item.id, "originalLoanAmount", val)
1151
+ }
1152
+ ) })
1153
+ ] }),
1154
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1155
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Repayments", children: /* @__PURE__ */ jsx(
1156
+ CurrencyInputWithSlider,
1157
+ {
1158
+ value: item.repaymentAmount,
1159
+ min: 0,
1160
+ max: 1e6,
1161
+ step: 100,
1162
+ onValueChange: (val) => updateItem(item.id, "repaymentAmount", val)
1163
+ }
1164
+ ) }) }),
1165
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1166
+ FrequencyToggle,
1167
+ {
1168
+ value: item.repaymentFrequency,
1169
+ onValueChange: (val) => updateItem(item.id, "repaymentFrequency", val)
1170
+ }
1171
+ ) })
1172
+ ] }),
1173
+ /* @__PURE__ */ jsx(FormField, { label: "Interest Rate", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1174
+ /* @__PURE__ */ jsx(
1175
+ Input,
1176
+ {
1177
+ value: item.interestRate,
1178
+ onChange: (e) => updateItem(
1179
+ item.id,
1180
+ "interestRate",
1181
+ e.target.value
1182
+ ),
1183
+ placeholder: "e.g. 6.5",
1184
+ className: "flex-1"
1185
+ }
1186
+ ),
1187
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "%" })
1188
+ ] }) }),
1189
+ /* @__PURE__ */ jsx(FormField, { label: "Notes", children: /* @__PURE__ */ jsx(
1190
+ Textarea,
1191
+ {
1192
+ value: item.details,
1193
+ onChange: (e) => updateItem(item.id, "details", e.target.value),
1194
+ placeholder: "Short comment",
1195
+ rows: 2
1196
+ }
1197
+ ) }),
1198
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
1199
+ OwnershipSplit,
1200
+ {
1201
+ owners: [
1202
+ {
1203
+ id: "main",
1204
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
1205
+ share: item.mainShare
1206
+ },
1207
+ {
1208
+ id: "co",
1209
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
1210
+ share: item.coShare
1211
+ }
1212
+ ],
1213
+ onOwnersChange: (owners) => {
1214
+ var _a2, _b2, _c2, _d2;
1215
+ updateItem(
1216
+ item.id,
1217
+ "mainShare",
1218
+ (_b2 = (_a2 = owners.find((o) => o.id === "main")) == null ? void 0 : _a2.share) != null ? _b2 : 50
1219
+ );
1220
+ updateItem(
1221
+ item.id,
1222
+ "coShare",
1223
+ (_d2 = (_c2 = owners.find((o) => o.id === "co")) == null ? void 0 : _c2.share) != null ? _d2 : 50
1224
+ );
1225
+ }
1226
+ }
1227
+ ) })
1228
+ ] }) })
1229
+ ] }, item.id);
1230
+ })
1231
+ }
1232
+ ),
1233
+ /* @__PURE__ */ jsxs(
1234
+ Button,
1235
+ {
1236
+ variant: "outline",
1237
+ onClick: addItem,
1238
+ className: "w-full gap-1.5",
1239
+ children: [
1240
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1241
+ "Add More"
1242
+ ]
1243
+ }
1244
+ )
1245
+ ] }),
1246
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1247
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1248
+ /* @__PURE__ */ jsx(
1249
+ Button,
1250
+ {
1251
+ onClick: () => {
1252
+ onSave(items);
1253
+ onOpenChange(false);
1254
+ },
1255
+ children: "Save"
1256
+ }
1257
+ )
1258
+ ] })
1259
+ ] }) });
1260
+ }
1261
+ function EditAboutApplicantModal({
1262
+ open,
1263
+ onOpenChange,
1264
+ applicantLabel = "Applicant",
1265
+ initialData,
1266
+ onSave,
1267
+ className
1268
+ }) {
1269
+ const [form, setForm] = React.useState(__spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData));
1270
+ React.useEffect(() => {
1271
+ if (open) {
1272
+ setForm(__spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData));
1273
+ }
1274
+ }, [open]);
1275
+ const setStr = (key) => (val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
1276
+ const handleNumDependantsChange = (val) => {
1277
+ const n = Math.max(0, Math.min(20, parseInt(val, 10) || 0));
1278
+ setForm((prev) => {
1279
+ var _a;
1280
+ const current = (_a = prev.dependants) != null ? _a : [];
1281
+ const next = n > current.length ? [...current, ...Array(n - current.length).fill({ dob: "" })] : current.slice(0, n);
1282
+ return __spreadProps(__spreadValues({}, prev), { numDependants: val, dependants: next });
1283
+ });
1284
+ };
1285
+ const setDependantDob = (index, dob) => setForm((prev) => {
1286
+ const next = prev.dependants.map((d, i) => i === index ? { dob } : d);
1287
+ return __spreadProps(__spreadValues({}, prev), { dependants: next });
1288
+ });
1289
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-md", className), children: [
1290
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1291
+ "Edit About ",
1292
+ applicantLabel
1293
+ ] }) }),
1294
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1295
+ /* @__PURE__ */ jsxs("div", { className: "flex gap-3 items-start", children: [
1296
+ /* @__PURE__ */ jsx("div", { className: "w-24 shrink-0", children: /* @__PURE__ */ jsx(FormField, { label: "Title", children: /* @__PURE__ */ jsxs(Select, { value: form.title, onValueChange: setStr("title"), children: [
1297
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Title" }) }),
1298
+ /* @__PURE__ */ jsx(SelectContent, { children: TITLE_OPTIONS.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1299
+ ] }) }) }),
1300
+ /* @__PURE__ */ jsx(FormField, { label: "First Name", className: "flex-1", children: /* @__PURE__ */ jsx(
1301
+ Input,
1302
+ {
1303
+ value: form.firstName,
1304
+ onChange: (e) => setStr("firstName")(e.target.value),
1305
+ placeholder: "First name"
1306
+ }
1307
+ ) }),
1308
+ /* @__PURE__ */ jsx(FormField, { label: "Last Name", className: "flex-1", children: /* @__PURE__ */ jsx(
1309
+ Input,
1310
+ {
1311
+ value: form.lastName,
1312
+ onChange: (e) => setStr("lastName")(e.target.value),
1313
+ placeholder: "Last name"
1314
+ }
1315
+ ) })
1316
+ ] }),
1317
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1318
+ /* @__PURE__ */ jsx(FormField, { label: "Phone Number", children: /* @__PURE__ */ jsx(
1319
+ Input,
1320
+ {
1321
+ value: form.phone,
1322
+ onChange: (e) => setStr("phone")(e.target.value),
1323
+ placeholder: "+61 4xx xxx xxx",
1324
+ type: "tel"
1325
+ }
1326
+ ) }),
1327
+ /* @__PURE__ */ jsx(FormField, { label: "Email", children: /* @__PURE__ */ jsx(
1328
+ Input,
1329
+ {
1330
+ value: form.email,
1331
+ onChange: (e) => setStr("email")(e.target.value),
1332
+ placeholder: "email@example.com",
1333
+ type: "email"
1334
+ }
1335
+ ) })
1336
+ ] }),
1337
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1338
+ /* @__PURE__ */ jsx(FormField, { label: "Date of Birth", children: /* @__PURE__ */ jsx(
1339
+ DatePicker,
1340
+ {
1341
+ value: form.dob ? new Date(form.dob) : void 0,
1342
+ onChange: (d) => setStr("dob")(d ? d.toISOString().slice(0, 10) : ""),
1343
+ calendarProps: {
1344
+ fromYear: 1900,
1345
+ toYear: (/* @__PURE__ */ new Date()).getFullYear() - 16
1346
+ }
1347
+ }
1348
+ ) }),
1349
+ /* @__PURE__ */ jsx(FormField, { label: "Gender", children: /* @__PURE__ */ jsxs(Select, { value: form.gender, onValueChange: setStr("gender"), children: [
1350
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1351
+ /* @__PURE__ */ jsx(SelectContent, { children: GENDER_OPTIONS.map((g) => /* @__PURE__ */ jsx(SelectItem, { value: g, children: g }, g)) })
1352
+ ] }) })
1353
+ ] }),
1354
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1355
+ /* @__PURE__ */ jsx(FormField, { label: "Marital Status", children: /* @__PURE__ */ jsxs(
1356
+ Select,
1357
+ {
1358
+ value: form.maritalStatus,
1359
+ onValueChange: setStr("maritalStatus"),
1360
+ children: [
1361
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1362
+ /* @__PURE__ */ jsx(SelectContent, { children: MARITAL_OPTIONS.map((m) => /* @__PURE__ */ jsx(SelectItem, { value: m, children: m }, m)) })
1363
+ ]
1364
+ }
1365
+ ) }),
1366
+ /* @__PURE__ */ jsx(FormField, { label: "No. of Dependants", children: /* @__PURE__ */ jsx(
1367
+ Input,
1368
+ {
1369
+ type: "number",
1370
+ min: 0,
1371
+ max: 20,
1372
+ value: form.numDependants,
1373
+ onChange: (e) => handleNumDependantsChange(e.target.value),
1374
+ placeholder: "0"
1375
+ }
1376
+ ) })
1377
+ ] }),
1378
+ form.dependants.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
1379
+ /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium", children: "Dependant Date of Birth" }),
1380
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-2 gap-3", children: form.dependants.map((dep, i) => /* @__PURE__ */ jsx(FormField, { label: `Dependant ${i + 1}`, children: /* @__PURE__ */ jsx(
1381
+ DatePicker,
1382
+ {
1383
+ value: dep.dob ? new Date(dep.dob) : void 0,
1384
+ onChange: (d) => setDependantDob(
1385
+ i,
1386
+ d ? d.toISOString().slice(0, 10) : ""
1387
+ ),
1388
+ calendarProps: {
1389
+ fromYear: 1900,
1390
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1391
+ }
1392
+ }
1393
+ ) }, i)) })
1394
+ ] }),
1395
+ /* @__PURE__ */ jsx(FormField, { label: "Citizen Status", children: /* @__PURE__ */ jsxs(
1396
+ Select,
1397
+ {
1398
+ value: form.citizenStatus,
1399
+ onValueChange: setStr("citizenStatus"),
1400
+ children: [
1401
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select status" }) }),
1402
+ /* @__PURE__ */ jsx(SelectContent, { children: CITIZEN_OPTIONS.map((c) => /* @__PURE__ */ jsx(SelectItem, { value: c, children: c }, c)) })
1403
+ ]
1404
+ }
1405
+ ) }),
1406
+ /* @__PURE__ */ jsx(FormField, { label: "Current Residential Address", children: /* @__PURE__ */ jsx(
1407
+ AddressAutocomplete,
1408
+ {
1409
+ value: form.residentialAddress,
1410
+ onValueChange: setStr("residentialAddress"),
1411
+ onSelect: (opt) => setStr("residentialAddress")(opt.label)
1412
+ }
1413
+ ) }),
1414
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1415
+ /* @__PURE__ */ jsx(FormField, { label: "Residential Status", children: /* @__PURE__ */ jsxs(
1416
+ Select,
1417
+ {
1418
+ value: form.residentialStatus,
1419
+ onValueChange: setStr("residentialStatus"),
1420
+ children: [
1421
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1422
+ /* @__PURE__ */ jsx(SelectContent, { children: RESIDENTIAL_STATUS_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1423
+ ]
1424
+ }
1425
+ ) }),
1426
+ /* @__PURE__ */ jsx(FormField, { label: "Time at Address", children: /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
1427
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
1428
+ /* @__PURE__ */ jsx(
1429
+ Input,
1430
+ {
1431
+ type: "number",
1432
+ min: 0,
1433
+ value: form.timeAtAddressYears,
1434
+ onChange: (e) => setStr("timeAtAddressYears")(e.target.value),
1435
+ placeholder: "0"
1436
+ }
1437
+ ),
1438
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "yr" })
1439
+ ] }),
1440
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 flex-1", children: [
1441
+ /* @__PURE__ */ jsx(
1442
+ Input,
1443
+ {
1444
+ type: "number",
1445
+ min: 0,
1446
+ max: 11,
1447
+ value: form.timeAtAddressMonths,
1448
+ onChange: (e) => setStr("timeAtAddressMonths")(e.target.value),
1449
+ placeholder: "0"
1450
+ }
1451
+ ),
1452
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground shrink-0", children: "mo" })
1453
+ ] })
1454
+ ] }) })
1455
+ ] }),
1456
+ parseInt(form.timeAtAddressYears || "99") < 2 && /* @__PURE__ */ jsx(FormField, { label: "Previous Address", children: /* @__PURE__ */ jsx(
1457
+ AddressAutocomplete,
1458
+ {
1459
+ value: form.previousAddress,
1460
+ onValueChange: setStr("previousAddress"),
1461
+ onSelect: (opt) => setStr("previousAddress")(opt.label)
1462
+ }
1463
+ ) }),
1464
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1465
+ /* @__PURE__ */ jsx(FormField, { label: "Driver's Licence", children: /* @__PURE__ */ jsx(
1466
+ Input,
1467
+ {
1468
+ value: form.driversLicence,
1469
+ onChange: (e) => setStr("driversLicence")(e.target.value),
1470
+ placeholder: "e.g. 12345678"
1471
+ }
1472
+ ) }),
1473
+ /* @__PURE__ */ jsx(FormField, { label: "Passport Number", children: /* @__PURE__ */ jsx(
1474
+ Input,
1475
+ {
1476
+ value: form.passport,
1477
+ onChange: (e) => setStr("passport")(e.target.value),
1478
+ placeholder: "e.g. PA1234567"
1479
+ }
1480
+ ) })
1481
+ ] }),
1482
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1483
+ /* @__PURE__ */ jsx(FormField, { label: "Property in Trust", children: /* @__PURE__ */ jsxs(
1484
+ Select,
1485
+ {
1486
+ value: form.propertyInTrust,
1487
+ onValueChange: setStr("propertyInTrust"),
1488
+ children: [
1489
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1490
+ /* @__PURE__ */ jsx(SelectContent, { children: PROPERTY_IN_TRUST_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1491
+ ]
1492
+ }
1493
+ ) }),
1494
+ /* @__PURE__ */ jsx(FormField, { label: "Company Ownership", children: /* @__PURE__ */ jsxs(
1495
+ Select,
1496
+ {
1497
+ value: form.companyOwnership,
1498
+ onValueChange: setStr("companyOwnership"),
1499
+ children: [
1500
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select" }) }),
1501
+ /* @__PURE__ */ jsx(SelectContent, { children: COMPANY_OWNERSHIP_OPTIONS.map((o) => /* @__PURE__ */ jsx(SelectItem, { value: o, children: o }, o)) })
1502
+ ]
1503
+ }
1504
+ ) })
1505
+ ] })
1506
+ ] }),
1507
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1508
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1509
+ /* @__PURE__ */ jsx(
1510
+ Button,
1511
+ {
1512
+ onClick: () => {
1513
+ onSave(form);
1514
+ onOpenChange(false);
1515
+ },
1516
+ children: "Save"
1517
+ }
1518
+ )
1519
+ ] })
1520
+ ] }) });
1521
+ }
1522
+ function EditIncomeModal({
1523
+ open,
1524
+ onOpenChange,
1525
+ applicantLabel = "Applicant",
1526
+ initialData,
1527
+ onSave,
1528
+ className
1529
+ }) {
1530
+ const defaultItems = React.useMemo(
1531
+ () => {
1532
+ var _a;
1533
+ return ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()];
1534
+ },
1535
+ []
1536
+ // eslint-disable-line react-hooks/exhaustive-deps
1537
+ );
1538
+ const [items, setItems] = React.useState(defaultItems);
1539
+ React.useEffect(() => {
1540
+ var _a;
1541
+ if (open) {
1542
+ setItems(
1543
+ ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()]
1544
+ );
1545
+ }
1546
+ }, [open]);
1547
+ const updateItem = (id, key, val) => setItems(
1548
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
1549
+ );
1550
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
1551
+ const addItem = () => setItems((prev) => [...prev, makeDefaultIncomeItem()]);
1552
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
1553
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-lg", className), children: [
1554
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1555
+ "Edit Income ",
1556
+ applicantLabel
1557
+ ] }) }),
1558
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1559
+ /* @__PURE__ */ jsx(
1560
+ Accordion,
1561
+ {
1562
+ multiple: true,
1563
+ defaultValue: defaultOpenItems,
1564
+ className: "w-full",
1565
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
1566
+ /* @__PURE__ */ jsx(
1567
+ AccordionItemHeader,
1568
+ {
1569
+ label: `Income ${index + 1} \u2014 ${item.incomeType || "New Income"}`,
1570
+ onRemove: () => removeItem(item.id),
1571
+ removeLabel: "Remove income item"
1572
+ }
1573
+ ),
1574
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
1575
+ /* @__PURE__ */ jsx(FormField, { label: "Income Type", children: /* @__PURE__ */ jsxs(
1576
+ Select,
1577
+ {
1578
+ value: item.incomeType,
1579
+ onValueChange: (val) => updateItem(item.id, "incomeType", val),
1580
+ children: [
1581
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
1582
+ /* @__PURE__ */ jsx(SelectContent, { children: INCOME_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1583
+ ]
1584
+ }
1585
+ ) }),
1586
+ /* @__PURE__ */ jsx(FormField, { label: "Job Title", children: /* @__PURE__ */ jsx(
1587
+ Input,
1588
+ {
1589
+ value: item.jobTitle,
1590
+ onChange: (e) => updateItem(item.id, "jobTitle", e.target.value),
1591
+ placeholder: "Job title"
1592
+ }
1593
+ ) }),
1594
+ /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
1595
+ /* @__PURE__ */ jsx(FormField, { label: "Start Date", children: /* @__PURE__ */ jsx(
1596
+ DatePicker,
1597
+ {
1598
+ value: item.startDate ? new Date(item.startDate) : void 0,
1599
+ onChange: (d) => updateItem(
1600
+ item.id,
1601
+ "startDate",
1602
+ d ? d.toISOString().slice(0, 10) : ""
1603
+ ),
1604
+ calendarProps: {
1605
+ fromYear: 1950,
1606
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1607
+ }
1608
+ }
1609
+ ) }),
1610
+ !item.stillInPosition && /* @__PURE__ */ jsx(FormField, { label: "End Date", children: /* @__PURE__ */ jsx(
1611
+ DatePicker,
1612
+ {
1613
+ value: item.endDate ? new Date(item.endDate) : void 0,
1614
+ onChange: (d) => updateItem(
1615
+ item.id,
1616
+ "endDate",
1617
+ d ? d.toISOString().slice(0, 10) : ""
1618
+ ),
1619
+ calendarProps: {
1620
+ fromYear: 1950,
1621
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
1622
+ }
1623
+ }
1624
+ ) })
1625
+ ] }),
1626
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1627
+ /* @__PURE__ */ jsx(
1628
+ Checkbox,
1629
+ {
1630
+ id: `still-in-position-${item.id}`,
1631
+ checked: item.stillInPosition,
1632
+ onCheckedChange: (checked) => updateItem(
1633
+ item.id,
1634
+ "stillInPosition",
1635
+ checked === true
1636
+ )
1637
+ }
1638
+ ),
1639
+ /* @__PURE__ */ jsx(
1640
+ "label",
1641
+ {
1642
+ htmlFor: `still-in-position-${item.id}`,
1643
+ className: "text-sm cursor-pointer select-none",
1644
+ children: "Still in position"
1645
+ }
1646
+ )
1647
+ ] }),
1648
+ /* @__PURE__ */ jsx(FormField, { label: "Company Name", children: /* @__PURE__ */ jsx(
1649
+ Input,
1650
+ {
1651
+ value: item.companyName,
1652
+ onChange: (e) => updateItem(item.id, "companyName", e.target.value),
1653
+ placeholder: "Company name"
1654
+ }
1655
+ ) }),
1656
+ /* @__PURE__ */ jsx(FormField, { label: "Company Address", children: /* @__PURE__ */ jsx(
1657
+ AddressAutocomplete,
1658
+ {
1659
+ value: item.companyAddress,
1660
+ onValueChange: (val) => updateItem(item.id, "companyAddress", val),
1661
+ placeholder: "Search company address"
1662
+ }
1663
+ ) }),
1664
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1665
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Income Amount", children: /* @__PURE__ */ jsx(
1666
+ CurrencyInputWithSlider,
1667
+ {
1668
+ value: item.incomeAmount,
1669
+ min: 0,
1670
+ max: 1e6,
1671
+ step: 1e3,
1672
+ onValueChange: (val) => updateItem(item.id, "incomeAmount", val)
1673
+ }
1674
+ ) }) }),
1675
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1676
+ FrequencyToggle,
1677
+ {
1678
+ value: item.frequency,
1679
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
1680
+ }
1681
+ ) })
1682
+ ] }),
1683
+ /* @__PURE__ */ jsx(FormField, { label: "Type of Company", children: /* @__PURE__ */ jsx(
1684
+ RadioGroup,
1685
+ {
1686
+ value: item.companyType,
1687
+ onValueChange: (val) => updateItem(
1688
+ item.id,
1689
+ "companyType",
1690
+ val
1691
+ ),
1692
+ className: "flex gap-4",
1693
+ children: ["Public", "Private"].map((opt) => /* @__PURE__ */ jsxs(
1694
+ "label",
1695
+ {
1696
+ className: "flex items-center gap-2 cursor-pointer text-sm",
1697
+ children: [
1698
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: opt }),
1699
+ opt
1700
+ ]
1701
+ },
1702
+ opt
1703
+ ))
1704
+ }
1705
+ ) })
1706
+ ] }) })
1707
+ ] }, item.id))
1708
+ }
1709
+ ),
1710
+ /* @__PURE__ */ jsxs(
1711
+ Button,
1712
+ {
1713
+ variant: "outline",
1714
+ onClick: addItem,
1715
+ className: "w-full gap-1.5",
1716
+ children: [
1717
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1718
+ "Add More"
1719
+ ]
1720
+ }
1721
+ )
1722
+ ] }),
1723
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1724
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1725
+ /* @__PURE__ */ jsx(
1726
+ Button,
1727
+ {
1728
+ onClick: () => {
1729
+ onSave({ items });
1730
+ onOpenChange(false);
1731
+ },
1732
+ children: "Save"
1733
+ }
1734
+ )
1735
+ ] })
1736
+ ] }) });
1737
+ }
1738
+ function EditExpensesModal({
1739
+ open,
1740
+ onOpenChange,
1741
+ applicantLabel = "Applicant",
1742
+ initialData,
1743
+ onSave,
1744
+ className
1745
+ }) {
1746
+ const defaultItems = React.useMemo(
1747
+ () => {
1748
+ var _a;
1749
+ return ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()];
1750
+ },
1751
+ []
1752
+ // eslint-disable-line react-hooks/exhaustive-deps
1753
+ );
1754
+ const [items, setItems] = React.useState(defaultItems);
1755
+ React.useEffect(() => {
1756
+ var _a;
1757
+ if (open) {
1758
+ setItems(
1759
+ ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()]
1760
+ );
1761
+ }
1762
+ }, [open]);
1763
+ const updateItem = (id, key, val) => setItems(
1764
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
1765
+ );
1766
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
1767
+ const addItem = () => setItems((prev) => [...prev, makeDefaultExpenseItem()]);
1768
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
1769
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: cn("max-w-lg", className), children: [
1770
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { children: [
1771
+ "Edit Expenses ",
1772
+ applicantLabel
1773
+ ] }) }),
1774
+ /* @__PURE__ */ jsxs(ModalScroll, { children: [
1775
+ /* @__PURE__ */ jsx(
1776
+ Accordion,
1777
+ {
1778
+ multiple: true,
1779
+ defaultValue: defaultOpenItems,
1780
+ className: "w-full",
1781
+ children: items.map((item, index) => /* @__PURE__ */ jsxs(AccordionItem, { value: item.id, children: [
1782
+ /* @__PURE__ */ jsx(
1783
+ AccordionItemHeader,
1784
+ {
1785
+ label: `Expense ${index + 1} \u2014 ${item.expenseType || "New Expense"}`,
1786
+ onRemove: () => removeItem(item.id),
1787
+ removeLabel: "Remove expense item"
1788
+ }
1789
+ ),
1790
+ /* @__PURE__ */ jsx(AccordionContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 pt-1", children: [
1791
+ /* @__PURE__ */ jsx(FormField, { label: "Expense Type", children: /* @__PURE__ */ jsxs(
1792
+ Select,
1793
+ {
1794
+ value: item.expenseType,
1795
+ onValueChange: (val) => updateItem(item.id, "expenseType", val),
1796
+ children: [
1797
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select type" }) }),
1798
+ /* @__PURE__ */ jsx(SelectContent, { children: EXPENSE_TYPES.map((t) => /* @__PURE__ */ jsx(SelectItem, { value: t, children: t }, t)) })
1799
+ ]
1800
+ }
1801
+ ) }),
1802
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
1803
+ /* @__PURE__ */ jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsx(FormField, { label: "Amount", children: /* @__PURE__ */ jsx(
1804
+ CurrencyInputWithSlider,
1805
+ {
1806
+ value: item.amount,
1807
+ min: 0,
1808
+ max: 1e5,
1809
+ step: 100,
1810
+ onValueChange: (val) => updateItem(item.id, "amount", val)
1811
+ }
1812
+ ) }) }),
1813
+ /* @__PURE__ */ jsx("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ jsx(
1814
+ FrequencyToggle,
1815
+ {
1816
+ value: item.frequency,
1817
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
1818
+ }
1819
+ ) })
1820
+ ] }),
1821
+ /* @__PURE__ */ jsx(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ jsx(
1822
+ OwnershipSplit,
1823
+ {
1824
+ owners: [
1825
+ {
1826
+ id: "main",
1827
+ name: "Main Applicant",
1828
+ share: item.mainShare
1829
+ },
1830
+ {
1831
+ id: "co",
1832
+ name: "Co-Applicant",
1833
+ share: item.coShare
1834
+ }
1835
+ ],
1836
+ onOwnersChange: (owners) => {
1837
+ var _a, _b, _c, _d;
1838
+ const main = (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : item.mainShare;
1839
+ const co = (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : item.coShare;
1840
+ updateItem(item.id, "mainShare", main);
1841
+ updateItem(item.id, "coShare", co);
1842
+ }
1843
+ }
1844
+ ) })
1845
+ ] }) })
1846
+ ] }, item.id))
1847
+ }
1848
+ ),
1849
+ /* @__PURE__ */ jsxs(
1850
+ Button,
1851
+ {
1852
+ variant: "outline",
1853
+ onClick: addItem,
1854
+ className: "w-full gap-1.5",
1855
+ children: [
1856
+ /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
1857
+ "Add More"
1858
+ ]
1859
+ }
1860
+ )
1861
+ ] }),
1862
+ /* @__PURE__ */ jsxs(DialogFooter, { children: [
1863
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
1864
+ /* @__PURE__ */ jsx(
1865
+ Button,
1866
+ {
1867
+ onClick: () => {
1868
+ onSave({ items });
1869
+ onOpenChange(false);
1870
+ },
1871
+ children: "Save"
1872
+ }
1873
+ )
1874
+ ] })
1875
+ ] }) });
1876
+ }
1877
+
1878
+ export {
1879
+ EditLoanScenarioModal,
1880
+ EditAssetsModal,
1881
+ EditDebtsModal,
1882
+ EditAboutApplicantModal,
1883
+ EditIncomeModal,
1884
+ EditExpensesModal
1885
+ };