@fayz-ai/admin 0.10.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 (557) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -0
  3. package/dist/CommandPalette-2AL327XQ.js +258 -0
  4. package/dist/CommandPalette-2AL327XQ.js.map +1 -0
  5. package/dist/ImportWizard-CISHGNQC.js +3 -0
  6. package/dist/ImportWizard-CISHGNQC.js.map +1 -0
  7. package/dist/ScheduleEditor-BSFF7LME.js +1040 -0
  8. package/dist/ScheduleEditor-BSFF7LME.js.map +1 -0
  9. package/dist/SubscriptionPage-NLZAZO4P.js +7 -0
  10. package/dist/SubscriptionPage-NLZAZO4P.js.map +1 -0
  11. package/dist/access/context.d.ts +47 -0
  12. package/dist/access/context.d.ts.map +1 -0
  13. package/dist/access/headless.d.ts +21 -0
  14. package/dist/access/headless.d.ts.map +1 -0
  15. package/dist/access/index.d.ts +12 -0
  16. package/dist/access/index.d.ts.map +1 -0
  17. package/dist/access/limits-registry.d.ts +33 -0
  18. package/dist/access/limits-registry.d.ts.map +1 -0
  19. package/dist/access/module-nav.d.ts +15 -0
  20. package/dist/access/module-nav.d.ts.map +1 -0
  21. package/dist/access/resolver.d.ts +2 -0
  22. package/dist/access/resolver.d.ts.map +1 -0
  23. package/dist/access/types.d.ts +43 -0
  24. package/dist/access/types.d.ts.map +1 -0
  25. package/dist/access/upgrade-modal-store.d.ts +23 -0
  26. package/dist/access/upgrade-modal-store.d.ts.map +1 -0
  27. package/dist/app/AdminShell.d.ts +65 -0
  28. package/dist/app/AdminShell.d.ts.map +1 -0
  29. package/dist/app/LoginPage.d.ts +3 -0
  30. package/dist/app/LoginPage.d.ts.map +1 -0
  31. package/dist/app/admin-app.d.ts +23 -0
  32. package/dist/app/admin-app.d.ts.map +1 -0
  33. package/dist/app/config.d.ts +277 -0
  34. package/dist/app/config.d.ts.map +1 -0
  35. package/dist/app/core-entities.d.ts +25 -0
  36. package/dist/app/core-entities.d.ts.map +1 -0
  37. package/dist/app/derive-contract.d.ts +8 -0
  38. package/dist/app/derive-contract.d.ts.map +1 -0
  39. package/dist/app/nav-contributions.store.d.ts +17 -0
  40. package/dist/app/nav-contributions.store.d.ts.map +1 -0
  41. package/dist/app/routing.d.ts +10 -0
  42. package/dist/app/routing.d.ts.map +1 -0
  43. package/dist/app/scaffold.d.ts +17 -0
  44. package/dist/app/scaffold.d.ts.map +1 -0
  45. package/dist/billing/index.d.ts +5 -0
  46. package/dist/billing/index.d.ts.map +1 -0
  47. package/dist/billing/index.js +3 -0
  48. package/dist/billing/index.js.map +1 -0
  49. package/dist/billing/plan-badge.d.ts +17 -0
  50. package/dist/billing/plan-badge.d.ts.map +1 -0
  51. package/dist/billing/store.d.ts +40 -0
  52. package/dist/billing/store.d.ts.map +1 -0
  53. package/dist/chunk-5O2UJAQ7.js +534 -0
  54. package/dist/chunk-5O2UJAQ7.js.map +1 -0
  55. package/dist/chunk-PNAJODZM.js +315 -0
  56. package/dist/chunk-PNAJODZM.js.map +1 -0
  57. package/dist/chunk-RKXZ7RUG.js +20 -0
  58. package/dist/chunk-RKXZ7RUG.js.map +1 -0
  59. package/dist/chunk-TNTZHUL6.js +817 -0
  60. package/dist/chunk-TNTZHUL6.js.map +1 -0
  61. package/dist/chunk-UMRN6427.js +510 -0
  62. package/dist/chunk-UMRN6427.js.map +1 -0
  63. package/dist/chunk-VN5NTK26.js +36 -0
  64. package/dist/chunk-VN5NTK26.js.map +1 -0
  65. package/dist/chunk-VTEP2AQX.js +101 -0
  66. package/dist/chunk-VTEP2AQX.js.map +1 -0
  67. package/dist/chunk-YUHCC7JY.js +11 -0
  68. package/dist/chunk-YUHCC7JY.js.map +1 -0
  69. package/dist/components/RightRail.d.ts +8 -0
  70. package/dist/components/RightRail.d.ts.map +1 -0
  71. package/dist/components/auth/CenteredLogin.d.ts +13 -0
  72. package/dist/components/auth/CenteredLogin.d.ts.map +1 -0
  73. package/dist/components/auth/LoginForm.d.ts +12 -0
  74. package/dist/components/auth/LoginForm.d.ts.map +1 -0
  75. package/dist/components/auth/LoginPage.d.ts +15 -0
  76. package/dist/components/auth/LoginPage.d.ts.map +1 -0
  77. package/dist/components/auth/OAuthButtons.d.ts +10 -0
  78. package/dist/components/auth/OAuthButtons.d.ts.map +1 -0
  79. package/dist/components/auth/ProtectedRoute.d.ts +11 -0
  80. package/dist/components/auth/ProtectedRoute.d.ts.map +1 -0
  81. package/dist/components/auth/RecoveryForm.d.ts +9 -0
  82. package/dist/components/auth/RecoveryForm.d.ts.map +1 -0
  83. package/dist/components/auth/SignupForm.d.ts +10 -0
  84. package/dist/components/auth/SignupForm.d.ts.map +1 -0
  85. package/dist/components/auth/SplitLogin.d.ts +14 -0
  86. package/dist/components/auth/SplitLogin.d.ts.map +1 -0
  87. package/dist/components/auth/index.d.ts +7 -0
  88. package/dist/components/auth/index.d.ts.map +1 -0
  89. package/dist/components/billing/InvoiceList.d.ts +9 -0
  90. package/dist/components/billing/InvoiceList.d.ts.map +1 -0
  91. package/dist/components/billing/PlanSelector.d.ts +13 -0
  92. package/dist/components/billing/PlanSelector.d.ts.map +1 -0
  93. package/dist/components/billing/SoftLimitBanner.d.ts +5 -0
  94. package/dist/components/billing/SoftLimitBanner.d.ts.map +1 -0
  95. package/dist/components/billing/SubscriptionCard.d.ts +12 -0
  96. package/dist/components/billing/SubscriptionCard.d.ts.map +1 -0
  97. package/dist/components/billing/SubscriptionPage.d.ts +5 -0
  98. package/dist/components/billing/SubscriptionPage.d.ts.map +1 -0
  99. package/dist/components/billing/UpgradeModal.d.ts +3 -0
  100. package/dist/components/billing/UpgradeModal.d.ts.map +1 -0
  101. package/dist/components/billing/UpgradeOverlay.d.ts +15 -0
  102. package/dist/components/billing/UpgradeOverlay.d.ts.map +1 -0
  103. package/dist/components/billing/UpgradePrompt.d.ts +10 -0
  104. package/dist/components/billing/UpgradePrompt.d.ts.map +1 -0
  105. package/dist/components/billing/access-contract.d.ts +18 -0
  106. package/dist/components/billing/access-contract.d.ts.map +1 -0
  107. package/dist/components/billing/gates.d.ts +14 -0
  108. package/dist/components/billing/gates.d.ts.map +1 -0
  109. package/dist/components/billing/index.d.ts +15 -0
  110. package/dist/components/billing/index.d.ts.map +1 -0
  111. package/dist/components/billing/plan-feature.d.ts +11 -0
  112. package/dist/components/billing/plan-feature.d.ts.map +1 -0
  113. package/dist/components/chat/ChatAttachments.d.ts +23 -0
  114. package/dist/components/chat/ChatAttachments.d.ts.map +1 -0
  115. package/dist/components/chat/ChatComposer.d.ts +21 -0
  116. package/dist/components/chat/ChatComposer.d.ts.map +1 -0
  117. package/dist/components/chat/ChatConversation.d.ts +20 -0
  118. package/dist/components/chat/ChatConversation.d.ts.map +1 -0
  119. package/dist/components/chat/ChatFab.d.ts +17 -0
  120. package/dist/components/chat/ChatFab.d.ts.map +1 -0
  121. package/dist/components/chat/ChatHistory.d.ts +16 -0
  122. package/dist/components/chat/ChatHistory.d.ts.map +1 -0
  123. package/dist/components/chat/ChatMessages.d.ts +16 -0
  124. package/dist/components/chat/ChatMessages.d.ts.map +1 -0
  125. package/dist/components/chat/ChatSuggestions.d.ts +17 -0
  126. package/dist/components/chat/ChatSuggestions.d.ts.map +1 -0
  127. package/dist/components/chat/ConfirmActionCard.d.ts +19 -0
  128. package/dist/components/chat/ConfirmActionCard.d.ts.map +1 -0
  129. package/dist/components/chat/RecordChip.d.ts +12 -0
  130. package/dist/components/chat/RecordChip.d.ts.map +1 -0
  131. package/dist/components/chat/index.d.ts +4 -0
  132. package/dist/components/chat/index.d.ts.map +1 -0
  133. package/dist/components/chat/markdown.d.ts +5 -0
  134. package/dist/components/chat/markdown.d.ts.map +1 -0
  135. package/dist/components/connect/AddConnectorPanel.d.ts +32 -0
  136. package/dist/components/connect/AddConnectorPanel.d.ts.map +1 -0
  137. package/dist/components/connect/ConnectConsentPage.d.ts +12 -0
  138. package/dist/components/connect/ConnectConsentPage.d.ts.map +1 -0
  139. package/dist/components/connect/ConnectorDetail.d.ts +29 -0
  140. package/dist/components/connect/ConnectorDetail.d.ts.map +1 -0
  141. package/dist/components/connect/ConnectorMark.d.ts +20 -0
  142. package/dist/components/connect/ConnectorMark.d.ts.map +1 -0
  143. package/dist/components/connect/ConnectorRow.d.ts +33 -0
  144. package/dist/components/connect/ConnectorRow.d.ts.map +1 -0
  145. package/dist/components/connect/ConnectorsPanel.d.ts +40 -0
  146. package/dist/components/connect/ConnectorsPanel.d.ts.map +1 -0
  147. package/dist/components/connect/ConnectorsTab.d.ts +16 -0
  148. package/dist/components/connect/ConnectorsTab.d.ts.map +1 -0
  149. package/dist/components/connect/client-marks.d.ts +31 -0
  150. package/dist/components/connect/client-marks.d.ts.map +1 -0
  151. package/dist/components/connect/index.d.ts +12 -0
  152. package/dist/components/connect/index.d.ts.map +1 -0
  153. package/dist/components/connect/model.d.ts +151 -0
  154. package/dist/components/connect/model.d.ts.map +1 -0
  155. package/dist/components/connect/useConnectors.d.ts +24 -0
  156. package/dist/components/connect/useConnectors.d.ts.map +1 -0
  157. package/dist/components/layout/BottomNav.d.ts +24 -0
  158. package/dist/components/layout/BottomNav.d.ts.map +1 -0
  159. package/dist/components/layout/CommandPalette.d.ts +23 -0
  160. package/dist/components/layout/CommandPalette.d.ts.map +1 -0
  161. package/dist/components/layout/LocationSwitchOverlay.d.ts +3 -0
  162. package/dist/components/layout/LocationSwitchOverlay.d.ts.map +1 -0
  163. package/dist/components/layout/MockModeBanner.d.ts +3 -0
  164. package/dist/components/layout/MockModeBanner.d.ts.map +1 -0
  165. package/dist/components/layout/PrintChrome.d.ts +10 -0
  166. package/dist/components/layout/PrintChrome.d.ts.map +1 -0
  167. package/dist/components/layout/index.d.ts +6 -0
  168. package/dist/components/layout/index.d.ts.map +1 -0
  169. package/dist/components/notes/NotesPanel.d.ts +13 -0
  170. package/dist/components/notes/NotesPanel.d.ts.map +1 -0
  171. package/dist/components/notifications/ChangelogFeed.d.ts +8 -0
  172. package/dist/components/notifications/ChangelogFeed.d.ts.map +1 -0
  173. package/dist/components/notifications/NotificationBell.d.ts +9 -0
  174. package/dist/components/notifications/NotificationBell.d.ts.map +1 -0
  175. package/dist/components/notifications/NotificationInbox.d.ts +13 -0
  176. package/dist/components/notifications/NotificationInbox.d.ts.map +1 -0
  177. package/dist/components/notifications/ToastProvider.d.ts +2 -0
  178. package/dist/components/notifications/ToastProvider.d.ts.map +1 -0
  179. package/dist/components/notifications/index.d.ts +5 -0
  180. package/dist/components/notifications/index.d.ts.map +1 -0
  181. package/dist/components/organization/InviteMemberDialog.d.ts +10 -0
  182. package/dist/components/organization/InviteMemberDialog.d.ts.map +1 -0
  183. package/dist/components/organization/OrgInitializer.d.ts +7 -0
  184. package/dist/components/organization/OrgInitializer.d.ts.map +1 -0
  185. package/dist/components/organization/OrgSwitcher.d.ts +7 -0
  186. package/dist/components/organization/OrgSwitcher.d.ts.map +1 -0
  187. package/dist/components/organization/PermissionMatrixEditor.d.ts +22 -0
  188. package/dist/components/organization/PermissionMatrixEditor.d.ts.map +1 -0
  189. package/dist/components/organization/PermissionProfilesTab.d.ts +3 -0
  190. package/dist/components/organization/PermissionProfilesTab.d.ts.map +1 -0
  191. package/dist/components/organization/TeamTab.d.ts +3 -0
  192. package/dist/components/organization/TeamTab.d.ts.map +1 -0
  193. package/dist/components/organization/TenantOnboarding.d.ts +9 -0
  194. package/dist/components/organization/TenantOnboarding.d.ts.map +1 -0
  195. package/dist/components/organization/index.d.ts +7 -0
  196. package/dist/components/organization/index.d.ts.map +1 -0
  197. package/dist/components/plugins/ConnectorsHub.d.ts +5 -0
  198. package/dist/components/plugins/ConnectorsHub.d.ts.map +1 -0
  199. package/dist/components/plugins/PluginSettingsPanel.d.ts +28 -0
  200. package/dist/components/plugins/PluginSettingsPanel.d.ts.map +1 -0
  201. package/dist/components/right-rail.d.ts +58 -0
  202. package/dist/components/right-rail.d.ts.map +1 -0
  203. package/dist/components/settings/BrandingSettings.d.ts +12 -0
  204. package/dist/components/settings/BrandingSettings.d.ts.map +1 -0
  205. package/dist/components/settings/CompanySettings.d.ts +13 -0
  206. package/dist/components/settings/CompanySettings.d.ts.map +1 -0
  207. package/dist/components/settings/ConnectedBrandingSettings.d.ts +2 -0
  208. package/dist/components/settings/ConnectedBrandingSettings.d.ts.map +1 -0
  209. package/dist/components/settings/ConnectedCompanySettings.d.ts +2 -0
  210. package/dist/components/settings/ConnectedCompanySettings.d.ts.map +1 -0
  211. package/dist/components/settings/ConnectedFieldRulesSettings.d.ts +2 -0
  212. package/dist/components/settings/ConnectedFieldRulesSettings.d.ts.map +1 -0
  213. package/dist/components/settings/ConnectedSecuritySettings.d.ts +2 -0
  214. package/dist/components/settings/ConnectedSecuritySettings.d.ts.map +1 -0
  215. package/dist/components/settings/ConnectedUserProfile.d.ts +3 -0
  216. package/dist/components/settings/ConnectedUserProfile.d.ts.map +1 -0
  217. package/dist/components/settings/FieldRulesSettings.d.ts +11 -0
  218. package/dist/components/settings/FieldRulesSettings.d.ts.map +1 -0
  219. package/dist/components/settings/HolidaysSettings.d.ts +21 -0
  220. package/dist/components/settings/HolidaysSettings.d.ts.map +1 -0
  221. package/dist/components/settings/LocationsCrudPage.d.ts +6 -0
  222. package/dist/components/settings/LocationsCrudPage.d.ts.map +1 -0
  223. package/dist/components/settings/LocationsOverview.d.ts +19 -0
  224. package/dist/components/settings/LocationsOverview.d.ts.map +1 -0
  225. package/dist/components/settings/SecuritySettings.d.ts +17 -0
  226. package/dist/components/settings/SecuritySettings.d.ts.map +1 -0
  227. package/dist/components/settings/SettingsPage.d.ts +46 -0
  228. package/dist/components/settings/SettingsPage.d.ts.map +1 -0
  229. package/dist/components/settings/UserProfile.d.ts +12 -0
  230. package/dist/components/settings/UserProfile.d.ts.map +1 -0
  231. package/dist/components/settings/index.d.ts +11 -0
  232. package/dist/components/settings/index.d.ts.map +1 -0
  233. package/dist/components/shared/ContactPicker.d.ts +92 -0
  234. package/dist/components/shared/ContactPicker.d.ts.map +1 -0
  235. package/dist/components/shared/PersonLink.d.ts +29 -0
  236. package/dist/components/shared/PersonLink.d.ts.map +1 -0
  237. package/dist/components/shared/create-person.d.ts +20 -0
  238. package/dist/components/shared/create-person.d.ts.map +1 -0
  239. package/dist/crud/CrudCardGrid.d.ts +13 -0
  240. package/dist/crud/CrudCardGrid.d.ts.map +1 -0
  241. package/dist/crud/CrudDetailPage.d.ts +23 -0
  242. package/dist/crud/CrudDetailPage.d.ts.map +1 -0
  243. package/dist/crud/CrudFormPage.d.ts +18 -0
  244. package/dist/crud/CrudFormPage.d.ts.map +1 -0
  245. package/dist/crud/CrudListView.d.ts +92 -0
  246. package/dist/crud/CrudListView.d.ts.map +1 -0
  247. package/dist/crud/CrudPage.d.ts +27 -0
  248. package/dist/crud/CrudPage.d.ts.map +1 -0
  249. package/dist/crud/CrudSkeletons.d.ts +21 -0
  250. package/dist/crud/CrudSkeletons.d.ts.map +1 -0
  251. package/dist/crud/DeleteConfirmDialog.d.ts +11 -0
  252. package/dist/crud/DeleteConfirmDialog.d.ts.map +1 -0
  253. package/dist/crud/EntityOverview.d.ts +14 -0
  254. package/dist/crud/EntityOverview.d.ts.map +1 -0
  255. package/dist/crud/ImportWizard.d.ts +18 -0
  256. package/dist/crud/ImportWizard.d.ts.map +1 -0
  257. package/dist/crud/archetype-lookup.d.ts +30 -0
  258. package/dist/crud/archetype-lookup.d.ts.map +1 -0
  259. package/dist/crud/archetypes/ActiveToggle.d.ts +8 -0
  260. package/dist/crud/archetypes/ActiveToggle.d.ts.map +1 -0
  261. package/dist/crud/archetypes/AddressesTab.d.ts +21 -0
  262. package/dist/crud/archetypes/AddressesTab.d.ts.map +1 -0
  263. package/dist/crud/archetypes/ArchetypeStatusBar.d.ts +11 -0
  264. package/dist/crud/archetypes/ArchetypeStatusBar.d.ts.map +1 -0
  265. package/dist/crud/archetypes/BlockSettingsPopover.d.ts +15 -0
  266. package/dist/crud/archetypes/BlockSettingsPopover.d.ts.map +1 -0
  267. package/dist/crud/archetypes/ClientOrdersTab.d.ts +18 -0
  268. package/dist/crud/archetypes/ClientOrdersTab.d.ts.map +1 -0
  269. package/dist/crud/archetypes/EntityLink.d.ts +32 -0
  270. package/dist/crud/archetypes/EntityLink.d.ts.map +1 -0
  271. package/dist/crud/archetypes/LocationDetailTabs.d.ts +11 -0
  272. package/dist/crud/archetypes/LocationDetailTabs.d.ts.map +1 -0
  273. package/dist/crud/archetypes/LocationFormLayout.d.ts +12 -0
  274. package/dist/crud/archetypes/LocationFormLayout.d.ts.map +1 -0
  275. package/dist/crud/archetypes/OrderDetailView.d.ts +115 -0
  276. package/dist/crud/archetypes/OrderDetailView.d.ts.map +1 -0
  277. package/dist/crud/archetypes/OrderFormView.d.ts +112 -0
  278. package/dist/crud/archetypes/OrderFormView.d.ts.map +1 -0
  279. package/dist/crud/archetypes/OrderListView.d.ts +36 -0
  280. package/dist/crud/archetypes/OrderListView.d.ts.map +1 -0
  281. package/dist/crud/archetypes/PersonDetailTabs.d.ts +35 -0
  282. package/dist/crud/archetypes/PersonDetailTabs.d.ts.map +1 -0
  283. package/dist/crud/archetypes/PersonFormLayout.d.ts +13 -0
  284. package/dist/crud/archetypes/PersonFormLayout.d.ts.map +1 -0
  285. package/dist/crud/archetypes/PersonPicker.d.ts +23 -0
  286. package/dist/crud/archetypes/PersonPicker.d.ts.map +1 -0
  287. package/dist/crud/archetypes/ProductDetailTabs.d.ts +11 -0
  288. package/dist/crud/archetypes/ProductDetailTabs.d.ts.map +1 -0
  289. package/dist/crud/archetypes/ProductFormLayout.d.ts +12 -0
  290. package/dist/crud/archetypes/ProductFormLayout.d.ts.map +1 -0
  291. package/dist/crud/archetypes/ScheduleEditor.d.ts +7 -0
  292. package/dist/crud/archetypes/ScheduleEditor.d.ts.map +1 -0
  293. package/dist/crud/archetypes/ServiceDetailTabs.d.ts +10 -0
  294. package/dist/crud/archetypes/ServiceDetailTabs.d.ts.map +1 -0
  295. package/dist/crud/archetypes/ServiceFormLayout.d.ts +12 -0
  296. package/dist/crud/archetypes/ServiceFormLayout.d.ts.map +1 -0
  297. package/dist/crud/archetypes/SubjectDetailTabs.d.ts +12 -0
  298. package/dist/crud/archetypes/SubjectDetailTabs.d.ts.map +1 -0
  299. package/dist/crud/archetypes/SubjectFormLayout.d.ts +14 -0
  300. package/dist/crud/archetypes/SubjectFormLayout.d.ts.map +1 -0
  301. package/dist/crud/createCrudPage.d.ts +34 -0
  302. package/dist/crud/createCrudPage.d.ts.map +1 -0
  303. package/dist/crud/csv-export.d.ts +3 -0
  304. package/dist/crud/csv-export.d.ts.map +1 -0
  305. package/dist/crud/fieldToColumn.d.ts +14 -0
  306. package/dist/crud/fieldToColumn.d.ts.map +1 -0
  307. package/dist/crud/index.d.ts +16 -0
  308. package/dist/crud/index.d.ts.map +1 -0
  309. package/dist/crud/placeholder.d.ts +7 -0
  310. package/dist/crud/placeholder.d.ts.map +1 -0
  311. package/dist/crud/relation-field.d.ts +28 -0
  312. package/dist/crud/relation-field.d.ts.map +1 -0
  313. package/dist/data/client.d.ts +14 -0
  314. package/dist/data/client.d.ts.map +1 -0
  315. package/dist/db.cjs +14 -0
  316. package/dist/db.cjs.map +1 -0
  317. package/dist/db.d.ts +2 -0
  318. package/dist/db.d.ts.map +1 -0
  319. package/dist/db.js +3 -0
  320. package/dist/db.js.map +1 -0
  321. package/dist/hooks/index.d.ts +20 -0
  322. package/dist/hooks/index.d.ts.map +1 -0
  323. package/dist/hooks/useAITools.d.ts +23 -0
  324. package/dist/hooks/useAITools.d.ts.map +1 -0
  325. package/dist/hooks/useAgentSurface.d.ts +15 -0
  326. package/dist/hooks/useAgentSurface.d.ts.map +1 -0
  327. package/dist/hooks/useAuth.d.ts +16 -0
  328. package/dist/hooks/useAuth.d.ts.map +1 -0
  329. package/dist/hooks/useChat.d.ts +38 -0
  330. package/dist/hooks/useChat.d.ts.map +1 -0
  331. package/dist/hooks/useDictation.d.ts +31 -0
  332. package/dist/hooks/useDictation.d.ts.map +1 -0
  333. package/dist/hooks/useFieldRules.d.ts +6 -0
  334. package/dist/hooks/useFieldRules.d.ts.map +1 -0
  335. package/dist/hooks/useFormatters.d.ts +7 -0
  336. package/dist/hooks/useFormatters.d.ts.map +1 -0
  337. package/dist/hooks/useGlobalSearch.d.ts +10 -0
  338. package/dist/hooks/useGlobalSearch.d.ts.map +1 -0
  339. package/dist/hooks/useLayout.d.ts +16 -0
  340. package/dist/hooks/useLayout.d.ts.map +1 -0
  341. package/dist/hooks/useMicLevels.d.ts +10 -0
  342. package/dist/hooks/useMicLevels.d.ts.map +1 -0
  343. package/dist/hooks/useModuleNavigation.d.ts +27 -0
  344. package/dist/hooks/useModuleNavigation.d.ts.map +1 -0
  345. package/dist/hooks/useNotifications.d.ts +11 -0
  346. package/dist/hooks/useNotifications.d.ts.map +1 -0
  347. package/dist/hooks/usePluginPrefs.d.ts +23 -0
  348. package/dist/hooks/usePluginPrefs.d.ts.map +1 -0
  349. package/dist/hooks/usePlugins.d.ts +5 -0
  350. package/dist/hooks/usePlugins.d.ts.map +1 -0
  351. package/dist/hooks/useSystemPermission.d.ts +3 -0
  352. package/dist/hooks/useSystemPermission.d.ts.map +1 -0
  353. package/dist/hooks/useTenant.d.ts +23 -0
  354. package/dist/hooks/useTenant.d.ts.map +1 -0
  355. package/dist/hooks/useTenantPluginSettings.d.ts +12 -0
  356. package/dist/hooks/useTenantPluginSettings.d.ts.map +1 -0
  357. package/dist/hooks/useTenantPlugins.d.ts +10 -0
  358. package/dist/hooks/useTenantPlugins.d.ts.map +1 -0
  359. package/dist/hooks/useTranslation.d.ts +5 -0
  360. package/dist/hooks/useTranslation.d.ts.map +1 -0
  361. package/dist/index.d.ts +93 -0
  362. package/dist/index.d.ts.map +1 -0
  363. package/dist/index.js +17207 -0
  364. package/dist/index.js.map +1 -0
  365. package/dist/lib/agent-approvals.d.ts +27 -0
  366. package/dist/lib/agent-approvals.d.ts.map +1 -0
  367. package/dist/lib/agent-surface.d.ts +78 -0
  368. package/dist/lib/agent-surface.d.ts.map +1 -0
  369. package/dist/lib/ai-tool-handlers.d.ts +154 -0
  370. package/dist/lib/ai-tool-handlers.d.ts.map +1 -0
  371. package/dist/lib/apply-field-rules.d.ts +4 -0
  372. package/dist/lib/apply-field-rules.d.ts.map +1 -0
  373. package/dist/lib/assistant-delegation.d.ts +5 -0
  374. package/dist/lib/assistant-delegation.d.ts.map +1 -0
  375. package/dist/lib/assistant-feature.d.ts +8 -0
  376. package/dist/lib/assistant-feature.d.ts.map +1 -0
  377. package/dist/lib/attachments.d.ts +95 -0
  378. package/dist/lib/attachments.d.ts.map +1 -0
  379. package/dist/lib/auth-context.d.ts +5 -0
  380. package/dist/lib/auth-context.d.ts.map +1 -0
  381. package/dist/lib/cache.d.ts +18 -0
  382. package/dist/lib/cache.d.ts.map +1 -0
  383. package/dist/lib/cn.d.ts +2 -0
  384. package/dist/lib/cn.d.ts.map +1 -0
  385. package/dist/lib/core-ai-tools.d.ts +49 -0
  386. package/dist/lib/core-ai-tools.d.ts.map +1 -0
  387. package/dist/lib/create-client-orders-provider.d.ts +3 -0
  388. package/dist/lib/create-client-orders-provider.d.ts.map +1 -0
  389. package/dist/lib/csv.d.ts +14 -0
  390. package/dist/lib/csv.d.ts.map +1 -0
  391. package/dist/lib/currency.d.ts +7 -0
  392. package/dist/lib/currency.d.ts.map +1 -0
  393. package/dist/lib/dedup.d.ts +2 -0
  394. package/dist/lib/dedup.d.ts.map +1 -0
  395. package/dist/lib/entity-registry.d.ts +19 -0
  396. package/dist/lib/entity-registry.d.ts.map +1 -0
  397. package/dist/lib/entity-routes.d.ts +48 -0
  398. package/dist/lib/entity-routes.d.ts.map +1 -0
  399. package/dist/lib/fayz-agent.d.ts +23 -0
  400. package/dist/lib/fayz-agent.d.ts.map +1 -0
  401. package/dist/lib/format.d.ts +7 -0
  402. package/dist/lib/format.d.ts.map +1 -0
  403. package/dist/lib/locale-config.d.ts +8 -0
  404. package/dist/lib/locale-config.d.ts.map +1 -0
  405. package/dist/lib/notes-tasks-bridge.d.ts +28 -0
  406. package/dist/lib/notes-tasks-bridge.d.ts.map +1 -0
  407. package/dist/lib/org-context.d.ts +5 -0
  408. package/dist/lib/org-context.d.ts.map +1 -0
  409. package/dist/lib/plugins.d.ts +2 -0
  410. package/dist/lib/plugins.d.ts.map +1 -0
  411. package/dist/lib/record-refs.d.ts +31 -0
  412. package/dist/lib/record-refs.d.ts.map +1 -0
  413. package/dist/lib/router.d.ts +15 -0
  414. package/dist/lib/router.d.ts.map +1 -0
  415. package/dist/lib/schedule-config.d.ts +32 -0
  416. package/dist/lib/schedule-config.d.ts.map +1 -0
  417. package/dist/lib/schedule-service.d.ts +76 -0
  418. package/dist/lib/schedule-service.d.ts.map +1 -0
  419. package/dist/lib/search-targets.d.ts +12 -0
  420. package/dist/lib/search-targets.d.ts.map +1 -0
  421. package/dist/lib/speech.d.ts +36 -0
  422. package/dist/lib/speech.d.ts.map +1 -0
  423. package/dist/lib/supabase.d.ts +10 -0
  424. package/dist/lib/supabase.d.ts.map +1 -0
  425. package/dist/org/adapters/mock.d.ts +4 -0
  426. package/dist/org/adapters/mock.d.ts.map +1 -0
  427. package/dist/org/adapters/supabase.d.ts +33 -0
  428. package/dist/org/adapters/supabase.d.ts.map +1 -0
  429. package/dist/org/cache.d.ts +29 -0
  430. package/dist/org/cache.d.ts.map +1 -0
  431. package/dist/org/context.d.ts +36 -0
  432. package/dist/org/context.d.ts.map +1 -0
  433. package/dist/org/index.d.ts +10 -0
  434. package/dist/org/index.d.ts.map +1 -0
  435. package/dist/org/index.js +5 -0
  436. package/dist/org/index.js.map +1 -0
  437. package/dist/org/store.d.ts +20 -0
  438. package/dist/org/store.d.ts.map +1 -0
  439. package/dist/org/team-rows.d.ts +45 -0
  440. package/dist/org/team-rows.d.ts.map +1 -0
  441. package/dist/permissions/PermissionGate.d.ts +12 -0
  442. package/dist/permissions/PermissionGate.d.ts.map +1 -0
  443. package/dist/permissions/context.d.ts +39 -0
  444. package/dist/permissions/context.d.ts.map +1 -0
  445. package/dist/permissions/index.d.ts +5 -0
  446. package/dist/permissions/index.d.ts.map +1 -0
  447. package/dist/permissions/index.js +3 -0
  448. package/dist/permissions/index.js.map +1 -0
  449. package/dist/permissions/roles.d.ts +7 -0
  450. package/dist/permissions/roles.d.ts.map +1 -0
  451. package/dist/permissions/store.d.ts +21 -0
  452. package/dist/permissions/store.d.ts.map +1 -0
  453. package/dist/plugins/ModuleActionBar.d.ts +27 -0
  454. package/dist/plugins/ModuleActionBar.d.ts.map +1 -0
  455. package/dist/plugins/PluginRegistryManager.d.ts +13 -0
  456. package/dist/plugins/PluginRegistryManager.d.ts.map +1 -0
  457. package/dist/plugins/QuickActionsButton.d.ts +12 -0
  458. package/dist/plugins/QuickActionsButton.d.ts.map +1 -0
  459. package/dist/plugins/SettingsGroup.d.ts +25 -0
  460. package/dist/plugins/SettingsGroup.d.ts.map +1 -0
  461. package/dist/plugins/WidgetSlot.d.ts +8 -0
  462. package/dist/plugins/WidgetSlot.d.ts.map +1 -0
  463. package/dist/plugins/createPluginContext.d.ts +28 -0
  464. package/dist/plugins/createPluginContext.d.ts.map +1 -0
  465. package/dist/plugins/createViewRouter.d.ts +38 -0
  466. package/dist/plugins/createViewRouter.d.ts.map +1 -0
  467. package/dist/projects/ProjectsSettings.d.ts +3 -0
  468. package/dist/projects/ProjectsSettings.d.ts.map +1 -0
  469. package/dist/projects/SeuSiteWidget.d.ts +7 -0
  470. package/dist/projects/SeuSiteWidget.d.ts.map +1 -0
  471. package/dist/projects/provider.d.ts +8 -0
  472. package/dist/projects/provider.d.ts.map +1 -0
  473. package/dist/projects/store.d.ts +16 -0
  474. package/dist/projects/store.d.ts.map +1 -0
  475. package/dist/projects/types.d.ts +46 -0
  476. package/dist/projects/types.d.ts.map +1 -0
  477. package/dist/stores/auth.store.d.ts +12 -0
  478. package/dist/stores/auth.store.d.ts.map +1 -0
  479. package/dist/stores/billing.store.d.ts +2 -0
  480. package/dist/stores/billing.store.d.ts.map +1 -0
  481. package/dist/stores/chat.store.d.ts +208 -0
  482. package/dist/stores/chat.store.d.ts.map +1 -0
  483. package/dist/stores/createCrudStore.d.ts +54 -0
  484. package/dist/stores/createCrudStore.d.ts.map +1 -0
  485. package/dist/stores/index.d.ts +13 -0
  486. package/dist/stores/index.d.ts.map +1 -0
  487. package/dist/stores/invite.store.d.ts +11 -0
  488. package/dist/stores/invite.store.d.ts.map +1 -0
  489. package/dist/stores/layout.store.d.ts +2 -0
  490. package/dist/stores/layout.store.d.ts.map +1 -0
  491. package/dist/stores/locale.store.d.ts +17 -0
  492. package/dist/stores/locale.store.d.ts.map +1 -0
  493. package/dist/stores/location.store.d.ts +20 -0
  494. package/dist/stores/location.store.d.ts.map +1 -0
  495. package/dist/stores/notifications.store.d.ts +12 -0
  496. package/dist/stores/notifications.store.d.ts.map +1 -0
  497. package/dist/stores/organization.store.d.ts +2 -0
  498. package/dist/stores/organization.store.d.ts.map +1 -0
  499. package/dist/stores/permissions.store.d.ts +2 -0
  500. package/dist/stores/permissions.store.d.ts.map +1 -0
  501. package/dist/stores/plugin.store.d.ts +24 -0
  502. package/dist/stores/plugin.store.d.ts.map +1 -0
  503. package/dist/stores/tenant.store.d.ts +11 -0
  504. package/dist/stores/tenant.store.d.ts.map +1 -0
  505. package/dist/stores/theme.store.d.ts +17 -0
  506. package/dist/stores/theme.store.d.ts.map +1 -0
  507. package/dist/theme/dark.d.ts +3 -0
  508. package/dist/theme/dark.d.ts.map +1 -0
  509. package/dist/theme/index.d.ts +8 -0
  510. package/dist/theme/index.d.ts.map +1 -0
  511. package/dist/theme/light.d.ts +3 -0
  512. package/dist/theme/light.d.ts.map +1 -0
  513. package/dist/theme/tailwind-preset.d.ts +4 -0
  514. package/dist/theme/tailwind-preset.d.ts.map +1 -0
  515. package/dist/theme/tokens.d.ts +119 -0
  516. package/dist/theme/tokens.d.ts.map +1 -0
  517. package/dist/theme/utils.d.ts +31 -0
  518. package/dist/theme/utils.d.ts.map +1 -0
  519. package/dist/types/auth-adapter.d.ts +14 -0
  520. package/dist/types/auth-adapter.d.ts.map +1 -0
  521. package/dist/types/auth.d.ts +34 -0
  522. package/dist/types/auth.d.ts.map +1 -0
  523. package/dist/types/billing.d.ts +81 -0
  524. package/dist/types/billing.d.ts.map +1 -0
  525. package/dist/types/client-orders.d.ts +47 -0
  526. package/dist/types/client-orders.d.ts.map +1 -0
  527. package/dist/types/crud.d.ts +137 -0
  528. package/dist/types/crud.d.ts.map +1 -0
  529. package/dist/types/entities.d.ts +150 -0
  530. package/dist/types/entities.d.ts.map +1 -0
  531. package/dist/types/entity-lookup.d.ts +18 -0
  532. package/dist/types/entity-lookup.d.ts.map +1 -0
  533. package/dist/types/index.d.ts +17 -0
  534. package/dist/types/index.d.ts.map +1 -0
  535. package/dist/types/integrations.d.ts +48 -0
  536. package/dist/types/integrations.d.ts.map +1 -0
  537. package/dist/types/invite.d.ts +23 -0
  538. package/dist/types/invite.d.ts.map +1 -0
  539. package/dist/types/layout.d.ts +26 -0
  540. package/dist/types/layout.d.ts.map +1 -0
  541. package/dist/types/notifications.d.ts +31 -0
  542. package/dist/types/notifications.d.ts.map +1 -0
  543. package/dist/types/org-adapter.d.ts +92 -0
  544. package/dist/types/org-adapter.d.ts.map +1 -0
  545. package/dist/types/permissions.d.ts +39 -0
  546. package/dist/types/permissions.d.ts.map +1 -0
  547. package/dist/types/platform.d.ts +25 -0
  548. package/dist/types/platform.d.ts.map +1 -0
  549. package/dist/types/plugins.d.ts +269 -0
  550. package/dist/types/plugins.d.ts.map +1 -0
  551. package/dist/types/tenant.d.ts +74 -0
  552. package/dist/types/tenant.d.ts.map +1 -0
  553. package/dist/ui.d.ts +2 -0
  554. package/dist/ui.d.ts.map +1 -0
  555. package/dist/ui.js +3 -0
  556. package/dist/ui.js.map +1 -0
  557. package/package.json +94 -0
