react-semaphor 0.1.207 → 0.1.208

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 (28) hide show
  1. package/dist/chunks/{dashboard-controls-CwMm9_ki.js → dashboard-controls-K5zNLdtH.js} +8 -8
  2. package/dist/chunks/{dashboard-controls-HlEsqiRq.js → dashboard-controls-yOzrvYwI.js} +583 -555
  3. package/dist/chunks/{dashboard-json-CI8wIOzY.js → dashboard-json-BuLoVNV4.js} +1 -1
  4. package/dist/chunks/{dashboard-json-DoYcT7tI.js → dashboard-json-DqChvVCF.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-eQcHYcAI.js → dashboard-summary-settings-dialog-DmccX33N.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-ioe7ZyFE.js → dashboard-summary-settings-dialog-tJueBNph.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-Cl_qfIV_.js → edit-dashboard-visual-CKNlwaCO.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-BotbTTiL.js → edit-dashboard-visual-CV4JsCTg.js} +1108 -1122
  9. package/dist/chunks/{editor-action-buttons-B0-mScSZ.js → editor-action-buttons-CAjqJiT_.js} +2 -2
  10. package/dist/chunks/{editor-action-buttons-CcXUQDy4.js → editor-action-buttons-DQVh7L5i.js} +1 -1
  11. package/dist/chunks/{index-CqOQuBxB.js → index-CBcPi9pm.js} +5818 -5770
  12. package/dist/chunks/{index-plgMsXq1.js → index-DQOwJyRp.js} +172 -172
  13. package/dist/chunks/{notification-bell-BI-XywDI.js → notification-bell-B-OVf20Q.js} +3 -3
  14. package/dist/chunks/{notification-bell-BSBRPw38.js → notification-bell-DyzIftQU.js} +1 -1
  15. package/dist/chunks/{resource-management-panel-Z8x52dx2.js → resource-management-panel-D_mSi7Cm.js} +3 -3
  16. package/dist/chunks/{resource-management-panel-D0q51oXw.js → resource-management-panel-NqaNfAq3.js} +1 -1
  17. package/dist/chunks/{use-role-aware-display-preferences-BWghO18e.js → use-role-aware-display-preferences-B4QJkliF.js} +1 -1
  18. package/dist/chunks/{use-role-aware-display-preferences-C-m9KEuJ.js → use-role-aware-display-preferences-DTSpe_ZT.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-BbVM0bck.js → use-visual-utils-CCT3ABI5.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-DHmGIepC.js → use-visual-utils-ChR-Jti8.js} +1 -1
  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 +5 -5
  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/package.json +1 -1
