@baasix/baasix 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/404/index.html +1 -1
- package/dist/app/404.html +1 -1
- package/dist/app/_next/static/chunks/{9599-c979a80a3f8557a2.js → 9599-9edda1c28609dcf0.js} +1 -1
- package/dist/app/_next/static/css/cbde4df39e638407.css +3 -0
- package/dist/app/activity-log/all-activity/index.html +1 -1
- package/dist/app/activity-log/all-activity/index.txt +1 -1
- package/dist/app/activity-log/email-log/index.html +1 -1
- package/dist/app/activity-log/email-log/index.txt +1 -1
- package/dist/app/activity-log/index.html +1 -1
- package/dist/app/activity-log/index.txt +1 -1
- package/dist/app/activity-log/notifications/index.html +1 -1
- package/dist/app/activity-log/notifications/index.txt +1 -1
- package/dist/app/activity-log/sessions/index.html +1 -1
- package/dist/app/activity-log/sessions/index.txt +1 -1
- package/dist/app/activity-log/workflow-executions/index.html +1 -1
- package/dist/app/activity-log/workflow-executions/index.txt +1 -1
- package/dist/app/activity-log/workflow-logs/index.html +1 -1
- package/dist/app/activity-log/workflow-logs/index.txt +1 -1
- package/dist/app/change-password/index.html +1 -1
- package/dist/app/change-password/index.txt +1 -1
- package/dist/app/dashboard/index.html +1 -1
- package/dist/app/dashboard/index.txt +1 -1
- package/dist/app/data-browser/index.html +1 -1
- package/dist/app/data-browser/index.txt +1 -1
- package/dist/app/file-manager/index.html +1 -1
- package/dist/app/file-manager/index.txt +1 -1
- package/dist/app/forgot-password/index.html +1 -1
- package/dist/app/forgot-password/index.txt +1 -1
- package/dist/app/index.html +1 -1
- package/dist/app/index.txt +1 -1
- package/dist/app/login/index.html +1 -1
- package/dist/app/login/index.txt +1 -1
- package/dist/app/register/index.html +1 -1
- package/dist/app/register/index.txt +1 -1
- package/dist/app/settings/migrations/index.html +1 -1
- package/dist/app/settings/migrations/index.txt +1 -1
- package/dist/app/settings/permissions/index.html +1 -1
- package/dist/app/settings/permissions/index.txt +2 -2
- package/dist/app/settings/project/index.html +1 -1
- package/dist/app/settings/project/index.txt +2 -2
- package/dist/app/settings/roles/index.html +1 -1
- package/dist/app/settings/roles/index.txt +2 -2
- package/dist/app/settings/schema/index.html +1 -1
- package/dist/app/settings/schema/index.txt +1 -1
- package/dist/app/settings/tasks/index.html +1 -1
- package/dist/app/settings/tasks/index.txt +1 -1
- package/dist/app/settings/templates/edit/index.html +1 -1
- package/dist/app/settings/templates/edit/index.txt +1 -1
- package/dist/app/settings/templates/index.html +1 -1
- package/dist/app/settings/templates/index.txt +2 -2
- package/dist/app/settings/tenants/index.html +1 -1
- package/dist/app/settings/tenants/index.txt +2 -2
- package/dist/app/users/index.html +1 -1
- package/dist/app/users/index.txt +1 -1
- package/dist/app/users/invites/index.html +1 -1
- package/dist/app/users/invites/index.txt +1 -1
- package/dist/app/users/list/index.html +1 -1
- package/dist/app/users/list/index.txt +1 -1
- package/dist/app/users/preferences/index.html +1 -1
- package/dist/app/users/preferences/index.txt +1 -1
- package/dist/app/users/user-roles/index.html +1 -1
- package/dist/app/users/user-roles/index.txt +1 -1
- package/dist/app/workflows/detail/index.html +1 -1
- package/dist/app/workflows/detail/index.txt +1 -1
- package/dist/app/workflows/edit/index.html +1 -1
- package/dist/app/workflows/edit/index.txt +1 -1
- package/dist/app/workflows/execution/index.html +1 -1
- package/dist/app/workflows/execution/index.txt +1 -1
- package/dist/app/workflows/index.html +1 -1
- package/dist/app/workflows/index.txt +1 -1
- package/dist/auth/routes.js +1 -1
- package/dist/auth/routes.js.map +1 -1
- package/dist/services/MailService.d.ts +3 -0
- package/dist/services/MailService.d.ts.map +1 -1
- package/dist/services/MailService.js +6 -4
- package/dist/services/MailService.js.map +1 -1
- package/package.json +1 -1
- package/dist/app/_next/static/css/6c4002bae4e236b2.css +0 -3
- /package/dist/app/_next/static/{3YgnPN88xlB7c-rX7iYE7 → Nyd0np5nDdcaHglA9X7AF}/_buildManifest.js +0 -0
- /package/dist/app/_next/static/{3YgnPN88xlB7c-rX7iYE7 → Nyd0np5nDdcaHglA9X7AF}/_ssgManifest.js +0 -0
package/dist/app/404/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/cbde4df39e638407.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-c0a542d3562cc14f.js"/><script src="/admin/_next/static/chunks/fd9d1056-54169f07cd680d6c.js" async=""></script><script src="/admin/_next/static/chunks/2117-29b5fa47421595ad.js" async=""></script><script src="/admin/_next/static/chunks/main-app-55bcae20c77aaf0e.js" async=""></script><script src="/admin/_next/static/chunks/6fcbdc68-90be1a5480b8d353.js" async=""></script><script src="/admin/_next/static/chunks/5094-8d53e403235d4ca6.js" async=""></script><script src="/admin/_next/static/chunks/4438-c9a12ca15b6e9160.js" async=""></script><script src="/admin/_next/static/chunks/6530-a91e10cffa4200c4.js" async=""></script><script src="/admin/_next/static/chunks/6241-30d7169d1010e5a4.js" async=""></script><script src="/admin/_next/static/chunks/1668-e3eabd0f6753c780.js" async=""></script><script src="/admin/_next/static/chunks/6869-11b3cd61c78598a7.js" async=""></script><script src="/admin/_next/static/chunks/8473-6598318371eca31b.js" async=""></script><script src="/admin/_next/static/chunks/4883-8a924721bb21b3b0.js" async=""></script><script src="/admin/_next/static/chunks/1303-6e8e0ab420489175.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-1af2638eaca64bf1.js" async=""></script><link rel="preload" href="https://www.googletagmanager.com/gtag/js?id=G-FBCW8DT7KT" as="script"/><meta name="robots" content="noindex"/><title>Baasix</title><script src="/admin/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="min-h-screen bg-background font-sans antialiased"><!--$--><div class="flex items-center justify-center min-h-screen bg-background"><div class="text-center"><div class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"></div><p class="mt-4 text-muted-foreground">Loading...</p></div></div><!--/$--><script src="/admin/_next/static/chunks/webpack-c0a542d3562cc14f.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/admin/_next/static/css/cbde4df39e638407.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[12846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[36423,[],\"\"]\n6:I[84821,[\"7999\",\"static/chunks/6fcbdc68-90be1a5480b8d353.js\",\"5094\",\"static/chunks/5094-8d53e403235d4ca6.js\",\"4438\",\"static/chunks/4438-c9a12ca15b6e9160.js\",\"6530\",\"static/chunks/6530-a91e10cffa4200c4.js\",\"6241\",\"static/chunks/6241-30d7169d1010e5a4.js\",\"1668\",\"static/chunks/1668-e3eabd0f6753c780.js\",\"6869\",\"static/chunks/6869-11b3cd61c78598a7.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"1303\",\"static/chunks/1303-6e8e0ab420489175.js\",\"3185\",\"static/chunks/app/layout-1af2638eaca64bf1.js\"],\"default\",1]\nc:I[61060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"Nyd0np5nDdcaHglA9X7AF\",\"assetPrefix\":\"/admin\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/admin/_next/static/css/cbde4df39e638407.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}],\"params\":{}}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}]]\n3:null\n"])</script></body></html>
|
package/dist/app/404.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/
|
|
1
|
+
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="stylesheet" href="/admin/_next/static/css/cbde4df39e638407.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-c0a542d3562cc14f.js"/><script src="/admin/_next/static/chunks/fd9d1056-54169f07cd680d6c.js" async=""></script><script src="/admin/_next/static/chunks/2117-29b5fa47421595ad.js" async=""></script><script src="/admin/_next/static/chunks/main-app-55bcae20c77aaf0e.js" async=""></script><script src="/admin/_next/static/chunks/6fcbdc68-90be1a5480b8d353.js" async=""></script><script src="/admin/_next/static/chunks/5094-8d53e403235d4ca6.js" async=""></script><script src="/admin/_next/static/chunks/4438-c9a12ca15b6e9160.js" async=""></script><script src="/admin/_next/static/chunks/6530-a91e10cffa4200c4.js" async=""></script><script src="/admin/_next/static/chunks/6241-30d7169d1010e5a4.js" async=""></script><script src="/admin/_next/static/chunks/1668-e3eabd0f6753c780.js" async=""></script><script src="/admin/_next/static/chunks/6869-11b3cd61c78598a7.js" async=""></script><script src="/admin/_next/static/chunks/8473-6598318371eca31b.js" async=""></script><script src="/admin/_next/static/chunks/4883-8a924721bb21b3b0.js" async=""></script><script src="/admin/_next/static/chunks/1303-6e8e0ab420489175.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-1af2638eaca64bf1.js" async=""></script><link rel="preload" href="https://www.googletagmanager.com/gtag/js?id=G-FBCW8DT7KT" as="script"/><meta name="robots" content="noindex"/><title>Baasix</title><script src="/admin/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body class="min-h-screen bg-background font-sans antialiased"><!--$--><div class="flex items-center justify-center min-h-screen bg-background"><div class="text-center"><div class="inline-block h-8 w-8 animate-spin rounded-full border-4 border-solid border-primary border-r-transparent align-[-0.125em] motion-reduce:animate-[spin_1.5s_linear_infinite]"></div><p class="mt-4 text-muted-foreground">Loading...</p></div></div><!--/$--><script src="/admin/_next/static/chunks/webpack-c0a542d3562cc14f.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/admin/_next/static/css/cbde4df39e638407.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"2:I[12846,[],\"\"]\n4:I[4707,[],\"\"]\n5:I[36423,[],\"\"]\n6:I[84821,[\"7999\",\"static/chunks/6fcbdc68-90be1a5480b8d353.js\",\"5094\",\"static/chunks/5094-8d53e403235d4ca6.js\",\"4438\",\"static/chunks/4438-c9a12ca15b6e9160.js\",\"6530\",\"static/chunks/6530-a91e10cffa4200c4.js\",\"6241\",\"static/chunks/6241-30d7169d1010e5a4.js\",\"1668\",\"static/chunks/1668-e3eabd0f6753c780.js\",\"6869\",\"static/chunks/6869-11b3cd61c78598a7.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"1303\",\"static/chunks/1303-6e8e0ab420489175.js\",\"3185\",\"static/chunks/app/layout-1af2638eaca64bf1.js\"],\"default\",1]\nc:I[61060,[],\"\"]\n7:{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"}\n8:{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"}\n9:{\"display\":\"inline-block\"}\na:{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0}\nd:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L2\",null,{\"buildId\":\"Nyd0np5nDdcaHglA9X7AF\",\"assetPrefix\":\"/admin\",\"urlParts\":[\"\",\"_not-found\",\"\"],\"initialTree\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"/_not-found\",{\"children\":[\"__PAGE__\",{},[[\"$L3\",[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],null],null],null]},[null,[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"/_not-found\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/admin/_next/static/css/cbde4df39e638407.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"$L6\",null,{\"children\":[\"$\",\"$L4\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L5\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":\"$7\",\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":\"$8\",\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":\"$9\",\"children\":[\"$\",\"h2\",null,{\"style\":\"$a\",\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}],\"params\":{}}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[[\"$\",\"meta\",null,{\"name\":\"robots\",\"content\":\"noindex\"}],\"$Lb\"],\"globalErrorComponent\":\"$c\",\"missingSlots\":\"$Wd\"}]\n"])</script><script>self.__next_f.push([1,"b:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}]]\n3:null\n"])</script></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9599],{24225:function(e,s,l){l.d(s,{HD:function(){return ef},iL:function(){return U},kL:function(){return x},h2:function(){return eT},Xx:function(){return R}});var a=l(57437),t=l(2265),n=l(69174),i=l(12381),r=l(42208),c=l(45675),d=l(18930),o=l(72337),m=l(71488);let u=["administrator","public"],x=()=>(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsx)(o.DataBrowserInner,{selectedCollection:"baasix_Role",title:"Roles Management",enableSearch:!0,enableFilters:!0,enableCreate:!0,enableView:!0,enableEdit:!0,enableDelete:!0,enableExport:!0,enableImport:!0,enableBulkSelect:!0,enableColumnSettings:!0,defaultVisibleColumns:["name","description","isTenantSpecific"],customColumnRenderers:{name:e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-medium",children:e}),u.includes(null==e?void 0:e.toLowerCase())&&(0,a.jsx)(m.pn,{children:(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{children:(0,a.jsx)(n.C,{variant:"outline",className:"text-xs",children:"System"})}),(0,a.jsx)(m._v,{children:(0,a.jsx)("p",{children:"System role - name cannot be changed"})})]})})]}),isTenantSpecific:e=>(0,a.jsx)(n.C,{variant:e?"default":"secondary",children:e?"Yes":"No"})},renderRowActions:e=>{var s;let{record:l,onView:t,onEdit:n,onDelete:o}=e,x=u.includes(null===(s=l.name)||void 0===s?void 0:s.toLowerCase());return(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:t,children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})}),(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,a.jsx)(c.Z,{className:"h-4 w-4"})}),(0,a.jsx)(m.pn,{children:(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)("span",{children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:o,disabled:x,children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})})})}),x&&(0,a.jsx)(m._v,{children:(0,a.jsx)("p",{children:"System roles cannot be deleted"})})]})})]})},getDisabledFields:e=>{var s;return u.includes(null==e?void 0:null===(s=e.name)||void 0===s?void 0:s.toLowerCase())?["name","isTenantSpecific"]:[]}})});var h=l(98728),p=l(74291),j=l(72135),v=l(51817),f=l(83229),g=l(14438),y=l(40279),N=l(75060),b=l(23675),w=l(94589),C=l(79820),_=l(17168),S=l(69140),A=l(5101),T=l(24065),k=l(54572);let I=[{name:"project_name",label:"Project Name",type:"String"},{name:"title",label:"Title",type:"String"},{name:"project_url",label:"API URL",type:"String"},{name:"app_url",label:"App URL",type:"String"},{name:"project_color",label:"Primary Color",type:"String",inputType:"color"},{name:"secondary_color",label:"Secondary Color",type:"String",inputType:"color"},{name:"description",label:"Description",type:"Text"},{name:"keywords",label:"Keywords",type:"String"}],Z=[{name:"project_logo_light",label:"Logo (Light)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_light_Id"},{name:"project_logo_dark",label:"Logo (Dark)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_dark_Id"},{name:"project_logo_full",label:"Logo (Full)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_full_Id"},{name:"project_logo_transparent",label:"Logo (Transparent)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_transparent_Id"},{name:"project_favicon",label:"Favicon",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_favicon_Id"},{name:"project_icon",label:"Project Icon",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_icon_Id"},{name:"email_icon",label:"Email Icon",relType:"BelongsTo",target:"baasix_File",foreignKey:"email_icon_Id"}],z=[{name:"email_signature",label:"Email Signature",type:"Text"},{name:"from_email_name",label:"From Email Name",type:"String"}],P=[{name:"smtp_enabled",label:"Enable SMTP",type:"Boolean"},{name:"smtp_host",label:"SMTP Host",type:"String"},{name:"smtp_port",label:"SMTP Port",type:"Integer"},{name:"smtp_secure",label:"SMTP Secure",type:"Boolean"},{name:"smtp_user",label:"SMTP Username",type:"String"},{name:"smtp_pass",label:"SMTP Password",type:"String",inputType:"password"},{name:"smtp_from_address",label:"SMTP From Address",type:"String"}],E=[{name:"timezone",label:"Timezone",type:"String"},{name:"language",label:"Language",type:"String"},{name:"date_format",label:"Date Format",type:"String"},{name:"currency",label:"Currency",type:"String"}],F=[{name:"mobile_session_limit",label:"Mobile Session Limit",type:"Integer",description:"-1 for unlimited, 0 to disable"},{name:"web_session_limit",label:"Web Session Limit",type:"Integer",description:"-1 for unlimited, 0 to disable"},{name:"session_limit_roles",label:"Session Limit Roles",type:"JSON",description:"Array of role IDs to apply session limits"}],O=[{name:"metadata",label:"Metadata",type:"JSON"},{name:"modules",label:"Modules",type:"JSON"}],D=e=>{var s;let{tenantId:l,title:n="Settings",description:r="Configure settings",onSaveSuccess:c,compact:d=!1}=e,[o,m]=(0,t.useState)(!1),[u,x]=(0,t.useState)({}),[h,p]=(0,t.useState)({}),[D,L]=(0,t.useState)(!1),[V,M]=(0,t.useState)(null),[R,B]=(0,t.useState)(null),[U,J]=(0,t.useState)(!1),{data:Q,isLoading:q,refetch:Y}=(0,j.sm)({resource:"baasix_Settings",filters:[{field:"tenant_Id",operator:"eq",value:l}],pagination:{current:1,pageSize:1},meta:{fields:["*","project_logo_light.*","project_logo_dark.*","project_logo_full.*","project_logo_transparent.*","project_favicon.*","project_icon.*","email_icon.*"]},queryOptions:{enabled:!!l}}),{data:K,isLoading:W,refetch:H}=(0,j.rD)({resource:"baasix_Settings",id:"1",meta:{fields:["*","project_logo_light.*","project_logo_dark.*","project_logo_full.*","project_logo_transparent.*","project_favicon.*","project_icon.*","email_icon.*"]},queryOptions:{enabled:!l}}),$=l?q:W,X=l?(null==Q?void 0:null===(s=Q.data)||void 0===s?void 0:s[0])||null:null==K?void 0:K.data,G=l?Y:H,{mutate:ee}=(0,j.PQ)(),{mutate:es}=(0,j.RO)();(0,t.useEffect)(()=>{var e,s,a;if(l&&!q){let l=null==Q?void 0:null===(e=Q.data)||void 0===e?void 0:e[0];if(l){x(l),B((null===(s=l.id)||void 0===s?void 0:s.toString())||null),J(!1);let e={};Z.forEach(s=>{l[s.name]&&(e[s.name]=l[s.name])}),p(e)}else x({}),B(null),J(!0),p({})}else if(!l&&X){x(X),B((null===(a=X.id)||void 0===a?void 0:a.toString())||null),J(!1);let e={};Z.forEach(s=>{X[s.name]&&(e[s.name]=X[s.name])}),p(e)}},[l,q,Q,X]);let el=()=>{let e={...u};return Z.forEach(s=>{let l=h[s.name];if(l){let a="string"==typeof l?l:l.id;e[s.foreignKey]=a}else e[s.foreignKey]=null;delete e[s.name]}),delete e.id,delete e.createdAt,delete e.updatedAt,delete e.userCreated,delete e.userUpdated,delete e.userCreated_Id,delete e.userUpdated_Id,delete e.tenant,l&&(e.tenant_Id=l),e},ea=async()=>{m(!0);try{let e=el();if(U)es({resource:"baasix_Settings",values:e},{onSuccess:()=>{g.Am.success("Tenant settings created successfully"),J(!1),G(),null==c||c()},onError:e=>{g.Am.error((null==e?void 0:e.message)||"Failed to create settings")}});else{let s=l?R:"1";if(!s){g.Am.error("No settings found to update");return}ee({resource:"baasix_Settings",id:s,values:e},{onSuccess:()=>{g.Am.success("Settings saved successfully"),G(),null==c||c()},onError:e=>{g.Am.error((null==e?void 0:e.message)||"Failed to save settings")}})}}catch(e){g.Am.error((null==e?void 0:e.message)||"Failed to save settings")}finally{m(!1)}},et=(e,s)=>{x(l=>({...l,[e]:s}))},en=(0,t.useCallback)((e,s)=>{let l=s?"string"==typeof s?{id:s}:s:null;p(s=>({...s,[e.name]:l}))},[]),ei=(0,t.useCallback)(e=>{p(s=>{let l={...s};return delete l[e.name],l})},[]),er=e=>{M(e),L(!0)},ec=e=>{let s=u[e.name];return e.relType?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:e.label}),(0,a.jsx)(A.q,{value:h[e.name],field:e,onClick:()=>er(e),onRemove:()=>ei(e)})]},e.name):"Boolean"===e.type?(0,a.jsxs)("div",{className:"flex items-center justify-between py-2",children:[(0,a.jsxs)("div",{className:"space-y-0.5",children:[(0,a.jsx)(N._,{children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(w.r,{checked:s||!1,onCheckedChange:s=>et(e.name,s)})]},e.name):"JSON"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(k.mq,{value:s,onChange:s=>et(e.name,s)})]},e.name):"Text"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(b.g,{id:e.name,value:s||"",onChange:s=>et(e.name,s.target.value),rows:3})]},e.name):"Integer"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(y.I,{id:e.name,type:"number",value:null!=s?s:"",onChange:s=>et(e.name,s.target.value?parseInt(s.target.value):null)})]},e.name):"color"===e.inputType?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(y.I,{id:e.name,type:"color",value:s||"#000000",onChange:s=>et(e.name,s.target.value),className:"w-12 h-10 p-1 cursor-pointer"}),(0,a.jsx)(y.I,{value:s||"",onChange:s=>et(e.name,s.target.value),placeholder:"#000000",className:"flex-1"})]})]},e.name):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(y.I,{id:e.name,type:e.inputType||"text",value:s||"",onChange:s=>et(e.name,s.target.value)})]},e.name)},ed=()=>(0,a.jsxs)(_.mQ,{defaultValue:"branding",className:"space-y-4",children:[(0,a.jsxs)(_.dr,{className:"flex-wrap h-auto gap-1",children:[(0,a.jsx)(_.SP,{value:"branding",children:"Branding"}),(0,a.jsx)(_.SP,{value:"logos",children:"Logos & Icons"}),(0,a.jsx)(_.SP,{value:"email",children:"Email"}),(0,a.jsx)(_.SP,{value:"smtp",children:"SMTP"}),(0,a.jsx)(_.SP,{value:"localization",children:"Localization"}),(0,a.jsx)(_.SP,{value:"sessions",children:"Sessions"}),(0,a.jsx)(_.SP,{value:"advanced",children:"Advanced"})]}),(0,a.jsxs)(_.nU,{value:"branding",className:"space-y-4",children:[(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:I.slice(0,4).map(ec)}),(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:I.slice(4,6).map(ec)}),I.slice(6).map(ec)]}),(0,a.jsx)(_.nU,{value:"logos",className:"space-y-4",children:(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Z.map(ec)})}),(0,a.jsx)(_.nU,{value:"email",className:"space-y-4",children:z.map(ec)}),(0,a.jsxs)(_.nU,{value:"smtp",className:"space-y-4",children:[P.filter(e=>"Boolean"===e.type).map(ec),u.smtp_enabled&&(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2 pt-4 border-t",children:P.filter(e=>"Boolean"!==e.type).map(ec)})]}),(0,a.jsx)(_.nU,{value:"localization",className:"space-y-4",children:(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:E.map(ec)})}),(0,a.jsxs)(_.nU,{value:"sessions",className:"space-y-4",children:[(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:F.filter(e=>"Integer"===e.type).map(ec)}),F.filter(e=>"JSON"===e.type).map(ec)]}),(0,a.jsx)(_.nU,{value:"advanced",className:"space-y-4",children:O.map(ec)})]});if($)return d?(0,a.jsx)("div",{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(S.O,{className:"h-4 w-24"}),(0,a.jsx)(S.O,{className:"h-10 w-full"})]},s))}):(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{children:[(0,a.jsx)(S.O,{className:"h-6 w-48"}),(0,a.jsx)(S.O,{className:"h-4 w-96 mt-2"})]}),(0,a.jsx)(C.aY,{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(S.O,{className:"h-4 w-24"}),(0,a.jsx)(S.O,{className:"h-10 w-full"})]},s))})]});let eo=(0,a.jsxs)(i.z,{onClick:ea,disabled:o,children:[o?(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}):(0,a.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),U?"Create Settings":"Save Changes"]});return d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-4",children:[ed(),(0,a.jsx)("div",{className:"flex justify-end pt-4 border-t",children:eo})]}),V&&(0,a.jsx)(T.x,{open:D,onClose:()=>{L(!1),setTimeout(()=>M(null),100)},onSelect:e=>en(V,e),target:V.target,field:V,selectedItems:h[V.name]?[h[V.name]]:[]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{className:"flex flex-row items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(C.ll,{children:n}),(0,a.jsx)(C.SZ,{children:r})]}),eo]}),(0,a.jsx)(C.aY,{children:ed()})]}),V&&(0,a.jsx)(T.x,{open:D,onClose:()=>{L(!1),setTimeout(()=>M(null),100)},onSelect:e=>en(V,e),target:V.target,field:V,selectedItems:h[V.name]?[h[V.name]]:[]})]})},L=e=>{let{open:s,onClose:l,tenantId:t,tenantName:n}=e;return(0,a.jsx)(p.Vq,{open:s,onOpenChange:e=>!e&&l(),children:(0,a.jsxs)(p.cZ,{className:"max-w-4xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,a.jsxs)(p.fK,{className:"flex-shrink-0 px-6 pt-6 pb-4",children:[(0,a.jsxs)(p.$N,{children:["Settings for ",n||"Tenant ".concat(t)]}),(0,a.jsx)(p.Be,{children:"Configure tenant-specific settings. These will override global project settings for this tenant."})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:(0,a.jsx)(D,{tenantId:t,compact:!0,onSaveSuccess:()=>{l()}})})]})})};var V=l(71096),M=l.n(V);let R=()=>{let[e,s]=(0,t.useState)(!1),[l,r]=(0,t.useState)(null),c=e=>{r({id:e.id,name:e.name}),s(!0)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsx)(o.DataBrowserInner,{selectedCollection:"baasix_Tenant",title:"Tenants Management",enableSearch:!0,enableFilters:!0,enableCreate:!0,enableView:!0,enableEdit:!0,enableDelete:!0,enableExport:!0,enableImport:!0,enableBulkSelect:!0,enableColumnSettings:!0,defaultVisibleColumns:["name","status","createdAt"],customColumnRenderers:{name:e=>(0,a.jsx)("span",{className:"font-medium",children:e}),status:e=>(0,a.jsx)(n.C,{variant:"active"===e?"default":"secondary",children:e||"Active"}),createdAt:e=>(0,a.jsx)("span",{className:"text-muted-foreground",children:e?M()(e).format("MMM D, YYYY HH:mm"):"-"})},renderRowActions:e=>{let{record:s,onView:l,onEdit:t,onDelete:n}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>c(s),title:"Tenant Settings",children:(0,a.jsx)(h.Z,{className:"h-4 w-4"})}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:l,title:"View",children:[(0,a.jsx)("span",{className:"sr-only",children:"View"}),(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})]}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:t,title:"Edit",children:[(0,a.jsx)("span",{className:"sr-only",children:"Edit"}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})]}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:n,title:"Delete",className:"text-destructive hover:text-destructive",children:[(0,a.jsx)("span",{className:"sr-only",children:"Delete"}),(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M3 6h18"}),(0,a.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,a.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})]})]})}})}),l&&(0,a.jsx)(L,{open:e,onClose:()=>{s(!1),r(null)},tenantId:l.id,tenantName:l.name})]})};var B=l(81853);let U=()=>{let{refetch:e}=(0,B.PY)();return(0,a.jsx)(D,{title:"Project Settings",description:"Configure your project branding, email, and other settings",onSaveSuccess:e})};var J=l(32489),Q=l(30401),q=l(88906),Y=l(95805),K=l(50091),W=l(17689),H=l(92735),$=l(33804),X=l(15291),G=l(29696),ee=l(47307),es=l(40875),el=l(93448);let ea=ee.fC,et=t.forwardRef((e,s)=>{let{className:l,...t}=e;return(0,a.jsx)(ee.ck,{ref:s,className:(0,el.cn)("border-b",l),...t})});et.displayName="AccordionItem";let en=t.forwardRef((e,s)=>{let{className:l,children:t,...n}=e;return(0,a.jsx)(ee.h4,{className:"flex",children:(0,a.jsxs)(ee.xz,{ref:s,className:(0,el.cn)("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",l),...n,children:[t,(0,a.jsx)(es.Z,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})})});en.displayName=ee.xz.displayName;let ei=t.forwardRef((e,s)=>{let{className:l,children:t,...n}=e;return(0,a.jsx)(ee.VY,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:(0,a.jsx)("div",{className:(0,el.cn)("pb-4 pt-0",l),children:t})})});ei.displayName=ee.VY.displayName;var er=l(10407),ec=l(91032),ed=l(68245);let eo=e=>{let{nodes:s,selectedFields:l,onSelectionChange:t,level:n=0,expandedNodes:i,onToggleExpand:r}=e,c=e=>{l.includes(e.value)?t(l.filter(s=>s!==e.value)):t([...l,e.value])},d=e=>{if(e.value.endsWith(".*")&&e.children&&e.children.length>0){let s=e.value.split("."),l=s[s.length-2]||s[0];return"".concat(l,".*")}if(e.value.startsWith("*"))return e.value;let s=e.title.split(".");return s[s.length-1]},o=e=>"*"===e?"all fields":"*.*"===e?"all + 1 level relations":"*.*.*"===e?"all + 2 level relations":"*.*.*.*"===e?"all + 3 level relations":null,m=s.filter(e=>!!e.value.startsWith("*")||!e.value.endsWith(".*")||!!e.children&&0!==e.children.length);return(0,a.jsx)("div",{className:(0,el.cn)("space-y-0.5",n>0&&"ml-4 pl-2 border-l border-muted"),children:m.map(e=>{let s=e.children&&e.children.length>0,m=i.has(e.key),u=l.includes(e.value),x=o(e.value);return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[s?(0,a.jsx)("button",{type:"button",onClick:()=>r(e.key),className:"p-0.5 hover:bg-muted rounded",children:m?(0,a.jsx)(es.Z,{className:"h-3.5 w-3.5"}):(0,a.jsx)(er.Z,{className:"h-3.5 w-3.5"})}):(0,a.jsx)("span",{className:"w-4"}),(0,a.jsx)(ed.X,{id:"field-".concat(e.key),checked:u,onCheckedChange:()=>c(e)}),(0,a.jsxs)(N._,{htmlFor:"field-".concat(e.key),className:(0,el.cn)("text-sm cursor-pointer flex-1",x&&"font-mono"),children:[d(e),x&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:["(",x,")"]}),s&&!x&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),s&&m&&(0,a.jsx)(eo,{nodes:e.children,selectedFields:l,onSelectionChange:t,level:n+1,expandedNodes:i,onToggleExpand:r})]},e.key)})})},em=e=>{let{open:s,onClose:l,permissionId:r,mode:c,defaultValues:o}=e,[m,u]=(0,t.useState)({collection:"",role_Id:"",action:"",fields:["*"],conditions:null,relConditions:null,defaultValues:null}),[x,h]=(0,t.useState)({}),[f,y]=(0,t.useState)(!1),[b,w]=(0,t.useState)(!1),[S,A]=(0,t.useState)("tree"),{schemas:T,getPermissionFields:I}=(0,G.I_)(),{data:Z,isLoading:z}=(0,j.rD)({resource:"permissions",id:r||"",queryOptions:{enabled:s&&"edit"===c&&!!r}}),{data:P}=(0,j.sm)({resource:"baasix_Role",pagination:{pageSize:-1}}),{mutate:E}=(0,j.RO)(),{mutate:F}=(0,j.PQ)(),{mutate:O}=(0,j.R2)(),D=(0,t.useMemo)(()=>T||[],[T]),L=(0,t.useMemo)(()=>(null==P?void 0:P.data)||[],[P]),V=(0,t.useMemo)(()=>m.collection&&I?I(m.collection):[],[m.collection,I]);(0,t.useEffect)(()=>{if("edit"===c&&(null==Z?void 0:Z.data)){var e;let s=Z.data,l=["*"];Array.isArray(s.fields)?l=s.fields:"string"==typeof s.fields&&(l=s.fields.split(",").map(e=>e.trim())),u({collection:s.collection||"",role_Id:s.role_Id||(null===(e=s.role)||void 0===e?void 0:e.id)||"",action:s.action||"",fields:l,conditions:s.conditions||null,relConditions:s.relConditions||null,defaultValues:s.defaultValues||null})}else"create"===c&&o&&u({collection:o.collection||"",role_Id:o.roleId||"",action:o.action||"",fields:["*"],conditions:null,relConditions:null,defaultValues:null})},[c,Z,o,s]);let M=()=>{u({collection:"",role_Id:"",action:"",fields:["*"],conditions:null,relConditions:null,defaultValues:null}),h({}),A("tree"),l()},R=()=>{r&&O({resource:"permissions",id:r},{onSuccess:()=>{g.Am.success("Permission deleted successfully"),M()},onError:e=>{g.Am.error("Error deleting permission: ".concat(e.message))}})},B=async e=>{e.preventDefault();let s={};if(m.collection||(s.collection="Collection is required"),m.role_Id||(s.role_Id="Role is required"),m.action||(s.action="Action is required"),Object.keys(s).length>0){h(s);return}y(!0);try{let e={collection:m.collection,role_Id:m.role_Id,action:m.action,fields:m.fields.length>0?m.fields:["*"],conditions:m.conditions||null,relConditions:m.relConditions||null,defaultValues:m.defaultValues||null};"create"===c?E({resource:"permissions",values:e},{onSuccess:()=>{g.Am.success("Permission created successfully"),M()},onError:e=>{g.Am.error("Error creating permission: ".concat(e.message))}}):F({resource:"permissions",id:r,values:e},{onSuccess:()=>{g.Am.success("Permission updated successfully"),M()},onError:e=>{g.Am.error("Error updating permission: ".concat(e.message))}})}catch(e){g.Am.error("Error: ".concat(e.message))}finally{y(!1)}},U=e=>{let s=L.find(s=>s.id===e);return(null==s?void 0:s.name)||e},J=e=>{var s;let l=D.find(s=>s.collectionName===e);return(null==l?void 0:null===(s=l.schema)||void 0===s?void 0:s.name)||e},[Q,q]=(0,t.useState)(new Set),Y="edit"===c&&z,K=(0,t.useMemo)(()=>{if("create"===c&&o){let e=o.action?o.action.charAt(0).toUpperCase()+o.action.slice(1):"",s=o.collection?J(o.collection):"",l=o.roleId?U(o.roleId):"";if(e&&s&&l)return"Create ".concat(e," Permission")}else if("edit"===c&&m.action){let e=m.action.charAt(0).toUpperCase()+m.action.slice(1);return"Edit ".concat(e," Permission")}return"create"===c?"Create Permission":"Edit Permission"},[c,o,m.action,L,D]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec.yo,{open:s,onOpenChange:e=>!e&&M(),children:(0,a.jsxs)(ec.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{className:"flex flex-row items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(ec.bC,{children:K}),(o||m.collection)&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mt-2",children:[((null==o?void 0:o.collection)||m.collection)&&(0,a.jsx)(n.C,{variant:"outline",children:J((null==o?void 0:o.collection)||m.collection)}),((null==o?void 0:o.roleId)||m.role_Id)&&(0,a.jsx)(n.C,{variant:"secondary",children:U((null==o?void 0:o.roleId)||m.role_Id)}),((null==o?void 0:o.action)||m.action)&&(0,a.jsx)(n.C,{children:((null==o?void 0:o.action)||m.action).charAt(0).toUpperCase()+((null==o?void 0:o.action)||m.action).slice(1)})]})]}),"edit"===c&&(0,a.jsxs)(i.z,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>w(!0),children:[(0,a.jsx)(d.Z,{className:"h-4 w-4 mr-1"}),"Delete"]})]}),Y?(0,a.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,a.jsx)(v.Z,{className:"h-6 w-6 animate-spin"})}):(0,a.jsxs)("form",{onSubmit:B,className:"mt-6 space-y-4",children:["delete"!==m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:"Fields"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select fields to allow. Leave empty or select * to allow all fields."}),(0,a.jsxs)(_.mQ,{value:S,onValueChange:e=>A(e),children:[(0,a.jsxs)(_.dr,{className:"grid w-full grid-cols-2",children:[(0,a.jsx)(_.SP,{value:"tree",children:"Tree Selection"}),(0,a.jsx)(_.SP,{value:"json",children:"JSON"})]}),(0,a.jsx)(_.nU,{value:"tree",className:"mt-2",children:(0,a.jsx)(C.Zb,{className:"max-h-[250px] overflow-y-auto",children:(0,a.jsx)(C.aY,{className:"p-3",children:V.length>0?(0,a.jsx)(eo,{nodes:V,selectedFields:m.fields,onSelectionChange:e=>{let s=e.length>0?e:["*"];u({...m,fields:s})},expandedNodes:Q,onToggleExpand:e=>{q(s=>{let l=new Set(s);return l.has(e)?l.delete(e):l.add(e),l})}}):(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"Select a collection to see available fields"})})})}),(0,a.jsxs)(_.nU,{value:"json",className:"mt-2",children:[(0,a.jsx)(k.mq,{value:m.fields,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?(u({...m,fields:e.length>0?e:["*"]}),h({...x,fieldsJson:""})):null===e&&(u({...m,fields:["*"]}),h({...x,fieldsJson:""}))},placeholder:'["*"]'}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:'Enter field names as a JSON array. Example: ["id", "name", "user.*"]'})]})]})]}),"create"!==m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"conditions",children:"Conditions"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter conditions in JSON format"}),(0,a.jsx)(k.mq,{value:m.conditions,onChange:e=>u({...m,conditions:e}),placeholder:'{"field": "value"}'})]}),"read"===m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"relConditions",children:"Relational Conditions (HasMany)"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter conditions in JSON format"}),(0,a.jsx)(k.mq,{value:m.relConditions,onChange:e=>u({...m,relConditions:e}),placeholder:'{"relation": {"field": "value"}}'})]}),("create"===m.action||"update"===m.action)&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"defaultValues",children:"Default Values"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter default values in JSON format"}),(0,a.jsx)(k.mq,{value:m.defaultValues,onChange:e=>u({...m,defaultValues:e}),placeholder:'{"field": "defaultValue"}'})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-4",children:[(0,a.jsxs)(i.z,{type:"submit",disabled:f,children:[f&&(0,a.jsx)(v.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"create"===c?"Create":"Update"]}),(0,a.jsx)(i.z,{type:"button",variant:"outline",onClick:M,children:"Cancel"})]})]})]})}),(0,a.jsx)(p.Vq,{open:b,onOpenChange:w,children:(0,a.jsxs)(p.cZ,{children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Delete Permission"}),(0,a.jsx)(p.Be,{children:"Are you sure you want to delete this permission? This action cannot be undone."})]}),(0,a.jsxs)(p.cN,{children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),(0,a.jsx)(i.z,{variant:"destructive",onClick:()=>{w(!1),R()},children:"Delete"})]})]})})]})};var eu=l(99397),ex=l(76865),eh=l(17342),ep=l(95937);let ej=e=>{var s,l,r,c,o,m,u,x,h,p,f,y;let{open:N,onClose:b}=e,[w,C]=(0,t.useState)(null),[_,S]=(0,t.useState)(null),[A,T]=(0,t.useState)(!1),k=(0,t.useRef)(null),I=(0,j.Ji)(),{mutate:Z,isLoading:z}=(0,j.uC)(),{mutate:P,isLoading:E}=(0,j.uC)(),F=async e=>{if(!e||!e.name.endsWith(".json")){g.Am.error("Please select a valid JSON file");return}C(e);let s=new FormData;s.append("rolesPermissions",e),Z({url:"".concat(I,"/permissions-preview-import"),method:"post",values:s},{onSuccess:e=>{S(null==e?void 0:e.data)},onError:e=>{g.Am.error("Error analyzing file: ".concat(e.message)),S(null)}})},O=async()=>{if(!w)return;let e=new FormData;e.append("rolesPermissions",w),P({url:"".concat(I,"/permissions-import"),method:"post",values:e},{onSuccess:()=>{g.Am.success("Permissions imported successfully"),D()},onError:e=>{g.Am.error("Error importing permissions: ".concat(e.message))}})},D=()=>{C(null),S(null),b()},L=e=>{if(!e)return null;let{added:s,modified:l,removed:t}=e;return(0,a.jsxs)("div",{className:"ml-6 mt-2 space-y-2 text-xs",children:[(null==s?void 0:s.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Added permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map((e,s)=>{let[l,t]=e.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-green-600 border-green-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]}),(null==l?void 0:l.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-yellow-600 font-medium",children:"Modified permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:l.map((e,s)=>{let[l,t]=e.permission.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-yellow-600 border-yellow-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]}),(null==t?void 0:t.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-red-600 font-medium",children:"Removed permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map((e,s)=>{let[l,t]=e.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-red-600 border-red-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]})]})},V=(e,s)=>{if(!e||0===e.length)return(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"No items"});let l=()=>{switch(s){case"new":return(0,a.jsx)(eu.Z,{className:"h-4 w-4 text-green-600"});case"modified":return(0,a.jsx)(ex.Z,{className:"h-4 w-4 text-yellow-600"});case"deleted":return(0,a.jsx)(d.Z,{className:"h-4 w-4 text-red-600"});case"unchanged":return(0,a.jsx)(Q.Z,{className:"h-4 w-4 text-green-600"})}};return(0,a.jsx)("ul",{className:"space-y-2",children:e.map((e,s)=>{var t,i,r,c,d;return(0,a.jsxs)("li",{className:"flex flex-col py-2 border-b last:border-0",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[l(),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"string"==typeof e?e:e.name}),(null===(t=e.differences)||void 0===t?void 0:t.permissions)&&(0,a.jsxs)("div",{className:"flex gap-1 mt-1 flex-wrap",children:[(null===(i=e.differences.permissions.added)||void 0===i?void 0:i.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-green-600 border-green-600 text-xs",children:["+",e.differences.permissions.added.length," added"]}),(null===(r=e.differences.permissions.modified)||void 0===r?void 0:r.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-yellow-600 border-yellow-600 text-xs",children:["~",e.differences.permissions.modified.length," modified"]}),(null===(c=e.differences.permissions.removed)||void 0===c?void 0:c.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-red-600 border-red-600 text-xs",children:["-",e.differences.permissions.removed.length," removed"]})]})]})]}),(null===(d=e.differences)||void 0===d?void 0:d.permissions)&&L(e.differences.permissions)]},s)})})};return(0,a.jsx)(ec.yo,{open:N,onOpenChange:e=>!e&&D(),children:(0,a.jsxs)(ec.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{className:"flex flex-row items-center justify-between",children:[(0,a.jsx)(ec.bC,{children:"Import Permissions"}),_&&(0,a.jsxs)(i.z,{onClick:O,disabled:E,children:[E&&(0,a.jsx)(v.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm Import"]})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-8 text-center transition-colors ".concat(A?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"),onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:e=>{e.preventDefault(),T(!1)},onDrop:e=>{e.preventDefault(),T(!1);let s=e.dataTransfer.files[0];s&&F(s)},onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.click()},children:[(0,a.jsx)("input",{ref:k,type:"file",accept:".json",className:"hidden",onChange:e=>{var s;let l=null===(s=e.target.files)||void 0===s?void 0:s[0];l&&F(l)}}),(0,a.jsx)(W.Z,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:"Click or drag permissions file to upload"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Support for single JSON file upload only"}),w&&(0,a.jsxs)("div",{className:"mt-4 flex items-center justify-center gap-2 text-sm",children:[(0,a.jsx)(eh.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:w.name})]})]}),z&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(v.Z,{className:"h-6 w-6 animate-spin mr-2"}),(0,a.jsx)("span",{children:"Analyzing permission changes..."})]}),_&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(ep.bZ,{children:[(0,a.jsx)(Q.Z,{className:"h-4 w-4"}),(0,a.jsx)(ep.Cd,{children:"Permissions Analysis Complete"}),(0,a.jsxs)(ep.X,{children:["Import version: ",_.importVersion," (",_.importTimestamp,")"]})]}),(0,a.jsxs)(ea,{type:"multiple",defaultValue:["new","modified","deleted","unchanged"],children:[(0,a.jsxs)(et,{value:"new",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eu.Z,{className:"h-4 w-4 text-green-600"}),"New Roles (",(null===(l=_.changes)||void 0===l?void 0:null===(s=l.new)||void 0===s?void 0:s.length)||0,")"]})}),(0,a.jsx)(ei,{children:V(null===(r=_.changes)||void 0===r?void 0:r.new,"new")})]}),(0,a.jsxs)(et,{value:"modified",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ex.Z,{className:"h-4 w-4 text-yellow-600"}),"Modified Roles (",(null===(o=_.changes)||void 0===o?void 0:null===(c=o.modified)||void 0===c?void 0:c.length)||0,")"]})}),(0,a.jsx)(ei,{children:V(null===(m=_.changes)||void 0===m?void 0:m.modified,"modified")})]}),(0,a.jsxs)(et,{value:"deleted",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.Z,{className:"h-4 w-4 text-red-600"}),"Deleted Roles (",(null===(x=_.changes)||void 0===x?void 0:null===(u=x.deleted)||void 0===u?void 0:u.length)||0,")"]})}),(0,a.jsx)(ei,{children:V(null===(h=_.changes)||void 0===h?void 0:h.deleted,"deleted")})]}),(0,a.jsxs)(et,{value:"unchanged",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Q.Z,{className:"h-4 w-4 text-green-600"}),"Unchanged Roles (",(null===(f=_.changes)||void 0===f?void 0:null===(p=f.unchanged)||void 0===p?void 0:p.length)||0,")"]})}),(0,a.jsx)(ei,{children:V(null===(y=_.changes)||void 0===y?void 0:y.unchanged,"unchanged")})]})]})]})]})]})})},ev=["create","read","update","delete"],ef=()=>{let[e,s]=(0,t.useState)("all"),[l,n]=(0,t.useState)("all"),[r,d]=(0,t.useState)(!1),[o,u]=(0,t.useState)(!1),[x,h]=(0,t.useState)(null),[p,f]=(0,t.useState)("create"),y=(0,j.Ji)(),{schemas:N}=(0,G.I_)(),{data:b,isLoading:w,refetch:_}=(0,j.sm)({resource:"baasix_Role",filters:[{field:"name",operator:"ne",value:"administrator"}],pagination:{pageSize:-1}}),{data:A,isLoading:T,refetch:k}=(0,j.sm)({resource:"permissions",meta:{fields:["*","role.id","role.name"]},pagination:{pageSize:-1}}),{refetch:I,isFetching:Z}=(0,j.EV)({url:"".concat(y,"/permissions-export"),method:"get",queryOptions:{enabled:!1,retry:!1}}),z=async()=>{try{let e=await I(),s=null==e?void 0:e.data;if(!(null==s?void 0:s.data)||(null==s?void 0:s.data.length)===0){g.Am.error("No permissions found to export");return}let l=window.URL.createObjectURL(new Blob([JSON.stringify(null==s?void 0:s.data)])),a=document.createElement("a");a.href=l,a.setAttribute("download","roles-permissions-export-".concat(Date.now(),".json")),document.body.appendChild(a),a.click(),a.remove(),window.URL.revokeObjectURL(l),g.Am.success("Permissions exported successfully")}catch(e){g.Am.error("Error exporting permissions: ".concat(e.message))}},P=(0,t.useMemo)(()=>{if(!(null==A?void 0:A.data)||!(null==b?void 0:b.data)||!N)return{};let e={};return N.forEach(s=>{e[s.collectionName]||(e[s.collectionName]={}),b.data.forEach(l=>{e[s.collectionName][l.id]={create:null,read:null,update:null,delete:null}})}),A.data.forEach(s=>{e[s.collection]&&e[s.collection][s.role_Id]&&(e[s.collection][s.role_Id][s.action]=s)}),e},[A,b,N]),E=(null==b?void 0:b.data)||[],F=N||[],O=(0,t.useMemo)(()=>{if(!F)return[];let e=Object.keys(P);return l&&"all"!==l&&(e=e.filter(e=>e.toLowerCase().includes(l.toLowerCase()))),e},[P,l,F]),D=(e,s,l)=>{h({collection:e,roleId:s,action:l}),f("create"),d(!0)},L=e=>{h(e),f("edit"),d(!0)},V=(e,s,l,t)=>{if(!e)return(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>D(s,l,t),children:(0,a.jsx)(J.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Grant Access"})]});let n=e.fields&&("string"==typeof e.fields?"*"!==e.fields:!(1===e.fields.length&&"*"===e.fields[0]))||e.conditions;return(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:(0,el.cn)("h-8 w-8",n?"text-yellow-600 hover:text-yellow-700":"text-green-600 hover:text-green-700"),onClick:()=>L(e),children:n?(0,a.jsx)(c.Z,{className:"h-4 w-4"}):(0,a.jsx)(Q.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:n?"Edit Specific Permissions":"Full Access Granted"})]})};return w||T?(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{children:[(0,a.jsx)(S.O,{className:"h-6 w-48"}),(0,a.jsx)(S.O,{className:"h-4 w-96 mt-2"})]}),(0,a.jsx)(C.aY,{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsx)(S.O,{className:"h-16 w-full"},s))})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsxs)(C.Zb,{className:"flex flex-col flex-1 overflow-hidden",children:[(0,a.jsxs)(C.Ol,{className:"flex flex-row items-center justify-between flex-wrap gap-2 flex-shrink-0",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(q.Z,{className:"h-5 w-5"}),"Permissions Management"]}),(0,a.jsx)(C.SZ,{children:"Manage access control for collections and actions"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)(X.Ph,{value:e,onValueChange:s,children:[(0,a.jsxs)(X.i4,{className:"w-[180px]",children:[(0,a.jsx)(Y.Z,{className:"h-4 w-4 mr-2"}),(0,a.jsx)(X.ki,{placeholder:"Filter by role"})]}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Roles"}),E.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)(X.Ph,{value:l,onValueChange:n,children:[(0,a.jsxs)(X.i4,{className:"w-[180px]",children:[(0,a.jsx)(K.Z,{className:"h-4 w-4 mr-2"}),(0,a.jsx)(X.ki,{placeholder:"Filter by collection"})]}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Collections"}),F.map(e=>{var s;return(0,a.jsx)(X.Ql,{value:e.collectionName,children:(null===(s=e.schema)||void 0===s?void 0:s.name)||e.collectionName},e.collectionName)})]})]}),(0,a.jsxs)(i.z,{variant:"outline",onClick:()=>u(!0),children:[(0,a.jsx)(W.Z,{className:"h-4 w-4 mr-2"}),"Import"]}),(0,a.jsxs)(i.z,{variant:"outline",onClick:()=>z(),disabled:Z,children:[Z?(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}):(0,a.jsx)(H.Z,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),(0,a.jsx)("div",{className:"sticky top-0 z-10 bg-background border-y px-4 py-2 flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"font-medium",children:"Role"}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:ev.map(e=>(0,a.jsx)("div",{className:"w-[80px] text-center text-sm text-muted-foreground font-medium capitalize",children:e},e))})]})}),(0,a.jsx)(C.aY,{className:"pt-0 flex-1 overflow-auto",children:(0,a.jsx)(ea,{type:"multiple",defaultValue:O,className:"w-full",children:O.map(s=>(0,a.jsxs)(et,{value:s,children:[(0,a.jsx)(en,{className:"hover:no-underline",children:(0,a.jsx)("span",{className:"font-medium",children:s})}),(0,a.jsx)(ei,{children:(0,a.jsx)($.iA,{children:(0,a.jsx)($.RM,{children:E.filter(s=>"all"===e||s.id===e).map(e=>(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.pj,{className:"font-medium",children:e.name}),(0,a.jsx)($.pj,{className:"text-right",children:(0,a.jsx)("div",{className:"flex items-center justify-end gap-2",children:ev.map(l=>{var t,n;let i=null===(n=P[s])||void 0===n?void 0:null===(t=n[e.id])||void 0===t?void 0:t[l];return(0,a.jsx)("div",{className:"w-[80px] flex justify-center",children:V(i,s,e.id,l)},l)})})})]},e.id))})})})]},s))})})]})}),(0,a.jsx)(em,{open:r,onClose:()=>{d(!1),h(null),k()},permissionId:"edit"===p?null==x?void 0:x.id:void 0,mode:p,defaultValues:"create"===p?{collection:null==x?void 0:x.collection,roleId:null==x?void 0:x.roleId,action:null==x?void 0:x.action}:void 0}),(0,a.jsx)(ej,{open:o,onClose:()=>{u(!1),_(),k()}})]})};var eg=l(99376),ey=l(89345),eN=l(48736),eb=l(98420),ew=l(78867),eC=l(12805),e_=l(69076),eS=l(90641);let eA={type:"",subject:"",body:"",tenant_Id:null,isActive:!0,description:""},eT=()=>{var e,s,l,o,u;let x=(0,eg.useRouter)(),[h,f]=(0,t.useState)("all"),[A,T]=(0,t.useState)("all"),[k,I]=(0,t.useState)("updatedAt"),[Z,z]=(0,t.useState)("desc"),[P,E]=(0,t.useState)(!1),[F,O]=(0,t.useState)(!1),[D,L]=(0,t.useState)(!1),[V,M]=(0,t.useState)(null),[R,B]=(0,t.useState)("create"),[U,J]=(0,t.useState)(eA),[Q,q]=(0,t.useState)(!1),[Y,K]=(0,t.useState)(!1),[W,H]=(0,t.useState)(null),G=(0,j.Ji)(),ee=(0,j.x5)(),{data:es}=(0,j.EV)({url:"".concat(G,"/templates/types"),method:"get"}),el=(null==es?void 0:null===(s=es.data)||void 0===s?void 0:null===(e=s.data)||void 0===e?void 0:e.types)||[],ea=(null==es?void 0:null===(o=es.data)||void 0===o?void 0:null===(l=o.data)||void 0===l?void 0:l.commonVariables)||[],{data:et,isLoading:en,refetch:ei}=(0,j.sm)({resource:"baasix_Template",meta:{fields:["*","tenant.id","tenant.name"]},pagination:{pageSize:-1},sorters:[{field:k,order:Z}]}),{data:er}=(0,j.sm)({resource:"baasix_Tenant",pagination:{pageSize:-1}}),{mutateAsync:ed}=(0,j.RO)(),{mutateAsync:eo}=(0,j.PQ)(),{mutateAsync:em}=(0,j.R2)(),ex=(null==et?void 0:et.data)||[],eh=(null==er?void 0:er.data)||[],ep=(0,t.useMemo)(()=>{let e=el.map(e=>({value:e.type,label:e.label})),s=ex.map(e=>e.type).filter(s=>!e.find(e=>e.value===s)).map(e=>({value:e,label:e}));return[...e,...s]},[el,ex]),ej=(0,t.useMemo)(()=>ex.filter(e=>{let s="all"===h||e.type===h,l="all"===A||"default"===A&&!e.tenant_Id||e.tenant_Id===A;return s&&l}),[ex,h,A]),ev=e=>ex.filter(s=>s.type===e).length,ef=e=>{let s=ep.find(s=>s.value===e);return(null==s?void 0:s.label)||e},eT=e=>{let s=el.find(s=>s.type===e);return(null==s?void 0:s.variables)||[]},ek=async e=>{H(e);try{var s;let l=ee();if(!l.custom)throw Error("Data provider does not support custom method");let a=await l.custom({url:"".concat(G,"/templates/default/").concat(e),method:"get"}),t=null==a?void 0:null===(s=a.data)||void 0===s?void 0:s.data;t?(J(e=>({...e,subject:t.subject||e.subject,body:t.body||e.body,description:t.description||e.description})),g.Am.success("Default template loaded")):g.Am.info("No default template available for this type")}catch(e){console.error("Load default template error:",e),g.Am.error("Failed to load default template")}finally{H(null)}};(0,t.useEffect)(()=>{"create"===R&&U.type&&!Y&&ek(U.type)},[U.type,R,Y]);let eI=e=>{J({type:e.type,subject:e.subject,body:e.body,tenant_Id:e.tenant_Id,isActive:e.isActive,description:e.description||""}),M(e),B("edit"),K(!1),E(!0)},eZ=e=>{x.push("/settings/templates/edit?id=".concat(e.id))},ez=e=>{M(e),O(!0)},eP=e=>{M(e),L(!0)},eE=async()=>{if(!U.type||!U.subject){g.Am.error("Please fill in type and subject");return}if("create"===R&&!U.body){g.Am.error("Please select a template type to load default content");return}q(!0);try{"create"===R?(await ed({resource:"baasix_Template",values:U}),g.Am.success("Template created successfully")):V&&(await eo({resource:"baasix_Template",id:V.id,values:U}),g.Am.success("Template updated successfully")),E(!1),ei()}catch(e){g.Am.error(e.message||"Failed to save template")}finally{q(!1)}},eF=async()=>{if(V)try{await em({resource:"baasix_Template",id:V.id}),g.Am.success("Template deleted successfully"),L(!1),ei()}catch(e){g.Am.error(e.message||"Failed to delete template")}},eO=e=>{J({type:e.type,subject:e.subject,body:e.body,tenant_Id:null,isActive:!0,description:e.description||""}),M(null),B("create"),K(!1),E(!0),g.Am.info("Template duplicated - modify and save as new")};return en?(0,a.jsxs)(C.Zb,{className:"h-full",children:[(0,a.jsx)(C.Ol,{children:(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(ey.Z,{className:"h-5 w-5"}),"Email Templates"]})}),(0,a.jsx)(C.aY,{children:(0,a.jsx)("div",{className:"space-y-3",children:[1,2,3,4,5].map(e=>(0,a.jsx)(S.O,{className:"h-12 w-full"},e))})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(C.Zb,{className:"h-full flex flex-col",children:[(0,a.jsx)(C.Ol,{className:"flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(ey.Z,{className:"h-5 w-5"}),"Email Templates"]}),(0,a.jsx)(C.SZ,{children:"Manage email templates for system notifications. Create tenant-specific overrides for customized branding."})]}),(0,a.jsxs)(i.z,{onClick:()=>{J(eA),M(null),B("create"),K(!1),E(!0)},children:[(0,a.jsx)(eu.Z,{className:"h-4 w-4 mr-2"}),"Add Template"]})]})}),(0,a.jsxs)(C.aY,{className:"flex-1 overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-4 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Type:"}),(0,a.jsxs)(X.Ph,{value:h,onValueChange:f,children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"All Types"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Types"}),ep.map(e=>(0,a.jsxs)(X.Ql,{value:e.value,children:[e.label," (",ev(e.value),")"]},e.value))]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Tenant:"}),(0,a.jsxs)(X.Ph,{value:A,onValueChange:T,children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"All Tenants"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Tenants"}),(0,a.jsx)(X.Ql,{value:"default",children:"Default (No Tenant)"}),eh.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Sort:"}),(0,a.jsxs)(X.Ph,{value:"".concat(k,":").concat(Z),onValueChange:e=>{let[s,l]=e.split(":");I(s),z(l)},children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"Sort by"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"updatedAt:desc",children:"Recently Updated"}),(0,a.jsx)(X.Ql,{value:"updatedAt:asc",children:"Oldest Updated"}),(0,a.jsx)(X.Ql,{value:"createdAt:desc",children:"Recently Created"}),(0,a.jsx)(X.Ql,{value:"createdAt:asc",children:"Oldest Created"}),(0,a.jsx)(X.Ql,{value:"type:asc",children:"Type (A-Z)"}),(0,a.jsx)(X.Ql,{value:"type:desc",children:"Type (Z-A)"})]})]})]})]}),(0,a.jsx)(eS.x,{className:"flex-1",children:(0,a.jsxs)($.iA,{children:[(0,a.jsx)($.xD,{children:(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.ss,{children:"Type"}),(0,a.jsx)($.ss,{children:"Subject"}),(0,a.jsx)($.ss,{children:"Tenant"}),(0,a.jsx)($.ss,{children:"Status"}),(0,a.jsx)($.ss,{children:"Updated"}),(0,a.jsx)($.ss,{className:"text-right",children:"Actions"})]})}),(0,a.jsx)($.RM,{children:0===ej.length?(0,a.jsx)($.SC,{children:(0,a.jsx)($.pj,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No templates found. Create one to get started."})}):ej.map(e=>(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.pj,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eN.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,a.jsx)("span",{className:"font-medium",children:ef(e.type)})]})}),(0,a.jsx)($.pj,{className:"max-w-[300px] truncate",children:e.subject}),(0,a.jsx)($.pj,{children:e.tenant?(0,a.jsxs)(n.C,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[(0,a.jsx)(eb.Z,{className:"h-3 w-3"}),e.tenant.name]}):(0,a.jsx)(n.C,{variant:"secondary",children:"Default"})}),(0,a.jsx)($.pj,{children:(0,a.jsx)(n.C,{variant:e.isActive?"default":"secondary",children:e.isActive?"Active":"Inactive"})}),(0,a.jsx)($.pj,{className:"text-muted-foreground text-sm",children:e.updatedAt?new Date(e.updatedAt).toLocaleDateString():"-"}),(0,a.jsx)($.pj,{className:"text-right",children:(0,a.jsx)(m.pn,{children:(0,a.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>ez(e),children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Preview"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eO(e),children:(0,a.jsx)(ew.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Duplicate"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eI(e),children:(0,a.jsx)(c.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Edit Details"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eZ(e),children:(0,a.jsx)(eC.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Design Template"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eP(e),className:"text-destructive hover:text-destructive",children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Delete"})]})]})})})]},e.id))})]})})]})]}),(0,a.jsx)(ec.yo,{open:P,onOpenChange:E,children:(0,a.jsxs)(ec.ue,{className:"w-full sm:max-w-[500px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{children:[(0,a.jsx)(ec.bC,{children:"create"===R?"Create Email Template":"Edit Email Template"}),(0,a.jsx)(ec.Ei,{children:"create"===R?"Create a new email template. Select a type to auto-load the default template.":"Edit template details. Use the Designer button to modify the email design."})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"type",children:"Template Type *"}),"edit"===R?(0,a.jsx)(y.I,{value:ef(U.type),disabled:!0,className:"bg-muted"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(X.Ph,{value:Y?"__custom__":U.type,onValueChange:e=>{"__custom__"===e?(J({...U,type:"",body:""}),K(!0)):(J({...U,type:e}),K(!1))},children:[(0,a.jsx)(X.i4,{children:(0,a.jsx)(X.ki,{placeholder:"Select type"})}),(0,a.jsxs)(X.Bw,{children:[el.map(e=>(0,a.jsx)(X.Ql,{value:e.type,children:e.label},e.type)),(0,a.jsx)(X.Ql,{value:"__custom__",children:"+ Custom Type..."})]})]}),Y&&(0,a.jsx)(y.I,{value:U.type,onChange:e=>J({...U,type:e.target.value}),placeholder:"Enter custom type name (e.g., orderConfirmation)",className:"mt-2",autoFocus:!0})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"tenant",children:"Tenant"}),(0,a.jsxs)(X.Ph,{value:U.tenant_Id||"default",onValueChange:e=>J({...U,tenant_Id:"default"===e?null:e}),children:[(0,a.jsx)(X.i4,{children:(0,a.jsx)(X.ki,{placeholder:"Select tenant"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"default",children:"Default (No Tenant)"}),eh.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"subject",children:"Subject Line *"}),(0,a.jsx)(y.I,{id:"subject",value:U.subject,onChange:e=>J({...U,subject:e.target.value}),placeholder:"Enter email subject (supports Liquid variables)"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"description",children:"Description"}),(0,a.jsx)(b.g,{id:"description",value:U.description,onChange:e=>J({...U,description:e.target.value}),placeholder:"Optional description of the template",rows:2})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(w.r,{id:"isActive",checked:U.isActive,onCheckedChange:e=>J({...U,isActive:e})}),(0,a.jsx)(N._,{htmlFor:"isActive",children:"Active"})]}),U.type&&(e=>{let s=Array.from(new Set([...eT(e),...ea]));return 0===s.length?null:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{className:"text-sm",children:"Available Variables (click to copy)"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map(e=>(0,a.jsx)(n.C,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 text-xs",onClick:()=>{navigator.clipboard.writeText("{{ ".concat(e," }}")),g.Am.success("Copied {{ ".concat(e," }}"))},children:"{{ "+e+" }}"},e))})]})})(U.type),"create"===R&&U.type&&!Y&&(0,a.jsx)("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md",children:W?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.Z,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{className:"text-sm",children:"Loading default template..."})]}):U.body?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Default template loaded. Use the Designer after creation to customize."}),(0,a.jsxs)(i.z,{type:"button",variant:"ghost",size:"sm",onClick:()=>ek(U.type),children:[(0,a.jsx)(e_.Z,{className:"h-3 w-3 mr-1"}),"Reload"]})]}):(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"No default template available for this type."})}),"edit"===R&&(0,a.jsx)("div",{className:"p-3 bg-muted rounded-md",children:(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["To edit the email design, save changes here first, then use the ",(0,a.jsx)(eC.Z,{className:"h-3 w-3 inline mx-1"})," Designer button from the list."]})})]}),(0,a.jsxs)(ec.FF,{className:"mt-6",children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>E(!1),children:"Cancel"}),(0,a.jsxs)(i.z,{onClick:eE,disabled:Q,children:[Q&&(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}),"create"===R?"Create Template":"Save Changes"]})]})]})}),(0,a.jsx)(p.Vq,{open:F,onOpenChange:O,children:(0,a.jsxs)(p.cZ,{className:"max-w-[800px] max-h-[90vh] overflow-y-auto",children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Template Preview"}),(0,a.jsxs)(p.Be,{children:[V&&ef(V.type),(null==V?void 0:V.tenant)&&" - ".concat(V.tenant.name)]})]}),V&&(0,a.jsxs)(_.mQ,{defaultValue:"rendered",className:"mt-4",children:[(0,a.jsxs)(_.dr,{children:[(0,a.jsx)(_.SP,{value:"rendered",children:"Rendered"}),(0,a.jsx)(_.SP,{value:"source",children:"Source"})]}),(0,a.jsx)(_.nU,{value:"rendered",className:"mt-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Subject:"}),(0,a.jsx)("p",{className:"font-medium",children:V.subject})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Body:"}),(0,a.jsx)("div",{className:"mt-2 border rounded-md p-4 prose prose-sm dark:prose-invert max-w-none bg-white dark:bg-gray-950",dangerouslySetInnerHTML:{__html:V.body}})]})]})}),(0,a.jsx)(_.nU,{value:"source",className:"mt-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Subject:"}),(0,a.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded text-sm overflow-x-auto",children:V.subject})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Body HTML:"}),(0,a.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded text-sm overflow-x-auto max-h-[400px]",children:V.body})]})]})})]})]})}),(0,a.jsx)(p.Vq,{open:D,onOpenChange:L,children:(0,a.jsxs)(p.cZ,{children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Delete Template"}),(0,a.jsx)(p.Be,{children:"Are you sure you want to delete this template? This action cannot be undone."})]}),V&&(0,a.jsxs)("div",{className:"py-4",children:[(0,a.jsxs)("p",{className:"text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:"Type:"})," ",ef(V.type)]}),(0,a.jsxs)("p",{className:"text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:"Tenant:"})," ",(null===(u=V.tenant)||void 0===u?void 0:u.name)||"Default"]})]}),(0,a.jsxs)(p.cN,{children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>L(!1),children:"Cancel"}),(0,a.jsx)(i.z,{variant:"destructive",onClick:eF,children:"Delete"})]})]})})]})}},69140:function(e,s,l){l.d(s,{O:function(){return n}});var a=l(57437),t=l(93448);function n(e){let{className:s,...l}=e;return(0,a.jsx)("div",{className:(0,t.cn)("animate-pulse rounded-md bg-muted",s),...l})}},81853:function(e,s,l){l.d(s,{Ml:function(){return r},PY:function(){return i}});var a=l(57437),t=l(2265);let n=(0,t.createContext)({projectSettings:null,isMultiTenant:!1,isLoading:!0,refetch:()=>{}}),i=()=>t.useContext(n)||(console.warn("useProject used outside of ProjectContextProvider, using defaults"),{projectSettings:null,isMultiTenant:!1,isLoading:!1,refetch:()=>{}}),r=e=>{let{children:s,baasixClient:l}=e,[i,r]=(0,t.useState)(null),[c,d]=(0,t.useState)(!0),o=(0,t.useCallback)(async()=>{try{d(!0);let e=await l.server.info();r(null==e?void 0:e.project)}catch(e){console.error("Failed to fetch project settings",e)}finally{d(!1)}},[l]);(0,t.useEffect)(()=>{o()},[o]);let m=(null==i?void 0:i.multitenant)===!0||(null==i?void 0:i.multitenant)==="true";return(0,a.jsx)(n.Provider,{value:{projectSettings:i,isMultiTenant:m,isLoading:c,refetch:o},children:s})}}}]);
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9599],{24225:function(e,s,l){l.d(s,{HD:function(){return ef},iL:function(){return U},kL:function(){return x},h2:function(){return eT},Xx:function(){return R}});var a=l(57437),t=l(2265),n=l(69174),i=l(12381),r=l(42208),c=l(45675),d=l(18930),o=l(72337),m=l(71488);let u=["administrator","public"],x=()=>(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsx)(o.DataBrowserInner,{selectedCollection:"baasix_Role",title:"Roles Management",enableSearch:!0,enableFilters:!0,enableCreate:!0,enableView:!0,enableEdit:!0,enableDelete:!0,enableExport:!0,enableImport:!0,enableBulkSelect:!0,enableColumnSettings:!0,defaultVisibleColumns:["name","description","isTenantSpecific"],customColumnRenderers:{name:e=>(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{className:"font-medium",children:e}),u.includes(null==e?void 0:e.toLowerCase())&&(0,a.jsx)(m.pn,{children:(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{children:(0,a.jsx)(n.C,{variant:"outline",className:"text-xs",children:"System"})}),(0,a.jsx)(m._v,{children:(0,a.jsx)("p",{children:"System role - name cannot be changed"})})]})})]}),isTenantSpecific:e=>(0,a.jsx)(n.C,{variant:e?"default":"secondary",children:e?"Yes":"No"})},renderRowActions:e=>{var s;let{record:l,onView:t,onEdit:n,onDelete:o}=e,x=u.includes(null===(s=l.name)||void 0===s?void 0:s.toLowerCase());return(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:t,children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})}),(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:n,children:(0,a.jsx)(c.Z,{className:"h-4 w-4"})}),(0,a.jsx)(m.pn,{children:(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)("span",{children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:o,disabled:x,children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})})})}),x&&(0,a.jsx)(m._v,{children:(0,a.jsx)("p",{children:"System roles cannot be deleted"})})]})})]})},getDisabledFields:e=>{var s;return u.includes(null==e?void 0:null===(s=e.name)||void 0===s?void 0:s.toLowerCase())?["name","isTenantSpecific"]:[]}})});var h=l(98728),p=l(74291),j=l(72135),v=l(51817),f=l(83229),g=l(14438),y=l(40279),N=l(75060),b=l(23675),w=l(94589),C=l(79820),_=l(17168),S=l(69140),A=l(5101),T=l(24065),k=l(54572);let I=[{name:"project_name",label:"Project Name",type:"String"},{name:"title",label:"Title",type:"String"},{name:"project_url",label:"API URL",type:"String"},{name:"app_url",label:"App URL",type:"String"},{name:"project_color",label:"Primary Color",type:"String",inputType:"color"},{name:"secondary_color",label:"Secondary Color",type:"String",inputType:"color"},{name:"description",label:"Description",type:"Text"},{name:"keywords",label:"Keywords",type:"String"}],Z=[{name:"project_logo_light",label:"Logo (Light)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_light_Id"},{name:"project_logo_dark",label:"Logo (Dark)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_dark_Id"},{name:"project_logo_full",label:"Logo (Full)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_full_Id"},{name:"project_logo_transparent",label:"Logo (Transparent)",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_logo_transparent_Id"},{name:"project_favicon",label:"Favicon",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_favicon_Id"},{name:"project_icon",label:"Project Icon",relType:"BelongsTo",target:"baasix_File",foreignKey:"project_icon_Id"},{name:"email_icon",label:"Email Icon",relType:"BelongsTo",target:"baasix_File",foreignKey:"email_icon_Id"}],z=[{name:"email_signature",label:"Email Signature",type:"Text"},{name:"from_email_name",label:"From Email Name",type:"String"}],E=[{name:"smtp_enabled",label:"Enable SMTP",type:"Boolean"},{name:"smtp_host",label:"SMTP Host",type:"String"},{name:"smtp_port",label:"SMTP Port",type:"Integer"},{name:"smtp_secure",label:"SMTP Secure",type:"Boolean"},{name:"smtp_user",label:"SMTP Username",type:"String"},{name:"smtp_pass",label:"SMTP Password",type:"String",inputType:"password"},{name:"smtp_from_address",label:"SMTP From Address",type:"String"}],P=[{name:"timezone",label:"Timezone",type:"String"},{name:"language",label:"Language",type:"String"},{name:"date_format",label:"Date Format",type:"String"},{name:"currency",label:"Currency",type:"String"}],F=[{name:"mobile_session_limit",label:"Mobile Session Limit",type:"Integer",description:"-1 for unlimited, 0 to disable"},{name:"web_session_limit",label:"Web Session Limit",type:"Integer",description:"-1 for unlimited, 0 to disable"},{name:"session_limit_roles",label:"Session Limit Roles",type:"JSON",description:"Array of role IDs to apply session limits"}],O=[{name:"metadata",label:"Metadata",type:"JSON"},{name:"modules",label:"Modules",type:"JSON"}],L=e=>{var s;let{tenantId:l,title:n="Settings",description:r="Configure settings",onSaveSuccess:c,compact:d=!1}=e,[o,m]=(0,t.useState)(!1),[u,x]=(0,t.useState)({}),[h,p]=(0,t.useState)({}),[L,D]=(0,t.useState)(!1),[M,V]=(0,t.useState)(null),[R,B]=(0,t.useState)(null),[U,J]=(0,t.useState)(!1),{data:Q,isLoading:q,refetch:Y}=(0,j.sm)({resource:"baasix_Settings",filters:[{field:"tenant_Id",operator:"eq",value:l}],pagination:{current:1,pageSize:1},meta:{fields:["*","project_logo_light.*","project_logo_dark.*","project_logo_full.*","project_logo_transparent.*","project_favicon.*","project_icon.*","email_icon.*"]},queryOptions:{enabled:!!l}}),{data:K,isLoading:H,refetch:W}=(0,j.rD)({resource:"baasix_Settings",id:"1",meta:{fields:["*","project_logo_light.*","project_logo_dark.*","project_logo_full.*","project_logo_transparent.*","project_favicon.*","project_icon.*","email_icon.*"]},queryOptions:{enabled:!l}}),$=l?q:H,X=l?(null==Q?void 0:null===(s=Q.data)||void 0===s?void 0:s[0])||null:null==K?void 0:K.data,G=l?Y:W,{mutate:ee}=(0,j.PQ)(),{mutate:es}=(0,j.RO)();(0,t.useEffect)(()=>{var e,s,a;if(l&&!q){let l=null==Q?void 0:null===(e=Q.data)||void 0===e?void 0:e[0];if(l){x(l),B((null===(s=l.id)||void 0===s?void 0:s.toString())||null),J(!1);let e={};Z.forEach(s=>{l[s.name]&&(e[s.name]=l[s.name])}),p(e)}else x({}),B(null),J(!0),p({})}else if(!l&&X){x(X),B((null===(a=X.id)||void 0===a?void 0:a.toString())||null),J(!1);let e={};Z.forEach(s=>{X[s.name]&&(e[s.name]=X[s.name])}),p(e)}},[l,q,Q,X]);let el=()=>{let e={...u};return Z.forEach(s=>{let l=h[s.name];if(l){let a="string"==typeof l?l:l.id;e[s.foreignKey]=a}else e[s.foreignKey]=null;delete e[s.name]}),delete e.id,delete e.createdAt,delete e.updatedAt,delete e.userCreated,delete e.userUpdated,delete e.userCreated_Id,delete e.userUpdated_Id,delete e.tenant,l&&(e.tenant_Id=l),e},ea=async()=>{m(!0);try{let e=el();if(U)es({resource:"baasix_Settings",values:e},{onSuccess:()=>{g.Am.success("Tenant settings created successfully"),J(!1),G(),null==c||c()},onError:e=>{g.Am.error((null==e?void 0:e.message)||"Failed to create settings")}});else{let s=l?R:"1";if(!s){g.Am.error("No settings found to update");return}ee({resource:"baasix_Settings",id:s,values:e},{onSuccess:()=>{g.Am.success("Settings saved successfully"),G(),null==c||c()},onError:e=>{g.Am.error((null==e?void 0:e.message)||"Failed to save settings")}})}}catch(e){g.Am.error((null==e?void 0:e.message)||"Failed to save settings")}finally{m(!1)}},et=(e,s)=>{x(l=>({...l,[e]:s}))},en=(0,t.useCallback)((e,s)=>{let l=s?"string"==typeof s?{id:s}:s:null;p(s=>({...s,[e.name]:l}))},[]),ei=(0,t.useCallback)(e=>{p(s=>{let l={...s};return delete l[e.name],l})},[]),er=e=>{V(e),D(!0)},ec=e=>{let s=u[e.name];return e.relType?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:e.label}),(0,a.jsx)(A.q,{value:h[e.name],field:e,onClick:()=>er(e),onRemove:()=>ei(e)})]},e.name):"Boolean"===e.type?(0,a.jsxs)("div",{className:"flex items-center justify-between py-2",children:[(0,a.jsxs)("div",{className:"space-y-0.5",children:[(0,a.jsx)(N._,{children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description})]}),(0,a.jsx)(w.r,{checked:s||!1,onCheckedChange:s=>et(e.name,s)})]},e.name):"JSON"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(k.mq,{value:s,onChange:s=>et(e.name,s)})]},e.name):"Text"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(b.g,{id:e.name,value:s||"",onChange:s=>et(e.name,s.target.value),rows:3})]},e.name):"Integer"===e.type?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(y.I,{id:e.name,type:"number",value:null!=s?s:"",onChange:s=>et(e.name,s.target.value?parseInt(s.target.value):null)})]},e.name):"color"===e.inputType?(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),(0,a.jsxs)("div",{className:"flex gap-2",children:[(0,a.jsx)(y.I,{id:e.name,type:"color",value:s||"#000000",onChange:s=>et(e.name,s.target.value),className:"w-12 h-10 p-1 cursor-pointer"}),(0,a.jsx)(y.I,{value:s||"",onChange:s=>et(e.name,s.target.value),placeholder:"#000000",className:"flex-1"})]})]},e.name):(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:e.name,children:e.label}),e.description&&(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:e.description}),(0,a.jsx)(y.I,{id:e.name,type:e.inputType||"text",value:s||"",onChange:s=>et(e.name,s.target.value)})]},e.name)},ed=()=>(0,a.jsxs)(_.mQ,{defaultValue:"branding",className:"space-y-4",children:[(0,a.jsxs)(_.dr,{className:"flex-wrap h-auto gap-1",children:[(0,a.jsx)(_.SP,{value:"branding",children:"Branding"}),(0,a.jsx)(_.SP,{value:"logos",children:"Logos & Icons"}),(0,a.jsx)(_.SP,{value:"email",children:"Email"}),(0,a.jsx)(_.SP,{value:"smtp",children:"SMTP"}),(0,a.jsx)(_.SP,{value:"localization",children:"Localization"}),(0,a.jsx)(_.SP,{value:"sessions",children:"Sessions"}),(0,a.jsx)(_.SP,{value:"advanced",children:"Advanced"})]}),(0,a.jsxs)(_.nU,{value:"branding",className:"space-y-4",children:[(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:I.slice(0,4).map(ec)}),(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:I.slice(4,6).map(ec)}),I.slice(6).map(ec)]}),(0,a.jsx)(_.nU,{value:"logos",className:"space-y-4",children:(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:Z.map(ec)})}),(0,a.jsx)(_.nU,{value:"email",className:"space-y-4",children:z.map(ec)}),(0,a.jsxs)(_.nU,{value:"smtp",className:"space-y-4",children:[E.filter(e=>"Boolean"===e.type).map(ec),u.smtp_enabled&&(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2 pt-4 border-t",children:E.filter(e=>"Boolean"!==e.type).map(ec)})]}),(0,a.jsx)(_.nU,{value:"localization",className:"space-y-4",children:(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:P.map(ec)})}),(0,a.jsxs)(_.nU,{value:"sessions",className:"space-y-4",children:[(0,a.jsx)("div",{className:"grid gap-4 md:grid-cols-2",children:F.filter(e=>"Integer"===e.type).map(ec)}),F.filter(e=>"JSON"===e.type).map(ec)]}),(0,a.jsx)(_.nU,{value:"advanced",className:"space-y-4",children:O.map(ec)})]});if($)return d?(0,a.jsx)("div",{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(S.O,{className:"h-4 w-24"}),(0,a.jsx)(S.O,{className:"h-10 w-full"})]},s))}):(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{children:[(0,a.jsx)(S.O,{className:"h-6 w-48"}),(0,a.jsx)(S.O,{className:"h-4 w-96 mt-2"})]}),(0,a.jsx)(C.aY,{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(S.O,{className:"h-4 w-24"}),(0,a.jsx)(S.O,{className:"h-10 w-full"})]},s))})]});let eo=(0,a.jsxs)(i.z,{onClick:ea,disabled:o,children:[o?(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}):(0,a.jsx)(f.Z,{className:"h-4 w-4 mr-2"}),U?"Create Settings":"Save Changes"]});return d?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"space-y-4",children:[ed(),(0,a.jsx)("div",{className:"flex justify-end pt-4 border-t",children:eo})]}),M&&(0,a.jsx)(T.x,{open:L,onClose:()=>{D(!1),setTimeout(()=>V(null),100)},onSelect:e=>en(M,e),target:M.target,field:M,selectedItems:h[M.name]?[h[M.name]]:[]})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{className:"flex flex-row items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(C.ll,{children:n}),(0,a.jsx)(C.SZ,{children:r})]}),eo]}),(0,a.jsx)(C.aY,{children:ed()})]}),M&&(0,a.jsx)(T.x,{open:L,onClose:()=>{D(!1),setTimeout(()=>V(null),100)},onSelect:e=>en(M,e),target:M.target,field:M,selectedItems:h[M.name]?[h[M.name]]:[]})]})},D=e=>{let{open:s,onClose:l,tenantId:t,tenantName:n}=e;return(0,a.jsx)(p.Vq,{open:s,onOpenChange:e=>!e&&l(),children:(0,a.jsxs)(p.cZ,{className:"max-w-4xl h-[90vh] flex flex-col p-0 gap-0",children:[(0,a.jsxs)(p.fK,{className:"flex-shrink-0 px-6 pt-6 pb-4",children:[(0,a.jsxs)(p.$N,{children:["Settings for ",n||"Tenant ".concat(t)]}),(0,a.jsx)(p.Be,{children:"Configure tenant-specific settings. These will override global project settings for this tenant."})]}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-6 pb-6",children:(0,a.jsx)(L,{tenantId:t,compact:!0,onSaveSuccess:()=>{l()}})})]})})};var M=l(71096),V=l.n(M);let R=()=>{let[e,s]=(0,t.useState)(!1),[l,r]=(0,t.useState)(null),c=e=>{r({id:e.id,name:e.name}),s(!0)};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsx)(o.DataBrowserInner,{selectedCollection:"baasix_Tenant",title:"Tenants Management",enableSearch:!0,enableFilters:!0,enableCreate:!0,enableView:!0,enableEdit:!0,enableDelete:!0,enableExport:!0,enableImport:!0,enableBulkSelect:!0,enableColumnSettings:!0,defaultVisibleColumns:["name","status","createdAt"],customColumnRenderers:{name:e=>(0,a.jsx)("span",{className:"font-medium",children:e}),status:e=>(0,a.jsx)(n.C,{variant:"active"===e?"default":"secondary",children:e||"Active"}),createdAt:e=>(0,a.jsx)("span",{className:"text-muted-foreground",children:e?V()(e).format("MMM D, YYYY HH:mm"):"-"})},renderRowActions:e=>{let{record:s,onView:l,onEdit:t,onDelete:n}=e;return(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>c(s),title:"Tenant Settings",children:(0,a.jsx)(h.Z,{className:"h-4 w-4"})}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:l,title:"View",children:[(0,a.jsx)("span",{className:"sr-only",children:"View"}),(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M2 12s3-7 10-7 10 7 10 7-3 7-10 7-10-7-10-7Z"}),(0,a.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})]}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:t,title:"Edit",children:[(0,a.jsx)("span",{className:"sr-only",children:"Edit"}),(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"})})]}),(0,a.jsxs)(i.z,{variant:"ghost",size:"icon",onClick:n,title:"Delete",className:"text-destructive hover:text-destructive",children:[(0,a.jsx)("span",{className:"sr-only",children:"Delete"}),(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M3 6h18"}),(0,a.jsx)("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),(0,a.jsx)("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]})]})]})}})}),l&&(0,a.jsx)(D,{open:e,onClose:()=>{s(!1),r(null)},tenantId:l.id,tenantName:l.name})]})};var B=l(81853);let U=()=>{let{refetch:e}=(0,B.PY)();return(0,a.jsx)(L,{title:"Project Settings",description:"Configure your project branding, email, and other settings",onSaveSuccess:e})};var J=l(32489),Q=l(30401),q=l(88906),Y=l(95805),K=l(50091),H=l(17689),W=l(92735),$=l(33804),X=l(15291),G=l(29696),ee=l(47307),es=l(40875),el=l(93448);let ea=ee.fC,et=t.forwardRef((e,s)=>{let{className:l,...t}=e;return(0,a.jsx)(ee.ck,{ref:s,className:(0,el.cn)("border-b",l),...t})});et.displayName="AccordionItem";let en=t.forwardRef((e,s)=>{let{className:l,children:t,...n}=e;return(0,a.jsx)(ee.h4,{className:"flex",children:(0,a.jsxs)(ee.xz,{ref:s,className:(0,el.cn)("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",l),...n,children:[t,(0,a.jsx)(es.Z,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})})});en.displayName=ee.xz.displayName;let ei=t.forwardRef((e,s)=>{let{className:l,children:t,...n}=e;return(0,a.jsx)(ee.VY,{ref:s,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...n,children:(0,a.jsx)("div",{className:(0,el.cn)("pb-4 pt-0",l),children:t})})});ei.displayName=ee.VY.displayName;var er=l(10407),ec=l(91032),ed=l(68245);let eo=e=>{let{nodes:s,selectedFields:l,onSelectionChange:t,level:n=0,expandedNodes:i,onToggleExpand:r}=e,c=e=>{l.includes(e.value)?t(l.filter(s=>s!==e.value)):t([...l,e.value])},d=e=>{if(e.value.endsWith(".*")&&e.children&&e.children.length>0){let s=e.value.split("."),l=s[s.length-2]||s[0];return"".concat(l,".*")}if(e.value.startsWith("*"))return e.value;let s=e.title.split(".");return s[s.length-1]},o=e=>"*"===e?"all fields":"*.*"===e?"all + 1 level relations":"*.*.*"===e?"all + 2 level relations":"*.*.*.*"===e?"all + 3 level relations":null,m=s.filter(e=>!!e.value.startsWith("*")||!e.value.endsWith(".*")||!!e.children&&0!==e.children.length);return(0,a.jsx)("div",{className:(0,el.cn)("space-y-0.5",n>0&&"ml-4 pl-2 border-l border-muted"),children:m.map(e=>{let s=e.children&&e.children.length>0,m=i.has(e.key),u=l.includes(e.value),x=o(e.value);return(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[s?(0,a.jsx)("button",{type:"button",onClick:()=>r(e.key),className:"p-0.5 hover:bg-muted rounded",children:m?(0,a.jsx)(es.Z,{className:"h-3.5 w-3.5"}):(0,a.jsx)(er.Z,{className:"h-3.5 w-3.5"})}):(0,a.jsx)("span",{className:"w-4"}),(0,a.jsx)(ed.X,{id:"field-".concat(e.key),checked:u,onCheckedChange:()=>c(e)}),(0,a.jsxs)(N._,{htmlFor:"field-".concat(e.key),className:(0,el.cn)("text-sm cursor-pointer flex-1",x&&"font-mono"),children:[d(e),x&&(0,a.jsxs)("span",{className:"text-xs text-muted-foreground ml-2",children:["(",x,")"]}),s&&!x&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),s&&m&&(0,a.jsx)(eo,{nodes:e.children,selectedFields:l,onSelectionChange:t,level:n+1,expandedNodes:i,onToggleExpand:r})]},e.key)})})},em=e=>{let{open:s,onClose:l,permissionId:r,mode:c,defaultValues:o}=e,[m,u]=(0,t.useState)({collection:"",role_Id:"",action:"",fields:["*"],conditions:null,relConditions:null,defaultValues:null}),[x,h]=(0,t.useState)({}),[f,y]=(0,t.useState)(!1),[b,w]=(0,t.useState)(!1),[S,A]=(0,t.useState)("tree"),{schemas:T,getPermissionFields:I}=(0,G.I_)(),{data:Z,isLoading:z}=(0,j.rD)({resource:"permissions",id:r||"",queryOptions:{enabled:s&&"edit"===c&&!!r}}),{data:E}=(0,j.sm)({resource:"baasix_Role",pagination:{pageSize:-1}}),{mutate:P}=(0,j.RO)(),{mutate:F}=(0,j.PQ)(),{mutate:O}=(0,j.R2)(),L=(0,t.useMemo)(()=>T||[],[T]),D=(0,t.useMemo)(()=>(null==E?void 0:E.data)||[],[E]),M=(0,t.useMemo)(()=>m.collection&&I?I(m.collection):[],[m.collection,I]);(0,t.useEffect)(()=>{if("edit"===c&&(null==Z?void 0:Z.data)){var e;let s=Z.data,l=["*"];Array.isArray(s.fields)?l=s.fields:"string"==typeof s.fields&&(l=s.fields.split(",").map(e=>e.trim())),u({collection:s.collection||"",role_Id:s.role_Id||(null===(e=s.role)||void 0===e?void 0:e.id)||"",action:s.action||"",fields:l,conditions:s.conditions||null,relConditions:s.relConditions||null,defaultValues:s.defaultValues||null})}else"create"===c&&o&&u({collection:o.collection||"",role_Id:o.roleId||"",action:o.action||"",fields:["*"],conditions:null,relConditions:null,defaultValues:null})},[c,Z,o,s]);let V=()=>{u({collection:"",role_Id:"",action:"",fields:["*"],conditions:null,relConditions:null,defaultValues:null}),h({}),A("tree"),l()},R=()=>{r&&O({resource:"permissions",id:r},{onSuccess:()=>{g.Am.success("Permission deleted successfully"),V()},onError:e=>{g.Am.error("Error deleting permission: ".concat(e.message))}})},B=async e=>{e.preventDefault();let s={};if(m.collection||(s.collection="Collection is required"),m.role_Id||(s.role_Id="Role is required"),m.action||(s.action="Action is required"),Object.keys(s).length>0){h(s);return}y(!0);try{let e={collection:m.collection,role_Id:m.role_Id,action:m.action,fields:m.fields.length>0?m.fields:["*"],conditions:m.conditions||null,relConditions:m.relConditions||null,defaultValues:m.defaultValues||null};"create"===c?P({resource:"permissions",values:e},{onSuccess:()=>{g.Am.success("Permission created successfully"),V()},onError:e=>{g.Am.error("Error creating permission: ".concat(e.message))}}):F({resource:"permissions",id:r,values:e},{onSuccess:()=>{g.Am.success("Permission updated successfully"),V()},onError:e=>{g.Am.error("Error updating permission: ".concat(e.message))}})}catch(e){g.Am.error("Error: ".concat(e.message))}finally{y(!1)}},U=e=>{let s=D.find(s=>s.id===e);return(null==s?void 0:s.name)||e},J=e=>{var s;let l=L.find(s=>s.collectionName===e);return(null==l?void 0:null===(s=l.schema)||void 0===s?void 0:s.name)||e},[Q,q]=(0,t.useState)(new Set),Y="edit"===c&&z,K=(0,t.useMemo)(()=>{if("create"===c&&o){let e=o.action?o.action.charAt(0).toUpperCase()+o.action.slice(1):"",s=o.collection?J(o.collection):"",l=o.roleId?U(o.roleId):"";if(e&&s&&l)return"Create ".concat(e," Permission")}else if("edit"===c&&m.action){let e=m.action.charAt(0).toUpperCase()+m.action.slice(1);return"Edit ".concat(e," Permission")}return"create"===c?"Create Permission":"Edit Permission"},[c,o,m.action,D,L]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ec.yo,{open:s,onOpenChange:e=>!e&&V(),children:(0,a.jsxs)(ec.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{className:"flex flex-row items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(ec.bC,{children:K}),(o||m.collection)&&(0,a.jsxs)("div",{className:"flex flex-wrap gap-2 mt-2",children:[((null==o?void 0:o.collection)||m.collection)&&(0,a.jsx)(n.C,{variant:"outline",children:J((null==o?void 0:o.collection)||m.collection)}),((null==o?void 0:o.roleId)||m.role_Id)&&(0,a.jsx)(n.C,{variant:"secondary",children:U((null==o?void 0:o.roleId)||m.role_Id)}),((null==o?void 0:o.action)||m.action)&&(0,a.jsx)(n.C,{children:((null==o?void 0:o.action)||m.action).charAt(0).toUpperCase()+((null==o?void 0:o.action)||m.action).slice(1)})]})]}),"edit"===c&&(0,a.jsxs)(i.z,{variant:"ghost",size:"sm",className:"text-destructive",onClick:()=>w(!0),children:[(0,a.jsx)(d.Z,{className:"h-4 w-4 mr-1"}),"Delete"]})]}),Y?(0,a.jsx)("div",{className:"flex items-center justify-center p-8",children:(0,a.jsx)(v.Z,{className:"h-6 w-6 animate-spin"})}):(0,a.jsxs)("form",{onSubmit:B,className:"mt-6 space-y-4",children:["delete"!==m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{children:"Fields"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select fields to allow. Leave empty or select * to allow all fields."}),(0,a.jsxs)(_.mQ,{value:S,onValueChange:e=>A(e),children:[(0,a.jsxs)(_.dr,{className:"grid w-full grid-cols-2",children:[(0,a.jsx)(_.SP,{value:"tree",children:"Tree Selection"}),(0,a.jsx)(_.SP,{value:"json",children:"JSON"})]}),(0,a.jsx)(_.nU,{value:"tree",className:"mt-2",children:(0,a.jsx)(C.Zb,{className:"max-h-[250px] overflow-y-auto",children:(0,a.jsx)(C.aY,{className:"p-3",children:M.length>0?(0,a.jsx)(eo,{nodes:M,selectedFields:m.fields,onSelectionChange:e=>{let s=e.length>0?e:["*"];u({...m,fields:s})},expandedNodes:Q,onToggleExpand:e=>{q(s=>{let l=new Set(s);return l.has(e)?l.delete(e):l.add(e),l})}}):(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"Select a collection to see available fields"})})})}),(0,a.jsxs)(_.nU,{value:"json",className:"mt-2",children:[(0,a.jsx)(k.mq,{value:m.fields,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?(u({...m,fields:e.length>0?e:["*"]}),h({...x,fieldsJson:""})):null===e&&(u({...m,fields:["*"]}),h({...x,fieldsJson:""}))},placeholder:'["*"]'}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:'Enter field names as a JSON array. Example: ["id", "name", "user.*"]'})]})]})]}),"create"!==m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"conditions",children:"Conditions"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter conditions in JSON format"}),(0,a.jsx)(k.mq,{value:m.conditions,onChange:e=>u({...m,conditions:e}),placeholder:'{"field": "value"}'})]}),"read"===m.action&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"relConditions",children:"Relational Conditions (HasMany)"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter conditions in JSON format"}),(0,a.jsx)(k.mq,{value:m.relConditions,onChange:e=>u({...m,relConditions:e}),placeholder:'{"relation": {"field": "value"}}'})]}),("create"===m.action||"update"===m.action)&&(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"defaultValues",children:"Default Values"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:"Enter default values in JSON format"}),(0,a.jsx)(k.mq,{value:m.defaultValues,onChange:e=>u({...m,defaultValues:e}),placeholder:'{"field": "defaultValue"}'})]}),(0,a.jsxs)("div",{className:"flex gap-2 pt-4",children:[(0,a.jsxs)(i.z,{type:"submit",disabled:f,children:[f&&(0,a.jsx)(v.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"create"===c?"Create":"Update"]}),(0,a.jsx)(i.z,{type:"button",variant:"outline",onClick:V,children:"Cancel"})]})]})]})}),(0,a.jsx)(p.Vq,{open:b,onOpenChange:w,children:(0,a.jsxs)(p.cZ,{children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Delete Permission"}),(0,a.jsx)(p.Be,{children:"Are you sure you want to delete this permission? This action cannot be undone."})]}),(0,a.jsxs)(p.cN,{children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>w(!1),children:"Cancel"}),(0,a.jsx)(i.z,{variant:"destructive",onClick:()=>{w(!1),R()},children:"Delete"})]})]})})]})};var eu=l(99397),ex=l(76865),eh=l(17342),ep=l(95937);let ej=e=>{var s,l,r,c,o,m,u,x,h,p,f,y;let{open:N,onClose:b}=e,[w,C]=(0,t.useState)(null),[_,S]=(0,t.useState)(null),[A,T]=(0,t.useState)(!1),k=(0,t.useRef)(null),I=(0,j.Ji)(),{mutate:Z,isLoading:z}=(0,j.uC)(),{mutate:E,isLoading:P}=(0,j.uC)(),F=async e=>{if(!e||!e.name.endsWith(".json")){g.Am.error("Please select a valid JSON file");return}C(e);let s=new FormData;s.append("rolesPermissions",e),Z({url:"".concat(I,"/permissions-preview-import"),method:"post",values:s},{onSuccess:e=>{S(null==e?void 0:e.data)},onError:e=>{g.Am.error("Error analyzing file: ".concat(e.message)),S(null)}})},O=async()=>{if(!w)return;let e=new FormData;e.append("rolesPermissions",w),E({url:"".concat(I,"/permissions-import"),method:"post",values:e},{onSuccess:()=>{g.Am.success("Permissions imported successfully"),L()},onError:e=>{g.Am.error("Error importing permissions: ".concat(e.message))}})},L=()=>{C(null),S(null),b()},D=e=>{if(!e)return null;let{added:s,modified:l,removed:t}=e;return(0,a.jsxs)("div",{className:"ml-6 mt-2 space-y-2 text-xs",children:[(null==s?void 0:s.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-green-600 font-medium",children:"Added permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map((e,s)=>{let[l,t]=e.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-green-600 border-green-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]}),(null==l?void 0:l.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-yellow-600 font-medium",children:"Modified permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:l.map((e,s)=>{let[l,t]=e.permission.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-yellow-600 border-yellow-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]}),(null==t?void 0:t.length)>0&&(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsx)("span",{className:"text-red-600 font-medium",children:"Removed permissions:"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:t.map((e,s)=>{let[l,t]=e.split(":");return(0,a.jsxs)(n.C,{variant:"outline",className:"text-red-600 border-red-600",children:[l," ",(0,a.jsxs)("span",{className:"ml-1 opacity-70",children:["(",t,")"]})]},s)})})]})]})},M=(e,s)=>{if(!e||0===e.length)return(0,a.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"No items"});let l=()=>{switch(s){case"new":return(0,a.jsx)(eu.Z,{className:"h-4 w-4 text-green-600"});case"modified":return(0,a.jsx)(ex.Z,{className:"h-4 w-4 text-yellow-600"});case"deleted":return(0,a.jsx)(d.Z,{className:"h-4 w-4 text-red-600"});case"unchanged":return(0,a.jsx)(Q.Z,{className:"h-4 w-4 text-green-600"})}};return(0,a.jsx)("ul",{className:"space-y-2",children:e.map((e,s)=>{var t,i,r,c,d;return(0,a.jsxs)("li",{className:"flex flex-col py-2 border-b last:border-0",children:[(0,a.jsxs)("div",{className:"flex items-start gap-2",children:[l(),(0,a.jsxs)("div",{className:"flex-1",children:[(0,a.jsx)("span",{className:"text-sm font-medium",children:"string"==typeof e?e:e.name}),(null===(t=e.differences)||void 0===t?void 0:t.permissions)&&(0,a.jsxs)("div",{className:"flex gap-1 mt-1 flex-wrap",children:[(null===(i=e.differences.permissions.added)||void 0===i?void 0:i.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-green-600 border-green-600 text-xs",children:["+",e.differences.permissions.added.length," added"]}),(null===(r=e.differences.permissions.modified)||void 0===r?void 0:r.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-yellow-600 border-yellow-600 text-xs",children:["~",e.differences.permissions.modified.length," modified"]}),(null===(c=e.differences.permissions.removed)||void 0===c?void 0:c.length)>0&&(0,a.jsxs)(n.C,{variant:"outline",className:"text-red-600 border-red-600 text-xs",children:["-",e.differences.permissions.removed.length," removed"]})]})]})]}),(null===(d=e.differences)||void 0===d?void 0:d.permissions)&&D(e.differences.permissions)]},s)})})};return(0,a.jsx)(ec.yo,{open:N,onOpenChange:e=>!e&&L(),children:(0,a.jsxs)(ec.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{className:"flex flex-row items-center justify-between",children:[(0,a.jsx)(ec.bC,{children:"Import Permissions"}),_&&(0,a.jsxs)(i.z,{onClick:O,disabled:P,children:[P&&(0,a.jsx)(v.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Confirm Import"]})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-8 text-center transition-colors ".concat(A?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"),onDragOver:e=>{e.preventDefault(),T(!0)},onDragLeave:e=>{e.preventDefault(),T(!1)},onDrop:e=>{e.preventDefault(),T(!1);let s=e.dataTransfer.files[0];s&&F(s)},onClick:()=>{var e;return null===(e=k.current)||void 0===e?void 0:e.click()},children:[(0,a.jsx)("input",{ref:k,type:"file",accept:".json",className:"hidden",onChange:e=>{var s;let l=null===(s=e.target.files)||void 0===s?void 0:s[0];l&&F(l)}}),(0,a.jsx)(H.Z,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),(0,a.jsx)("p",{className:"text-sm font-medium",children:"Click or drag permissions file to upload"}),(0,a.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Support for single JSON file upload only"}),w&&(0,a.jsxs)("div",{className:"mt-4 flex items-center justify-center gap-2 text-sm",children:[(0,a.jsx)(eh.Z,{className:"h-4 w-4"}),(0,a.jsx)("span",{children:w.name})]})]}),z&&(0,a.jsxs)("div",{className:"flex items-center justify-center py-8",children:[(0,a.jsx)(v.Z,{className:"h-6 w-6 animate-spin mr-2"}),(0,a.jsx)("span",{children:"Analyzing permission changes..."})]}),_&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)(ep.bZ,{children:[(0,a.jsx)(Q.Z,{className:"h-4 w-4"}),(0,a.jsx)(ep.Cd,{children:"Permissions Analysis Complete"}),(0,a.jsxs)(ep.X,{children:["Import version: ",_.importVersion," (",_.importTimestamp,")"]})]}),(0,a.jsxs)(ea,{type:"multiple",defaultValue:["new","modified","deleted","unchanged"],children:[(0,a.jsxs)(et,{value:"new",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eu.Z,{className:"h-4 w-4 text-green-600"}),"New Roles (",(null===(l=_.changes)||void 0===l?void 0:null===(s=l.new)||void 0===s?void 0:s.length)||0,")"]})}),(0,a.jsx)(ei,{children:M(null===(r=_.changes)||void 0===r?void 0:r.new,"new")})]}),(0,a.jsxs)(et,{value:"modified",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(ex.Z,{className:"h-4 w-4 text-yellow-600"}),"Modified Roles (",(null===(o=_.changes)||void 0===o?void 0:null===(c=o.modified)||void 0===c?void 0:c.length)||0,")"]})}),(0,a.jsx)(ei,{children:M(null===(m=_.changes)||void 0===m?void 0:m.modified,"modified")})]}),(0,a.jsxs)(et,{value:"deleted",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(d.Z,{className:"h-4 w-4 text-red-600"}),"Deleted Roles (",(null===(x=_.changes)||void 0===x?void 0:null===(u=x.deleted)||void 0===u?void 0:u.length)||0,")"]})}),(0,a.jsx)(ei,{children:M(null===(h=_.changes)||void 0===h?void 0:h.deleted,"deleted")})]}),(0,a.jsxs)(et,{value:"unchanged",children:[(0,a.jsx)(en,{children:(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(Q.Z,{className:"h-4 w-4 text-green-600"}),"Unchanged Roles (",(null===(f=_.changes)||void 0===f?void 0:null===(p=f.unchanged)||void 0===p?void 0:p.length)||0,")"]})}),(0,a.jsx)(ei,{children:M(null===(y=_.changes)||void 0===y?void 0:y.unchanged,"unchanged")})]})]})]})]})]})})},ev=["create","read","update","delete"],ef=()=>{let[e,s]=(0,t.useState)("all"),[l,n]=(0,t.useState)("all"),[r,d]=(0,t.useState)(!1),[o,u]=(0,t.useState)(!1),[x,h]=(0,t.useState)(null),[p,f]=(0,t.useState)("create"),y=(0,j.Ji)(),{schemas:N}=(0,G.I_)(),{data:b,isLoading:w,refetch:_}=(0,j.sm)({resource:"baasix_Role",filters:[{field:"name",operator:"ne",value:"administrator"}],pagination:{pageSize:-1}}),{data:A,isLoading:T,refetch:k}=(0,j.sm)({resource:"permissions",meta:{fields:["*","role.id","role.name"]},pagination:{pageSize:-1}}),{refetch:I,isFetching:Z}=(0,j.EV)({url:"".concat(y,"/permissions-export"),method:"get",queryOptions:{enabled:!1,retry:!1}}),z=async()=>{try{let e=await I(),s=null==e?void 0:e.data;if(!(null==s?void 0:s.data)||(null==s?void 0:s.data.length)===0){g.Am.error("No permissions found to export");return}let l=window.URL.createObjectURL(new Blob([JSON.stringify(null==s?void 0:s.data)])),a=document.createElement("a");a.href=l,a.setAttribute("download","roles-permissions-export-".concat(Date.now(),".json")),document.body.appendChild(a),a.click(),a.remove(),window.URL.revokeObjectURL(l),g.Am.success("Permissions exported successfully")}catch(e){g.Am.error("Error exporting permissions: ".concat(e.message))}},E=(0,t.useMemo)(()=>{if(!(null==A?void 0:A.data)||!(null==b?void 0:b.data)||!N)return{};let e={};return N.forEach(s=>{e[s.collectionName]||(e[s.collectionName]={}),b.data.forEach(l=>{e[s.collectionName][l.id]={create:null,read:null,update:null,delete:null}})}),A.data.forEach(s=>{e[s.collection]&&e[s.collection][s.role_Id]&&(e[s.collection][s.role_Id][s.action]=s)}),e},[A,b,N]),P=(null==b?void 0:b.data)||[],F=N||[],O=(0,t.useMemo)(()=>{if(!F)return[];let e=Object.keys(E);return l&&"all"!==l&&(e=e.filter(e=>e.toLowerCase().includes(l.toLowerCase()))),e},[E,l,F]),L=(e,s,l)=>{h({collection:e,roleId:s,action:l}),f("create"),d(!0)},D=e=>{h(e),f("edit"),d(!0)},M=(e,s,l,t)=>{if(!e)return(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive hover:text-destructive",onClick:()=>L(s,l,t),children:(0,a.jsx)(J.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Grant Access"})]});let n=e.fields&&("string"==typeof e.fields?"*"!==e.fields:!(1===e.fields.length&&"*"===e.fields[0]))||e.conditions;return(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",className:(0,el.cn)("h-8 w-8",n?"text-yellow-600 hover:text-yellow-700":"text-green-600 hover:text-green-700"),onClick:()=>D(e),children:n?(0,a.jsx)(c.Z,{className:"h-4 w-4"}):(0,a.jsx)(Q.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:n?"Edit Specific Permissions":"Full Access Granted"})]})};return w||T?(0,a.jsxs)(C.Zb,{children:[(0,a.jsxs)(C.Ol,{children:[(0,a.jsx)(S.O,{className:"h-6 w-48"}),(0,a.jsx)(S.O,{className:"h-4 w-96 mt-2"})]}),(0,a.jsx)(C.aY,{className:"space-y-4",children:Array.from({length:5}).map((e,s)=>(0,a.jsx)(S.O,{className:"h-16 w-full"},s))})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"flex flex-col h-full overflow-hidden",children:(0,a.jsxs)(C.Zb,{className:"flex flex-col flex-1 overflow-hidden",children:[(0,a.jsxs)(C.Ol,{className:"flex flex-row items-center justify-between flex-wrap gap-2 flex-shrink-0",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(q.Z,{className:"h-5 w-5"}),"Permissions Management"]}),(0,a.jsx)(C.SZ,{children:"Manage access control for collections and actions"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,a.jsxs)(X.Ph,{value:e,onValueChange:s,children:[(0,a.jsxs)(X.i4,{className:"w-[180px]",children:[(0,a.jsx)(Y.Z,{className:"h-4 w-4 mr-2"}),(0,a.jsx)(X.ki,{placeholder:"Filter by role"})]}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Roles"}),P.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]}),(0,a.jsxs)(X.Ph,{value:l,onValueChange:n,children:[(0,a.jsxs)(X.i4,{className:"w-[180px]",children:[(0,a.jsx)(K.Z,{className:"h-4 w-4 mr-2"}),(0,a.jsx)(X.ki,{placeholder:"Filter by collection"})]}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Collections"}),F.map(e=>{var s;return(0,a.jsx)(X.Ql,{value:e.collectionName,children:(null===(s=e.schema)||void 0===s?void 0:s.name)||e.collectionName},e.collectionName)})]})]}),(0,a.jsxs)(i.z,{variant:"outline",onClick:()=>u(!0),children:[(0,a.jsx)(H.Z,{className:"h-4 w-4 mr-2"}),"Import"]}),(0,a.jsxs)(i.z,{variant:"outline",onClick:()=>z(),disabled:Z,children:[Z?(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}):(0,a.jsx)(W.Z,{className:"h-4 w-4 mr-2"}),"Export"]})]})]}),(0,a.jsx)("div",{className:"sticky top-0 z-10 bg-background border-y px-4 py-2 flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsx)("span",{className:"font-medium",children:"Role"}),(0,a.jsx)("div",{className:"flex items-center gap-2",children:ev.map(e=>(0,a.jsx)("div",{className:"w-[80px] text-center text-sm text-muted-foreground font-medium capitalize",children:e},e))})]})}),(0,a.jsx)(C.aY,{className:"pt-0 flex-1 overflow-auto",children:(0,a.jsx)(ea,{type:"multiple",defaultValue:O,className:"w-full",children:O.map(s=>(0,a.jsxs)(et,{value:s,children:[(0,a.jsx)(en,{className:"hover:no-underline",children:(0,a.jsx)("span",{className:"font-medium",children:s})}),(0,a.jsx)(ei,{children:(0,a.jsx)($.iA,{children:(0,a.jsx)($.RM,{children:P.filter(s=>"all"===e||s.id===e).map(e=>(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.pj,{className:"font-medium",children:e.name}),(0,a.jsx)($.pj,{className:"text-right",children:(0,a.jsx)("div",{className:"flex items-center justify-end gap-2",children:ev.map(l=>{var t,n;let i=null===(n=E[s])||void 0===n?void 0:null===(t=n[e.id])||void 0===t?void 0:t[l];return(0,a.jsx)("div",{className:"w-[80px] flex justify-center",children:M(i,s,e.id,l)},l)})})})]},e.id))})})})]},s))})})]})}),(0,a.jsx)(em,{open:r,onClose:()=>{d(!1),h(null),k()},permissionId:"edit"===p?null==x?void 0:x.id:void 0,mode:p,defaultValues:"create"===p?{collection:null==x?void 0:x.collection,roleId:null==x?void 0:x.roleId,action:null==x?void 0:x.action}:void 0}),(0,a.jsx)(ej,{open:o,onClose:()=>{u(!1),_(),k()}})]})};var eg=l(99376),ey=l(89345),eN=l(48736),eb=l(98420),ew=l(78867),eC=l(12805),e_=l(69076),eS=l(90641);let eA={type:"",subject:"",body:"",tenant_Id:null,isActive:!0,description:""},eT=()=>{var e,s,l,o,u;let x=(0,eg.useRouter)(),[h,f]=(0,t.useState)("all"),[A,T]=(0,t.useState)("all"),[k,I]=(0,t.useState)("updatedAt"),[Z,z]=(0,t.useState)("desc"),[E,P]=(0,t.useState)(!1),[F,O]=(0,t.useState)(!1),[L,D]=(0,t.useState)(!1),[M,V]=(0,t.useState)(null),[R,B]=(0,t.useState)("create"),[U,J]=(0,t.useState)(eA),[Q,q]=(0,t.useState)(!1),[Y,K]=(0,t.useState)(!1),[H,W]=(0,t.useState)(null),G=(0,j.Ji)(),ee=(0,j.x5)(),{data:es}=(0,j.EV)({url:"".concat(G,"/templates/types"),method:"get"}),el=(null==es?void 0:null===(s=es.data)||void 0===s?void 0:null===(e=s.data)||void 0===e?void 0:e.types)||[],ea=(null==es?void 0:null===(o=es.data)||void 0===o?void 0:null===(l=o.data)||void 0===l?void 0:l.commonVariables)||[],{data:et,isLoading:en,refetch:ei}=(0,j.sm)({resource:"baasix_Template",meta:{fields:["*","tenant.id","tenant.name"]},pagination:{pageSize:-1},sorters:[{field:k,order:Z}]}),{data:er}=(0,j.sm)({resource:"baasix_Tenant",pagination:{pageSize:-1}}),{mutateAsync:ed}=(0,j.RO)(),{mutateAsync:eo}=(0,j.PQ)(),{mutateAsync:em}=(0,j.R2)(),ex=(null==et?void 0:et.data)||[],eh=(null==er?void 0:er.data)||[],ep=(0,t.useMemo)(()=>{let e=el.map(e=>({value:e.type,label:e.label})),s=ex.map(e=>e.type).filter(s=>!e.find(e=>e.value===s)).map(e=>({value:e,label:e}));return[...e,...s]},[el,ex]),ej=(0,t.useMemo)(()=>ex.filter(e=>{let s="all"===h||e.type===h,l="all"===A||"default"===A&&!e.tenant_Id||e.tenant_Id===A;return s&&l}),[ex,h,A]),ev=e=>ex.filter(s=>s.type===e).length,ef=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];let s=el.find(s=>s.type===e);return s?s.label:e},eT=e=>{let s=el.find(s=>s.type===e);return(null==s?void 0:s.variables)||[]},ek=async e=>{W(e);try{var s;let l=ee();if(!l.custom)throw Error("Data provider does not support custom method");let a=await l.custom({url:"".concat(G,"/templates/default/").concat(e),method:"get"}),t=null==a?void 0:null===(s=a.data)||void 0===s?void 0:s.data;t?(J(e=>({...e,subject:t.subject||e.subject,body:t.body||e.body,description:t.description||e.description})),g.Am.success("Default template loaded")):g.Am.info("No default template available for this type")}catch(e){console.error("Load default template error:",e),g.Am.error("Failed to load default template")}finally{W(null)}};(0,t.useEffect)(()=>{"create"===R&&U.type&&!Y&&ek(U.type)},[U.type,R,Y]);let eI=e=>{J({type:e.type,subject:e.subject,body:e.body,tenant_Id:e.tenant_Id,isActive:e.isActive,description:e.description||""}),V(e),B("edit"),K(!1),P(!0)},eZ=e=>{x.push("/settings/templates/edit?id=".concat(e.id))},ez=e=>{V(e),O(!0)},eE=e=>{V(e),D(!0)},eP=async()=>{if(!U.type||!U.subject){g.Am.error("Please fill in type and subject");return}if("create"===R&&!U.body&&!Y){g.Am.error("Please select a template type to load default content");return}let e={...U};Y&&!e.body&&(e.body="<p>Email content for ".concat(U.type,"</p>")),q(!0);try{"create"===R?(await ed({resource:"baasix_Template",values:e}),g.Am.success("Template created successfully")):M&&(await eo({resource:"baasix_Template",id:M.id,values:U}),g.Am.success("Template updated successfully")),P(!1),ei()}catch(e){g.Am.error(e.message||"Failed to save template")}finally{q(!1)}},eF=async()=>{if(M)try{await em({resource:"baasix_Template",id:M.id}),g.Am.success("Template deleted successfully"),D(!1),ei()}catch(e){g.Am.error(e.message||"Failed to delete template")}},eO=e=>{J({type:e.type,subject:e.subject,body:e.body,tenant_Id:null,isActive:!0,description:e.description||""}),V(null),B("create"),K(!1),P(!0),g.Am.info("Template duplicated - modify and save as new")};return en?(0,a.jsxs)(C.Zb,{className:"h-full",children:[(0,a.jsx)(C.Ol,{children:(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(ey.Z,{className:"h-5 w-5"}),"Email Templates"]})}),(0,a.jsx)(C.aY,{children:(0,a.jsx)("div",{className:"space-y-3",children:[1,2,3,4,5].map(e=>(0,a.jsx)(S.O,{className:"h-12 w-full"},e))})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(C.Zb,{className:"h-full flex flex-col",children:[(0,a.jsx)(C.Ol,{className:"flex-shrink-0",children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)(C.ll,{className:"flex items-center gap-2",children:[(0,a.jsx)(ey.Z,{className:"h-5 w-5"}),"Email Templates"]}),(0,a.jsx)(C.SZ,{children:"Manage email templates for system notifications. Create tenant-specific overrides for customized branding."})]}),(0,a.jsxs)(i.z,{onClick:()=>{J(eA),V(null),B("create"),K(!1),P(!0)},children:[(0,a.jsx)(eu.Z,{className:"h-4 w-4 mr-2"}),"Add Template"]})]})}),(0,a.jsxs)(C.aY,{className:"flex-1 overflow-hidden flex flex-col",children:[(0,a.jsxs)("div",{className:"flex flex-wrap gap-4 mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Type:"}),(0,a.jsxs)(X.Ph,{value:h,onValueChange:f,children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"All Types"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Types"}),ep.map(e=>{let s=el.some(s=>s.type===e.value)?e.label:e.value;return(0,a.jsxs)(X.Ql,{value:e.value,children:[s," (",ev(e.value),")"]},e.value)})]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Tenant:"}),(0,a.jsxs)(X.Ph,{value:A,onValueChange:T,children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"All Tenants"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"all",children:"All Tenants"}),(0,a.jsx)(X.Ql,{value:"default",children:"Default (No Tenant)"}),eh.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(N._,{className:"text-sm whitespace-nowrap",children:"Sort:"}),(0,a.jsxs)(X.Ph,{value:"".concat(k,":").concat(Z),onValueChange:e=>{let[s,l]=e.split(":");I(s),z(l)},children:[(0,a.jsx)(X.i4,{className:"w-[180px]",children:(0,a.jsx)(X.ki,{placeholder:"Sort by"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"updatedAt:desc",children:"Recently Updated"}),(0,a.jsx)(X.Ql,{value:"updatedAt:asc",children:"Oldest Updated"}),(0,a.jsx)(X.Ql,{value:"createdAt:desc",children:"Recently Created"}),(0,a.jsx)(X.Ql,{value:"createdAt:asc",children:"Oldest Created"}),(0,a.jsx)(X.Ql,{value:"type:asc",children:"Type (A-Z)"}),(0,a.jsx)(X.Ql,{value:"type:desc",children:"Type (Z-A)"})]})]})]})]}),(0,a.jsx)(eS.x,{className:"flex-1",children:(0,a.jsxs)($.iA,{children:[(0,a.jsx)($.xD,{children:(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.ss,{children:"Type"}),(0,a.jsx)($.ss,{children:"Subject"}),(0,a.jsx)($.ss,{children:"Tenant"}),(0,a.jsx)($.ss,{children:"Status"}),(0,a.jsx)($.ss,{children:"Updated"}),(0,a.jsx)($.ss,{className:"text-right",children:"Actions"})]})}),(0,a.jsx)($.RM,{children:0===ej.length?(0,a.jsx)($.SC,{children:(0,a.jsx)($.pj,{colSpan:6,className:"text-center text-muted-foreground py-8",children:"No templates found. Create one to get started."})}):ej.map(e=>{let s=el.some(s=>s.type===e.type);return(0,a.jsxs)($.SC,{children:[(0,a.jsx)($.pj,{children:(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(eN.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,a.jsx)("span",{className:"font-medium",children:ef(e.type)})]}),s&&(0,a.jsx)("span",{className:"text-xs text-muted-foreground ml-6 font-mono",children:e.type})]})}),(0,a.jsx)($.pj,{className:"max-w-[300px] truncate",children:e.subject}),(0,a.jsx)($.pj,{children:e.tenant?(0,a.jsxs)(n.C,{variant:"outline",className:"flex items-center gap-1 w-fit",children:[(0,a.jsx)(eb.Z,{className:"h-3 w-3"}),e.tenant.name]}):(0,a.jsx)(n.C,{variant:"secondary",children:"Default"})}),(0,a.jsx)($.pj,{children:(0,a.jsx)(n.C,{variant:e.isActive?"default":"secondary",children:e.isActive?"Active":"Inactive"})}),(0,a.jsx)($.pj,{className:"text-muted-foreground text-sm",children:e.updatedAt?new Date(e.updatedAt).toLocaleDateString():"-"}),(0,a.jsx)($.pj,{className:"text-right",children:(0,a.jsx)(m.pn,{children:(0,a.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>ez(e),children:(0,a.jsx)(r.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Preview"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eO(e),children:(0,a.jsx)(ew.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Duplicate"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eI(e),children:(0,a.jsx)(c.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Edit Details"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eZ(e),children:(0,a.jsx)(eC.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Design Template"})]}),(0,a.jsxs)(m.u,{children:[(0,a.jsx)(m.aJ,{asChild:!0,children:(0,a.jsx)(i.z,{variant:"ghost",size:"icon",onClick:()=>eE(e),className:"text-destructive hover:text-destructive",children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})})}),(0,a.jsx)(m._v,{children:"Delete"})]})]})})})]},e.id)})})]})})]})]}),(0,a.jsx)(ec.yo,{open:E,onOpenChange:P,children:(0,a.jsxs)(ec.ue,{className:"w-full sm:max-w-[500px] overflow-y-auto",children:[(0,a.jsxs)(ec.Tu,{children:[(0,a.jsx)(ec.bC,{children:"create"===R?"Create Email Template":"Edit Email Template"}),(0,a.jsx)(ec.Ei,{children:"create"===R?"Create a new email template. Select a type to auto-load the default template.":"Edit template details. Use the Designer button to modify the email design."})]}),(0,a.jsxs)("div",{className:"mt-6 space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"type",children:"Template Type *"}),"edit"===R?(0,a.jsx)(y.I,{value:ef(U.type),disabled:!0,className:"bg-muted"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)(X.Ph,{value:Y?"__custom__":U.type,onValueChange:e=>{"__custom__"===e?(J({...U,type:"",body:""}),K(!0)):(J({...U,type:e}),K(!1))},children:[(0,a.jsx)(X.i4,{children:(0,a.jsx)(X.ki,{placeholder:"Select type"})}),(0,a.jsxs)(X.Bw,{children:[el.map(e=>(0,a.jsx)(X.Ql,{value:e.type,children:e.label},e.type)),(0,a.jsx)(X.Ql,{value:"__custom__",children:"+ Custom Type..."})]})]}),Y&&(0,a.jsx)(y.I,{value:U.type,onChange:e=>J({...U,type:e.target.value}),placeholder:"Enter custom type name (e.g., orderConfirmation)",className:"mt-2",autoFocus:!0})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"tenant",children:"Tenant"}),(0,a.jsxs)(X.Ph,{value:U.tenant_Id||"default",onValueChange:e=>J({...U,tenant_Id:"default"===e?null:e}),children:[(0,a.jsx)(X.i4,{children:(0,a.jsx)(X.ki,{placeholder:"Select tenant"})}),(0,a.jsxs)(X.Bw,{children:[(0,a.jsx)(X.Ql,{value:"default",children:"Default (No Tenant)"}),eh.map(e=>(0,a.jsx)(X.Ql,{value:e.id,children:e.name},e.id))]})]})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"subject",children:"Subject Line *"}),(0,a.jsx)(y.I,{id:"subject",value:U.subject,onChange:e=>J({...U,subject:e.target.value}),placeholder:"Enter email subject (supports Liquid variables)"})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"description",children:"Description"}),(0,a.jsx)(b.g,{id:"description",value:U.description,onChange:e=>J({...U,description:e.target.value}),placeholder:"Optional description of the template",rows:2})]}),(0,a.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,a.jsx)(w.r,{id:"isActive",checked:U.isActive,onCheckedChange:e=>J({...U,isActive:e})}),(0,a.jsx)(N._,{htmlFor:"isActive",children:"Active"})]}),U.type&&(e=>{let s=Array.from(new Set([...eT(e),...ea]));return 0===s.length?null:(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{className:"text-sm",children:"Available Variables (click to copy)"}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map(e=>(0,a.jsx)(n.C,{variant:"secondary",className:"cursor-pointer hover:bg-secondary/80 text-xs",onClick:()=>{navigator.clipboard.writeText("{{ ".concat(e," }}")),g.Am.success("Copied {{ ".concat(e," }}"))},children:"{{ "+e+" }}"},e))})]})})(U.type),"create"===R&&U.type&&!Y&&(0,a.jsx)("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-md",children:H?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(v.Z,{className:"h-4 w-4 animate-spin"}),(0,a.jsx)("span",{className:"text-sm",children:"Loading default template..."})]}):U.body?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"Default template loaded. Use the Designer after creation to customize."}),(0,a.jsxs)(i.z,{type:"button",variant:"ghost",size:"sm",onClick:()=>ek(U.type),children:[(0,a.jsx)(e_.Z,{className:"h-3 w-3 mr-1"}),"Reload"]})]}):(0,a.jsx)("span",{className:"text-sm text-muted-foreground",children:"No default template available for this type."})}),"create"===R&&Y&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"p-3 bg-blue-50 dark:bg-blue-950 rounded-md border border-blue-200 dark:border-blue-800",children:(0,a.jsxs)("p",{className:"text-sm text-blue-700 dark:text-blue-300",children:[(0,a.jsx)("strong",{children:"Custom Template:"})," You can leave the body empty and use the Designer after creation, or provide basic HTML content below."]})}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)(N._,{htmlFor:"customBody",children:"Email Body (Optional HTML)"}),(0,a.jsx)(b.g,{id:"customBody",value:U.body,onChange:e=>J({...U,body:e.target.value}),placeholder:"<p>Your email content here...</p>",rows:6,className:"font-mono text-sm"})]})]}),"edit"===R&&(0,a.jsx)("div",{className:"p-3 bg-muted rounded-md",children:(0,a.jsxs)("p",{className:"text-sm text-muted-foreground",children:["To edit the email design, save changes here first, then use the ",(0,a.jsx)(eC.Z,{className:"h-3 w-3 inline mx-1"})," Designer button from the list."]})})]}),(0,a.jsxs)(ec.FF,{className:"mt-6",children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>P(!1),children:"Cancel"}),(0,a.jsxs)(i.z,{onClick:eP,disabled:Q,children:[Q&&(0,a.jsx)(v.Z,{className:"h-4 w-4 mr-2 animate-spin"}),"create"===R?"Create Template":"Save Changes"]})]})]})}),(0,a.jsx)(p.Vq,{open:F,onOpenChange:O,children:(0,a.jsxs)(p.cZ,{className:"max-w-[800px] max-h-[90vh] overflow-y-auto",children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Template Preview"}),(0,a.jsxs)(p.Be,{children:[M&&ef(M.type),(null==M?void 0:M.tenant)&&" - ".concat(M.tenant.name)]})]}),M&&(0,a.jsxs)(_.mQ,{defaultValue:"rendered",className:"mt-4",children:[(0,a.jsxs)(_.dr,{children:[(0,a.jsx)(_.SP,{value:"rendered",children:"Rendered"}),(0,a.jsx)(_.SP,{value:"source",children:"Source"})]}),(0,a.jsx)(_.nU,{value:"rendered",className:"mt-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Subject:"}),(0,a.jsx)("p",{className:"font-medium",children:M.subject})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Body:"}),(0,a.jsx)("div",{className:"mt-2 border rounded-md p-4 prose prose-sm dark:prose-invert max-w-none bg-white dark:bg-gray-950",dangerouslySetInnerHTML:{__html:M.body}})]})]})}),(0,a.jsx)(_.nU,{value:"source",className:"mt-4",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Subject:"}),(0,a.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded text-sm overflow-x-auto",children:M.subject})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)(N._,{className:"text-sm text-muted-foreground",children:"Body HTML:"}),(0,a.jsx)("pre",{className:"mt-1 p-2 bg-muted rounded text-sm overflow-x-auto max-h-[400px]",children:M.body})]})]})})]})]})}),(0,a.jsx)(p.Vq,{open:L,onOpenChange:D,children:(0,a.jsxs)(p.cZ,{children:[(0,a.jsxs)(p.fK,{children:[(0,a.jsx)(p.$N,{children:"Delete Template"}),(0,a.jsx)(p.Be,{children:"Are you sure you want to delete this template? This action cannot be undone."})]}),M&&(0,a.jsxs)("div",{className:"py-4",children:[(0,a.jsxs)("p",{className:"text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:"Type:"})," ",ef(M.type)]}),(0,a.jsxs)("p",{className:"text-sm",children:[(0,a.jsx)("span",{className:"font-medium",children:"Tenant:"})," ",(null===(u=M.tenant)||void 0===u?void 0:u.name)||"Default"]})]}),(0,a.jsxs)(p.cN,{children:[(0,a.jsx)(i.z,{variant:"outline",onClick:()=>D(!1),children:"Cancel"}),(0,a.jsx)(i.z,{variant:"destructive",onClick:eF,children:"Delete"})]})]})})]})}},69140:function(e,s,l){l.d(s,{O:function(){return n}});var a=l(57437),t=l(93448);function n(e){let{className:s,...l}=e;return(0,a.jsx)("div",{className:(0,t.cn)("animate-pulse rounded-md bg-muted",s),...l})}},81853:function(e,s,l){l.d(s,{Ml:function(){return r},PY:function(){return i}});var a=l(57437),t=l(2265);let n=(0,t.createContext)({projectSettings:null,isMultiTenant:!1,isLoading:!0,refetch:()=>{}}),i=()=>t.useContext(n)||(console.warn("useProject used outside of ProjectContextProvider, using defaults"),{projectSettings:null,isMultiTenant:!1,isLoading:!1,refetch:()=>{}}),r=e=>{let{children:s,baasixClient:l}=e,[i,r]=(0,t.useState)(null),[c,d]=(0,t.useState)(!0),o=(0,t.useCallback)(async()=>{try{d(!0);let e=await l.server.info();r(null==e?void 0:e.project)}catch(e){console.error("Failed to fetch project settings",e)}finally{d(!1)}},[l]);(0,t.useEffect)(()=>{o()},[o]);let m=(null==i?void 0:i.multitenant)===!0||(null==i?void 0:i.multitenant)==="true";return(0,a.jsx)(n.Provider,{value:{projectSettings:i,isMultiTenant:m,isLoading:c,refetch:o},children:s})}}}]);
|