@decocms/mesh 2.65.0 → 2.65.1
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/client/assets/{AlertCircle-BLu8Aodi.js → AlertCircle-Sq0aBvsC.js} +1 -1
- package/dist/client/assets/{ArrowUp-TSXJSHlb.js → ArrowUp-CvxgIRrE.js} +1 -1
- package/dist/client/assets/{Calendar-B_PCwOFB.js → Calendar-DS_6zH5D.js} +1 -1
- package/dist/client/assets/{Check-TVVdApmr.js → Check-DNCI8C1c.js} +1 -1
- package/dist/client/assets/{CheckCircle-BZgpD8UD.js → CheckCircle-COsIOW0_.js} +1 -1
- package/dist/client/assets/{ChevronDown-DQimov-w.js → ChevronDown-CmDSkkyU.js} +1 -1
- package/dist/client/assets/{ChevronRight-C1wmaJaY.js → ChevronRight-Cme_aOxM.js} +1 -1
- package/dist/client/assets/{Code01-C-_CZ4Yt.js → Code01-DlwIBx5j.js} +1 -1
- package/dist/client/assets/{Copy01-CsYLZnEs.js → Copy01-CX9SC5FE.js} +1 -1
- package/dist/client/assets/{DotsHorizontal-DoBmdgcU.js → DotsHorizontal-Dz0bRPai.js} +1 -1
- package/dist/client/assets/{DotsVertical-BmpdBChT.js → DotsVertical-CC8faZfe.js} +1 -1
- package/dist/client/assets/{Download01-dA91PaJn.js → Download01-Cj1VuArg.js} +1 -1
- package/dist/client/assets/{Edit01-Cax2qmzX.js → Edit01-C8mqwImV.js} +1 -1
- package/dist/client/assets/{File02-SOxsIjUX.js → File02-3scwR97O.js} +1 -1
- package/dist/client/assets/{File06-CJnXWkSw.js → File06-BmoKv1ZA.js} +1 -1
- package/dist/client/assets/{FilterLines-BciMLF4N.js → FilterLines-BcuJXQ3t.js} +1 -1
- package/dist/client/assets/{Globe02-CZ780J53.js → Globe02-BQTpYCGK.js} +1 -1
- package/dist/client/assets/{Grid01-CDiu9G8k.js → Grid01-CH_80p-4.js} +1 -1
- package/dist/client/assets/{Home02-CayMHoZF.js → Home02-KQaRNwL3.js} +1 -1
- package/dist/client/assets/{Image01-eW3uiaQL.js → Image01-qkpxD1yj.js} +1 -1
- package/dist/client/assets/{Inbox01-CVff9P-h.js → Inbox01-mn1giWLi.js} +1 -1
- package/dist/client/assets/{InfoCircle-Cwf7A7aM.js → InfoCircle-jWdDj_pa.js} +1 -1
- package/dist/client/assets/{LinkExternal01-BjOSGZOe.js → LinkExternal01-BJcBkMgt.js} +1 -1
- package/dist/client/assets/{List-Blxn6IBl.js → List-BWbZDQVx.js} +1 -1
- package/dist/client/assets/{Loading01-CatM6JDa.js → Loading01-DuNH8QVR.js} +1 -1
- package/dist/client/assets/{Lock01-CrPQKqta.js → Lock01-CCyf9a9X.js} +1 -1
- package/dist/client/assets/{Pin01-D3LZgLE8.js → Pin01-CU7bB1L8.js} +1 -1
- package/dist/client/assets/{Play-BA6_L1fM.js → Play-CrBwr4cr.js} +1 -1
- package/dist/client/assets/{Plus-LdanziaX.js → Plus-ZDIS0vbh.js} +1 -1
- package/dist/client/assets/{SearchMd-CDLQipSw.js → SearchMd-6GhPnBK1.js} +1 -1
- package/dist/client/assets/{Share07-DPsUpckx.js → Share07-BDsQfZYE.js} +1 -1
- package/dist/client/assets/{Terminal-C0IzqPpG.js → Terminal-Bx4QINJq.js} +1 -1
- package/dist/client/assets/{Tool01-BUbXFy6J.js → Tool01-DoELZ-Fj.js} +1 -1
- package/dist/client/assets/{Trash01-Du6SwTAz.js → Trash01-DGR7JKVH.js} +1 -1
- package/dist/client/assets/{Upload01-CgP92uxk.js → Upload01-C08PhgQO.js} +1 -1
- package/dist/client/assets/{Users03-CsLBIBVK.js → Users03-C-DkXcQ6.js} +1 -1
- package/dist/client/assets/{X-D7ML9mux.js → X-Cw8dXC6B.js} +1 -1
- package/dist/client/assets/{XClose-U1yU7qCl.js → XClose-BOKH0Ji3.js} +1 -1
- package/dist/client/assets/{agent-connections-preview-CsYvxmEm.js → agent-connections-preview-C1QLXOEH.js} +1 -1
- package/dist/client/assets/{agent-detail-wkiWbQKN.js → agent-detail-Jt4PhiY7.js} +1 -1
- package/dist/client/assets/{agents-kNb1WD8x.js → agents-Br3GzWPS.js} +1 -1
- package/dist/client/assets/{alert-dialog-DZBrJq-m.js → alert-dialog-Bt2DNs-q.js} +1 -1
- package/dist/client/assets/{auth-catchall-BEy8E7j_.js → auth-catchall-C-ZsonS7.js} +1 -1
- package/dist/client/assets/{badge-Cw5-hSpe.js → badge-DsLVLnaN.js} +1 -1
- package/dist/client/assets/{binder-ClDDqAqe.js → binder-AghfMQli.js} +1 -1
- package/dist/client/assets/{breadcrumb-Caj5YR93.js → breadcrumb-k6_ciPji.js} +1 -1
- package/dist/client/assets/{button-BgBCyPX0.js → button-C2Npiaxw.js} +1 -1
- package/dist/client/assets/{card-DElUPHrE.js → card-CuSLw2Wn.js} +1 -1
- package/dist/client/assets/{checkbox-C3ba2fF0.js → checkbox-CeETLr6E.js} +1 -1
- package/dist/client/assets/{circle-alert-C2UMYCQm.js → circle-alert-Bwtfy9KA.js} +1 -1
- package/dist/client/assets/{collapsible-Rf1qFjgA.js → collapsible-kdbIagB_.js} +1 -1
- package/dist/client/assets/{collection-detail-D7X5ych8.js → collection-detail-BioqVjvv.js} +1 -1
- package/dist/client/assets/{collection-search-DuFKyqlJ.js → collection-search-BT1Haqdl.js} +1 -1
- package/dist/client/assets/{collection-tab-BiZnyYe2.js → collection-tab-CadD9eyl.js} +1 -1
- package/dist/client/assets/{collection-table-wrapper-Cd3HlK0O.js → collection-table-wrapper-BlVqD0Fp.js} +1 -1
- package/dist/client/assets/{collection-tabs-Dh1QsIBU.js → collection-tabs-D8pHKDB9.js} +1 -1
- package/dist/client/assets/{command-Di7AyqP9.js → command-Dzjf2dKr.js} +1 -1
- package/dist/client/assets/{connect-D9Hcd45W.js → connect-BulmDFHR.js} +1 -1
- package/dist/client/assets/{connection-card-bCbaOHws.js → connection-card-_pmn_9ur.js} +1 -1
- package/dist/client/assets/{connection-detail-CZ9gXvAv.js → connection-detail-DtAXMJt7.js} +1 -1
- package/dist/client/assets/{connections-DIaziwAv.js → connections-Cgg4Ehdx.js} +1 -1
- package/dist/client/assets/constants-BLEeM90x.js +1 -0
- package/dist/client/assets/{constants-BfWMVBcn.js → constants-CiJIPOcv.js} +1 -1
- package/dist/client/assets/{create-organization-dialog-WF7bdDSH.js → create-organization-dialog-CUyzVLEt.js} +1 -1
- package/dist/client/assets/{dialog-Bnus_vJ4.js → dialog-ByiIrjjH.js} +1 -1
- package/dist/client/assets/{dropdown-menu-BdLRctPP.js → dropdown-menu-BXLews1x.js} +1 -1
- package/dist/client/assets/{dynamic-plugin-layout-C4Hm0K_j.js → dynamic-plugin-layout-CQpxZjNJ.js} +1 -1
- package/dist/client/assets/{empty-state-BHEu_dw7.js → empty-state-BhLPGCFf.js} +1 -1
- package/dist/client/assets/{empty-state-IVJXfQvW.js → empty-state-DCefUqf-.js} +1 -1
- package/dist/client/assets/{env-vars-editor-BQGzh8xm.js → env-vars-editor-CyRZUIFU.js} +1 -1
- package/dist/client/assets/{error-boundary-Cqs9yFyH.js → error-boundary-CZlFheRY.js} +1 -1
- package/dist/client/assets/{extract-connection-data-BttJNYGh.js → extract-connection-data-DQkYWC-q.js} +1 -1
- package/dist/client/assets/{file-browser-D9rjJxeo.js → file-browser-bPGGZg11.js} +2 -2
- package/dist/client/assets/{form-gT1yr3Qo.js → form-CJsO1IWr.js} +1 -1
- package/dist/client/assets/{grid-view-B3IbROP2.js → grid-view-CQCNSuKd.js} +1 -1
- package/dist/client/assets/{home-DDpJgZ3V.js → home-B_4GnWnZ.js} +1 -1
- package/dist/client/assets/{index-DtEKIwl5.js → index-9jleOnNn.js} +1 -1
- package/dist/client/assets/{index-CrhNqpPK.js → index-Cm3M40mu.js} +1 -1
- package/dist/client/assets/{index-Cfcn3j8H.js → index-CuLYtmwa.js} +1 -1
- package/dist/client/assets/{index-VemZ02DZ.js → index-DR06FVTS.js} +1 -1
- package/dist/client/assets/{index-CZuZisdm.js → index-DaLWui-m.js} +1 -1
- package/dist/client/assets/{index--WoOZV8D.js → index-EJkHYsSC.js} +1 -1
- package/dist/client/assets/{index-ByQ-WW1t.js → index-S9nBXez3.js} +3 -3
- package/dist/client/assets/{index-CzUXuhMT.js → index-ymK78sXU.js} +1 -1
- package/dist/client/assets/{infiniteQueryObserver-BYaSWja-.js → infiniteQueryObserver-Bk6kPCGD.js} +1 -1
- package/dist/client/assets/{input-CZnIHLcz.js → input-WEkqgPCx.js} +1 -1
- package/dist/client/assets/{layout-cMYqFuJn.js → layout-DhWpZyaF.js} +1 -1
- package/dist/client/assets/{localstorage-keys-CmNyjwKR.js → localstorage-keys-1daarnfj.js} +1 -1
- package/dist/client/assets/{login-XOYvZmH2.js → login-C6Z0Hf-G.js} +1 -1
- package/dist/client/assets/{mcp-oauth-Cb_Gab-K.js → mcp-oauth-BeGVYXYi.js} +1 -1
- package/dist/client/assets/{mcp-server-card-uMBYGp_W.js → mcp-server-card-TH49CKyg.js} +1 -1
- package/dist/client/assets/{mcp-server-detail-aBjEsXJ_.js → mcp-server-detail-B5lwLhNL.js} +2 -2
- package/dist/client/assets/members-CGC1M2Fl.js +3 -0
- package/dist/client/assets/{monaco-editor-BKGJwQX8.js → monaco-editor-D62uyIRE.js} +1 -1
- package/dist/client/assets/{monitoring-CTVn2xIM.js → monitoring-C8lQE18O.js} +1 -1
- package/dist/client/assets/{oauth-callback-BK14KwlT.js → oauth-callback-BRmmw_vE.js} +1 -1
- package/dist/client/assets/{page-BRoCqKJJ.js → page-C11n8gYY.js} +1 -1
- package/dist/client/assets/{page-C_q1Hu0d.js → page-C6Z5AAxa.js} +1 -1
- package/dist/client/assets/{plugin-empty-state-DFlDiIxl.js → plugin-empty-state-CiNAFBPt.js} +1 -1
- package/dist/client/assets/{plugin-header-CBL4cwNA.js → plugin-header-Cs7vmVyn.js} +1 -1
- package/dist/client/assets/{plugins-CZKUVOCn.js → plugins-DxTFEvsx.js} +1 -1
- package/dist/client/assets/{popover-5IvuXkII.js → popover-DyvWBt1E.js} +1 -1
- package/dist/client/assets/{registry-utils-BhwI9Zxs.js → registry-utils-RKHarYmu.js} +1 -1
- package/dist/client/assets/{resizable-BwJPsyFO.js → resizable-DqIEdFEF.js} +1 -1
- package/dist/client/assets/{select-CTRzFFUx.js → select-DP5Dfkvv.js} +1 -1
- package/dist/client/assets/{settings-BexesTWb.js → settings-DW3RHdzH.js} +1 -1
- package/dist/client/assets/{shell-layout-B1C9fUMW.js → shell-layout-DVjDk4PE.js} +1 -1
- package/dist/client/assets/{spinner-DOOIz_y9.js → spinner-CAgETmH3.js} +1 -1
- package/dist/client/assets/{store-invite-Ba7ZRzca.js → store-invite-DfU-qVkO.js} +1 -1
- package/dist/client/assets/{switch-_3WnqN5a.js → switch-D7U_Vekt.js} +1 -1
- package/dist/client/assets/{table-DpIrnboJ.js → table-20ccyhvp.js} +1 -1
- package/dist/client/assets/{textarea-DGIzduMJ.js → textarea-D3xU8GPb.js} +1 -1
- package/dist/client/assets/{tools-list-BAYACY-u.js → tools-list-DTW_RJ6B.js} +1 -1
- package/dist/client/assets/{typewriter-title-BUxC2Fu_.js → typewriter-title-BZWOVDcY.js} +1 -1
- package/dist/client/assets/{use-binding-DULZGaaF.js → use-binding-OJZZKHfM.js} +1 -1
- package/dist/client/assets/{use-connection-BKNC3gBB.js → use-connection-DsOrNBOn.js} +1 -1
- package/dist/client/assets/{use-create-virtual-mcp-D3Pg2rlz.js → use-create-virtual-mcp-BJbJkcpt.js} +1 -1
- package/dist/client/assets/{use-deco-chat-open-DiV8AU-5.js → use-deco-chat-open-BWq3TCrl.js} +1 -1
- package/dist/client/assets/{use-list-state-DqBnjzP2.js → use-list-state--e44Cg6A.js} +1 -1
- package/dist/client/assets/{use-mcp-prompts-DKz5CZB0.js → use-mcp-prompts-m9itAfo1.js} +1 -1
- package/dist/client/assets/{use-mobile-YX8Ptv-0.js → use-mobile-BQcJDrUC.js} +1 -1
- package/dist/client/assets/{use-organization-settings-Bz__LWh9.js → use-organization-settings-DT-GwMSs.js} +1 -1
- package/dist/client/assets/{use-virtual-mcp-DDcNtB11.js → use-virtual-mcp-Bib66D0T.js} +1 -1
- package/dist/client/assets/useInfiniteQuery-DEJMvJ24.js +1 -0
- package/dist/client/assets/{useMutation-kTl5A-lQ.js → useMutation-D0FAjxJB.js} +1 -1
- package/dist/client/assets/useQuery-9ftL5KuZ.js +1 -0
- package/dist/client/assets/{view-mode-toggle-BibpdmwA.js → view-mode-toggle-e1wVUIQC.js} +1 -1
- package/dist/client/assets/{workflow-BFrCK9lY.js → workflow-Criibj7u.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/cli.js +4 -4
- package/dist/server/migrate.js +4 -4
- package/package.json +1 -1
- package/dist/client/assets/constants-DRQ176RT.js +0 -1
- package/dist/client/assets/members-BZdwsMln.js +0 -3
- package/dist/client/assets/useInfiniteQuery-CNM2deBK.js +0 -1
- package/dist/client/assets/useQuery-Cjcoc_Gz.js +0 -1
package/dist/server/migrate.js
CHANGED
|
@@ -1208,9 +1208,9 @@ Please refer to the documentation here: https://better-auth.com/docs/plugins/org
|
|
|
1208
1208
|
WHERE plugin_id = ${Z} AND name = ${H}
|
|
1209
1209
|
`.execute(Y);if(Number(F.rows[0]?.cnt)===0){console.warn(` \u26A0\uFE0F Failed to migrate ${Z}/${H}, keeping in old table`);continue}}await uW`
|
|
1210
1210
|
DELETE FROM kysely_migration WHERE name = ${J}
|
|
1211
|
-
`.execute(Y)}}async function jn4(Y
|
|
1211
|
+
`.execute(Y)}}async function jn4(Y){let X=H36();if(X.length===0)return;let Q=await uW`
|
|
1212
1212
|
SELECT plugin_id, name FROM plugin_migrations
|
|
1213
|
-
`.execute(Y),
|
|
1213
|
+
`.execute(Y),J=new Set(Q.rows.map((W)=>`${W.plugin_id}/${W.name}`)),G=new Map;for(let{pluginId:W,migration:Z}of X){if(!G.has(W))G.set(W,[]);G.get(W).push({name:Z.name,up:Z.up})}let K=0;for(let[W,Z]of G){Z.sort((H,F)=>H.name.localeCompare(F.name));for(let H of Z){let F=`${W}/${H.name}`;if(J.has(F))continue;if(K===0)console.log("\uD83D\uDD0C Running plugin migrations...");K++,console.log(` Running: ${F}`),await H.up(Y);let q=new Date().toISOString();await uW`
|
|
1214
1214
|
INSERT INTO plugin_migrations (plugin_id, name, timestamp)
|
|
1215
|
-
VALUES (${
|
|
1216
|
-
`.execute(Y)}}if(
|
|
1215
|
+
VALUES (${W}, ${H.name}, ${q})
|
|
1216
|
+
`.execute(Y)}}if(K>0)console.log(`\u2705 ${K} plugin migration(s) completed`)}async function kn4(Y,X){await Rn4(Y,X),await Sn4(Y,X);let Q=new Dq6({db:Y,provider:{getMigrations:()=>Promise.resolve(pP)}}),{error:J,results:G}=await Q.migrateToLatest();if(G?.forEach((K)=>{if(K.status==="Success")console.log(`\u2705 Migration "${K.migrationName}" executed successfully`);else if(K.status==="Error")console.error(`\u274C Failed to execute migration "${K.migrationName}"`)}),J)throw console.error("Failed to migrate"),console.error(J),J}async function vn4(Y){let{keepOpen:X=!1,database:Q,skipBetterAuth:J=!1,seed:G}=Y??{};if(!J&&!Q)await Uq6();let K=Q??cM(),W=async()=>{if(!X&&!Q)console.log("\uD83D\uDD12 Closing database connection..."),await hY6(K).catch((Z)=>{console.warn("Warning: Error closing database:",Z)})};try{console.log("\uD83D\uDCCA Running Kysely migrations..."),await kn4(K.db,K.type),console.log("\uD83C\uDF89 Core migrations completed successfully"),await jn4(K.db);let Z;if(G)Z=await kX0(K.db,G);return await W(),{seedResult:Z}}catch(Z){throw await W(),Z}}async function G18(){let Y=cM(),X=new Dq6({db:Y.db,provider:{getMigrations:()=>Promise.resolve(pP)}}),{error:Q,results:J}=await X.migrateDown();if(J?.forEach((G)=>{if(G.status==="Success")console.log(`\u2705 Migration "${G.migrationName}" rolled back successfully`);else if(G.status==="Error")console.error(`\u274C Failed to rollback migration "${G.migrationName}"`)}),Q)throw console.error("Failed to rollback migration"),console.error(Q),Q}if(import.meta.main)console.log("\uD83D\uDE80 Migration script starting..."),console.log("\uD83D\uDCE6 Imported migrateToLatest function"),(async()=>{console.log("\uD83C\uDFC3 Executing migration function...");try{await vn4(),console.log("\u2705 All migrations completed. Exiting..."),process.exit(0)}catch(Y){console.error("\u274C Migration failed:",Y),process.exit(1)}})();export{kX0 as runSeed,kn4 as runKyselyMigrations,vn4 as migrateToLatest,G18 as migrateDown};
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{H as t,I as a}from"./index-ByQ-WW1t.js";const e=t(a,{target:"draft-7"});export{e as B};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{r as D,c as le,j as s,p as Xt,u as Ce,g as ae,K as ue,o as yt,ad as ct,s as Ne,ba as Jt,bg as Wt,F as Oe,k as zt,h as es,t as ne,E as ts}from"./index-ByQ-WW1t.js";import{C as ss,a as ns}from"./collection-table-wrapper-Cd3HlK0O.js";import{C as Ke}from"./collection-search-DuFKyqlJ.js";import{P as Te}from"./index-DtEKIwl5.js";import{B as rs,a as is,b as os,e as ls}from"./breadcrumb-Caj5YR93.js";import{I as kt,c as Re,b as Le,T as Pe,a as Me,E as dt}from"./empty-state-IVJXfQvW.js";import{C as De}from"./checkbox-C3ba2fF0.js";import{c as X,B as ie}from"./button-BgBCyPX0.js";import{e as Ut}from"./use-connection-BKNC3gBB.js";import{u as Ct,C as mt,a as ut,b as St,c as as,d as cs,e as ds,f as ms}from"./command-Di7AyqP9.js";import{u as it}from"./useQuery-Cjcoc_Gz.js";import{u as ve}from"./useMutation-kTl5A-lQ.js";import{f as ze,a as ke,b as Ue,c as Be,d as Ve,e as Ge,A as $e,g as Fe,h as Ae}from"./alert-dialog-DZBrJq-m.js";import{B as Ee}from"./badge-Cw5-hSpe.js";import{D as Bt,f as Vt,a as Gt,b as us,c as fs,e as hs}from"./dialog-Bnus_vJ4.js";import{D as jt,a as vt,b as Nt,c as tt,d as gs,e as xs,f as ps,g as bs}from"./dropdown-menu-BdLRctPP.js";import{i as Cs}from"./DotsHorizontal-DoBmdgcU.js";import{i as st}from"./Loading01-CatM6JDa.js";import{i as js}from"./Lock01-CrPQKqta.js";import{s as nt}from"./Plus-LdanziaX.js";import{s as $t}from"./Trash01-Du6SwTAz.js";import{i as It}from"./X-D7ML9mux.js";import{I as vs}from"./input-CZnIHLcz.js";import{S as Xe}from"./switch-_3WnqN5a.js";import{E as Ns}from"./error-boundary-Cqs9yFyH.js";import{a as Ts,F as wt,b as At,c as Es,d as Ot,f as _t}from"./form-gT1yr3Qo.js";import{S as ht,a as gt,b as xt,c as pt,d as bt}from"./select-CTRzFFUx.js";import{T as ys}from"./textarea-DGIzduMJ.js";import{a as qe,u as Qe}from"./constants-BfWMVBcn.js";import{C as Rt}from"./card-DElUPHrE.js";import{i as Ft}from"./DotsVertical-BmpdBChT.js";import{i as Ss}from"./index-CzUXuhMT.js";import{s as Kt}from"./XClose-U1yU7qCl.js";import{a as Is,b as ws,P as As}from"./popover-5IvuXkII.js";import{t as Os}from"./ChevronDown-DQimov-w.js";import"./ArrowUp-TSXJSHlb.js";import"./Check-TVVdApmr.js";import"./Grid01-CDiu9G8k.js";import"./List-Blxn6IBl.js";import"./view-mode-toggle-BibpdmwA.js";import"./table-DpIrnboJ.js";import"./SearchMd-CDLQipSw.js";import"./ChevronRight-C1wmaJaY.js";const qt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M19 12H5m0 0 7 7m-7-7 7-7"}));qt.displayName="ArrowLeft";const Tt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M11.302 21.615c.221.129.332.194.488.227.122.026.298.026.42 0 .156-.034.267-.098.488-.227C14.646 20.478 20 16.908 20 12V7.217c0-.799 0-1.199-.13-1.542a2 2 0 0 0-.548-.79c-.275-.243-.65-.383-1.398-.664l-5.362-2.01c-.208-.078-.312-.117-.419-.133a1 1 0 0 0-.286 0c-.107.016-.21.055-.419.133L6.076 4.22c-.748.28-1.122.421-1.398.664a2 2 0 0 0-.547.79C4 6.018 4 6.418 4 7.217V12c0 4.908 5.354 8.478 7.302 9.615Z"}));Tt.displayName="Shield01";const Qt=({size:t=24,color:e="currentColor",...n})=>D.createElement("svg",{viewBox:"0 0 24 24",width:t,height:t,stroke:e,strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",...n},D.createElement("path",{d:"M20 17H4m0 0 4-4m-4 4 4 4M4 7h16m0 0-4-4m4 4-4 4"}));Qt.displayName="SwitchHorizontal01";const Ht=[{name:"ORGANIZATION_CREATE",description:"Create a new organization",category:"Organizations"},{name:"ORGANIZATION_LIST",description:"List organizations",category:"Organizations"},{name:"ORGANIZATION_GET",description:"View organization details",category:"Organizations"},{name:"ORGANIZATION_UPDATE",description:"Update organization",category:"Organizations"},{name:"ORGANIZATION_DELETE",description:"Delete organization",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_SETTINGS_GET",description:"View organization settings",category:"Organizations"},{name:"ORGANIZATION_SETTINGS_UPDATE",description:"Update organization settings",category:"Organizations"},{name:"ORGANIZATION_MEMBER_ADD",description:"Add members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_REMOVE",description:"Remove members",category:"Organizations",dangerous:!0},{name:"ORGANIZATION_MEMBER_LIST",description:"List members",category:"Organizations"},{name:"ORGANIZATION_MEMBER_UPDATE_ROLE",description:"Update member roles",category:"Organizations"},{name:"COLLECTION_CONNECTIONS_CREATE",description:"Create connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_LIST",description:"List connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_GET",description:"View connection details",category:"Connections"},{name:"COLLECTION_CONNECTIONS_UPDATE",description:"Update connections",category:"Connections"},{name:"COLLECTION_CONNECTIONS_DELETE",description:"Delete connections",category:"Connections",dangerous:!0},{name:"CONNECTION_TEST",description:"Test connections",category:"Connections"},{name:"DATABASES_RUN_SQL",description:"Run SQL queries",category:"Connections",dangerous:!0},{name:"COLLECTION_VIRTUAL_MCP_CREATE",description:"Create virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_LIST",description:"List virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_GET",description:"View virtual MCP details",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_UPDATE",description:"Update virtual MCPs",category:"Virtual MCPs"},{name:"COLLECTION_VIRTUAL_MCP_DELETE",description:"Delete virtual MCPs",category:"Virtual MCPs",dangerous:!0},{name:"MONITORING_LOGS_LIST",description:"List monitoring logs",category:"Monitoring"},{name:"MONITORING_STATS",description:"View monitoring statistics",category:"Monitoring"},{name:"API_KEY_CREATE",description:"Create API key",category:"API Keys"},{name:"API_KEY_LIST",description:"List API keys",category:"API Keys"},{name:"API_KEY_UPDATE",description:"Update API key",category:"API Keys"},{name:"API_KEY_DELETE",description:"Delete API key",category:"API Keys",dangerous:!0},{name:"EVENT_PUBLISH",description:"Publish events",category:"Event Bus"},{name:"EVENT_SUBSCRIBE",description:"Subscribe to events",category:"Event Bus"},{name:"EVENT_UNSUBSCRIBE",description:"Unsubscribe from events",category:"Event Bus"},{name:"EVENT_CANCEL",description:"Cancel recurring events",category:"Event Bus"},{name:"EVENT_ACK",description:"Acknowledge event delivery",category:"Event Bus"},{name:"EVENT_SUBSCRIPTION_LIST",description:"List event subscriptions",category:"Event Bus"},{name:"EVENT_SYNC_SUBSCRIPTIONS",description:"Sync subscriptions to desired state",category:"Event Bus"},{name:"USER_GET",description:"Get a user by id",category:"Users"},{name:"CODE_EXECUTION_SEARCH_TOOLS",description:"Search available tools by name or description",category:"Code Execution"},{name:"CODE_EXECUTION_DESCRIBE_TOOLS",description:"Get detailed schemas for specific tools",category:"Code Execution"},{name:"CODE_EXECUTION_RUN_CODE",description:"Run JavaScript code in a sandbox with tool access",category:"Code Execution",dangerous:!0},{name:"COLLECTION_THREADS_CREATE",description:"Create threads",category:"Threads"},{name:"COLLECTION_THREADS_LIST",description:"List threads",category:"Threads"},{name:"COLLECTION_THREADS_GET",description:"View thread details",category:"Threads"},{name:"COLLECTION_THREADS_UPDATE",description:"Update threads",category:"Threads"},{name:"COLLECTION_THREADS_DELETE",description:"Delete threads",category:"Threads",dangerous:!0},{name:"COLLECTION_THREAD_MESSAGES_LIST",description:"List thread messages",category:"Threads"},{name:"TAGS_LIST",description:"List organization tags",category:"Tags"},{name:"TAGS_CREATE",description:"Create organization tag",category:"Tags"},{name:"TAGS_DELETE",description:"Delete organization tag",category:"Tags",dangerous:!0},{name:"MEMBER_TAGS_GET",description:"Get member tags",category:"Tags"},{name:"MEMBER_TAGS_SET",description:"Set member tags",category:"Tags"}],_s={ORGANIZATION_CREATE:"Create organization",ORGANIZATION_LIST:"List organizations",ORGANIZATION_GET:"View organization details",ORGANIZATION_UPDATE:"Update organization",ORGANIZATION_DELETE:"Delete organization",ORGANIZATION_SETTINGS_GET:"View organization settings",ORGANIZATION_SETTINGS_UPDATE:"Update organization settings",ORGANIZATION_MEMBER_LIST:"List members",ORGANIZATION_MEMBER_ADD:"Add members",ORGANIZATION_MEMBER_REMOVE:"Remove members",ORGANIZATION_MEMBER_UPDATE_ROLE:"Update member roles",COLLECTION_CONNECTIONS_LIST:"List connections",COLLECTION_CONNECTIONS_GET:"View connection details",COLLECTION_CONNECTIONS_CREATE:"Create connections",COLLECTION_CONNECTIONS_UPDATE:"Update connections",COLLECTION_CONNECTIONS_DELETE:"Delete connections",CONNECTION_TEST:"Test connections",DATABASES_RUN_SQL:"Run SQL queries",COLLECTION_VIRTUAL_MCP_CREATE:"Create virtual MCPs",COLLECTION_VIRTUAL_MCP_LIST:"List virtual MCPs",COLLECTION_VIRTUAL_MCP_GET:"View virtual MCP details",COLLECTION_VIRTUAL_MCP_UPDATE:"Update virtual MCPs",COLLECTION_VIRTUAL_MCP_DELETE:"Delete virtual MCPs",MONITORING_LOGS_LIST:"List monitoring logs",MONITORING_STATS:"View monitoring statistics",API_KEY_CREATE:"Create API key",API_KEY_LIST:"List API keys",API_KEY_UPDATE:"Update API key",API_KEY_DELETE:"Delete API key",EVENT_PUBLISH:"Publish events",EVENT_SUBSCRIBE:"Subscribe to events",EVENT_UNSUBSCRIBE:"Unsubscribe from events",EVENT_CANCEL:"Cancel recurring events",EVENT_ACK:"Acknowledge event delivery",EVENT_SUBSCRIPTION_LIST:"List event subscriptions",EVENT_SYNC_SUBSCRIPTIONS:"Sync subscriptions to desired state",USER_GET:"Get user by id",CODE_EXECUTION_SEARCH_TOOLS:"Search tools",CODE_EXECUTION_DESCRIBE_TOOLS:"Describe tools",CODE_EXECUTION_RUN_CODE:"Run code",COLLECTION_THREADS_CREATE:"Create threads",COLLECTION_THREADS_LIST:"List threads",COLLECTION_THREADS_GET:"View thread details",COLLECTION_THREADS_UPDATE:"Update threads",COLLECTION_THREADS_DELETE:"Delete threads",COLLECTION_THREAD_MESSAGES_LIST:"List thread messages",TAGS_LIST:"List organization tags",TAGS_CREATE:"Create organization tag",TAGS_DELETE:"Delete organization tag",MEMBER_TAGS_GET:"Get member tags",MEMBER_TAGS_SET:"Set member tags"};function Rs(){const t={Organizations:[],Connections:[],"Virtual MCPs":[],Threads:[],Monitoring:[],Users:[],"API Keys":[],"Event Bus":[],"Code Execution":[],Tags:[]};for(const e of Ht)t[e.category]?.push(e);return t}function Ls(){return Ht.map(t=>({value:t.name,label:_s[t.name],dangerous:t.dangerous}))}const Ps=D.memo(function(e){const n=le.c(21),{connection:r,isSelected:l,hasToolsEnabled:o,activeToolsCount:c,totalToolsCount:i,onSelect:u,onToggle:x}=e,m=l?"bg-accent/50":"hover:bg-muted/50";let C;n[0]!==m?(C=X("flex items-center gap-3 p-2 rounded-lg transition-colors will-change-auto",m),n[0]=m,n[1]=C):C=n[1];let d;n[2]!==r.icon||n[3]!==r.title?(d=s.jsx(kt,{icon:r.icon,name:r.title,size:"xs"}),n[2]=r.icon,n[3]=r.title,n[4]=d):d=n[4];let N;n[5]!==r.title?(N=s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:r.title})}),n[5]=r.title,n[6]=N):N=n[6];let g;n[7]!==u||n[8]!==d||n[9]!==N?(g=s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0 cursor-pointer",onClick:u,children:[d,N]}),n[7]=u,n[8]=d,n[9]=N,n[10]=g):g=n[10];let j;n[11]!==c||n[12]!==r.tools||n[13]!==o||n[14]!==x||n[15]!==i?(j=r.tools&&r.tools.length>0&&s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-xs text-muted-foreground shrink-0",children:[c,"/",i]}),s.jsx(De,{checked:o,onCheckedChange:x,onClick:zs})]}),n[11]=c,n[12]=r.tools,n[13]=o,n[14]=x,n[15]=i,n[16]=j):j=n[16];let b;return n[17]!==C||n[18]!==g||n[19]!==j?(b=s.jsxs("div",{className:C,children:[g,j]}),n[17]=C,n[18]=g,n[19]=j,n[20]=b):b=n[20],b}),Ms=D.memo(function(e){const n=le.c(18),{connectionId:r,tool:l,isSelected:o,onToggle:c}=e,i=`tool-${r}-${l.name}`,u=o?"text-foreground":"text-muted-foreground";let x;n[0]!==u?(x=X("text-sm font-medium",u),n[0]=u,n[1]=x):x=n[1];let m;n[2]!==x||n[3]!==l.name?(m=s.jsx("div",{className:"flex items-center gap-2 mb-1",children:s.jsx("span",{className:x,children:l.name})}),n[2]=x,n[3]=l.name,n[4]=m):m=n[4];let C;n[5]!==l.description?(C=l.description&&s.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:l.description}),n[5]=l.description,n[6]=C):C=n[6];let d;n[7]!==m||n[8]!==C?(d=s.jsxs("div",{className:"flex-1 min-w-0",children:[m,C]}),n[7]=m,n[8]=C,n[9]=d):d=n[9];const N=`tool-${r}-${l.name}`;let g;n[10]!==o||n[11]!==c||n[12]!==N?(g=s.jsx("div",{className:"flex items-center shrink-0",children:s.jsx(De,{id:N,checked:o,onCheckedChange:c,onClick:ks})}),n[10]=o,n[11]=c,n[12]=N,n[13]=g):g=n[13];let j;return n[14]!==i||n[15]!==d||n[16]!==g?(j=s.jsxs("label",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-muted/50 cursor-pointer group will-change-auto",htmlFor:i,children:[d,g]}),n[14]=i,n[15]=d,n[16]=g,n[17]=j):j=n[17],j});function Ds({toolSet:t,onToolSetChange:e,excludeVirtualMcpId:n}){const[r,l]=D.useState(""),o=D.useDeferredValue(r),[c,i]=D.useState("all"),[u,x]=D.useState(!1),m=D.useRef(new Set(Object.keys(t))),C=Ut({searchTerm:o.trim()||void 0}),d=n?C.filter(h=>h.connection_type!=="VIRTUAL"?!0:Xt(h.connection_url)!==n):C,N=m.current,g=[...N.values()].map(h=>d.find(S=>S.id===h)).filter(h=>h!==void 0),j=d.filter(h=>!N.has(h.id)),b=[...g,...j],I=h=>{const S=t[h];return S!==void 0&&S.length>0},v=b.filter(h=>{if(c==="all")return!0;const S=I(h.id);return c==="selected"?S:c==="unselected"?!S:!0}),[f,w]=D.useState(b[0]?.id??null),T=f?b.find(h=>h.id===f)??null:null,P=T?.tools??[],A=(h,S)=>t[h]?.includes(S)??!1,L=(h,S)=>{const E=t[h]??[],p=E.includes(S),R={...t};if(p){const k=E.filter(V=>V!==S);k.length===0?delete R[h]:R[h]=k}else R[h]=[...E,S];e(R)},_=h=>{const S=b.find(V=>V.id===h);if(!S?.tools)return;const E=t[h]??[],p=S.tools.map(V=>V.name),R=E.length>0&&p.every(V=>E.includes(V)),k={...t};R?delete k[h]:(k[h]=p,w(h)),e(k)},M=h=>{w(h),x(!0)},O=()=>{x(!1)};return s.jsxs("div",{className:"flex h-full",children:[s.jsxs("div",{className:X("w-full md:w-80 border-r border-border flex flex-col",u&&"hidden md:flex"),children:[s.jsx(Ke,{value:r,onChange:l,placeholder:"Search MCP Servers..."}),s.jsxs("div",{className:"flex gap-1 p-2 border-b border-border",children:[s.jsx("button",{onClick:()=>i("all"),className:X("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="all"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"All"}),s.jsx("button",{onClick:()=>i("selected"),className:X("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="selected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Selected"}),s.jsx("button",{onClick:()=>i("unselected"),className:X("flex-1 px-3 py-1.5 text-xs font-medium rounded-md transition-colors border cursor-pointer",c==="unselected"?"bg-muted border-border":"border-border opacity-75 hover:opacity-100"),children:"Unselected"})]}),s.jsx("div",{className:"flex-1 overflow-auto",children:v.length===0?s.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:r?"No connections found":c==="selected"?"No servers selected":c==="unselected"?"No unselected servers":"No connections available"}):s.jsx("div",{className:"p-2 space-y-1",children:v.map(h=>{const S=h.tools?.length??0,E=t[h.id]?.length??0;return s.jsx(Ps,{connection:h,isSelected:f===h.id,hasToolsEnabled:I(h.id),activeToolsCount:E,totalToolsCount:S,onSelect:()=>M(h.id),onToggle:()=>_(h.id)},h.id)})})})]}),s.jsx("div",{className:X("flex-1 flex-col",u?"flex":"hidden md:flex"),children:T?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"md:hidden border-b border-border p-4 flex items-center gap-3",children:[s.jsx(ie,{variant:"ghost",size:"sm",onClick:O,className:"h-8 w-8 p-0 shrink-0",children:s.jsx(qt,{size:20})}),s.jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[s.jsx(kt,{icon:T.icon,name:T.title,size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:T.title}),T.description&&s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:T.description})]})]})]}),s.jsx("div",{className:"flex-1 overflow-auto p-4",children:P.length===0?s.jsx("div",{className:"text-sm text-muted-foreground text-center py-8",children:"This connection has no tools available"}):s.jsx("div",{className:"space-y-2",children:P.map(h=>s.jsx(Ms,{connectionId:T.id,tool:h,isSelected:A(T.id,h.name),onToggle:()=>L(T.id,h.name)},h.name))})})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx("div",{className:"text-sm text-muted-foreground text-center",children:"Select a connection to view its tools"})})})]})}function zs(t){return t.stopPropagation()}function ks(t){return t.stopPropagation()}const Lt=[{value:"owner",label:"Owner",isBuiltin:!0},{value:"admin",label:"Admin",isBuiltin:!0},{value:"user",label:"User",isBuiltin:!0}];function Us(t){return t.replace(/-/g," ")}function Bs(t){if(!t)return{staticPermissions:[],allowsAllStaticPermissions:!1,connectionIds:[],allowsAllConnections:!1,toolNames:[],allowsAllTools:!1};const e=[];let n=!1;const r=[];let l=!1;const o=new Set;let c=!1;for(const[i,u]of Object.entries(t)){if(i==="self"){u.includes("*")?n=!0:e.push(...u);continue}if(i==="*"){if(l=!0,u.includes("*"))c=!0;else for(const x of u)o.add(x);continue}if(r.push(i),u.includes("*"))c=!0;else for(const x of u)o.add(x)}return{staticPermissions:e,allowsAllStaticPermissions:n,connectionIds:r,allowsAllConnections:l,toolNames:Array.from(o),allowsAllTools:c}}function Et(){const{locator:t}=Ce(),{data:e,isLoading:n,error:r,refetch:l}=it({queryKey:ue.organizationRoles(t),queryFn:async()=>{try{const i=await ae.organization.listRoles();return i?.error?(console.error("[useOrganizationRoles] API error:",i.error),[]):i?.data??[]}catch(i){return console.error("[useOrganizationRoles] Fetch error:",i),[]}},staleTime:3e4}),o=Lt.map(i=>({role:i.value,label:i.label,isBuiltin:i.isBuiltin}));if(e&&Array.isArray(e))for(const i of e){const u=i.role;if(!u||Lt.some(j=>j.value===u))continue;const{staticPermissions:x,allowsAllStaticPermissions:m,connectionIds:C,allowsAllConnections:d,toolNames:N,allowsAllTools:g}=Bs(i.permission);o.push({id:i.id,role:u,label:Us(u),isBuiltin:!1,permission:i.permission??void 0,staticPermissionCount:m?-1:x.length,allowsAllStaticPermissions:m,connectionCount:d?-1:C.length,allowsAllConnections:d,toolCount:g?-1:N.length,allowsAllTools:g})}const c=o.filter(i=>!i.isBuiltin);return{roles:o,customRoles:c,builtinRoles:o.filter(i=>i.isBuiltin),isLoading:n,error:r,refetch:l}}const Vs=yt({role:yt({id:Ne().optional(),slug:Ne().optional(),label:Ne()}),allowAllStaticPermissions:Wt(),staticPermissions:ct(Ne()),toolSet:Jt(Ne(),ct(Ne())),memberIds:ct(Ne())});function Zt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}const Gs=[{role:"owner",label:"Owner",color:"bg-red-500"},{role:"admin",label:"Admin",color:"bg-blue-500"},{role:"user",label:"User",color:"bg-green-500"}],ft=["bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500"];function $s(t){if(!t)return"bg-neutral-400";let e=0;for(let r=0;r<t.length;r++){const l=t.charCodeAt(r);e=(e<<5)-e+l,e=e&e}const n=Math.abs(e)%ft.length;return ft[n]??ft[0]}function Je(){return{role:{id:void 0,slug:void 0,label:""},allowAllStaticPermissions:!1,staticPermissions:[],toolSet:{},memberIds:[]}}function Fs(t){const e=le.c(39),{allowAllStaticPermissions:n,staticPermissions:r,onAllowAllChange:l,onPermissionsChange:o,readOnly:c}=t,i=c===void 0?!1:c,[u,x]=D.useState(""),m=D.useDeferredValue(u);let C,d,N,g,j;if(e[0]!==n||e[1]!==m||e[2]!==l||e[3]!==o||e[4]!==i||e[5]!==u||e[6]!==r){const v=Rs(),f=Ls(),w=f.filter(O=>O.label.toLowerCase().includes(m.toLowerCase())),T=O=>{if(r.includes(O))o(r.filter(h=>h!==O));else{const h=[...r,O];h.length===f.length?(l(!0),o([])):o(h)}};N="flex flex-col h-full",e[12]!==u?(g=s.jsx("div",{className:"border-b border-border",children:s.jsx(Ke,{value:u,onChange:x,placeholder:"Search permissions...",className:"border-b-0"})}),e[12]=u,e[13]=g):g=e[13];const P=!i&&"hover:bg-muted/50 cursor-pointer";let A;e[14]!==P?(A=X("flex items-center justify-between px-4 py-3 rounded-lg",P),e[14]=P,e[15]=A):A=e[15];let L;e[16]!==n||e[17]!==l||e[18]!==o||e[19]!==i?(L=()=>{if(i)return;l(!n),o([])},e[16]=n,e[17]=l,e[18]=o,e[19]=i,e[20]=L):L=e[20];let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("span",{className:"text-sm font-medium",children:"All organization permissions"}),e[21]=_):_=e[21];let M;e[22]!==n||e[23]!==l||e[24]!==o||e[25]!==i?(M=s.jsx("div",{onClick:Zs,children:i?s.jsx(Re,{children:s.jsxs(Le,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(Xe,{checked:n,disabled:i,onCheckedChange:O=>{i||(l(O),o([]))}})})}),s.jsx(Me,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Xe,{checked:n,disabled:i,onCheckedChange:O=>{i||(l(O),o([]))}})}),e[22]=n,e[23]=l,e[24]=o,e[25]=i,e[26]=M):M=e[26],e[27]!==M||e[28]!==A||e[29]!==L?(j=s.jsx("div",{className:"border-b border-border",children:s.jsxs("div",{className:A,onClick:L,children:[_,M]})}),e[27]=M,e[28]=A,e[29]=L,e[30]=j):j=e[30],C="flex-1 overflow-auto",d=Object.entries(v).map(O=>{const[h,S]=O,E=w.filter(p=>S.some(R=>R.name===p.value));return E.length===0?null:s.jsxs("div",{className:"mb-6 last:mb-0",children:[s.jsx("h4",{className:"text-sm font-medium p-3 pb-1.5 text-muted-foreground/75",children:h}),s.jsx("div",{className:"space-y-1",children:E.map(p=>s.jsxs("div",{className:X("flex items-center justify-between gap-3 px-4 py-3",!i&&"hover:bg-muted/50 cursor-pointer"),onClick:()=>{if(!i)if(n){l(!1);const R=f.map(Hs);o(R.filter(k=>k!==p.value))}else T(p.value)},children:[s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("span",{className:"text-sm",children:p.label})}),s.jsx("div",{onClick:Qs,children:i?s.jsx(Re,{children:s.jsxs(Le,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(Xe,{checked:n||r.includes(p.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const R=f.map(qs);o(R.filter(k=>k!==p.value))}else T(p.value)}})})}),s.jsx(Me,{children:s.jsx("p",{children:"Built-in role permissions cannot be changed"})})]})}):s.jsx(Xe,{checked:n||r.includes(p.value),disabled:i,onCheckedChange:()=>{if(!i)if(n){l(!1);const R=f.map(Ks);o(R.filter(k=>k!==p.value))}else T(p.value)}})})]},p.value))})]},h)}),e[0]=n,e[1]=m,e[2]=l,e[3]=o,e[4]=i,e[5]=u,e[6]=r,e[7]=C,e[8]=d,e[9]=N,e[10]=g,e[11]=j}else C=e[7],d=e[8],N=e[9],g=e[10],j=e[11];let b;e[31]!==C||e[32]!==d?(b=s.jsx("div",{className:C,children:d}),e[31]=C,e[32]=d,e[33]=b):b=e[33];let I;return e[34]!==N||e[35]!==g||e[36]!==j||e[37]!==b?(I=s.jsxs("div",{className:N,children:[g,j,b]}),e[34]=N,e[35]=g,e[36]=j,e[37]=b,e[38]=I):I=e[38],I}function Ks(t){return t.value}function qs(t){return t.value}function Qs(t){return t.stopPropagation()}function Hs(t){return t.value}function Zs(t){return t.stopPropagation()}function Ys(t){const e=le.c(56),{open:n,onOpenChange:r,selectedMemberIds:l,onAddMembers:o}=t,[c,i]=D.useState(""),u=D.useDeferredValue(c);let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[0]=x):x=e[0];const[m,C]=D.useState(x),{data:d}=Ct();let N,g,j,b,I,v,f,w,T,P,A;if(e[1]!==d?.data?.members||e[2]!==u||e[3]!==o||e[4]!==r||e[5]!==n||e[6]!==m||e[7]!==c||e[8]!==l){const R=d?.data?.members??[];let k;e[20]!==u?(k=U=>{const a=u.toLowerCase();return U.user?.name?.toLowerCase().includes(a)||U.user?.email?.toLowerCase().includes(a)},e[20]=u,e[21]=k):k=e[21];const V=R.filter(k),q=Xs;let Q;e[22]!==l?(Q=U=>l.includes(U),e[22]=l,e[23]=Q):Q=e[23];const H=Q;let Z;e[24]!==m?(Z=U=>{m.includes(U)?C(m.filter(a=>a!==U)):C([...m,U])},e[24]=m,e[25]=Z):Z=e[25];const se=Z;let J;e[26]!==o||e[27]!==r||e[28]!==m?(J=()=>{o(m),C([]),r(!1)},e[26]=o,e[27]=r,e[28]=m,e[29]=J):J=e[29],j=J,g=ze,P=n,A=r,N=ke,w="sm:max-w-md p-0 overflow-hidden",e[30]===Symbol.for("react.memo_cache_sentinel")?(T=s.jsxs(Ue,{className:"px-6 pt-6",children:[s.jsx(Be,{children:"Add Members to Role"}),s.jsx(Ve,{children:"Select members to add to this role."})]}),e[30]=T):T=e[30],v="flex flex-col h-80",e[31]!==c?(f=s.jsx(Ke,{value:c,onChange:i,placeholder:"Search members...",className:"border-b border-t-0 border-x-0 rounded-none"}),e[31]=c,e[32]=f):f=e[32],b="flex-1 overflow-auto",I=V.length===0?s.jsx("div",{className:"flex items-center justify-center h-full px-6",children:s.jsx("p",{className:"text-sm text-muted-foreground",children:c?"No members found":"No members available"})}):s.jsx("div",{className:"px-6 py-2 space-y-1",children:V.map(U=>{const a=q(U),y=H(U.id),F=m.includes(U.id);return s.jsxs("label",{className:X("flex items-center gap-3 p-2 rounded-lg",!a||y?"opacity-50 cursor-not-allowed":"cursor-pointer hover:bg-muted/50"),children:[s.jsx(De,{checked:F||y,onCheckedChange:()=>{a&&!y&&se(U.id)},disabled:!a||y}),s.jsx(Ae,{url:U.user?.image??void 0,fallback:Zt(U.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:U.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:U.user?.email})]}),!a&&s.jsx(Ee,{variant:"secondary",className:"shrink-0",children:"Owner"}),y&&a&&s.jsx(Ee,{variant:"outline",className:"shrink-0",children:"Added"})]},U.id)})}),e[1]=d?.data?.members,e[2]=u,e[3]=o,e[4]=r,e[5]=n,e[6]=m,e[7]=c,e[8]=l,e[9]=N,e[10]=g,e[11]=j,e[12]=b,e[13]=I,e[14]=v,e[15]=f,e[16]=w,e[17]=T,e[18]=P,e[19]=A}else N=e[9],g=e[10],j=e[11],b=e[12],I=e[13],v=e[14],f=e[15],w=e[16],T=e[17],P=e[18],A=e[19];let L;e[33]!==b||e[34]!==I?(L=s.jsx("div",{className:b,children:I}),e[33]=b,e[34]=I,e[35]=L):L=e[35];let _;e[36]!==L||e[37]!==v||e[38]!==f?(_=s.jsxs("div",{className:v,children:[f,L]}),e[36]=L,e[37]=v,e[38]=f,e[39]=_):_=e[39];let M;e[40]===Symbol.for("react.memo_cache_sentinel")?(M=s.jsx($e,{children:"Cancel"}),e[40]=M):M=e[40];const O=m.length===0,h=m.length>0&&`(${m.length})`;let S;e[41]!==j||e[42]!==O||e[43]!==h?(S=s.jsxs(Ge,{className:"px-6 pb-6",children:[M,s.jsxs(Fe,{onClick:j,disabled:O,children:["Add ",h]})]}),e[41]=j,e[42]=O,e[43]=h,e[44]=S):S=e[44];let E;e[45]!==N||e[46]!==_||e[47]!==S||e[48]!==w||e[49]!==T?(E=s.jsxs(N,{className:w,children:[T,_,S]}),e[45]=N,e[46]=_,e[47]=S,e[48]=w,e[49]=T,e[50]=E):E=e[50];let p;return e[51]!==g||e[52]!==E||e[53]!==P||e[54]!==A?(p=s.jsx(g,{open:P,onOpenChange:A,children:E}),e[51]=g,e[52]=E,e[53]=P,e[54]=A,e[55]=p):p=e[55],p}function Xs(t){return t.role!=="owner"}function Js(t){const e=le.c(40),{memberIds:n,onMemberIdsChange:r,readOnly:l}=t,o=l===void 0?!1:l,[c,i]=D.useState(""),u=D.useDeferredValue(c),[x,m]=D.useState(!1),{data:C}=Ct();let d,N,g,j,b;if(e[0]!==C?.data?.members||e[1]!==u||e[2]!==n||e[3]!==r||e[4]!==o||e[5]!==c){const w=C?.data?.members??[];let T;e[11]!==n?(T=E=>n.includes(E.id),e[11]=n,e[12]=T):T=e[12];const P=w.filter(T);let A;e[13]!==u?(A=E=>{const p=u.toLowerCase();return E.user?.name?.toLowerCase().includes(p)||E.user?.email?.toLowerCase().includes(p)},e[13]=u,e[14]=A):A=e[14];const L=P.filter(A);let _;e[15]!==n||e[16]!==r?(_=E=>{r(n.filter(p=>p!==E))},e[15]=n,e[16]=r,e[17]=_):_=e[17];const M=_;let O;e[18]!==n||e[19]!==r?(O=E=>{r([...n,...E])},e[18]=n,e[19]=r,e[20]=O):O=e[20],d=O,j="flex flex-col h-full";let h;e[21]!==c?(h=s.jsx(Ke,{value:c,onChange:i,placeholder:"Search members...",className:"flex-1 border-b-0"}),e[21]=c,e[22]=h):h=e[22];let S;e[23]!==o?(S=o?s.jsx("div",{className:"pr-4",children:s.jsx(Re,{children:s.jsxs(Le,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsxs(ie,{variant:"outline",size:"sm",disabled:!0,children:[s.jsx(nt,{size:16}),"Add Member"]})})}),s.jsx(Me,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})})}):s.jsx("div",{className:"pr-4",children:s.jsxs(ie,{variant:"outline",size:"sm",onClick:()=>m(!0),children:[s.jsx(nt,{size:16}),"Add Member"]})}),e[23]=o,e[24]=S):S=e[24],e[25]!==h||e[26]!==S?(b=s.jsxs("div",{className:"flex items-center border-b border-border",children:[h,S]}),e[25]=h,e[26]=S,e[27]=b):b=e[27],N="flex-1 overflow-auto",g=P.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("div",{className:"text-center",children:[s.jsx("h3",{className:"text-lg font-medium mb-2",children:"No members"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Add members to this role to grant them the configured permissions."})]})}):L.length===0?s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsxs("p",{className:"text-sm text-muted-foreground",children:['No members match "',c,'"']})}):s.jsx("div",{className:"p-4 space-y-2",children:L.map(E=>s.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg bg-muted/30",children:[s.jsx(Ae,{url:E.user?.image??void 0,fallback:Zt(E.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-sm font-medium truncate",children:E.user?.name||"Unknown"}),s.jsx("p",{className:"text-xs text-muted-foreground truncate",children:E.user?.email})]}),o?s.jsx(Re,{children:s.jsxs(Le,{children:[s.jsx(Pe,{asChild:!0,children:s.jsx("div",{children:s.jsx(ie,{variant:"ghost",size:"sm",disabled:!0,children:s.jsx(It,{size:16})})})}),s.jsx(Me,{children:s.jsx("p",{children:"Owner membership cannot be changed"})})]})}):s.jsx(ie,{variant:"ghost",size:"sm",onClick:()=>M(E.id),children:s.jsx(It,{size:16})})]},E.id))}),e[0]=C?.data?.members,e[1]=u,e[2]=n,e[3]=r,e[4]=o,e[5]=c,e[6]=d,e[7]=N,e[8]=g,e[9]=j,e[10]=b}else d=e[6],N=e[7],g=e[8],j=e[9],b=e[10];let I;e[28]!==N||e[29]!==g?(I=s.jsx("div",{className:N,children:g}),e[28]=N,e[29]=g,e[30]=I):I=e[30];let v;e[31]!==x||e[32]!==d||e[33]!==n?(v=s.jsx(Ys,{open:x,onOpenChange:m,selectedMemberIds:n,onAddMembers:d}),e[31]=x,e[32]=d,e[33]=n,e[34]=v):v=e[34];let f;return e[35]!==j||e[36]!==b||e[37]!==I||e[38]!==v?(f=s.jsxs("div",{className:j,children:[b,I,v]}),e[35]=j,e[36]=b,e[37]=I,e[38]=v,e[39]=f):f=e[39],f}function Ws(t){const e=le.c(3);let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(st,{size:24,className:"animate-spin text-muted-foreground"})}),e[0]=n):n=e[0];let r;return e[1]!==t?(r=s.jsx(D.Suspense,{fallback:n,children:s.jsx(Js,{...t})}),e[1]=t,e[2]=r):r=e[2],r}const en={owner:[],admin:[],user:[]};function We(t,e){const n=t==="owner"||t==="admin",r=e.filter(l=>l.role===t);return{role:{slug:t,label:t.charAt(0).toUpperCase()+t.slice(1)},allowAllStaticPermissions:n,staticPermissions:en[t],toolSet:{},memberIds:r.map(l=>l.id)}}function tn({trigger:t,onSuccess:e}){const[n,r]=D.useState(!1),[l,o]=D.useState("mcp"),{locator:c}=Ce(),i=Oe(),u=Ut()??[],{customRoles:x,refetch:m}=Et(),{data:C}=it({queryKey:ue.members(c),queryFn:()=>ae.organization.listMembers()}),d=zt({resolver:es(Vs),defaultValues:Je()}),N=d.formState.isValid,g=d.formState.isDirty,[j,b]=D.useState(null),[I,v]=D.useState(null),f=!d.watch("role.id")&&!d.watch("role.slug")&&!I,[w,T]=D.useState(null),[P,A]=D.useState(!1),[L,_]=D.useState(null),M=a=>{const y=a.permission||{},F=y.self||[],de=F.includes("*"),te=de?[]:F.filter(B=>B!=="*"),W={};for(const[B,G]of Object.entries(y))if(B!=="self")if(B==="*")for(const Y of u)G.includes("*")?W[Y.id]=Y.tools?.map(re=>re.name)??[]:W[Y.id]=G;else{const Y=u.find(re=>re.id===B);Y&&(G.includes("*")?W[B]=Y.tools?.map(re=>re.name)??[]:W[B]=G)}const ce=(C?.data?.members??[]).filter(B=>B.role===a.role).map(B=>B.id);return{role:{id:a.id,slug:a.role,label:a.label},allowAllStaticPermissions:de,staticPermissions:te,toolSet:W,memberIds:ce}},O=a=>{const y=M(a);d.reset(y),b(a.id??null),v(null)},h=()=>{d.reset(Je()),b(null),v(null),o("mcp")},S=a=>{g&&N?(_(()=>()=>O(a)),A(!0)):O(a)},E=async()=>{g&&N&&await Z(),h()},p=a=>{if(g&&N)_(()=>()=>{const y=We(a,C?.data?.members??[]);d.reset(y),v(a),b(null),o("org")}),A(!0);else{const y=We(a,C?.data?.members??[]);d.reset(y),v(a),b(null),o("org")}},R=a=>{if(!a&&d.formState.isDirty&&N){_(()=>()=>{r(!1),d.reset(Je()),v(null)}),A(!0);return}if(r(a),!a)d.reset(Je()),v(null),b(null);else{const y=x[0];if(y)O(y);else{const F=We("user",C?.data?.members??[]);d.reset(F),v("user"),b(null),o("org")}}},k=()=>{A(!1),L&&(L(),_(null))},V=a=>{const y={};a.allowAllStaticPermissions?y.self=["*"]:a.staticPermissions.length>0&&(y.self=a.staticPermissions);for(const[F,de]of Object.entries(a.toolSet))if(de.length>0){const W=u.find(ee=>ee.id===F)?.tools?.map(ee=>ee.name)??[];W.length>0&&W.every(ee=>de.includes(ee))?y[F]=["*"]:y[F]=de}return y},q=ve({mutationFn:async a=>{const y=V(a),F=a.role.slug||a.role.label.toLowerCase().replace(/\s+/g,"-");if(a.role.slug&&!a.role.id){const W=(C?.data?.members??[]).filter(B=>B.role===a.role.slug).map(B=>B.id),ee=a.memberIds.filter(B=>!W.includes(B)),ce=W.filter(B=>!a.memberIds.includes(B));for(const B of ee){const G=await ae.organization.updateMemberRole({memberId:B,role:[a.role.slug]});if(G?.error)throw new Error(G.error.message)}for(const B of ce){const G=await ae.organization.updateMemberRole({memberId:B,role:["user"]});if(G?.error)throw new Error(G.error.message)}return a}else if(a.role.id){const te=await ae.organization.updateRole({roleId:a.role.id,data:{permission:y}});if(te?.error)throw new Error(te.error.message);const ee=(C?.data?.members??[]).filter(G=>G.role===a.role.slug).map(G=>G.id),ce=a.memberIds.filter(G=>!ee.includes(G)),B=ee.filter(G=>!a.memberIds.includes(G));for(const G of ce){const Y=await ae.organization.updateMemberRole({memberId:G,role:[a.role.slug]});if(Y?.error)throw new Error(Y.error.message)}for(const G of B){const Y=await ae.organization.updateMemberRole({memberId:G,role:["user"]});if(Y?.error)throw new Error(Y.error.message)}return a}else{const te=await ae.organization.createRole({role:F,permission:y});if(te?.error)throw new Error(te.error.message);for(const W of a.memberIds){const ee=await ae.organization.updateMemberRole({memberId:W,role:[F]});if(ee?.error)throw new Error(ee.error.message)}return{...a,role:{...a.role,id:te.data?.roleData?.id,slug:F}}}},onSuccess:(a,y)=>{i.invalidateQueries({queryKey:ue.members(c)}),i.invalidateQueries({queryKey:ue.organizationRoles(c)});const F=!y.role.id&&!y.role.slug,de=y.role.slug&&!y.role.id;ne.success(de?"Members updated successfully!":F?"Role created successfully!":"Role updated successfully!"),m(),d.reset(a),a.role.id&&b(a.role.id),e?.()},onError:a=>{ne.error(a instanceof Error?a.message:"Failed to save role")}}),Q=ve({mutationFn:async a=>{const y=await ae.organization.deleteRole({roleId:a});if(y?.error)throw new Error(y.error.message);return y?.data},onSuccess:()=>{if(i.invalidateQueries({queryKey:ue.members(c)}),i.invalidateQueries({queryKey:ue.organizationRoles(c)}),ne.success("Role deleted successfully!"),m(),w?.id===j){const a=x.filter(y=>y.id!==w?.id);if(a[0])O(a[0]);else{const y=We("user",C?.data?.members??[]);d.reset(y),v("user"),b(null),o("org")}}},onError:a=>{ne.error(a instanceof Error?a.message:"Failed to delete role")}}),H=q.isPending||Q.isPending,Z=async()=>{const a=d.getValues();if(!a.role.label.trim()){ne.error("Role name is required"),d.setFocus("role.label");return}await q.mutateAsync(a)},se=d.handleSubmit(a=>{if(!a.role.label.trim()){ne.error("Role name is required"),d.setFocus("role.label");return}q.mutate(a)}),J=a=>{a.id&&T({id:a.id,label:a.label})},U=()=>{w?.id&&Q.mutate(w.id),T(null)};return s.jsxs(Bt,{open:n,onOpenChange:R,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsx(Gt,{className:"sm:max-w-5xl h-[80vh] max-h-[80vh] flex flex-col p-0 overflow-hidden w-[95vw]",children:s.jsxs("div",{className:"flex-1 flex overflow-hidden min-h-0 flex-col sm:flex-row",children:[s.jsxs("div",{className:"w-full sm:w-64 sm:border-r border-b sm:border-b-0 border-border flex flex-col bg-background sm:h-full max-h-[40vh] sm:max-h-full",children:[s.jsx("div",{className:"flex-1 overflow-auto px-3.5 py-3.5 pt-3.5",children:s.jsxs("div",{className:"flex flex-col gap-1",children:[Gs.map(a=>{const y=I===a.role;return s.jsxs("div",{className:X("flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden cursor-pointer transition-colors",y?"bg-accent":"hover:bg-muted/50"),onClick:()=>p(a.role),children:[s.jsx("div",{className:X("shrink-0 size-3 rounded-full",a.color)}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:a.label}),s.jsx(js,{size:14,className:"text-muted-foreground shrink-0"})]},a.role)}),x.map(a=>{const y=j===a.id;return s.jsxs("div",{className:X("group flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden transition-colors cursor-pointer",y?"bg-accent":"hover:bg-muted/50"),onClick:()=>S(a),children:[s.jsx("div",{className:X("shrink-0 size-3 rounded-full",$s(a.label))}),s.jsx("p",{className:"text-sm font-medium truncate flex-1",children:a.label}),s.jsxs(jt,{children:[s.jsx(vt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"icon",className:X("size-5 shrink-0 transition-opacity opacity-0 pointer-events-none","group-hover:opacity-100 group-hover:pointer-events-auto",y&&"opacity-100 pointer-events-auto"),onClick:F=>F.stopPropagation(),children:s.jsx(Cs,{size:14})})}),s.jsx(Nt,{align:"end",children:s.jsxs(tt,{className:"text-destructive",onClick:F=>{F.stopPropagation(),J(a)},children:[s.jsx($t,{size:16}),"Delete"]})})]})]},a.id)}),f&&s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded-lg overflow-hidden bg-accent",children:[s.jsx("div",{className:"shrink-0 size-3 rounded-full bg-neutral-400"}),s.jsx(vs,{...d.register("role.label"),placeholder:"Enter role name",className:"flex-1 text-sm font-medium border-0 shadow-none h-auto px-0 py-0 focus-visible:ring-0 bg-transparent",autoFocus:!0}),s.jsx(Ee,{variant:"secondary",className:"shrink-0 text-xs px-1.5 py-0",children:"New"})]})]})}),s.jsx("div",{className:"px-3.5 pb-3.5",children:s.jsxs(ie,{variant:"outline",size:"default",onClick:E,disabled:H||g,className:"w-full h-10",children:[s.jsx(nt,{size:16}),"Create new role"]})})]}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.jsxs("div",{className:"h-12 border-b border-border px-4 py-3.5 flex items-center gap-2 shrink-0",children:[!I&&s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("mcp"),className:X("h-7 rounded-lg px-2 border border-input transition-colors",l==="mcp"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"MCP Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("org"),className:X("h-7 rounded-lg px-2 border border-input transition-colors",l==="org"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Organization Permissions"}),s.jsx(ie,{variant:"outline",size:"sm",onClick:()=>o("members"),className:X("h-7 rounded-lg px-2 border border-input transition-colors",l==="members"?"bg-accent border-border text-foreground":"bg-transparent text-muted-foreground hover:border-border hover:bg-accent/50 hover:text-foreground"),children:"Members"})]}),s.jsxs("div",{className:"flex-1 overflow-hidden min-h-0",children:[l==="mcp"&&!I&&s.jsx(Ds,{toolSet:d.watch("toolSet"),onToolSetChange:a=>d.setValue("toolSet",a,{shouldDirty:!0})}),l==="org"&&s.jsx(Fs,{allowAllStaticPermissions:d.watch("allowAllStaticPermissions"),staticPermissions:d.watch("staticPermissions"),onAllowAllChange:a=>d.setValue("allowAllStaticPermissions",a,{shouldDirty:!0}),onPermissionsChange:a=>d.setValue("staticPermissions",a,{shouldDirty:!0}),readOnly:!!I}),l==="members"&&s.jsx(Ws,{memberIds:d.watch("memberIds"),onMemberIdsChange:a=>d.setValue("memberIds",a,{shouldDirty:!0}),readOnly:I==="owner"})]}),(!I||I!=="owner")&&s.jsxs("div",{className:"border-t border-border px-5 py-5 flex items-center justify-end gap-2.5 shrink-0",children:[s.jsx(ie,{variant:"outline",onClick:()=>R(!1),disabled:H,className:"h-10",children:"Cancel"}),s.jsx(ie,{onClick:se,disabled:H||!N||!d.formState.isDirty,className:"h-10",children:q.isPending?"Saving...":f?"Create Role":"Save Changes"})]})]})]})}),s.jsx(ze,{open:w!==null,onOpenChange:a=>!a&&T(null),children:s.jsxs(ke,{children:[s.jsxs(Ue,{children:[s.jsx(Be,{children:"Delete Role"}),s.jsxs(Ve,{children:['Are you sure you want to delete the "',w?.label,'" role? This action cannot be undone.']})]}),s.jsxs(Ge,{children:[s.jsx($e,{children:"Cancel"}),s.jsx(Fe,{onClick:U,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})}),s.jsx(ze,{open:P,onOpenChange:A,children:s.jsxs(ke,{children:[s.jsxs(Ue,{children:[s.jsx(Be,{children:"Discard Changes"}),s.jsx(Ve,{children:"You have unsaved changes. Are you sure you want to discard them?"})]}),s.jsxs(Ge,{children:[s.jsx($e,{onClick:()=>_(null),children:"Keep Editing"}),s.jsx(Fe,{onClick:k,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Discard"})]})]})})]})}const sn=Ne().email("Invalid email address");function nn(t){if(!t.trim())return[];const e=t.split(/[,;\n]/).map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);return Array.from(new Set(e))}function rn({trigger:t}){const[e,n]=D.useState(!1),{locator:r}=Ce(),l=Oe(),{data:o}=ae.useSession(),c=o?.user?.email,{roles:i,isLoading:u}=Et(),x=i.filter(v=>v.role!=="owner"),m=zt({mode:"onChange",defaultValues:{emailsText:"",role:"user"}}),C=m.watch("emailsText"),d=m.watch("role"),g=nn(C).filter(v=>{const f=sn.safeParse(v).success,w=!c||v!==c.toLowerCase();return f&&w}),j=ve({mutationFn:async({emails:v,role:f})=>{if(!f)throw new Error("Please select a role");const w=await Promise.allSettled(v.map(async P=>{const A=await ae.organization.inviteMember({email:P,role:f});if(A.error)throw new Error(A.error.message);return A.data})),T=w.filter(P=>P.status==="rejected");if(T.length>0)throw new Error(`Failed to invite ${T.length} member${T.length>1?"s":""}`);return w},onSuccess:(v,{emails:f})=>{l.invalidateQueries({queryKey:ue.members(r)}),l.invalidateQueries({queryKey:ue.invitations(r)}),ne.success(f.length===1?"Member invited successfully!":`${f.length} members invited successfully!`),m.reset({emailsText:"",role:"user"}),n(!1)},onError:v=>{ne.error(v instanceof Error?v.message:"Failed to invite members")}}),b=v=>{if(g.length===0){ne.error("Please enter at least one valid email address");return}if(!v.role){ne.error("Please select a role");return}j.mutate({emails:g,role:v.role})},I=g.length>0&&!!d;return s.jsxs(Bt,{open:e,onOpenChange:n,children:[s.jsx(Vt,{asChild:!0,children:t}),s.jsxs(Gt,{className:"sm:max-w-lg",children:[s.jsx(us,{children:s.jsx(fs,{children:"Invite members"})}),s.jsx(Ts,{...m,children:s.jsxs("form",{onSubmit:m.handleSubmit(b),className:"space-y-4",children:[s.jsx(wt,{control:m.control,name:"emailsText",render:({field:v})=>s.jsxs(At,{children:[s.jsx(Es,{children:"Email addresses"}),s.jsx(Ot,{children:s.jsx(ys,{...v,disabled:j.isPending,placeholder:`Enter email addresses separated by commas or new lines
|
|
2
|
-
e.g. user1@example.com, user2@example.com
|
|
3
|
-
or one per line`,className:"min-h-[120px] resize-none"})}),s.jsx(_t,{})]})}),s.jsx(wt,{control:m.control,name:"role",render:({field:v})=>s.jsxs(At,{children:[s.jsx(Ot,{children:s.jsxs(ht,{value:v.value,onValueChange:v.onChange,disabled:j.isPending||u,children:[s.jsx(gt,{className:"w-full",children:s.jsx(xt,{placeholder:"Select a role"})}),s.jsx(pt,{children:x.map(f=>{const w=[];return f.isBuiltin||(f.allowsAllStaticPermissions?w.push("Full org access"):f.staticPermissionCount&&f.staticPermissionCount>0&&w.push(`${f.staticPermissionCount} org perm${f.staticPermissionCount!==1?"s":""}`),f.allowsAllConnections?w.push("All connections"):f.connectionCount&&f.connectionCount>0&&w.push(`${f.connectionCount} connection${f.connectionCount!==1?"s":""}`),(f.connectionCount!==0||f.allowsAllConnections)&&(f.allowsAllTools?w.push("all tools"):f.toolCount&&f.toolCount>0&&w.push(`${f.toolCount} tool${f.toolCount!==1?"s":""}`))),s.jsx(bt,{value:f.role,children:s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{children:f.label}),!f.isBuiltin&&w.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:w.join(", ")})]})},f.role)})})]})}),s.jsx(_t,{})]})}),s.jsxs(hs,{children:[s.jsx(ie,{variant:"outline",onClick:()=>{m.reset({emailsText:"",role:"user"}),n(!1)},type:"button",disabled:j.isPending,children:"Cancel"}),s.jsx(ie,{type:"submit",disabled:j.isPending||!I,children:j.isPending?"Inviting...":`Invite ${g.length||0} Member${g.length!==1?"s":""}`})]})]})})]})]})}function on(){const t=le.c(9),{org:e,locator:n}=Ce();let r;t[0]!==e.id?(r={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Qe(r);let o;t[2]!==n?(o=ue.invitations(n),t[2]=n,t[3]=o):o=t[3];let c;t[4]!==l?(c=async()=>{const u=await l.callTool({name:"ORGANIZATION_GET",arguments:{}});return(u.structuredContent??u)?.invitations??[]},t[4]=l,t[5]=c):c=t[5];let i;return t[6]!==o||t[7]!==c?(i={queryKey:o,queryFn:c},t[6]=o,t[7]=c,t[8]=i):i=t[8],ts(i)}function ln(){const t=le.c(5),{locator:e}=Ce(),n=Oe();let r;t[0]!==e||t[1]!==n?(r={mutationFn:cn,onSuccess:()=>{n.invalidateQueries({queryKey:ue.invitations(e)}),ne.success("Invitation cancelled")},onError:an},t[0]=e,t[1]=n,t[2]=r):r=t[2];const l=ve(r);let o;return t[3]!==l?(o={cancel:l},t[3]=l,t[4]=o):o=t[4],o}function an(t){ne.error(t instanceof Error?t.message:"Failed to cancel invitation")}async function cn(t){const e=await ae.organization.cancelInvitation({invitationId:t});if(e?.error)throw new Error(e.error.message);return e.data}const ot={tags:t=>[t,"tags"],memberTags:(t,e)=>[t,"member-tags",e]};function dn(){const t=le.c(9),{org:e,locator:n}=Ce();let r;t[0]!==e.id?(r={connectionId:qe,orgId:e.id},t[0]=e.id,t[1]=r):r=t[1];const l=Qe(r);let o;t[2]!==n?(o=ot.tags(n),t[2]=n,t[3]=o):o=t[3];let c;t[4]!==l?(c=async()=>{const u=await l.callTool({name:"TAGS_LIST",arguments:{}});return(u.structuredContent??u).tags},t[4]=l,t[5]=c):c=t[5];let i;return t[6]!==o||t[7]!==c?(i={queryKey:o,queryFn:c,staleTime:3e4},t[6]=o,t[7]=c,t[8]=i):i=t[8],it(i)}function mn(){const t=le.c(10),e=Oe(),{org:n,locator:r}=Ce();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Qe(l);let c;t[2]!==o?(c=async x=>{const m=await o.callTool({name:"TAGS_CREATE",arguments:{name:x}});return(m.structuredContent??m).tag},t[2]=o,t[3]=c):c=t[3];let i;t[4]!==r||t[5]!==e?(i=()=>{e.invalidateQueries({queryKey:ot.tags(r)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let u;return t[7]!==c||t[8]!==i?(u={mutationFn:c,onSuccess:i,onError:un},t[7]=c,t[8]=i,t[9]=u):u=t[9],ve(u)}function un(t){ne.error(t instanceof Error?t.message:"Failed to create tag")}function fn(t){const e=le.c(12),{org:n,locator:r}=Ce();let l;e[0]!==n.id?(l={connectionId:qe,orgId:n.id},e[0]=n.id,e[1]=l):l=e[1];const o=Qe(l);let c;e[2]!==r||e[3]!==t?(c=ot.memberTags(r,t),e[2]=r,e[3]=t,e[4]=c):c=e[4];let i;e[5]!==o||e[6]!==t?(i=async()=>{const m=await o.callTool({name:"MEMBER_TAGS_GET",arguments:{memberId:t}});return(m.structuredContent??m).tags},e[5]=o,e[6]=t,e[7]=i):i=e[7];const u=!!t;let x;return e[8]!==c||e[9]!==i||e[10]!==u?(x={queryKey:c,queryFn:i,staleTime:3e4,enabled:u},e[8]=c,e[9]=i,e[10]=u,e[11]=x):x=e[11],it(x)}function hn(){const t=le.c(10),e=Oe(),{org:n,locator:r}=Ce();let l;t[0]!==n.id?(l={connectionId:qe,orgId:n.id},t[0]=n.id,t[1]=l):l=t[1];const o=Qe(l);let c;t[2]!==o?(c=async x=>{const{memberId:m,tagIds:C}=x,d=await o.callTool({name:"MEMBER_TAGS_SET",arguments:{memberId:m,tagIds:C}});return d.structuredContent??d},t[2]=o,t[3]=c):c=t[3];let i;t[4]!==r||t[5]!==e?(i=(x,m)=>{e.invalidateQueries({queryKey:ot.memberTags(r,m.memberId)})},t[4]=r,t[5]=e,t[6]=i):i=t[6];let u;return t[7]!==c||t[8]!==i?(u={mutationFn:c,onSuccess:i,onError:gn},t[7]=c,t[8]=i,t[9]=u):u=t[9],ve(u)}function gn(t){ne.error(t instanceof Error?t.message:"Failed to update member tags")}function Yt(t){const e=le.c(44),{memberId:n,className:r,disabled:l,placeholder:o,maxDisplay:c}=t,i=l===void 0?!1:l,u=o===void 0?"Add tags...":o,x=c===void 0?2:c,[m,C]=D.useState(!1),[d,N]=D.useState(""),{data:g,isLoading:j}=dn(),b=g===void 0?[]:g,{data:I,isLoading:v}=fn(n),f=I===void 0?[]:I,w=mn(),T=hn(),P=j||v,A=f.map(pn);let L;e[0]!==d?(L=K=>K.name.toLowerCase().includes(d.toLowerCase()),e[0]=d,e[1]=L):L=e[1];const _=b.filter(L);let M;e[2]!==d?(M=K=>K.name.toLowerCase()===d.toLowerCase(),e[2]=d,e[3]=M):M=e[3];const O=b.find(M),h=d.trim()&&!O,S=async K=>{const be=A.includes(K.id)?A.filter(ye=>ye!==K.id):[...A,K.id];await T.mutateAsync({memberId:n,tagIds:be})},E=async()=>{if(!d.trim())return;const K=await w.mutateAsync(d.trim());await T.mutateAsync({memberId:n,tagIds:[...A,K.id]}),N("")},p=async K=>{const ge=A.filter(be=>be!==K);await T.mutateAsync({memberId:n,tagIds:ge})},R=w.isPending||T.isPending,k=ws;let V;e[4]!==m?(V=()=>C(!m),e[4]=m,e[5]=V):V=e[5];let q;e[6]!==r?(q=X("h-auto min-h-8 px-2 py-1 justify-start font-normal","hover:bg-accent/50",r),e[6]=r,e[7]=q):q=e[7];const Q=i||P,H=P?s.jsx(st,{size:14,className:"animate-spin text-muted-foreground"}):f.length>0?s.jsxs("div",{className:"flex items-center gap-1 flex-wrap",children:[f.slice(0,x).map(xn),f.length>x&&s.jsxs(Ee,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:["+",f.length-x]})]}):s.jsx("span",{className:"text-muted-foreground text-xs",children:u});let Z;e[8]===Symbol.for("react.memo_cache_sentinel")?(Z=s.jsx(Os,{size:14,className:"ml-1 shrink-0 opacity-50"}),e[8]=Z):Z=e[8];let se;e[9]!==Q||e[10]!==H||e[11]!==V||e[12]!==q?(se=s.jsx(As,{asChild:!0,children:s.jsxs(ie,{variant:"ghost",size:"sm",onClick:V,className:q,disabled:Q,children:[H,Z]})}),e[9]=Q,e[10]=H,e[11]=V,e[12]=q,e[13]=se):se=e[13];const J=Is,U="w-56 p-0",a="start";let y;e[14]===Symbol.for("react.memo_cache_sentinel")?(y=()=>C(!1),e[14]=y):y=e[14];const F=ds,de=!1;let te;e[15]!==d?(te=s.jsx(ms,{placeholder:"Search or create...",value:d,onValueChange:N,className:"h-9"}),e[15]=d,e[16]=te):te=e[16];const W=cs,ee=f.length>0&&s.jsxs(s.Fragment,{children:[s.jsx(mt,{heading:"Selected",children:f.map(K=>s.jsx(ut,{onSelect:()=>S(K),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center justify-between w-full",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(De,{checked:!0,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:K.name})]}),s.jsx("button",{onClick:ge=>{ge.stopPropagation(),p(K.id)},className:"opacity-50 hover:opacity-100",disabled:R,children:s.jsx(Kt,{size:14})})]})},K.id))}),s.jsx(St,{})]}),ce=mt,B="Available",G=_.length===0&&!h&&s.jsx(as,{children:"No tags found."}),Y=_.filter(K=>!A.includes(K.id)).map(K=>s.jsx(ut,{onSelect:()=>S(K),className:"cursor-pointer",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(De,{checked:!1,className:"[&_svg]:!text-primary-foreground"}),s.jsx("span",{children:K.name})]})},K.id));let re;e[17]!==ce||e[18]!==G||e[19]!==Y?(re=s.jsxs(ce,{heading:B,children:[G,Y]}),e[17]=ce,e[18]=G,e[19]=Y,e[20]=re):re=e[20];let me;e[21]!==E||e[22]!==R||e[23]!==d||e[24]!==h?(me=h&&s.jsxs(s.Fragment,{children:[s.jsx(St,{}),s.jsx(mt,{children:s.jsx(ut,{onSelect:E,className:"cursor-pointer",disabled:R,children:s.jsxs("div",{className:"flex items-center gap-2 text-primary",children:[R?s.jsx(st,{size:14,className:"animate-spin"}):s.jsx(nt,{size:14}),s.jsxs("span",{children:['Create "',d.trim(),'"']})]})})})]}),e[21]=E,e[22]=R,e[23]=d,e[24]=h,e[25]=me):me=e[25];let pe;e[26]!==W||e[27]!==ee||e[28]!==re||e[29]!==me?(pe=s.jsxs(W,{children:[ee,re,me]}),e[26]=W,e[27]=ee,e[28]=re,e[29]=me,e[30]=pe):pe=e[30];let fe;e[31]!==F||e[32]!==te||e[33]!==pe?(fe=s.jsxs(F,{shouldFilter:de,children:[te,pe]}),e[31]=F,e[32]=te,e[33]=pe,e[34]=fe):fe=e[34];let he;e[35]!==J||e[36]!==y||e[37]!==fe?(he=s.jsx(J,{className:U,align:a,onEscapeKeyDown:y,children:fe}),e[35]=J,e[36]=y,e[37]=fe,e[38]=he):he=e[38];let je;return e[39]!==k||e[40]!==m||e[41]!==se||e[42]!==he?(je=s.jsxs(k,{open:m,onOpenChange:C,children:[se,he]}),e[39]=k,e[40]=m,e[41]=se,e[42]=he,e[43]=je):je=e[43],je}function xn(t){return s.jsx(Ee,{variant:"secondary",className:"text-xs px-1.5 py-0 h-5",children:t.name},t.id)}function pn(t){return t.id}const Pt=["bg-neutral-400","bg-red-500","bg-orange-500","bg-amber-500","bg-yellow-500","bg-lime-500","bg-green-500","bg-emerald-500","bg-teal-500","bg-cyan-500","bg-sky-500","bg-blue-500","bg-indigo-500","bg-violet-500","bg-purple-500","bg-fuchsia-500","bg-pink-500","bg-rose-500","bg-slate-500"],bn={owner:"bg-red-500",admin:"bg-blue-500",user:"bg-green-500"};function rt(t){return t?t.split(" ").map(e=>e[0]).join("").toUpperCase().slice(0,2):"?"}function Cn(t){const e=new Map;for(const[n,r]of Object.entries(bn))e.set(n,r);for(let n=0;n<t.length;n++){const r=t[n];r&&!e.has(r.role)&&e.set(r.role,Pt[n%Pt.length]??"bg-neutral-400")}return e}function jn(t){return new Date(t).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}function et(t){const e=le.c(79),{role:n,memberId:r,isOwner:l,roleColorMap:o,selectableRoles:c,onRoleChange:i,size:u,className:x}=t,m=u===void 0?"xs":u;let C,d,N,g,j,b,I,v,f,w,T;if(e[0]!==x||e[1]!==l||e[2]!==r||e[3]!==i||e[4]!==n||e[5]!==o||e[6]!==c||e[7]!==m){T=Symbol.for("react.early_return_sentinel");e:{const E=o.get(n)??"bg-neutral-400";if(l){let p;e[19]!==r||e[20]!==i?(p=U=>i(r,U),e[19]=r,e[20]=i,e[21]=p):p=e[21];let R;e[22]!==n?(R=s.jsx("span",{className:"capitalize truncate",children:n}),e[22]=n,e[23]=R):R=e[23];const k=s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx("div",{className:X("size-2 rounded-full shrink-0",E)}),R]});let V;e[24]!==k?(V=s.jsx(xt,{children:k}),e[24]=k,e[25]=V):V=e[25];let q;e[26]!==x||e[27]!==m||e[28]!==V?(q=s.jsx(gt,{size:m,className:x,children:V}),e[26]=x,e[27]=m,e[28]=V,e[29]=q):q=e[29];let Q;if(e[30]!==o||e[31]!==c){let U;e[33]!==o?(U=a=>{const y=o.get(a.role)??"bg-neutral-400";return s.jsx(bt,{value:a.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:X("size-3 rounded-full",y)}),s.jsx("span",{className:"capitalize",children:a.label})]})},a.role)},e[33]=o,e[34]=U):U=e[34],Q=c.map(U),e[30]=o,e[31]=c,e[32]=Q}else Q=e[32];let H;e[35]!==Q?(H=s.jsx(pt,{children:Q}),e[35]=Q,e[36]=H):H=e[36];let Z;e[37]!==l||e[38]!==n||e[39]!==p||e[40]!==q||e[41]!==H?(Z=s.jsx(Pe,{asChild:!0,children:s.jsx("div",{className:"w-fit",children:s.jsxs(ht,{value:n,onValueChange:p,disabled:l,children:[q,H]})})}),e[37]=l,e[38]=n,e[39]=p,e[40]=q,e[41]=H,e[42]=Z):Z=e[42];let se;e[43]===Symbol.for("react.memo_cache_sentinel")?(se=s.jsx(Me,{children:s.jsx("p",{children:"The owner role cannot be changed"})}),e[43]=se):se=e[43];let J;e[44]!==Z?(J=s.jsx(Re,{children:s.jsxs(Le,{children:[Z,se]})}),e[44]=Z,e[45]=J):J=e[45],T=J;break e}N=ht,v=n,e[46]!==r||e[47]!==i?(f=p=>i(r,p),e[46]=r,e[47]=i,e[48]=f):f=e[48],w=l,d=gt,b=m,I=x,C=xt,j="flex items-center gap-2 min-w-0",g=X("size-2 rounded-full shrink-0",E)}e[0]=x,e[1]=l,e[2]=r,e[3]=i,e[4]=n,e[5]=o,e[6]=c,e[7]=m,e[8]=C,e[9]=d,e[10]=N,e[11]=g,e[12]=j,e[13]=b,e[14]=I,e[15]=v,e[16]=f,e[17]=w,e[18]=T}else C=e[8],d=e[9],N=e[10],g=e[11],j=e[12],b=e[13],I=e[14],v=e[15],f=e[16],w=e[17],T=e[18];if(T!==Symbol.for("react.early_return_sentinel"))return T;let P;e[49]!==g?(P=s.jsx("div",{className:g}),e[49]=g,e[50]=P):P=e[50];let A;e[51]!==n?(A=s.jsx("span",{className:"capitalize truncate",children:n}),e[51]=n,e[52]=A):A=e[52];let L;e[53]!==P||e[54]!==A||e[55]!==j?(L=s.jsxs("div",{className:j,children:[P,A]}),e[53]=P,e[54]=A,e[55]=j,e[56]=L):L=e[56];let _;e[57]!==C||e[58]!==L?(_=s.jsx(C,{children:L}),e[57]=C,e[58]=L,e[59]=_):_=e[59];let M;e[60]!==d||e[61]!==_||e[62]!==b||e[63]!==I?(M=s.jsx(d,{size:b,className:I,children:_}),e[60]=d,e[61]=_,e[62]=b,e[63]=I,e[64]=M):M=e[64];let O;if(e[65]!==o||e[66]!==c){let E;e[68]!==o?(E=p=>{const R=o.get(p.role)??"bg-neutral-400";return s.jsx(bt,{value:p.role,children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:X("size-3 rounded-full",R)}),s.jsx("span",{className:"capitalize",children:p.label})]})},p.role)},e[68]=o,e[69]=E):E=e[69],O=c.map(E),e[65]=o,e[66]=c,e[67]=O}else O=e[67];let h;e[70]!==O?(h=s.jsx(pt,{children:O}),e[70]=O,e[71]=h):h=e[71];let S;return e[72]!==N||e[73]!==M||e[74]!==h||e[75]!==v||e[76]!==f||e[77]!==w?(S=s.jsxs(N,{value:v,onValueChange:f,disabled:w,children:[M,h]}),e[72]=N,e[73]=M,e[74]=h,e[75]=v,e[76]=f,e[77]=w,e[78]=S):S=e[78],S}function Mt(t){const e=le.c(51),{member:n,roles:r,onChangeRole:l,onRemove:o,isUpdating:c}=t,i=c===void 0?!1:c,u=n.role==="owner";let x,m,C,d,N,g,j,b,I;if(e[0]!==u||e[1]!==i||e[2]!==n.id||e[3]!==n.role||e[4]!==l||e[5]!==r){let M;e[15]!==n.role?(M=p=>p.role!==n.role&&p.role!=="owner",e[15]=n.role,e[16]=M):M=e[16];const O=r.filter(M);d=jt;let h;e[17]===Symbol.for("react.memo_cache_sentinel")?(h=s.jsx(Ft,{size:20}),e[17]=h):h=e[17],e[18]!==u?(I=s.jsx(vt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",disabled:u,onClick:Nn,children:h})}),e[18]=u,e[19]=I):I=e[19],C=Nt,j="end",b=vn,m=gs;let S;e[20]===Symbol.for("react.memo_cache_sentinel")?(S=s.jsx(Qt,{size:16}),e[20]=S):S=e[20],e[21]!==i?(g=s.jsxs(xs,{disabled:i,children:[S,"Change Role"]}),e[21]=i,e[22]=g):g=e[22],x=ps;let E;e[23]!==i||e[24]!==n.id||e[25]!==l?(E=p=>{const R=[];return p.isBuiltin||(p.allowsAllStaticPermissions?R.push("Full org access"):p.staticPermissionCount&&p.staticPermissionCount>0&&R.push(`${p.staticPermissionCount} org perm${p.staticPermissionCount!==1?"s":""}`),p.allowsAllConnections?R.push("All connections"):p.connectionCount&&p.connectionCount>0&&R.push(`${p.connectionCount} connection${p.connectionCount!==1?"s":""}`),(p.connectionCount!==0||p.allowsAllConnections)&&(p.allowsAllTools?R.push("all tools"):p.toolCount&&p.toolCount>0&&R.push(`${p.toolCount} tool${p.toolCount!==1?"s":""}`))),s.jsxs(tt,{onClick:k=>{k.stopPropagation(),l(n.id,p.role)},disabled:i,children:[p.isBuiltin?s.jsx(Tt,{size:16}):s.jsx(Ss,{size:16}),s.jsxs("span",{className:"flex flex-col",children:[s.jsx("span",{children:p.label}),!p.isBuiltin&&R.length>0&&s.jsx("span",{className:"text-xs text-muted-foreground",children:R.join(", ")})]})]},p.role)},e[23]=i,e[24]=n.id,e[25]=l,e[26]=E):E=e[26],N=O.map(E),e[0]=u,e[1]=i,e[2]=n.id,e[3]=n.role,e[4]=l,e[5]=r,e[6]=x,e[7]=m,e[8]=C,e[9]=d,e[10]=N,e[11]=g,e[12]=j,e[13]=b,e[14]=I}else x=e[6],m=e[7],C=e[8],d=e[9],N=e[10],g=e[11],j=e[12],b=e[13],I=e[14];let v;e[27]!==x||e[28]!==N?(v=s.jsx(x,{children:N}),e[27]=x,e[28]=N,e[29]=v):v=e[29];let f;e[30]!==m||e[31]!==g||e[32]!==v?(f=s.jsxs(m,{children:[g,v]}),e[30]=m,e[31]=g,e[32]=v,e[33]=f):f=e[33];let w;e[34]===Symbol.for("react.memo_cache_sentinel")?(w=s.jsx(bs,{}),e[34]=w):w=e[34];let T;e[35]!==n.id||e[36]!==o?(T=M=>{M.stopPropagation(),o(n.id)},e[35]=n.id,e[36]=o,e[37]=T):T=e[37];let P;e[38]===Symbol.for("react.memo_cache_sentinel")?(P=s.jsx($t,{size:16}),e[38]=P):P=e[38];let A;e[39]!==T?(A=s.jsxs(tt,{variant:"destructive",onClick:T,children:[P,"Remove Member"]}),e[39]=T,e[40]=A):A=e[40];let L;e[41]!==C||e[42]!==A||e[43]!==j||e[44]!==b||e[45]!==f?(L=s.jsxs(C,{align:j,onClick:b,children:[f,w,A]}),e[41]=C,e[42]=A,e[43]=j,e[44]=b,e[45]=f,e[46]=L):L=e[46];let _;return e[47]!==d||e[48]!==L||e[49]!==I?(_=s.jsxs(d,{children:[I,L]}),e[47]=d,e[48]=L,e[49]=I,e[50]=_):_=e[50],_}function vn(t){return t.stopPropagation()}function Nn(t){return t.stopPropagation()}function Dt(t){const e=le.c(8),{invitationId:n,onCancel:r,isCancelling:l}=t,o=l===void 0?!1:l;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c=s.jsx(vt,{asChild:!0,children:s.jsx(ie,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0",onClick:En,children:s.jsx(Ft,{size:20})})}),e[0]=c):c=e[0];let i;e[1]!==n||e[2]!==r?(i=m=>{m.stopPropagation(),r(n)},e[1]=n,e[2]=r,e[3]=i):i=e[3];let u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=s.jsx(Kt,{size:16}),e[4]=u):u=e[4];let x;return e[5]!==o||e[6]!==i?(x=s.jsxs(jt,{children:[c,s.jsx(Nt,{align:"end",onClick:Tn,children:s.jsxs(tt,{variant:"destructive",onClick:i,disabled:o,children:[u,"Cancel Invitation"]})})]}),e[5]=o,e[6]=i,e[7]=x):x=e[7],x}function Tn(t){return t.stopPropagation()}function En(t){return t.stopPropagation()}function yn(){const t=le.c(79),{data:e}=Ct(),{data:n}=on(),r=ln(),l=Oe(),{locator:o}=Ce(),[c,i]=D.useState(null),[u,x]=D.useState(null),[m,C]=D.useState(""),[d,N]=D.useState("table"),[g,j]=D.useState("member"),[b,I]=D.useState("asc"),v=e?.data?.members;let f;t[0]!==g?(f=z=>{g===z?I(Un):(j(z),I("asc"))},t[0]=g,t[1]=f):f=t[1];const w=f;let T=v??[],P=n??[];if(m){const z=m.toLowerCase();T=T.filter($=>$.user?.name?.toLowerCase().includes(z)||$.user?.email?.toLowerCase().includes(z)||$.role?.toLowerCase().includes(z)),P=P.filter($=>$.email?.toLowerCase().includes(z)||$.role?.toLowerCase().includes(z))}if(g&&b){let z;t[2]!==b||t[3]!==g?(z=($,oe)=>{let xe,_e;e:switch(g){case"member":{xe=$.user?.name||"",_e=oe.user?.name||"";break e}case"role":{xe=$.role||"",_e=oe.role||"";break e}case"joined":{xe=$.createdAt?typeof $.createdAt=="string"?$.createdAt:$.createdAt.toISOString():"",_e=oe.createdAt?typeof oe.createdAt=="string"?oe.createdAt:oe.createdAt.toISOString():"";break e}default:return 0}return b==="asc"?xe.localeCompare(_e):_e.localeCompare(xe)},t[2]=b,t[3]=g,t[4]=z):z=t[4],T=[...T].sort(z)}const A=T;let L;t[5]!==o||t[6]!==l?(L={mutationFn:kn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(o)}),ne.success("Member has been removed from the organization"),i(null)},onError:zn},t[5]=o,t[6]=l,t[7]=L):L=t[7];const _=ve(L);let M;t[8]!==o||t[9]!==l?(M={mutationFn:Dn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.members(o)}),ne.success("Member's role has been updated")},onError:Mn},t[8]=o,t[9]=l,t[10]=M):M=t[10];const O=ve(M);let h;t[11]!==o||t[12]!==l?(h={mutationFn:Pn,onSuccess:()=>{l.invalidateQueries({queryKey:ue.invitations(o)}),ne.success("Invitation role has been updated")},onError:Ln},t[11]=o,t[12]=l,t[13]=h):h=t[13];const S=ve(h),{roles:E,customRoles:p}=Et();let R;t[14]!==p?(R=Cn(p),t[14]=p,t[15]=R):R=t[15];const k=R;let V;t[16]!==E?(V=E.filter(Rn),t[16]=E,t[17]=V):V=t[17];const q=V;let Q;t[18]===Symbol.for("react.memo_cache_sentinel")?(Q={id:"member",header:"Member",render:_n,cellClassName:"flex-1 min-w-0",sortable:!0},t[18]=Q):Q=t[18];let H;t[19]!==k||t[20]!==q||t[21]!==S||t[22]!==O?(H={id:"role",header:"Role",render:z=>z.type==="member"?s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:z.data.role==="owner",roleColorMap:k,selectableRoles:q,onRoleChange:($,oe)=>O.mutate({memberId:$,role:oe}),className:"w-36"}):s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:!1,roleColorMap:k,selectableRoles:q,onRoleChange:($,oe)=>S.mutate({invitationId:$,role:oe,email:z.data.email}),className:"w-36"}),cellClassName:"w-36 shrink-0",sortable:!0},t[19]=k,t[20]=q,t[21]=S,t[22]=O,t[23]=H):H=t[23];let Z,se;t[24]===Symbol.for("react.memo_cache_sentinel")?(Z={id:"tags",header:"Tags",render:On,cellClassName:"w-40 shrink-0"},se={id:"joined",header:"Joined",render:An,cellClassName:"w-48 shrink-0",sortable:!0},t[24]=Z,t[25]=se):(Z=t[24],se=t[25]);let J;t[26]!==r.cancel.isPending||t[27]!==E||t[28]!==O?(J={id:"actions",header:"",render:z=>z.type==="member"?s.jsx(Mt,{member:z.data,roles:E,onChangeRole:($,oe)=>O.mutate({memberId:$,role:oe}),onRemove:i,isUpdating:O.isPending}):s.jsx(Dt,{invitationId:z.data.id,onCancel:x,isCancelling:r.cancel.isPending}),cellClassName:"w-12 shrink-0"},t[26]=r.cancel.isPending,t[27]=E,t[28]=O,t[29]=J):J=t[29];let U;t[30]!==J||t[31]!==H?(U=[Q,H,Z,se,J],t[30]=J,t[31]=H,t[32]=U):U=t[32];const a=U;let y;t[33]===Symbol.for("react.memo_cache_sentinel")?(y=s.jsx(tn,{trigger:s.jsxs(ie,{variant:"outline",size:"sm",className:"h-7 px-3 rounded-lg text-sm font-medium",children:[s.jsx(Tt,{size:16}),"Manage Roles"]})}),t[33]=y):y=t[33];let F;t[34]===Symbol.for("react.memo_cache_sentinel")?(F=s.jsxs("div",{className:"flex items-center gap-2",children:[y,s.jsx(rn,{trigger:s.jsx(ie,{size:"sm",children:"Invite Member"})})]}),t[34]=F):F=t[34];const de=F,te=[...A.map(wn),...P.filter(In).map(Sn)],W=Te,ee=!!u;let ce;t[35]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>x(null),t[35]=ce):ce=t[35];let B;t[36]===Symbol.for("react.memo_cache_sentinel")?(B=s.jsxs(Ue,{children:[s.jsx(Be,{children:"Cancel Invitation"}),s.jsx(Ve,{children:"Are you sure you want to cancel this invitation? The invitee will no longer be able to join the organization with this invitation."})]}),t[36]=B):B=t[36];let G;t[37]===Symbol.for("react.memo_cache_sentinel")?(G=s.jsx($e,{children:"Keep Invitation"}),t[37]=G):G=t[37];let Y;t[38]!==r.cancel||t[39]!==u?(Y=()=>{u&&(r.cancel.mutate(u),x(null))},t[38]=r.cancel,t[39]=u,t[40]=Y):Y=t[40];let re;t[41]!==r.cancel.isPending||t[42]!==Y?(re=s.jsxs(ke,{children:[B,s.jsxs(Ge,{children:[G,s.jsx(Fe,{onClick:Y,disabled:r.cancel.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Invitation"})]})]}),t[41]=r.cancel.isPending,t[42]=Y,t[43]=re):re=t[43];let me;t[44]!==ee||t[45]!==re?(me=s.jsx(ze,{open:ee,onOpenChange:ce,children:re}),t[44]=ee,t[45]=re,t[46]=me):me=t[46];const pe=!!c;let fe;t[47]===Symbol.for("react.memo_cache_sentinel")?(fe=()=>i(null),t[47]=fe):fe=t[47];let he;t[48]===Symbol.for("react.memo_cache_sentinel")?(he=s.jsxs(Ue,{children:[s.jsx(Be,{children:"Remove Member"}),s.jsx(Ve,{children:"Are you sure you want to remove this member from the organization? This action cannot be undone."})]}),t[48]=he):he=t[48];let je;t[49]===Symbol.for("react.memo_cache_sentinel")?(je=s.jsx($e,{children:"Cancel"}),t[49]=je):je=t[49];let K;t[50]!==c||t[51]!==_?(K=()=>c&&_.mutate(c),t[50]=c,t[51]=_,t[52]=K):K=t[52];let ge;t[53]!==_.isPending||t[54]!==K?(ge=s.jsxs(ke,{children:[he,s.jsxs(Ge,{children:[je,s.jsx(Fe,{onClick:K,disabled:_.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Remove"})]})]}),t[53]=_.isPending,t[54]=K,t[55]=ge):ge=t[55];let be;t[56]!==pe||t[57]!==ge?(be=s.jsx(ze,{open:pe,onOpenChange:fe,children:ge}),t[56]=pe,t[57]=ge,t[58]=be):be=t[58];let ye;t[59]===Symbol.for("react.memo_cache_sentinel")?(ye=s.jsx(Te.Header.Left,{children:s.jsx(rs,{children:s.jsx(is,{children:s.jsx(os,{children:s.jsx(ls,{children:"Members"})})})})}),t[59]=ye):ye=t[59];let He;t[60]===Symbol.for("react.memo_cache_sentinel")?(He=[{id:"member",label:"Name"},{id:"role",label:"Role"},{id:"joined",label:"Joined"}],t[60]=He):He=t[60];let Se;t[61]!==w||t[62]!==b||t[63]!==g||t[64]!==d?(Se=s.jsxs(Te.Header,{children:[ye,s.jsxs(Te.Header.Right,{children:[s.jsx(ss,{viewMode:d,onViewModeChange:N,sortKey:g,sortDirection:b,onSort:w,sortOptions:He}),de]})]}),t[61]=w,t[62]=b,t[63]=g,t[64]=d,t[65]=Se):Se=t[65];let Ze;t[66]===Symbol.for("react.memo_cache_sentinel")?(Ze=z=>{z.key==="Escape"&&(C(""),z.target.blur())},t[66]=Ze):Ze=t[66];let Ie;t[67]!==m?(Ie=s.jsx(Ke,{value:m,onChange:C,placeholder:"Search members...",onKeyDown:Ze}),t[67]=m,t[68]=Ie):Ie=t[68];const lt=Te,at=d==="cards"?s.jsx("div",{className:"flex-1 overflow-auto p-5",children:te.length===0?s.jsx(dt,{title:"No members found",description:m?`No members match "${m}"`:"Invite members to get started."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4",children:te.map(z=>{if(z.type==="invitation")return s.jsxs(Rt,{className:"transition-colors relative opacity-75",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Dt,{invitationId:z.data.id,onCancel:x,isCancelling:r.cancel.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ae,{fallback:rt(z.data.email),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:z.data.email}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx(Ee,{variant:"outline",className:"w-fit text-amber-600 border-amber-400",children:"Pending"})}),s.jsx(et,{role:z.data.role,memberId:z.data.id,isOwner:!1,roleColorMap:k,selectableRoles:q,onRoleChange:(oe,xe)=>S.mutate({invitationId:oe,role:xe,email:z.data.email}),className:"w-fit"})]})]})]},`inv-${z.data.id}`);const $=z.data;return s.jsxs(Rt,{className:"transition-colors relative",children:[s.jsx("div",{className:"absolute top-4 right-4 z-10",children:s.jsx(Mt,{member:$,roles:E,onChangeRole:(oe,xe)=>O.mutate({memberId:oe,role:xe}),onRemove:i,isUpdating:O.isPending})}),s.jsxs("div",{className:"flex flex-col gap-4 p-6",children:[s.jsx(Ae,{url:$.user?.image??void 0,fallback:rt($.user?.name),shape:"circle",size:"lg",className:"shrink-0"}),s.jsxs("div",{className:"flex flex-col gap-2",children:[s.jsx("h3",{className:"text-base font-medium text-foreground truncate",children:$.user?.name||"Unknown"}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:$.user?.email}),s.jsx(et,{role:$.role,memberId:$.id,isOwner:$.role==="owner",roleColorMap:k,selectableRoles:q,onRoleChange:(oe,xe)=>O.mutate({memberId:oe,role:xe}),className:"w-fit"}),s.jsx(Yt,{memberId:$.id,maxDisplay:3})]})]})]},$.id)})})}):s.jsx(ns,{columns:a,data:te,isLoading:!1,sortKey:g,sortDirection:b,onSort:w,emptyState:m?s.jsx(dt,{title:"No members found",description:`No members match "${m}"`}):s.jsx(dt,{title:"No members found",description:"Invite members to get started."})});let we;t[69]!==lt.Content||t[70]!==at?(we=s.jsx(lt.Content,{children:at}),t[69]=lt.Content,t[70]=at,t[71]=we):we=t[71];let Ye;return t[72]!==W||t[73]!==me||t[74]!==be||t[75]!==Se||t[76]!==Ie||t[77]!==we?(Ye=s.jsxs(W,{children:[me,be,Se,Ie,we]}),t[72]=W,t[73]=me,t[74]=be,t[75]=Se,t[76]=Ie,t[77]=we,t[78]=Ye):Ye=t[78],Ye}function Sn(t){return{type:"invitation",data:t}}function In(t){return t.status==="pending"}function wn(t){return{type:"member",data:t}}function An(t){return t.type==="member"?s.jsx("span",{className:"text-sm text-foreground",children:t.data.createdAt?jn(t.data.createdAt):"N/A"}):s.jsx(Ee,{variant:"outline",children:"Pending"})}function On(t){return t.type==="member"?s.jsx(Yt,{memberId:t.data.id,maxDisplay:2}):s.jsx("span",{className:"text-xs text-muted-foreground",children:"-"})}function _n(t){return t.type==="member"?s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{url:t.data.user?.image??void 0,fallback:rt(t.data.user?.name),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.user?.name||"Unknown"}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:t.data.user?.email})]})]}):s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(Ae,{fallback:rt(t.data.email),shape:"circle",size:"sm"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-foreground truncate",children:t.data.email}),s.jsx("div",{className:"text-sm text-muted-foreground truncate",children:"Invitation sent"})]})]})}function Rn(t){return t.role!=="owner"}function Ln(t){ne.error(t instanceof Error?t.message:"Failed to update invitation role")}async function Pn(t){const{invitationId:e,role:n,email:r}=t,l=await ae.organization.cancelInvitation({invitationId:e});if(l?.error)throw new Error(l.error.message);const o=await ae.organization.inviteMember({email:r,role:n});if(o?.error)throw new Error(o.error.message)}function Mn(t){ne.error(t instanceof Error?t.message:"Failed to update role")}async function Dn(t){const{memberId:e,role:n}=t,r=await ae.organization.updateMemberRole({memberId:e,role:[n]});if(r?.error)throw new Error(r.error.message)}function zn(t){ne.error(t instanceof Error?t.message:"Failed to remove member")}async function kn(t){const e=await ae.organization.removeMember({memberIdOrEmail:t});if(e?.error)throw new Error(e.error.message)}function Un(t){return t==="asc"?"desc":t==="desc"?null:"asc"}function Ar(){const t=le.c(2);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=s.jsx(Te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("div",{className:"text-sm text-muted-foreground",children:"Failed to load members"})})}),t[0]=e):e=t[0];let n;return t[1]===Symbol.for("react.memo_cache_sentinel")?(n=s.jsx(Ns,{fallback:e,children:s.jsx(D.Suspense,{fallback:s.jsx(Te,{children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx(st,{size:32,className:"animate-spin text-muted-foreground"})})}),children:s.jsx(yn,{})})}),t[1]=n):n=t[1],n}export{Ar as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{I as u}from"./infiniteQueryObserver-BYaSWja-.js";import{a1 as i}from"./index-ByQ-WW1t.js";function t(e,r){return i(e,u,r)}export{t as u};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a1 as u,a4 as s}from"./index-ByQ-WW1t.js";function o(e,r){return u(e,s,r)}export{o as u};
|