@@ -1,29 +1,29 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-plgMsXq1.js"),b=require("react");require("react-dom");const _=require("./notification-bell-BSBRPw38.js"),Ye=require("./use-role-aware-display-preferences-BWghO18e.js"),Ze=require("./date-formatter-Sz6QDaM8.js"),ve=require("./dashboard-summary-settings-dialog-ioe7ZyFE.js"),je=require("./editor-action-buttons-CcXUQDy4.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);/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DQOwJyRp.js"),b=require("react");require("react-dom");const _=require("./notification-bell-DyzIftQU.js"),is=require("./use-role-aware-display-preferences-B4QJkliF.js"),ls=require("./date-formatter-Sz6QDaM8.js"),Ne=require("./dashboard-summary-settings-dialog-tJueBNph.js"),De=require("./editor-action-buttons-DQVh7L5i.js");function cs(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=cs(b);/**
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 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"}]]);/**
6
+ */const ds=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
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 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"}]]);/**
11
+ */const us=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
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 as=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
16
+ */const ms=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
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 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"}]]);/**
21
+ */const hs=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
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 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={};/**
26
+ */const ps=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 ie={exports:{}},ne={};/**
27
27
  * @license React
28
28
  * use-sync-external-store-shim.production.js
29
29
  *
@@ -31,7 +31,7 @@
31
31
  *
32
32
  * This source code is licensed under the MIT license found in the
33
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={};/**
34
+ */var we;function xs(){if(we)return ne;we=1;var t=b;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,i=t.useLayoutEffect,u=t.useDebugValue;function p(d,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})},[d,h,m]),l(function(){return g(j)&&S({inst:j}),d(function(){g(j)&&S({inst:j})})},[d]),u(h),h}function g(d){var m=d.getSnapshot;d=d.value;try{var h=m();return!a(d,h)}catch{return!0}}function f(d,m){return m()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:p;return ne.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:c,ne}var oe={};/**
35
35
  * @license React
36
36
  * use-sync-external-store-shim.development.js
37
37
  *
@@ -39,4 +39,4 @@
39
39
  *
40
40
  * This source code is licensed under the MIT license found in the
41
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;
42
+ */var Ce;function gs(){return Ce||(Ce=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){c||l.startTransition===void 0||(c=!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(!d){var S=v();i(j,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!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,c=!1,d=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:n;oe.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())}()),oe}process.env.NODE_ENV==="production"?ie.exports=xs():ie.exports=gs();var fs=ie.exports;function vs(){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(ps,{strokeWidth:1.5,className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),e.jsx(ms,{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 js(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 le(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 bs(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await s.postRequest(r,a,{operation:"delete",lensId:n})}function Ss(){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,c]=b.useState(!1),d=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 js(v.apiServiceUrl,t,d,m,h==null?void 0:h.accessToken);S&&(i([...l||[],S]),u(S.id),c(!1)),g(!1)}return e.jsxs(s.Dialog,{open:f,onOpenChange:c,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 ys(){const[t,n]=b.useState(!1),a=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:l,setSelectedLensId:i}=s.useDashboardActions(),{authToken:u,tokenProps:p}=s.useSemaphorContext();async function g(d){i(d)}async function f(d){if(await bs(p.apiServiceUrl,d,u==null?void 0:u.accessToken)){const h=a==null?void 0:a.filter(v=>v.id!==d);l(h||[]),i("original")}}async function c(d){const m=a==null?void 0:a.map(j=>j.id===d.id?{...j,isDefault:!d.isDefault}:{...j,isDefault:!1});l(m||[]);const h={...d,isDefault:!d.isDefault};await le(p.apiServiceUrl,h,u==null?void 0:u.accessToken);const v=a==null?void 0:a.find(j=>j.isDefault);if(v&&v.id!==d.id){const j={...v,isDefault:!1};await le(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(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:g,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(),c(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(),f(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 Ns=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await s.postRequestRegular(r,n,a)},Ds=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")}},ws=async(t,n,a,r)=>{const l=`${t}/management/v1/groups/${a}/members`;return await s.postRequestRegular(l,n,r)},Cs=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 Ls(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Ns(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 Ms(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Ds(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 As(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>ws(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 Es(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:l})=>Cs(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 Is({onSuccess:t,tenantId:n,isTenantUser:a}){const[r,l]=b.useState(""),[i,u]=b.useState(""),[p,g]=b.useState({}),f=Ls(),c=()=>{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},d=async m=>{if(m.preventDefault(),!c())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: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&&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 Ts(){return fs.useSyncExternalStore(ks,()=>!0,()=>!1)}function ks(){return()=>{}}var ce="Avatar",[Os]=s.createContextScope(ce),[_s,Me]=Os(ce),Ae=E.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[l,i]=E.useState("idle");return e.jsx(_s,{scope:a,imageLoadingStatus:l,onImageLoadingStatusChange:i,children:e.jsx(s.Primitive.span,{...r,ref:n})})});Ae.displayName=ce;var Ee="AvatarImage",Ie=E.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:l=()=>{},...i}=t,u=Me(Ee,a),p=Rs(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});Ie.displayName=Ee;var Te="AvatarFallback",ke=E.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...l}=t,i=Me(Te,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});ke.displayName=Te;function Le(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function Rs(t,{referrerPolicy:n,crossOrigin:a}){const r=Ts(),l=E.useRef(null),i=r?(l.current||(l.current=new window.Image),l.current):null,[u,p]=E.useState(()=>Le(i,t));return s.useLayoutEffect2(()=>{p(Le(i,t))},[i,t]),s.useLayoutEffect2(()=>{const g=d=>()=>{p(d)};if(!i)return;const f=g("loaded"),c=g("error");return i.addEventListener("load",f),i.addEventListener("error",c),n&&(i.referrerPolicy=n),typeof a=="string"&&(i.crossOrigin=a),()=>{i.removeEventListener("load",f),i.removeEventListener("error",c)}},[i,a,n]),u}var Oe=Ae,_e=Ie,Re=ke;const de=E.forwardRef(({className:t,...n},a)=>e.jsx(Oe,{ref:a,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));de.displayName=Oe.displayName;const Ps=E.forwardRef(({className:t,...n},a)=>e.jsx(_e,{ref:a,className:s.cn("aspect-square h-full w-full",t),...n}));Ps.displayName=_e.displayName;const ue=E.forwardRef(({className:t,...n},a)=>e.jsx(Re,{ref:a,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));ue.displayName=Re.displayName;function Fs({open:t,onOpenChange:n,group:a,onUpdate:r}){const[l,i]=b.useState("members"),[u,p]=b.useState(""),[g,f]=b.useState([]),[c,d]=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=As(),I=Es(),C=(m==null?void 0:m.members)||[],P=b.useMemo(()=>new Set(C.map(x=>x.userId)),[C]),k=b.useMemo(()=>S.filter(x=>!P.has(x.id)),[S,P]),F=b.useMemo(()=>{if(!u)return k;const x=u.toLowerCase();return k.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))})},[k,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]),T=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)}},U=async()=>{if(c.length!==0)try{await I.mutateAsync({groupId:a.id,data:{userIds:c}}),d([]),v(),r==null||r()}catch(x){console.error("Failed to remove members:",x)}},X=x=>{f(D=>D.includes(x)?D.filter(A=>A!==x):[...D,x])},G=x=>{d(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(""),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:x=>p(x.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:c.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(Us,{member:x,selected:c.includes(x.userId),onToggle:()=>G(x.userId)},x.id))})}),c.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:[c.length," member",c.length!==1?"s":""," selected"]}),e.jsx(s.Button,{variant:"destructive",size:"sm",onClick:U,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(Gs,{user:x,selected:g.includes(x.id),onToggle:()=>X(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:T,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 Us({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(de,{className:"h-8 w-8",children:e.jsx(ue,{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 Gs({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(de,{className:"h-8 w-8",children:e.jsx(ue,{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 Bs({open:t,onOpenChange:n}){const[a,r]=b.useState("groups"),[l,i]=b.useState(""),[u,p]=b.useState(null),[g,f]=b.useState(!1),[c,d]=b.useState(null),{tokenProps:m}=s.useSemaphorContext(),{currentUser:h}=s.useCurrentUserInfo(),v=Ms(),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 T;return N.name.toLowerCase().includes(l.toLowerCase())||((T=N.description)==null?void 0:T.toLowerCase().includes(l.toLowerCase()))}),P=async()=>{if(c)try{await v.mutateAsync(c.id),d(null),I()}catch(N){console.error("Failed to delete group:",N)}},k=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(qs,{group:N,onManageMembers:()=>k(N),onDelete:()=>d(N),currentUserId:h==null?void 0:h.id},N.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(Is,{onSuccess:F,tenantId:S,isTenantUser:j})})]})]})}),u&&e.jsx(Fs,{open:g,onOpenChange:f,group:u,onUpdate:()=>I()}),e.jsx(s.AlertDialog,{open:!!c,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 "',c==null?void 0:c.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 qs({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 ",ls.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 Vs(){var je,be,Se,ye;_.useExportRecovery(),_.useExportPolling();const{authToken:t,tokenProps:n,id:a}=s.useSemaphorContext(),{isLocalDev:r}=s.useDashboardPreferences(),{permissions:l}=is.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),c=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,v]=b.useState(!1),[j,S]=b.useState(!1),[w,M]=b.useState(!1),[I,C]=b.useState(!1),[P,k]=b.useState(!1),[F,N]=b.useState(!1),[T,U]=b.useState(null),[X,G]=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 $=O?(be=O==null?void 0:O.permissions)==null?void 0:be.canEdit:(je=R==null?void 0:R.permissions)==null?void 0:je.canEdit,Pe=s.useDashboardStore(o=>o.showFilters),Fe=s.useAssistantLayoutStore(o=>o.setPanelOpen),Ue=s.useDashboardStore(o=>o.showDashboardJSON),Y=s.useDashboardStore(o=>o.onSaveFunction),Ge=s.useDashboardStore(o=>o.actions.setShowFilters),{setIsDashboardEditing:me,setShowDashboardJSON:he}=s.useDashboardStore(o=>o.actions),{setInitialDashboard:pe,clearSelectedDashboard:Be}=s.useManagementStore(o=>o.actions),{resources:Q}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Z}=s.useUserPreferences(),qe=((Se=Z==null?void 0:Z.preference)==null?void 0:Se.defaultDashboardId)||null,{mutate:Ve,isPending:ze}=s.useDefaultDashboardMutation(),{currentUser:He}=s.useCurrentUserInfo(),$e=s.canUserManageGroups(He),B=O||R,xe=B?{id:B.id,title:(c==null?void 0:c.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Qe}=s.useAddNewFrame(),[q,ee]=b.useState(!1),[Ke,K]=b.useState(!1),W=s.useUpdateResource(s.ResourceType.DASHBOARD),[V,se]=b.useState(null),We=async(o,L)=>{if(!(c!=null&&c.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:c.id,newTitle:o,previousTitle:L}),W.mutate({resourceId:c.id,data:{title:o}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:H=>{console.error("Failed to update dashboard title:",H),s.ue.error("Failed to update dashboard title"),m(L)}})};b.useEffect(()=>{if(Q&&Q.length>0){const o=c==null?void 0:c.id;if(o){const L=Q.find(H=>H.id===o);L&&pe(L)}}},[Q,c==null?void 0:c.id,pe]);const J=n.orgUserId||n.tenantId,Je=d&&!y&&J&&$,{setDashboard:ge}=s.useDashboardStore(o=>o.actions),Xe=()=>{me(!0)},te=()=>{me(!1),he(!1),se(null)};_.usePristineSnapshotInitializer(d,c,V,o=>se(o));const Ye=()=>V?JSON.stringify(c)!==JSON.stringify(V):!1,Ze=()=>{Ye()?K(!0):te()},es=async()=>{await ae({closeAfterSave:!0})},ss=()=>{V&&ge(V),te(),K(!1)};async function ae(o){const L=(o==null?void 0:o.closeAfterSave)??X;G(L),L&&K(!1);const H=s.cloneDeep(c);N(!0),U(null),ee(!0);const os={template:c};W.mutate({resourceId:c.id,data:os},{onSuccess:()=>{ee(!1),s.ue.success("Dashboard saved!"),se(H),N(!1),G(!1),L&&te()},onError:()=>{ee(!1),U("Failed to save dashboard. Please try again."),s.ue.error("Failed to save dashboard")}})}async function ts(){if(v(!0),!g||!f)return;const o=JSON.stringify(c),L={...f,template:o,filterValues:A};await le(n.apiServiceUrl,L,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Y==null||Y(c),v(!1)}const fe=(f==null?void 0:f.name)||c.title;W.isPending&&console.log("Title during update:",{title:fe,dashboardStateTitle:c.title,dashboardId:c==null?void 0:c.id,currentLensName:f==null?void 0:f.name});const ve=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,as=!!ve&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),rs=i,z=(c==null?void 0:c.id)||null,re=!!z&&qe===z,ns=()=>{z&&Ve({dashboardId:re?null:z})};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:[ve&&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(us,{className:"h-4 w-4"})}),rs&&!y&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:()=>Be(),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.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:fe||"Untitled Dashboard",onSave:o=>{console.log("EditableText onSave called:",{newTitle:o,canEditDashboard:$,dashboardId:c==null?void 0:c.id});const L=(c==null?void 0:c.title)||"";m(o),We(o,L)},isEditable:$&&!f,displayClassName:"text-sm font-medium",inputClassName:"text-sm font-medium",placeholder:"Dashboard Title",isPending:W.isPending}),as&&z&&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:ns,disabled:ze||!(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",re?"fill-yellow-400 text-yellow-400":"text-muted-foreground hover:text-yellow-400")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:re?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),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(hs,{className:"h-4 w-4"})})]}),!y&&i&&e.jsx(s.DownloadPdf,{}),!y&&i&&e.jsx(_.ScheduleDashboard,{}),!y&&i&&e.jsx(_.NotificationBell,{}),!y&&i&&$e&&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&&((ye=B==null?void 0:B.permissions)==null?void 0:ye.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"})}),!Pe&&!y&&d&&l.canUseFilters&&i&&e.jsx(s.Button,{className:"h-7 p-2",variant:"outline",onClick:()=>{Fe("dashboard",!1),Ge(!0)},size:"sm",children:e.jsx(s.Filter,{className:"h-4 w-4"})}),d&&!y&&J&&r&&i&&e.jsx(Ss,{}),!y&&J&&r&&i&&e.jsx(ys,{}),d&&!y&&J&&f&&r&&i&&e.jsxs(s.Button,{className:"h-7 p-2",variant:"secondary",disabled:h,onClick:ts,size:"sm",children:[e.jsx(De.Save,{className:"mr-2 h-4 w-4"}),"Save Lens"]}),d&&!y&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",size:"sm",disabled:!d,onClick:()=>Qe(),children:[e.jsx(s.Plus,{className:"mr-2 h-4 w-4"}),"Visual"]}),!y&&!d&&$&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Xe,size:"sm",children:[e.jsx(s.Pencil,{className:"mr-2 h-4 w-4"}),"Edit"]}),Je&&i&&e.jsxs(s.Button,{className:"h-7 p-2",disabled:q,onClick:()=>ae(),size:"sm",children:[q?e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(De.Save,{className:"mr-2 h-4 w-4"}),q?"Saving...":"Save"]}),!y&&d&&r&&i&&e.jsx("div",{className:"flex items-center space-x-2",children:e.jsx(s.Button,{className:"h-7 p-2",onClick:()=>he(!Ue),size:"sm",variant:"ghost",children:e.jsx(s.Code,{className:"h-4 w-4"})})}),!y&&r&&e.jsx(vs,{}),d&&!y&&i&&e.jsxs(s.Button,{variant:"outline",className:"h-7 p-2",onClick:Ze,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:()=>k(!0),children:[e.jsx(s.FileText,{className:"mr-2 h-4 w-4"}),"Summary Settings"]})]})]}),j&&xe&&e.jsx(s.ShareDialog,{resource:xe,resourceType:s.ResourceType.DASHBOARD,onClose:()=>S(!1)}),e.jsx(Bs,{open:w,onOpenChange:M}),e.jsx(Ne.CalendarPreferencesDialog,{open:I,onOpenChange:C}),e.jsx(Ne.DashboardSummarySettingsDialog,{open:P,onOpenChange:k,dashboard:c,disabled:!d,onApply:o=>ge({...c,summary:o})}),e.jsx(s.AlertDialog,{open:F,onOpenChange:o=>{!o&&q&&!T||(N(o),o||(U(null),G(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:T?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:T?"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:T?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{N(!1),U(null),G(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>ae(),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:Ke,onOpenChange:K,onSave:es,onDiscard:ss,isSaving:q})]})]})}exports.default=Vs;