react-semaphor 0.1.211 → 0.1.212
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/chunks/{dashboard-controls-CnDq9Uh_.js → dashboard-controls-BcpwRqRu.js} +13 -8
- package/dist/chunks/{dashboard-controls-7KpXzAWL.js → dashboard-controls-DG0FT__o.js} +373 -359
- package/dist/chunks/{dashboard-json-dqey5VK0.js → dashboard-json-C1b81ShY.js} +1 -1
- package/dist/chunks/{dashboard-json-stWvjp2O.js → dashboard-json-F8qwUIWM.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DuxhidK1.js → dashboard-summary-settings-dialog-CsjLFOn-.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DPEe6XBC.js → dashboard-summary-settings-dialog-yytNDqsJ.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-D_XPr8f8.js → edit-dashboard-visual-B-qAacmt.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CQAk_UsI.js → edit-dashboard-visual-C-Y0fhBE.js} +2 -2
- package/dist/chunks/{editor-action-buttons-D34_GSZu.js → editor-action-buttons-BddCK22U.js} +2 -2
- package/dist/chunks/{editor-action-buttons-CH7W6KdH.js → editor-action-buttons-Dr9s7Z0u.js} +1 -1
- package/dist/chunks/{index-BfiIPyeS.js → index-irqsC0zR.js} +1 -1
- package/dist/chunks/{index-BDS2sWhv.js → index-tdtX3LgC.js} +4 -4
- package/dist/chunks/{notification-bell-hijGST9g.js → notification-bell-CRzJdHm5.js} +2 -2
- package/dist/chunks/{notification-bell-Cu3qDd9V.js → notification-bell-Ci1RHooZ.js} +137 -135
- package/dist/chunks/{resource-management-panel-BvHqslqC.js → resource-management-panel-CaKSsCiq.js} +3 -3
- package/dist/chunks/{resource-management-panel-gK3a6OEj.js → resource-management-panel-cwMyqyn1.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-a5FH9Y0k.js → use-role-aware-display-preferences-CImfZXy5.js} +1 -1
- package/dist/chunks/{use-role-aware-display-preferences-BlR29aKQ.js → use-role-aware-display-preferences-D5eZpiQS.js} +1 -1
- package/dist/chunks/{use-visual-utils-ptPsQ3nC.js → use-visual-utils-0xqPjTL6.js} +1 -1
- package/dist/chunks/{use-visual-utils-B11AA2fd.js → use-visual-utils-BAVRApHw.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/main.d.ts +3 -1
- package/package.json +1 -1
|
@@ -1,29 +1,34 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-irqsC0zR.js"),f=require("react");require("react-dom");const _=require("./notification-bell-CRzJdHm5.js"),bs=require("./use-role-aware-display-preferences-D5eZpiQS.js"),ys=require("./date-formatter-Sz6QDaM8.js"),Fe=require("./dashboard-summary-settings-dialog-CsjLFOn-.js"),ae=require("./normalize-dashboard-for-dirty-check-D9x96J2F.js"),Re=require("./editor-action-buttons-Dr9s7Z0u.js");function Ss(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const I=Ss(f);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Ds=s.createLucideIcon("
|
|
6
|
+
*/const Ds=s.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);/**
|
|
7
7
|
* @license lucide-react v0.453.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ns=s.createLucideIcon("
|
|
11
|
+
*/const Ns=s.createLucideIcon("Glasses",[["circle",{cx:"6",cy:"15",r:"4",key:"vux9w4"}],["circle",{cx:"18",cy:"15",r:"4",key:"18o8ve"}],["path",{d:"M14 15a2 2 0 0 0-2-2 2 2 0 0 0-2 2",key:"1ag4bs"}],["path",{d:"M2.5 13 5 7c.7-1.3 1.4-2 3-2",key:"1hm1gs"}],["path",{d:"M21.5 13 19 7c-.7-1.3-1.5-2-3-2",key:"1r31ai"}]]);/**
|
|
12
12
|
* @license lucide-react v0.453.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const ws=s.createLucideIcon("
|
|
16
|
+
*/const ws=s.createLucideIcon("Menu",[["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}],["line",{x1:"4",x2:"20",y1:"6",y2:"6",key:"1owob3"}],["line",{x1:"4",x2:"20",y1:"18",y2:"18",key:"yk5zj1"}]]);/**
|
|
17
17
|
* @license lucide-react v0.453.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Cs=s.createLucideIcon("
|
|
21
|
+
*/const Cs=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
22
22
|
* @license lucide-react v0.453.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Ls=s.createLucideIcon("
|
|
26
|
+
*/const Ls=s.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
|
|
27
|
+
* @license lucide-react v0.453.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const Ms=s.createLucideIcon("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);var ve={exports:{}},xe={};/**
|
|
27
32
|
* @license React
|
|
28
33
|
* use-sync-external-store-shim.production.js
|
|
29
34
|
*
|
|
@@ -31,7 +36,7 @@
|
|
|
31
36
|
*
|
|
32
37
|
* This source code is licensed under the MIT license found in the
|
|
33
38
|
* LICENSE file in the root directory of this source tree.
|
|
34
|
-
*/var Ue;function As(){if(Ue)return
|
|
39
|
+
*/var Ue;function As(){if(Ue)return xe;Ue=1;var t=f;function n(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var a=typeof Object.is=="function"?Object.is:n,r=t.useState,l=t.useEffect,c=t.useLayoutEffect,u=t.useDebugValue;function p(d,m){var h=m(),j=r({inst:{value:h,getSnapshot:m}}),b=j[0].inst,y=j[1];return c(function(){b.value=h,b.getSnapshot=m,x(b)&&y({inst:b})},[d,h,m]),l(function(){return x(b)&&y({inst:b}),d(function(){x(b)&&y({inst:b})})},[d]),u(h),h}function x(d){var m=d.getSnapshot;d=d.value;try{var h=m();return!a(d,h)}catch{return!0}}function v(d,m){return m()}var i=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?v:p;return xe.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:i,xe}var fe={};/**
|
|
35
40
|
* @license React
|
|
36
41
|
* use-sync-external-store-shim.development.js
|
|
37
42
|
*
|
|
@@ -39,4 +44,4 @@
|
|
|
39
44
|
*
|
|
40
45
|
* This source code is licensed under the MIT license found in the
|
|
41
46
|
* LICENSE file in the root directory of this source tree.
|
|
42
|
-
*/var Fe;function Ms(){return Fe||(Fe=1,process.env.NODE_ENV!=="production"&&function(){function t(h,j){return h===j&&(h!==0||1/h===1/j)||h!==h&&j!==j}function n(h,j){i||l.startTransition===void 0||(i=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var b=j();if(!d){var S=j();c(b,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}S=u({inst:{value:b,getSnapshot:j}});var w=S[0].inst,A=S[1];return x(function(){w.value=b,w.getSnapshot=j,a(w)&&A({inst:w})},[h,b,j]),p(function(){return a(w)&&A({inst:w}),h(function(){a(w)&&A({inst:w})})},[h]),v(b),b}function a(h){var j=h.getSnapshot;h=h.value;try{var b=j();return!c(h,b)}catch{return!0}}function r(h,j){return j()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=f,c=typeof Object.is=="function"?Object.is:t,u=l.useState,p=l.useEffect,x=l.useLayoutEffect,v=l.useDebugValue,i=!1,d=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;xe.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),xe}process.env.NODE_ENV==="production"?fe.exports=As():fe.exports=Ms();var Es=fe.exports;function Is(){const{setTheme:t}=s.useTheme(),n=s.useDashboardStore(a=>a.actions.setDashboardTheme);return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"h-7 p-2",variant:"ghost",size:"sm",children:[e.jsx(Ls,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(ws,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>{t("light"),n("light")},children:"Light"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("dark"),n("dark")},children:"Dark"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("system"),n("system")},children:"System"})]})]})}async function ks(t,n,a,r,l){if(!l)return null;const c=JSON.stringify(a),u=`${t}/v1/lens`;return await s.postRequest(u,l,{name:n,template:c,filterValues:r,operation:"create"})}async function ve(t,n,a){if(!a)return null;const{id:r,template:l,filterValues:c,isDefault:u,shared:p}=n,x=`${t}/v1/lens`;return await s.postRequest(x,a,{lensId:r,template:l,filterValues:c,isDefault:u,shared:p,operation:"update"})}async function Ts(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:n})}function Os(){const[t,n]=f.useState(""),[a,r]=f.useState(!1),l=s.useDashboardStore(S=>S.lenses),{setLenses:c,setSelectedLensId:u}=s.useDashboardActions(),[p,x]=f.useState(!1),[v,i]=f.useState(!1),d=s.useDashboardStore(S=>S.dashboard),m=s.useDashboardStore(S=>S.filterValues),{authToken:h,tokenProps:j}=s.useSemaphorContext();async function b(){x(!0);const S=await ks(j.apiServiceUrl,t,d,m,h==null?void 0:h.accessToken);S&&(c([...l||[],S]),u(S.id),i(!1)),x(!1)}return e.jsxs(s.Dialog,{open:v,onOpenChange:i,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:S=>{n(S.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:b,disabled:p,children:p?"Creating...":"Add"})})]})]})}function _s(){const[t,n]=f.useState(!1),a=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:l,setSelectedLensId:c}=s.useDashboardActions(),{authToken:u,tokenProps:p}=s.useSemaphorContext();async function x(d){c(d)}async function v(d){if(await Ts(p.apiServiceUrl,d,u==null?void 0:u.accessToken)){const h=a==null?void 0:a.filter(j=>j.id!==d);l(h||[]),c("original")}}async function i(d){const m=a==null?void 0:a.map(b=>b.id===d.id?{...b,isDefault:!d.isDefault}:{...b,isDefault:!1});l(m||[]);const h={...d,isDefault:!d.isDefault};await ve(p.apiServiceUrl,h,u==null?void 0:u.accessToken);const j=a==null?void 0:a.find(b=>b.isDefault);if(j&&j.id!==d.id){const b={...j,isDefault:!1};await ve(p.apiServiceUrl,b,u==null?void 0:u.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(Ds,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:x,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(d=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:d.id,children:[e.jsx("p",{children:d.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:m=>{m.preventDefault(),i(d)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!d.isDefault,"text-green-500":d.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:m=>{m.preventDefault(),v(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})]})}const Rs=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,n,a)},Us=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`,l=await fetch(r,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}});if(!l.ok){const c=await l.text();throw new Error(c||"Failed to delete group")}},Fs=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,n,r)},Ps=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`,c=await fetch(l,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(r)});if(!c.ok){const u=await c.text();throw new Error(u||"Failed to remove group members")}};function Gs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Rs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:r.message})}})}function Bs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Us(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:r.message})}})}function qs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>Fs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:r.message})}})}function Hs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>Ps(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:r.message})}})}function zs({onSuccess:t,tenantId:n,isTenantUser:a}){const[r,l]=f.useState(""),[c,u]=f.useState(""),[p,x]=f.useState({}),v=Gs(),i=()=>{const m={};return r.trim()?r.length<3?m.name="Group name must be at least 3 characters":r.length>50&&(m.name="Group name must be less than 50 characters"):m.name="Group name is required",c&&c.length>200&&(m.description="Description must be less than 200 characters"),x(m),Object.keys(m).length===0},d=async m=>{if(m.preventDefault(),!i())return;const h={name:r.trim(),description:c.trim()||void 0,type:a?"TENANT_GROUP":"ORG_GROUP",...a&&n?{tenantId:n}:{}};try{await v.mutateAsync(h),l(""),u(""),x({}),t()}catch(j){console.error("Failed to create group:",j)}};return e.jsxs("form",{onSubmit:d,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-name",children:["Group Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:r,onChange:m=>{l(m.target.value),p.name&&x(h=>({...h,name:""}))},className:p.name?"border-destructive":"",disabled:v.isPending}),p.name&&e.jsx("p",{className:"text-sm text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-description",children:["Description",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group...",value:c,onChange:m=>{u(m.target.value),p.description&&x(h=>({...h,description:""}))},className:p.description?"border-destructive":"",disabled:v.isPending,rows:3}),p.description&&e.jsx("p",{className:"text-sm text-destructive",children:p.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/200 characters"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(s.CircleAlert,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This group will be accessible to users in your workspace. You can add members after creating the group."})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(s.Button,{type:"button",variant:"outline",onClick:()=>{l(""),u(""),x({})},disabled:v.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:v.isPending||!r.trim(),children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Create Group"]})})]})]})}function Vs(){return Es.useSyncExternalStore($s,()=>!0,()=>!1)}function $s(){return()=>{}}var je="Avatar",[Qs]=s.createContextScope(je),[Ks,Ge]=Qs(je),Be=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[l,c]=E.useState("idle");return e.jsx(Ks,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(s.Primitive.span,{...r,ref:n})})});Be.displayName=je;var qe="AvatarImage",He=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...c}=t,u=Ge(qe,a),p=Ws(r,c),x=s.useCallbackRef(v=>{l(v),u.onImageLoadingStatusChange(v)});return s.useLayoutEffect2(()=>{p!=="idle"&&x(p)},[p,x]),p==="loaded"?e.jsx(s.Primitive.img,{...c,ref:n,src:r}):null});He.displayName=qe;var ze="AvatarFallback",Ve=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,c=Ge(ze,a),[u,p]=E.useState(r===void 0);return E.useEffect(()=>{if(r!==void 0){const x=window.setTimeout(()=>p(!0),r);return()=>window.clearTimeout(x)}},[r]),u&&c.imageLoadingStatus!=="loaded"?e.jsx(s.Primitive.span,{...l,ref:n}):null});Ve.displayName=ze;function Pe(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ws(t,{referrerPolicy:n,crossOrigin:a}){const r=Vs(),l=E.useRef(null),c=r?(l.current||(l.current=new window.Image),l.current):null,[u,p]=E.useState(()=>Pe(c,t));return s.useLayoutEffect2(()=>{p(Pe(c,t))},[c,t]),s.useLayoutEffect2(()=>{const x=d=>()=>{p(d)};if(!c)return;const v=x("loaded"),i=x("error");return c.addEventListener("load",v),c.addEventListener("error",i),n&&(c.referrerPolicy=n),typeof a=="string"&&(c.crossOrigin=a),()=>{c.removeEventListener("load",v),c.removeEventListener("error",i)}},[c,a,n]),u}var $e=Be,Qe=He,Ke=Ve;const be=E.forwardRef(({className:t,...n},a)=>e.jsx($e,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));be.displayName=$e.displayName;const Js=E.forwardRef(({className:t,...n},a)=>e.jsx(Qe,{ref:a,className:s.cn("aspect-square h-full w-full",t),...n}));Js.displayName=Qe.displayName;const Se=E.forwardRef(({className:t,...n},a)=>e.jsx(Ke,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));Se.displayName=Ke.displayName;function Xs({open:t,onOpenChange:n,group:a,onUpdate:r}){const[l,c]=f.useState("members"),[u,p]=f.useState(""),[x,v]=f.useState([]),[i,d]=f.useState([]),{data:m,isLoading:h,refetch:j}=s.useGroupMembers(a.id),b=a.type==="TENANT_GROUP"?"tenant":"organization",{users:S,isLoading:w}=s.useUnifiedUsers({type:b,tenantId:a.tenantId||void 0,active:!0,limit:100}),A=qs(),I=Hs(),C=(m==null?void 0:m.members)||[],R=f.useMemo(()=>new Set(C.map(g=>g.userId)),[C]),T=f.useMemo(()=>S.filter(g=>!R.has(g.id)),[S,R]),U=f.useMemo(()=>{if(!u)return T;const g=u.toLowerCase();return T.filter(N=>{var M,O;return((M=N.name)==null?void 0:M.toLowerCase().includes(g))||((O=N.email)==null?void 0:O.toLowerCase().includes(g))})},[T,u]),y=f.useMemo(()=>{if(!u)return C;const g=u.toLowerCase();return C.filter(N=>{var M,O,J,D;return((O=(M=N.user)==null?void 0:M.name)==null?void 0:O.toLowerCase().includes(g))||((D=(J=N.user)==null?void 0:J.email)==null?void 0:D.toLowerCase().includes(g))})},[C,u]),F=async()=>{if(x.length!==0)try{await A.mutateAsync({groupId:a.id,data:{userIds:x,userType:b==="tenant"?"tenant":"org"}}),v([]),c("members"),j(),r==null||r()}catch(g){console.error("Failed to add members:",g)}},P=async()=>{if(i.length!==0)try{await I.mutateAsync({groupId:a.id,data:{userIds:i}}),d([]),j(),r==null||r()}catch(g){console.error("Failed to remove members:",g)}},G=g=>{v(N=>N.includes(g)?N.filter(M=>M!==g):[...N,g])},B=g=>{d(N=>N.includes(g)?N.filter(M=>M!==g):[...N,g])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:a.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[C.length," ",C.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",a.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:g=>{c(g),p(""),d([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search members...",value:u,onChange:g=>p(g.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:i.length>0?"h-[300px]":"h-[350px]",children:h?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>e.jsx(s.Skeleton,{className:"h-16 w-full"},g))}):y.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:u?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:u?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:y.map(g=>e.jsx(Ys,{member:g,selected:i.includes(g.userId),onToggle:()=>B(g.userId)},g.id))})}),i.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i.length," member",i.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:P,disabled:I.isPending,children:I.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(s.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search users to add...",value:u,onChange:g=>p(g.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:w?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>e.jsx(s.Skeleton,{className:"h-16 w-full"},g))}):U.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:u?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:U.map(g=>e.jsx(Zs,{user:g,selected:x.includes(g.id),onToggle:()=>G(g.id)},g.id))})}),x.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.length," user",x.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:F,disabled:A.isPending,children:A.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Ys({member:t,selected:n,onToggle:a}){var l,c,u,p;const r=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(x=>x[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(be,{className:"h-8 w-8",children:e.jsx(Se,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((u=t.user)==null?void 0:u.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(p=t.user)==null?void 0:p.email})]})]})}function Zs({user:t,selected:n,onToggle:a}){var l;const r=((l=t.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(be,{className:"h-8 w-8",children:e.jsx(Se,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function et({open:t,onOpenChange:n}){const[a,r]=f.useState("groups"),[l,c]=f.useState(""),[u,p]=f.useState(null),[x,v]=f.useState(!1),[i,d]=f.useState(null),{tokenProps:m}=s.useSemaphorContext(),{currentUser:h}=s.useCurrentUserInfo(),j=Bs(),b=(h==null?void 0:h.type)==="tenant",S=m==null?void 0:m.tenantId,{groups:w,isLoading:A,refetch:I}=s.useGroups({type:b?"TENANT_GROUP":"all",tenantId:b?S:void 0,includeMembers:!1}),C=w.filter(y=>{var F;return y.name.toLowerCase().includes(l.toLowerCase())||((F=y.description)==null?void 0:F.toLowerCase().includes(l.toLowerCase()))}),R=async()=>{if(i)try{await j.mutateAsync(i.id),d(null),I()}catch(y){console.error("Failed to delete group:",y)}},T=y=>{p(y),v(!0)},U=()=>{r("groups"),I()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-4xl max-h-[80vh]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-5 w-5"}),"Group Management"]}),e.jsx(s.DialogDescription,{children:"Manage your groups, create new groups, and control group membership"})]}),e.jsxs(s.Tabs,{value:a,onValueChange:r,className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsxs(s.TabsTrigger,{value:"groups",className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-4 w-4"}),"Groups"]}),e.jsxs(s.TabsTrigger,{value:"create",className:"flex items-center gap-2",children:[e.jsx(s.Plus,{className:"h-4 w-4"}),"Create Group"]})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search groups...",value:l,onChange:y=>c(y.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:A?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(y=>e.jsx(s.Skeleton,{className:"h-24 w-full"},y))}):C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No groups found"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:C.map(y=>e.jsx(st,{group:y,onManageMembers:()=>T(y),onDelete:()=>d(y),currentUserId:h==null?void 0:h.id},y.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(zs,{onSuccess:U,tenantId:S,isTenantUser:b})})]})]})}),u&&e.jsx(Xs,{open:x,onOpenChange:v,group:u,onUpdate:()=>I()}),e.jsx(s.AlertDialog,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Group"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',i==null?void 0:i.name,'"? This action cannot be undone and will remove all members from the group.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:R,disabled:j.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function st({group:t,onManageMembers:n,onDelete:a,currentUserId:r}){const l=t.createdBy===r;return e.jsx("div",{className:"rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",Ss.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:n,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:a,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function tt(){var Ie,ke,Te,Oe;_.useExportRecovery(),_.useExportPolling();const{authToken:t,tokenProps:n,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=bs.useRoleAwareDisplayPreferences(),c=s.useHasDashboardId(),{isLoading:u}=s.useDashboardQuery();s.useDashboardStore(o=>o.theme);const p=s.useDashboardStore(o=>o.lenses),x=s.useDashboardStore(o=>o.selectedLensId),v=p==null?void 0:p.find(o=>o.id===x),i=s.useDashboardStore(o=>o.dashboard);s.useDashboardStore(o=>o.selectedSheetId);const d=s.useDashboardStore(o=>o.isDashboardEditing),{setDashboardTitle:m}=s.useDashboardStore(o=>o.actions),[h,j]=f.useState(!1),[b,S]=f.useState(!1),[w,A]=f.useState(!1),[I,C]=f.useState(!1),[R,T]=f.useState(!1),[U,y]=f.useState(!1),[F,P]=f.useState(!1),[G,B]=f.useState(null),[g,N]=f.useState(!1),M=s.useDashboardStore(o=>o.isDashboardPanelOpen),O=s.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),J=s.useDashboardStore(o=>o.filterValues),D=s.useDashboardStore(o=>o.isVisualEditing);s.useEditorStore(o=>o.card);const H=s.useManagementStore(o=>o.selectedDashboard),X=s.useManagementStore(o=>o.initialDashboard);s.useManagementStore(o=>o.selectedVisual),s.useDashboardStore(o=>o.selectedFrameId),s.useEditorStore(o=>o.frame);const Y=H?(ke=H==null?void 0:H.permissions)==null?void 0:ke.canEdit:(Ie=X==null?void 0:X.permissions)==null?void 0:Ie.canEdit,We=s.useDashboardStore(o=>o.showFilters),Je=s.useAssistantLayoutStore(o=>o.setPanelOpen),Xe=s.useDashboardStore(o=>o.showDashboardJSON),re=s.useDashboardStore(o=>o.onSaveFunction),Ye=s.useDashboardStore(o=>o.actions.setShowFilters),{setIsDashboardEditing:ye,setShowDashboardJSON:De}=s.useDashboardStore(o=>o.actions),{setInitialDashboard:Ne,clearSelectedDashboard:ne}=s.useManagementStore(o=>o.actions),{resources:Z}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:oe}=s.useUserPreferences(),Ze=((Te=oe==null?void 0:oe.preference)==null?void 0:Te.defaultDashboardId)||null,{mutate:es,isPending:ss}=s.useDefaultDashboardMutation(),{currentUser:ts}=s.useCurrentUserInfo(),as=s.canUserManageGroups(ts),q=H||X,we=q?{id:q.id,title:(i==null?void 0:i.title)||q.title||"Dashboard"}:null,{handleAddNewFrame:rs}=s.useAddNewFrame(),[ie,le]=f.useState(!1),[ns,z]=f.useState(!1),[V,ee]=f.useState("close"),$=s.useUpdateResource(s.ResourceType.DASHBOARD),[k,ce]=f.useState(null),os=async(o,L)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:o,previousTitle:L}),$.mutate({resourceId:i.id,data:{title:o}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:W=>{console.error("Failed to update dashboard title:",W),s.ue.error("Failed to update dashboard title"),m(L)}})};f.useEffect(()=>{if(Z&&Z.length>0){const o=i==null?void 0:i.id;if(o){const L=Z.find(W=>W.id===o);L&&Ne(L)}}},[Z,i==null?void 0:i.id,Ne]);const se=n.orgUserId||n.tenantId,Ce=d&&!D&&se&&Y,{setDashboard:de}=s.useDashboardStore(o=>o.actions),is=()=>{ye(!0)},ue=()=>{ye(!1),De(!1),ce(null)};_.usePristineSnapshotInitializer(d,i,k,o=>ce(o));const{isDirty:Le,isDirtyPending:ls,resetDirty:te}=ae.useDebouncedDirtyCheck(i,k,300,1e3,ae.serializeDashboardForDirtyCheck),Ae=f.useCallback(()=>k?ae.serializeDashboardForDirtyCheck(i)!==ae.serializeDashboardForDirtyCheck(k):!1,[i,k]),me=Le||ls,Q=ie||$.isPending,cs=()=>{Ae()?(ee("close"),z(!0)):(ue(),te())},ds=async()=>{await he({closeAfterSave:!0,navigateHomeAfterSave:V==="home"})},us=()=>{k&&de(k),ue(),V==="home"&&ne(),ee("close"),z(!1),te()},ms=()=>{k&&(de(k),te())},hs=()=>{if(d&&Ae()){ee("home"),z(!0);return}ne()};async function he(o){const L=(o==null?void 0:o.closeAfterSave)??g,W=(o==null?void 0:o.navigateHomeAfterSave)??!1;N(L),L&&z(!1);const vs=s.cloneDeep(i);P(!0),B(null),le(!0);const js={template:i};$.mutate({resourceId:i.id,data:js},{onSuccess:()=>{le(!1),s.ue.success("Dashboard saved!"),ce(vs),P(!1),N(!1),L&&(ue(),te(),W&&ne()),ee("close")},onError:()=>{le(!1),B("Failed to save dashboard. Please try again."),s.ue.error("Failed to save dashboard")}})}async function ps(){if(j(!0),!x||!v)return;const o=JSON.stringify(i),L={...v,template:o,filterValues:J};await ve(n.apiServiceUrl,L,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),re==null||re(i),j(!1)}const Me=(v==null?void 0:v.name)||i.title;$.isPending&&console.log("Title during update:",{title:Me,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:v==null?void 0:v.name});const Ee=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,gs=!!Ee&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),xs=c,K=(i==null?void 0:i.id)||null,pe=!!K&&Ze===K,fs=()=>{K&&es({dashboardId:pe?null:K})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[Ee&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{O(!M)},className:"h-7 p-2",children:e.jsx(Ns,{className:"h-4 w-4"})}),xs&&!D&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:hs,className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!D&&c&&(u?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.LoaderCircle,{className:"h-3 w-3 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:Me||"Untitled Dashboard",onSave:o=>{console.log("EditableText onSave called:",{newTitle:o,canEditDashboard:Y,dashboardId:i==null?void 0:i.id});const L=(i==null?void 0:i.title)||"";m(o),os(o,L)},isEditable:Y&&!v,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:$.isPending}),gs&&K&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"icon",onClick:fs,disabled:ss||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"h-7 w-7",children:e.jsx(s.Star,{className:s.cn("h-4 w-4 transition-colors",pe?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:pe?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[D&&e.jsxs(e.Fragment,{children:[e.jsx(_.AdvancedModeToggle,{className:"mr-2"}),e.jsx(_.VisualEditingControls,{className:"h-7"})]}),r&&!D&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Copy Token",onClick:()=>{var o;t!=null&&t.accessToken&&((o=navigator==null?void 0:navigator.clipboard)!=null&&o.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},className:"h-7 p-2",children:e.jsx(s.Copy,{className:"h-4 w-4"})}),e.jsx(s.IconButton,{tooltip:"Invalidate Token",onClick:()=>s.invalidateToken(n.apiServiceUrl),className:"h-7 p-2",children:e.jsx(Cs,{className:"h-4 w-4"})})]}),!D&&c&&e.jsx(s.DownloadPdf,{}),!D&&c&&e.jsx(_.NotificationBell,{}),!D&&c&&((Oe=q==null?void 0:q.permissions)==null?void 0:Oe.canShare)&&e.jsx(s.IconButton,{tooltip:"Share Dashboard",onClick:()=>S(!0),className:"h-7 p-2",children:e.jsx(s.Share2,{className:"h-4 w-4"})}),!We&&!D&&d&&l.canUseFilters&&c&&e.jsx(s.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>{Je("dashboard",!1),Ye(!0)},size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),d&&!D&&se&&r&&c&&e.jsx(Os,{}),!D&&se&&r&&c&&e.jsx(_s,{}),d&&!D&&se&&v&&r&&c&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:h,onClick:ps,size:"sm",children:[e.jsx(Re.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!d,onClick:()=>rs(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!D&&!d&&Y&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:is,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),Ce&&c&&Le&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:ms,size:"sm",disabled:Q,children:[e.jsx(s.Undo2,{className:"mr-2 h-4 w-4"}),"Undo"]}),Ce&&c&&e.jsxs("div",{className:"relative inline-flex",children:[e.jsxs(s.Button,{className:s.cn("h-7 p-2",!me&&"opacity-60"),disabled:Q||!me,onClick:()=>he(),size:"sm",children:[Q?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Re.Save,{className:"mr-2 h-4 w-4"}),Q?"Saving...":"Save"]}),me&&!Q&&e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-orange-500 ring-2 ring-background"})]}),!D&&d&&r&&c&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>De(!Xe),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!D&&r&&e.jsx(Is,{}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:cs,children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),!D&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"h-7 p-2",children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(s.Clock,{className:"mr-2 h-4 w-4"}),"Schedule Dashboard"]}),as&&e.jsxs(s.DropdownMenuItem,{onClick:()=>A(!0),children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Manage Groups"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>T(!0),children:[e.jsx(s.Calendar,{className:"mr-2 h-4 w-4"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>y(!0),children:[e.jsx(s.FileText,{className:"mr-2 h-4 w-4"}),"Summary Settings"]})]})]}),b&&we&&e.jsx(s.ShareDialog,{resource:we,resourceType:s.ResourceType.DASHBOARD,onClose:()=>S(!1)}),e.jsx(et,{open:w,onOpenChange:A}),(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:I,onOpenChange:C,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(_e.CalendarPreferencesDialog,{open:R,onOpenChange:T}),e.jsx(_e.DashboardSummarySettingsDialog,{open:U,onOpenChange:y,dashboard:i,disabled:!d,onApply:o=>de({...i,summary:o})}),e.jsx(s.AlertDialog,{open:F,onOpenChange:o=>{!o&&ie&&!G||(P(o),o||(B(null),N(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:G?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:G?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:G?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{P(!1),B(null),N(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>he({closeAfterSave:g,navigateHomeAfterSave:V==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(_.UnsavedChangesAlert,{open:ns,onOpenChange:o=>{z(o)},onSave:ds,onDiscard:us,isSaving:ie,saveLabel:V==="home"?"Save & Return to Hub":"Save & Close",discardLabel:V==="home"?"Discard & Return to Hub":"Discard"})]})]})}exports.default=tt;
|
|
47
|
+
*/var Pe;function Is(){return Pe||(Pe=1,process.env.NODE_ENV!=="production"&&function(){function t(h,j){return h===j&&(h!==0||1/h===1/j)||h!==h&&j!==j}function n(h,j){i||l.startTransition===void 0||(i=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var b=j();if(!d){var y=j();c(b,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}y=u({inst:{value:b,getSnapshot:j}});var w=y[0].inst,M=y[1];return x(function(){w.value=b,w.getSnapshot=j,a(w)&&M({inst:w})},[h,b,j]),p(function(){return a(w)&&M({inst:w}),h(function(){a(w)&&M({inst:w})})},[h]),v(b),b}function a(h){var j=h.getSnapshot;h=h.value;try{var b=j();return!c(h,b)}catch{return!0}}function r(h,j){return j()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=f,c=typeof Object.is=="function"?Object.is:t,u=l.useState,p=l.useEffect,x=l.useLayoutEffect,v=l.useDebugValue,i=!1,d=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;fe.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),fe}process.env.NODE_ENV==="production"?ve.exports=As():ve.exports=Is();var ks=ve.exports;function Es(){const{setTheme:t}=s.useTheme(),n=s.useDashboardStore(a=>a.actions.setDashboardTheme);return e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs(s.Button,{className:"h-7 p-2",variant:"ghost",size:"sm",children:[e.jsx(Ms,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(Cs,{strokeWidth:1.5,className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),e.jsx("span",{className:"sr-only",children:"Toggle theme"})]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>{t("light"),n("light")},children:"Light"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("dark"),n("dark")},children:"Dark"}),e.jsx(s.DropdownMenuItem,{onClick:()=>{t("system"),n("system")},children:"System"})]})]})}async function Ts(t,n,a,r,l){if(!l)return null;const c=JSON.stringify(a),u=`${t}/v1/lens`;return await s.postRequest(u,l,{name:n,template:c,filterValues:r,operation:"create"})}async function je(t,n,a){if(!a)return null;const{id:r,template:l,filterValues:c,isDefault:u,shared:p}=n,x=`${t}/v1/lens`;return await s.postRequest(x,a,{lensId:r,template:l,filterValues:c,isDefault:u,shared:p,operation:"update"})}async function Os(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:n})}function _s(){const[t,n]=f.useState(""),[a,r]=f.useState(!1),l=s.useDashboardStore(y=>y.lenses),{setLenses:c,setSelectedLensId:u}=s.useDashboardActions(),[p,x]=f.useState(!1),[v,i]=f.useState(!1),d=s.useDashboardStore(y=>y.dashboard),m=s.useDashboardStore(y=>y.filterValues),{authToken:h,tokenProps:j}=s.useSemaphorContext();async function b(){x(!0);const y=await Ts(j.apiServiceUrl,t,d,m,h==null?void 0:h.accessToken);y&&(c([...l||[],y]),u(y.id),i(!1)),x(!1)}return e.jsxs(s.Dialog,{open:v,onOpenChange:i,children:[e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",className:"h-7 p-2",size:"sm",children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create Lens"}),e.jsx(s.DialogDescription,{children:"Lenses are private by default and are only visible to you."})]}),e.jsx("div",{className:"grid gap-4 py-4",children:e.jsxs("div",{className:"grid grid-cols-8 items-center gap-4",children:[e.jsx(s.Label,{className:"text-right",children:"Name"}),e.jsx(s.Input,{value:t,onChange:y=>{n(y.target.value)},id:"name",className:"col-span-7 focus-visible:ring-0 focus-visible:ring-ring focus-visible:ring-offset-0"})]})}),a&&e.jsx("p",{className:"text-sm",children:"The lens name already exists. Use a differnet name."}),e.jsx(s.DialogFooter,{children:e.jsx(s.Button,{size:"sm",variant:"outline",type:"submit",onClick:b,disabled:p,children:p?"Creating...":"Add"})})]})]})}function Fs(){const[t,n]=f.useState(!1),a=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:l,setSelectedLensId:c}=s.useDashboardActions(),{authToken:u,tokenProps:p}=s.useSemaphorContext();async function x(d){c(d)}async function v(d){if(await Os(p.apiServiceUrl,d,u==null?void 0:u.accessToken)){const h=a==null?void 0:a.filter(j=>j.id!==d);l(h||[]),c("original")}}async function i(d){const m=a==null?void 0:a.map(b=>b.id===d.id?{...b,isDefault:!d.isDefault}:{...b,isDefault:!1});l(m||[]);const h={...d,isDefault:!d.isDefault};await je(p.apiServiceUrl,h,u==null?void 0:u.accessToken);const j=a==null?void 0:a.find(b=>b.isDefault);if(j&&j.id!==d.id){const b={...j,isDefault:!1};await je(p.apiServiceUrl,b,u==null?void 0:u.accessToken)}}return e.jsxs(s.DropdownMenu,{open:t,onOpenChange:n,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"Lenses",className:"h-7 p-2",children:e.jsx(Ns,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-60",children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:x,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(d=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:d.id,children:[e.jsx("p",{children:d.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:m=>{m.preventDefault(),i(d)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!d.isDefault,"text-green-500":d.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:m=>{m.preventDefault(),v(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})]})}const Rs=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,n,a)},Us=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`,l=await fetch(r,{method:"DELETE",headers:{Authorization:`Bearer ${n}`}});if(!l.ok){const c=await l.text();throw new Error(c||"Failed to delete group")}},Ps=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,n,r)},Gs=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`,c=await fetch(l,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(r)});if(!c.ok){const u=await c.text();throw new Error(u||"Failed to remove group members")}};function Bs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Rs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:()=>{a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:r=>{console.error("Failed to create group:",r),s.ue.error("Failed to create group",{description:r.message})}})}function qs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Us(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:r.message})}})}function Hs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>Ps(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:r.message})}})}function zs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>Gs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,l),onSuccess:(r,l)=>{a.invalidateQueries({queryKey:["group",l.groupId]}),a.invalidateQueries({queryKey:["group-members",l.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:r.message})}})}function Vs({onSuccess:t,tenantId:n,isTenantUser:a}){const[r,l]=f.useState(""),[c,u]=f.useState(""),[p,x]=f.useState({}),v=Bs(),i=()=>{const m={};return r.trim()?r.length<3?m.name="Group name must be at least 3 characters":r.length>50&&(m.name="Group name must be less than 50 characters"):m.name="Group name is required",c&&c.length>200&&(m.description="Description must be less than 200 characters"),x(m),Object.keys(m).length===0},d=async m=>{if(m.preventDefault(),!i())return;const h={name:r.trim(),description:c.trim()||void 0,type:a?"TENANT_GROUP":"ORG_GROUP",...a&&n?{tenantId:n}:{}};try{await v.mutateAsync(h),l(""),u(""),x({}),t()}catch(j){console.error("Failed to create group:",j)}};return e.jsxs("form",{onSubmit:d,className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-name",children:["Group Name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",placeholder:"e.g., Marketing Team, Engineering Squad",value:r,onChange:m=>{l(m.target.value),p.name&&x(h=>({...h,name:""}))},className:p.name?"border-destructive":"",disabled:v.isPending}),p.name&&e.jsx("p",{className:"text-sm text-destructive",children:p.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(s.Label,{htmlFor:"group-description",children:["Description",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(optional)"})]}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group...",value:c,onChange:m=>{u(m.target.value),p.description&&x(h=>({...h,description:""}))},className:p.description?"border-destructive":"",disabled:v.isPending,rows:3}),p.description&&e.jsx("p",{className:"text-sm text-destructive",children:p.description}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[c.length,"/200 characters"]})]}),e.jsx("div",{className:"rounded-lg border bg-muted/50 p-4",children:e.jsxs("div",{className:"flex gap-3",children:[e.jsx(s.CircleAlert,{className:"h-4 w-4 mt-0.5 text-muted-foreground"}),e.jsx("div",{className:"text-sm text-muted-foreground",children:"This group will be accessible to users in your workspace. You can add members after creating the group."})]})})]}),e.jsxs("div",{className:"flex justify-end gap-3",children:[e.jsx(s.Button,{type:"button",variant:"outline",onClick:()=>{l(""),u(""),x({})},disabled:v.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:v.isPending||!r.trim(),children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Create Group"]})})]})]})}function $s(){return ks.useSyncExternalStore(Qs,()=>!0,()=>!1)}function Qs(){return()=>{}}var be="Avatar",[Ks]=s.createContextScope(be),[Ws,Be]=Ks(be),qe=I.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[l,c]=I.useState("idle");return e.jsx(Ws,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(s.Primitive.span,{...r,ref:n})})});qe.displayName=be;var He="AvatarImage",ze=I.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...c}=t,u=Be(He,a),p=Js(r,c),x=s.useCallbackRef(v=>{l(v),u.onImageLoadingStatusChange(v)});return s.useLayoutEffect2(()=>{p!=="idle"&&x(p)},[p,x]),p==="loaded"?e.jsx(s.Primitive.img,{...c,ref:n,src:r}):null});ze.displayName=He;var Ve="AvatarFallback",$e=I.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,c=Be(Ve,a),[u,p]=I.useState(r===void 0);return I.useEffect(()=>{if(r!==void 0){const x=window.setTimeout(()=>p(!0),r);return()=>window.clearTimeout(x)}},[r]),u&&c.imageLoadingStatus!=="loaded"?e.jsx(s.Primitive.span,{...l,ref:n}):null});$e.displayName=Ve;function Ge(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Js(t,{referrerPolicy:n,crossOrigin:a}){const r=$s(),l=I.useRef(null),c=r?(l.current||(l.current=new window.Image),l.current):null,[u,p]=I.useState(()=>Ge(c,t));return s.useLayoutEffect2(()=>{p(Ge(c,t))},[c,t]),s.useLayoutEffect2(()=>{const x=d=>()=>{p(d)};if(!c)return;const v=x("loaded"),i=x("error");return c.addEventListener("load",v),c.addEventListener("error",i),n&&(c.referrerPolicy=n),typeof a=="string"&&(c.crossOrigin=a),()=>{c.removeEventListener("load",v),c.removeEventListener("error",i)}},[c,a,n]),u}var Qe=qe,Ke=ze,We=$e;const ye=I.forwardRef(({className:t,...n},a)=>e.jsx(Qe,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));ye.displayName=Qe.displayName;const Xs=I.forwardRef(({className:t,...n},a)=>e.jsx(Ke,{ref:a,className:s.cn("aspect-square h-full w-full",t),...n}));Xs.displayName=Ke.displayName;const Se=I.forwardRef(({className:t,...n},a)=>e.jsx(We,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));Se.displayName=We.displayName;function Ys({open:t,onOpenChange:n,group:a,onUpdate:r}){const[l,c]=f.useState("members"),[u,p]=f.useState(""),[x,v]=f.useState([]),[i,d]=f.useState([]),{data:m,isLoading:h,refetch:j}=s.useGroupMembers(a.id),b=a.type==="TENANT_GROUP"?"tenant":"organization",{users:y,isLoading:w}=s.useUnifiedUsers({type:b,tenantId:a.tenantId||void 0,active:!0,limit:100}),M=Hs(),k=zs(),C=(m==null?void 0:m.members)||[],F=f.useMemo(()=>new Set(C.map(g=>g.userId)),[C]),T=f.useMemo(()=>y.filter(g=>!F.has(g.id)),[y,F]),R=f.useMemo(()=>{if(!u)return T;const g=u.toLowerCase();return T.filter(N=>{var A,O;return((A=N.name)==null?void 0:A.toLowerCase().includes(g))||((O=N.email)==null?void 0:O.toLowerCase().includes(g))})},[T,u]),S=f.useMemo(()=>{if(!u)return C;const g=u.toLowerCase();return C.filter(N=>{var A,O,J,D;return((O=(A=N.user)==null?void 0:A.name)==null?void 0:O.toLowerCase().includes(g))||((D=(J=N.user)==null?void 0:J.email)==null?void 0:D.toLowerCase().includes(g))})},[C,u]),U=async()=>{if(x.length!==0)try{await M.mutateAsync({groupId:a.id,data:{userIds:x,userType:b==="tenant"?"tenant":"org"}}),v([]),c("members"),j(),r==null||r()}catch(g){console.error("Failed to add members:",g)}},P=async()=>{if(i.length!==0)try{await k.mutateAsync({groupId:a.id,data:{userIds:i}}),d([]),j(),r==null||r()}catch(g){console.error("Failed to remove members:",g)}},G=g=>{v(N=>N.includes(g)?N.filter(A=>A!==g):[...N,g])},B=g=>{d(N=>N.includes(g)?N.filter(A=>A!==g):[...N,g])};return e.jsx(e.Fragment,{children:e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-3xl max-h-[80vh]","aria-describedby":"group-members-description",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:a.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[C.length," ",C.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",a.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:g=>{c(g),p(""),d([])},className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsx(s.TabsTrigger,{value:"members",children:"Current Members"}),e.jsx(s.TabsTrigger,{value:"add",children:"Add Members"})]}),e.jsxs(s.TabsContent,{value:"members",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search members...",value:u,onChange:g=>p(g.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:i.length>0?"h-[300px]":"h-[350px]",children:h?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>e.jsx(s.Skeleton,{className:"h-16 w-full"},g))}):S.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:u?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:u?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:S.map(g=>e.jsx(Zs,{member:g,selected:i.includes(g.userId),onToggle:()=>B(g.userId)},g.id))})}),i.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[i.length," member",i.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:P,disabled:k.isPending,children:k.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Removing..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Trash2,{className:"mr-2 h-4 w-4"}),"Remove Selected"]})})]})]}),e.jsxs(s.TabsContent,{value:"add",className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search users to add...",value:u,onChange:g=>p(g.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:w?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(g=>e.jsx(s.Skeleton,{className:"h-16 w-full"},g))}):R.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.UserPlus,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No available users"}),e.jsx("p",{className:"text-xs mt-1",children:u?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:R.map(g=>e.jsx(et,{user:g,selected:x.includes(g.id),onToggle:()=>G(g.id)},g.id))})}),x.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.length," user",x.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:U,disabled:M.isPending,children:M.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Adding..."]}):e.jsxs(e.Fragment,{children:[e.jsx(s.UserPlus,{className:"mr-2 h-4 w-4"}),"Add Members"]})})]})]})]})]})})})}function Zs({member:t,selected:n,onToggle:a}){var l,c,u,p;const r=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(x=>x[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(ye,{className:"h-8 w-8",children:e.jsx(Se,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((u=t.user)==null?void 0:u.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(p=t.user)==null?void 0:p.email})]})]})}function et({user:t,selected:n,onToggle:a}){var l;const r=((l=t.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:a,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(ye,{className:"h-8 w-8",children:e.jsx(Se,{className:"text-xs",children:r})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:t.name}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.email})]})]})}function st({open:t,onOpenChange:n}){const[a,r]=f.useState("groups"),[l,c]=f.useState(""),[u,p]=f.useState(null),[x,v]=f.useState(!1),[i,d]=f.useState(null),{tokenProps:m}=s.useSemaphorContext(),{currentUser:h}=s.useCurrentUserInfo(),j=qs(),b=(h==null?void 0:h.type)==="tenant",y=m==null?void 0:m.tenantId,{groups:w,isLoading:M,refetch:k}=s.useGroups({type:b?"TENANT_GROUP":"all",tenantId:b?y:void 0,includeMembers:!1}),C=w.filter(S=>{var U;return S.name.toLowerCase().includes(l.toLowerCase())||((U=S.description)==null?void 0:U.toLowerCase().includes(l.toLowerCase()))}),F=async()=>{if(i)try{await j.mutateAsync(i.id),d(null),k()}catch(S){console.error("Failed to delete group:",S)}},T=S=>{p(S),v(!0)},R=()=>{r("groups"),k()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-w-4xl max-h-[80vh]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-5 w-5"}),"Group Management"]}),e.jsx(s.DialogDescription,{children:"Manage your groups, create new groups, and control group membership"})]}),e.jsxs(s.Tabs,{value:a,onValueChange:r,className:"mt-4",children:[e.jsxs(s.TabsList,{className:"grid w-full grid-cols-2",children:[e.jsxs(s.TabsTrigger,{value:"groups",className:"flex items-center gap-2",children:[e.jsx(s.Users,{className:"h-4 w-4"}),"Groups"]}),e.jsxs(s.TabsTrigger,{value:"create",className:"flex items-center gap-2",children:[e.jsx(s.Plus,{className:"h-4 w-4"}),"Create Group"]})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{placeholder:"Search groups...",value:l,onChange:S=>c(S.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:M?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(S=>e.jsx(s.Skeleton,{className:"h-24 w-full"},S))}):C.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx(s.Users,{className:"h-12 w-12 mb-3 opacity-50"}),e.jsx("p",{className:"text-sm font-medium",children:"No groups found"}),e.jsx("p",{className:"text-xs mt-1",children:l?"Try a different search":"Create your first group to get started"})]}):e.jsx("div",{className:"space-y-3",children:C.map(S=>e.jsx(tt,{group:S,onManageMembers:()=>T(S),onDelete:()=>d(S),currentUserId:h==null?void 0:h.id},S.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Vs,{onSuccess:R,tenantId:y,isTenantUser:b})})]})]})}),u&&e.jsx(Ys,{open:x,onOpenChange:v,group:u,onUpdate:()=>k()}),e.jsx(s.AlertDialog,{open:!!i,onOpenChange:()=>d(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Group"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',i==null?void 0:i.name,'"? This action cannot be undone and will remove all members from the group.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:F,disabled:j.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function tt({group:t,onManageMembers:n,onDelete:a,currentUserId:r}){const l=t.createdBy===r;return e.jsx("div",{className:"rounded-lg border bg-card p-4 transition-colors hover:bg-muted/50",children:e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:t.description})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(s.Users,{className:"h-3 w-3"}),t.memberCount," ",t.memberCount===1?"member":"members"]}),e.jsxs("span",{children:["Created ",ys.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:n,title:"Manage members",children:e.jsx(s.UserPlus,{className:"h-4 w-4"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:a,title:"Delete group",className:"text-destructive hover:text-destructive",children:e.jsx(s.Trash2,{className:"h-4 w-4"})})]})]})})}function at(){var Ee,Te,Oe,_e;_.useExportRecovery(),_.useExportPolling();const{authToken:t,tokenProps:n,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=bs.useRoleAwareDisplayPreferences(),c=s.useHasDashboardId(),{isLoading:u}=s.useDashboardQuery();s.useDashboardStore(o=>o.theme);const p=s.useDashboardStore(o=>o.lenses),x=s.useDashboardStore(o=>o.selectedLensId),v=p==null?void 0:p.find(o=>o.id===x),i=s.useDashboardStore(o=>o.dashboard);s.useDashboardStore(o=>o.selectedSheetId);const d=s.useDashboardStore(o=>o.isDashboardEditing),{setDashboardTitle:m}=s.useDashboardStore(o=>o.actions),[h,j]=f.useState(!1),[b,y]=f.useState(!1),[w,M]=f.useState(!1),[k,C]=f.useState(!1),[F,T]=f.useState(!1),[R,S]=f.useState(!1),[U,P]=f.useState(!1),[G,B]=f.useState(null),[g,N]=f.useState(!1),A=s.useDashboardStore(o=>o.isDashboardPanelOpen),O=s.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),J=s.useDashboardStore(o=>o.filterValues),D=s.useDashboardStore(o=>o.isVisualEditing);s.useEditorStore(o=>o.card);const H=s.useManagementStore(o=>o.selectedDashboard),X=s.useManagementStore(o=>o.initialDashboard);s.useManagementStore(o=>o.selectedVisual),s.useDashboardStore(o=>o.selectedFrameId),s.useEditorStore(o=>o.frame);const Y=H?(Te=H==null?void 0:H.permissions)==null?void 0:Te.canEdit:(Ee=X==null?void 0:X.permissions)==null?void 0:Ee.canEdit,re=s.useDashboardStore(o=>o.showFilters),Je=s.useAssistantLayoutStore(o=>o.setPanelOpen),Xe=s.useDashboardStore(o=>o.showDashboardJSON),ne=s.useDashboardStore(o=>o.onSaveFunction),Ye=s.useDashboardStore(o=>o.actions.setShowFilters),{setIsDashboardEditing:De,setShowDashboardJSON:Ne}=s.useDashboardStore(o=>o.actions),{setInitialDashboard:we,clearSelectedDashboard:oe}=s.useManagementStore(o=>o.actions),{resources:Z}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:ie}=s.useUserPreferences(),Ze=((Oe=ie==null?void 0:ie.preference)==null?void 0:Oe.defaultDashboardId)||null,{mutate:es,isPending:ss}=s.useDefaultDashboardMutation(),{currentUser:ts}=s.useCurrentUserInfo(),as=s.canUserManageGroups(ts),q=H||X,Ce=q?{id:q.id,title:(i==null?void 0:i.title)||q.title||"Dashboard"}:null,{handleAddNewFrame:rs}=s.useAddNewFrame(),[le,ce]=f.useState(!1),[ns,z]=f.useState(!1),[V,ee]=f.useState("close"),$=s.useUpdateResource(s.ResourceType.DASHBOARD),[E,de]=f.useState(null),os=async(o,L)=>{if(!(i!=null&&i.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:i.id,newTitle:o,previousTitle:L}),$.mutate({resourceId:i.id,data:{title:o}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:W=>{console.error("Failed to update dashboard title:",W),s.ue.error("Failed to update dashboard title"),m(L)}})};f.useEffect(()=>{if(Z&&Z.length>0){const o=i==null?void 0:i.id;if(o){const L=Z.find(W=>W.id===o);L&&we(L)}}},[Z,i==null?void 0:i.id,we]);const se=n.orgUserId||n.tenantId,Le=d&&!D&&se&&Y,{setDashboard:ue}=s.useDashboardStore(o=>o.actions),is=()=>{De(!0)},me=()=>{De(!1),Ne(!1),de(null)};_.usePristineSnapshotInitializer(d,i,E,o=>de(o));const{isDirty:Me,isDirtyPending:ls,resetDirty:te}=ae.useDebouncedDirtyCheck(i,E,300,1e3,ae.serializeDashboardForDirtyCheck),Ae=f.useCallback(()=>E?ae.serializeDashboardForDirtyCheck(i)!==ae.serializeDashboardForDirtyCheck(E):!1,[i,E]),he=Me||ls,Q=le||$.isPending,cs=()=>{Ae()?(ee("close"),z(!0)):(me(),te())},ds=async()=>{await pe({closeAfterSave:!0,navigateHomeAfterSave:V==="home"})},us=()=>{E&&ue(E),me(),V==="home"&&oe(),ee("close"),z(!1),te()},ms=()=>{E&&(ue(E),te())},hs=()=>{if(d&&Ae()){ee("home"),z(!0);return}oe()};async function pe(o){const L=(o==null?void 0:o.closeAfterSave)??g,W=(o==null?void 0:o.navigateHomeAfterSave)??!1;N(L),L&&z(!1);const vs=s.cloneDeep(i);P(!0),B(null),ce(!0);const js={template:i};$.mutate({resourceId:i.id,data:js},{onSuccess:()=>{ce(!1),s.ue.success("Dashboard saved!"),de(vs),P(!1),N(!1),L&&(me(),te(),W&&oe()),ee("close")},onError:()=>{ce(!1),B("Failed to save dashboard. Please try again."),s.ue.error("Failed to save dashboard")}})}async function ps(){if(j(!0),!x||!v)return;const o=JSON.stringify(i),L={...v,template:o,filterValues:J};await je(n.apiServiceUrl,L,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),ne==null||ne(i),j(!1)}const Ie=(v==null?void 0:v.name)||i.title;$.isPending&&console.log("Title during update:",{title:Ie,dashboardStateTitle:i.title,dashboardId:i==null?void 0:i.id,currentLensName:v==null?void 0:v.name});const ke=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,gs=!!ke&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),xs=c,K=(i==null?void 0:i.id)||null,ge=!!K&&Ze===K,fs=()=>{K&&es({dashboardId:ge?null:K})};return e.jsxs("div",{className:"flex h-11 shrink-0 items-center justify-between gap-2 overflow-x-auto border-b px-4 py-2",role:"dashboard-controls",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[ke&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{O(!A)},className:"h-7 p-2",children:e.jsx(ws,{className:"h-4 w-4"})}),xs&&!D&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:hs,className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!D&&c&&(u?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.LoaderCircle,{className:"h-3 w-3 animate-spin text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:Ie||"Untitled Dashboard",onSave:o=>{console.log("EditableText onSave called:",{newTitle:o,canEditDashboard:Y,dashboardId:i==null?void 0:i.id});const L=(i==null?void 0:i.title)||"";m(o),os(o,L)},isEditable:Y&&!v,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:$.isPending}),gs&&K&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"icon",onClick:fs,disabled:ss||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"h-7 w-7",children:e.jsx(s.Star,{className:s.cn("h-4 w-4 transition-colors",ge?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:ge?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[D&&e.jsxs(e.Fragment,{children:[e.jsx(_.AdvancedModeToggle,{className:"mr-2"}),e.jsx(_.VisualEditingControls,{className:"h-7"})]}),r&&!D&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{tooltip:"Copy Token",onClick:()=>{var o;t!=null&&t.accessToken&&((o=navigator==null?void 0:navigator.clipboard)!=null&&o.writeText?navigator.clipboard.writeText(t.accessToken).then(()=>s.ue.success("Token copied to clipboard")).catch(()=>s.ue.error("Unable to copy token")):s.ue.error("Clipboard not available"))},className:"h-7 p-2",children:e.jsx(s.Copy,{className:"h-4 w-4"})}),e.jsx(s.IconButton,{tooltip:"Invalidate Token",onClick:()=>s.invalidateToken(n.apiServiceUrl),className:"h-7 p-2",children:e.jsx(Ls,{className:"h-4 w-4"})})]}),!D&&c&&e.jsx(s.DownloadPdf,{}),!D&&c&&e.jsx(_.NotificationBell,{}),!D&&c&&((_e=q==null?void 0:q.permissions)==null?void 0:_e.canShare)&&e.jsx(s.IconButton,{tooltip:"Share Dashboard",onClick:()=>y(!0),className:"h-7 p-2",children:e.jsx(s.Share2,{className:"h-4 w-4"})}),!D&&d&&l.canUseFilters&&c&&e.jsxs(s.Button,{className:"h-7 px-2",variant:"outline",onClick:()=>{re||Je("dashboard",!1),Ye(!re)},size:"sm",children:[re?e.jsx(Ds,{className:"mr-2 h-4 w-4"}):e.jsx(s.Filter,{className:"mr-2 h-4 w-4"}),"Filter"]}),d&&!D&&se&&r&&c&&e.jsx(_s,{}),!D&&se&&r&&c&&e.jsx(Fs,{}),d&&!D&&se&&v&&r&&c&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:h,onClick:ps,size:"sm",children:[e.jsx(Re.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!d,onClick:()=>rs(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!D&&!d&&Y&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:is,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),Le&&c&&Me&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:ms,size:"sm",disabled:Q,children:[e.jsx(s.Undo2,{className:"mr-2 h-4 w-4"}),"Undo"]}),Le&&c&&e.jsxs("div",{className:"relative inline-flex",children:[e.jsxs(s.Button,{className:s.cn("h-7 p-2",!he&&"opacity-60"),disabled:Q||!he,onClick:()=>pe(),size:"sm",children:[Q?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Re.Save,{className:"mr-2 h-4 w-4"}),Q?"Saving...":"Save"]}),he&&!Q&&e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute -right-1 -top-1 h-2.5 w-2.5 rounded-full bg-orange-500 ring-2 ring-background"})]}),!D&&d&&r&&c&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>Ne(!Xe),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!D&&r&&e.jsx(Es,{}),d&&!D&&c&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:cs,children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),!D&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"h-7 p-2",children:e.jsx(s.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(s.Clock,{className:"mr-2 h-4 w-4"}),"Schedule Dashboard"]}),as&&e.jsxs(s.DropdownMenuItem,{onClick:()=>M(!0),children:[e.jsx(s.Users,{className:"mr-2 h-4 w-4"}),"Manage Groups"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>T(!0),children:[e.jsx(s.Calendar,{className:"mr-2 h-4 w-4"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>S(!0),children:[e.jsx(s.FileText,{className:"mr-2 h-4 w-4"}),"Summary Settings"]})]})]}),b&&Ce&&e.jsx(s.ShareDialog,{resource:Ce,resourceType:s.ResourceType.DASHBOARD,onClose:()=>y(!1)}),e.jsx(st,{open:w,onOpenChange:M}),(i==null?void 0:i.id)&&e.jsx(s.EmailScheduleDialog,{open:k,onOpenChange:C,dashboardId:i.id,dashboardName:i==null?void 0:i.title}),e.jsx(Fe.CalendarPreferencesDialog,{open:F,onOpenChange:T}),e.jsx(Fe.DashboardSummarySettingsDialog,{open:R,onOpenChange:S,dashboard:i,disabled:!d,onApply:o=>ue({...i,summary:o})}),e.jsx(s.AlertDialog,{open:U,onOpenChange:o=>{!o&&le&&!G||(P(o),o||(B(null),N(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:G?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:G?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:G?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{P(!1),B(null),N(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>pe({closeAfterSave:g,navigateHomeAfterSave:V==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(_.UnsavedChangesAlert,{open:ns,onOpenChange:o=>{z(o)},onSave:ds,onDiscard:us,isSaving:le,saveLabel:V==="home"?"Save & Return to Hub":"Save & Close",discardLabel:V==="home"?"Discard & Return to Hub":"Discard"})]})]})}exports.default=at;
|