react-semaphor 0.1.204 → 0.1.205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/chunks/dashboard-controls-DekrQ0yg.js +42 -0
  2. package/dist/chunks/dashboard-controls-n5_oB_dp.js +1584 -0
  3. package/dist/chunks/{dashboard-json-Cwh8kbV9.js → dashboard-json-B5YyWsMv.js} +5 -5
  4. package/dist/chunks/{dashboard-json-Dh8csIFq.js → dashboard-json-VG8uFdaU.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-_3iUVFkC.js → dashboard-summary-settings-dialog-B7_fbNYb.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-BL4vn4lZ.js → dashboard-summary-settings-dialog-DnfxWTj2.js} +55 -55
  7. package/dist/chunks/{edit-dashboard-visual-RiCeBX0X.js → edit-dashboard-visual-BxDQKLvc.js} +9 -9
  8. package/dist/chunks/{edit-dashboard-visual-DEc3lB9j.js → edit-dashboard-visual-bl33bktZ.js} +928 -914
  9. package/dist/chunks/{editor-action-buttons-BfLWRprW.js → editor-action-buttons-BUAzU5tX.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-DovtyKKL.js → editor-action-buttons-DngVSXyw.js} +65 -65
  11. package/dist/chunks/index-CtLqMYAL.js +1109 -0
  12. package/dist/chunks/{index-DaQXz6Oi.js → index-em2ecoK3.js} +33535 -29709
  13. package/dist/chunks/notification-bell-BWh1ZNB4.js +11 -0
  14. package/dist/chunks/{notification-bell-Cn3-W-S3.js → notification-bell-Ck-SNMez.js} +232 -233
  15. package/dist/chunks/{resource-management-panel-qsbMXn91.js → resource-management-panel-BGJ4XMn5.js} +188 -188
  16. package/dist/chunks/{resource-management-panel-DBnpAHFb.js → resource-management-panel-Ji1DZtnk.js} +1 -1
  17. package/dist/chunks/{use-role-aware-display-preferences-B22nZN2c.js → use-role-aware-display-preferences-C0-SK5cT.js} +1 -1
  18. package/dist/chunks/{use-role-aware-display-preferences-CnipXO4k.js → use-role-aware-display-preferences-DEkMGyx9.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-JlfPxiXq.js → use-visual-utils-BLdGPBdR.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-B9X7-yfe.js → use-visual-utils-BYBat4tj.js} +28 -28
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +258 -173
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/main.d.ts +813 -2
  29. package/dist/types/types.d.ts +222 -0
  30. package/package.json +2 -1
  31. package/dist/chunks/dashboard-controls-D5VrI40y.js +0 -42
  32. package/dist/chunks/dashboard-controls-p7I_UrIz.js +0 -1661
  33. package/dist/chunks/index-CpnMO9b6.js +0 -1087
  34. package/dist/chunks/notification-bell-DsJcuxld.js +0 -11
