@baasix/baasix 0.1.49 → 0.1.50
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/3817-863d6bb5cfa0a8de.js +1 -0
- package/dist/app/_next/static/chunks/6869-4f920a71fdc6b538.js +1 -0
- package/dist/app/_next/static/chunks/7304-bdd00a7504bc4081.js +1 -0
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/all-activity/{page-ff48b4acd0fc42fe.js → page-a7e9f0b39624b489.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/email-log/{page-fa1d9d5e2291811e.js → page-40f2b9ecf73e74b5.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/notifications/{page-7b517b1ae290cc0e.js → page-21fcdd2f0b3549db.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/sessions/{page-a267a7efa8bec4f4.js → page-82662735f1ec476a.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-executions/{page-ce2e9cb89b2f5602.js → page-4a781c95e5fb25f0.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/activity-log/workflow-logs/{page-a8347ffa1a172231.js → page-70bf8d31074dcba0.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/data-browser/{page-83316eb3328c20a5.js → page-d5715b9743d8dba4.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/file-manager/{page-e1fa630b92b3bf6e.js → page-c008de2bcf6811b9.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/permissions/{page-3d5fe31bbd93d286.js → page-2d3043500adcdb12.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/project/{page-35f7f73a8545dc50.js → page-6a58f15efb013e17.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/roles/{page-daffea990bfddd85.js → page-00cf3e4483986407.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/tasks/{page-36ad1f78b9e98e6e.js → page-fa3c401992a2fb8f.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/templates/{page-cf00084298675fec.js → page-aafbfd4f12875738.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/settings/tenants/{page-33c4895d4355cf17.js → page-f34d97ce6f68183b.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/invites/{page-1a394b10364eb827.js → page-20dd05a8745b6283.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/list/{page-e39a7cb508819983.js → page-479a164304f4de3f.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/{page-7fd4c1f311e3cec1.js → page-909d7be1b8d9800c.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/preferences/{page-0ef2ed33049757c4.js → page-e3fbcc425e1710e5.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/users/user-roles/{page-b776b7b3d24e97d6.js → page-3f654c69d79269f7.js} +1 -1
- package/dist/app/_next/static/chunks/app/(authenticated)/workflows/{page-97844b66676d0717.js → page-33c1c69678122839.js} +1 -1
- package/dist/app/_next/static/chunks/{webpack-953623aeb7ba634a.js → webpack-6ac1be755b80e221.js} +1 -1
- package/dist/app/activity-log/all-activity/index.html +1 -1
- package/dist/app/activity-log/all-activity/index.txt +3 -3
- package/dist/app/activity-log/email-log/index.html +1 -1
- package/dist/app/activity-log/email-log/index.txt +3 -3
- package/dist/app/activity-log/index.html +1 -1
- package/dist/app/activity-log/index.txt +2 -2
- package/dist/app/activity-log/notifications/index.html +1 -1
- package/dist/app/activity-log/notifications/index.txt +3 -3
- package/dist/app/activity-log/sessions/index.html +1 -1
- package/dist/app/activity-log/sessions/index.txt +3 -3
- package/dist/app/activity-log/workflow-executions/index.html +1 -1
- package/dist/app/activity-log/workflow-executions/index.txt +3 -3
- package/dist/app/activity-log/workflow-logs/index.html +1 -1
- package/dist/app/activity-log/workflow-logs/index.txt +3 -3
- package/dist/app/change-password/index.html +1 -1
- package/dist/app/change-password/index.txt +2 -2
- package/dist/app/dashboard/index.html +1 -1
- package/dist/app/dashboard/index.txt +2 -2
- package/dist/app/data-browser/index.html +1 -1
- package/dist/app/data-browser/index.txt +3 -3
- package/dist/app/file-manager/index.html +1 -1
- package/dist/app/file-manager/index.txt +3 -3
- package/dist/app/forgot-password/index.html +1 -1
- package/dist/app/forgot-password/index.txt +2 -2
- package/dist/app/index.html +1 -1
- package/dist/app/index.txt +2 -2
- package/dist/app/login/index.html +1 -1
- package/dist/app/login/index.txt +3 -3
- package/dist/app/register/index.html +1 -1
- package/dist/app/register/index.txt +2 -2
- package/dist/app/settings/migrations/index.html +1 -1
- package/dist/app/settings/migrations/index.txt +2 -2
- package/dist/app/settings/permissions/index.html +1 -1
- package/dist/app/settings/permissions/index.txt +3 -3
- package/dist/app/settings/project/index.html +1 -1
- package/dist/app/settings/project/index.txt +3 -3
- package/dist/app/settings/roles/index.html +1 -1
- package/dist/app/settings/roles/index.txt +3 -3
- package/dist/app/settings/schema/index.html +1 -1
- package/dist/app/settings/schema/index.txt +2 -2
- package/dist/app/settings/tasks/index.html +1 -1
- package/dist/app/settings/tasks/index.txt +3 -3
- package/dist/app/settings/templates/edit/index.html +1 -1
- package/dist/app/settings/templates/edit/index.txt +2 -2
- package/dist/app/settings/templates/index.html +1 -1
- package/dist/app/settings/templates/index.txt +3 -3
- package/dist/app/settings/tenants/index.html +1 -1
- package/dist/app/settings/tenants/index.txt +3 -3
- package/dist/app/users/index.html +1 -1
- package/dist/app/users/index.txt +3 -3
- package/dist/app/users/invites/index.html +1 -1
- package/dist/app/users/invites/index.txt +3 -3
- package/dist/app/users/list/index.html +1 -1
- package/dist/app/users/list/index.txt +3 -3
- package/dist/app/users/preferences/index.html +1 -1
- package/dist/app/users/preferences/index.txt +3 -3
- package/dist/app/users/user-roles/index.html +1 -1
- package/dist/app/users/user-roles/index.txt +3 -3
- package/dist/app/workflows/detail/index.html +1 -1
- package/dist/app/workflows/detail/index.txt +2 -2
- package/dist/app/workflows/edit/index.html +1 -1
- package/dist/app/workflows/edit/index.txt +2 -2
- package/dist/app/workflows/execution/index.html +1 -1
- package/dist/app/workflows/execution/index.txt +2 -2
- package/dist/app/workflows/index.html +1 -1
- package/dist/app/workflows/index.txt +3 -3
- package/package.json +1 -1
- package/dist/app/_next/static/chunks/3817-5954b08d65ca55fa.js +0 -1
- package/dist/app/_next/static/chunks/6869-11b3cd61c78598a7.js +0 -1
- package/dist/app/_next/static/chunks/7304-9584593752db7f07.js +0 -1
- /package/dist/app/_next/static/{w0mOVqxJmGgqAp-kWZW5- → DYIYZoqILRowEWsJ0xAMA}/_buildManifest.js +0 -0
- /package/dist/app/_next/static/{w0mOVqxJmGgqAp-kWZW5- → DYIYZoqILRowEWsJ0xAMA}/_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/17a2e01c4184b106.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-
|
|
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/17a2e01c4184b106.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-6ac1be755b80e221.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-4f920a71fdc6b538.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/7304-bdd00a7504bc4081.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-64ac14a534e2809b.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-6ac1be755b80e221.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/17a2e01c4184b106.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-4f920a71fdc6b538.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"7304\",\"static/chunks/7304-bdd00a7504bc4081.js\",\"3185\",\"static/chunks/app/layout-64ac14a534e2809b.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\":\"DYIYZoqILRowEWsJ0xAMA\",\"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/17a2e01c4184b106.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/17a2e01c4184b106.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-
|
|
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/17a2e01c4184b106.css" data-precedence="next"/><link rel="preload" as="script" fetchPriority="low" href="/admin/_next/static/chunks/webpack-6ac1be755b80e221.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-4f920a71fdc6b538.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/7304-bdd00a7504bc4081.js" async=""></script><script src="/admin/_next/static/chunks/app/layout-64ac14a534e2809b.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-6ac1be755b80e221.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/17a2e01c4184b106.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-4f920a71fdc6b538.js\",\"8473\",\"static/chunks/8473-6598318371eca31b.js\",\"4883\",\"static/chunks/4883-8a924721bb21b3b0.js\",\"7304\",\"static/chunks/7304-bdd00a7504bc4081.js\",\"3185\",\"static/chunks/app/layout-64ac14a534e2809b.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\":\"DYIYZoqILRowEWsJ0xAMA\",\"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/17a2e01c4184b106.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>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3817],{92322:function(e,l,t){t.d(l,{j:function(){return y}});var s=t(57437),a=t(2265),n=t(29501),r=t(12381),i=t(40279),o=t(75060),c=t(23675),d=t(94589),u=t(51817),m=t(90641),h=t(79622),x=t(5101),p=t(24065);let f=["createdAt","updatedAt","deletedAt","userCreated_Id","userUpdated_Id","userDeleted_Id","userCreated","userUpdated","userDeleted"],g=["UUIDV4","SUID","AUTOINCREMENT","NOW"],v=e=>!!e.defaultValue&&"object"==typeof e.defaultValue&&!!e.defaultValue.type&&g.includes(e.defaultValue.type),j=["createdAt","updatedAt","deletedAt"],y=e=>{let{fields:l,initialValues:t,onSubmit:g,isLoading:y,onCancel:N,disabledFields:b=[]}=e,{register:w,handleSubmit:C,setValue:S,watch:k,reset:T,formState:{errors:D}}=(0,n.cI)({defaultValues:t||{}}),[A,I]=(0,a.useState)(!1),[_,E]=(0,a.useState)(null),[O,F]=(0,a.useState)({});(0,a.useEffect)(()=>{if(t){T(t);let e=l.filter(e=>e.relType),s={};e.forEach(e=>{let l=t[e.name];if(("BelongsTo"===e.relType||"HasOne"===e.relType)&&!l&&e.foreignKey){let s=t[e.foreignKey];s&&(l={id:s})}("BelongsTo"===e.relType||"HasOne"===e.relType)&&l?s[e.name]=l:["HasMany","BelongsToMany","M2M","M2A"].includes(e.relType)&&l&&(s[e.name]=Array.isArray(l)?l:[l])}),F(s)}},[t,T,l]);let Z=t&&Object.keys(t).length>0,M=l.filter(e=>e.relType&&e.foreignKey).map(e=>e.foreignKey),z=l.filter(e=>!(M.includes(e.name)||f.includes(e.name))&&(!e.primaryKey||!Z&&!v(e))),P=z.filter(e=>!e.relType),B=z.filter(e=>e.relType),L=(e,l)=>{if("BelongsTo"===e.relType||"HasOne"===e.relType){let t=l?"string"==typeof l?{id:l}:l:null;if(F(l=>({...l,[e.name]:t})),e.foreignKey){let t="string"==typeof l?l:null==l?void 0:l.id;S(e.foreignKey,t)}}else{let t=(Array.isArray(l)?l:[l]).map(e=>"string"==typeof e?{id:e}:e);F(l=>({...l,[e.name]:t}))}},U=(e,l)=>{"BelongsTo"===e.relType||"HasOne"===e.relType?(F(l=>{let t={...l};return delete t[e.name],t}),e.foreignKey&&S(e.foreignKey,null)):F(t=>({...t,[e.name]:(t[e.name]||[]).filter(e=>e.id!==l)}))},R=e=>{E(e),I(!0)};return(0,s.jsxs)("form",{onSubmit:C(e=>{let t={...e};j.forEach(e=>{delete t[e]}),l.filter(e=>e.relType).forEach(e=>{if("BelongsTo"===e.relType||"HasOne"===e.relType){let l=O[e.name];if(l&&e.foreignKey){let s="string"==typeof l?l:l.id;t[e.foreignKey]=s}delete t[e.name]}else if(["HasMany","BelongsToMany","M2M","M2A"].includes(e.relType)){let l=O[e.name];l&&Array.isArray(l)?t[e.name]=l.map(e=>({id:"string"==typeof e?e:e.id})):delete t[e.name]}}),g(t)}),children:[(0,s.jsx)(m.x,{className:"h-[calc(100vh-200px)] pr-4",children:(0,s.jsxs)("div",{className:"space-y-4",children:[P.map(e=>{let l=k(e.name),t=e.name,a=e.label||t.replace(/_/g," "),n=b.includes(t);switch(e.type){case"Boolean":return(0,s.jsxs)("div",{className:"flex items-center justify-between space-x-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(d.r,{id:t,checked:l||!1,onCheckedChange:e=>S(t,e),disabled:n})]},t);case"Number":case"Integer":case"Float":case"Decimal":case"BigInt":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"number",step:"Integer"===e.type||"BigInt"===e.type?"1":"any",disabled:n,...w(t,{valueAsNumber:!0})})]},t);case"Date":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"date",value:(e=>{if(!e)return"";let l=new Date(e),t=l.getFullYear(),s=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0");return"".concat(t,"-").concat(s,"-").concat(a)})(l),disabled:n,onChange:e=>{S(t,e.target.value||null)}})]},t);case"DateTime":case"DateTime_NO_TZ":case"DATETIME":case"TIMESTAMP":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"datetime-local",value:(e=>{if(!e)return"";let l=new Date(e),t=l.getFullYear(),s=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0"),n=String(l.getHours()).padStart(2,"0"),r=String(l.getMinutes()).padStart(2,"0");return"".concat(t,"-").concat(s,"-").concat(a,"T").concat(n,":").concat(r)})(l),disabled:n,onChange:e=>{S(t,e.target.value?new Date(e.target.value).toISOString():null)}})]},t);case"Time":case"Time_NO_TZ":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"time",value:(e=>{if(!e)return"";if("string"==typeof e){let l=e.match(/^(\d{2}):(\d{2})/);if(l)return"".concat(l[1],":").concat(l[2]);if(e.includes("T")){let l=new Date(e),t=String(l.getHours()).padStart(2,"0"),s=String(l.getMinutes()).padStart(2,"0");return"".concat(t,":").concat(s)}}return e})(l),disabled:n,onChange:e=>{S(t,e.target.value||null)}})]},t);case"Text":case"LONGTEXT":case"MEDIUMTEXT":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(c.g,{id:t,rows:4,disabled:n,...w(t)})]},t);case"JSON":case"JSONB":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.mq,{value:l,onChange:e=>S(t,e),disabled:n})]},t);case"Enum":case"ENUM":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.o_,{value:l||"",onChange:e=>S(t,e),options:e.values||[],placeholder:"Select an option",allowNull:e.allowNull,disabled:n})]},t);case"Email":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"email",disabled:n,...w(t)})]},t);case"URL":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"url",placeholder:"https://",disabled:n,...w(t)})]},t);case"Phone":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"tel",disabled:n,...w(t)})]},t);case"Password":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"password",disabled:n,...w(t)})]},t);case"Array_Integer":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"number"})]},t);case"Array_String":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"string"})]},t);case"Array_Double":case"Array_Decimal":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"number"})]},t);case"Array_UUID":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"string",placeholder:"Enter UUID values"})]},t);case"Array_Date":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"date"})]},t);case"Array_DateTime":case"Array_DateTime_NO_TZ":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"datetime"})]},t);case"Array_Time":case"Array_Time_NO_TZ":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"time"})]},t);case"Array_Boolean":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.OF,{value:l||[],onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),itemType:"boolean"})]},t);case"Range_Integer":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"integer"})]},t);case"Range_Double":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"double"})]},t);case"Range_Decimal":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"decimal"})]},t);case"Range_Date":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"date"})]},t);case"Range_DateTime":case"Range_DateTime_NO_TZ":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"datetime"})]},t);case"Range_Time":case"Range_Time_NO_TZ":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.sU,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),rangeType:"time"})]},t);case"Point":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"Point",fieldName:a})]},t);case"Polygon":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"Polygon",fieldName:a})]},t);case"LineString":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"LineString",fieldName:a})]},t);case"MultiPoint":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiPoint",fieldName:a})]},t);case"MultiPolygon":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiPolygon",fieldName:a})]},t);case"MultiLineString":return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(h.XG,{value:l,onChange:e=>S(t,e,{shouldDirty:!0,shouldTouch:!0}),geometryType:"MultiLineString",fieldName:a})]},t);default:return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{htmlFor:t,children:a}),(0,s.jsx)(i.I,{id:t,type:"text",disabled:n,...w(t)})]},t)}}),B.length>0&&(0,s.jsxs)("div",{className:"space-y-4 pt-4 border-t",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-muted-foreground",children:"Relationships"}),B.map(e=>{let l="BelongsTo"===e.relType||"HasOne"===e.relType?O[e.name]:O[e.name]||[];return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(o._,{children:e.label||e.name.replace(/_/g," ")}),(0,s.jsx)(x.q,{value:l,field:e,onClick:()=>R(e),onRemove:l=>U(e,l)})]},e.name)})]})]})}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-4 border-t mt-4",children:[(0,s.jsx)(r.z,{type:"button",variant:"outline",onClick:N,disabled:y,children:"Cancel"}),(0,s.jsxs)(r.z,{type:"submit",disabled:y,children:[y&&(0,s.jsx)(u.Z,{className:"mr-2 h-4 w-4 animate-spin"}),t?"Update":"Create"]})]}),_&&(0,s.jsx)(p.x,{open:A,onClose:()=>{I(!1),setTimeout(()=>E(null),100)},onSelect:e=>{L(_,e)},target:_.target,field:_,selectedItems:"BelongsTo"===_.relType||"HasOne"===_.relType?O[_.name]?[O[_.name]]:[]:O[_.name]||[]})]})}},24065:function(e,l,t){t.d(l,{x:function(){return N}});var s=t(57437),a=t(2265),n=t(29696),r=t(91032),i=t(12381),o=t(69174),c=t(75060),d=t(17168),u=t(99397),m=t(32489),h=t(69658),x=t(17689),p=t(51817),f=t(72337),g=t(92322),v=t(72135),j=t(14438);let y=e=>{if(0===e)return"0 B";let l=Math.floor(Math.log(e)/Math.log(1024));return parseFloat((e/Math.pow(1024,l)).toFixed(2))+" "+["B","KB","MB","GB"][l]},N=e=>{var l;let{open:t,onClose:N,onSelect:b,target:w,field:C,selectedItems:S=[]}=e,[k,T]=(0,a.useState)(S),[D,A]=(0,a.useState)(!1),[I,_]=(0,a.useState)("select"),[E,O]=(0,a.useState)([]),[F,Z]=(0,a.useState)(!1),[M,z]=(0,a.useState)(0),P=(0,a.useRef)(null),{getFieldsByCollection:B,schemas:L}=(0,n.I_)();(0,v.Ji)();let U="files"===w||"baasix_File"===w,R="HasMany"===C.relType||"BelongsToMany"===C.relType||"M2M"===C.relType||"M2A"===C.relType;(0,a.useEffect)(()=>{t&&(T(S||[]),_("select"),O([]))},[t,S]);let J=B(w),V=null==L?void 0:L.find(e=>e.collectionName===w),K=(0,a.useMemo)(()=>J?Object.entries(J).map(e=>{let[l,t]=e;return{name:l,...t,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}}):[],[J]),{mutate:q,isLoading:W}=(0,v.RO)(),H=(0,a.useCallback)(e=>{e.preventDefault(),O(Array.from(e.dataTransfer.files))},[]),G=(0,a.useCallback)(e=>{e.preventDefault()},[]),Y=e=>{O(E.filter((l,t)=>t!==e))},X=async()=>{if(0===E.length)return;Z(!0);let e=[];try{for(let l of E){let t=new FormData;t.append("file",l),await new Promise((s,a)=>{q({resource:"files",values:t},{onSuccess:l=>{let t=null==l?void 0:l.data;t&&e.push(t),s()},onError:e=>{j.Am.error("Failed to upload ".concat(l.name,": ").concat(e.message)),a(e)}})})}if(j.Am.success("".concat(E.length," file(s) uploaded successfully")),Z(!1),e.length>0){if(R){let l=[...k,...e];T(l),b(l),O([]),_("select"),z(e=>e+1)}else{b(e[0]),setTimeout(()=>{N()},50);return}}}catch(e){console.error("Upload error:",e),Z(!1)}},Q=(0,a.useCallback)(e=>{T(e),!R&&e.length>0&&(b(e[0]),N())},[R,b,N]),$=()=>{b(k),N()};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(r.yo,{open:t,onOpenChange:e=>!e&&N(),children:(0,s.jsx)(r.ue,{className:"w-full sm:w-[900px] sm:max-w-[900px] flex flex-col p-0",hideDefaultClose:!0,children:U?(0,s.jsxs)(d.mQ,{value:I,onValueChange:e=>_(e),className:"flex-1 flex flex-col min-h-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-3 py-2 border-b shrink-0",children:[(0,s.jsx)(r.sw,{asChild:!0,children:(0,s.jsxs)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:[(0,s.jsx)(m.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})}),(0,s.jsxs)("span",{className:"font-medium truncate text-sm",children:["Select ",(null==C?void 0:C.label)||(null==C?void 0:C.name)]}),R&&k.length>0&&(0,s.jsx)(o.C,{variant:"secondary",className:"shrink-0",children:k.length}),(0,s.jsxs)(d.dr,{className:"grid grid-cols-2 ml-auto",children:[(0,s.jsxs)(d.SP,{value:"select",className:"text-xs px-3",children:[(0,s.jsx)(h.Z,{className:"mr-1.5 h-3.5 w-3.5"}),"Select"]}),(0,s.jsxs)(d.SP,{value:"upload",className:"text-xs px-3",children:[(0,s.jsx)(x.Z,{className:"mr-1.5 h-3.5 w-3.5"}),"Upload"]})]}),R&&(0,s.jsxs)(i.z,{onClick:$,children:["Done (",k.length,")"]})]}),(0,s.jsx)(d.nU,{value:"select",className:"flex-1 flex flex-col min-h-0 mt-0 data-[state=inactive]:hidden",children:(0,s.jsx)("div",{className:"flex-1 flex flex-col min-h-0 px-3 pb-3",children:w&&(0,s.jsx)(f.DataBrowserInner,{selectedCollection:w,hideTitle:!0,enableSearch:!0,enableFilters:!0,enableCreate:!1,enableView:!1,enableEdit:!1,enableDelete:!1,enableExport:!1,enableImport:!1,enableBulkSelect:!1,enableColumnSettings:!1,showSelectionColumn:!0,selectionMode:R?"multiple":"single",externalSelectedRows:k,onExternalSelectionChange:Q,highlightSelectedRows:!0,syncSearchWithUrl:!1},M)})}),(0,s.jsx)(d.nU,{value:"upload",className:"flex-1 overflow-auto p-4 mt-0 data-[state=inactive]:hidden",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-12 text-center cursor-pointer hover:border-primary transition-colors",onClick:()=>{var e;return null===(e=P.current)||void 0===e?void 0:e.click()},onDrop:H,onDragOver:G,children:[(0,s.jsx)(x.Z,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground"}),(0,s.jsx)("p",{className:"text-lg font-medium",children:"Drag and drop files here"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mt-1",children:"or click to browse"}),(0,s.jsx)("input",{ref:P,type:"file",multiple:R,className:"hidden",onChange:e=>{e.target.files&&O(Array.from(e.target.files))}})]}),E.length>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(c._,{children:"Selected Files"}),(0,s.jsx)("div",{className:"space-y-2 max-h-60 overflow-y-auto",children:E.map((e,l)=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-3 bg-muted rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 truncate",children:[(0,s.jsx)(h.Z,{className:"h-5 w-5 shrink-0 text-muted-foreground"}),(0,s.jsxs)("div",{className:"min-w-0",children:[(0,s.jsx)("span",{className:"text-sm font-medium truncate block",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:y(e.size)})]})]}),(0,s.jsx)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",onClick:()=>Y(l),children:(0,s.jsx)(m.Z,{className:"h-4 w-4"})})]},l))}),(0,s.jsxs)(i.z,{onClick:X,disabled:F||0===E.length,className:"w-full",children:[F?(0,s.jsx)(p.Z,{className:"mr-2 h-4 w-4 animate-spin"}):(0,s.jsx)(x.Z,{className:"mr-2 h-4 w-4"}),"Upload & Select"]})]})]})})]}):(0,s.jsx)("div",{className:"flex-1 flex flex-col min-h-0 px-3 pb-3 pt-2",children:w&&(0,s.jsx)(f.DataBrowserInner,{selectedCollection:w,hideTitle:!0,enableSearch:!0,enableFilters:!0,enableCreate:!1,enableView:!1,enableEdit:!1,enableDelete:!1,enableExport:!1,enableImport:!1,enableBulkSelect:!1,enableColumnSettings:!1,showSelectionColumn:!0,selectionMode:R?"multiple":"single",externalSelectedRows:k,onExternalSelectionChange:Q,highlightSelectedRows:!0,quickFilters:(0,s.jsxs)("div",{className:"flex items-center gap-2 mr-auto",children:[(0,s.jsx)(r.sw,{asChild:!0,children:(0,s.jsxs)(i.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0",children:[(0,s.jsx)(m.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"sr-only",children:"Close"})]})}),(0,s.jsxs)("span",{className:"font-medium truncate text-sm",children:["Select ",(null==C?void 0:C.label)||(null==C?void 0:C.name)]}),R&&k.length>0&&(0,s.jsx)(o.C,{variant:"secondary",className:"shrink-0",children:k.length})]}),headerActions:(0,s.jsxs)(s.Fragment,{children:[!U&&(0,s.jsx)(i.z,{size:"icon",onClick:()=>A(!0),title:"Create New",children:(0,s.jsx)(u.Z,{className:"h-4 w-4"})}),R&&(0,s.jsxs)(i.z,{onClick:$,children:["Done (",k.length,")"]})]}),syncSearchWithUrl:!1})})})}),(0,s.jsx)(r.yo,{open:D,onOpenChange:A,children:(0,s.jsxs)(r.ue,{className:"w-full sm:w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,s.jsx)(r.Tu,{children:(0,s.jsxs)(r.bC,{children:["Create New ",(null==V?void 0:null===(l=V.schema)||void 0===l?void 0:l.name)||w]})}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(g.j,{fields:K,onSubmit:e=>{q({resource:w,values:e},{onSuccess:e=>{j.Am.success("Item created successfully"),A(!1),R?T([...k,e.data]):(b(e.data),N())},onError:e=>{j.Am.error("Failed to create: ".concat(e.message))}})},isLoading:W,onCancel:()=>A(!1)})})]})})]})}},5101:function(e,l,t){t.d(l,{q:function(){return o}});var s=t(57437);t(2265);var a=t(12381),n=t(69174),r=t(32489),i=t(73247);let o=e=>{let{value:l,field:t,onClick:o,onRemove:c,placeholder:d}=e,u=e=>{if(!e||"object"!=typeof e)return!1;let l=Object.keys(e);return 0===l.length||l.every(l=>null===e[l]||void 0===e[l])},m=e=>{if(!e||"object"==typeof e&&u(e))return"";if("string"==typeof e||"number"==typeof e)return String(e);if(t.showAs&&Array.isArray(t.showAs)){let l=["-"," ",",","_"," and "," or "],s=[];t.showAs.forEach(t=>{if(l.includes(t))s.push(t);else{let l;if(t.includes(".")){let s=t.split("."),a=e;for(let e of s)if(null==(a=null==a?void 0:a[e]))break;l=a}else l=e[t];null!=l&&""!==l&&s.push(String(l))}});let a=s.filter((e,t)=>{let a=l.includes(e),n=t>0&&l.includes(s[t-1]),r=t===s.length-1;return!a||0!==t&&!r&&!n});return a.length>0?a.join(""):e.id||e.name||""}return e.name||e.title||e.label||e.email||e.id||""};if(Array.isArray(l))return(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)("div",{onClick:o,className:"cursor-pointer",children:l.length>0?(0,s.jsx)("div",{className:"flex flex-wrap gap-1 p-2 border rounded-md min-h-10 bg-background",children:l.map((e,l)=>(0,s.jsxs)(n.C,{variant:"secondary",className:"flex items-center gap-1",children:[m(e),(0,s.jsx)("button",{type:"button",onClick:l=>{l.stopPropagation(),null==c||c(e)},className:"ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:(0,s.jsx)(r.Z,{className:"h-3 w-3"})})]},e.id||l))}):(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background text-muted-foreground cursor-pointer hover:bg-accent",children:[(0,s.jsx)(i.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{children:d||"Select ".concat(t.label||t.name)})]})}),l.length>0&&(0,s.jsxs)(a.z,{type:"button",variant:"outline",size:"sm",onClick:o,className:"flex items-center gap-1",children:[(0,s.jsx)(i.Z,{className:"h-3 w-3"}),"Add More"]})]});let h=l&&!u(l);return(0,s.jsx)("div",{onClick:o,className:"cursor-pointer",children:(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsx)("div",{className:"flex-1",children:h?(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background",children:[(0,s.jsx)("span",{className:"flex-1",children:m(l)}),(0,s.jsx)("button",{type:"button",onClick:e=>{e.stopPropagation(),null==c||c(l)},className:"text-muted-foreground hover:text-foreground",children:(0,s.jsx)(r.Z,{className:"h-4 w-4"})})]}):(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 border rounded-md min-h-10 bg-background text-muted-foreground hover:bg-accent",children:[(0,s.jsx)(i.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{children:d||"Select ".concat(t.label||t.name)})]})})})})}},72337:function(e,l,t){t.r(l),t.d(l,{DataBrowser:function(){return eQ},DataBrowserInner:function(){return eX},default:function(){return e$}});var s=t(57437),a=t(2265),n=t(99376),r=t(72135),i=t(10795),o=t(93662),c=t(84314),d=t(29696),u=t(63751),m=t(28757),h=t(83434),x=t(79622),p=t(12381),f=t(43368),g=t(79820),v=t(33804),j=t(69174),y=t(91032),N=t(74291),b=t(32060),w=t(15291),C=t(68245),S=t(90740),k=t(98728),T=t(82431),D=t(67782),A=t(92735),I=t(17689),_=t(99397),E=t(41905),O=t(20265),F=t(15051),Z=t(28842),M=t(51817),z=t(42208),P=t(15868),B=t(18930),L=t(92451),U=t(10407),R=t(83774),J=t(40875),V=t(82284),K=t(13781),q=t(7586),W=t(64935),H=t(17168),G=t(23675),Y=t(12749),X=t(90641),Q=t(71096),$=t.n(Q),ee=t(40279),el=t(94589),et=t(46291),es=t(31047),ea=t(91723),en=t(93448),er=t(27107);let ei=["isNull","isNotNull","_true","_false"],eo={text:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Contains",value:"iLike"},{label:"Not Contains",value:"notILike"},{label:"Contains (case-sensitive)",value:"like"},{label:"Not Contains (case-sensitive)",value:"notLike"},{label:"Starts With",value:"startsWith"},{label:"Not Starts With",value:"nstartsWith"},{label:"Ends With",value:"endsWith"},{label:"Not Ends With",value:"nendsWith"},{label:"In",value:"in"},{label:"Not In",value:"notIn"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],number:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"Greater Than",value:"gt"},{label:"Greater Than or Equal",value:"gte"},{label:"Less Than",value:"lt"},{label:"Less Than or Equal",value:"lte"},{label:"In",value:"in"},{label:"Not In",value:"notIn"},{label:"Between",value:"between"},{label:"Not Between",value:"notBetween"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],date:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"After",value:"gt"},{label:"On or After",value:"gte"},{label:"Before",value:"lt"},{label:"On or Before",value:"lte"},{label:"Between",value:"between"},{label:"Not Between",value:"notBetween"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],boolean:[{label:"Is True",value:"_true"},{label:"Is False",value:"_false"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],relation:[{label:"Equals",value:"eq"},{label:"Not Equals",value:"ne"},{label:"In",value:"in"},{label:"Not In",value:"notIn"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],array:[{label:"Contains All",value:"arraycontains"},{label:"Contained By",value:"arraycontained"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],json:[{label:"Contains",value:"jsonbContains"},{label:"Not Contains",value:"jsonbNotContains"},{label:"Contained By",value:"jsonbContainedBy"},{label:"Has Key",value:"jsonbHasKey"},{label:"Has Any Keys",value:"jsonbHasAnyKeys"},{label:"Has All Keys",value:"jsonbHasAllKeys"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}],geospatial:[{label:"Within",value:"within"},{label:"Contains",value:"containsGEO"},{label:"Intersects",value:"intersects"},{label:"Not Intersects",value:"nIntersects"},{label:"Distance Within",value:"dwithin"},{label:"Is Empty",value:"isNull"},{label:"Is Not Empty",value:"isNotNull"}]},ec={DOUBLE:"Double",TEXT:"Text",Float:"Double",Enum:"ENUM",Geometry:"Point",Array:"Array_String"},ed=e=>{var l;return e&&null!==(l=ec[e])&&void 0!==l?l:e},eu=e=>{if(!e)return eo.text;if(e.relType)return eo.relation;let l=ed(e.type);if(null==l?void 0:l.startsWith("Array_"))return eo.array;if(null==l?void 0:l.startsWith("Range_"))return eo.number;switch(l){case"Integer":case"BigInt":case"Decimal":case"Double":case"Real":return eo.number;case"Date":case"DateTime":case"DateTime_NO_TZ":case"Time":case"Time_NO_TZ":return eo.date;case"Boolean":return eo.boolean;case"JSON":case"JSONB":return eo.json;case"Point":case"Polygon":case"LineString":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":case"Geography":return eo.geospatial;default:return eo.text}},em=(e,l,t)=>{if(null==e)return e;if("isNull"===l||"isNotNull"===l||"_true"===l)return!0;if("_false"===l)return!1;if("in"===l||"notIn"===l)return Array.isArray(e)?e:[e];if("jsonbHasKey"===l)return e;if("jsonbHasAnyKeys"===l||"jsonbHasAllKeys"===l)return Array.isArray(e)?e:[e];if("jsonbContains"===l||"jsonbContainedBy"===l||"jsonbNotContains"===l){if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e}if("arraycontains"===l||"arraycontained"===l)return Array.isArray(e)?e:[e];if(t){let s=ed(t.type);if("Date"===s||"DateTime"===s||"DateTime_NO_TZ"===s)return("between"===l||"notBetween"===l)&&Array.isArray(e)?e.map(e=>e?$()(e).toISOString():null):e?$()(e).toISOString():null;if("Time"===s||"Time_NO_TZ"===s)return("between"===l||"notBetween"===l)&&Array.isArray(e)?e.map(e=>e||null):e||null;if("Integer"===s||"BigInt"===s||"Decimal"===s||"Double"===s||"Real"===s)return("between"===l||"notBetween"===l)&&Array.isArray(e)?e.map(e=>void 0!==e&&""!==e?Number(e):null):"in"===l||"notIn"===l?(Array.isArray(e)?e:[e]).map(e=>void 0!==e&&""!==e?Number(e):null).filter(e=>null!==e):void 0!==e&&""!==e?Number(e):null;if("Boolean"===s)return!!e;if((null==s?void 0:s.startsWith("Array_"))||(null==s?void 0:s.startsWith("Range_")))return Array.isArray(e)?e:[e];if("Point"===s||"Polygon"===s||"LineString"===s||"MultiPoint"===s||"MultiLineString"===s||"MultiPolygon"===s||"GeometryCollection"===s||"Geography"===s)try{return"string"==typeof e?JSON.parse(e):e}catch(e){}}return e},eh=e=>{let{value:l,onChange:t,placeholder:a}=e;return(0,s.jsxs)(Y.J2,{children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsxs)(p.z,{variant:"outline",className:(0,en.cn)("w-full justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[(0,s.jsx)(es.Z,{className:"mr-2 h-4 w-4"}),l?(0,er.WU)(l,"PPP"):a||"Pick a date"]})}),(0,s.jsx)(Y.yk,{className:"w-auto p-0",align:"start",children:(0,s.jsx)(et.f,{mode:"single",selected:l,onSelect:t,initialFocus:!0})})]})},ex=e=>{let{value:l,onChange:t,placeholder:a}=e,n=l?"".concat(String(l.getHours()).padStart(2,"0"),":").concat(String(l.getMinutes()).padStart(2,"0")):"",r=e=>{if(!e)return;let[s,a]=e.split(":").map(Number),n=l?new Date(l):new Date;n.setHours(s,a,0,0),t(n)};return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)(Y.J2,{children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsxs)(p.z,{variant:"outline",className:(0,en.cn)("justify-start text-left font-normal",!l&&"text-muted-foreground"),children:[(0,s.jsx)(es.Z,{className:"mr-2 h-4 w-4"}),l?(0,er.WU)(l,"PPP"):a||"Pick a date"]})}),(0,s.jsx)(Y.yk,{className:"w-auto p-0",align:"start",children:(0,s.jsx)(et.f,{mode:"single",selected:l,onSelect:e=>{if(!e){t(void 0);return}l&&e.setHours(l.getHours(),l.getMinutes(),0,0),t(e)},initialFocus:!0})})]}),(0,s.jsx)(ee.I,{type:"time",value:n,onChange:e=>r(e.target.value),className:"w-28"})]})},ep=e=>{let{value:l,onChange:t,placeholder:a}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ea.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)(ee.I,{type:"time",value:(e=>{if(!e)return"";if(e.includes("T")){let l=new Date(e);if(!isNaN(l.getTime()))return"".concat(String(l.getHours()).padStart(2,"0"),":").concat(String(l.getMinutes()).padStart(2,"0"))}return/^\d{2}:\d{2}/.test(e)?e.substring(0,5):e})(l),onChange:e=>t(e.target.value||void 0),placeholder:a||"Select time",className:"w-full"})]})},ef=(e,l,t,a)=>{var n,r,i,o,c,d,u;if(ei.includes(l))return null;if("in"===l||"notIn"===l)return(0,s.jsx)(ee.I,{placeholder:"Enter values (comma-separated)",value:Array.isArray(t)?t.join(", "):t||"",onChange:e=>{let l=e.target.value.split(",").map(e=>e.trim()).filter(Boolean);a(l.length>0?l:void 0)}});if("jsonbContains"===l||"jsonbContainedBy"===l||"jsonbNotContains"===l)return(0,s.jsx)(G.g,{placeholder:'Enter JSON (e.g. {"key": "value"})',value:"object"==typeof t?JSON.stringify(t,null,2):t||"",onChange:e=>{try{a(JSON.parse(e.target.value))}catch(l){a(e.target.value)}},rows:3});if("jsonbHasKey"===l)return(0,s.jsx)(ee.I,{placeholder:"Enter key name",value:t||"",onChange:e=>a(e.target.value)});if("jsonbHasAnyKeys"===l||"jsonbHasAllKeys"===l)return(0,s.jsx)(ee.I,{placeholder:"Enter keys (comma-separated)",value:Array.isArray(t)?t.join(", "):t||"",onChange:e=>{let l=e.target.value.split(",").map(e=>e.trim()).filter(Boolean);a(l.length>0?l:void 0)}});if(!e)return(0,s.jsx)(ee.I,{placeholder:"Enter value",value:t||"",onChange:e=>a(e.target.value)});if(e.relType)return"in"===l||"notIn"===l?(0,s.jsx)(ee.I,{placeholder:"Enter IDs (comma-separated)",value:Array.isArray(t)?t.join(", "):t||"",onChange:e=>{let l=e.target.value.split(",").map(e=>e.trim()).filter(Boolean);a(l.length>0?l:void 0)}}):(0,s.jsxs)(w.Ph,{value:t||"",onValueChange:a,children:[(0,s.jsx)(w.i4,{className:"w-full",children:(0,s.jsx)(w.ki,{placeholder:"Select value"})}),(0,s.jsx)(w.Bw,{})]});let m=ed(e.type);if(null==m?void 0:m.startsWith("Array_"))return(0,s.jsx)(ee.I,{placeholder:"Enter values (comma-separated)",value:Array.isArray(t)?t.join(", "):t||"",onChange:e=>{let l=e.target.value.split(",").map(e=>e.trim()).filter(Boolean);a(l.length>0?l:void 0)}});if(null==m?void 0:m.startsWith("Range_"))return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ee.I,{placeholder:"From",className:"w-24",value:null!==(n=null==t?void 0:t[0])&&void 0!==n?n:"",onChange:e=>a([e.target.value||void 0,null==t?void 0:t[1]])}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,s.jsx)(ee.I,{placeholder:"To",className:"w-24",value:null!==(r=null==t?void 0:t[1])&&void 0!==r?r:"",onChange:e=>a([null==t?void 0:t[0],e.target.value||void 0])})]});switch(m){case"Integer":case"BigInt":case"Decimal":case"Double":case"Real":if("between"===l||"notBetween"===l)return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ee.I,{type:"number",className:"w-24",value:null!==(i=null==t?void 0:t[0])&&void 0!==i?i:"",onChange:e=>a([e.target.value?Number(e.target.value):void 0,null==t?void 0:t[1]]),placeholder:"Min"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,s.jsx)(ee.I,{type:"number",className:"w-24",value:null!==(o=null==t?void 0:t[1])&&void 0!==o?o:"",onChange:e=>a([null==t?void 0:t[0],e.target.value?Number(e.target.value):void 0]),placeholder:"Max"})]});return(0,s.jsx)(ee.I,{type:"number",value:null!=t?t:"",onChange:e=>a(e.target.value?Number(e.target.value):void 0),className:"w-full"});case"Boolean":return(0,s.jsx)(el.r,{checked:!0===t,onCheckedChange:a});case"Date":if("between"===l||"notBetween"===l)return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eh,{value:(null==t?void 0:t[0])?new Date(t[0]):void 0,onChange:e=>a([null==e?void 0:e.toISOString(),null==t?void 0:t[1]]),placeholder:"From"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,s.jsx)(eh,{value:(null==t?void 0:t[1])?new Date(t[1]):void 0,onChange:e=>a([null==t?void 0:t[0],null==e?void 0:e.toISOString()]),placeholder:"To"})]});return(0,s.jsx)(eh,{value:t?new Date(t):void 0,onChange:e=>a(null==e?void 0:e.toISOString())});case"DateTime":case"DateTime_NO_TZ":if("between"===l||"notBetween"===l)return(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(ex,{value:(null==t?void 0:t[0])?new Date(t[0]):void 0,onChange:e=>a([null==e?void 0:e.toISOString(),null==t?void 0:t[1]]),placeholder:"From"}),(0,s.jsx)("span",{className:"text-muted-foreground text-center",children:"to"}),(0,s.jsx)(ex,{value:(null==t?void 0:t[1])?new Date(t[1]):void 0,onChange:e=>a([null==t?void 0:t[0],null==e?void 0:e.toISOString()]),placeholder:"To"})]});return(0,s.jsx)(ex,{value:t?new Date(t):void 0,onChange:e=>a(null==e?void 0:e.toISOString())});case"Time":case"Time_NO_TZ":if("between"===l||"notBetween"===l)return(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ep,{value:null==t?void 0:t[0],onChange:e=>a([e,null==t?void 0:t[1]]),placeholder:"From"}),(0,s.jsx)("span",{className:"text-muted-foreground",children:"to"}),(0,s.jsx)(ep,{value:null==t?void 0:t[1],onChange:e=>a([null==t?void 0:t[0],e]),placeholder:"To"})]});return(0,s.jsx)(ep,{value:t,onChange:a});case"Enum":case"ENUM":return(0,s.jsxs)(w.Ph,{value:t||"",onValueChange:a,children:[(0,s.jsx)(w.i4,{className:"w-full",children:(0,s.jsx)(w.ki,{placeholder:"Select value"})}),(0,s.jsx)(w.Bw,{children:null===(d=(null===(u=e.values)||void 0===u?void 0:u.values)||e.values)||void 0===d?void 0:null===(c=d.map)||void 0===c?void 0:c.call(d,e=>(0,s.jsx)(w.Ql,{value:e,children:e},e))})]});case"JSON":case"JSONB":return(0,s.jsx)(G.g,{placeholder:"Enter JSON value",value:"object"==typeof t?JSON.stringify(t,null,2):t||"",onChange:e=>{try{a(JSON.parse(e.target.value))}catch(l){a(e.target.value)}},rows:3});case"Point":case"Polygon":case"LineString":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":case"Geography":return(0,s.jsx)(G.g,{placeholder:"Enter GeoJSON",value:"object"==typeof t?JSON.stringify(t):t||"",onChange:e=>a(e.target.value)});case"UUID":case"SUID":case"TOKEN":return(0,s.jsx)(ee.I,{placeholder:"Enter ID value",value:t||"",onChange:e=>a(e.target.value)});case"VIRTUAL":return(0,s.jsx)(ee.I,{placeholder:"Enter value",value:t||"",onChange:e=>a(e.target.value)});default:return(0,s.jsx)(ee.I,{placeholder:"Enter value",value:t||"",onChange:e=>a(e.target.value)})}},eg=e=>e&&"object"==typeof e&&"field"in e&&"operator"in e,ev=e=>{let{fields:l,value:t,onChange:n}=e,{getFieldsByCollection:r}=(0,d.I_)(),[i,o]=(0,a.useState)(new Set),[c,u]=(0,a.useState)(!1),m=(0,a.useCallback)(function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:3;return 0===t?[]:e.map(e=>{let s=l?"".concat(l,".").concat(e.name):e.name,a={name:e.name,path:s,label:e.label||e.name,type:e.type,relType:e.relType,target:e.target};if(e.relType&&e.target){let l=r(e.target);if(l){let e=Object.entries(l).map(e=>{let[l,t]=e;return{name:l,...t,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}});a.children=m(e,s,t-1)}}return a})},[r]),h=(0,a.useMemo)(()=>m(l),[l,m]),x=(e,l)=>{l.stopPropagation();let t=new Set(i);t.has(e)?t.delete(e):t.add(e),o(t)},f=e=>{n(e),u(!1)},g=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,a=e.children&&e.children.length>0,n=i.has(e.path),r=t===e.path;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 py-1.5 px-2 cursor-pointer hover:bg-accent rounded-sm ".concat(r?"bg-accent":""),style:{paddingLeft:"".concat(16*l+8,"px")},onClick:()=>f(e.path),children:[a?(0,s.jsx)("button",{type:"button",onClick:l=>x(e.path,l),className:"p-0.5 hover:bg-muted rounded",children:n?(0,s.jsx)(J.Z,{className:"h-3 w-3"}):(0,s.jsx)(U.Z,{className:"h-3 w-3"})}):(0,s.jsx)("span",{className:"w-4"}),(0,s.jsxs)("span",{className:"text-sm truncate flex-1",children:[e.label,e.relType&&(0,s.jsxs)("span",{className:"text-xs text-muted-foreground ml-1",children:["(",e.relType,")"]})]})]}),a&&n&&(0,s.jsx)("div",{children:e.children.map(e=>g(e,l+1))})]},e.path)};return(0,s.jsxs)(Y.J2,{open:c,onOpenChange:u,children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsxs)(p.z,{variant:"outline",role:"combobox","aria-expanded":c,className:"w-full sm:w-[180px] justify-between text-left font-normal",children:[(0,s.jsx)("span",{className:"truncate",children:t?t.split(".").join(" → "):"Select field"}),(0,s.jsx)(J.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,s.jsx)(Y.yk,{className:"w-[280px] p-1",align:"start",onWheel:e=>{e.stopPropagation()},children:(0,s.jsx)(X.x,{className:"h-[300px]",children:h.map(e=>g(e))})})]})},ej=e=>{let{fields:l,onApply:t,initialFilters:n=[],collectionName:r}=e,{getFieldsByCollection:i}=(0,d.I_)(),[o,c]=(0,a.useState)(r),[u,h]=(0,a.useState)("builder"),[x,f]=(0,a.useState)("{}"),[v,j]=(0,a.useState)(""),[y,N]=(0,a.useState)({logic:"and",conditions:[{field:"",operator:"",value:void 0}]});(0,a.useEffect)(()=>{r&&r!==o&&(N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),c(r))},[r,o]);let b=(0,a.useCallback)(e=>{if(!e)return null;if(e.includes(".")){let t=e.split("."),s=l,a=null;for(let e=0;e<t.length;e++){let l=t[e];if(!(a=s.find(e=>e.name===l)))return null;if(a.relType&&a.target&&e<t.length-1){let e=i(a.target);if(!e)return null;s=Object.entries(e).map(e=>{let[l,t]=e;return{name:l,...t}})}}return a}return l.find(l=>l.name===e)},[l,i]),C=(0,a.useCallback)(e=>e&&0!==e.length?1===e.length&&"operator"in e[0]&&("and"===e[0].operator||"or"===e[0].operator)&&Array.isArray(e[0].value)?{logic:e[0].operator,conditions:e[0].value.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:"operator"in e&&("and"===e.operator||"or"===e.operator)&&Array.isArray(e.value)?{logic:e.operator,conditions:e.value.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:"operator"in e&&("and"===e.operator||"or"===e.operator)&&Array.isArray(e.value)?C([e]):{field:"",operator:"",value:void 0})}:{field:"",operator:"",value:void 0})}:{logic:"and",conditions:e.map(e=>"field"in e?{field:e.field,operator:e.operator,value:e.value}:{field:"",operator:"",value:void 0})}:{logic:"and",conditions:[{field:"",operator:"",value:void 0}]},[]);(0,a.useEffect)(()=>{n.length>0?N(C(n)):N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]})},[n,C]);let S=(0,a.useCallback)(e=>{if(!e||!e.conditions||0===e.conditions.length)return[];let l=e.conditions.filter(e=>eg(e)?e.field&&e.operator&&(ei.includes(e.operator)||void 0!==e.value):S(e).length>0);if(0===l.length)return[];if(1===l.length&&eg(l[0])){let e=l[0],t=b(e.field);return[{field:e.field,operator:e.operator,value:em(e.value,e.operator,t)}]}return[{operator:e.logic,value:l.map(e=>{if(eg(e)){let l=b(e.field);return{field:e.field,operator:e.operator,value:em(e.value,e.operator,l)}}{let l=S(e);return 1===l.length?l[0]:{operator:"and",value:[]}}})}]},[b]);(0,a.useEffect)(()=>{if("json"===u){let e=S(y);f(JSON.stringify((0,m.gm)(e),null,2)),j("")}},[y,u,S]);let k=e=>{f(e);try{JSON.parse(e),j("")}catch(e){j("Invalid JSON format")}},T=()=>{try{let e=JSON.parse(x),l=(0,m.LR)(e);j(""),t(l)}catch(e){j("Invalid JSON format")}},D=e=>JSON.parse(JSON.stringify(e)),A=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=D(y),t=l;for(let l=0;l<e.length;l++){let s=e[l];if(eg(t.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}t=t.conditions[s]}t.conditions.push({field:"",operator:"",value:void 0}),N(l)},I=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=D(y),t=l;for(let l=0;l<e.length;l++){let s=e[l];if(eg(t.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}t=t.conditions[s]}t.conditions.push({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),N(l)},E=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,t=D(y),s=t;for(let l=0;l<e.length;l++){let t=e[l];if(eg(s.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}s=s.conditions[t]}if(s.conditions.splice(l,1),0===s.conditions.length){if(0===e.length)s.conditions.push({field:"",operator:"",value:void 0});else{let l=t;for(let t=0;t<e.length-1;t++){let s=e[t];eg(l.conditions[s])||(l=l.conditions[s])}l.conditions.splice(e[e.length-1],1),0===l.conditions.length&&l.conditions.push({field:"",operator:"",value:void 0})}}N(t)},O=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(0===e.length)return;let l=D(y),t=l;for(let l=0;l<e.length-1;l++){let s=e[l];if(eg(t.conditions[s])){console.error("Invalid path: expected a group but found a condition");return}t=t.conditions[s]}t.conditions.splice(e[e.length-1],1),0===t.conditions.length&&t.conditions.push({field:"",operator:"",value:void 0}),N(l)},F=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,t=D(y),s=t;for(let l=0;l<e.length;l++){let t=e[l];if(eg(s.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}s=s.conditions[t]}s.logic=l,N(t)},Z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0,s=D(y),a=s;for(let l=0;l<e.length;l++){let t=e[l];if(eg(a.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[t]}let n=a.conditions[l];eg(n)&&(n.field=t,n.operator="",n.value=void 0),N(s)},M=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0,s=D(y),a=s;for(let l=0;l<e.length;l++){let t=e[l];if(eg(a.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[t]}let n=a.conditions[l];eg(n)&&(n.operator=t,ei.includes(t)?n.value=!0:n.value=void 0),N(s)},z=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],l=arguments.length>1?arguments[1]:void 0,t=arguments.length>2?arguments[2]:void 0,s=D(y),a=s;for(let l=0;l<e.length;l++){let t=e[l];if(eg(a.conditions[t])){console.error("Invalid path: expected a group but found a condition");return}a=a.conditions[t]}let n=a.conditions[l];eg(n)&&(n.value=t),N(s)},P=function(e,t){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=b(e.field),i=n?eu(n):[];return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center gap-2 mb-2 p-2 sm:p-0 bg-muted/30 sm:bg-transparent rounded-lg",children:[(0,s.jsx)("div",{className:"relative w-full sm:w-auto",children:(0,s.jsx)(ev,{fields:l,value:e.field||"",onChange:e=>Z(a,t,e),collectionName:r})}),(0,s.jsxs)(w.Ph,{value:e.operator||"",onValueChange:e=>M(a,t,e),disabled:!e.field,children:[(0,s.jsx)(w.i4,{className:"w-full sm:w-[180px]",children:(0,s.jsx)(w.ki,{placeholder:"Select operator"})}),(0,s.jsx)(w.Bw,{children:i.map(e=>(0,s.jsx)(w.Ql,{value:e.value,children:e.label},e.value))})]}),e.field&&e.operator&&!ei.includes(e.operator)&&(0,s.jsx)("div",{className:"w-full sm:w-auto sm:min-w-[180px]",children:ef(n,e.operator,e.value,e=>z(a,t,e))}),(0,s.jsx)(p.z,{type:"button",variant:"ghost",size:"icon",onClick:()=>E(a,t),className:"text-muted-foreground hover:text-destructive self-end sm:self-auto",children:(0,s.jsx)(V.Z,{className:"h-4 w-4"})})]},"condition-".concat(a.join("-"),"-").concat(t))},L=function(e){let l=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],t=0===l.length;return(0,s.jsxs)(g.Zb,{className:"".concat(t?"":"ml-4 border-l-2 border-l-primary/30"),children:[(0,s.jsx)(g.Ol,{className:"py-3 px-4",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(g.ll,{className:"text-sm font-medium",children:t?"Filter Conditions":"Nested Group"}),(0,s.jsxs)(w.Ph,{value:e.logic,onValueChange:e=>F(l,e),children:[(0,s.jsx)(w.i4,{className:"w-[80px] h-8",children:(0,s.jsx)(w.ki,{})}),(0,s.jsxs)(w.Bw,{children:[(0,s.jsx)(w.Ql,{value:"and",children:"AND"}),(0,s.jsx)(w.Ql,{value:"or",children:"OR"})]})]}),!t&&(0,s.jsx)(p.z,{type:"button",variant:"ghost",size:"icon",onClick:()=>O(l),className:"text-destructive hover:text-destructive",children:(0,s.jsx)(B.Z,{className:"h-4 w-4"})})]})}),(0,s.jsxs)(g.aY,{className:"py-2 px-4",children:[e.conditions.map((e,t)=>eg(e)?P(e,t,l):L(e,[...l,t])),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-2",children:[(0,s.jsxs)(p.z,{type:"button",variant:"outline",size:"sm",onClick:()=>A(l),children:[(0,s.jsx)(_.Z,{className:"h-4 w-4 mr-1"}),"Add Condition"]}),(0,s.jsxs)(p.z,{type:"button",variant:"outline",size:"sm",onClick:()=>I(l),children:[(0,s.jsx)(K.Z,{className:"h-4 w-4 mr-1"}),"Add Nested Group"]})]})]})]},"group-".concat(l.join("-")))};return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)(H.mQ,{value:u,onValueChange:e=>{if("json"===e&&"builder"===u){let e=S(y);f(JSON.stringify((0,m.gm)(e),null,2)),j("")}else if("builder"===e&&"json"===u)try{let e=JSON.parse(x),l=(0,m.LR)(e),t=C(l);N(t),j("")}catch(e){}h(e)},children:[(0,s.jsxs)(H.dr,{className:"grid w-full grid-cols-2 max-w-[300px]",children:[(0,s.jsxs)(H.SP,{value:"builder",className:"flex items-center gap-2",children:[(0,s.jsx)(q.Z,{className:"h-4 w-4"}),"Builder"]}),(0,s.jsxs)(H.SP,{value:"json",className:"flex items-center gap-2",children:[(0,s.jsx)(W.Z,{className:"h-4 w-4"}),"JSON"]})]}),(0,s.jsx)(H.nU,{value:"builder",className:"mt-4",children:L(y)}),(0,s.jsx)(H.nU,{value:"json",className:"mt-4",children:(0,s.jsxs)(g.Zb,{children:[(0,s.jsx)(g.Ol,{className:"py-3 px-4",children:(0,s.jsx)(g.ll,{className:"text-sm font-medium",children:"JSON Filter Editor (Baasix Format)"})}),(0,s.jsxs)(g.aY,{className:"py-2 px-4",children:[(0,s.jsx)(G.g,{value:x,onChange:e=>k(e.target.value),placeholder:'{"fieldName": {"eq": "value"}}',className:"font-mono text-sm min-h-[300px]"}),v&&(0,s.jsx)("p",{className:"text-sm text-destructive mt-2",children:v}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground mt-2",children:["Edit filters in Baasix format. Example: ",'{"status": {"eq": "active"}, "AND": [{"price": {"gte": 10}}]}']})]})]})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(p.z,{type:"button",onClick:()=>{"json"===u?T():t(S(y))},children:"Apply Filters"}),(0,s.jsx)(p.z,{type:"button",variant:"outline",onClick:()=>{N({logic:"and",conditions:[{field:"",operator:"",value:void 0}]}),f("{}"),j(""),t([])},children:"Reset"})]})]})},ey=e=>{let{visible:l,onClose:t,formFields:a,onApply:n,initialFilters:r,collectionName:i}=e;return(0,s.jsx)(y.yo,{open:l,onOpenChange:e=>!e&&t(),children:(0,s.jsxs)(y.ue,{className:"w-full sm:w-[600px] sm:max-w-[600px] md:w-[700px] md:max-w-[700px] lg:w-[800px] lg:max-w-[800px] overflow-y-auto",side:"right",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"Advanced Filters"})}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(ej,{fields:a,onApply:e=>{n(e),t()},initialFilters:r,collectionName:i})})]})})};var eN=t(75060);let eb=e=>{let{nodes:l,selectedColumns:t,onSelectionChange:a,level:n=0,expandedNodes:r,onToggleExpand:i}=e,o=e=>e.children&&0!==e.children.length?e.children.flatMap(o):e.disabled?[]:[e.value],c=e=>{if(!e.disabled){if(e.children&&e.children.length>0){let l=o(e);l.every(e=>t.includes(e))?a(t.filter(e=>!l.includes(e))):a(Array.from(new Set([...t,...l])))}else t.includes(e.value)?a(t.filter(l=>l!==e.value)):a([...t,e.value])}},d=e=>{let l=e.split(".");return l[l.length-1].replace(/_/g," ").replace(/([A-Z])/g," $1").trim()};return(0,s.jsx)("div",{className:"space-y-0.5 ".concat(n>0?"ml-4 pl-2 border-l border-muted":""),children:l.map(e=>{let l=e.children&&e.children.length>0,u=r.has(e.key),m=o(e),h=l?m.length>0&&m.every(e=>t.includes(e)):t.includes(e.value),x=l&&m.some(e=>t.includes(e))&&!m.every(e=>t.includes(e));return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[l&&(0,s.jsx)("button",{type:"button",onClick:()=>i(e.key),className:"p-0.5 hover:bg-muted rounded",children:u?(0,s.jsx)(J.Z,{className:"h-3.5 w-3.5"}):(0,s.jsx)(U.Z,{className:"h-3.5 w-3.5"})}),!l&&(0,s.jsx)("span",{className:"w-4"}),(0,s.jsx)(C.X,{id:"export-".concat(e.key),checked:h,disabled:e.disabled&&!l,onCheckedChange:()=>c(e),className:(0,en.cn)(x&&"data-[state=unchecked]:bg-primary/30")}),(0,s.jsxs)(eN._,{htmlFor:"export-".concat(e.key),className:(0,en.cn)("text-sm cursor-pointer flex-1",e.disabled&&!l&&"text-muted-foreground"),children:[d(e.title),l&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),l&&u&&(0,s.jsx)(eb,{nodes:e.children,selectedColumns:t,onSelectionChange:a,level:n+1,expandedNodes:r,onToggleExpand:i})]},e.key)})})},ew=e=>{let{visible:l,onClose:t,exportColumns:n,onExportColumnsChange:r,exportLimit:i,onExportLimitChange:o,exportPage:c,onExportPageChange:d,isExporting:u,onExport:m,columnTreeData:h}=e,[f,v]=(0,a.useState)(new Set),[j,N]=(0,a.useState)("tree");return(0,s.jsx)(y.yo,{open:l,onOpenChange:e=>!e&&t(),children:(0,s.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto flex flex-col",side:"right",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"Export Data"})}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto py-4 space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{className:"text-base font-semibold",children:"Select Columns to Export:"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Choose which columns to include in the export. Expand relational fields to access nested columns."}),(0,s.jsxs)(H.mQ,{value:j,onValueChange:e=>N(e),children:[(0,s.jsxs)(H.dr,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(H.SP,{value:"tree",children:"Tree Selection"}),(0,s.jsx)(H.SP,{value:"json",children:"JSON"})]}),(0,s.jsx)(H.nU,{value:"tree",className:"mt-2",children:(0,s.jsx)(g.Zb,{className:"max-h-[300px] overflow-y-auto",children:(0,s.jsx)(g.aY,{className:"p-3",children:h.length>0?(0,s.jsx)(eb,{nodes:h,selectedColumns:n,onSelectionChange:r,expandedNodes:f,onToggleExpand:e=>{v(l=>{let t=new Set(l);return t.has(e)?t.delete(e):t.add(e),t})}}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground py-2",children:"No columns available"})})})}),(0,s.jsxs)(H.nU,{value:"json",className:"mt-2",children:[(0,s.jsx)(x.mq,{value:n,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?r(e):null===e&&r([])},placeholder:'["id", "name", "user.email"]'}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:'Enter column names as a JSON array. Use dot notation for nested fields (e.g., "user.name").'})]})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{className:"text-base font-semibold",children:"Export Limits:"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{htmlFor:"exportLimit",children:"Number of Records"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ee.I,{id:"exportLimit",type:"number",value:-1===i?"":i,onChange:e=>{let l=e.target.value;o(""===l?-1:parseInt(l)||0),(""===l||-1===parseInt(l))&&d(1)},placeholder:"Enter number of records",className:"flex-1"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(C.X,{id:"allRecords",checked:-1===i,onCheckedChange:e=>{e&&(o(-1),d(1))}}),(0,s.jsx)(eN._,{htmlFor:"allRecords",className:"text-sm",children:"All Records"})]})]})]}),-1!==i&&i>0&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{htmlFor:"exportPage",children:"Page Number"}),(0,s.jsx)(ee.I,{id:"exportPage",type:"number",min:1,value:c,onChange:e=>d(parseInt(e.target.value)||1),placeholder:"Enter page number"}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Records ",(c-1)*i+1," to ",c*i," will be exported"]})]})]})]}),(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-4",children:[(0,s.jsx)(eN._,{className:"text-base font-semibold",children:"Export Summary:"}),(0,s.jsxs)("div",{className:"mt-2 space-y-1 text-sm",children:[(0,s.jsxs)("p",{children:["• Columns: ",n.length," selected"]}),(0,s.jsxs)("p",{children:["• Records: ",-1===i?"All records":"".concat(i," records from page ").concat(c)]}),(0,s.jsx)("p",{children:"• Format: CSV"})]})]})})]}),(0,s.jsxs)(y.FF,{className:"pt-4 border-t",children:[(0,s.jsx)(p.z,{variant:"outline",onClick:t,children:"Cancel"}),(0,s.jsx)(p.z,{onClick:m,disabled:0===n.length||u,children:u?"Exporting...":"Export"})]})]})})};var eC=t(48736),eS=t(49322),ek=t(32489),eT=t(14438),eD=t(95937),eA=t(81853);let eI=e=>{var l,t,n,i,o;let{visible:c,onClose:u,selectedCollection:m,onImportComplete:h}=e,[x,f]=(0,a.useState)("csv"),[v,j]=(0,a.useState)([]),[N,b]=(0,a.useState)(void 0),[C,S]=(0,a.useState)(!1),k=(0,r.Ji)(),{mutate:T,isLoading:D}=(0,r.uC)(),{isMultiTenant:A}=(0,eA.PY)(),{getFieldsByCollection:_}=(0,d.I_)(),E=(0,a.useMemo)(()=>{let e=_(m);return!!e&&"tenant_Id"in e},[m,_]),O=A&&E,{data:F,isLoading:Z}=(0,r.sm)({resource:"baasix_Tenant",queryOptions:{enabled:A&&E}}),M=(0,a.useCallback)(e=>{f(e),j([])},[]),z=(0,a.useCallback)(e=>("csv"===x?"text/csv"===e.type||e.name.toLowerCase().endsWith(".csv"):"application/json"===e.type||e.name.toLowerCase().endsWith(".json"))?e.size/1024/1024<50||(eT.Am.error("File must be smaller than 50MB"),!1):(eT.Am.error("Please upload a valid ".concat(x.toUpperCase()," file")),!1),[x]),P=(0,a.useCallback)(e=>{if(!e||0===e.length)return;let l=e[0];z(l)&&j([l])},[z]),B=(0,a.useCallback)(e=>{e.preventDefault(),S(!1),P(e.dataTransfer.files)},[P]),L=(0,a.useCallback)(e=>{e.preventDefault(),S(!0)},[]),U=(0,a.useCallback)(e=>{e.preventDefault(),S(!1)},[]),R=(0,a.useCallback)(()=>{if(0===v.length){eT.Am.error("Please select a file to import");return}if(O&&!N){eT.Am.error("Please select a tenant for this tenant-enabled collection");return}let e=v[0],l=new FormData;"csv"===x?l.append("csvFile",e):l.append("jsonFile",e),N&&l.append("tenant",N);let t="csv"===x?"items/".concat(m,"/import-csv"):"items/".concat(m,"/import-json");T({url:"".concat(k,"/").concat(t),method:"post",values:l},{onSuccess:e=>{var l;eT.Am.success("Successfully imported ".concat((null==e?void 0:null===(l=e.results)||void 0===l?void 0:l.imported)||0," items")),h(),u(),j([])},onError:e=>{var l,t,s,a,n,r,i,o,c;console.error("Import error:",e);let d="Import failed";if((null==e?void 0:null===(s=e.response)||void 0===s?void 0:null===(t=s.data)||void 0===t?void 0:null===(l=t.error)||void 0===l?void 0:l.message)?d=e.response.data.error.message:(null==e?void 0:e.message)&&(d=e.message),(null==e?void 0:null===(c=e.response)||void 0===c?void 0:null===(o=c.data)||void 0===o?void 0:null===(i=o.error)||void 0===i?void 0:null===(r=i.details)||void 0===r?void 0:null===(n=r.results)||void 0===n?void 0:null===(a=n.errors)||void 0===a?void 0:a.length)>0){let l=e.response.data.error.details.results.errors.length;d+=". ".concat(l," rows had errors.")}eT.Am.error(d)}})},[v,x,m,h,u,k,T,O,N]),J=(0,a.useCallback)(()=>{j([])},[]),V=(0,a.useCallback)(()=>"csv"===x?{title:"CSV Example",content:'name,email,age,tags,metadata\n"John Doe","john@example.com",30,"[""admin"", ""user""]","{""department"": ""IT""}"\n"Jane Smith","jane@example.com",25,"[""user""]","{""department"": ""HR""}"',description:"CSV files should have headers in the first row. JSON fields should be properly escaped strings."}:{title:"JSON Example",content:'[\n {\n "name": "John Doe",\n "email": "john@example.com", \n "age": 30,\n "tags": ["admin", "user"],\n "metadata": {"department": "IT"}\n },\n {\n "name": "Jane Smith",\n "email": "jane@example.com",\n "age": 25, \n "tags": ["user"],\n "metadata": {"department": "HR"}\n }\n]',description:"JSON files should contain an array of objects. Each object represents a record to import."},[x])();return(0,s.jsx)(y.yo,{open:c,onOpenChange:e=>!e&&u(),children:(0,s.jsxs)(y.ue,{className:"w-[700px] sm:max-w-[700px] overflow-y-auto flex flex-col",side:"right",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"Import Data"})}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto py-4 space-y-6",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{className:"text-base font-semibold",children:"Select Import Format:"}),(0,s.jsx)(H.mQ,{value:x,onValueChange:M,children:(0,s.jsxs)(H.dr,{className:"grid w-full grid-cols-2",children:[(0,s.jsxs)(H.SP,{value:"csv",className:"flex items-center gap-2",children:[(0,s.jsx)(eC.Z,{className:"h-4 w-4"}),"CSV File"]}),(0,s.jsxs)(H.SP,{value:"json",className:"flex items-center gap-2",children:[(0,s.jsx)(W.Z,{className:"h-4 w-4"}),"JSON File"]})]})})]}),A&&E&&(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(eN._,{className:"text-base font-semibold",children:["Select Tenant",O?" (Required)":" (Optional)",":"]}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:O?"This collection is tenant-enabled. Please select a tenant to import data into.":"Leave empty to import into your current tenant context. Select a specific tenant to import data into that tenant."}),(0,s.jsxs)(w.Ph,{value:N||"",onValueChange:e=>b(e||void 0),children:[(0,s.jsx)(w.i4,{className:O&&!N?"border-destructive":"",children:(0,s.jsx)(w.ki,{placeholder:Z?"Loading...":O?"Select tenant (required)":"Select tenant (optional)"})}),(0,s.jsx)(w.Bw,{children:null==F?void 0:null===(l=F.data)||void 0===l?void 0:l.map(e=>(0,s.jsx)(w.Ql,{value:e.id,children:e.name},e.id))})]})]}),(0,s.jsxs)(eD.bZ,{children:[(0,s.jsx)(eS.Z,{className:"h-4 w-4"}),(0,s.jsx)(eD.Cd,{children:"Important Notes"}),(0,s.jsx)(eD.X,{children:(0,s.jsxs)("ul",{className:"list-disc list-inside mt-2 space-y-1 text-sm",children:[(0,s.jsx)("li",{children:"The import will create new records in the selected collection"}),(0,s.jsx)("li",{children:"If any record fails validation, the entire import will be rolled back"}),(0,s.jsx)("li",{children:"JSON fields should be properly formatted (arrays and objects)"}),(0,s.jsx)("li",{children:"Relational data can be created by providing nested objects"}),(0,s.jsx)("li",{children:"Maximum file size: 50MB"})]})})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)(eN._,{className:"text-base font-semibold",children:["Upload ",x.toUpperCase()," File:"]}),0===v.length?(0,s.jsxs)("div",{className:"border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ".concat(C?"border-primary bg-primary/5":"border-muted-foreground/25 hover:border-primary/50"),onDrop:B,onDragOver:L,onDragLeave:U,onClick:()=>{let e=document.createElement("input");e.type="file",e.accept="csv"===x?".csv,text/csv":".json,application/json",e.onchange=e=>{P(e.target.files)},e.click()},children:[(0,s.jsx)(I.Z,{className:"h-10 w-10 mx-auto text-muted-foreground mb-4"}),(0,s.jsxs)("p",{className:"text-sm font-medium",children:["Click or drag ",x.toUpperCase()," file to this area to upload"]}),(0,s.jsxs)("p",{className:"text-sm text-muted-foreground mt-1",children:["Support for single ",x.toUpperCase()," file upload"]})]}):(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-4 flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:["csv"===x?(0,s.jsx)(eC.Z,{className:"h-8 w-8 text-green-600"}):(0,s.jsx)(W.Z,{className:"h-8 w-8 text-blue-600"}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"font-medium text-sm",children:v[0].name}),(0,s.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(v[0].size/1024/1024).toFixed(2)," MB"]})]})]}),(0,s.jsx)(p.z,{variant:"ghost",size:"icon",onClick:J,children:(0,s.jsx)(ek.Z,{className:"h-4 w-4"})})]})})]}),(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-4",children:[(0,s.jsx)("h4",{className:"font-semibold mb-2",children:V.title}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground mb-3",children:V.description}),(0,s.jsx)("pre",{className:"bg-muted p-3 rounded text-xs overflow-x-auto max-h-[200px]",children:V.content})]})}),v.length>0&&(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-4",children:[(0,s.jsx)(eN._,{className:"text-base font-semibold",children:"Import Summary:"}),(0,s.jsxs)("div",{className:"mt-2 space-y-1 text-sm",children:[(0,s.jsxs)("p",{children:["• Collection: ",m]}),(0,s.jsxs)("p",{children:["• File: ",null===(t=v[0])||void 0===t?void 0:t.name]}),(0,s.jsxs)("p",{children:["• Size: ",((null===(n=v[0])||void 0===n?void 0:n.size)/1024/1024).toFixed(2)," MB"]}),(0,s.jsxs)("p",{children:["• Format: ",x.toUpperCase()]}),A&&E&&(0,s.jsxs)("p",{children:["• Tenant:"," ",N?(null==F?void 0:null===(o=F.data)||void 0===o?void 0:null===(i=o.find(e=>e.id===N))||void 0===i?void 0:i.name)||N:(0,s.jsx)("span",{className:O?"text-destructive":"",children:O?"Not selected (required)":"Current tenant context"})]})]})]})})]}),(0,s.jsxs)(y.FF,{className:"pt-4 border-t",children:[(0,s.jsx)(p.z,{variant:"outline",onClick:u,children:"Cancel"}),(0,s.jsx)(p.z,{onClick:R,disabled:0===v.length||D||O&&!N,children:D?"Importing...":"Import Data"})]})]})})};var e_=t(45675),eE=t(29501),eO=t(33245),eF=t(30401),eZ=t(71488);let eM=["id","createdAt","updatedAt","deletedAt","userCreated_Id","userUpdated_Id","userDeleted_Id","userCreated","userUpdated","userDeleted"],ez=e=>{let{visible:l,onClose:t,selectedRows:n,selectedCollection:i,onSuccess:o}=e,{getFieldsByCollection:c}=(0,d.I_)(),[u,m]=(0,a.useState)([]),[h,f]=(0,a.useState)(!1),{mutate:g}=(0,r.e)(),{register:v,handleSubmit:j,setValue:y,watch:b,reset:w,formState:{errors:S}}=(0,eE.cI)({defaultValues:{}}),k=(0,a.useMemo)(()=>{let e=c(i);return e?Object.entries(e).filter(e=>{var l,t;let[s,a]=e;return!eM.includes(s)&&!a.primaryKey&&(null===(l=a.defaultValue)||void 0===l?void 0:l.type)!=="AUTOINCREMENT"&&(null===(t=a.defaultValue)||void 0===t?void 0:t.type)!=="UUIDV4"&&!a.virtual&&!a.relType}).map(e=>{let[l,t]=e;return{name:l,...t}}):[]},[i,c]);(0,a.useEffect)(()=>{l||(m([]),w({}))},[l,w]);let T=(e,l)=>{l?m(l=>[...l,e]):(m(l=>l.filter(l=>l!==e)),y(e,void 0))},D=async e=>{if(0===u.length){eT.Am.error("Please select at least one field to update");return}f(!0);let l=n.map(e=>e.id),s={};for(let l of u)void 0!==e[l]&&(s[l]=e[l]);if(0===Object.keys(s).length){eT.Am.error("Please provide values for the selected fields"),f(!1);return}try{await new Promise((e,t)=>{g({resource:i,ids:l,values:s},{onSuccess:()=>e(),onError:e=>t(e)})}),eT.Am.success("".concat(n.length," items updated successfully")),o(),t()}catch(e){console.error("Bulk update error:",e),eT.Am.error((null==e?void 0:e.message)||"Failed to update items")}finally{f(!1)}},A=e=>{var l,t;let a=e.name,n=b(a),r=(null===(l=e.type)||void 0===l?void 0:l.toLowerCase())||"string",i=!u.includes(a);if("enum"===r){let l=e.values||[];return(0,s.jsx)(x.o_,{value:n,onChange:e=>y(a,e),options:l,allowNull:!1!==e.allowNull,disabled:i,placeholder:"Select ".concat(e.name,"...")})}return"boolean"===r?(0,s.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,s.jsx)(el.r,{checked:n||!1,onCheckedChange:e=>y(a,e),disabled:i}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:n?"True":"False"})]}):["integer","bigint","float","decimal","double","real"].includes(r)?(0,s.jsx)(ee.I,{type:"number",...v(a,{valueAsNumber:!0}),disabled:i,placeholder:"Enter ".concat(e.name,"..."),step:["float","decimal","double","real"].includes(r)?"0.01":"1"}):["json","jsonb"].includes(r)?(0,s.jsx)(x.mq,{value:n,onChange:e=>y(a,e),disabled:i}):"array"===r?(0,s.jsx)(x.OF,{value:n||[],onChange:e=>y(a,e),itemType:(null===(t=e.values)||void 0===t?void 0:t.type)||"String",disabled:i}):"text"===r?(0,s.jsx)(G.g,{...v(a),disabled:i,placeholder:"Enter ".concat(e.name,"..."),rows:3}):["date","datetime"].includes(r)?(0,s.jsx)(ee.I,{type:"date"===r?"date":"datetime-local",...v(a),disabled:i}):(0,s.jsx)(ee.I,{...v(a),disabled:i,placeholder:"Enter ".concat(e.name,"...")})};return(0,s.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&t(),children:(0,s.jsxs)(N.cZ,{className:"sm:max-w-[600px] max-h-[80vh]",children:[(0,s.jsxs)(N.fK,{children:[(0,s.jsx)(N.$N,{children:"Bulk Edit"}),(0,s.jsxs)(N.Be,{children:["Update ",n.length," selected items. Only the fields you select and fill in will be updated."]})]}),(0,s.jsxs)("form",{onSubmit:j(D),children:[(0,s.jsx)(X.x,{className:"h-[400px] pr-4",children:(0,s.jsxs)("div",{className:"space-y-4 py-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-muted rounded-lg",children:[(0,s.jsx)(eO.Z,{className:"h-4 w-4 text-muted-foreground"}),(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Select the fields you want to update by checking the checkbox next to each field."})]}),0===k.length?(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No editable fields found for this collection."}):k.map(e=>(0,s.jsx)("div",{className:"p-3 border rounded-lg transition-colors ".concat(u.includes(e.name)?"border-primary bg-primary/5":"border-border"),children:(0,s.jsxs)("div",{className:"flex items-start gap-3",children:[(0,s.jsx)(C.X,{id:"field-".concat(e.name),checked:u.includes(e.name),onCheckedChange:l=>T(e.name,l),className:"mt-1"}),(0,s.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(eN._,{htmlFor:"field-".concat(e.name),className:"font-medium cursor-pointer",children:e.name}),(0,s.jsx)(eZ.pn,{children:(0,s.jsxs)(eZ.u,{children:[(0,s.jsx)(eZ.aJ,{asChild:!0,children:(0,s.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-muted rounded text-muted-foreground",children:[e.type,e.relType&&" (".concat(e.relType,")")]})}),(0,s.jsxs)(eZ._v,{children:[(0,s.jsxs)("p",{children:["Field type: ",e.type]}),e.relType&&(0,s.jsxs)("p",{children:["Relation: ",e.relType]}),!1===e.allowNull&&(0,s.jsx)("p",{children:"Required field"})]})]})})]}),(0,s.jsx)("div",{className:u.includes(e.name)?"":"opacity-50",children:A(e)})]})]})},e.name))]})}),(0,s.jsx)(N.cN,{className:"mt-4",children:(0,s.jsxs)("div",{className:"flex items-center justify-between w-full",children:[(0,s.jsxs)("span",{className:"text-sm text-muted-foreground",children:[u.length," field(s) selected"]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.z,{type:"button",variant:"outline",onClick:t,disabled:h,children:"Cancel"}),(0,s.jsx)(p.z,{type:"submit",disabled:h||0===u.length,children:h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(M.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Updating..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eF.Z,{className:"mr-2 h-4 w-4"}),"Update ",n.length," Items"]})})]})]})})]})]})})},eP=e=>{let{visible:l,onClose:t,selectedRows:n,selectedCollection:i,onClearSelection:o,customActions:c}=e,[d,u]=(0,a.useState)(!1),[m,h]=(0,a.useState)(!1),[x,f]=(0,a.useState)(!1),{mutate:g}=(0,r.F2)();(0,a.useEffect)(()=>{l||(u(!1),h(!1),f(!1))},[l]);let v=async()=>{f(!0);let e=n.length,l=n.map(e=>e.id);try{await new Promise((e,t)=>{g({resource:i,ids:l},{onSuccess:()=>e(),onError:e=>t(e)})}),eT.Am.success("".concat(e," items deleted successfully")),f(!1),u(!1),o(),t()}catch(e){console.error("Bulk delete error:",e),eT.Am.error((null==e?void 0:e.message)||"Failed to delete items"),f(!1)}};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&t(),children:(0,s.jsxs)(N.cZ,{className:"sm:max-w-[500px]",children:[(0,s.jsxs)(N.fK,{children:[(0,s.jsx)(N.$N,{children:"Bulk Actions"}),(0,s.jsxs)(N.Be,{children:[n.length," items selected. Choose an action to perform on all selected items."]})]}),(0,s.jsxs)("div",{className:"space-y-3 py-4",children:[(0,s.jsxs)(p.z,{variant:"destructive",className:"w-full justify-start gap-2",onClick:()=>u(!0),children:[(0,s.jsx)(B.Z,{className:"h-4 w-4"}),"Delete Selected (",n.length,")"]}),(0,s.jsxs)(p.z,{variant:"outline",className:"w-full justify-start gap-2",onClick:()=>{h(!0)},children:[(0,s.jsx)(e_.Z,{className:"h-4 w-4"}),"Edit Selected (",n.length,")"]}),null==c?void 0:c.map((e,l)=>(0,s.jsxs)(p.z,{variant:e.variant||"outline",className:"w-full justify-start gap-2",onClick:()=>e.onClick(n),disabled:e.disabled,children:[e.icon,e.label," (",n.length,")"]},l))]}),(0,s.jsx)(N.cN,{children:(0,s.jsx)(p.z,{variant:"outline",onClick:t,children:"Cancel"})})]})}),(0,s.jsx)(N.Vq,{open:d,onOpenChange:e=>{x||e||u(!1)},children:(0,s.jsxs)(N.cZ,{children:[(0,s.jsxs)(N.fK,{children:[(0,s.jsx)(N.$N,{children:"Delete Selected Items"}),(0,s.jsxs)(N.Be,{children:["Are you sure you want to delete ",n.length," items? This action cannot be undone."]})]}),(0,s.jsxs)(N.cN,{children:[(0,s.jsx)(p.z,{type:"button",variant:"outline",onClick:()=>u(!1),disabled:x,children:"Cancel"}),(0,s.jsx)(p.z,{type:"button",variant:"destructive",onClick:v,disabled:x,children:x?"Deleting...":"Delete"})]})]})}),(0,s.jsx)(ez,{visible:m,onClose:()=>h(!1),selectedRows:n,selectedCollection:i,onSuccess:()=>{o(),t()}})]})},eB=e=>{let{nodes:l,selectedColumns:t,onSelectionChange:a,level:n=0,expandedNodes:r,onToggleExpand:i}=e,o=e=>{if(!e.disabled){if(t.includes(e.value)){let l=e.value+".";a(t.filter(t=>t!==e.value&&!t.startsWith(l)))}else a([...t,e.value])}},c=e=>e.children&&0!==e.children.length?e.children.flatMap(c):e.disabled?[]:[e.value],d=e=>{let l=e.split(".");return l[l.length-1].replace(/_/g," ").replace(/([A-Z])/g," $1").trim()};return(0,s.jsx)("div",{className:"space-y-0.5 ".concat(n>0?"ml-4 pl-2 border-l border-muted":""),children:l.map(e=>{let l=e.children&&e.children.length>0,c=r.has(e.key),u=t.includes(e.value),m=e.value+".",h=l&&t.some(e=>e.startsWith(m)),x=l&&h&&!u;return(0,s.jsxs)("div",{children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 py-1 hover:bg-muted/50 rounded px-1",children:[l&&(0,s.jsx)("button",{type:"button",onClick:()=>i(e.key),className:"p-0.5 hover:bg-muted rounded",children:c?(0,s.jsx)(J.Z,{className:"h-3.5 w-3.5"}):(0,s.jsx)(U.Z,{className:"h-3.5 w-3.5"})}),!l&&(0,s.jsx)("span",{className:"w-4"}),(0,s.jsx)(C.X,{id:"col-".concat(e.key),checked:u,disabled:e.disabled,onCheckedChange:()=>o(e),className:(0,en.cn)(x&&"data-[state=unchecked]:bg-primary/30")}),(0,s.jsxs)(eN._,{htmlFor:"col-".concat(e.key),className:(0,en.cn)("text-sm cursor-pointer flex-1",e.disabled&&"text-muted-foreground"),children:[d(e.title),l&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-1",children:"(relation)"})]})]}),l&&c&&(0,s.jsx)(eB,{nodes:e.children,selectedColumns:t,onSelectionChange:a,level:n+1,expandedNodes:r,onToggleExpand:i})]},e.key)})})},eL=e=>{let{visible:l,onClose:t,tableDensity:n,onTableDensityChange:r,visibleColumns:i,onVisibleColumnsChange:o,columnTreeData:c}=e,[d,u]=(0,a.useState)(new Set),[m,h]=(0,a.useState)("tree");return(0,s.jsx)(N.Vq,{open:l,onOpenChange:e=>!e&&t(),children:(0,s.jsxs)(N.cZ,{className:"sm:max-w-[500px] max-h-[80vh] flex flex-col",children:[(0,s.jsxs)(N.fK,{children:[(0,s.jsx)(N.$N,{children:"Column Settings"}),(0,s.jsx)(N.Be,{children:"Customize your table display preferences."})]}),(0,s.jsxs)("div",{className:"space-y-6 py-4 flex-1 overflow-y-auto",children:[(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{className:"text-sm font-semibold",children:"Table Density"}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)(p.z,{size:"sm",variant:"small"===n?"default":"outline",onClick:()=>r("small"),className:(0,en.cn)("small"===n&&"bg-primary text-primary-foreground"),children:"Compact"}),(0,s.jsx)(p.z,{size:"default",variant:"middle"===n?"default":"outline",onClick:()=>r("middle"),className:(0,en.cn)("middle"===n&&"bg-primary text-primary-foreground"),children:"Default"}),(0,s.jsx)(p.z,{size:"lg",variant:"large"===n?"default":"outline",onClick:()=>r("large"),className:(0,en.cn)("large"===n&&"bg-primary text-primary-foreground"),children:"Comfortable"})]})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsx)(eN._,{className:"text-sm font-semibold",children:"Visible Columns"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select columns to display. Expand relational fields to access nested columns."}),(0,s.jsxs)(H.mQ,{value:m,onValueChange:e=>h(e),children:[(0,s.jsxs)(H.dr,{className:"grid w-full grid-cols-2",children:[(0,s.jsx)(H.SP,{value:"tree",children:"Tree Selection"}),(0,s.jsx)(H.SP,{value:"json",children:"JSON"})]}),(0,s.jsx)(H.nU,{value:"tree",className:"mt-2",children:(0,s.jsx)(g.Zb,{className:"max-h-[250px] overflow-y-auto",children:(0,s.jsx)(g.aY,{className:"p-3",children:c.length>0?(0,s.jsx)(eB,{nodes:c,selectedColumns:i,onSelectionChange:o,expandedNodes:d,onToggleExpand:e=>{u(l=>{let t=new Set(l);return t.has(e)?t.delete(e):t.add(e),t})}}):(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"No columns available"})})})}),(0,s.jsxs)(H.nU,{value:"json",className:"mt-2",children:[(0,s.jsx)(x.mq,{value:i,onChange:e=>{Array.isArray(e)&&e.every(e=>"string"==typeof e)?o(e):null===e&&o([])},placeholder:'["id", "name", "user.email"]'}),(0,s.jsx)("p",{className:"text-xs text-muted-foreground mt-1",children:"Enter column names as a JSON array. Use dot notation for nested fields."})]})]})]})]}),(0,s.jsx)(N.cN,{children:(0,s.jsx)(p.z,{variant:"outline",onClick:t,children:"Close"})})]})})};var eU=t(92322),eR=t(2596),eJ=t(24156);let eV=e=>{let{value:l,field:t,onSave:n,onCancel:r,isLoading:i=!1}=e,[o,c]=(0,a.useState)(l),[d,u]=(0,a.useState)(""),m=(0,a.useRef)(null),h=(0,a.useRef)(null),x=(0,a.useRef)(l);(0,a.useEffect)(()=>{m.current&&(m.current.focus(),m.current.select())},[]);let f=(0,a.useCallback)(e=>null===x.current||void 0===x.current?null!=e&&""!==e:null==e||""===e?null!==x.current&&void 0!==x.current&&""!==x.current:String(x.current)!==String(e),[]),g=(0,a.useCallback)(e=>{f(e)?n(e):r()},[f,n,r]),v=(0,a.useCallback)(e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key?(e.preventDefault(),r()):"Tab"===e.key&&(e.preventDefault(),g(o)):(e.preventDefault(),g(o))},[o,g,r]),j=(0,a.useCallback)(e=>{var l;null!==(l=h.current)&&void 0!==l&&l.contains(e.relatedTarget)||g(o)},[o,g]);if("Boolean"===t.type||"BOOLEAN"===t.type)return(0,s.jsx)("div",{ref:h,className:"flex items-center justify-center h-full",onKeyDown:v,tabIndex:0,onBlur:j,children:i?(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"}):(0,s.jsx)(C.X,{checked:!!o,onCheckedChange:e=>{c(e),!!x.current!=!!e?n(e):r()},autoFocus:!0})});if(("Enum"===t.type||"ENUM"===t.type)&&t.values&&t.values.length>0){let e=t.values||[],l=d.trim()?e.filter(e=>e.toLowerCase().includes(d.toLowerCase())):e,a=d.trim()&&!e.some(e=>e.toLowerCase()===d.trim().toLowerCase()),m=e=>{c(e),u(""),String(x.current||"")!==String(e||"")?n(e):r()},f=()=>{if(d.trim()){let e=d.trim();c(e),u(""),String(x.current||"")!==String(e||"")?n(e):r()}};return(0,s.jsx)("div",{ref:h,className:"w-full",onKeyDown:v,children:i?(0,s.jsx)("div",{className:"flex items-center justify-center h-8",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}):(0,s.jsxs)(Y.J2,{open:!0,onOpenChange:e=>!e&&r(),children:[(0,s.jsx)(Y.xo,{asChild:!0,children:(0,s.jsxs)(p.z,{variant:"outline",role:"combobox",className:"h-8 w-full justify-between text-sm font-normal",children:[o||"Select...",(0,s.jsx)(eJ.Z,{className:"ml-2 h-4 w-4 shrink-0 opacity-50"})]})}),(0,s.jsx)(Y.yk,{className:"w-[200px] p-0",align:"start",children:(0,s.jsxs)(eR.mY,{shouldFilter:!1,children:[(0,s.jsx)(eR.sZ,{placeholder:"Search or type custom...",value:d,onValueChange:u}),(0,s.jsxs)(eR.e8,{children:[(0,s.jsx)(eR.rb,{children:d.trim()?(0,s.jsxs)("button",{onClick:f,className:"flex w-full items-center gap-2 px-2 py-1.5 text-sm hover:bg-accent rounded cursor-pointer",children:[(0,s.jsx)(_.Z,{className:"h-4 w-4"}),'Add "',d.trim(),'"']}):"No options found."}),(0,s.jsxs)(eR.fu,{children:[t.allowNull&&(0,s.jsxs)(eR.di,{value:"",onSelect:()=>m(""),children:[(0,s.jsx)(eF.Z,{className:(0,en.cn)("mr-2 h-4 w-4",o?"opacity-0":"opacity-100")}),(0,s.jsx)("span",{className:"text-muted-foreground italic",children:"None"})]}),l.map(e=>(0,s.jsxs)(eR.di,{value:e,onSelect:()=>m(e),children:[(0,s.jsx)(eF.Z,{className:(0,en.cn)("mr-2 h-4 w-4",o===e?"opacity-100":"opacity-0")}),e]},e))]}),a&&l.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(eR.zz,{}),(0,s.jsx)(eR.fu,{children:(0,s.jsxs)(eR.di,{value:"add-custom-".concat(d),onSelect:f,children:[(0,s.jsx)(_.Z,{className:"mr-2 h-4 w-4"}),'Add "',d.trim(),'"']})})]})]})]})})]})})}return"Number"===t.type||"Integer"===t.type||"INTEGER"===t.type||"INT"===t.type||"BigInt"===t.type||"BIGINT"===t.type||"SMALLINT"===t.type||"TINYINT"===t.type||"Float"===t.type||"FLOAT"===t.type||"Double"===t.type||"DOUBLE"===t.type||"Decimal"===t.type||"DECIMAL"===t.type?(0,s.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}),(0,s.jsx)(ee.I,{ref:m,type:"number",value:null!=o?o:"",onChange:e=>{let l=e.target.value;c(""===l?null:Number(l))},onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"Date"===t.type||"DATEONLY"===t.type?(0,s.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}),(0,s.jsx)(ee.I,{ref:m,type:"date",value:(e=>{if(!e)return"";let l=new Date(e),t=l.getFullYear(),s=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0");return"".concat(t,"-").concat(s,"-").concat(a)})(o),onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"DateTime"===t.type||"DateTime_NO_TZ"===t.type||"DATETIME"===t.type||"TIMESTAMP"===t.type?(0,s.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}),(0,s.jsx)(ee.I,{ref:m,type:"datetime-local",value:(e=>{if(!e)return"";let l=new Date(e),t=l.getFullYear(),s=String(l.getMonth()+1).padStart(2,"0"),a=String(l.getDate()).padStart(2,"0"),n=String(l.getHours()).padStart(2,"0"),r=String(l.getMinutes()).padStart(2,"0");return"".concat(t,"-").concat(s,"-").concat(a,"T").concat(n,":").concat(r)})(o),onChange:e=>{c(e.target.value?new Date(e.target.value).toISOString():null)},onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):"Time"===t.type||"Time_NO_TZ"===t.type?(0,s.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}),(0,s.jsx)(ee.I,{ref:m,type:"time",value:(e=>{if(!e)return"";if("string"==typeof e){let l=e.match(/^(\d{2}):(\d{2})/);if(l)return"".concat(l[1],":").concat(l[2]);if(e.includes("T")){let l=new Date(e),t=String(l.getHours()).padStart(2,"0"),s=String(l.getMinutes()).padStart(2,"0");return"".concat(t,":").concat(s)}}return e})(o),onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]}):(0,s.jsxs)("div",{ref:h,className:"relative w-full",children:[i&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center bg-background/50 z-10",children:(0,s.jsx)(M.Z,{className:"h-4 w-4 animate-spin"})}),(0,s.jsx)(ee.I,{ref:m,type:"text",value:null!=o?o:"",onChange:e=>c(e.target.value||null),onKeyDown:v,onBlur:j,className:"h-8 text-sm",disabled:i})]})},eK=["String","VARCHAR","CHAR","Number","Integer","INTEGER","INT","BigInt","BIGINT","SMALLINT","TINYINT","Float","FLOAT","Double","DOUBLE","Decimal","DECIMAL","Boolean","BOOLEAN","Date","Date_NO_TZ","DATEONLY","DateTime","DateTime_NO_TZ","DATETIME","TIMESTAMP","Time","Time_NO_TZ","Enum","ENUM","Email","URL","Phone"],eq=e=>!e.relType&&!e.primaryKey&&!["createdAt","updatedAt","deletedAt","userCreated","userUpdated","userDeleted","userCreated_Id","userUpdated_Id","userDeleted_Id"].includes(e.name)&&eK.includes(e.type);var eW=t(59892);let eH=e=>{let{id:l,children:t,className:a,onClick:n,disabled:r=!1}=e,{attributes:i,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:h}=(0,o.nB)({id:l,disabled:r}),x={transform:eW.ux.Transform.toString(u),transition:m,opacity:h?.5:1,zIndex:h?1e3:void 0};return r?(0,s.jsx)(v.SC,{className:a,onClick:n,children:t}):(0,s.jsxs)(v.SC,{ref:d,style:x,className:(0,en.cn)(a,h&&"bg-muted shadow-lg"),onClick:n,children:[(0,s.jsx)(v.pj,{className:"w-8 px-2 cursor-grab active:cursor-grabbing",...i,...c,onClick:e=>e.stopPropagation(),children:(0,s.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground hover:text-foreground"})}),t]})};var eG=t(83724);let eY=e=>{let l=e.replace(/\./g," → ").replace(/_/g," ").replace(/([A-Z])/g," $1").trim();return l.charAt(0).toUpperCase()+l.slice(1)},eX=e=>{let{selectedCollection:l,schemaName:t,title:n,hideTitle:J=!1,enableSearch:V=!0,enableFilters:K=!0,enableCreate:q=!0,enableView:W=!1,enableEdit:H=!0,enableDelete:G=!0,enableExport:Y=!0,enableImport:X=!0,enableBulkSelect:Q=!0,enableColumnSettings:$=!0,enableFilePreview:ee=!1,enableInlineEdit:el=!0,headerActions:et,renderRowActions:es,quickFilters:ea,customColumnRenderers:er,defaultVisibleColumns:ei,getDisabledFields:eo,defaultMeta:ec,defaultFilters:ed,permanentFilters:eu,defaultSorters:em,syncSearchWithUrl:eh=!0,onRecordClick:ex,onRefresh:ep,showSelectionColumn:ef=!1,selectionMode:eg="single",externalSelectedRows:ev,onExternalSelectionChange:ej,highlightSelectedRows:eN=!1,customBulkActions:eb}=e,[eC,eS]=(0,a.useState)(()=>{if(eh){let e=new URLSearchParams(window.location.search),t=e.get("collection");if(!t||t===l)return e.get("q")||""}return""}),ek=(0,a.useCallback)(e=>{if(eS(e),eh){let l=new URLSearchParams(window.location.search);e?l.set("q",e):l.delete("q");let t="".concat(window.location.pathname,"?").concat(l.toString());window.history.replaceState(null,"",t)}},[eh]),[eD,eA]=(0,a.useState)(!1),[e_,eE]=(0,a.useState)(!1),[eO,eF]=(0,a.useState)(!1),[eZ,eM]=(0,a.useState)(!1),[ez,eB]=(0,a.useState)(!1),[eR,eJ]=(0,a.useState)(null),[eK,eW]=(0,a.useState)(1),[eX,eQ]=(0,a.useState)(10),[e$,e0]=(0,a.useState)([]),[e1,e2]=(0,a.useState)(ed||[]),e4=(0,a.useCallback)(()=>em&&em.length>0?em:[],[em]),[e5,e3]=(0,a.useState)(e4()),[e8,e7]=(0,a.useState)(!1),[e6,e9]=(0,a.useState)(null),[le,ll]=(0,a.useState)(""),[lt,ls]=(0,a.useState)(""),[la,ln]=(0,a.useState)(!1),[lr,li]=(0,a.useState)(!1),[lo,lc]=(0,a.useState)(!1),[ld,lu]=(0,a.useState)(!1),[lm,lh]=(0,a.useState)([]),[lx,lp]=(0,a.useState)(-1),[lf,lg]=(0,a.useState)(1),[lv,lj]=(0,a.useState)(!1),[ly,lN]=(0,a.useState)("middle"),[lb,lw]=(0,a.useState)(null),[lC,lS]=(0,a.useState)(null),[lk,lT]=(0,a.useState)({}),[lD,lA]=(0,a.useState)(null),[lI,l_]=(0,a.useState)(0),[lE,lO]=(0,a.useState)(0),[lF,lZ]=(0,a.useState)(null),[lM,lz]=(0,a.useState)(!1),lP=(0,r.Ji)(),lB=localStorage.getItem("token"),{getFieldsByCollection:lL,getNestedFields:lU,isSortEnabled:lR}=(0,d.I_)(),lJ=lR(l),[lV,lK]=(0,a.useState)(!1),{getColumnPreferences:lq,saveColumnPreferences:lW,getFilterPreferences:lH,saveFilterPreferences:lG,isInitialized:lY}=(0,u.Gn)(),lX=(0,a.useMemo)(()=>lL(l),[l,lL]),lQ=(0,a.useMemo)(()=>{if(!l||!lX)return[];if(ei&&ei.length>0){let e=lq(l);return e&&e.visibleColumns&&e.visibleColumns.length>0?e.visibleColumns:ei}let e=lq(l);if(e&&e.visibleColumns&&e.visibleColumns.length>0)return e.visibleColumns;let t=["userCreated_Id","userCreated","userUpdated_Id","userUpdated","userDeleted","userDeleted_Id","createdAt","updatedAt","deletedAt"];return Object.keys(lX).filter(e=>{let l=lX[e];return!t.includes(e)&&!l.relType}).slice(0,5)},[l,lX,lq,ei]);(0,a.useEffect)(()=>{if(l&&lY){let e=lq(l);(null==e?void 0:e.columnWidths)?lT(e.columnWidths):lT({})}},[l,lY,lq]),(0,a.useEffect)(()=>{if(l&&lY&&!ed){let e=lH(l);(null==e?void 0:e.filters)?e2(e.filters):e2([])}},[l,lY,ed]),(0,a.useEffect)(()=>{!lJ||(null==em?void 0:em.length)||0!==e5.length||e3([{field:"sort",order:"asc"}])},[lJ,em,e5.length]);let l$=(0,a.useMemo)(()=>{if(!lX||!l)return["*"];let e=["id"];return lQ.forEach(l=>{if("id"!==l){if(l.includes("."))e.push(l);else{let t=lX[l];t&&(t.relType&&t.showAs?e.push(l+".*"):e.push(l))}}}),e.length>0?e:["*"]},[lX,l,lQ]),l0=(0,a.useMemo)(()=>eC?[{field:"search",operator:"contains",value:eC}]:[],[eC]),l1=(0,a.useMemo)(()=>[...eu||[],...e1,...l0],[eu,e1,l0]),l2=!!l&&l$.length>0&&lY,{data:l4,isLoading:l5,refetch:l3}=(0,r.sm)({resource:l,meta:{fields:l$,...ec},queryOptions:{enabled:l2},pagination:{current:eK,pageSize:eX,mode:"server"},filters:l1,sorters:e5}),l8=(0,a.useCallback)(()=>{l3(),null==ep||ep()},[l3,ep]),l7=(null==l4?void 0:l4.data)||[],l6=(null==l4?void 0:l4.total)||0,l9=Math.ceil(l6/eX),{mutate:te,isLoading:tl}=(0,r.R2)(),{mutate:tt,isLoading:ts}=(0,r.RO)(),{mutate:ta,isLoading:tn}=(0,r.PQ)(),tr=null==eR?void 0:eR.id,ti=(0,a.useMemo)(()=>{if(!lX)return["*"];let e=["*"];return Object.entries(lX).forEach(l=>{let[t,s]=l;s.relType&&e.push("".concat(t,".*"))}),e},[lX]),{data:to,isLoading:tc,isFetching:td}=(0,r.rD)({resource:l,id:tr||"",queryOptions:{enabled:!!(tr&&(eO||eZ))},meta:{fields:ti}}),tu=null==to?void 0:to.data,tm=(0,a.useMemo)(()=>Object.entries(lX||{}).map(e=>{let[l,t]=e;return{name:l,...t,label:l.replace(/_/g," ").replace(/([A-Z])/g," $1").trim()}}),[lX]),th=(0,a.useCallback)((e,l)=>{if(!e)return"-";if("string"==typeof e||"number"==typeof e)return String(e);if(l.showAs&&Array.isArray(l.showAs)){let t=["-"," ",",","_"," and "," or "],s=[];l.showAs.forEach(l=>{if(t.includes(l))s.push(l);else{let t;if(l.includes(".")){let s=l.split("."),a=e;for(let e of s)if(null==(a=null==a?void 0:a[e]))break;t=a}else t=e[l];null!=t&&""!==t&&s.push(String(t))}});let a=s.filter((e,l)=>{let a=t.includes(e),n=l>0&&t.includes(s[l-1]),r=l===s.length-1;return!a||0!==l&&!r&&!n});if(a.length>0)return a.join("")}return e.name||e.title||e.label||e.email||e.id||JSON.stringify(e)},[]);(0,a.useMemo)(()=>lX?Object.keys(lX):[],[lX]);let tx=(0,a.useMemo)(()=>lX?lU(l):[],[lX,l,lU]);(0,a.useEffect)(()=>{l&&lX&&lh(Object.keys(lX).filter(e=>!["userCreated_Id","userCreated","userUpdated_Id","userUpdated","userDeleted","userDeleted_Id","createdAt","updatedAt","deletedAt"].includes(e)))},[l,lX]);let tp=(0,r.x5)(),tf=(0,a.useCallback)((e,l,t)=>{let s=new Blob([[l.map(e=>e.includes(",")||e.includes('"')||e.includes("\n")?'"'.concat(e.replace(/"/g,'""'),'"'):e).join(","),...e.map(e=>l.map(l=>{let t=e;for(let e of l.split("."))t=null==t?void 0:t[e];if(null==t)return"";if("object"==typeof t){let e=JSON.stringify(t);return'"'.concat(e.replace(/"/g,'""'),'"')}return"string"==typeof t&&(t.includes(",")||t.includes('"')||t.includes("\n"))?'"'.concat(t.replace(/"/g,'""'),'"'):t}).join(","))].join("\n")],{type:"text/csv;charset=utf-8;"}),a=document.createElement("a"),n=URL.createObjectURL(s);a.setAttribute("href",n),a.setAttribute("download","".concat(t,"_export_").concat(new Date().toISOString().split("T")[0],".csv")),a.style.visibility="hidden",document.body.appendChild(a),a.click(),document.body.removeChild(a)},[]),tg=(0,a.useCallback)(async()=>{lj(!0);try{let e={resource:l,meta:{fields:lm},filters:l1,dataProviderName:void 0};-1!==lx&&lx>0&&(e.pagination={current:lf,pageSize:lx,mode:"server"});let{data:t}=await tp().getList(e);tf(t,lm,l),ln(!1),eT.Am.success("Export completed successfully")}catch(e){console.error("Export error:",e),eT.Am.error("Export failed")}finally{lj(!1)}},[lm,lx,lf,l,l1,tp,tf]),tv=(0,a.useCallback)(()=>{l8()},[l8]),tj=(0,a.useMemo)(()=>new Set(["JSON","JSONB","VIRTUAL","Array_Integer","Array_String","Array_Double","Array_Decimal","Array_UUID","Array_Date","Array_DateTime","Array_Boolean","Point","Polygon","LineString"]),[]),ty=(0,a.useCallback)((e,l)=>!e||!tj.has(e)&&(null==l?void 0:l.relType)!=="M2A"&&(null==l||!l.alias),[tj]),tN=(0,a.useMemo)(()=>lX?lQ.map(e=>{if(e.includes(".")){let[l,...t]=e.split("."),s=lX[l];if(s&&s.relType){let l="BelongsTo"===s.relType||"HasOne"===s.relType||"M2O"===s.relType||"O2O"===s.relType;return{key:e,title:eY(e),field:{name:e,type:"String",relType:null,isNested:!0},sortable:l,isNested:!0}}return null}let l=lX[e];if(!l)return null;let t=!("HasMany"===l.relType||"BelongsToMany"===l.relType)&&ty(l.type,l);return{key:e,title:eY(e),field:{name:e,type:l.type||"String",relType:l.relType,showAs:Array.isArray(l.showAs)?l.showAs:l.showAs?[l.showAs]:void 0,displayFormat:l.displayFormat,displayOptions:l.displayOptions,values:l.values,allowNull:l.allowNull},sortable:t,isNested:!1}}).filter(Boolean):[],[lX,lQ,ty]),tb=(0,a.useCallback)(e=>{e3(l=>{let t=l.find(l=>l.field===e);return t?"asc"===t.order?[{field:e,order:"desc"}]:[]:[{field:e,order:"asc"}]})},[]),tw=(0,i.Dy)((0,i.VT)(i.we,{activationConstraint:{distance:8}}),(0,i.VT)(i.Lg,{coordinateGetter:o.is})),tC=(0,a.useCallback)(async e=>{let{active:t,over:s}=e;if(lK(!1),!s||t.id===s.id)return;let a=String(t.id),n=String(s.id),r=l7.findIndex(e=>String(e.id)===a),i=l7.findIndex(e=>String(e.id)===n);if(-1!==r&&-1!==i)try{let e=(0,m.fO)(h.G);await e(l,a,n,r<i?"after":"before"),eT.Am.success("Order updated successfully"),l8()}catch(e){eT.Am.error((null==e?void 0:e.message)||"Failed to update order")}},[l,l8,l7]),tS=(0,a.useCallback)(()=>{lK(!0)},[]),tk=(0,a.useCallback)(e=>{let l=e5.find(l=>l.field===e);return(null==l?void 0:l.order)||null},[e5]),tT=(0,a.useCallback)(async e=>{e2(e),await lG(l,{filters:e,sorters:[]}),eW(1)},[l,lG]);(0,a.useCallback)(async(e,t)=>{let s=t?[...lQ,e]:lQ.filter(l=>l!==e);await lW(l,{visibleColumns:s,tableDensity:ly,columnWidths:lk})},[l,lQ,lW,ly,lk]);let tD=(0,a.useCallback)(async e=>{await lW(l,{visibleColumns:e,tableDensity:ly,columnWidths:lk})},[l,lW,ly,lk]),tA=(0,a.useCallback)(async e=>{lN(e),await lW(l,{visibleColumns:lQ,tableDensity:e,columnWidths:lk})},[l,lQ,lW,lk]),tI=(0,a.useCallback)((e,l)=>{lw(l),e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",l);let t=e.currentTarget;setTimeout(()=>{t.style.opacity="0.5"},0)},[]),t_=(0,a.useCallback)(e=>{e.currentTarget.style.opacity="1",lw(null),lS(null)},[]),tE=(0,a.useCallback)((e,l)=>{e.preventDefault(),e.dataTransfer.dropEffect="move",lb&&l!==lb&&lS(l)},[lb]),tO=(0,a.useCallback)(()=>{lS(null)},[]),tF=(0,a.useCallback)(async(e,t)=>{if(e.preventDefault(),!lb||lb===t){lw(null),lS(null);return}let s=[...lQ],a=s.indexOf(lb),n=s.indexOf(t);-1!==a&&-1!==n&&(s.splice(a,1),s.splice(n,0,lb),await lW(l,{visibleColumns:s,tableDensity:ly,columnWidths:lk})),lw(null),lS(null)},[lb,lQ,l,lW,ly,lk]),tZ=(0,a.useCallback)((e,l)=>{e.preventDefault(),e.stopPropagation(),lA(l),l_(e.clientX),lO(lk[l]||150)},[lk]),tM=(0,a.useCallback)(e=>{if(!lD)return;let l=Math.max(80,lE+(e.clientX-lI));lT(e=>({...e,[lD]:l}))},[lD,lI,lE]),tz=(0,a.useCallback)(async()=>{lD&&(await lW(l,{visibleColumns:lQ,tableDensity:ly,columnWidths:lk}),lA(null))},[lD,l,lQ,ly,lk,lW]);(0,a.useEffect)(()=>(lD&&(document.addEventListener("mousemove",tM),document.addEventListener("mouseup",tz),document.body.style.cursor="col-resize",document.body.style.userSelect="none"),()=>{document.removeEventListener("mousemove",tM),document.removeEventListener("mouseup",tz),document.body.style.cursor="",document.body.style.userSelect=""}),[lD,tM,tz]);let tP=(0,a.useCallback)(()=>{eR&&te({resource:l,id:eR.id},{onSuccess:()=>{eT.Am.success("Record deleted successfully"),eB(!1),eJ(null),l8()},onError:e=>{eT.Am.error("Failed to delete record"),console.error(e)}})},[eR,l,te,l8]),tB=(0,a.useCallback)(e=>{tt({resource:l,values:e},{onSuccess:()=>{eT.Am.success("Record created successfully"),eE(!1),l8()},onError:e=>{eT.Am.error("Failed to create record"),console.error(e)}})},[l,tt,l8]),tL=(0,a.useCallback)(e=>{eR&&ta({resource:l,id:eR.id,values:e},{onSuccess:()=>{eT.Am.success("Record updated successfully"),eM(!1),eJ(null),l8()},onError:e=>{eT.Am.error("Failed to update record"),console.error(e)}})},[eR,l,ta,l8]),tU=(0,a.useCallback)(async(e,t,s)=>(lz(!0),new Promise((a,n)=>{ta({resource:l,id:e,values:{[t]:s}},{onSuccess:()=>{eT.Am.success("Field updated"),lZ(null),lz(!1),l8(),a()},onError:e=>{eT.Am.error("Failed to update field"),console.error(e),lz(!1),n(e)}})})),[l,ta,l8]),tR=(0,a.useCallback)(()=>{lZ(null)},[]),tJ=(0,a.useCallback)(()=>{e$.length===l7.length?e0([]):e0(l7.map(e=>e.id))},[e$,l7]),tV=(0,a.useCallback)(e=>{e0(l=>l.includes(e)?l.filter(l=>l!==e):[...l,e])},[]);return l?(0,s.jsxs)("div",{className:"flex flex-col h-full gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[!J&&(0,s.jsx)("h1",{className:"text-lg font-semibold",children:n||t||l}),(0,s.jsxs)("div",{className:(0,en.cn)("flex items-center gap-2 flex-wrap",J&&"flex-1 justify-end"),children:[ea,V&&(0,s.jsx)(f.t,{value:eC,onChange:ek,placeholder:"Search...",expandedWidth:"w-64"}),K&&(0,s.jsxs)(p.z,{variant:e1.length>0?"default":"outline",size:"icon",onClick:()=>eA(!0),title:"Filters",className:"relative",children:[(0,s.jsx)(S.Z,{className:"h-4 w-4"}),e1.length>0&&(0,s.jsx)(j.C,{variant:"secondary",className:"absolute -top-1 -right-1 h-4 w-4 p-0 flex items-center justify-center text-xs",children:e1.length})]}),$&&(0,s.jsx)(p.z,{variant:"outline",size:"icon",onClick:()=>lu(!0),title:"Settings",children:(0,s.jsx)(k.Z,{className:"h-4 w-4"})}),(0,s.jsx)(p.z,{variant:"outline",size:"icon",onClick:()=>l8(),title:"Refresh",children:(0,s.jsx)(T.Z,{className:"h-4 w-4"})}),(Y||X)&&(0,s.jsxs)(b.h_,{children:[(0,s.jsx)(b.$F,{asChild:!0,children:(0,s.jsx)(p.z,{variant:"outline",size:"icon",title:"More",children:(0,s.jsx)(D.Z,{className:"h-4 w-4"})})}),(0,s.jsxs)(b.AW,{align:"end",children:[(0,s.jsx)(b.Ju,{children:"Data Actions"}),(0,s.jsx)(b.VD,{}),Y&&(0,s.jsxs)(b.Xi,{onClick:()=>ln(!0),children:[(0,s.jsx)(A.Z,{className:"mr-2 h-4 w-4"}),"Export"]}),X&&(0,s.jsxs)(b.Xi,{onClick:()=>li(!0),children:[(0,s.jsx)(I.Z,{className:"mr-2 h-4 w-4"}),"Import"]})]})]}),et,q&&(0,s.jsx)(p.z,{size:"icon",onClick:()=>eE(!0),title:"Create",children:(0,s.jsx)(_.Z,{className:"h-4 w-4"})})]})]}),Q&&e$.length>0&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-2 bg-muted rounded-md",children:[(0,s.jsxs)("span",{className:"text-sm font-medium",children:[e$.length," row(s) selected"]}),(0,s.jsx)(p.z,{variant:"outline",size:"sm",onClick:()=>lc(!0),children:"Bulk Actions"}),(0,s.jsx)(p.z,{variant:"outline",size:"sm",onClick:()=>e0([]),children:"Clear"})]}),(0,s.jsxs)(g.Zb,{className:"flex-1 flex flex-col overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"flex-1 overflow-auto relative",children:(0,s.jsxs)("table",{className:"w-full caption-bottom text-sm min-w-max",children:[(0,s.jsx)("thead",{className:"sticky top-0 z-10 bg-background",children:(0,s.jsxs)(v.SC,{className:"border-b",children:[lJ&&(0,s.jsx)(v.ss,{className:"w-8 px-2",children:(0,s.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground"})}),ef&&(0,s.jsx)(v.ss,{className:"w-12 sticky left-0 bg-background z-20",children:"multiple"===eg?"Select":""}),Q&&(0,s.jsx)(v.ss,{className:"w-12 sticky left-0 bg-background z-20",children:(0,s.jsx)(C.X,{checked:l7.length>0&&e$.length===l7.length,onCheckedChange:tJ})}),tN.map(e=>{let l=tk(e.key),t=lb===e.key,a=lC===e.key,n=lk[e.key];return(0,s.jsxs)(v.ss,{draggable:!0,onDragStart:l=>tI(l,e.key),onDragEnd:t_,onDragOver:l=>tE(l,e.key),onDragLeave:tO,onDrop:l=>tF(l,e.key),style:{width:n?"".concat(n,"px"):void 0,minWidth:n?"".concat(n,"px"):void 0},className:(0,en.cn)("whitespace-nowrap cursor-grab active:cursor-grabbing relative group/header",e.sortable&&"cursor-pointer select-none",t&&"opacity-50",a&&"border-l-2 border-l-primary"),onClick:()=>e.sortable&&tb(e.key),children:[(0,s.jsxs)("div",{className:"flex items-center gap-1 pr-2",children:[(0,s.jsx)(E.Z,{className:"h-4 w-4 text-muted-foreground opacity-40 hover:opacity-100 cursor-grab flex-shrink-0"}),(0,s.jsx)("span",{className:"truncate",children:e.title}),e.sortable&&(0,s.jsx)("span",{className:"ml-1 flex-shrink-0",children:"asc"===l?(0,s.jsx)(O.Z,{className:"h-4 w-4"}):"desc"===l?(0,s.jsx)(F.Z,{className:"h-4 w-4"}):(0,s.jsx)(Z.Z,{className:"h-4 w-4 text-muted-foreground"})})]}),(0,s.jsx)("div",{className:(0,en.cn)("absolute right-0 top-0 bottom-0 w-[3px] cursor-col-resize","border-r border-border hover:border-primary hover:bg-primary/20",lD===e.key&&"border-primary bg-primary/30"),onMouseDown:l=>tZ(l,e.key),onClick:e=>e.stopPropagation()})]},e.key)}),(es||W||H||G)&&(0,s.jsx)(v.ss,{className:"w-24",children:"Actions"})]})}),(0,s.jsx)(i.LB,{sensors:tw,collisionDetection:i.pE,onDragStart:tS,onDragEnd:tC,modifiers:[c.DL],children:(0,s.jsx)(o.Fo,{items:l7.map(e=>e.id),strategy:o.qw,disabled:!lJ,children:(0,s.jsx)("tbody",{className:(0,en.cn)("[&_tr:last-child]:border-0","small"===ly&&"[&_tr]:h-8 [&_td]:py-1 [&_td]:text-xs","middle"===ly&&"[&_tr]:h-12 [&_td]:py-2 [&_td]:text-sm","large"===ly&&"[&_tr]:h-16 [&_td]:py-4"),children:l5?(0,s.jsx)(v.SC,{children:(0,s.jsx)(v.pj,{colSpan:tN.length+(lJ?1:0)+(ef?1:0)+(Q?1:0)+(es||W||H||G?1:0),className:"h-48 text-center",children:(0,s.jsx)(M.Z,{className:"h-8 w-8 animate-spin mx-auto"})})}):0===l7.length?(0,s.jsx)(v.SC,{children:(0,s.jsx)(v.pj,{colSpan:tN.length+(lJ?1:0)+(ef?1:0)+(Q?1:0)+(es||W||H||G?1:0),className:"h-48 text-center text-muted-foreground",children:"No data available"})}):l7.map((e,l)=>{let t=null==ev?void 0:ev.some(l=>l.id===e.id);return(0,s.jsxs)(eH,{id:e.id,disabled:!lJ,className:(0,en.cn)(ex&&"cursor-pointer hover:bg-muted/50",eN&&t&&"bg-primary/10 hover:bg-primary/15"),onClick:()=>null==ex?void 0:ex(e),children:[ef&&(0,s.jsx)(v.pj,{onClick:e=>e.stopPropagation(),className:"sticky left-0 bg-background z-10",children:"multiple"===eg?(0,s.jsx)(C.X,{checked:t||!1,onCheckedChange:l=>{l?null==ej||ej([...ev||[],e]):null==ej||ej((ev||[]).filter(l=>l.id!==e.id))}}):(0,s.jsx)("input",{type:"radio",name:"external-selection",checked:t||!1,onChange:()=>{null==ej||ej([e])},className:"h-4 w-4 text-primary border-border focus:ring-primary"})}),Q&&(0,s.jsx)(v.pj,{onClick:e=>e.stopPropagation(),children:(0,s.jsx)(C.X,{checked:e$.includes(e.id),onCheckedChange:()=>tV(e.id)})}),tN.map(l=>{let t=e;if(l.isNested){for(let e of l.key.split(".")){if(null==t)break;if(Array.isArray(t)){if(0===(t=t.map(l=>null==l?void 0:l[e]).filter(e=>null!=e)).length){t=null;break}}else t=null==t?void 0:t[e]}Array.isArray(t)&&(t=t.join(", "))}else t=e[l.key];if(er&&er[l.key]){let a=lk[l.key];return(0,s.jsx)(v.pj,{style:{width:a?"".concat(a,"px"):void 0,maxWidth:a?"".concat(a,"px"):void 0},className:a?"overflow-hidden":"",children:(0,s.jsx)("div",{className:a?"truncate":"",children:er[l.key](t,e,l.field)})},l.key)}let a=lk[l.key],n=l.isNested&&null!=t&&"object"==typeof t?null:t,r=(null==lF?void 0:lF.recordId)===e.id&&(null==lF?void 0:lF.columnKey)===l.key,i=el&&!l.isNested&&l.field&&eq(l.field);return(0,s.jsx)(v.pj,{style:{width:a?"".concat(a,"px"):void 0,maxWidth:a?"".concat(a,"px"):void 0},className:(0,en.cn)(a?"overflow-hidden":"",i&&!r&&"cursor-cell"),onDoubleClick:t=>{i&&!r&&(t.stopPropagation(),lZ({recordId:e.id,columnKey:l.key}))},children:r?(0,s.jsx)(eV,{value:t,field:l.field,onSave:t=>tU(e.id,l.key,t),onCancel:tR,isLoading:lM}):(0,s.jsx)("div",{className:a?"truncate":"",children:l.isNested?(0,s.jsx)("span",{className:"text-sm",children:null!=n?String(n):"-"}):(0,s.jsx)(x.Zl,{field:l.field,value:t,readOnly:!0,size:"small"})})},l.key)}),(es||W||H||G)&&(0,s.jsx)(v.pj,{onClick:e=>e.stopPropagation(),children:es?es({record:e,onView:()=>{eJ(e),eF(!0)},onEdit:()=>{eJ(e),eM(!0)},onDelete:()=>{eJ(e),eB(!0)}}):(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[W&&(0,s.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{eJ(e),eF(!0)},children:(0,s.jsx)(z.Z,{className:"h-4 w-4"})}),H&&(0,s.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>{eJ(e),eM(!0)},children:(0,s.jsx)(P.Z,{className:"h-4 w-4"})}),G&&(0,s.jsx)(p.z,{variant:"ghost",size:"icon",className:"h-8 w-8 text-destructive",onClick:()=>{eJ(e),eB(!0)},children:(0,s.jsx)(B.Z,{className:"h-4 w-4"})})]})})]},e.id||l)})})})})]})}),(0,s.jsxs)("div",{className:"flex items-center justify-between border-t px-3 py-2 gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("p",{className:"text-sm text-muted-foreground hidden sm:block",children:["Showing ",(eK-1)*eX+1," to"," ",Math.min(eK*eX,l6)," of ",l6," ","records"]}),(0,s.jsxs)(w.Ph,{value:eX.toString(),onValueChange:e=>{eQ(Number(e)),eW(1)},children:[(0,s.jsx)(w.i4,{className:"w-[70px] sm:w-[100px]",children:(0,s.jsx)(w.ki,{})}),(0,s.jsxs)(w.Bw,{children:[(0,s.jsxs)(w.Ql,{value:"10",children:[(0,s.jsx)("span",{className:"sm:hidden",children:"10"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"10 / page"})]}),(0,s.jsxs)(w.Ql,{value:"25",children:[(0,s.jsx)("span",{className:"sm:hidden",children:"25"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"25 / page"})]}),(0,s.jsxs)(w.Ql,{value:"50",children:[(0,s.jsx)("span",{className:"sm:hidden",children:"50"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"50 / page"})]}),(0,s.jsxs)(w.Ql,{value:"100",children:[(0,s.jsx)("span",{className:"sm:hidden",children:"100"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"100 / page"})]})]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1 sm:gap-2",children:[(0,s.jsxs)(p.z,{variant:"outline",size:"sm",onClick:()=>eW(e=>Math.max(1,e-1)),disabled:1===eK,children:[(0,s.jsx)(L.Z,{className:"h-4 w-4"}),(0,s.jsx)("span",{className:"hidden sm:inline",children:"Previous"})]}),(0,s.jsxs)("span",{className:"text-sm whitespace-nowrap",children:[(0,s.jsxs)("span",{className:"sm:hidden",children:[eK,"/",l9||1]}),(0,s.jsxs)("span",{className:"hidden sm:inline",children:["Page ",eK," of ",l9||1]})]}),(0,s.jsxs)(p.z,{variant:"outline",size:"sm",onClick:()=>eW(e=>Math.min(l9,e+1)),disabled:eK>=l9,children:[(0,s.jsx)("span",{className:"hidden sm:inline",children:"Next"}),(0,s.jsx)(U.Z,{className:"h-4 w-4"})]})]})]})]}),K&&(0,s.jsx)(ey,{visible:eD,onClose:()=>eA(!1),formFields:tm,onApply:tT,initialFilters:e1,collectionName:l}),q&&(0,s.jsx)(y.yo,{open:e_,onOpenChange:eE,children:(0,s.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"Create New Record"})}),(0,s.jsx)("div",{className:"mt-4",children:(0,s.jsx)(eU.j,{fields:tm,onSubmit:tB,isLoading:ts,onCancel:()=>eE(!1)})})]})}),W&&(0,s.jsx)(y.yo,{open:eO,onOpenChange:e=>{eF(e),e||eJ(null)},children:(0,s.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"View Record"})}),(0,s.jsx)("div",{className:"mt-4 space-y-4",children:tc||td?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(M.Z,{className:"h-8 w-8 animate-spin"})}):tu?(()=>{let e,l;let t=tm.filter(e=>e.relType&&e.foreignKey).map(e=>e.foreignKey),a=ee&&tu.type&&tu.id?(0,s.jsxs)("div",{className:"mb-4 space-y-2",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-muted-foreground",children:"Preview"}),(0,s.jsx)("div",{className:"p-3 bg-muted/50 rounded-md flex items-center justify-center",children:(null==(e=tu.type)?void 0:e.startsWith("image/"))?(0,s.jsx)("img",{src:"".concat(lP,"/assets/").concat(tu.id,"?access_token=").concat(lB),alt:tu.title||"Image preview",className:"max-w-full max-h-64 object-contain rounded",onError:e=>{e.target.style.display="none"}}):(null==(l=tu.type)?void 0:l.startsWith("video/"))?(0,s.jsx)("video",{src:"".concat(lP,"/assets/").concat(tu.id,"?access_token=").concat(lB),controls:!0,className:"max-w-full max-h-64 rounded"}):(0,s.jsx)("div",{className:"text-center text-muted-foreground py-4",children:(0,s.jsx)("span",{className:"text-sm",children:"No preview available for this file type"})})})]}):null,n=tm.filter(e=>!t.includes(e.name)).map(e=>{var l,t;let a=tu[e.name],n=e=>!e||"object"==typeof e&&(null===e.id||void 0===e.id);return(0,s.jsxs)("div",{className:"space-y-1",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-muted-foreground capitalize",children:e.label||e.name.replace(/_/g," ")}),["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"].includes(e.type)&&a&&(0,s.jsxs)(p.z,{variant:"ghost",size:"sm",className:"h-6 text-xs gap-1",onClick:()=>{e9(a),ll(e.label||e.name),ls(e.type),e7(!0)},children:[(0,s.jsx)(R.Z,{className:"h-3 w-3"}),"View in Map"]})]}),(0,s.jsx)("div",{className:"p-3 bg-muted/50 rounded-md min-h-[40px]",children:(null==er?void 0:er[e.name])?er[e.name](a,tu,e):e.relType?(()=>{if(!a||n(a))return(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"});if(Array.isArray(a)){let l=a.filter(e=>!n(e));return 0===l.length?(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"}):(0,s.jsx)("div",{className:"flex flex-wrap gap-1",children:l.map((l,t)=>(0,s.jsx)(j.C,{variant:"secondary",className:"text-xs",children:th(l,e)},(null==l?void 0:l.id)||t))})}return"object"==typeof a?(0,s.jsx)(j.C,{variant:"secondary",className:"text-xs",children:th(a,e)}):(0,s.jsx)("span",{className:"text-sm",children:String(a)})})():null!=a?["DateTime","DateTime_NO_TZ","DATETIME","TIMESTAMP"].includes(e.type)?(0,s.jsxs)("span",{className:"text-sm",children:[new Date(a).toLocaleString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"}),(0,s.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",Intl.DateTimeFormat().resolvedOptions().timeZone,")"]})]}):"Date"===e.type?(0,s.jsx)("span",{className:"text-sm",children:new Date(a).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}):["Time","Time_NO_TZ"].includes(e.type)?(0,s.jsx)("span",{className:"text-sm",children:a}):["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon"].includes(e.type)?(0,s.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-all max-h-24 overflow-auto",children:JSON.stringify(a,null,2)}):(null===(l=e.type)||void 0===l?void 0:l.startsWith("Array_"))?(0,s.jsxs)("div",{className:"flex flex-wrap gap-1",children:[Array.isArray(a)&&a.length>0?a.slice(0,10).map((l,t)=>{let a=String(l);if(e.type.includes("Date")||e.type.includes("DateTime")){let t=new Date(l);a=e.type.includes("DateTime")?t.toLocaleString():t.toLocaleDateString()}else e.type.includes("Boolean")&&(a=l?"true":"false");return(0,s.jsx)(j.C,{variant:"secondary",className:"text-xs",children:a},t)}):(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"Empty array"}),Array.isArray(a)&&a.length>10&&(0,s.jsxs)(j.C,{variant:"outline",className:"text-xs",children:["+",a.length-10," more"]})]}):(null===(t=e.type)||void 0===t?void 0:t.startsWith("Range_"))?(()=>{var l,t;if(!a||"object"!=typeof a)return(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"});let n=!1!==a.lowerInclusive?"[":"(",r=!1!==a.upperInclusive?"]":")",i=String(null!==(l=a.lower)&&void 0!==l?l:""),o=String(null!==(t=a.upper)&&void 0!==t?t:"");if(e.type.includes("Date")||e.type.includes("DateTime")){if(a.lower){let l=new Date(a.lower);i=e.type.includes("DateTime")?l.toLocaleString():l.toLocaleDateString()}if(a.upper){let l=new Date(a.upper);o=e.type.includes("DateTime")?l.toLocaleString():l.toLocaleDateString()}}return(0,s.jsxs)(j.C,{variant:"secondary",className:"font-mono text-xs",children:[n,i," – ",o,r]})})():"object"==typeof a?(0,s.jsx)("pre",{className:"text-sm whitespace-pre-wrap break-all",children:JSON.stringify(a,null,2)}):(0,s.jsx)("span",{className:"text-sm",children:String(a)}):(0,s.jsx)("span",{className:"text-sm text-muted-foreground",children:"-"})})]},e.name)});return(0,s.jsxs)(s.Fragment,{children:[a,n]})})():(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No data available"})})]})}),H&&(0,s.jsx)(y.yo,{open:eZ,onOpenChange:e=>{eM(e),e||eJ(null)},children:(0,s.jsxs)(y.ue,{className:"w-[600px] sm:max-w-[600px] overflow-y-auto",children:[(0,s.jsx)(y.Tu,{children:(0,s.jsx)(y.bC,{children:"Edit Record"})}),(0,s.jsx)("div",{className:"mt-4",children:tc||td?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)(M.Z,{className:"h-8 w-8 animate-spin"})}):tu?(0,s.jsx)(eU.j,{fields:tm,initialValues:tu,onSubmit:tL,isLoading:tn,disabledFields:(null==eo?void 0:eo(tu))||[],onCancel:()=>{eM(!1),eJ(null)}}):(0,s.jsx)("div",{className:"text-center py-8 text-muted-foreground",children:"No data available"})})]})}),G&&(0,s.jsx)(N.Vq,{open:ez,onOpenChange:eB,children:(0,s.jsxs)(N.cZ,{children:[(0,s.jsxs)(N.fK,{children:[(0,s.jsx)(N.$N,{children:"Delete Record"}),(0,s.jsx)(N.Be,{children:"Are you sure you want to delete this record? This action cannot be undone."})]}),(0,s.jsxs)(N.cN,{children:[(0,s.jsx)(p.z,{variant:"outline",onClick:()=>{eB(!1),eJ(null)},children:"Cancel"}),(0,s.jsxs)(p.z,{variant:"destructive",onClick:tP,disabled:tl,children:[tl&&(0,s.jsx)(M.Z,{className:"mr-2 h-4 w-4 animate-spin"}),"Delete"]})]})]})}),Y&&(0,s.jsx)(ew,{visible:la,onClose:()=>ln(!1),exportColumns:lm,onExportColumnsChange:lh,exportLimit:lx,onExportLimitChange:lp,exportPage:lf,onExportPageChange:lg,isExporting:lv,onExport:tg,columnTreeData:tx}),X&&(0,s.jsx)(eI,{visible:lr,onClose:()=>li(!1),selectedCollection:l,onImportComplete:tv}),Q&&(0,s.jsx)(eP,{visible:lo,onClose:()=>lc(!1),selectedRows:l7.filter(e=>e$.includes(e.id)),selectedCollection:l,onClearSelection:()=>{e0([]),l8()},customActions:eb}),$&&(0,s.jsx)(eL,{visible:ld,onClose:()=>lu(!1),tableDensity:ly,onTableDensityChange:tA,visibleColumns:lQ,onVisibleColumnsChange:tD,columnTreeData:tx}),(0,s.jsx)(eG.Z,{open:e8,onOpenChange:e7,value:e6,fieldName:le,fieldType:lt})]}):(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-8 text-center",children:[(0,s.jsx)("h3",{className:"text-lg font-medium",children:"Please select a collection"}),(0,s.jsx)("p",{className:"text-muted-foreground mt-2",children:"Choose a collection from the sidebar to view and manage its data."})]})})},eQ=()=>{let e=(0,n.useSearchParams)(),l=e.get("collection")||"",t=e.get("schema")||"",{isLoading:a}=(0,d.I_)(),{isInitialized:r,isLoading:i}=(0,u.Gn)();return a||i||!r?(0,s.jsx)(g.Zb,{children:(0,s.jsxs)(g.aY,{className:"p-8 text-center",children:[(0,s.jsx)(M.Z,{className:"h-8 w-8 animate-spin mx-auto"}),(0,s.jsx)("p",{className:"text-muted-foreground mt-2",children:"Loading..."})]})}):(0,s.jsx)(eX,{selectedCollection:l,schemaName:t,enableView:!0},l)};var e$=eQ},32060:function(e,l,t){t.d(l,{$F:function(){return u},AW:function(){return m},Ju:function(){return x},VD:function(){return p},Xi:function(){return h},h_:function(){return d}});var s=t(57437),a=t(2265),n=t(28119),r=t(10407),i=t(30401),o=t(40519),c=t(93448);let d=n.fC,u=n.xz;n.ZA,n.Uv,n.Tr,n.Ee,a.forwardRef((e,l)=>{let{className:t,inset:a,children:i,...o}=e;return(0,s.jsxs)(n.fF,{ref:l,className:(0,c.cn)("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",a&&"pl-8",t),...o,children:[i,(0,s.jsx)(r.Z,{className:"ml-auto h-4 w-4"})]})}).displayName=n.fF.displayName,a.forwardRef((e,l)=>{let{className:t,...a}=e;return(0,s.jsx)(n.tu,{ref:l,className:(0,c.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...a})}).displayName=n.tu.displayName;let m=a.forwardRef((e,l)=>{let{className:t,sideOffset:a=4,...r}=e;return(0,s.jsx)(n.Uv,{children:(0,s.jsx)(n.VY,{ref:l,sideOffset:a,className:(0,c.cn)("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...r})})});m.displayName=n.VY.displayName;let h=a.forwardRef((e,l)=>{let{className:t,inset:a,...r}=e;return(0,s.jsx)(n.ck,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",a&&"pl-8",t),...r})});h.displayName=n.ck.displayName,a.forwardRef((e,l)=>{let{className:t,children:a,checked:r,...o}=e;return(0,s.jsxs)(n.oC,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:r,...o,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.wU,{children:(0,s.jsx)(i.Z,{className:"h-4 w-4"})})}),a]})}).displayName=n.oC.displayName,a.forwardRef((e,l)=>{let{className:t,children:a,...r}=e;return(0,s.jsxs)(n.Rk,{ref:l,className:(0,c.cn)("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...r,children:[(0,s.jsx)("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:(0,s.jsx)(n.wU,{children:(0,s.jsx)(o.Z,{className:"h-2 w-2 fill-current"})})}),a]})}).displayName=n.Rk.displayName;let x=a.forwardRef((e,l)=>{let{className:t,inset:a,...r}=e;return(0,s.jsx)(n.__,{ref:l,className:(0,c.cn)("px-2 py-1.5 text-sm font-semibold",a&&"pl-8",t),...r})});x.displayName=n.__.displayName;let p=a.forwardRef((e,l)=>{let{className:t,...a}=e;return(0,s.jsx)(n.Z0,{ref:l,className:(0,c.cn)("-mx-1 my-1 h-px bg-muted",t),...a})});p.displayName=n.Z0.displayName},17168:function(e,l,t){t.d(l,{SP:function(){return c},dr:function(){return o},mQ:function(){return i},nU:function(){return d}});var s=t(57437),a=t(2265),n=t(20271),r=t(93448);let i=n.fC,o=a.forwardRef((e,l)=>{let{className:t,...a}=e;return(0,s.jsx)(n.aV,{ref:l,className:(0,r.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",t),...a})});o.displayName=n.aV.displayName;let c=a.forwardRef((e,l)=>{let{className:t,...a}=e;return(0,s.jsx)(n.xz,{ref:l,className:(0,r.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",t),...a})});c.displayName=n.xz.displayName;let d=a.forwardRef((e,l)=>{let{className:t,...a}=e;return(0,s.jsx)(n.VY,{ref:l,className:(0,r.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...a})});d.displayName=n.VY.displayName},63751:function(e,l,t){t.d(l,{CE:function(){return c},Gn:function(){return o}});var s=t(57437),a=t(2265),n=t(72135),r=t(14438);let i=(0,a.createContext)(void 0),o=()=>{let e=(0,a.useContext)(i);if(!e)throw Error("usePreferences must be used within a PreferencesProvider");return e};function c(e){var l;let{children:t}=e,[o,c]=(0,a.useState)([]),[d,u]=(0,a.useState)(!1),{data:m}=(0,n.kS)(),h=(null==m?void 0:m.id)||(null==m?void 0:null===(l=m.user)||void 0===l?void 0:l.id)||null,{data:x,isLoading:p,refetch:f}=(0,n.sm)({resource:"baasix_UserPreference",queryOptions:{enabled:!!h},filters:h?[{field:"userId",operator:"eq",value:h}]:[],pagination:{pageSize:-1,mode:"off"}}),{mutate:g}=(0,n.RO)({resource:"baasix_UserPreference"}),{mutate:v}=(0,n.PQ)({resource:"baasix_UserPreference"});(0,a.useEffect)(()=>{(null==x?void 0:x.data)?(c(x.data),u(!0)):h&&!p&&(c([]),u(!0))},[x,h,p]);let j=(0,a.useMemo)(()=>{let e={};return o.forEach(l=>{l.isDefault&&(e[l.collectionName]||(e[l.collectionName]={}),e[l.collectionName][l.preferenceType]=l)}),e},[o]),y=(0,a.useCallback)((e,l)=>{var t;return(null===(t=j[e])||void 0===t?void 0:t[l])||null},[j]),N=(0,a.useCallback)(async(e,l,t)=>{if(!h){console.warn("No user ID available for saving preferences");return}let s=y(e,l),a={userId:h,collectionName:e,preferenceType:l,preferenceData:t,isDefault:!0};try{(null==s?void 0:s.id)?await new Promise((e,l)=>{v({id:s.id,values:a,successNotification:!1},{onSuccess:()=>{f(),e()},onError:e=>{console.error("Error updating preference:",e),l(e)}})}):await new Promise((e,l)=>{g({values:a,successNotification:!1},{onSuccess:()=>{f(),e()},onError:e=>{console.error("Error creating preference:",e),l(e)}})})}catch(e){throw r.Am.error("Failed to save preferences"),e}},[h,y,g,v,f]),b=(0,a.useCallback)(e=>{var l;let t=null===(l=j[e])||void 0===l?void 0:l.columns;return t?t.preferenceData:null},[j]),w=(0,a.useCallback)(async(e,l)=>{await N(e,"columns",l)},[N]),C=(0,a.useCallback)(e=>{var l;let t=null===(l=j[e])||void 0===l?void 0:l.filters;return t?t.preferenceData:null},[j]),S=(0,a.useCallback)(async(e,l)=>{await N(e,"filters",l)},[N]),k=(0,a.useCallback)(e=>{var l;let t=null===(l=j[e])||void 0===l?void 0:l.sorting;return t?t.preferenceData:null},[j]),T=(0,a.useCallback)(async(e,l)=>{await N(e,"sorting",l)},[N]),D=(0,a.useCallback)(e=>{var l;let t=null===(l=j[e])||void 0===l?void 0:l.pagination;return t?t.preferenceData:null},[j]),A=(0,a.useCallback)(async(e,l)=>{await N(e,"pagination",l)},[N]);return(0,s.jsx)(i.Provider,{value:{getColumnPreferences:b,saveColumnPreferences:w,getFilterPreferences:C,saveFilterPreferences:S,getSortingPreferences:k,saveSortingPreferences:T,getPaginationPreferences:D,savePaginationPreferences:A,isLoading:p,isInitialized:d,refetchPreferences:f},children:t})}}}]);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6869],{99376:function(t,e,s){var i=s(35475);s.o(i,"usePathname")&&s.d(e,{usePathname:function(){return i.usePathname}}),s.o(i,"useRouter")&&s.d(e,{useRouter:function(){return i.useRouter}}),s.o(i,"useSearchParams")&&s.d(e,{useSearchParams:function(){return i.useSearchParams}})},49112:function(t,e,s){s.d(e,{NQ:function(){return a},ql:function(){return $}});var i={ACCESS_TOKEN:"baasix_access_token",REFRESH_TOKEN:"baasix_refresh_token",TOKEN_EXPIRY:"baasix_token_expiry",USER:"baasix_user",TENANT:"baasix_tenant"},a=class t extends Error{status;code;details;isRetryable;constructor(e,s=500,i,a){super(e),this.name="BaasixError",this.status=s,this.code=i,this.details=a,this.isRetryable=s>=500||429===s,Error.captureStackTrace&&Error.captureStackTrace(this,t)}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code,details:this.details}}},r=class{config;refreshPromise=null;constructor(t){this.config=t}updateConfig(t){this.config={...this.config,...t}}getBaseUrl(){return this.config.baseUrl}buildUrl(t,e){let s=new URL(t,this.config.baseUrl);return e&&Object.entries(e).forEach(([t,e])=>{null!=e&&("object"==typeof e?s.searchParams.set(t,JSON.stringify(e)):s.searchParams.set(t,String(e)))}),s.toString()}async getAccessToken(){return this.config.token?this.config.token:"cookie"===this.config.authMode?null:await this.config.storage.get(i.ACCESS_TOKEN)}async isTokenExpired(){let t=await this.config.storage.get(i.TOKEN_EXPIRY);if(!t)return!1;let e=parseInt(t,10);return Date.now()>=e-6e4}async refreshToken(){return this.refreshPromise||(this.refreshPromise=(async()=>{try{let t=await this.config.storage.get(i.REFRESH_TOKEN);if(!t&&"jwt"===this.config.authMode)throw new a("No refresh token available",401,"NO_REFRESH_TOKEN");let e=await fetch(this.buildUrl("/auth/refresh"),{method:"POST",headers:{"Content-Type":"application/json",...this.config.headers},body:JSON.stringify("jwt"===this.config.authMode?{refreshToken:t,authMode:"jwt"}:{authMode:"cookie"}),credentials:this.config.credentials});if(!e.ok)throw new a("Token refresh failed",e.status,"REFRESH_FAILED");let s=await e.json(),r={accessToken:s.token,refreshToken:s.refreshToken,expiresIn:s.expiresIn,expiresAt:s.expiresIn?Date.now()+1e3*s.expiresIn:void 0};return await this.config.storage.set(i.ACCESS_TOKEN,r.accessToken),r.refreshToken&&await this.config.storage.set(i.REFRESH_TOKEN,r.refreshToken),r.expiresAt&&await this.config.storage.set(i.TOKEN_EXPIRY,r.expiresAt.toString()),this.config.onTokenRefresh?.(r),r}finally{this.refreshPromise=null}})()),this.refreshPromise}async buildHeaders(t={}){let e={"Content-Type":"application/json",...this.config.headers};if(this.config.tenantId&&(e["X-Tenant-Id"]=this.config.tenantId),t.skipAuth)return e;if("jwt"===this.config.authMode){if(this.config.autoRefresh&&await this.isTokenExpired())try{await this.refreshToken()}catch{}let t=await this.getAccessToken();t&&(e.Authorization=`Bearer ${t}`)}return e}async parseError(t){let e={};try{e=await t.json()}catch{}let s=e.error?.message||e.message||t.statusText||"Request failed",i=e.error?.code,r=e.details;return new a(s,t.status,i,r)}async request(t,e,s={}){let{params:i,timeout:r,skipAuth:n,rawResponse:o,...c}=s,l=this.buildUrl(e,i),h=await this.buildHeaders({skipAuth:n}),u=r||this.config.timeout,d=new AbortController,m=setTimeout(()=>d.abort(),u);try{let e=await fetch(l,{method:t,headers:{...h,...c.headers},credentials:this.config.credentials,signal:d.signal,...c});if(401===e.status&&!n&&this.config.autoRefresh)try{await this.refreshToken();let e=await this.buildHeaders({skipAuth:!1}),s=await fetch(l,{method:t,headers:{...e,...c.headers},credentials:this.config.credentials,...c});if(!s.ok)throw await this.parseError(s);if(o)return s;if(204===s.status)return{};return await s.json()}catch(t){throw this.config.onAuthError?.(),t}if(!e.ok)throw await this.parseError(e);if(o)return e;if(204===e.status)return{};return await e.json()}catch(t){if(t instanceof a)throw t;if(t instanceof Error){if("AbortError"===t.name)throw new a("Request timeout",408,"TIMEOUT");throw new a(t.message,0,"NETWORK_ERROR")}throw new a("Unknown error occurred",500,"UNKNOWN")}finally{clearTimeout(m)}}get(t,e){return this.request("GET",t,e)}post(t,e,s){return this.request("POST",t,{...s,body:e?JSON.stringify(e):void 0})}patch(t,e,s){return this.request("PATCH",t,{...s,body:e?JSON.stringify(e):void 0})}put(t,e,s){return this.request("PUT",t,{...s,body:e?JSON.stringify(e):void 0})}delete(t,e){return this.request("DELETE",t,e)}async upload(t,e,s){let{params:i,timeout:r,skipAuth:n,onProgress:o}=s||{},c=this.buildUrl(t,i),l=await this.buildHeaders({skipAuth:n}),h=r||this.config.timeout;if(delete l["Content-Type"],o&&"undefined"!=typeof XMLHttpRequest)return new Promise((t,s)=>{let i=new XMLHttpRequest;i.open("POST",c),Object.entries(l).forEach(([t,e])=>{i.setRequestHeader(t,e)}),i.withCredentials="include"===this.config.credentials,i.upload.onprogress=t=>{t.lengthComputable&&o(Math.round(t.loaded/t.total*100))},i.onload=()=>{if(i.status>=200&&i.status<300)try{t(JSON.parse(i.responseText))}catch{t({})}else s(new a(i.statusText||"Upload failed",i.status,"UPLOAD_ERROR"))},i.onerror=()=>{s(new a("Network error during upload",0,"NETWORK_ERROR"))},i.ontimeout=()=>{s(new a("Upload timeout",408,"TIMEOUT"))},i.timeout=h,i.send(e)});let u=new AbortController,d=setTimeout(()=>u.abort(),h);try{let t=await fetch(c,{method:"POST",headers:l,body:e,credentials:this.config.credentials,signal:u.signal});if(!t.ok)throw await this.parseError(t);return await t.json()}finally{clearTimeout(d)}}},n=class{prefix;constructor(t="baasix_"){this.prefix=t}getKey(t){return t.startsWith(this.prefix)?t:`${this.prefix}${t}`}get(t){if("undefined"==typeof window||!window.localStorage)return null;try{return localStorage.getItem(this.getKey(t))}catch{return console.warn(`[Baasix SDK] Failed to get item from localStorage: ${t}`),null}}set(t,e){if("undefined"!=typeof window&&window.localStorage)try{localStorage.setItem(this.getKey(t),e)}catch{console.warn(`[Baasix SDK] Failed to set item in localStorage: ${t}`)}}remove(t){if("undefined"!=typeof window&&window.localStorage)try{localStorage.removeItem(this.getKey(t))}catch{console.warn(`[Baasix SDK] Failed to remove item from localStorage: ${t}`)}}clear(){if("undefined"!=typeof window&&window.localStorage)try{let t=[];for(let e=0;e<localStorage.length;e++){let s=localStorage.key(e);s?.startsWith(this.prefix)&&t.push(s)}t.forEach(t=>localStorage.removeItem(t))}catch{console.warn("[Baasix SDK] Failed to clear localStorage")}}},o=class{store;constructor(){this.store=new Map}get(t){return this.store.get(t)??null}set(t,e){this.store.set(t,e)}remove(t){this.store.delete(t)}clear(){this.store.clear()}keys(){return Array.from(this.store.keys())}size(){return this.store.size}},c=class{client;storage;authMode;onAuthStateChange;currentUser=null;constructor(t){this.client=t.client,this.storage=t.storage,this.authMode=t.authMode,this.onAuthStateChange=t.onAuthStateChange}emitAuthStateChange(t,e){this.currentUser=e,this.onAuthStateChange?.(t,e)}async storeTokens(t){if("jwt"===this.authMode&&(await this.storage.set(i.ACCESS_TOKEN,t.token),t.refreshToken&&await this.storage.set(i.REFRESH_TOKEN,t.refreshToken),t.expiresIn)){let e=Date.now()+1e3*t.expiresIn;await this.storage.set(i.TOKEN_EXPIRY,e.toString())}t.user&&await this.storage.set(i.USER,JSON.stringify(t.user))}async clearAuth(){await this.storage.remove(i.ACCESS_TOKEN),await this.storage.remove(i.REFRESH_TOKEN),await this.storage.remove(i.TOKEN_EXPIRY),await this.storage.remove(i.USER),await this.storage.remove(i.TENANT),this.currentUser=null}async register(t){let e=await this.client.post("/auth/register",t,{skipAuth:!0});return await this.storeTokens(e),this.emitAuthStateChange("SIGNED_IN",e.user),e}async login(t){let e=await this.client.post("/auth/login",{email:t.email,password:t.password,tenant_Id:t.tenantId,authMode:t.authMode,authType:t.authType},{skipAuth:!0});return await this.storeTokens(e),this.emitAuthStateChange("SIGNED_IN",e.user),e}async logout(){try{await this.client.get("/auth/logout")}catch{}await this.clearAuth(),this.emitAuthStateChange("SIGNED_OUT",null)}async getUser(){try{let t=await this.client.get("/auth/me");return this.currentUser=t.user,await this.storage.set(i.USER,JSON.stringify(t.user)),t.user}catch(t){if(t instanceof a&&401===t.status)return await this.clearAuth(),null;throw t}}async me(){return this.getUser()}async getCachedUser(){if(this.currentUser)return this.currentUser;let t=await this.storage.get(i.USER);if(t)try{return this.currentUser=JSON.parse(t),this.currentUser}catch{}return null}async isAuthenticated(){if("cookie"===this.authMode)return null!==await this.getCachedUser();if(!await this.storage.get(i.ACCESS_TOKEN))return!1;let t=await this.storage.get(i.TOKEN_EXPIRY);return!(t&&Date.now()>=parseInt(t,10))||!!await this.storage.get(i.REFRESH_TOKEN)}async getToken(){return"cookie"===this.authMode?null:await this.storage.get(i.ACCESS_TOKEN)}async setToken(t){await this.storage.set(i.ACCESS_TOKEN,t)}async refreshToken(){let t=await this.storage.get(i.REFRESH_TOKEN),e=await this.client.post("/auth/refresh","jwt"===this.authMode?{refreshToken:t,authMode:"jwt"}:{authMode:"cookie"});await this.storeTokens(e);let s={accessToken:e.token,refreshToken:e.refreshToken,expiresIn:e.expiresIn,expiresAt:e.expiresIn?Date.now()+1e3*e.expiresIn:void 0};return this.emitAuthStateChange("TOKEN_REFRESHED",e.user),s}async sendMagicLink(t){await this.client.post("/auth/magiclink",{email:t.email,link:t.redirectUrl,mode:t.mode||"link"},{skipAuth:!0})}async verifyMagicLink(t){let e=await this.client.get(`/auth/magiclink/${encodeURIComponent(t)}`,{skipAuth:!0});return await this.storeTokens(e),this.emitAuthStateChange("SIGNED_IN",e.user),e}async forgotPassword(t){await this.client.post("/auth/password/reset",{email:t.email,link:t.redirectUrl},{skipAuth:!0})}async resetPassword(t,e){await this.client.post(`/auth/password/reset/${encodeURIComponent(t)}`,{password:e},{skipAuth:!0})}async changePassword(t,e){await this.client.post("/auth/password/change",{currentPassword:t,newPassword:e})}async getTenants(){return(await this.client.get("/auth/tenants")).tenants}async switchTenant(t){let e=await this.client.post("/auth/switch-tenant",{tenant_Id:t});return await this.storeTokens(e),await this.storage.set(i.TENANT,t),this.emitAuthStateChange("TENANT_SWITCHED",e.user),e}async getState(){let t=await this.isAuthenticated();return{user:await this.getCachedUser(),isAuthenticated:t,isLoading:!1,error:null}}async initialize(){let t=await this.getState();return t.isAuthenticated&&t.user&&this.emitAuthStateChange("SIGNED_IN",t.user),t}getOAuthUrl(t){let e=this.client.getBaseUrl(),s=new URLSearchParams({redirect_url:t.redirectUrl});return t.scopes?.length&&s.set("scopes",t.scopes.join(",")),t.state&&s.set("state",t.state),`${e}/auth/signin/${t.provider}?${s.toString()}`}async handleOAuthCallback(t){await this.storage.set(i.ACCESS_TOKEN,t);let e=await this.getUser();return this.emitAuthStateChange("SIGNED_IN",e),{token:t,user:e}}async requestEmailVerification(t){await this.client.post("/auth/email/verify",{link:t})}async verifyEmail(t){await this.client.get(`/auth/email/verify/${encodeURIComponent(t)}`,{skipAuth:!0})}async checkSession(){try{return(await this.client.get("/auth/check")).valid}catch{return!1}}async sendInvite(t){await this.client.post("/auth/invite",{email:t.email,role_Id:t.roleId,tenant_Id:t.tenantId,link:t.redirectUrl})}async verifyInvite(t,e){return await this.client.get(`/auth/verify-invite/${encodeURIComponent(t)}`,{params:{link:e},skipAuth:!0})}async acceptInvite(t){let e=await this.client.post("/auth/accept-invite",{inviteToken:t});return await this.storeTokens(e),this.emitAuthStateChange("SIGNED_IN",e.user),e}async registerWithInvite(t){let e=await this.client.post("/auth/register",{...t,inviteToken:t.inviteToken},{skipAuth:!0});return await this.storeTokens(e),this.emitAuthStateChange("SIGNED_IN",e.user),e}},l=class{collection;client;queryParams={};constructor(t,e){this.collection=t,this.client=e}select(...t){let e=1===t.length&&Array.isArray(t[0])?t[0]:t;return this.queryParams.fields=e,this}fields(...t){return this.select(...t)}filter(t){return this.queryParams.filter=t,this}where(t){return this.filter(t)}sort(t){return this.queryParams.sort=t,this}orderBy(t){return this.sort(t)}limit(t){return this.queryParams.limit=t,this}page(t){return this.queryParams.page=t,this}offset(t){return this.queryParams.offset=t,this}search(t,e){return this.queryParams.search=t,e&&(this.queryParams.searchFields=e),this}withDeleted(){return this.queryParams.paranoid=!1,this}relFilter(t){return this.queryParams.relConditions=t,this}getQuery(){return{...this.queryParams}}async get(){return this.client.get(`/items/${this.collection}`,{params:this.buildParams()})}async first(){return(await this.limit(1).get()).data[0]||null}async count(){return(await this.client.get(`/items/${this.collection}`,{params:{...this.buildParams(),limit:0}})).totalCount||0}buildParams(){let t={};return this.queryParams.fields&&(t.fields=this.queryParams.fields),this.queryParams.filter&&(t.filter=this.queryParams.filter),this.queryParams.sort&&(t.sort=this.queryParams.sort),void 0!==this.queryParams.limit&&(t.limit=this.queryParams.limit),void 0!==this.queryParams.page&&(t.page=this.queryParams.page),void 0!==this.queryParams.offset&&(t.offset=this.queryParams.offset),this.queryParams.search&&(t.search=this.queryParams.search),this.queryParams.searchFields&&(t.searchFields=this.queryParams.searchFields),void 0!==this.queryParams.paranoid&&(t.paranoid=this.queryParams.paranoid),this.queryParams.relConditions&&(t.relConditions=this.queryParams.relConditions),this.queryParams.aggregate&&(t.aggregate=this.queryParams.aggregate),this.queryParams.groupBy&&(t.groupBy=this.queryParams.groupBy),t}},h=class{collection;client;constructor(t,e){this.collection=t,this.client=e.client}query(){return new l(this.collection,this.client)}async find(t){return this.client.get(`/items/${this.collection}`,{params:t})}async findMany(t){return this.find(t)}async findOne(t,e){return(await this.client.get(`/items/${this.collection}/${t}`,{params:e})).data}async get(t,e){return this.findOne(t,e)}async create(t){return(await this.client.post(`/items/${this.collection}`,t)).data}async insert(t){return this.create(t)}async createMany(t){return(await this.client.post(`/items/${this.collection}/bulk`,t)).data}async insertMany(t){return this.createMany(t)}async update(t,e){return(await this.client.patch(`/items/${this.collection}/${t}`,e)).data}async updateMany(t,e){let s=t.map(t=>({id:t,data:e}));return(await this.client.patch(`/items/${this.collection}/bulk`,s)).data}async upsert(t,e){let s=await this.find({filter:t,limit:1});return s.data.length>0?this.update(s.data[0].id,e):this.create(e)}async delete(t){await this.client.delete(`/items/${this.collection}/${t}`)}async deleteMany(t){await this.client.delete(`/items/${this.collection}/bulk`,{body:JSON.stringify(t)})}async softDelete(t){await this.update(t,{deletedAt:new Date().toISOString()})}async restore(t){await this.update(t,{deletedAt:null})}async aggregate(t){return(await this.client.get(`/items/${this.collection}`,{params:t})).data}async importCSV(t){let e=new FormData;return File,e.append("csvFile",t),(await this.client.post(`/items/${this.collection}/import-csv`,e)).results}async importJSON(t){let e=new FormData;return File,e.append("jsonFile",t),(await this.client.post(`/items/${this.collection}/import-json`,e)).results}async importData(t){return await this.client.post(`/items/${this.collection}/bulk`,t)}async sortItem(t,e,s="before"){await this.client.post(`/utils/sort/${this.collection}`,{item:t,to:e,mode:s})}async reorder(t){for(let e=1;e<t.length;e++)await this.client.post(`/utils/sort/${this.collection}`,{item:t[e],to:t[e-1],mode:"after"})}},u=class{client;constructor(t){this.client=t.client}async upload(t,e){let s=new FormData;return t instanceof File||Blob,s.append("file",t),e?.title&&s.append("title",e.title),e?.description&&s.append("description",e.description),e?.folder&&s.append("folder",e.folder),e?.storage&&s.append("storage",e.storage),e?.isPublic!==void 0&&s.append("isPublic",String(e.isPublic)),e?.metadata&&s.append("metadata",JSON.stringify(e.metadata)),(await this.client.upload("/files",s,{onProgress:e?.onProgress,timeout:e?.timeout})).data}async uploadMany(t,e){let s=[];for(let i of t instanceof FileList?Array.from(t):t){let t=await this.upload(i,e);s.push(t)}return s}async find(t){return this.client.get("/files",{params:t})}async findOne(t){return(await this.client.get(`/files/${t}`)).data}async update(t,e){return(await this.client.patch(`/files/${t}`,e)).data}async delete(t){await this.client.delete(`/files/${t}`)}async deleteMany(t){await Promise.all(t.map(t=>this.delete(t)))}getAssetUrl(t,e){let s=new URL(`/assets/${t}`,this.client.getBaseUrl());return e&&(e.width&&s.searchParams.set("width",String(e.width)),e.height&&s.searchParams.set("height",String(e.height)),e.fit&&s.searchParams.set("fit",e.fit),e.quality&&s.searchParams.set("quality",String(e.quality)),e.format&&s.searchParams.set("format",e.format)),s.toString()}async download(t,e){let s=this.getAssetUrl(t,e),i=await fetch(s);if(!i.ok)throw Error(`Failed to download file: ${i.statusText}`);return i.blob()}async toBase64(t,e){let s=await this.download(t,e);return new Promise((t,e)=>{let i=new FileReader;i.onloadend=()=>{t(i.result.split(",")[1])},i.onerror=e,i.readAsDataURL(s)})}async importFromUrl(t,e){return(await this.client.post("/files/import",{url:t,...e})).data}},d=class{client;constructor(t){this.client=t.client}async find(t){let e=t?{...t,sort:function(t){if(t){if("string"==typeof t)return t;if(Array.isArray(t))return 0===t.length?void 0:"object"==typeof t[0]&&"column"in t[0]?t.map(t=>`${t.column}:${t.order.toLowerCase()}`).join(","):t.map(t=>t.startsWith("-")?`${t.substring(1)}:desc`:t.includes(":")?t:`${t}:asc`).join(",");if("object"==typeof t){let e=Object.entries(t);if(0===e.length)return;return e.map(([t,e])=>`${t}:${e.toLowerCase()}`).join(",")}}}(t.sort)}:void 0;return this.client.get("/schemas",{params:e})}async findOne(t){return(await this.client.get(`/schemas/${t}`)).data}async create(t){return(await this.client.post("/schemas",t)).data}async update(t,e){return(await this.client.patch(`/schemas/${t}`,e)).data}async delete(t){await this.client.delete(`/schemas/${t}`)}async createRelationship(t,e){await this.client.post(`/schemas/${t}/relationships`,e)}async deleteRelationship(t,e){await this.client.delete(`/schemas/${t}/relationships/${e}`)}async updateRelationship(t,e,s){await this.client.patch(`/schemas/${t}/relationships/${e}`,s)}async createIndex(t,e){await this.client.post(`/schemas/${t}/indexes`,e)}async deleteIndex(t,e){await this.client.delete(`/schemas/${t}/indexes/${e}`)}async addField(t,e,s){let i=await this.findOne(t),a={...i.schema.fields,[e]:s};return this.update(t,{schema:{...i.schema,fields:a}})}async removeField(t,e){let s=await this.findOne(t),{[e]:i,...a}=s.schema.fields;return this.update(t,{schema:{...s.schema,fields:a}})}async export(){return(await this.client.get("/schemas/export")).data}async import(t){await this.client.post("/schemas/import",{schemas:t})}},m=class{client;constructor(t){this.client=t.client}async find(t){return this.client.get("/notifications",{params:t})}async getUnreadCount(){return(await this.client.get("/notifications/unread/count")).count}async markAsSeen(t){return{count:(await this.client.post("/notifications/mark-seen",{notificationIds:t})).count}}async delete(t){return{count:(await this.client.delete("/notifications",{params:t?{notificationIds:t}:void 0})).count}}async send(t){return{notificationIds:(await this.client.post("/notifications/send",t)).notificationIds}}async cleanup(t=30){return{count:(await this.client.post("/notifications/cleanup",{days:t})).count}}},g=class{client;constructor(t){this.client=t.client}async find(t){return this.client.get("/permissions",{params:t})}async findOne(t){return(await this.client.get(`/permissions/${t}`)).data}async findByRole(t){return this.client.get("/permissions",{params:{filter:{role_Id:{eq:t}},limit:-1}})}async findByCollection(t){return this.client.get("/permissions",{params:{filter:{collection:{eq:t}},limit:-1}})}async create(t){return(await this.client.post("/permissions",t)).data}async update(t,e){return(await this.client.patch(`/permissions/${t}`,e)).data}async delete(t){await this.client.delete(`/permissions/${t}`)}async getRoles(){return this.client.get("/items/baasix_Role",{params:{limit:-1}})}async createCrudPermissions(t,e,s){let i=[];for(let a of["create","read","update","delete"]){let r=s[a];if(!1===r)continue;let n=await this.create({role_Id:t,collection:e,action:a,fields:r?.fields||["*"],conditions:r?.conditions});i.push(n)}return i}async reloadCache(){await this.client.post("/permissions/reload")}async export(){return(await this.client.post("/permissions-export",{})).data}async import(t,e){return(await this.client.post("/permissions-import",{...t,...e})).data}},w=class{client;constructor(t){this.client=t.client}async get(){return(await this.client.get("/settings")).data}async getKey(t){return(await this.get())[t]??null}async update(t){return(await this.client.patch("/settings",t)).data}async set(t,e){return this.update({[t]:e})}async getByAppUrl(t){return(await this.client.get("/settings/by-app-url",{params:{appUrl:t}})).data}async getBranding(){return(await this.client.get("/settings/branding")).data}async testEmail(t){return await this.client.post("/settings/test-email",{to:t})}async reload(){await this.client.post("/settings/reload")}async deleteTenant(){await this.client.delete("/settings/tenant")}},p=class{client;constructor(t){this.client=t.client}async generate(t,e){return await this.client.post(`/reports/${t}`,e)}async query(t,e){return await this.client.get(`/reports/${t}`,{params:e})}async getStats(t){return await this.client.post("/reports/stats",{stats:t})}async aggregate(t,e){return(await this.client.get(`/items/${t}`,{params:{aggregate:e.aggregate,groupBy:e.groupBy,filter:e.filter,sort:e.sort,limit:e.limit??-1,page:e.page}})).data}async count(t,e){return(await this.client.get(`/items/${t}`,{params:{filter:e,limit:0}})).totalCount||0}async distinct(t,e,s){return(await this.client.post(`/reports/${t}`,{fields:[e],groupBy:[e],aggregate:{_count:{function:"distinct",field:e}},filter:s,limit:-1})).data.map(t=>t[e])}},f=class{client;constructor(t){this.client=t.client}async find(t){return this.client.get("/workflows",{params:t})}async findOne(t){return(await this.client.get(`/workflows/${t}`)).data}async create(t){return(await this.client.post("/workflows",t)).data}async update(t,e){return(await this.client.patch(`/workflows/${t}`,e)).data}async delete(t){await this.client.delete(`/workflows/${t}`)}async execute(t,e){return(await this.client.post(`/workflows/${t}/execute`,{triggerData:e})).data}async test(t,e){return(await this.client.post(`/workflows/${t}/test`,{triggerData:e})).data}async getExecutions(t,e){return this.client.get(`/workflows/${t}/executions`,{params:e})}async getExecution(t,e){return(await this.client.get(`/workflows/${t}/executions/${e}`)).data}async cancelExecution(t,e){await this.client.post(`/workflows/${t}/executions/${e}/cancel`)}async enable(t){return this.update(t,{isActive:!0})}async disable(t){return this.update(t,{isActive:!1})}async duplicate(t,e){let{id:s,createdAt:i,updatedAt:a,...r}=await this.findOne(t);return this.create({...r,name:`Copy of ${r.name}`,...e})}async executeNode(t,e,s){return(await this.client.post(`/workflows/${t}/nodes/${e}/execute`,{triggerData:s})).data}async getExecutionLogs(t,e){return(await this.client.get(`/workflows/${t}/executions/${e}/logs`)).data}async getStats(t){return(await this.client.get(`/workflows/${t}/stats`)).data}async validate(t){return await this.client.post("/workflows/validate",t)}async export(t){return(await this.client.get(`/workflows/${t}/export`)).data}async exportAll(t){return(await this.client.post("/workflows/export",t||{})).data}async importPreview(t){let e=new FormData;return File,e.append("file",t),(await this.client.post("/workflows/import/preview",e)).data}async import(t,e){let s=new FormData;return File,s.append("file",t),e?.overwrite!==void 0&&s.append("overwrite",String(e.overwrite)),(await this.client.post("/workflows/import",s)).data}},y=class{client;storage;socket=null;socketClient=null;socketUrl;socketPath;subscriptions=new Map;workflowCallbacks=new Map;roomCallbacks=new Map;roomUserCallbacks=new Map;kickCallbacks=new Map;creatorChangedCallbacks=new Map;connectionCallbacks=new Set;reconnecting=!1;connectionPromise=null;constructor(t){this.client=t.client,this.storage=t.storage,this.socketUrl=t.socketUrl||"",this.socketPath=t.socketPath||"/realtime"}setSocketClient(t){this.socketClient=t}setSocketUrl(t){this.socketUrl=t}ensureSocketClient(){if(!this.socketClient)throw Error("Socket.io client not set. Please call baasix.realtime.setSocketClient(io) with socket.io-client.")}async getAuthToken(){return await this.storage.get(i.ACCESS_TOKEN)}async connect(){if(this.connectionPromise)return this.connectionPromise;if(this.socket?.connected)return Promise.resolve();this.ensureSocketClient(),this.connectionPromise=new Promise(async(t,e)=>{try{let s=await this.getAuthToken(),i=this.socketUrl||this.client.getBaseUrl();this.socket=this.socketClient(i,{auth:{token:s||void 0},path:this.socketPath,transports:["websocket","polling"],reconnection:!0,reconnectionAttempts:10,reconnectionDelay:1e3,timeout:2e4}),this.socket.on("connect",()=>{console.log("[Baasix Realtime] Connected"),this.reconnecting=!1,this.notifyConnectionChange(!0),t()}),this.socket.on("disconnect",t=>{console.log("[Baasix Realtime] Disconnected:",t),this.notifyConnectionChange(!1)}),this.socket.on("connect_error",t=>{console.error("[Baasix Realtime] Connection error:",t.message),this.reconnecting||e(t)}),this.socket.on("reconnect",()=>{console.log("[Baasix Realtime] Reconnected"),this.reconnecting=!1,this.resubscribeAll(),this.notifyConnectionChange(!0)}),this.socket.on("reconnect_attempt",()=>{this.reconnecting=!0}),this.socket.on("connected",t=>{console.log("[Baasix Realtime] Authenticated as user:",t.userId)}),this.socket.on("workflow:execution:update",t=>{this.handleWorkflowUpdate(t)}),this.socket.on("workflow:execution:complete",t=>{this.handleWorkflowUpdate({...t,status:"complete"})}),this.socket.on("room:user:joined",t=>{let e=this.roomUserCallbacks.get(t.room);e?.joined.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Realtime] Error in room user joined callback:",t)}})}),this.socket.on("room:user:left",t=>{let e=this.roomUserCallbacks.get(t.room);e?.left.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Realtime] Error in room user left callback:",t)}})}),this.socket.on("room:kicked",t=>{let e=this.kickCallbacks.get(t.room);e?.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Realtime] Error in room kicked callback:",t)}}),this.cleanupRoomListeners(t.room)}),this.socket.on("room:creator:changed",t=>{let e=this.creatorChangedCallbacks.get(t.room);e?.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Realtime] Error in room creator changed callback:",t)}})}),this.socket.connect()}catch(t){this.connectionPromise=null,e(t)}});try{await this.connectionPromise}finally{this.connectionPromise=null}}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null),this.subscriptions.clear(),this.workflowCallbacks.clear(),this.roomCallbacks.clear(),this.roomUserCallbacks.clear(),this.kickCallbacks.clear(),this.creatorChangedCallbacks.clear()}get isConnected(){return this.socket?.connected??!1}onConnectionChange(t){return this.connectionCallbacks.add(t),()=>{this.connectionCallbacks.delete(t)}}notifyConnectionChange(t){this.connectionCallbacks.forEach(e=>e(t))}subscribe(t,e){this.socket?.connected||console.warn("[Baasix Realtime] Not connected. Call connect() first.");let s=`${Date.now()}-${Math.random().toString(36).substr(2,9)}`,i=this.subscriptions.get(t);return i||(i={collection:t,callbacks:new Map},this.subscriptions.set(t,i),this.subscribeOnServer(t),this.setupCollectionListeners(t)),i.callbacks.set(s,e),()=>{let e=this.subscriptions.get(t);e&&(e.callbacks.delete(s),0===e.callbacks.size&&(this.unsubscribeOnServer(t),this.removeCollectionListeners(t),this.subscriptions.delete(t)))}}on(t,e,s){return this.subscribe(t,t=>{t.action===e&&s(t.data)})}onAny(t){let e=[];return this.subscriptions.forEach((s,i)=>{let a=this.subscribe(i,e=>{t(i,e)});e.push(a)}),()=>{e.forEach(t=>t())}}subscribeOnServer(t){this.socket?.connected&&this.socket.emit("subscribe",{collection:t},e=>{"error"===e.status&&console.error(`[Baasix Realtime] Failed to subscribe to ${t}:`,e.message)})}unsubscribeOnServer(t){this.socket?.connected&&this.socket.emit("unsubscribe",{collection:t})}setupCollectionListeners(t){this.socket&&["create","update","delete"].forEach(e=>{let s=`${t}:${e}`;this.socket.on(s,e=>{this.handleCollectionEvent(t,e)})})}removeCollectionListeners(t){this.socket&&["create","update","delete"].forEach(e=>{let s=`${t}:${e}`;this.socket.off(s)})}handleCollectionEvent(t,e){let s=this.subscriptions.get(t);s&&s.callbacks.forEach(t=>{try{t(e)}catch(t){console.error("[Baasix Realtime] Error in subscription callback:",t)}})}resubscribeAll(){this.subscriptions.forEach((t,e)=>{this.subscribeOnServer(e),this.setupCollectionListeners(e)})}subscribeToExecution(t,e){let s=String(t);this.socket?.connected&&this.socket.emit("workflow:execution:join",{executionId:s});let i=this.workflowCallbacks.get(s);return i||(i=new Set,this.workflowCallbacks.set(s,i)),i.add(e),()=>{let t=this.workflowCallbacks.get(s);t&&(t.delete(e),0===t.size&&this.workflowCallbacks.delete(s))}}handleWorkflowUpdate(t){let e=String(t.executionId),s=this.workflowCallbacks.get(e);s&&s.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Realtime] Error in workflow callback:",t)}})}async joinRoom(t,e={}){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");return new Promise((s,i)=>{this.socket.emit("room:join",{room:t,metadata:e},e=>{"success"===e.status?(this.setupRoomListeners(t),s({history:e.history??[]})):i(Error(e.message||"Failed to join room"))})})}async leaveRoom(t){if(this.socket?.connected)return new Promise((e,s)=>{this.socket.emit("room:leave",{room:t},i=>{"success"===i.status?(this.cleanupRoomListeners(t),e()):s(Error(i.message||"Failed to leave room"))})})}async getRoomMembers(t){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");return new Promise((e,s)=>{this.socket.emit("room:members",{room:t},t=>{"success"===t.status?e(t.members):s(Error(t.message||"Failed to get room members"))})})}async listRooms(t){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");return new Promise((e,s)=>{this.socket.emit("room:list",{prefix:t??""},t=>{"success"===t.status?e(t.rooms):s(Error(t.message||"Failed to list rooms"))})})}async kickFromRoom(t,e){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");return new Promise((s,i)=>{this.socket.emit("room:kick",{room:t,userId:e},t=>{"success"===t.status?s():i(Error(t.message||"Failed to kick user"))})})}onKicked(t,e){return this.kickCallbacks.has(t)||this.kickCallbacks.set(t,new Set),this.kickCallbacks.get(t).add(e),()=>{let s=this.kickCallbacks.get(t);s&&(s.delete(e),0===s.size&&this.kickCallbacks.delete(t))}}onRoomCreatorChanged(t,e){return this.creatorChangedCallbacks.has(t)||this.creatorChangedCallbacks.set(t,new Set),this.creatorChangedCallbacks.get(t).add(e),()=>{let s=this.creatorChangedCallbacks.get(t);s&&(s.delete(e),0===s.size&&this.creatorChangedCallbacks.delete(t))}}async sendToRoom(t,e,s,i={}){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");let a=i.history??!0;return new Promise((i,r)=>{this.socket.emit("room:message",{room:t,event:e,payload:s,history:a},t=>{"success"===t.status?i():r(Error(t.message||"Failed to send message"))})})}onRoomMessage(t,e,s){this.roomCallbacks.has(t)||this.roomCallbacks.set(t,new Map);let i=this.roomCallbacks.get(t);return i.has(e)||i.set(e,new Set),i.get(e).add(s),()=>{let i=this.roomCallbacks.get(t);if(i){let a=i.get(e);a&&(a.delete(s),0===a.size&&i.delete(e)),0===i.size&&this.roomCallbacks.delete(t)}}}onRoomUserJoined(t,e){return this.roomUserCallbacks.has(t)||this.roomUserCallbacks.set(t,{joined:new Set,left:new Set}),this.roomUserCallbacks.get(t).joined.add(e),()=>{let s=this.roomUserCallbacks.get(t);s&&(s.joined.delete(e),0===s.joined.size&&0===s.left.size&&this.roomUserCallbacks.delete(t))}}onRoomUserLeft(t,e){return this.roomUserCallbacks.has(t)||this.roomUserCallbacks.set(t,{joined:new Set,left:new Set}),this.roomUserCallbacks.get(t).left.add(e),()=>{let s=this.roomUserCallbacks.get(t);s&&(s.left.delete(e),0===s.joined.size&&0===s.left.size&&this.roomUserCallbacks.delete(t))}}async invoke(t,e){if(!this.socket?.connected)throw Error("Not connected. Call connect() first.");return new Promise((s,i)=>{this.socket.emit("custom",{event:t,payload:e},t=>{"success"===t.status?s(t):i(Error(t.message||"Custom event failed"))})})}setupRoomListeners(t){this.roomCallbacks.has(t)||this.roomCallbacks.set(t,new Map),this.roomUserCallbacks.has(t)||this.roomUserCallbacks.set(t,{joined:new Set,left:new Set})}cleanupRoomListeners(t){this.roomCallbacks.delete(t),this.roomUserCallbacks.delete(t),this.kickCallbacks.delete(t),this.creatorChangedCallbacks.delete(t)}channel(t){return new k(this,t)}},k=class{realtime;collection;handlers=new Map;unsubscribeFn=null;constructor(t,e){this.realtime=t,this.collection=e}on(t,e){let s=this.mapEvent(t);return"*"===s?["create","update","delete"].forEach(t=>{this.addHandler(t,e)}):this.addHandler(s,e),this}mapEvent(t){switch(t.toUpperCase()){case"INSERT":return"create";case"UPDATE":return"update";case"DELETE":return"delete";default:return"*"}}addHandler(t,e){this.handlers.has(t)||this.handlers.set(t,[]),this.handlers.get(t).push(e)}subscribe(){return this.unsubscribeFn=this.realtime.subscribe(this.collection,t=>{let e=this.handlers.get(t.action);e&&e.forEach(e=>{try{e(t)}catch(t){console.error("[Baasix Channel] Handler error:",t)}})}),this}unsubscribe(){this.unsubscribeFn&&(this.unsubscribeFn(),this.unsubscribeFn=null),this.handlers.clear()}},C=class{client;collection="baasix_Role";constructor(t){this.client=t.client}async find(){return this.client.get(`/items/${this.collection}`,{params:{limit:-1}})}async findOne(t){return(await this.client.get(`/items/${this.collection}/${t}`)).data}async findByName(t){return(await this.client.get(`/items/${this.collection}`,{params:{filter:JSON.stringify({name:{eq:t}}),limit:1}})).data[0]||null}async create(t){return(await this.client.post(`/items/${this.collection}`,t)).data.id}async update(t,e){await this.client.patch(`/items/${this.collection}/${t}`,e)}async delete(t){await this.client.delete(`/items/${this.collection}/${t}`)}},b=class{client;collection="baasix_User";constructor(t){this.client=t.client}async find(t={}){let e={};return t.filter&&(e.filter=JSON.stringify(t.filter)),t.sort&&(e.sort=t.sort),void 0!==t.limit&&(e.limit=t.limit),void 0!==t.page&&(e.page=t.page),t.fields?.length&&(e.fields=t.fields.join(",")),this.client.get(`/items/${this.collection}`,{params:e})}async findOne(t,e){let s={};return e?.length&&(s.fields=e.join(",")),(await this.client.get(`/items/${this.collection}/${t}`,{params:s})).data}async findByEmail(t){return(await this.client.get(`/items/${this.collection}`,{params:{filter:JSON.stringify({email:{eq:t}}),limit:1}})).data[0]||null}async create(t){return(await this.client.post(`/items/${this.collection}`,t)).data.id}async update(t,e){await this.client.patch(`/items/${this.collection}/${t}`,e)}async delete(t){await this.client.delete(`/items/${this.collection}/${t}`)}async changePassword(t,e){await this.client.post("/auth/admin/change-password",{userId:t,password:e})}async suspend(t){await this.client.patch(`/items/${this.collection}/${t}`,{status:"suspended"})}async activate(t){await this.client.patch(`/items/${this.collection}/${t}`,{status:"active"})}async createMany(t){return(await this.client.post(`/items/${this.collection}/bulk`,t)).data}async deleteMany(t){await this.client.delete(`/items/${this.collection}/bulk`,{body:JSON.stringify(t)})}},E=class{client;constructor(t){this.client=t.client}async status(){return(await this.client.get("/migrations/status")).data}async list(t){return(await this.client.get("/migrations",{params:t})).data}async pending(){return(await this.client.get("/migrations/pending")).data}async check(){return(await this.client.get("/migrations/check")).data}async get(t){try{return(await this.client.get(`/migrations/${encodeURIComponent(t)}`)).data}catch{return null}}async run(t){return(await this.client.post("/migrations/run",t||{})).data}async rollback(t){return(await this.client.post(`/migrations/rollback/${encodeURIComponent(t)}`,{})).data}async rollbackBatch(){return(await this.client.post("/migrations/rollback-batch",{})).data}async create(t,e){return(await this.client.post("/migrations/create",{name:t,...e})).data}async markCompleted(t,e){return(await this.client.post(`/migrations/mark-completed/${encodeURIComponent(t)}`,{metadata:e})).data}async markAllCompleted(t){return(await this.client.post("/migrations/mark-all-completed",{toVersion:t})).data}},S=class{client;constructor(t){this.client=t.client}async info(){return this.client.get("/")}async health(){try{return await this.client.get("/health"),!0}catch{return!1}}},T=class{config;httpClient;storage;auth;files;schemas;notifications;permissions;settings;reports;workflows;realtime;roles;users;migrations;server;itemsModules=new Map;constructor(t){if(!t.url)throw Error("Baasix SDK: url is required");let e=t.url.replace(/\/$/,"");this.config={...t,url:e,authMode:t.authMode||"jwt",timeout:t.timeout||6e5,autoRefresh:!1!==t.autoRefresh},this.storage=t.storage||("undefined"!=typeof window&&void 0!==window.localStorage?new n:new o);let s=t.credentials||("cookie"===this.config.authMode?"include":"same-origin");this.httpClient=new r({baseUrl:e,authMode:this.config.authMode,storage:this.storage,timeout:this.config.timeout,autoRefresh:this.config.autoRefresh,credentials:s,headers:t.headers||{},token:t.token,tenantId:t.tenantId,onAuthError:()=>{this.config.onAuthStateChange?.("SIGNED_OUT",null)},onTokenRefresh:()=>{}}),this.auth=new c({client:this.httpClient,storage:this.storage,authMode:this.config.authMode,onAuthStateChange:t.onAuthStateChange}),this.files=new u({client:this.httpClient}),this.schemas=new d({client:this.httpClient}),this.notifications=new m({client:this.httpClient}),this.permissions=new g({client:this.httpClient}),this.settings=new w({client:this.httpClient}),this.reports=new p({client:this.httpClient}),this.workflows=new f({client:this.httpClient}),this.roles=new C({client:this.httpClient}),this.users=new b({client:this.httpClient}),this.migrations=new E({client:this.httpClient}),this.server=new S({client:this.httpClient}),this.realtime=new y({client:this.httpClient,storage:this.storage,socketUrl:t.socketUrl,socketPath:t.socketPath})}items(t){return this.itemsModules.has(t)||this.itemsModules.set(t,new h(t,{client:this.httpClient})),this.itemsModules.get(t)}collection(t){return this.items(t)}from(t){return this.items(t)}get request(){return this.httpClient}configure(t){t.headers&&this.httpClient.updateConfig({headers:t.headers}),void 0!==t.tenantId&&this.httpClient.updateConfig({tenantId:t.tenantId}),t.token&&this.httpClient.updateConfig({token:t.token}),t.timeout&&this.httpClient.updateConfig({timeout:t.timeout})}async setTenant(t){this.httpClient.updateConfig({tenantId:t}),await this.storage.set(i.TENANT,t)}async getTenant(){return await this.storage.get(i.TENANT)}async clearTenant(){this.httpClient.updateConfig({tenantId:void 0}),await this.storage.remove(i.TENANT)}async setToken(t){return this.auth.setToken(t)}async getToken(){return this.storage.get(i.ACCESS_TOKEN)}getUrl(){return this.config.url}getAuthMode(){return this.config.authMode}getStorage(){return this.storage}};function $(t){return new T(t)}}}]);
|