@@ -0,0 +1,534 @@
1
+ import { useTranslation } from './chunk-YUHCC7JY.js';
2
+ import { useBillingStore, resolvePlanBadge } from './chunk-VN5NTK26.js';
3
+ import { useOrganizationStore, useTenantOptional, useOrgAdapterOptional } from './chunk-PNAJODZM.js';
4
+ import { usePermissionsStore } from './chunk-VTEP2AQX.js';
5
+ import * as React from 'react';
6
+ import { Sparkles, Check, Crown, Minus } from 'lucide-react';
7
+ import { cn, Card, CardContent, Badge, CardHeader, Button, ConfirmDialog, toast } from '@fayz-ai/ui';
8
+ export { cn } from '@fayz-ai/ui';
9
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
10
+ import { invalidateCount, usePluginRuntimeOptional, getAllEntities, countByTenant } from '@fayz-ai/core';
11
+ import { useAuthStore } from '@fayz-ai/auth';
12
+ import { mergeLimitDeclarations, isEntitledByPlan, resolveAccess, resolveLimit, agentDenial } from '@fayz-ai/core/access';
13
+ export { UPGRADE_URL, agentDenial, isEntitledByPlan, resolveAccess } from '@fayz-ai/core/access';
14
+ import { create } from 'zustand';
15
+
16
+ function parsePlanFeature(feature) {
17
+ return feature.startsWith("*") ? { label: feature.slice(1).trim(), highlighted: true } : { label: feature, highlighted: false };
18
+ }
19
+ function PlanFeatureItem({ feature, className, iconClassName }) {
20
+ const { label, highlighted } = parsePlanFeature(feature);
21
+ return /* @__PURE__ */ jsxs("li", { className: cn("flex items-start gap-2", className, highlighted && "font-medium text-primary"), children: [
22
+ highlighted ? /* @__PURE__ */ jsx(Sparkles, { className: cn("mt-0.5 shrink-0 text-primary", iconClassName), "aria-hidden": "true" }) : /* @__PURE__ */ jsx(Check, { className: cn("mt-0.5 shrink-0 text-primary", iconClassName), "aria-hidden": "true" }),
23
+ /* @__PURE__ */ jsx("span", { children: label })
24
+ ] });
25
+ }
26
+ var CORE_LIMIT_DECLARATIONS = [
27
+ { key: "users", label: "Users", table: "tenant_members" },
28
+ { key: "locations", label: "Locations", table: "locations" }
29
+ ];
30
+ function entityDerivedLimitDeclarations(entities) {
31
+ const out = [];
32
+ for (const e of entities) {
33
+ const def = e.entityDef;
34
+ if (def?.limitKey && def.data?.table) {
35
+ out.push({
36
+ key: def.limitKey,
37
+ label: e.labelPlural,
38
+ table: def.data.table,
39
+ kindFilter: def.data.archetypeKind
40
+ });
41
+ }
42
+ }
43
+ return out;
44
+ }
45
+ var registry = /* @__PURE__ */ new Map();
46
+ function setLimitRegistry(declarations) {
47
+ const next = /* @__PURE__ */ new Map();
48
+ for (const decl of declarations) next.set(decl.key, decl);
49
+ registry = next;
50
+ }
51
+ function getLimitDeclaration(key) {
52
+ return registry.get(key);
53
+ }
54
+ var listeners = /* @__PURE__ */ new Map();
55
+ function subscribeLimit(key, cb) {
56
+ let set = listeners.get(key);
57
+ if (!set) {
58
+ set = /* @__PURE__ */ new Set();
59
+ listeners.set(key, set);
60
+ }
61
+ set.add(cb);
62
+ return () => {
63
+ set?.delete(cb);
64
+ if (set && set.size === 0) listeners.delete(key);
65
+ };
66
+ }
67
+ function invalidateLimit(key) {
68
+ const decl = registry.get(key);
69
+ if (decl) invalidateCount(decl.table);
70
+ listeners.get(key)?.forEach((cb) => cb());
71
+ }
72
+ var useUpgradeModalStore = create((set) => ({
73
+ current: null,
74
+ open: (payload) => set({ current: payload }),
75
+ close: () => set({ current: null })
76
+ }));
77
+ var AccessContext = React.createContext(null);
78
+ function AccessProvider({ children, limitDeclarations }) {
79
+ const user = useAuthStore((s) => s.user);
80
+ const org = useOrganizationStore((s) => s.currentOrg);
81
+ const profile = usePermissionsStore((s) => s.currentProfile);
82
+ const plans = useBillingStore((s) => s.plans);
83
+ const runtime = usePluginRuntimeOptional();
84
+ const pluginLimits = runtime?.pluginLimits;
85
+ React.useEffect(() => {
86
+ setLimitRegistry(
87
+ mergeLimitDeclarations(
88
+ CORE_LIMIT_DECLARATIONS,
89
+ entityDerivedLimitDeclarations(getAllEntities()),
90
+ pluginLimits,
91
+ limitDeclarations
92
+ )
93
+ );
94
+ }, [pluginLimits, limitDeclarations]);
95
+ const plan = React.useMemo(
96
+ () => org?.plan ? plans.find((p) => p.id === org.plan) ?? null : null,
97
+ [plans, org?.plan]
98
+ );
99
+ const session = React.useMemo(
100
+ () => ({ user, org, profile, plan }),
101
+ [user, org, profile, plan]
102
+ );
103
+ const value = React.useMemo(
104
+ () => ({
105
+ session,
106
+ can: (feature, action) => resolveAccess(session, feature, action),
107
+ entitled: (feature) => isEntitledByPlan(session.plan, feature)
108
+ }),
109
+ [session]
110
+ );
111
+ return /* @__PURE__ */ jsx(AccessContext.Provider, { value, children });
112
+ }
113
+ AccessProvider.displayName = "AccessProvider";
114
+ var ALLOW_ALL = {
115
+ can: () => ({ allowed: true }),
116
+ entitled: () => true
117
+ };
118
+ function useAccess() {
119
+ const ctx = React.useContext(AccessContext);
120
+ if (!ctx) throw new Error("useAccess must be used inside <AccessProvider>");
121
+ return { can: ctx.can, entitled: ctx.entitled };
122
+ }
123
+ function useAccessOptional() {
124
+ const ctx = React.useContext(AccessContext);
125
+ return ctx ? { can: ctx.can, entitled: ctx.entitled } : ALLOW_ALL;
126
+ }
127
+ function useAccessSession() {
128
+ return React.useContext(AccessContext)?.session ?? null;
129
+ }
130
+ function resolveCap(plan, key) {
131
+ return plan?.entitlements?.limits?.[key];
132
+ }
133
+ function useLimit(key) {
134
+ const session = useAccessSession();
135
+ const tenantId = session?.org?.id;
136
+ const cap = resolveCap(session?.plan ?? null, key);
137
+ const declaration = getLimitDeclaration(key);
138
+ const unlimited = !declaration || cap === void 0 || cap === -1;
139
+ const [used, setUsed] = React.useState(0);
140
+ const [loading, setLoading] = React.useState(!unlimited);
141
+ const [version, setVersion] = React.useState(0);
142
+ const refresh = React.useCallback(() => setVersion((v) => v + 1), []);
143
+ React.useEffect(() => subscribeLimit(key, refresh), [key, refresh]);
144
+ React.useEffect(() => {
145
+ if (unlimited || !declaration || !tenantId) {
146
+ setUsed(0);
147
+ setLoading(false);
148
+ return;
149
+ }
150
+ let active = true;
151
+ setLoading(true);
152
+ countByTenant(declaration.table, {
153
+ kind: declaration.kindFilter,
154
+ period: declaration.period,
155
+ tenantId,
156
+ fresh: version > 0
157
+ }).then((n) => {
158
+ if (active) {
159
+ setUsed(n);
160
+ setLoading(false);
161
+ }
162
+ }).catch(() => {
163
+ if (active) setLoading(false);
164
+ });
165
+ return () => {
166
+ active = false;
167
+ };
168
+ }, [unlimited, declaration, tenantId, version]);
169
+ const bounds = resolveLimit({ cap, hasDeclaration: Boolean(declaration), used });
170
+ return { key, ...bounds, loading, refresh };
171
+ }
172
+ function useLimitGuard(key) {
173
+ const session = useAccessSession();
174
+ const tenantId = session?.org?.id;
175
+ const plan = session?.plan ?? null;
176
+ const openModal = useUpgradeModalStore((s) => s.open);
177
+ return React.useCallback(
178
+ async (n = 1) => {
179
+ const cap = resolveCap(plan, key);
180
+ const declaration = getLimitDeclaration(key);
181
+ if (!declaration || cap === void 0 || cap === -1 || !tenantId) return "ok";
182
+ const used = await countByTenant(declaration.table, {
183
+ kind: declaration.kindFilter,
184
+ period: declaration.period,
185
+ tenantId,
186
+ fresh: true
187
+ });
188
+ if (used + n > cap) {
189
+ openModal({ limitKey: key });
190
+ return "blocked";
191
+ }
192
+ return "ok";
193
+ },
194
+ [key, plan, tenantId, openModal]
195
+ );
196
+ }
197
+ function getAccessSnapshot() {
198
+ const user = useAuthStore.getState().user;
199
+ const org = useOrganizationStore.getState().currentOrg;
200
+ const profile = usePermissionsStore.getState().currentProfile;
201
+ const plans = useBillingStore.getState().plans;
202
+ const plan = org?.plan ? plans.find((p) => p.id === org.plan) ?? null : null;
203
+ return { user, org, profile, plan };
204
+ }
205
+ function checkAccess(feature, action) {
206
+ const session = getAccessSnapshot();
207
+ const decision = resolveAccess(session, feature, action);
208
+ if (decision.allowed) return { allowed: true };
209
+ return agentDenial(decision.reason ?? "role");
210
+ }
211
+ async function guardLimit(key, n = 1) {
212
+ const session = getAccessSnapshot();
213
+ const tenantId = session.org?.id;
214
+ const cap = session.plan?.entitlements?.limits?.[key];
215
+ const declaration = getLimitDeclaration(key);
216
+ if (!declaration || cap === void 0 || cap === -1 || !tenantId) return { allowed: true };
217
+ const used = await countByTenant(declaration.table, {
218
+ kind: declaration.kindFilter,
219
+ period: declaration.period,
220
+ tenantId,
221
+ fresh: true
222
+ });
223
+ if (used + n > cap) {
224
+ return agentDenial("limit", { key, max: cap, used });
225
+ }
226
+ return { allowed: true };
227
+ }
228
+ function applyNavAccess(items, access, knownFeatures) {
229
+ const decorate = (item) => {
230
+ const children = item.children ? item.children.map(decorate).filter((c) => c !== null) : void 0;
231
+ if (!item.feature) {
232
+ return children ? { ...item, children } : item;
233
+ }
234
+ if (knownFeatures.has(item.feature)) {
235
+ const decision = access.can(item.feature, "read");
236
+ if (!decision.allowed && decision.reason === "role") return null;
237
+ }
238
+ const premium = access.entitled(item.feature) === false;
239
+ return children ? { ...item, premium, children } : { ...item, premium };
240
+ };
241
+ return items.map(decorate).filter((i) => i !== null);
242
+ }
243
+ function useModuleNavAccess(items) {
244
+ const access = useAccessOptional();
245
+ const features = usePermissionsStore((s) => s.features);
246
+ const knownFeatures = React.useMemo(
247
+ () => new Set(features.map((f) => f.id)),
248
+ [features]
249
+ );
250
+ return React.useMemo(
251
+ () => applyNavAccess(items, access, knownFeatures),
252
+ [items, access, knownFeatures]
253
+ );
254
+ }
255
+
256
+ // src/components/billing/access-contract.ts
257
+ function getPlanEntitlements(plan) {
258
+ return plan?.entitlements;
259
+ }
260
+ function featureDisplayName(label) {
261
+ if (!label) return "";
262
+ return label.replace(/\s*\([^)]*\)\s*$/, "").trim() || label.trim();
263
+ }
264
+ var CURRENCY_BY_REGION = {
265
+ BR: "BRL",
266
+ PT: "EUR",
267
+ ES: "EUR",
268
+ FR: "EUR",
269
+ DE: "EUR",
270
+ IT: "EUR",
271
+ NL: "EUR",
272
+ IE: "EUR",
273
+ GB: "GBP",
274
+ US: "USD",
275
+ CA: "CAD",
276
+ AU: "AUD",
277
+ MX: "MXN",
278
+ AR: "ARS",
279
+ CL: "CLP",
280
+ CO: "COP"
281
+ };
282
+ function resolvePlanCurrency(planCurrency, locale) {
283
+ if (planCurrency) return planCurrency;
284
+ const region = locale?.split(/[-_]/)[1]?.toUpperCase();
285
+ return region && CURRENCY_BY_REGION[region] || "USD";
286
+ }
287
+ function formatPrice(plan, tr) {
288
+ if (plan.price <= 0) return tr("billing.free", "Free");
289
+ try {
290
+ const isInteger = Number.isInteger(plan.price);
291
+ return new Intl.NumberFormat(void 0, {
292
+ style: "currency",
293
+ currency: plan.currency || "USD",
294
+ minimumFractionDigits: isInteger ? 0 : 2
295
+ }).format(plan.price);
296
+ } catch {
297
+ return `${plan.currency || ""} ${plan.price}`.trim();
298
+ }
299
+ }
300
+ function intervalSuffix(plan, tr) {
301
+ if (plan.price <= 0) return "";
302
+ return plan.interval === "year" ? tr("billing.perYear", "/yr") : tr("billing.perMonth", "/mo");
303
+ }
304
+ function SubscriptionPage({ className }) {
305
+ const { t } = useTranslation();
306
+ const tr = (key, fallback) => {
307
+ const v = t(key);
308
+ return !v || v === key ? fallback : v;
309
+ };
310
+ const plans = useBillingStore((s) => s.plans);
311
+ const checkout = useBillingStore((s) => s.checkout);
312
+ useTenantOptional();
313
+ const adapter = useOrgAdapterOptional();
314
+ const setCurrentOrg = useOrganizationStore((s) => s.setCurrentOrg);
315
+ const currentOrg = useOrganizationStore((s) => s.currentOrg);
316
+ const currentPlanId = currentOrg?.plan || "free";
317
+ const currentBadge = resolvePlanBadge(currentPlanId, plans);
318
+ const currentPlan = plans.find((p) => p.id === currentPlanId);
319
+ const [pending, setPending] = React.useState(null);
320
+ const [busy, setBusy] = React.useState(false);
321
+ const allFeatures = React.useMemo(() => {
322
+ const seen = /* @__PURE__ */ new Set();
323
+ const out = [];
324
+ for (const plan of plans) {
325
+ for (const f of plan.features) {
326
+ if (!seen.has(f)) {
327
+ seen.add(f);
328
+ out.push(f);
329
+ }
330
+ }
331
+ }
332
+ return out;
333
+ }, [plans]);
334
+ const featureCatalog = usePermissionsStore((s) => s.features);
335
+ const entitlementsMatrix = React.useMemo(() => {
336
+ const hasAny = plans.some((p) => getPlanEntitlements(p));
337
+ if (!hasAny) return null;
338
+ const featureIds = [];
339
+ const featureSeen = /* @__PURE__ */ new Set();
340
+ const limitKeys = [];
341
+ const limitSeen = /* @__PURE__ */ new Set();
342
+ for (const plan of plans) {
343
+ const ent = getPlanEntitlements(plan);
344
+ for (const id of Object.keys(ent?.features ?? {})) {
345
+ if (!featureSeen.has(id)) {
346
+ featureSeen.add(id);
347
+ featureIds.push(id);
348
+ }
349
+ }
350
+ for (const key of Object.keys(ent?.limits ?? {})) {
351
+ if (!limitSeen.has(key)) {
352
+ limitSeen.add(key);
353
+ limitKeys.push(key);
354
+ }
355
+ }
356
+ }
357
+ if (featureIds.length === 0 && limitKeys.length === 0) return null;
358
+ const labelForFeature = (id) => featureCatalog.find((f) => f.id === id)?.label ?? id;
359
+ const labelForLimit = (key) => {
360
+ const v = t(`limit.label.${key}`);
361
+ return !v || v === `limit.label.${key}` ? key : v;
362
+ };
363
+ return { featureIds, limitKeys, labelForFeature, labelForLimit };
364
+ }, [plans, featureCatalog, t]);
365
+ async function applyChange(plan) {
366
+ setBusy(true);
367
+ try {
368
+ if (checkout) {
369
+ await checkout(plan.id);
370
+ setPending(null);
371
+ return;
372
+ }
373
+ if (adapter && currentOrg) {
374
+ const updated = await adapter.updateOrg(currentOrg.id, { plan: plan.id });
375
+ setCurrentOrg(updated);
376
+ } else if (currentOrg) {
377
+ setCurrentOrg({ ...currentOrg, plan: plan.id });
378
+ }
379
+ toast.success(
380
+ tr("billing.planChanged", "Plan updated").replace("{{plan}}", plan.name)
381
+ );
382
+ setPending(null);
383
+ } catch {
384
+ toast.error(tr("billing.planChangeFailed", "Couldn't change your plan. Please try again."));
385
+ } finally {
386
+ setBusy(false);
387
+ }
388
+ }
389
+ if (plans.length === 0) {
390
+ return /* @__PURE__ */ jsx("div", { className: className ?? "mx-auto max-w-5xl", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: tr("billing.noPlans", "No plans are configured.") }) });
391
+ }
392
+ return /* @__PURE__ */ jsxs("div", { className: className ?? "mx-auto max-w-5xl space-y-8", children: [
393
+ /* @__PURE__ */ jsxs("div", { children: [
394
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold tracking-tight", children: tr("billing.subscription.title", "Subscription") }),
395
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: tr("billing.subscription.subtitle", "Manage your plan and unlock more features.") })
396
+ ] }),
397
+ /* @__PURE__ */ jsx(
398
+ Card,
399
+ {
400
+ className: cn(
401
+ "relative overflow-hidden",
402
+ currentBadge.paid && "border-amber-400/60 bg-gradient-to-br from-amber-50/60 to-transparent dark:from-amber-950/20"
403
+ ),
404
+ children: /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-wrap items-center justify-between gap-4 p-6", children: [
405
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4", children: [
406
+ /* @__PURE__ */ jsx(
407
+ "div",
408
+ {
409
+ className: cn(
410
+ "flex h-12 w-12 shrink-0 items-center justify-center rounded-xl",
411
+ currentBadge.paid ? "bg-amber-400/20 text-amber-600 dark:text-amber-400" : "bg-muted text-muted-foreground"
412
+ ),
413
+ children: currentBadge.paid ? /* @__PURE__ */ jsx(Crown, { className: "h-6 w-6" }) : /* @__PURE__ */ jsx(Sparkles, { className: "h-6 w-6" })
414
+ }
415
+ ),
416
+ /* @__PURE__ */ jsxs("div", { children: [
417
+ /* @__PURE__ */ jsx("p", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: tr("billing.currentPlan", "Current Plan") }),
418
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
419
+ /* @__PURE__ */ jsx("span", { className: "text-xl font-bold", children: currentBadge.label }),
420
+ currentBadge.paid && // Paid marker only — a literal "Pro" here was misleading next
421
+ // to non-Pro paid tiers ("Starter / Pro", QA finding).
422
+ /* @__PURE__ */ jsx(
423
+ Badge,
424
+ {
425
+ "aria-label": tr("billing.paidPlan", "Paid plan"),
426
+ className: "border-amber-400/40 bg-amber-400/15 text-amber-700 dark:text-amber-300",
427
+ children: /* @__PURE__ */ jsx(Crown, { className: "h-3 w-3" })
428
+ }
429
+ )
430
+ ] })
431
+ ] })
432
+ ] }),
433
+ currentPlan && /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
434
+ /* @__PURE__ */ jsx("span", { className: "text-2xl font-bold", children: formatPrice(currentPlan, tr) }),
435
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: intervalSuffix(currentPlan, tr) })
436
+ ] })
437
+ ] })
438
+ }
439
+ ),
440
+ /* @__PURE__ */ jsx("div", { className: "grid gap-6 md:grid-cols-2 lg:grid-cols-3", children: plans.map((plan) => {
441
+ const isCurrent = plan.id === currentPlanId;
442
+ const paid = plan.price > 0;
443
+ return /* @__PURE__ */ jsxs(
444
+ Card,
445
+ {
446
+ className: cn(
447
+ "relative flex flex-col",
448
+ plan.highlighted && "border-primary shadow-md",
449
+ isCurrent && "ring-2 ring-primary/40"
450
+ ),
451
+ children: [
452
+ plan.highlighted && /* @__PURE__ */ jsx("div", { className: "absolute -top-3 left-1/2 -translate-x-1/2", children: /* @__PURE__ */ jsxs(Badge, { children: [
453
+ /* @__PURE__ */ jsx(Crown, { className: "mr-1 h-3 w-3" }),
454
+ tr("billing.mostPopular", "Most Popular")
455
+ ] }) }),
456
+ /* @__PURE__ */ jsxs(CardHeader, { className: "pb-0", children: [
457
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
458
+ /* @__PURE__ */ jsx("h3", { className: "text-xl font-semibold", children: plan.name }),
459
+ paid && /* @__PURE__ */ jsx(Crown, { className: "h-4 w-4 text-amber-500" })
460
+ ] }),
461
+ plan.description && /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: plan.description })
462
+ ] }),
463
+ /* @__PURE__ */ jsxs(CardContent, { className: "flex flex-1 flex-col pt-4", children: [
464
+ /* @__PURE__ */ jsxs("div", { className: "mb-6", children: [
465
+ /* @__PURE__ */ jsx("span", { className: "text-4xl font-bold", children: formatPrice(plan, tr) }),
466
+ /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: intervalSuffix(plan, tr) })
467
+ ] }),
468
+ /* @__PURE__ */ jsx("ul", { className: "mb-6 flex-1 space-y-3", children: plan.features.map((feature) => /* @__PURE__ */ jsx(PlanFeatureItem, { feature, className: "text-sm", iconClassName: "h-4 w-4" }, feature)) }),
469
+ isCurrent ? /* @__PURE__ */ jsx(Button, { variant: "outline", className: "w-full", disabled: true, children: tr("billing.currentPlan", "Current Plan") }) : /* @__PURE__ */ jsx(
470
+ Button,
471
+ {
472
+ className: "w-full",
473
+ variant: plan.highlighted ? "default" : "outline",
474
+ onClick: () => setPending(plan),
475
+ children: tr("billing.changeToPlan", "Switch to this plan")
476
+ }
477
+ )
478
+ ] })
479
+ ]
480
+ },
481
+ plan.id
482
+ );
483
+ }) }),
484
+ (entitlementsMatrix || allFeatures.length > 0) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
485
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold", children: tr("billing.featureMatrix", "Feature comparison") }),
486
+ /* @__PURE__ */ jsx("div", { className: "overflow-x-auto rounded-lg border", children: /* @__PURE__ */ jsxs("table", { className: "w-full border-collapse text-sm", children: [
487
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: "border-b bg-muted/40", children: [
488
+ /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-left font-medium", children: tr("billing.features", "Features") }),
489
+ plans.map((plan) => /* @__PURE__ */ jsx("th", { className: "px-4 py-3 text-center font-medium", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", children: [
490
+ plan.price > 0 && /* @__PURE__ */ jsx(Crown, { className: "h-3.5 w-3.5 text-amber-500" }),
491
+ plan.name
492
+ ] }) }, plan.id))
493
+ ] }) }),
494
+ /* @__PURE__ */ jsx("tbody", { children: entitlementsMatrix ? /* @__PURE__ */ jsxs(Fragment, { children: [
495
+ entitlementsMatrix.featureIds.map((id, i) => /* @__PURE__ */ jsxs("tr", { className: cn(i % 2 === 1 && "bg-muted/20"), children: [
496
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-left", children: entitlementsMatrix.labelForFeature(id) }),
497
+ plans.map((plan) => {
498
+ const entitled = getPlanEntitlements(plan)?.features?.[id] !== false;
499
+ return /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-center", children: entitled ? /* @__PURE__ */ jsx(Check, { className: "mx-auto h-4 w-4 text-primary" }) : /* @__PURE__ */ jsx(Minus, { className: "mx-auto h-4 w-4 text-muted-foreground/40" }) }, plan.id);
500
+ })
501
+ ] }, `f:${id}`)),
502
+ entitlementsMatrix.limitKeys.map((key, i) => /* @__PURE__ */ jsxs("tr", { className: cn((entitlementsMatrix.featureIds.length + i) % 2 === 1 && "bg-muted/20"), children: [
503
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-left", children: entitlementsMatrix.labelForLimit(key) }),
504
+ plans.map((plan) => {
505
+ const cap = getPlanEntitlements(plan)?.limits?.[key];
506
+ const cell = cap === void 0 ? "\u2014" : cap < 0 ? tr("billing.unlimited", "Unlimited") : tr("billing.upTo", "Up to {count}").replace("{count}", String(cap)).replace("{{count}}", String(cap));
507
+ return /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-center text-muted-foreground", children: cell }, plan.id);
508
+ })
509
+ ] }, `l:${key}`))
510
+ ] }) : allFeatures.map((feature, i) => /* @__PURE__ */ jsxs("tr", { className: cn(i % 2 === 1 && "bg-muted/20"), children: [
511
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-left", children: parsePlanFeature(feature).label }),
512
+ plans.map((plan) => /* @__PURE__ */ jsx("td", { className: "px-4 py-2.5 text-center", children: plan.features.includes(feature) ? /* @__PURE__ */ jsx(Check, { className: "mx-auto h-4 w-4 text-primary" }) : /* @__PURE__ */ jsx(Minus, { className: "mx-auto h-4 w-4 text-muted-foreground/40" }) }, plan.id))
513
+ ] }, feature)) })
514
+ ] }) })
515
+ ] }),
516
+ /* @__PURE__ */ jsx(
517
+ ConfirmDialog,
518
+ {
519
+ open: pending !== null,
520
+ onConfirm: () => pending && void applyChange(pending),
521
+ onCancel: () => setPending(null),
522
+ title: tr("billing.changePlanConfirmTitle", "Change plan?"),
523
+ description: pending ? tr("billing.changePlanConfirmBody", "You're switching to the {{plan}} plan.").replace("{{plan}}", pending.name) : void 0,
524
+ confirmLabel: tr("billing.changePlanConfirm", "Switch plan"),
525
+ cancelLabel: tr("common.cancel", "Cancel"),
526
+ loading: busy
527
+ }
528
+ )
529
+ ] });
530
+ }
531
+
532
+ export { AccessProvider, CORE_LIMIT_DECLARATIONS, PlanFeatureItem, SubscriptionPage, checkAccess, entityDerivedLimitDeclarations, featureDisplayName, getAccessSnapshot, getPlanEntitlements, guardLimit, invalidateLimit, resolvePlanCurrency, useAccess, useAccessOptional, useLimit, useLimitGuard, useModuleNavAccess, useUpgradeModalStore };
533
+ //# sourceMappingURL=chunk-5O2UJAQ7.js.map
534
+ //# sourceMappingURL=chunk-5O2UJAQ7.js.map