react-semaphor 0.1.294 → 0.1.296
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{braces-DfDQiR3J.js → braces-BNXseceK.js} +1 -1
- package/dist/chunks/{braces-DR-GdaLC.js → braces-DVrX_3Q_.js} +1 -1
- package/dist/chunks/dashboard-controls-CKKZcVA5.js +2219 -0
- package/dist/chunks/dashboard-controls-DS2xJxHU.js +47 -0
- package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +11 -0
- package/dist/chunks/{dashboard-filter-controls-button-DxgGUl00.js → dashboard-filter-controls-button-xPaIlNHP.js} +501 -495
- package/dist/chunks/{dashboard-json-BvTeHePu.js → dashboard-json-cuj9vYY9.js} +1 -1
- package/dist/chunks/{dashboard-json-DQW8TN0I.js → dashboard-json-ovQyHWw6.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-BsmKiGud.js → dashboard-summary-settings-dialog-BUg3Qyhh.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-q7fx3YAK.js → dashboard-summary-settings-dialog-DF076HeJ.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-RVl9nbDZ.js → edit-dashboard-visual-32TAM00c.js} +5373 -5302
- package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +183 -0
- package/dist/chunks/{index-DerPpfv0.js → index-BDeJH9hO.js} +103982 -88259
- package/dist/chunks/index-Dbrs96G8.js +1533 -0
- package/dist/chunks/{resource-management-panel-epydPwyM.js → resource-management-panel-2qcXsKwg.js} +2 -2
- package/dist/chunks/{resource-management-panel-DnZ1rw1A.js → resource-management-panel-C4qoxy_g.js} +31 -30
- package/dist/chunks/use-create-flow-overlay-state-BMD3YRzU.js +21 -0
- package/dist/chunks/{use-create-flow-overlay-state-C5vdfXhM.js → use-create-flow-overlay-state-CHeppRNE.js} +572 -568
- package/dist/chunks/{use-visual-utils-D9Kknvjl.js → use-visual-utils-BIHLaVwh.js} +70 -68
- package/dist/chunks/use-visual-utils-dOYWf6nM.js +1 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +113 -112
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +271 -0
- package/dist/types/main.d.ts +324 -0
- package/dist/types/shared.d.ts +240 -0
- package/dist/types/surfboard.d.ts +271 -0
- package/dist/types/types.d.ts +271 -0
- package/package.json +7 -1
- package/dist/chunks/dashboard-controls-C3Z9bpYE.js +0 -2014
- package/dist/chunks/dashboard-controls-DGEVXgP5.js +0 -47
- package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +0 -11
- package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +0 -183
- package/dist/chunks/index-BlspGR07.js +0 -1435
- package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +0 -21
- package/dist/chunks/use-visual-utils-Dw_yw9zU.js +0 -1
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BlspGR07.js"),f=require("react");require("react-dom");const R=require("./dashboard-filter-controls-button-BIYT1ucX.js"),Qs=require("./date-formatter-CqXdM6JO.js"),is=require("./dashboard-summary-settings-dialog-BsmKiGud.js"),Ws=require("./use-debounced-dirty-check-XHSwAefL.js"),Ie=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),ls=require("./use-create-flow-overlay-state-Bcg4EgoD.js"),Js=require("./braces-DR-GdaLC.js");function Ys(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,a.get?a:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const w=Ys(f);/**
|
|
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 Xs=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 Zs=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 et=s.createLucideIcon("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
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 st=s.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
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 tt=s.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
|
|
27
|
-
* @license lucide-react v0.453.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const at=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 Te={exports:{}},ke={};/**
|
|
32
|
-
* @license React
|
|
33
|
-
* use-sync-external-store-shim.production.js
|
|
34
|
-
*
|
|
35
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
36
|
-
*
|
|
37
|
-
* This source code is licensed under the MIT license found in the
|
|
38
|
-
* LICENSE file in the root directory of this source tree.
|
|
39
|
-
*/var cs;function rt(){if(cs)return ke;cs=1;var t=f;function n(u,o){return u===o&&(u!==0||1/u===1/o)||u!==u&&o!==o}var r=typeof Object.is=="function"?Object.is:n,a=t.useState,l=t.useEffect,c=t.useLayoutEffect,h=t.useDebugValue;function m(u,o){var p=o(),g=a({inst:{value:p,getSnapshot:o}}),S=g[0].inst,y=g[1];return c(function(){S.value=p,S.getSnapshot=o,x(S)&&y({inst:S})},[u,p,o]),l(function(){return x(S)&&y({inst:S}),u(function(){x(S)&&y({inst:S})})},[u]),h(p),p}function x(u){var o=u.getSnapshot;u=u.value;try{var p=o();return!r(u,p)}catch{return!0}}function b(u,o){return o()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?b:m;return ke.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,ke}var Oe={};/**
|
|
40
|
-
* @license React
|
|
41
|
-
* use-sync-external-store-shim.development.js
|
|
42
|
-
*
|
|
43
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
44
|
-
*
|
|
45
|
-
* This source code is licensed under the MIT license found in the
|
|
46
|
-
* LICENSE file in the root directory of this source tree.
|
|
47
|
-
*/var ds;function nt(){return ds||(ds=1,process.env.NODE_ENV!=="production"&&function(){function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function n(p,g){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 S=g();if(!u){var y=g();c(S,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}y=h({inst:{value:S,getSnapshot:g}});var N=y[0].inst,C=y[1];return x(function(){N.value=S,N.getSnapshot=g,r(N)&&C({inst:N})},[p,S,g]),m(function(){return r(N)&&C({inst:N}),p(function(){r(N)&&C({inst:N})})},[p]),b(S),S}function r(p){var g=p.getSnapshot;p=p.value;try{var S=g();return!c(p,S)}catch{return!0}}function a(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var l=f,c=typeof Object.is=="function"?Object.is:t,h=l.useState,m=l.useEffect,x=l.useLayoutEffect,b=l.useDebugValue,d=!1,u=!1,o=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:n;Oe.useSyncExternalStore=l.useSyncExternalStore!==void 0?l.useSyncExternalStore:o,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"?Te.exports=rt():Te.exports=nt();var ot=Te.exports;const be=["light","dark","system"];function it(){const{theme:t,setTheme:n}=s.useTheme(),r=s.useDashboardStore(h=>h.actions.setDashboardTheme);function a(){const h=be.includes(t)?t:"system",m=be[(be.indexOf(h)+1)%be.length];n(m),r(m)}const l=t==="light"?at:t==="dark"?st:et,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(s.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:a,"aria-label":c,title:c,children:e.jsx(l,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}async function lt(t,n,r,a,l){if(!l)return null;const c=JSON.stringify(r),h=`${t}/v1/lens`;return await s.postRequest(h,l,{name:n,template:c,filterValues:a,operation:"create"})}async function Pe(t,n,r){if(!r)return null;const{id:a,template:l,filterValues:c,isDefault:h,shared:m}=n,x=`${t}/v1/lens`;return await s.postRequest(x,r,{lensId:a,template:l,filterValues:c,isDefault:h,shared:m,operation:"update"})}async function ct(t,n,r){if(!r)return null;const a=`${t}/v1/lens`;return await s.postRequest(a,r,{operation:"delete",lensId:n})}const dt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function ut({open:t,onOpenChange:n}={}){const[r,a]=f.useState(""),[l,c]=f.useState(!1),h=s.useDashboardStore(j=>j.lenses),{setLenses:m,setSelectedLensId:x}=s.useDashboardActions(),[b,d]=f.useState(!1),[u,o]=f.useState(!1),p=t!==void 0,g=p?t:u,S=j=>{p||o(j),n==null||n(j)},y=s.useDashboardStore(j=>j.dashboard),N=s.useDashboardStore(j=>j.filterValues),{authToken:C,tokenProps:T}=s.useSemaphorContext();async function L(){d(!0);const j=await lt(T.apiServiceUrl,r,y,N,C==null?void 0:C.accessToken);j&&(m([...h||[],j]),x(j.id),S(!1)),d(!1)}return e.jsxs(s.Dialog,{open:g,onOpenChange:S,children:[p?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-[6px] border-border/60 sm:max-w-[420px] sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Create lens"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Lenses are private by default and are only visible to you."})]}),e.jsxs("div",{className:"space-y-1.5 py-1",children:[e.jsx(s.Label,{htmlFor:"lens-name",className:dt,children:"Name"}),e.jsx(s.Input,{id:"lens-name",size:"xs",value:r,placeholder:"Monthly review, West region, …",onChange:j=>a(j.target.value)}),l&&e.jsx("p",{className:"text-[12px] text-destructive",children:"A lens with this name already exists. Pick a different one."})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>S(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",type:"submit",onClick:L,disabled:b||!r.trim(),children:b?"Creating…":"Create"})]})]})]})}function mt({includeLabel:t=!1}={}){const n=s.useDashboardStore(d=>d.lenses),r=s.useDashboardStore(d=>d.selectedLensId),{setLenses:a,setSelectedLensId:l}=s.useDashboardActions(),{authToken:c,tokenProps:h}=s.useSemaphorContext();async function m(d){l(d)}async function x(d){if(await ct(h.apiServiceUrl,d,c==null?void 0:c.accessToken)){const o=n==null?void 0:n.filter(p=>p.id!==d);a(o||[]),l("original")}}async function b(d){const u=n==null?void 0:n.map(g=>g.id===d.id?{...g,isDefault:!d.isDefault}:{...g,isDefault:!1});a(u||[]);const o={...d,isDefault:!d.isDefault};await Pe(h.apiServiceUrl,o,c==null?void 0:c.accessToken);const p=n==null?void 0:n.find(g=>g.isDefault);if(p&&p.id!==d.id){const g={...p,isDefault:!1};await Pe(h.apiServiceUrl,g,c==null?void 0:c.accessToken)}}return e.jsxs(e.Fragment,{children:[t?e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{className:"px-3",children:"Lenses"}),e.jsx(s.DropdownMenuSeparator,{})]}):null,e.jsxs(s.DropdownMenuRadioGroup,{value:r,onValueChange:m,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.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:u=>{u.preventDefault(),b(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:u=>{u.preventDefault(),x(d.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},d.id))]})]})}function ht(){const{displayPreferences:t,shouldShowElement:n}=s.useDisplayPreferences(),{currentUser:r,userContext:a}=s.useCurrentUserInfo(),l=f.useMemo(()=>s.getRoleBasedDisplayOverrides(r),[r]),c=f.useMemo(()=>m=>l&&l[m]!==void 0&&l[m]===!1?!1:n(m),[l,n,t]),h=f.useMemo(()=>{var m,x,b,d,u;return{canEdit:((m=a==null?void 0:a.permissions)==null?void 0:m.canEdit)??s.canUserEdit(r),canUseFilters:((x=a==null?void 0:a.permissions)==null?void 0:x.canEdit)??s.canUserUseFilters(r),canManageDashboards:((b=a==null?void 0:a.permissions)==null?void 0:b.canCreateDashboard)??s.canUserManageDashboards(r),canCreateDashboards:((d=a==null?void 0:a.permissions)==null?void 0:d.canCreateDashboard)??s.canUserCreateDashboards(r),canAccessVisuals:((u=a==null?void 0:a.permissions)==null?void 0:u.canEdit)??s.canUserAccessVisuals(r)}},[r,a]);return{displayPreferences:t,shouldShowElement:c,permissions:h,currentUser:r}}const pt=async(t,n,r)=>{const a=`${t}/management/v1/groups`;return await s.postRequestRegular(a,n,r)},xt=async(t,n,r)=>{const a=`${t}/management/v1/groups/${r}`;await s.requestJsonRegular(a,n,"DELETE")},ft=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;return await s.postRequestRegular(l,n,a)},gt=async(t,n,r,a)=>{const l=`${t}/management/v1/groups/${r}/members`;await s.requestJsonRegular(l,n,"DELETE",a)};function bt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>pt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:()=>{r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group created successfully")},onError:a=>{console.error("Failed to create group:",a),s.ue.error("Failed to create group",{description:s.getRequestErrorMessage(a,"Failed to create group")})}})}function vt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:a=>xt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["groups"]}),r.removeQueries({queryKey:["group",l]}),s.ue.success("Group deleted successfully")},onError:a=>{console.error("Failed to delete group:",a),s.ue.error("Failed to delete group",{description:s.getRequestErrorMessage(a,"Failed to delete group")})}})}function St(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>ft(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members added successfully")},onError:a=>{console.error("Failed to add group members:",a),s.ue.error("Failed to add members",{description:s.getRequestErrorMessage(a,"Failed to add members")})}})}function yt(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),r=s.useQueryClient();return s.useMutation({mutationFn:({groupId:a,data:l})=>gt(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",a,l),onSuccess:(a,l)=>{r.invalidateQueries({queryKey:["group",l.groupId]}),r.invalidateQueries({queryKey:["group-members",l.groupId]}),r.invalidateQueries({queryKey:["groups"]}),s.ue.success("Members removed successfully")},onError:a=>{console.error("Failed to remove group members:",a),s.ue.error("Failed to remove members",{description:s.getRequestErrorMessage(a,"Failed to remove members")})}})}const us="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function jt({onSuccess:t,tenantId:n,isTenantUser:r}){const[a,l]=f.useState(""),[c,h]=f.useState(""),[m,x]=f.useState({}),b=bt(),d=()=>{const o={};return a.trim()?a.length<3?o.name="Group name must be at least 3 characters":a.length>50&&(o.name="Group name must be less than 50 characters"):o.name="Group name is required",c&&c.length>200&&(o.description="Description must be less than 200 characters"),x(o),Object.keys(o).length===0},u=async o=>{if(o.preventDefault(),!d())return;const p={name:a.trim(),description:c.trim()||void 0,type:r?"TENANT_GROUP":"ORG_GROUP",...r&&n?{tenantId:n}:{}};try{await b.mutateAsync(p),l(""),h(""),x({}),t()}catch(g){console.error("Failed to create group:",g)}};return e.jsxs("form",{onSubmit:u,className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs(s.Label,{htmlFor:"group-name",className:us,children:["Group name ",e.jsx("span",{className:"text-destructive",children:"*"})]}),e.jsx(s.Input,{id:"group-name",size:"xs",placeholder:"e.g., Marketing Team, Engineering Squad",value:a,onChange:o=>{l(o.target.value),m.name&&x(p=>({...p,name:""}))},className:m.name?"border-destructive":"",disabled:b.isPending}),m.name&&e.jsx("p",{className:"text-[12px] text-destructive",children:m.name})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"group-description",className:us,children:"Description (optional)"}),e.jsx(s.Textarea,{id:"group-description",placeholder:"Describe the purpose of this group…",value:c,onChange:o=>{h(o.target.value),m.description&&x(p=>({...p,description:""}))},className:`text-[13px] ${m.description?"border-destructive":""}`,disabled:b.isPending,rows:3}),m.description?e.jsx("p",{className:"text-[12px] text-destructive",children:m.description}):e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[c.length,"/200"]})]}),e.jsxs("div",{className:"flex gap-2 text-[12px] text-muted-foreground",children:[e.jsx(s.Info,{className:"h-3.5 w-3.5 shrink-0 mt-0.5"}),e.jsx("p",{children:"This group will be accessible to users in your workspace. You can add members after creating it."})]}),e.jsxs("div",{className:"flex justify-end gap-1.5 pt-1",children:[e.jsx(s.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>{l(""),h(""),x({})},disabled:b.isPending,children:"Clear"}),e.jsx(s.Button,{type:"submit",size:"xs",disabled:b.isPending||!a.trim(),children:b.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating…"]}):"Create group"})]})]})}function Dt(t,n=[]){let r=[];function a(c,h){const m=w.createContext(h);m.displayName=c+"Context";const x=r.length;r=[...r,h];const b=u=>{var N;const{scope:o,children:p,...g}=u,S=((N=o==null?void 0:o[t])==null?void 0:N[x])||m,y=w.useMemo(()=>g,Object.values(g));return e.jsx(S.Provider,{value:y,children:p})};b.displayName=c+"Provider";function d(u,o){var S;const p=((S=o==null?void 0:o[t])==null?void 0:S[x])||m,g=w.useContext(p);if(g)return g;if(h!==void 0)return h;throw new Error(`\`${u}\` must be used within \`${c}\``)}return[b,d]}const l=()=>{const c=r.map(h=>w.createContext(h));return function(m){const x=(m==null?void 0:m[t])||c;return w.useMemo(()=>({[`__scope${t}`]:{...m,[t]:x}}),[m,x])}};return l.scopeName=t,[a,Nt(l,...n)]}function Nt(...t){const n=t[0];if(t.length===1)return n;const r=()=>{const a=t.map(l=>({useScope:l(),scopeName:l.scopeName}));return function(c){const h=a.reduce((m,{useScope:x,scopeName:b})=>{const u=x(c)[`__scope${b}`];return{...m,...u}},{});return w.useMemo(()=>({[`__scope${n.scopeName}`]:h}),[h])}};return r.scopeName=n.scopeName,r}var wt=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Fe=wt.reduce((t,n)=>{const r=s.createSlot(`Primitive.${n}`),a=w.forwardRef((l,c)=>{const{asChild:h,...m}=l,x=h?r:n;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),e.jsx(x,{...m,ref:c})});return a.displayName=`Primitive.${n}`,{...t,[n]:a}},{});function Ct(){return ot.useSyncExternalStore(Mt,()=>!0,()=>!1)}function Mt(){return()=>{}}var _e="Avatar",[Et]=Dt(_e),[Lt,ps]=Et(_e),xs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,...a}=t,[l,c]=w.useState("idle");return e.jsx(Lt,{scope:r,imageLoadingStatus:l,onImageLoadingStatusChange:c,children:e.jsx(Fe.span,{...a,ref:n})})});xs.displayName=_e;var fs="AvatarImage",gs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,src:a,onLoadingStatusChange:l=()=>{},...c}=t,h=ps(fs,r),m=At(a,c),x=s.useCallbackRef(b=>{l(b),h.onImageLoadingStatusChange(b)});return s.useLayoutEffect2(()=>{m!=="idle"&&x(m)},[m,x]),m==="loaded"?e.jsx(Fe.img,{...c,ref:n,src:a}):null});gs.displayName=fs;var bs="AvatarFallback",vs=w.forwardRef((t,n)=>{const{__scopeAvatar:r,delayMs:a,...l}=t,c=ps(bs,r),[h,m]=w.useState(a===void 0);return w.useEffect(()=>{if(a!==void 0){const x=window.setTimeout(()=>m(!0),a);return()=>window.clearTimeout(x)}},[a]),h&&c.imageLoadingStatus!=="loaded"?e.jsx(Fe.span,{...l,ref:n}):null});vs.displayName=bs;function ms(t,n){return t?n?(t.src!==n&&(t.src=n),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function At(t,{referrerPolicy:n,crossOrigin:r}){const a=Ct(),l=w.useRef(null),c=a?(l.current||(l.current=new window.Image),l.current):null,[h,m]=w.useState(()=>ms(c,t));return s.useLayoutEffect2(()=>{m(ms(c,t))},[c,t]),s.useLayoutEffect2(()=>{const x=u=>()=>{m(u)};if(!c)return;const b=x("loaded"),d=x("error");return c.addEventListener("load",b),c.addEventListener("error",d),n&&(c.referrerPolicy=n),typeof r=="string"&&(c.crossOrigin=r),()=>{c.removeEventListener("load",b),c.removeEventListener("error",d)}},[c,r,n]),h}var Ss=xs,ys=gs,js=vs;const Re=w.forwardRef(({className:t,...n},r)=>e.jsx(Ss,{ref:r,className:s.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));Re.displayName=Ss.displayName;const It=w.forwardRef(({className:t,...n},r)=>e.jsx(ys,{ref:r,className:s.cn("aspect-square h-full w-full",t),...n}));It.displayName=ys.displayName;const Ue=w.forwardRef(({className:t,...n},r)=>e.jsx(js,{ref:r,className:s.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));Ue.displayName=js.displayName;function kt({open:t,onOpenChange:n,group:r,onUpdate:a}){const[l,c]=f.useState("members"),[h,m]=f.useState(""),[x,b]=f.useState([]),[d,u]=f.useState([]),{data:o,isLoading:p,refetch:g}=s.useGroupMembers(r.id),S=r.type==="TENANT_GROUP"?"tenant":"organization",{users:y,isLoading:N}=s.useUnifiedUsers({type:S,tenantId:r.tenantId||void 0,active:!0,limit:100}),C=St(),T=yt(),L=(o==null?void 0:o.members)||[],j=f.useMemo(()=>new Set(L.map(v=>v.userId)),[L]),P=f.useMemo(()=>y.filter(v=>!j.has(v.id)),[y,j]),$=f.useMemo(()=>{if(!h)return P;const v=h.toLowerCase();return P.filter(M=>{var k,F;return((k=M.name)==null?void 0:k.toLowerCase().includes(v))||((F=M.email)==null?void 0:F.toLowerCase().includes(v))})},[P,h]),D=f.useMemo(()=>{if(!h)return L;const v=h.toLowerCase();return L.filter(M=>{var k,F,ee,U;return((F=(k=M.user)==null?void 0:k.name)==null?void 0:F.toLowerCase().includes(v))||((U=(ee=M.user)==null?void 0:ee.email)==null?void 0:U.toLowerCase().includes(v))})},[L,h]),q=async()=>{if(x.length!==0)try{await C.mutateAsync({groupId:r.id,data:{userIds:x,userType:S==="tenant"?"tenant":"org"}}),b([]),c("members"),g(),a==null||a()}catch(v){console.error("Failed to add members:",v)}},X=async()=>{if(d.length!==0)try{await T.mutateAsync({groupId:r.id,data:{userIds:d}}),u([]),g(),a==null||a()}catch(v){console.error("Failed to remove members:",v)}},ve=v=>{b(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])},Z=v=>{u(M=>M.includes(v)?M.filter(k=>k!==v):[...M,v])};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:r.name}),e.jsx("div",{className:"flex items-center gap-2 mt-1",children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:[L.length," ",L.length===1?"member":"members"]})}),e.jsxs("p",{id:"group-members-description",className:"sr-only",children:["Add or remove members from the ",r.name," group"]})]}),e.jsxs(s.Tabs,{value:l,onValueChange:v=>{c(v),m(""),u([])},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:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:d.length>0?"h-[300px]":"h-[350px]",children:p?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):D.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:h?"No members found":"No members yet"}),e.jsx("p",{className:"text-xs mt-1",children:h?"Try a different search":'Switch to the "Add Members" tab to add people to this group'})]}):e.jsx("div",{className:"space-y-2",children:D.map(v=>e.jsx(Ot,{member:v,selected:d.includes(v.userId),onToggle:()=>Z(v.userId)},v.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:X,disabled:T.isPending,children:T.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:h,onChange:v=>m(v.target.value),className:"pl-10"})]}),e.jsx(s.ScrollArea,{className:"h-[300px]",children:N?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(v=>e.jsx(s.Skeleton,{className:"h-16 w-full"},v))}):$.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:h?"Try a different search":"All eligible users are already members"})]}):e.jsx("div",{className:"space-y-2",children:$.map(v=>e.jsx(Tt,{user:v,selected:x.includes(v.id),onToggle:()=>ve(v.id)},v.id))})}),x.length>0&&e.jsxs("div",{className:"flex items-center justify-between pt-4 border-t",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x.length," user",x.length!==1?"s":""," selected"]}),e.jsx(s.Button,{onClick:q,disabled:C.isPending,children:C.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 Ot({member:t,selected:n,onToggle:r}){var l,c,h,m;const a=((c=(l=t.user)==null?void 0:l.name)==null?void 0:c.split(" ").map(x=>x[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Re,{className:"h-8 w-8",children:e.jsx(Ue,{className:"text-xs",children:a})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:((h=t.user)==null?void 0:h.name)||"Unknown User"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:(m=t.user)==null?void 0:m.email})]})]})}function Tt({user:t,selected:n,onToggle:r}){var l;const a=((l=t.name)==null?void 0:l.split(" ").map(c=>c[0]).join("").toUpperCase())||"?";return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg border bg-card hover:bg-muted/50 cursor-pointer",onClick:r,children:[e.jsx(s.Checkbox,{checked:n}),e.jsx(Re,{className:"h-8 w-8",children:e.jsx(Ue,{className:"text-xs",children:a})}),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 Pt({open:t,onOpenChange:n}){const[r,a]=f.useState("groups"),[l,c]=f.useState(""),[h,m]=f.useState(null),[x,b]=f.useState(!1),[d,u]=f.useState(null),{tokenProps:o}=s.useSemaphorContext(),{currentUser:p}=s.useCurrentUserInfo(),g=vt(),S=(p==null?void 0:p.type)==="tenant",y=o==null?void 0:o.tenantId,{groups:N,isLoading:C,refetch:T}=s.useGroups({type:S?"TENANT_GROUP":"all",tenantId:S?y:void 0,includeMembers:!1}),L=N.filter(D=>{var q;return D.name.toLowerCase().includes(l.toLowerCase())||((q=D.description)==null?void 0:q.toLowerCase().includes(l.toLowerCase()))}),j=async()=>{if(d)try{await g.mutateAsync(d.id),u(null),T()}catch(D){console.error("Failed to delete group:",D)}},P=D=>{m(D),b(!0)},$=()=>{a("groups"),T()};return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"max-h-[80vh] max-w-3xl rounded-[6px] border-border/60 sm:rounded-[6px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:"Group management"}),e.jsx(s.DialogDescription,{className:"text-[13px] leading-5",children:"Manage groups, create new ones, and control membership."})]}),e.jsxs(s.Tabs,{value:r,onValueChange:a,className:"mt-2",children:[e.jsxs(s.TabsList,{className:"h-8 w-full justify-start gap-1 bg-transparent p-0 border-b border-border/60 rounded-none",children:[e.jsx(s.TabsTrigger,{value:"groups",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Groups"}),e.jsx(s.TabsTrigger,{value:"create",className:"h-8 rounded-none border-b-2 border-transparent bg-transparent px-3 text-[13px] data-[state=active]:border-foreground data-[state=active]:bg-transparent data-[state=active]:shadow-none",children:"Create group"})]}),e.jsx(s.TabsContent,{value:"groups",className:"mt-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx(s.Search,{className:"absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx(s.Input,{size:"xs",placeholder:"Search groups…",value:l,onChange:D=>c(D.target.value),className:"pl-7"})]}),e.jsx(s.ScrollArea,{className:"h-[400px]",children:C?e.jsx("div",{className:"space-y-2",children:[1,2,3].map(D=>e.jsx(s.Skeleton,{className:"h-16 w-full rounded-[6px]"},D))}):L.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-muted-foreground",children:[e.jsx("p",{className:"text-[13px]",children:"No groups found."}),e.jsx("p",{className:"mt-1 text-[12px]",children:l?"Try a different search.":"Create your first group to get started."})]}):e.jsx("div",{className:"space-y-2 pr-2",children:L.map(D=>e.jsx(Ft,{group:D,onManageMembers:()=>P(D),onDelete:()=>u(D),currentUserId:p==null?void 0:p.id},D.id))})})]})}),e.jsx(s.TabsContent,{value:"create",className:"mt-4",children:e.jsx(jt,{onSuccess:$,tenantId:y,isTenantUser:S})})]})]})}),h&&e.jsx(kt,{open:x,onOpenChange:b,group:h,onUpdate:()=>T()}),e.jsx(s.AlertDialog,{open:!!d,onOpenChange:()=>u(null),children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete group"}),e.jsxs(s.AlertDialogDescription,{children:['Delete "',d==null?void 0:d.name,`"? This removes all members and can't be undone.`]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsx(s.AlertDialogAction,{onClick:j,disabled:g.isPending,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:g.isPending?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Deleting…"]}):"Delete group"})]})]})})]})}function Ft({group:t,onManageMembers:n,onDelete:r,currentUserId:a}){const l=t.createdBy===a;return e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-card px-3 py-2.5 transition-colors hover:bg-muted/30",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1 space-y-1",children:[e.jsx("h4",{className:"text-[13px] font-medium text-foreground",children:t.name}),t.description&&e.jsx("p",{className:"text-[12px] text-muted-foreground",children:t.description}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-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 ",Qs.format(new Date(t.createdAt),"MMM d, yyyy")]})]})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-0.5",children:[e.jsx(s.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:n,title:"Manage members","aria-label":"Manage members",children:e.jsx(s.UserPlus,{className:"h-3.5 w-3.5"})}),l&&e.jsx(s.Button,{variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:bg-destructive/10 hover:text-destructive",onClick:r,title:"Delete group","aria-label":"Delete group",children:e.jsx(s.Trash2,{className:"h-3.5 w-3.5"})})]})]})})}function J(t,n,r){var c,h;const a=(t.controls||[]).find(m=>m.id===r);if(a)return a.label;const l=(h=(c=s.findCardById(t,n))==null?void 0:c.controls)==null?void 0:h.find(m=>m.id===r);return(l==null?void 0:l.label)||r}function Y(t,n){var r;return((r=s.findCardById(t,n))==null?void 0:r.title)||n}function _t(t){const{errors:n,dashboard:r}=t;if(!r)return n;const a=new Map;for(const l of n){const c=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,d,u]=c,o=`${d}:${u}:missing-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${J(r,d,u)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const h=l.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(h){const[,d,u]=h,o=`${d}:${u}:missing-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an outdated "${J(r,d,u)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const m=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(m){const[,d,u]=m,o=`${d}:${u}:invalid-metric`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${J(r,d,u)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const x=l.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(x){const[,d,u]=x,o=`${d}:${u}:invalid-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" has an invalid "${J(r,d,u)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const b=l.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(b){const[,d,u]=b,o=`${d}:${u}:missing-temporal-group-by`;a.has(o)||a.set(o,`"${Y(r,d)}" can no longer use "${J(r,d,u)}" for time grain because the card does not currently group by a date field.`);continue}a.set(l,l)}return Array.from(a.values())}function hs(t,n){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(n)}}function Rt(){var ts,as,rs,ns;R.useExportRecovery(),R.useExportPolling();const{authToken:t,tokenProps:n,id:r}=s.useSemaphorContext(),{isLocalDev:a}=s.useDashboardPreferences(),{permissions:l}=ht(),c=s.useHasDashboardId(),{isLoading:h}=s.useDashboardQuery();s.useDashboardStore(i=>i.theme);const m=s.useDashboardStore(i=>i.isDownloadingPdf),x=s.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),b=s.useDashboardStore(i=>i.lenses),d=s.useDashboardStore(i=>i.selectedLensId),u=b==null?void 0:b.find(i=>i.id===d),o=s.useDashboardStore(i=>i.dashboard);s.useDashboardStore(i=>i.selectedSheetId);const p=s.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:g}=s.useDashboardStore(i=>i.actions),[S,y]=f.useState(!1),[N,C]=f.useState(!1),[T,L]=f.useState(!1),[j,P]=f.useState(!1),[$,D]=f.useState(!1),[q,X]=f.useState(!1),[ve,Z]=f.useState(!1),[v,M]=f.useState(!1),[k,F]=f.useState(null),[ee,U]=f.useState(!1),[se,te]=f.useState(null),[Ge,ae]=f.useState([]),[$e,re]=f.useState(!1),Ds=s.useDashboardStore(i=>i.isDashboardPanelOpen),Ns=s.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),ws=s.useDashboardStore(i=>i.filterValues),A=s.useDashboardStore(i=>i.isVisualEditing);s.useEditorStore(i=>i.card);const z=s.useManagementStore(i=>i.selectedDashboard),ne=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),s.useDashboardStore(i=>i.selectedFrameId),s.useEditorStore(i=>i.frame);const oe=z?(as=z==null?void 0:z.permissions)==null?void 0:as.canEdit:(ts=ne==null?void 0:ne.permissions)==null?void 0:ts.canEdit,ie=s.useDashboardStore(i=>i.showFilters),qe=s.useAssistantLayoutStore(i=>i.setPanelOpen),Be=s.useDashboardStore(i=>i.showDashboardJSON),Se=s.useDashboardStore(i=>i.onSaveFunction),ze=s.useDashboardStore(i=>i.actions.setShowFilters),{setIsDashboardEditing:He,setShowDashboardJSON:Ve}=s.useDashboardStore(i=>i.actions),{setInitialDashboard:Ke,clearSelectedDashboard:ye}=s.useManagementStore(i=>i.actions),{resources:le}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:je}=s.useUserPreferences(),Cs=((rs=je==null?void 0:je.preference)==null?void 0:rs.defaultDashboardId)||null,{mutate:Ms,isPending:Es}=s.useDefaultDashboardMutation(),{currentUser:Ls}=s.useCurrentUserInfo(),As=s.canUserManageGroups(Ls),B=z||ne,Qe=B?{id:B.id,title:(o==null?void 0:o.title)||B.title||"Dashboard"}:null,{handleAddNewFrame:Is}=s.useAddNewFrame(),[De,Ne]=f.useState(!1),[ks,H]=f.useState(!1),[we,ce]=f.useState("close"),V=s.useUpdateResource(s.ResourceType.DASHBOARD),[O,de]=f.useState(null),We=f.useCallback(i=>{window.setTimeout(()=>{F(i)},0)},[]),Os=async(i,E)=>{if(!(o!=null&&o.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:o.id,newTitle:i,previousTitle:E}),V.mutate({resourceId:o.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:_=>{console.error("Failed to update dashboard title:",_),s.ue.error("Failed to update dashboard title"),g(E)}})};f.useEffect(()=>{if(le&&le.length>0){const i=o==null?void 0:o.id;if(i){const E=le.find(_=>_.id===i);E&&Ke(E)}}},[le,o==null?void 0:o.id,Ke]);const K=n.orgUserId||n.tenantId,Je=p&&!A&&K&&oe,{setDashboard:Ce}=s.useDashboardStore(i=>i.actions),Me=s.useDashboardStore(i=>i.semanticExecutionPayload),Ts=()=>{He(!0)},Ee=()=>{He(!1),Ve(!1),de(null),F(null)};f.useEffect(()=>{if(!p){O&&de(null);return}O||!o||h||de(hs(o,Me))},[o,O,p,h,Me]);const ue=(O==null?void 0:O.dashboard)??null,{isDirty:Ye,isDirtyPending:Ps,resetDirty:me}=Ws.useDebouncedDirtyCheck(o,ue,300,1e3,Ie.serializeDashboardForDirtyCheck),Xe=f.useCallback(()=>ue?Ie.serializeDashboardForDirtyCheck(o)!==Ie.serializeDashboardForDirtyCheck(ue):!1,[o,ue]),Ze=Ye||Ps,he=De||V.isPending,Fs=()=>{Xe()?(ce("close"),H(!0)):(Ee(),me())},_s=async()=>{await Le({closeAfterSave:!0,navigateHomeAfterSave:we==="home"})},Rs=()=>{O&&Ce(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),Ee(),we==="home"&&ye(),ce("close"),H(!1),me()},Us=()=>{O&&(Ce(O.dashboard,{semanticExecutionPayload:O.semanticExecutionPayload}),me())},Gs=()=>{if(p&&Xe()){ce("home"),H(!0);return}ye()};async function Le(i){const E=s.useDashboardStore.getState().dashboard;if(!E)return;const _=(i==null?void 0:i.closeAfterSave)??$e,Hs=(i==null?void 0:i.navigateHomeAfterSave)??!1;re(_),_&&H(!1);const Vs=s.cloneDeep(E);U(!0),te(null),ae([]),Ne(!0);const Ks={template:E};V.mutate({resourceId:E.id,data:Ks},{onSuccess:I=>{var xe,fe,os;const G=(I==null?void 0:I.id)||((xe=I==null?void 0:I.dashboard)==null?void 0:xe.id)||((fe=I==null?void 0:I.resource)==null?void 0:fe.id)||((os=I==null?void 0:I.template)==null?void 0:os.id)||null;if(!E.id&&G){const Ae=s.useAIInteractionStore.getState(),ge=Ae.pendingDashboardDraftMigration;(ge==null?void 0:ge.scopeKey)===x?Ae.actions.setPendingDashboardDraftMigrationExpectedDashboardId(G):ge&&Ae.actions.clearPendingDashboardDraftMigration()}Ne(!1),s.ue.success("Dashboard saved!"),de(hs(Vs,s.useDashboardStore.getState().semanticExecutionPayload)),U(!1),re(!1),_&&(Ee(),me(),Hs&&ye()),ce("close")},onError:I=>{Ne(!1),te("Failed to save dashboard. Please try again.");const G=I.details,xe=Array.isArray(G==null?void 0:G.errors)?(G.errors||[]).filter(fe=>typeof fe=="string"):[];ae(_t({errors:xe,dashboard:E||void 0})),s.ue.error("Failed to save dashboard")}})}async function $s(){if(y(!0),!d||!u)return;const i=s.useDashboardStore.getState().dashboard;if(!i){y(!1);return}const E=JSON.stringify(i),_={...u,template:E,filterValues:ws};await Pe(n.apiServiceUrl,_,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Se==null||Se(i),y(!1)}const es=(u==null?void 0:u.name)||o.title,Q=!!(o!=null&&o.id);V.isPending&&console.log("Title during update:",{title:es,dashboardStateTitle:o.title,dashboardId:o==null?void 0:o.id,currentLensName:u==null?void 0:u.name});const ss=n.orgUserId||n.tenantId&&n.endUserId&&n.endUserEmail,qs=!!ss&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl);f.useEffect(()=>{!Q&&j&&P(!1)},[Q,j]);const Bs=c,W=(o==null?void 0:o.id)||null,pe=!!W&&Cs===W,zs=()=>{W&&Ms({dashboardId:pe?null:W})};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:[ss&&e.jsxs(e.Fragment,{children:[e.jsx(s.IconButton,{"aria-label":"Manage Dashboards",tooltip:"Manage Dashboards",onClick:()=>{Ns(!Ds)},className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(Zs,{className:"h-3.5 w-3.5"})}),Bs&&!A&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:Gs,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})})]}),!A&&c&&(h?e.jsx("div",{className:"h-4 w-28 rounded-md bg-muted/70 animate-pulse","aria-label":"Loading dashboard title",role:"status",children:e.jsx("span",{className:"sr-only",children:"Loading dashboard title"})}):e.jsxs(e.Fragment,{children:[e.jsx(s.EditableText,{value:es||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:oe,dashboardId:o==null?void 0:o.id});const E=(o==null?void 0:o.title)||"";g(i),Os(i,E)},isEditable:oe&&!u,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:V.isPending}),qs&&W&&e.jsx(s.TooltipProvider,{children:e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx(s.Button,{variant:"ghost",size:"xs",onClick:zs,disabled:Es||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0","aria-label":pe?"Remove as default dashboard":"Make this a default dashboard",children:e.jsx(s.Star,{className:s.cn("h-3.5 w-3.5 transition-colors",pe?"fill-foreground text-foreground":"text-muted-foreground hover:text-foreground")})})}),e.jsx(s.TooltipContent,{children:e.jsx("p",{children:pe?"Remove as default dashboard":"Make this a default dashboard"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[A&&e.jsxs(e.Fragment,{children:[e.jsx(R.AdvancedModeToggle,{}),e.jsx(R.VisualEditingControls,{})]}),!A&&c&&((ns=B==null?void 0:B.permissions)==null?void 0:ns.canShare)&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:()=>C(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!A&&p&&l.canUseFilters&&c&&e.jsx(R.DashboardFilterControlsButton,{showFilters:ie,onToggleFilters:()=>{ie||qe("dashboard",!1),ze(!ie)},onAddFilter:()=>{ie||(qe("dashboard",!1),ze(!0))},onAddControl:()=>{We("create")},onManageControls:()=>We("manage")}),p&&!A&&c&&k?e.jsx(R.DashboardControlsSettings,{open:!0,onOpenChange:i=>{i||F(null)},showTrigger:!1,initialMode:k}):null,p&&!A&&K&&u&&a&&c&&e.jsxs(s.Button,{variant:"secondary",size:"xs",disabled:S,onClick:$s,children:[e.jsx(ls.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",disabled:!p,onClick:()=>Is(),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),!A&&!p&&oe&&c&&e.jsxs(s.Button,{size:"xs",onClick:Ts,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Je&&c&&Ye&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:Us,disabled:he,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Je&&c&&e.jsxs(s.Button,{size:"xs",className:s.cn(!Ze&&"opacity-60"),disabled:he||!Ze,onClick:()=>Le(),children:[he?e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(ls.Save,{className:"h-3.5 w-3.5"}),he?"Saving...":"Save"]}),p&&!A&&c&&e.jsxs(s.Button,{variant:"outline",size:"xs",onClick:Fs,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!A&&c&&e.jsx("div",{className:"ml-2",children:e.jsx(R.NotificationBell,{})}),!A&&a&&e.jsx(it,{}),!A&&c&&e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.IconButton,{tooltip:"More Options",className:"w-7 px-0 text-muted-foreground hover:text-foreground",buttonProps:{size:"xs",variant:"ghost","aria-label":"More dashboard options"},children:e.jsx(s.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-56 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports"}),e.jsxs(s.DropdownMenuItem,{disabled:m,onSelect:()=>M(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsxs(s.DropdownMenuItem,{disabled:!Q,onSelect:()=>{Q&&P(!0)},children:[e.jsx(s.Clock,{className:"h-3.5 w-3.5"}),"Schedule"]}),e.jsx(s.DropdownMenuSeparator,{}),As&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>L(!0),children:[e.jsx(s.Users,{className:"h-3.5 w-3.5"}),"Manage Groups"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsx(s.DropdownMenuLabel,{children:"Preferences"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>D(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>X(!0),children:[e.jsx(s.FileText,{className:"h-3.5 w-3.5"}),"Summary Settings"]}),a&&c&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsx(s.DropdownMenuLabel,{children:"Developer"}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>{var i;t!=null&&t.accessToken&&((i=navigator==null?void 0:navigator.clipboard)!=null&&i.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"))},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>s.invalidateToken(n.apiServiceUrl),children:[e.jsx(tt,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Ve(!Be),children:[e.jsx(Js.Braces,{className:"h-3.5 w-3.5"}),Be?"Hide dashboard JSON":"Show dashboard JSON"]}),K&&p&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Z(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),K&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(Xs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(mt,{})})]})]})]})]}),N&&Qe&&e.jsx(s.ShareDialog,{resource:Qe,resourceType:s.ResourceType.DASHBOARD,onClose:()=>C(!1)}),e.jsx(Pt,{open:T,onOpenChange:L}),Q&&(o==null?void 0:o.id)&&e.jsx(s.EmailScheduleDialog,{open:j,onOpenChange:P,dashboardId:o.id,dashboardName:o==null?void 0:o.title}),e.jsx(is.CalendarPreferencesDialog,{open:$,onOpenChange:D}),e.jsx(is.DashboardSummarySettingsDialog,{open:q,onOpenChange:X,dashboard:o,disabled:!p,onApply:i=>Ce({...o,summary:i},{semanticExecutionPayload:Me})}),a&&K&&c&&e.jsx(ut,{open:ve,onOpenChange:Z}),c&&e.jsx(s.DownloadPdf,{open:v,onOpenChange:M}),e.jsx(s.AlertDialog,{open:ee,onOpenChange:i=>{!i&&De&&!se||(U(i),i||(te(null),ae([]),re(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:se?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:se?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Ge.length>0&&e.jsxs("div",{className:"space-y-1 rounded-md border border-destructive/20 bg-destructive/5 p-3 text-left",children:[e.jsx("div",{className:"text-sm font-medium text-destructive",children:"What needs attention"}),e.jsx("ul",{className:"list-disc space-y-1 pl-4 text-xs text-muted-foreground",children:Ge.slice(0,5).map(i=>e.jsx("li",{children:i},i))})]})]}),e.jsx(s.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:justify-end",children:se?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{U(!1),te(null),ae([]),re(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Le({closeAfterSave:$e,navigateHomeAfterSave:we==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(R.UnsavedChangesAlert,{open:ks,onOpenChange:i=>{H(i)},onSave:_s,onDiscard:Rs,isSaving:De,saveLabel:"Save",discardLabel:"Discard"})]})]})}exports.default=Rt;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const g=require("react"),e=require("./index-BlspGR07.js"),t=require("react/jsx-runtime"),F=require("./use-create-flow-overlay-state-Bcg4EgoD.js"),z=require("./use-visual-utils-Dw_yw9zU.js"),M=require("./date-formatter-CqXdM6JO.js");/**
|
|
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 U=e.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
|
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 H=e.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]),$=1e4,_=15e3,q=3e4,X=3e4,G=12e4,V=2*60*60*1e3;function K(s){const r=Date.now()-s.getTime();return r<X?$:r<G?_:q}function Q(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(p=>p.activeExports),[d,i]=g.useState(typeof document<"u"?!document.hidden:!0),m=g.useRef(null),c=g.useRef(!1),h=g.useRef(void 0),o=r==null?void 0:r.apiServiceUrl,a=s==null?void 0:s.accessToken,x=g.useCallback(()=>{const p=e.useExportStore.getState().activeExports;return Array.from(p.values()).filter(b=>e.isExportInProgress(b.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const p=()=>{i(!document.hidden)};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]);const C=g.useCallback(async()=>{if(!o||!a){c.current=!1;return}const p=x();if(p.length===0){c.current=!1;return}const b=Date.now(),S=p.filter(n=>b-n.startedAt.getTime()>V);if(S.length>0){const{updateExport:n}=e.useExportStore.getState().actions;for(const w of S)n(w.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const v=p.filter(n=>b-n.startedAt.getTime()<=V);if(v.length===0){c.current=!1;return}const j=await Promise.allSettled(v.map(async n=>{try{const w=await e.getExportStatus(o,a,n.id);let y;if(w.status==="completed")try{y=await e.getDownloadUrl(o,a,n.id)}catch(I){console.error(`[useExportPolling] Failed to get download URL for ${n.id}:`,I)}return{id:n.id,status:w.status,progress:w.progress,completedChunks:w.completedChunks,completedAt:w.completedAt?new Date(w.completedAt):void 0,lastUpdatedAt:new Date,fileSize:w.fileSize,error:w.error,downloadUrl:y}}catch(w){return console.error(`[useExportPolling] Failed to poll export ${n.id}:`,w),null}})),{updateExport:E}=e.useExportStore.getState().actions;for(const n of j)n.status==="fulfilled"&&n.value&&E(n.value.id,n.value);const D=x();if(D.length>0&&!document.hidden){const n=D.reduce((y,I)=>I.startedAt<y?I.startedAt:y,D[0].startedAt),w=K(n);m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{var y;(y=h.current)==null||y.call(h)},w)}else c.current=!1},[o,a,x]);return g.useEffect(()=>{h.current=C},[C]),g.useEffect(()=>{var b;x().length>0&&d&&!c.current&&(c.current=!0,(b=h.current)==null||b.call(h))},[f,d,x]),g.useEffect(()=>{var b;const p=x();d&&p.length>0&&!c.current&&(c.current=!0,(b=h.current)==null||b.call(h))},[d,x]),g.useEffect(()=>{!d&&m.current&&(clearTimeout(m.current),m.current=null,c.current=!1)},[d]),g.useEffect(()=>()=>{m.current&&(clearTimeout(m.current),m.current=null)},[]),{isPolling:c.current,isTabVisible:d,inProgressCount:x().length}}function W(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(h=>h.activeExports),{addExport:d}=e.useExportActions(),i=g.useRef(!1),m=r==null?void 0:r.apiServiceUrl,c=s==null?void 0:s.accessToken;g.useEffect(()=>{if(i.current||!m||!c)return;(async()=>{try{const{exports:o}=await e.getExports(m,c,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const a of o){if(f.has(a.id))continue;const x=a.totalChunks?Math.round(a.completedChunks/a.totalChunks*100):0;let C;if(a.status==="completed")try{C=await e.getDownloadUrl(m,c,a.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${a.id}:`,b)}const p={id:a.id,status:a.status,progress:x,title:Y(a),totalRows:a.totalRows,totalChunks:a.totalChunks,completedChunks:a.completedChunks,startedAt:new Date(a.createdAt),lastUpdatedAt:new Date,completedAt:a.completedAt?new Date(a.completedAt):void 0,fileSize:a.fileSize,error:a.error,expiresAt:new Date(a.expiresAt),downloadUrl:C};d(p)}i.current=!0}catch(o){console.error("[useExportRecovery] Failed to recover exports:",o),i.current=!0}})()},[m,c,d,f])}function Y(s){return s.title?s.title:e.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function Z({open:s,onOpenChange:r,isLibraryVisual:f,currentVisualName:d,isSaving:i=!1,destinationMode:m="both",onConfirm:c}){const[h,o]=g.useState(f&&d?`Copy of ${d}`:d||""),[a,x]=g.useState("");g.useEffect(()=>{s&&(o(f&&d?`Copy of ${d}`:d||""),x(""))},[s,f,d]);const C=!!h.trim(),p=m==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:m==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},b=()=>{!C||i||c({name:h.trim(),description:a.trim()||void 0,saveToLibrary:p.saveToLibrary,saveToCurrentDashboard:p.saveToCurrentDashboard})};return t.jsx(e.Dialog,{open:s,onOpenChange:r,children:t.jsxs(e.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsxs(e.DialogHeader,{children:[t.jsxs(e.DialogTitle,{className:"flex items-center gap-2",children:[t.jsx("span",{children:"Save Visual As"}),p.badgeType!=="local"&&t.jsx(F.VisualBadge,{type:p.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),t.jsx(e.DialogDescription,{children:p.description})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"name",children:"Name"}),t.jsx(e.Input,{id:"name",value:h,onChange:S=>o(S.target.value),placeholder:"Enter visual name",disabled:i})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),t.jsx(e.Textarea,{id:"description",value:a,onChange:S=>x(S.target.value),placeholder:"Enter visual description",rows:3,disabled:i})]})]}),t.jsxs(e.DialogFooter,{children:[t.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:i,children:"Cancel"}),t.jsxs(e.Button,{onClick:b,disabled:!C||i,children:[i&&t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),p.actionLabel]})]})]})})}function J(){const[s,r]=g.useState(!1),[f,d]=g.useState(!1),[i,m]=g.useState(null),[c,h]=g.useState(null),o=e.useEditorStore(u=>u.frame),a=e.useEditorStore(u=>u.card),x=e.useSelectedVisual(),C=e.useDashboardStore(u=>u.selectedSheetId),p=e.useDashboardStore(u=>u.dashboard),b=e.useDashboardStore(u=>u.actions.setIsDashboardPanelOpen),{getUpdatedFrame:S}=z.useVisualUtils(),{selectVisual:v}=e.useManagementActions(),{addFrame:j,setSelectedFrameId:E,setIsVisualEditing:D}=e.useDashboardActions(),n=e.useResolveExistingFrameSemanticExecutionPayload(),w=!!(o!=null&&o.visualId),y=(()=>{var u,l;return((u=o==null?void 0:o.cards)==null?void 0:u.length)===1&&((l=o.cards[0])!=null&&l.title)?o.cards[0].title:x!=null&&x.title?x.title:(a==null?void 0:a.title)||"Untitled Visual"})(),I=e.useCreateVisualWithFrame(u=>{u!=null&&u.id&&(v(u),f&&i&&c&&C&&(async()=>{try{const l={...i,id:e.v4(),visualId:u.id};j(C,l,{position:"end",semanticExecutionPayload:c}),E(l.id),d(!1),m(null),h(null),D(!1)}catch(l){console.error("Failed to promote semantic metadata for saved visual:",l),e.ue.error(l instanceof Error?l.message:"Failed to prepare semantic metadata for the saved visual")}})(),b(!0),r(!1))});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async u=>{if(!C){e.ue.error("No sheet selected");return}const l=S(),N=e.getDynamicFrameSaveIssue(l);if(N){e.ue.error(N);return}const L=l.cards.length===1?{...l,cards:l.cards.map(A=>({...A,title:u.name}))}:l;if(u.saveToLibrary){let A=null;if(u.saveToCurrentDashboard)try{A=await n(L,{previousFrame:e.findDashboardFrameById(p,L.id)})}catch(B){console.error("Failed to prepare semantic metadata before saving visual:",B),e.ue.error(B instanceof Error?B.message:"Failed to prepare semantic metadata for the saved visual");return}d(u.saveToCurrentDashboard),m(L),h(A);const T={title:u.name,description:u.description,frameObject:L,isPrivate:!1};I.mutate(T)}else if(u.saveToCurrentDashboard){const A={...L,id:e.v4(),visualId:void 0};try{const T=await n(L,{previousFrame:e.findDashboardFrameById(p,L.id)});j(C,A,{position:"end",semanticExecutionPayload:T}),E(A.id),e.ue.success("Visual saved to dashboard"),r(!1),D(!1)}catch(T){console.error("Failed to save visual to dashboard:",T),e.ue.error(T instanceof Error?T.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:w,currentVisualName:y,isSaving:I.isPending}}function ee(s={}){const r=e.useEditorStore(l=>l.frame),f=e.useManagementStore(l=>l.selectedVisual),d=e.useDashboardStore(l=>l.selectedFrameId),i=e.useDashboardStore(l=>l.selectedSheetId),m=e.useDashboardStore(l=>l.dashboard),{setIsVisualEditing:c,updateFrame:h}=e.useDashboardActions(),[o,a]=g.useState(!1),[x,C]=g.useState("both"),p=e.useResolveExistingFrameSemanticExecutionPayload(),b=!!(r!=null&&r.visualId||f!=null&&f.id),S=!!(r!=null&&r.visualId&&d),v=b&&!S,{saveAsDialogOpen:j,setSaveAsDialogOpen:E,handleSaveAs:D,isLibraryVisual:n,currentVisualName:w,isSaving:y}=J(),{getUpdatedFrame:I}=z.useVisualUtils(),k=async()=>{if(!i){e.ue.error("No sheet selected");return}if(o)return;a(!0);const l=I(),N=e.getDynamicFrameSaveIssue(l);if(N){a(!1),e.ue.error(N);return}const P={...l,visualId:void 0},L=e.findDashboardFrameById(m,P.id);try{const A=await p(P,{previousFrame:L});h(i,P,{semanticExecutionPayload:A})}catch(A){console.error("Failed to apply local semantic metadata:",A),a(!1),e.ue.error(A instanceof Error?A.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{a(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),c(!1)},300)},u=l=>{C(l),E(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-[5px]",children:[!b&&t.jsx(F.EditorAcceptButton,{className:"rounded-none",variant:"default"}),b&&v&&t.jsx(F.VisualSaveButton,{className:"rounded-none",variant:"default"}),b&&S&&t.jsx(F.VisualSaveAndApplyButton,{className:"rounded-none"}),t.jsxs(e.DropdownMenu,{modal:!1,children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"default",size:"xs",className:"w-7 rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:y||o,children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-[6px] border border-border/60 p-1 shadow-sm",children:[S&&t.jsxs(t.Fragment,{children:[t.jsxs(e.DropdownMenuItem,{onClick:k,disabled:o,children:[t.jsx(e.Check,{className:"h-3.5 w-3.5"}),o?"Applying...":"Apply Locally"]}),t.jsx(e.DropdownMenuSeparator,{})]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>u("local"),disabled:y,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>u("library"),disabled:y,children:[t.jsx(F.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>u("both"),disabled:y,children:[t.jsx(F.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),t.jsx(F.EditorCancelButton,{}),t.jsx(Z,{open:j,onOpenChange:l=>{y||E(l)},isLibraryVisual:n,currentVisualName:w,isSaving:y,destinationMode:x,onConfirm:D})]})}function te({className:s}){const r=e.useEditorStore(o=>o.isDevMode),f=e.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:d}=e.useEditorActions(),{config:i}=g.useContext(e.SemaphorContext).tokenProps,m=(i==null?void 0:i.showAdvancedMode)!==!1;if(!f||!m)return null;const c="h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground",h="bg-muted text-foreground hover:bg-muted";return t.jsxs("div",{role:"radiogroup","aria-label":"Editor mode",className:e.cn("inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",s),children:[t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":!r,className:e.cn(c,!r&&h),onClick:()=>d(!1),children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Drag & drop"]}),t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":r,className:e.cn(c,"border-l border-border/60",r&&h),onClick:()=>d(!0),children:[t.jsx(e.CodeXml,{className:"h-3.5 w-3.5"}),"SQL"]})]})}function se({open:s,onOpenChange:r,onSave:f,onDiscard:d,isSaving:i,title:m="Unsaved changes",description:c="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:h="Cancel",discardLabel:o="Discard",saveLabel:a="Save"}){const x=C=>{!C&&i||r(C)};return t.jsx(e.AlertDialog,{open:s,onOpenChange:x,children:t.jsxs(e.AlertDialogContent,{children:[t.jsxs(e.AlertDialogHeader,{children:[t.jsx(e.AlertDialogTitle,{children:m}),t.jsx(e.AlertDialogDescription,{children:c})]}),t.jsxs(e.AlertDialogFooter,{children:[t.jsx(e.Button,{type:"button",size:"xs",onClick:d,disabled:i,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:o}),t.jsx(e.AlertDialogCancel,{disabled:i,children:h}),t.jsx(e.Button,{type:"button",size:"xs",onClick:f,disabled:i,children:i?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):a})]})]})})}function O({export:s,onRemove:r}){const f=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},d=h=>{h.stopPropagation(),r==null||r(s.id)},i=()=>{switch(s.status){case"completed":return t.jsx(e.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return t.jsx(F.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return t.jsx(e.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},m=e.isExportInProgress(s.status),c=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return t.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[t.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[i(),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsx("span",{children:e.formatFileSize(s.fileSize)})]})]}),m&&t.jsx("div",{className:"text-xs text-muted-foreground",children:c}),s.status==="failed"&&t.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),t.jsx(e.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:d,"aria-label":"Remove notification",children:t.jsx(e.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:M.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&t.jsxs(e.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:f,children:[t.jsx(e.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),m&&t.jsxs("div",{children:[t.jsx(e.Progress,{value:s.progress,className:"h-1.5"}),t.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&t.jsx("span",{className:"text-xs text-muted-foreground",children:M.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function R(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(v=>v.activeExports),{clearCompleted:d,removeExport:i,updateExport:m}=e.useExportActions(),[c,h]=g.useState(!1),[o,a]=g.useState(!1),x=Array.from(f.values()).sort((v,j)=>j.startedAt.getTime()-v.startedAt.getTime()),C=x.some(v=>v.status==="completed"||v.status==="failed"),p=g.useCallback(async()=>{const v=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!v||!j)){h(!0);try{const E=Array.from(f.values());await Promise.all(E.map(async D=>{try{const n=await e.getExportStatus(v,j,D.id);let w;if(n.status==="completed")try{w=await e.getDownloadUrl(v,j,D.id)}catch(y){console.error(`Failed to get download URL for ${D.id}:`,y)}m(D.id,{status:n.status,progress:n.progress,completedChunks:n.completedChunks,completedAt:n.completedAt?new Date(n.completedAt):void 0,lastUpdatedAt:new Date,fileSize:n.fileSize,error:n.error,downloadUrl:w})}catch(n){console.error(`Failed to refresh export ${D.id}:`,n)}}))}finally{h(!1)}}},[f,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,m]),b=g.useCallback(async()=>{const v=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!v||!j){d();return}a(!0);try{const E=x.filter(n=>n.status==="completed"||n.status==="failed"),D=await Promise.allSettled(E.map(async n=>(await e.cancelExport(v,j,n.id),n.id)));for(const n of D)n.status==="fulfilled"?i(n.value):console.error("Failed to delete export:",n.reason)}finally{a(!1)}},[x,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,d,i]),S=g.useCallback(async v=>{const j=r==null?void 0:r.apiServiceUrl,E=s==null?void 0:s.accessToken;if(j&&E)try{await e.cancelExport(j,E,v),i(v);return}catch(D){console.error(`Failed to cancel export ${v}:`,D)}i(v)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,i]);return x.length===0?t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(U,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("h4",{className:"font-semibold",children:"Exports"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:p,disabled:c,title:"Refresh status",children:t.jsx(e.RefreshCw,{className:`h-4 w-4 ${c?"animate-spin":""}`})}),C&&t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:o,children:o?"Clearing...":"Clear all"})]})]}),t.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:t.jsx("div",{className:"divide-y",children:x.map(v=>t.jsx(O,{export:v,onRemove:S},v.id))})})]})}function re({variant:s}){const r=e.useExportStore(o=>o.activeExports),f=e.useInProgressExportsCount(),d=r.size>0,i=Array.from(r.values()).some(o=>o.status==="completed"||o.status==="failed"),c=f>0?f>9?"9+":String(f):null,h=d;return t.jsxs(e.Popover,{children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[t.jsx(e.Bell,{className:"h-3.5 w-3.5"}),h&&t.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${c?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:c})]})}),t.jsx(e.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:t.jsx(R,{})})]})}function ae(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function oe({open:s,onOpenChange:r,trigger:f,showTrigger:d=!0,initialMode:i="manage"}){const m=i==="create",{forceClose:c,handleOpenChange:h,isCreateFlowActive:o,preventPassiveDismissDuringCreate:a,resolvedOpen:x,setIsCreateFlowActive:C}=F.useCreateFlowOverlayState({open:s,onOpenChange:r,initialCreateFlowActive:i==="create",dismissMode:d?"passive":"explicit-only"}),p=e.useDashboardStore(u=>u.dashboard),{setDashboardControlsModel:b}=e.useDashboardActions(),{participants:S}=e.useDashboardStructuralParticipants(e.getDashboardCards(p)),v=Array.from(new Map(S.flatMap(u=>u.fieldChoices.map(l=>{var N;return[l.value,{option:l,target:(N=u.fieldTargetMap)==null?void 0:N[l.value]}]}))).values()),j=Array.from(new Map(S.flatMap(u=>u.metricChoices.map(l=>{var N;return[l.value,{option:l,target:(N=u.metricTargetMap)==null?void 0:N[l.value]}]}))).values()),E=e.collectDashboardControlIds({...p||{},controls:[]}),D=e.buildDashboardStructuralParticipantIdsByControlId(p),n=(u,l,N)=>{b(u,l,ae(N))},w=g.useCallback(()=>{if(m){c();return}C(!1)},[m,c,C]),y=t.jsx(F.ControlDefinitionListEditor,{scope:"dashboard",controls:p.controls||[],reservedControlIds:E,defaultValues:p.defaultControlValues||{},usageByControlId:e.buildDashboardControlUsageById(p),availableFieldChoices:v,availableMetricChoices:j,structuralParticipants:S,structuralParticipantIdsByControlId:D,initialCreateFlow:i==="create",onCreateFlowActiveChange:C,onCreateFlowComplete:w,onChange:n,emptyMessage:"No dashboard controls yet."}),I=o?"Add dashboard control":"Dashboard Controls",k=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),y]});return d?t.jsxs(e.Popover,{open:x,onOpenChange:h,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:f||t.jsxs(e.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[t.jsx(e.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),t.jsx(e.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:a,onPointerDownOutside:a,children:k})]}):t.jsx(e.Dialog,{open:x,onOpenChange:h,children:t.jsxs(e.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:a,onPointerDownOutside:a,children:[t.jsxs(e.DialogHeader,{className:o?"space-y-0":void 0,children:[t.jsx(e.DialogTitle,{className:"text-[15px]",children:I}),t.jsx(e.DialogDescription,{className:o?"sr-only":"text-[13px]",children:o?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:y})]})})}function ne({showFilters:s,onToggleFilters:r,onAddFilter:f,onAddControl:d,onManageControls:i,size:m="default",className:c,primaryButtonClassName:h,secondaryButtonClassName:o,dropdownContentClassName:a}){const x=m==="toolbar";return t.jsxs("div",{className:e.cn("relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",x?"h-8":"h-7",c),children:[t.jsxs(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",h),onClick:r,children:[s?t.jsx(H,{className:"h-3.5 w-3.5"}):t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),t.jsxs(e.DropdownMenu,{children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",o),"aria-label":"Filter and control actions",children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"start",className:e.cn("min-w-[180px] rounded-[6px] border border-border/60 p-1 shadow-sm",a),children:[t.jsxs(e.DropdownMenuItem,{onSelect:f,children:[t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),t.jsxs(e.DropdownMenuItem,{onSelect:d,children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),t.jsxs(e.DropdownMenuItem,{onSelect:i,children:[t.jsx(e.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=te;exports.DashboardControlsSettings=oe;exports.DashboardFilterControlsButton=ne;exports.ExportNotificationItem=O;exports.ExportNotificationList=R;exports.NotificationBell=re;exports.UnsavedChangesAlert=se;exports.VisualEditingControls=ee;exports.useExportPolling=Q;exports.useExportRecovery=W;
|