@@ -0,0 +1,42 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CtLqMYAL.js"),b=require("react");require("react-dom");const _=require("./notification-bell-BWh1ZNB4.js"),Ye=require("./use-role-aware-display-preferences-C0-SK5cT.js"),Ze=require("./date-formatter-Sz6QDaM8.js"),ve=require("./dashboard-summary-settings-dialog-B7_fbNYb.js"),je=require("./editor-action-buttons-BUAzU5tX.js");function es(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 E=es(b);/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ss=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"}]]);/**
7
+ * @license lucide-react v0.453.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ts=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"}]]);/**
12
+ * @license lucide-react v0.453.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const as=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const rs=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"}]]);/**
22
+ * @license lucide-react v0.453.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const ns=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 re={exports:{}},te={};/**
27
+ * @license React
28
+ * use-sync-external-store-shim.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var be;function os(){if(be)return te;be=1;var t=b;function n(c,m){return c===m&&(c!==0||1/c===1/m)||c!==c&&m!==m}var a=typeof Object.is=="function"?Object.is:n,r=t.useState,l=t.useEffect,i=t.useLayoutEffect,u=t.useDebugValue;function p(c,m){var h=m(),v=r({inst:{value:h,getSnapshot:m}}),j=v[0].inst,S=v[1];return i(function(){j.value=h,j.getSnapshot=m,g(j)&&S({inst:j})},[c,h,m]),l(function(){return g(j)&&S({inst:j}),c(function(){g(j)&&S({inst:j})})},[c]),u(h),h}function g(c){var m=c.getSnapshot;c=c.value;try{var h=m();return!a(c,h)}catch{return!0}}function f(c,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:p;return te.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,te}var ae={};/**
35
+ * @license React
36
+ * use-sync-external-store-shim.development.js
37
+ *
38
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
39
+ *
40
+ * This source code is licensed under the MIT license found in the
41
+ * LICENSE file in the root directory of this source tree.
42
+ */var Se;function is(){return Se||(Se=1,process.env.NODE_ENV!=="production"&&function(){function t(h,v){return h===v&&(h!==0||1/h===1/v)||h!==h&&v!==v}function n(h,v){d||l.startTransition===void 0||(d=!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 j=v();if(!c){var S=v();i(j,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),c=!0)}S=u({inst:{value:j,getSnapshot:v}});var w=S[0].inst,M=S[1];return g(function(){w.value=j,w.getSnapshot=v,a(w)&&M({inst:w})},[h,j,v]),p(function(){return a(w)&&M({inst:w}),h(function(){a(w)&&M({inst:w})})},[h]),f(j),j}function a(h){var v=h.getSnapshot;h=h.value;try{var j=v();return!i(h,j)}catch{return!0}}function r(h,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=b,i=typeof Object.is=="function"?Object.is:t,u=l.useState,p=l.useEffect,g=l.useLayoutEffect,f=l.useDebugValue,d=!1,c=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;ae.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())}()),ae}process.env.NODE_ENV==="production"?re.exports=os():re.exports=is();var ls=re.exports;function cs(){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(ns,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(as,{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 ds(t,n,a,r,l){if(!l)return null;const i=JSON.stringify(a),u=`${t}/v1/lens`;return await s.postRequest(u,l,{name:n,template:i,filterValues:r,operation:"create"})}async function ne(t,n,a){if(!a)return null;const{id:r,template:l,filterValues:i,isDefault:u,shared:p}=n,g=`${t}/v1/lens`;return await s.postRequest(g,a,{lensId:r,template:l,filterValues:i,isDefault:u,shared:p,operation:"update"})}async function us(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:n})}function ms(){const[t,n]=b.useState(""),[a,r]=b.useState(!1),l=s.useDashboardStore(S=>S.lenses),{setLenses:i,setSelectedLensId:u}=s.useDashboardActions(),[p,g]=b.useState(!1),[f,d]=b.useState(!1),c=s.useDashboardStore(S=>S.dashboard),m=s.useDashboardStore(S=>S.filterValues),{authToken:h,tokenProps:v}=s.useSemaphorContext();async function j(){g(!0);const S=await ds(v.apiServiceUrl,t,c,m,h==null?void 0:h.accessToken);S&&(i([...l||[],S]),u(S.id),d(!1)),g(!1)}return e.jsxs(s.Dialog,{open:f,onOpenChange:d,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:j,disabled:p,children:p?"Creating...":"Add"})})]})]})}function hs(){const[t,n]=b.useState(!1),a=s.useDashboardStore(c=>c.lenses),r=s.useDashboardStore(c=>c.selectedLensId),{setLenses:l,setSelectedLensId:i}=s.useDashboardActions(),{authToken:u,tokenProps:p}=s.useSemaphorContext();async function g(c){i(c)}async function f(c){if(await us(p.apiServiceUrl,c,u==null?void 0:u.accessToken)){const h=a==null?void 0:a.filter(v=>v.id!==c);l(h||[]),i("original")}}async function d(c){const m=a==null?void 0:a.map(j=>j.id===c.id?{...j,isDefault:!c.isDefault}:{...j,isDefault:!1});l(m||[]);const h={...c,isDefault:!c.isDefault};await ne(p.apiServiceUrl,h,u==null?void 0:u.accessToken);const v=a==null?void 0:a.find(j=>j.isDefault);if(v&&v.id!==c.id){const j={...v,isDefault:!1};await ne(p.apiServiceUrl,j,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(ss,{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:g,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),a==null?void 0:a.map(c=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:c.id,children:[e.jsx("p",{children:c.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:m=>{m.preventDefault(),d(c)},className:s.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!c.isDefault,"text-green-500":c.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:m=>{m.preventDefault(),f(c.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},c.id))]})]})]})}const ps=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,n,a)},xs=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 i=await l.text();throw new Error(i||"Failed to delete group")}},gs=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,n,r)},fs=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`,i=await fetch(l,{method:"DELETE",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n}`},body:JSON.stringify(r)});if(!i.ok){const u=await i.text();throw new Error(u||"Failed to remove group members")}};function vs(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>ps(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 js(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>xs(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 bs(){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 added successfully")},onError:r=>{console.error("Failed to add group members:",r),s.ue.error("Failed to add members",{description:r.message})}})}function Ss(){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 removed successfully")},onError:r=>{console.error("Failed to remove group members:",r),s.ue.error("Failed to remove members",{description:r.message})}})}function ys({onSuccess:t,tenantId:n,isTenantUser:a}){const[r,l]=b.useState(""),[i,u]=b.useState(""),[p,g]=b.useState({}),f=vs(),d=()=>{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",i&&i.length>200&&(m.description="Description must be less than 200 characters"),g(m),Object.keys(m).length===0},c=async m=>{if(m.preventDefault(),!d())return;const h={name:r.trim(),description:i.trim()||void 0,type:a?"TENANT_GROUP":"ORG_GROUP",...a&&n?{tenantId:n}:{}};try{await f.mutateAsync(h),l(""),u(""),g({}),t()}catch(v){console.error("Failed to create group:",v)}};return e.jsxs("form",{onSubmit:c,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&&g(h=>({...h,name:""}))},className:p.name?"border-destructive":"",disabled:f.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:i,onChange:m=>{u(m.target.value),p.description&&g(h=>({...h,description:""}))},className:p.description?"border-destructive":"",disabled:f.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:[i.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(""),g({})},disabled:f.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",disabled:f.isPending||!r.trim(),children:f.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 Ns(){return ls.useSyncExternalStore(Ds,()=>!0,()=>!1)}function Ds(){return()=>{}}var oe="Avatar",[ws]=s.createContextScope(oe),[Cs,Ne]=ws(oe),De=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[l,i]=E.useState("idle");return e.jsx(Cs,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:i,children:e.jsx(s.Primitive.span,{...r,ref:n})})});De.displayName=oe;var we="AvatarImage",Ce=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...i}=t,u=Ne(we,a),p=Ls(r,i),g=s.useCallbackRef(f=>{l(f),u.onImageLoadingStatusChange(f)});return s.useLayoutEffect2(()=>{p!=="idle"&&g(p)},[p,g]),p==="loaded"?e.jsx(s.Primitive.img,{...i,ref:n,src:r}):null});Ce.displayName=we;var Le="AvatarFallback",Me=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,i=Ne(Le,a),[u,p]=E.useState(r===void 0);return E.useEffect(()=>{if(r!==void 0){const g=window.setTimeout(()=>p(!0),r);return()=>window.clearTimeout(g)}},[r]),u&&i.imageLoadingStatus!=="loaded"?e.jsx(s.Primitive.span,{...l,ref:n}):null});Me.displayName=Le;function ye(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Ls(t,{referrerPolicy:n,crossOrigin:a}){const r=Ns(),l=E.useRef(null),i=r?(l.current||(l.current=new window.Image),l.current):null,[u,p]=E.useState(()=>ye(i,t));return s.useLayoutEffect2(()=>{p(ye(i,t))},[i,t]),s.useLayoutEffect2(()=>{const g=c=>()=>{p(c)};if(!i)return;const f=g("loaded"),d=g("error");return i.addEventListener("load",f),i.addEventListener("error",d),n&&(i.referrerPolicy=n),typeof a=="string"&&(i.crossOrigin=a),()=>{i.removeEventListener("load",f),i.removeEventListener("error",d)}},[i,a,n]),u}var Ae=De,Ee=Ce,Ie=Me;const ie=E.forwardRef(({className:t,...n},a)=>e.jsx(Ae,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));ie.displayName=Ae.displayName;const Ms=E.forwardRef(({className:t,...n},a)=>e.jsx(Ee,{ref:a,className:s.cn("aspect-square h-full w-full",t),...n}));Ms.displayName=Ee.displayName;const le=E.forwardRef(({className:t,...n},a)=>e.jsx(Ie,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));le.displayName=Ie.displayName;function As({open:t,onOpenChange:n,group:a,onUpdate:r}){const[l,i]=b.useState("members"),[u,p]=b.useState(""),[g,f]=b.useState([]),[d,c]=b.useState([]),{data:m,isLoading:h,refetch:v}=s.useGroupMembers(a.id),j=a.type==="TENANT_GROUP"?"tenant":"organization",{users:S,isLoading:w}=s.useUnifiedUsers({type:j,tenantId:a.tenantId||void 0,active:!0,limit:100}),M=bs(),I=Ss(),C=(m==null?void 0:m.members)||[],P=b.useMemo(()=>new Set(C.map(x=>x.userId)),[C]),T=b.useMemo(()=>S.filter(x=>!P.has(x.id)),[S,P]),F=b.useMemo(()=>{if(!u)return T;const x=u.toLowerCase();return T.filter(D=>{var A,y;return((A=D.name)==null?void 0:A.toLowerCase().includes(x))||((y=D.email)==null?void 0:y.toLowerCase().includes(x))})},[T,u]),N=b.useMemo(()=>{if(!u)return C;const x=u.toLowerCase();return C.filter(D=>{var A,y,O,R;return((y=(A=D.user)==null?void 0:A.name)==null?void 0:y.toLowerCase().includes(x))||((R=(O=D.user)==null?void 0:O.email)==null?void 0:R.toLowerCase().includes(x))})},[C,u]),k=async()=>{if(g.length!==0)try{await M.mutateAsync({groupId:a.id,data:{userIds:g,userType:j==="tenant"?"tenant":"org"}}),f([]),i("members"),v(),r==null||r()}catch(x){console.error("Failed to add members:",x)}},G=async()=>{if(d.length!==0)try{await I.mutateAsync({groupId:a.id,data:{userIds:d}}),c([]),v(),r==null||r()}catch(x){console.error("Failed to remove members:",x)}},J=x=>{f(D=>D.includes(x)?D.filter(A=>A!==x):[...D,x])},U=x=>{c(D=>D.includes(x)?D.filter(A=>A!==x):[...D,x])};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:x=>{i(x),p(""),c([])},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:x=>p(x.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:d.length>0?"h-[300px]":"h-[350px]",children:h?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(x=>e.jsx(s.Skeleton,{className:"h-16 w-full"},x))}):N.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:N.map(x=>e.jsx(Es,{member:x,selected:d.includes(x.userId),onToggle:()=>U(x.userId)},x.id))})}),d.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:[d.length," member",d.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:G,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:x=>p(x.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(x=>e.jsx(s.Skeleton,{className:"h-16 w-full"},x))}):F.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:F.map(x=>e.jsx(Is,{user:x,selected:g.includes(x.id),onToggle:()=>J(x.id)},x.id))})}),g.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:[g.length," user",g.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:k,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 Es({member:t,selected:n,onToggle:a}){var l,i,u,p;const r=((i=(l=t.user)==null?void 0:l.name)==null?void 0:i.split(" ").map(g=>g[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(ie,{className:"h-8 w-8",children:e.jsx(le,{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 Is({user:t,selected:n,onToggle:a}){var l;const r=((l=t.name)==null?void 0:l.split(" ").map(i=>i[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(ie,{className:"h-8 w-8",children:e.jsx(le,{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 ks({open:t,onOpenChange:n}){const[a,r]=b.useState("groups"),[l,i]=b.useState(""),[u,p]=b.useState(null),[g,f]=b.useState(!1),[d,c]=b.useState(null),{tokenProps:m}=s.useSemaphorContext(),{currentUser:h}=s.useCurrentUserInfo(),v=js(),j=(h==null?void 0:h.type)==="tenant",S=m==null?void 0:m.tenantId,{groups:w,isLoading:M,refetch:I}=s.useGroups({type:j?"TENANT_GROUP":"all",tenantId:j?S:void 0,includeMembers:!1}),C=w.filter(N=>{var k;return N.name.toLowerCase().includes(l.toLowerCase())||((k=N.description)==null?void 0:k.toLowerCase().includes(l.toLowerCase()))}),P=async()=>{if(d)try{await v.mutateAsync(d.id),c(null),I()}catch(N){console.error("Failed to delete group:",N)}},T=N=>{p(N),f(!0)},F=()=>{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:N=>i(N.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(N=>e.jsx(s.Skeleton,{className:"h-24 w-full"},N))}):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(N=>e.jsx(Ts,{group:N,onManageMembers:()=>T(N),onDelete:()=>c(N),currentUserId:h==null?void 0:h.id},N.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(ys,{onSuccess:F,tenantId:S,isTenantUser:j})})]})]})}),u&&e.jsx(As,{open:g,onOpenChange:f,group:u,onUpdate:()=>I()}),e.jsx(s.AlertDialog,{open:!!d,onOpenChange:()=>c(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 "',d==null?void 0:d.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:P,disabled:v.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:v.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Deleting..."]}):"Delete Group"})]})]})})]})}function Ts({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 ",Ze.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 Os(){var xe,ge,fe;_.useExportRecovery(),_.useExportPolling();const{authToken:t,tokenProps:n,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=Ye.useRoleAwareDisplayPreferences(),i=s.useHasDashboardId(),{isLoading:u}=s.useDashboardQuery();s.useDashboardStore(o=>o.theme);const p=s.useDashboardStore(o=>o.lenses),g=s.useDashboardStore(o=>o.selectedLensId),f=p==null?void 0:p.find(o=>o.id===g),d=s.useDashboardStore(o=>o.dashboard);s.useDashboardStore(o=>o.selectedSheetId);const c=s.useDashboardStore(o=>o.isDashboardEditing),{setDashboardTitle:m}=s.useDashboardStore(o=>o.actions),[h,v]=b.useState(!1),[j,S]=b.useState(!1),[w,M]=b.useState(!1),[I,C]=b.useState(!1),[P,T]=b.useState(!1),[F,N]=b.useState(!1),[k,G]=b.useState(null),[J,U]=b.useState(!1),x=s.useDashboardStore(o=>o.isDashboardPanelOpen),D=s.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),A=s.useDashboardStore(o=>o.filterValues),y=s.useDashboardStore(o=>o.isVisualEditing);s.useEditorStore(o=>o.card);const O=s.useManagementStore(o=>o.selectedDashboard),R=s.useManagementStore(o=>o.initialDashboard);s.useManagementStore(o=>o.selectedVisual),s.useDashboardStore(o=>o.selectedFrameId),s.useEditorStore(o=>o.frame);const H=O?(ge=O==null?void 0:O.permissions)==null?void 0:ge.canEdit:(xe=R==null?void 0:R.permissions)==null?void 0:xe.canEdit,ke=s.useDashboardStore(o=>o.showFilters),Te=s.useAssistantLayoutStore(o=>o.setPanelOpen),Oe=s.useDashboardStore(o=>o.showDashboardJSON),X=s.useDashboardStore(o=>o.onSaveFunction),_e=s.useDashboardStore(o=>o.actions.setShowFilters),{setIsDashboardEditing:ce,setShowDashboardJSON:de}=s.useDashboardStore(o=>o.actions),{setInitialDashboard:ue,clearSelectedDashboard:Re}=s.useManagementStore(o=>o.actions),{resources:$}=s.useResourceManagement(s.ResourceType.DASHBOARD),{currentUser:Pe}=s.useCurrentUserInfo(),Fe=s.canUserManageGroups(Pe),B=O||R,me=B?{id:B.id,title:(d==null?void 0:d.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Ge}=s.useAddNewFrame(),[q,Y]=b.useState(!1),[Ue,Q]=b.useState(!1),K=s.useUpdateResource(s.ResourceType.DASHBOARD),[V,Z]=b.useState(null),Be=async(o,L)=>{if(!(d!=null&&d.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:d.id,newTitle:o,previousTitle:L}),K.mutate({resourceId:d.id,data:{title:o}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:z=>{console.error("Failed to update dashboard title:",z),s.ue.error("Failed to update dashboard title"),m(L)}})};b.useEffect(()=>{if($&&$.length>0){const o=d==null?void 0:d.id;if(o){const L=$.find(z=>z.id===o);L&&ue(L)}}},[$,d==null?void 0:d.id,ue]);const W=n.orgUserId||n.tenantId,qe=c&&!y&&W&&H,{setDashboard:he}=s.useDashboardStore(o=>o.actions),Ve=()=>{ce(!0)},ee=()=>{ce(!1),de(!1),Z(null)};_.usePristineSnapshotInitializer(c,d,V,o=>Z(o));const ze=()=>V?JSON.stringify(d)!==JSON.stringify(V):!1,He=()=>{ze()?Q(!0):ee()},$e=async()=>{await se({closeAfterSave:!0})},Qe=()=>{V&&he(V),ee(),Q(!1)};async function se(o){const L=(o==null?void 0:o.closeAfterSave)??J;U(L),L&&Q(!1);const z=s.cloneDeep(d);N(!0),G(null),Y(!0);const Xe={template:d};K.mutate({resourceId:d.id,data:Xe},{onSuccess:()=>{Y(!1),s.ue.success("Dashboard saved!"),Z(z),N(!1),U(!1),L&&ee()},onError:()=>{Y(!1),G("Failed to save dashboard. Please try again."),s.ue.error("Failed to save dashboard")}})}async function Ke(){if(v(!0),!g||!f)return;const o=JSON.stringify(d),L={...f,template:o,filterValues:A};await ne(n.apiServiceUrl,L,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),X==null||X(d),v(!1)}const pe=(f==null?void 0:f.name)||d.title;K.isPending&&console.log("Title during update:",{title:pe,dashboardStateTitle:d.title,dashboardId:d==null?void 0:d.id,currentLensName:f==null?void 0:f.name});const We=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,Je=i;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:[We&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{D(!x)},className:"h-7 p-2",children:e.jsx(ts,{className:"h-4 w-4"})}),Je&&!y&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:()=>Re(),className:"h-7 p-2",children:e.jsx(s.House,{className:"h-4 w-4"})})]}),!y&&i&&(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.jsx(s.EditableText,{value:pe||"Untitled Dashboard",onSave:o=>{console.log("EditableText onSave called:",{newTitle:o,canEditDashboard:H,dashboardId:d==null?void 0:d.id});const L=(d==null?void 0:d.title)||"";m(o),Be(o,L)},isEditable:H&&!f,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:K.isPending}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[y&&e.jsxs(e.Fragment,{children:[e.jsx(_.AdvancedModeToggle,{className:"mr-2"}),e.jsx(_.VisualEditingControls,{className:"h-7"})]}),r&&!y&&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(rs,{className:"h-4 w-4"})})]}),!y&&i&&e.jsx(s.DownloadPdf,{}),!y&&i&&e.jsx(_.ScheduleDashboard,{}),!y&&i&&e.jsx(_.NotificationBell,{}),!y&&i&&Fe&&e.jsx(s.IconButton,{tooltip:"Manage Groups",onClick:()=>M(!0),className:"h-7 p-2",children:e.jsx(s.Users,{className:"h-4 w-4"})}),!y&&i&&((fe=B==null?void 0:B.permissions)==null?void 0:fe.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"})}),!ke&&!y&&c&&l.canUseFilters&&i&&e.jsx(s.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>{Te("dashboard",!1),_e(!0)},size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),c&&!y&&W&&r&&i&&e.jsx(ms,{}),!y&&W&&r&&i&&e.jsx(hs,{}),c&&!y&&W&&f&&r&&i&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:h,onClick:Ke,size:"sm",children:[e.jsx(je.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),c&&!y&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!c,onClick:()=>Ge(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!y&&!c&&H&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Ve,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),qe&&i&&e.jsxs(s.Button,{className:"h-7 p-2",disabled:q,onClick:()=>se(),size:"sm",children:[q?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(je.Save,{className:"mr-2 h-4 w-4"}),q?"Saving...":"Save"]}),!y&&c&&r&&i&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>de(!Oe),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!y&&r&&e.jsx(cs,{}),c&&!y&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:He,children:[e.jsx(s.Cross2Icon,{className:"mr-2 h-4 w-4"}),"Close"]}),!y&&i&&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.Calendar,{className:"mr-2 h-4 w-4"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>T(!0),children:[e.jsx(s.FileText,{className:"mr-2 h-4 w-4"}),"Summary Settings"]})]})]}),j&&me&&e.jsx(s.ShareDialog,{resource:me,resourceType:s.ResourceType.DASHBOARD,onClose:()=>S(!1)}),e.jsx(ks,{open:w,onOpenChange:M}),e.jsx(ve.CalendarPreferencesDialog,{open:I,onOpenChange:C}),e.jsx(ve.DashboardSummarySettingsDialog,{open:P,onOpenChange:T,dashboard:d,disabled:!c,onApply:o=>he({...d,summary:o})}),e.jsx(s.AlertDialog,{open:F,onOpenChange:o=>{!o&&q&&!k||(N(o),o||(G(null),U(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:k?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:k?"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:k?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{N(!1),G(null),U(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>se(),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:Ue,onOpenChange:Q,onSave:$e,onDiscard:Qe,isSaving:q})]})]})}exports.default=Os;