react-semaphor 0.1.424 → 0.1.425
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/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +243 -91
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +8 -8
- package/dist/chunks/{analyze-result-contract-D7pjjYPy.js → analyze-result-contract-DnfF8kBb.js} +434 -427
- package/dist/chunks/analyze-result-contract-ege_u6Nl.js +1 -0
- package/dist/chunks/{braces-8TRlDwDw.js → braces-BdbUk_r9.js} +1 -1
- package/dist/chunks/{braces-D2tStQjF.js → braces-CbO-aIwH.js} +1 -1
- package/dist/chunks/calendar-preferences-dialog-BLaSWhLl.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-D5mABNDT.js → calendar-preferences-dialog-DJwV0aqn.js} +4 -4
- package/dist/chunks/{catalog-field-grounding-CJKAqtiC.js → catalog-field-grounding-DcxPLns0.js} +10 -10
- package/dist/chunks/{switch-2bh3Hka1.js → code-editor-Bkk7s8hI.js} +7382 -6809
- package/dist/chunks/code-editor-CkXyNgYc.js +138 -0
- package/dist/chunks/{common-types-4bjoIgvm.js → common-types-ClkOI-3O.js} +4 -4
- package/dist/chunks/comparison-document-migration-CQJ0DZlL.js +414 -0
- package/dist/chunks/comparison-document-migration-Db64RWYD.js +1 -0
- package/dist/chunks/{index-Dzz6jXSY.js → dashboard-5agU0G_D.js} +57458 -56183
- package/dist/chunks/dashboard-MKIqgGDp.js +1402 -0
- package/dist/chunks/{dashboard-briefing-launcher-DuWgwtxX.js → dashboard-briefing-launcher-CII8-4qo.js} +11 -6
- package/dist/chunks/{dashboard-briefing-launcher-BNDzMjjt.js → dashboard-briefing-launcher-qyEVfuOm.js} +226 -209
- package/dist/chunks/dashboard-controls-PJpeYZHw.js +36 -0
- package/dist/chunks/dashboard-controls-aJY0FNPP.js +2196 -0
- package/dist/chunks/dashboard-input-contract-BFpERluO.js +18 -0
- package/dist/chunks/dashboard-input-contract-DV3cshjz.js +1 -0
- package/dist/chunks/{dashboard-json-CkTEDNtH.js → dashboard-json-CzHSP6Fa.js} +16 -15
- package/dist/chunks/dashboard-json-DtmR5yCf.js +1 -0
- package/dist/chunks/date-formatter-BTTYdAik.js +1 -0
- package/dist/chunks/date-formatter-D-89jTjG.js +514 -0
- package/dist/chunks/{edit-dashboard-visual-CRjVRZLk.js → edit-dashboard-visual-AkZzwBCV.js} +8892 -8996
- package/dist/chunks/edit-dashboard-visual-Cif6uDqN.js +182 -0
- package/dist/chunks/{index-CjzRe2su.js → index-CnujJ3fa.js} +3 -3
- package/dist/chunks/{index-DRlMUglg.js → index-Dpm_VET4.js} +2 -2
- package/dist/chunks/{index-CJdxSyQq.js → index-If0wlXGi.js} +308 -308
- package/dist/chunks/index-jSrCwPQz.js +31 -0
- package/dist/chunks/{x-CXDkqdur.js → index-xHCrHprY.js} +59 -59
- package/dist/chunks/{layout-grid-C0OI-MRn.js → layout-grid-B08pP7v6.js} +1 -1
- package/dist/chunks/{layout-grid-CiubineE.js → layout-grid-D5tYJg1-.js} +1 -1
- package/dist/chunks/metric-comparison-4oA4ouU9.js +354 -0
- package/dist/chunks/metric-comparison-nQKquVnx.js +1 -0
- package/dist/chunks/{palette-C4KTXOug.js → palette-C0yjT5Tv.js} +1 -1
- package/dist/chunks/{palette-Cp1hqZtm.js → palette-jqaAcwiQ.js} +1 -1
- package/dist/chunks/{save-DgMfP0j8.js → save-HCJjjzdX.js} +1 -1
- package/dist/chunks/{save-C__QggEE.js → save-Xdc4pnys.js} +1 -1
- package/dist/chunks/{search-BHsQIWBV.js → search-DHZCro8B.js} +1 -1
- package/dist/chunks/{search-DNCejM7Z.js → search-Dcud9ajy.js} +1 -1
- package/dist/chunks/{update-policy-C1pmhLz9.js → update-policy-BgONreNd.js} +1 -1
- package/dist/chunks/{update-policy-BCJc0oI5.js → update-policy-CY2k-pJP.js} +9 -9
- package/dist/chunks/{use-create-flow-overlay-state-B9vArrvr.js → use-create-flow-overlay-state-ByOKVV2K.js} +62 -62
- package/dist/chunks/{use-create-flow-overlay-state-B-bYbtix.js → use-create-flow-overlay-state-DmuReEnk.js} +2 -2
- package/dist/chunks/validators-B4VMLX3_.js +1 -0
- package/dist/chunks/{validators-PXkij33j.js → validators-Cz-XuORM.js} +123 -119
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +2 -2
- package/dist/dashboard-authoring/index.js +6 -4
- package/dist/data-app-builder/index.cjs +6 -6
- package/dist/data-app-builder/index.js +5 -5
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +6 -6
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +65 -68
- package/dist/format-utils/index.cjs +2 -2
- package/dist/format-utils/index.js +59 -58
- package/dist/index.cjs +1 -1
- package/dist/index.js +19 -19
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +299 -3
- package/dist/types/brand-studio.d.ts +2 -2
- package/dist/types/briefings.d.ts +65 -41
- package/dist/types/dashboard-assistant.d.ts +28 -7
- package/dist/types/dashboard-authoring.d.ts +123 -43
- package/dist/types/dashboard.d.ts +97 -48
- package/dist/types/data-app-builder.d.ts +2 -2
- package/dist/types/data-app-sdk.d.ts +1 -1
- package/dist/types/format-utils.d.ts +98 -10
- package/dist/types/index.js +1 -1
- package/dist/types/main.d.ts +229 -95
- package/dist/types/shared.d.ts +84 -43
- package/dist/types/surfboard.d.ts +99 -49
- package/dist/types/types.d.ts +110 -50
- package/package.json +2 -1
- package/dist/chunks/analyze-result-contract-DpDcImgk.js +0 -1
- package/dist/chunks/calendar-preferences-dialog-iokD3HbE.js +0 -1
- package/dist/chunks/contracts-CoCOpd_i.js +0 -11
- package/dist/chunks/contracts-CtB2VONT.js +0 -1
- package/dist/chunks/dashboard-controls-bbEF-AbK.js +0 -52
- package/dist/chunks/dashboard-controls-id39vb7G.js +0 -2322
- package/dist/chunks/dashboard-json-DVoqS1ks.js +0 -1
- package/dist/chunks/date-formatter-B4EBSe9C.js +0 -1
- package/dist/chunks/date-formatter-BlhBftA9.js +0 -416
- package/dist/chunks/edit-dashboard-visual-CkrxZCcp.js +0 -178
- package/dist/chunks/index-S1CGUcSz.js +0 -1406
- package/dist/chunks/switch-DMT7qf_R.js +0 -138
- package/dist/chunks/validators-DMlVbd1p.js +0 -1
- package/dist/chunks/x-B6ghREd2.js +0 -31
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),d=require("./code-editor-CkXyNgYc.js"),s=require("./dashboard-MKIqgGDp.js"),U=require("./index-jSrCwPQz.js");require("./analyze-result-contract-ege_u6Nl.js");const g=require("react");require("./index-Dpm_VET4.js");require("./comparison-document-migration-Db64RWYD.js");const Xt=require("react-dom");require("../briefings/index.cjs");const V=require("./dashboard-briefing-launcher-CII8-4qo.js"),vt=require("./search-Dcud9ajy.js"),yt=require("./index-D7KJindZ.js"),Yt=require("./calendar-preferences-dialog-BLaSWhLl.js"),Zt=require("./use-debounced-dirty-check-XHSwAefL.js"),qe=require("./normalize-dashboard-for-dirty-check-BXRUMVb2.js"),xt=require("./save-Xdc4pnys.js"),es=require("./palette-C0yjT5Tv.js"),ts=require("./braces-CbO-aIwH.js");function ss(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(n,a,r.get?r:{enumerable:!0,get:()=>t[a]})}}return n.default=t,Object.freeze(n)}const L=ss(g);/**
|
|
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 rs=U.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 as=U.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"}]]);/**
|
|
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 ns=U.createLucideIcon("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
17
|
+
* @license lucide-react v0.453.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const os=U.createLucideIcon("ShieldX",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m14.5 9.5-5 5",key:"17q4r4"}],["path",{d:"m9.5 9.5 5 5",key:"18nt4w"}]]);/**
|
|
22
|
+
* @license lucide-react v0.453.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const is=U.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"}]]);/**
|
|
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 ds=U.createLucideIcon("UserPlus",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]]);/**
|
|
32
|
+
* @license lucide-react v0.453.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const jt=U.createLucideIcon("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]),Ne=["light","dark","system"];function ls(){const{theme:t,setTheme:n}=s.useTheme(),a=d.useDashboardStore(x=>x.actions.setDashboardTheme);function r(){const x=Ne.includes(t)?t:"system",h=Ne[(Ne.indexOf(x)+1)%Ne.length];n(h),a(h)}const o=t==="light"?is:t==="dark"?ns:as,c=t==="light"?"Theme: light (click for dark)":t==="dark"?"Theme: dark (click for system)":"Theme: system (click for light)";return e.jsx(d.Button,{type:"button",variant:"ghost",size:"xs",className:"h-7 w-7 p-0 text-muted-foreground hover:text-foreground",onClick:r,"aria-label":c,title:c,children:e.jsx(o,{className:"h-3.5 w-3.5",strokeWidth:1.5})})}function wt(t){const n=new Date().toISOString(),a=s.buildDashboardSheetsInputExecutionSnapshot({dashboard:t.dashboard,sheetIds:(t.dashboard.sheets||[]).filter(r=>r.kind!=="document").map(r=>r.id),sheetKind:"dashboard",mode:"dashboard",generatedAt:n,runtimeValues:{dashboardInputValues:t.dashboardInputValues,filterValues:t.filterValues,controlValues:t.controlValues,inlineFilterValuesMap:t.inlineFilterValuesMap,cardControlValuesMap:t.cardControlValuesMap}}).snapshot;return{generatedAt:n,dashboardInputValues:a.dashboardInputValues}}async function cs(t,n,a,r,o,c){if(!c)return null;const x=JSON.stringify(a),h=`${t}/v1/lens`;return await d.postRequest(h,c,{name:n,template:x,filterValues:r,inputValues:o,operation:"create"})}async function Be(t,n,a){if(!a)return null;const{id:r,template:o,filterValues:c,inputValues:x,isDefault:h,shared:p}=n,j=`${t}/v1/lens`;return await d.postRequest(j,a,{lensId:r,template:o,filterValues:c,inputValues:x,isDefault:h,shared:p,operation:"update"})}async function us(t,n,a){if(!a)return null;const r=`${t}/v1/lens`;return await d.postRequest(r,a,{operation:"delete",lensId:n})}const ms="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function hs({open:t,onOpenChange:n}={}){const[a,r]=g.useState(""),[o,c]=g.useState(!1),x=d.useDashboardStore(y=>y.lenses),{setLenses:h,setSelectedLensId:p}=d.useDashboardActions(),[j,l]=g.useState(!1),[m,v]=g.useState(!1),f=t!==void 0,D=f?t:m,w=y=>{f||v(y),n==null||n(y)},u=d.useDashboardStore(y=>y.dashboard),k=d.useDashboardStore(y=>y.filterValues),{authToken:S,tokenProps:E}=s.useSemaphorContext();async function N(){l(!0);const y=d.useDashboardStore.getState(),q=wt({dashboard:u,dashboardInputValues:y.dashboardInputValues,filterValues:k,controlValues:y.controlValues,inlineFilterValuesMap:y.inlineFilterValuesMap,cardControlValuesMap:y.cardControlValuesMap}),B=await cs(E.apiServiceUrl,a,u,k,q,S==null?void 0:S.accessToken);B&&(h([...x||[],B]),p(B.id),w(!1)),l(!1)}return e.jsxs(s.Dialog,{open:D,onOpenChange:w,children:[f?null:e.jsx(s.DialogTrigger,{asChild:!0,children:e.jsxs(d.Button,{variant:"secondary",size:"xs",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Lens"]})}),e.jsxs(s.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",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(d.Label,{htmlFor:"lens-name",className:ms,children:"Name"}),e.jsx(d.Input,{id:"lens-name",size:"xs",value:a,placeholder:"Monthly review, West region, …",onChange:y=>r(y.target.value)}),o&&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(d.Button,{variant:"outline",size:"xs",onClick:()=>w(!1),children:"Cancel"}),e.jsx(d.Button,{size:"xs",type:"submit",onClick:N,disabled:j||!a.trim(),children:j?"Creating…":"Create"})]})]})]})}function ps({includeLabel:t=!1}={}){const n=d.useDashboardStore(l=>l.lenses),a=d.useDashboardStore(l=>l.selectedLensId),{setLenses:r,setSelectedLensId:o}=d.useDashboardActions(),{authToken:c,tokenProps:x}=s.useSemaphorContext();async function h(l){o(l)}async function p(l){if(await us(x.apiServiceUrl,l,c==null?void 0:c.accessToken)){const v=n==null?void 0:n.filter(f=>f.id!==l);r(v||[]),o("original")}}async function j(l){const m=n==null?void 0:n.map(D=>D.id===l.id?{...D,isDefault:!l.isDefault}:{...D,isDefault:!1});r(m||[]);const v={...l,isDefault:!l.isDefault};await Be(x.apiServiceUrl,v,c==null?void 0:c.accessToken);const f=n==null?void 0:n.find(D=>D.isDefault);if(f&&f.id!==l.id){const D={...f,isDefault:!1};await Be(x.apiServiceUrl,D,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:a,onValueChange:h,children:[e.jsx(s.DropdownMenuRadioItem,{value:"original",children:"Original"}),n==null?void 0:n.map(l=>e.jsxs(s.DropdownMenuRadioItem,{className:"group flex justify-between gap-2",value:l.id,children:[e.jsx("p",{children:l.name}),e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsx(s.House,{onClick:m=>{m.preventDefault(),j(l)},className:d.cn("size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",{invisible:!l.isDefault,"text-green-500":l.isDefault}),strokeWidth:1.5}),e.jsx(s.Cross2Icon,{onClick:m=>{m.preventDefault(),p(l.id)},className:"invisible size-3.5 text-muted-foreground hover:cursor-pointer hover:text-foreground group-hover:visible",strokeWidth:1.5})]})]},l.id))]})]})}function xs(){const{displayPreferences:t,shouldShowElement:n}=s.useDisplayPreferences(),{currentUser:a,userContext:r}=s.useCurrentUserInfo(),o=g.useMemo(()=>s.getRoleBasedDisplayOverrides(a),[a]),c=g.useMemo(()=>h=>o&&o[h]!==void 0&&o[h]===!1?!1:n(h),[o,n,t]),x=g.useMemo(()=>{var h,p,j,l,m;return{canEdit:((h=r==null?void 0:r.permissions)==null?void 0:h.canEdit)??s.canUserEdit(a),canUseFilters:((p=r==null?void 0:r.permissions)==null?void 0:p.canEdit)??s.canUserUseFilters(a),canManageDashboards:((j=r==null?void 0:r.permissions)==null?void 0:j.canCreateDashboard)??s.canUserManageDashboards(a),canCreateDashboards:((l=r==null?void 0:r.permissions)==null?void 0:l.canCreateDashboard)??s.canUserCreateDashboards(a),canAccessVisuals:((m=r==null?void 0:r.permissions)==null?void 0:m.canEdit)??s.canUserAccessVisuals(a)}},[a,r]);return{displayPreferences:t,shouldShowElement:c,permissions:x,currentUser:a}}var $e="Avatar",[fs]=d.createContextScope($e),gs=[0,()=>{}],[bs,Dt]=fs($e),Ge=L.forwardRef((t,n)=>{const{__scopeAvatar:a,...r}=t,[o,c]=L.useState("idle"),[x,h]=ys();return e.jsx(bs,{scope:a,imageLoadingStatus:o,setImageLoadingStatus:c,imageCount:x,setImageCount:h,children:e.jsx(d.Primitive.span,{...r,ref:n})})});Ge.displayName=$e;var Nt="AvatarImage",ze=L.forwardRef((t,n)=>{const{__scopeAvatar:a,src:r,onLoadingStatusChange:o,...c}=t,x=Dt(Nt,a);js(x.setImageCount);const h=vs(r,{referrerPolicy:c.referrerPolicy,crossOrigin:c.crossOrigin,loadingStatus:x.imageLoadingStatus,setLoadingStatus:x.setImageLoadingStatus}),p=d.useCallbackRef(l=>{o==null||o(l)}),j=L.useRef(h);return d.useLayoutEffect2(()=>{const l=j.current;j.current=h,h!==l&&p(h)},[h,p]),h==="loaded"?e.jsx(d.Primitive.img,{...c,ref:n,src:r}):null});ze.displayName=Nt;var St="AvatarFallback",_e=L.forwardRef((t,n)=>{const{__scopeAvatar:a,delayMs:r,...o}=t,c=Dt(St,a),[x,h]=L.useState(r===void 0);return L.useEffect(()=>{if(r!==void 0){const p=window.setTimeout(()=>h(!0),r);return()=>window.clearTimeout(p)}},[r]),x&&c.imageLoadingStatus!=="loaded"?e.jsx(d.Primitive.span,{...o,ref:n}):null});_e.displayName=St;function vs(t,{loadingStatus:n,setLoadingStatus:a,referrerPolicy:r,crossOrigin:o}){return d.useLayoutEffect2(()=>{if(!t){a("error");return}const c=new window.Image,x=p=>{const j=p.currentTarget;a(ft(j))},h=()=>a("error");return c.addEventListener("load",x),c.addEventListener("error",h),r&&(c.referrerPolicy=r),c.crossOrigin=o??null,c.src=t,a(ft(c)),()=>{c.removeEventListener("load",x),c.removeEventListener("error",h),a("idle")}},[t,o,r,a]),n}function ft(t){return t.complete?t.naturalWidth>0?"loaded":"error":"loading"}function ys(){let t=gs;{t=L.useState(0);const[n]=t,a=L.useRef(!1);L.useEffect(()=>{n>1&&!a.current&&(a.current=!0,console.warn("Avatar: Only one `Avatar.Image` component should be rendered per `Avatar.Root`, but multiple were detected. This will lead to unexpected behavior."))},[n])}return t}function js(t){L.useEffect(()=>(t(n=>n+1),()=>{t(n=>n-1)}),[t])}const Ct=L.forwardRef(({className:t,...n},a)=>e.jsx(Ge,{ref:a,className:d.cn("relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",t),...n}));Ct.displayName=Ge.displayName;const ws=L.forwardRef(({className:t,...n},a)=>e.jsx(ze,{ref:a,className:d.cn("aspect-square h-full w-full",t),...n}));ws.displayName=ze.displayName;const kt=L.forwardRef(({className:t,...n},a)=>e.jsx(_e,{ref:a,className:d.cn("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...n}));kt.displayName=_e.displayName;const Ds=async(t,n,a)=>{const r=`${t}/management/v1/groups`;return await d.postRequestRegular(r,n,a)},Ns=async(t,n,a,r)=>{const o=`${t}/management/v1/groups/${a}`;return d.requestJsonRegular(o,n,"PATCH",r)},Ss=async(t,n,a)=>{const r=`${t}/management/v1/groups/${a}`;await d.requestJsonRegular(r,n,"DELETE")},Cs=async(t,n,a,r)=>{const o=`${t}/management/v1/groups/${a}/members`;return await d.postRequestRegular(o,n,r)},ks=async(t,n,a,r)=>{const o=`${t}/management/v1/groups/${a}/members`;await d.requestJsonRegular(o,n,"DELETE",r)};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:()=>{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:d.getRequestErrorMessage(r,"Failed to create group")})}})}function Is(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>Ns(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["groups"]}),s.ue.success("Group updated successfully")},onError:r=>{console.error("Failed to update group:",r),s.ue.error("Failed to update group",{description:d.getRequestErrorMessage(r,"Failed to update group")})}})}function Ls(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:r=>Ss(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["groups"]}),a.removeQueries({queryKey:["group",o]}),s.ue.success("Group deleted successfully")},onError:r=>{console.error("Failed to delete group:",r),s.ue.error("Failed to delete group",{description:d.getRequestErrorMessage(r,"Failed to delete group")})}})}function Es(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>Cs(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.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:d.getRequestErrorMessage(r,"Failed to add members")})}})}function As(){const{authToken:t,tokenProps:n}=s.useSemaphorContext(),a=s.useQueryClient();return s.useMutation({mutationFn:({groupId:r,data:o})=>ks(n.apiServiceUrl,(t==null?void 0:t.accessToken)||"",r,o),onSuccess:(r,o)=>{a.invalidateQueries({queryKey:["group",o.groupId]}),a.invalidateQueries({queryKey:["group-members",o.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:d.getRequestErrorMessage(r,"Failed to remove members")})}})}const Ps=[];function Rs({open:t,onOpenChange:n}){var S,E,N;const{tokenProps:a}=s.useSemaphorContext(),{currentUser:r}=s.useCurrentUserInfo(),o=(r==null?void 0:r.type)==="tenant",c=a==null?void 0:a.tenantId,{groups:x,isLoading:h,error:p,refetch:j}=s.useGroups({type:o?"TENANT_GROUP":"all",tenantId:o?c:void 0,includeMembers:!1}),l=p?Mt(p,"Unable to load groups."):null,[m,v]=g.useState({kind:"list"}),[f,D]=g.useState(null),w=Ls();g.useEffect(()=>{t||(v({kind:"list"}),D(null))},[t]);const u=m.kind==="members"&&x.find(y=>y.id===m.groupId)||null,k=async()=>{if(f)try{await w.mutateAsync(f.id),D(null),v({kind:"list"}),j()}catch{}};return e.jsx(s.Dialog,{open:t,onOpenChange:n,children:e.jsxs(s.DialogContent,{className:"flex max-h-[640px] w-[720px] max-w-[92vw] flex-col gap-0 overflow-hidden p-0",children:[m.kind==="list"?e.jsxs("div",{className:"shrink-0 border-b border-border px-5 pt-4 pb-3.5",children:[e.jsx(s.DialogTitle,{className:"text-[15px] font-semibold tracking-tight",children:"Group management"}),e.jsx(s.DialogDescription,{className:"mt-1 text-[12px] leading-[1.5] text-muted-foreground",children:"Organize people into groups for shared access."})]}):m.kind==="create"?e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:()=>v({kind:"list"}),"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium",children:"New group"}),e.jsx(s.DialogDescription,{className:"sr-only",children:"Create a new group to organize members."})]}):null,m.kind==="list"&&e.jsx(Us,{groups:x,isLoading:h,errorMessage:l,onRetry:()=>j(),currentUserId:r==null?void 0:r.id,onOpenGroup:y=>v({kind:"members",groupId:y}),onCreate:()=>v({kind:"create"}),onDeleteRequest:y=>D(y)}),m.kind==="members"&&u&&e.jsx(Ts,{group:u,isTenantViewer:o,canEdit:((S=u.permissions)==null?void 0:S.canEdit)??u.createdBy===(r==null?void 0:r.id),canDelete:((E=u.permissions)==null?void 0:E.canDelete)??u.createdBy===(r==null?void 0:r.id),canManageMembers:((N=u.permissions)==null?void 0:N.canManageMembers)??u.createdBy===(r==null?void 0:r.id),onBack:()=>v({kind:"list"}),onMembersChanged:j,onUpdated:j,onRequestDelete:()=>D(u)},u.id),m.kind==="create"&&e.jsx(Vs,{isTenantUser:o,tenantId:c,onCancel:()=>v({kind:"list"}),onCreated:y=>{j(),v({kind:"members",groupId:y})}}),f&&e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border bg-muted/40 px-5 py-2.5",children:[e.jsxs("div",{className:"min-w-0 text-[12px] text-foreground",children:["Delete ",e.jsx("span",{className:"font-medium",children:f.name}),"?",e.jsx("span",{className:"ml-2 text-muted-foreground",children:"Members lose any access granted via this group."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>D(null),disabled:w.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-background",children:"Cancel"}),e.jsxs("button",{type:"button",onClick:k,disabled:w.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-rose-600 px-2.5 text-[12px] font-medium text-white hover:bg-rose-700 disabled:opacity-60",children:[w.isPending?e.jsx(d.LoaderCircle,{className:"h-3 w-3 animate-spin"}):e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})]})]})]})})}function Us({groups:t,isLoading:n,errorMessage:a,onRetry:r,currentUserId:o,onOpenGroup:c,onCreate:x,onDeleteRequest:h}){const[p,j]=g.useState(""),l=g.useMemo(()=>t.filter(m=>!p.trim()||m.name.toLowerCase().includes(p.toLowerCase())||(m.description||"").toLowerCase().includes(p.toLowerCase())),[t,p]);return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{className:"flex flex-1 items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(vt.Search,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:p,onChange:m=>j(m.target.value),placeholder:"Search groups…",className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),p&&e.jsx("button",{type:"button",onClick:()=>j(""),className:"flex h-4 w-4 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(U.X,{className:"h-2.5 w-2.5"})})]}),e.jsxs("button",{type:"button",onClick:x,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:n?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(m=>e.jsx("div",{className:"h-12 animate-pulse rounded-[4px] bg-muted/60"},m))}):a?e.jsx(It,{title:"Can't load groups",message:a,onRetry:r}):l.length===0&&t.length===0?e.jsx(Os,{onCreate:x}):l.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsxs("div",{className:"text-[12px] text-foreground",children:['No groups match "',p,'"']}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:"Try a different search."})]}):l.map(m=>{var v;return e.jsx(Fs,{group:m,canDelete:((v=m.permissions)==null?void 0:v.canDelete)??m.createdBy===o,onClick:()=>c(m.id),onDelete:()=>h(m)},m.id)})})]})}function Fs({group:t,canDelete:n,onClick:a,onDelete:r}){let o="";try{o=yt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{o=""}return e.jsxs("button",{type:"button",onClick:a,className:"group flex w-full items-center gap-3 border-b border-border/60 px-5 py-2.5 text-left hover:bg-accent/40",children:[e.jsx("div",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-[4px] border border-border bg-background text-muted-foreground",children:e.jsx(s.UsersRound,{className:"h-3.5 w-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),e.jsxs("div",{className:"mt-0.5 flex items-center gap-2 text-[11px] text-muted-foreground",children:[e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(jt,{className:"h-2.5 w-2.5"}),t.memberCount," member",t.memberCount===1?"":"s"]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-2.5 w-2.5"}),o]})]}),t.description&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:t.description})]})]})]}),e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[n&&e.jsx("span",{role:"button",tabIndex:0,onClick:c=>{c.stopPropagation(),r()},onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&(c.preventDefault(),c.stopPropagation(),r())},"aria-label":`Delete ${t.name}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.Trash2,{className:"h-3 w-3"})}),e.jsx(vt.ChevronRight,{className:"h-3.5 w-3.5 text-muted-foreground"})]})]})}function Os({onCreate:t}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 py-12 text-center",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full border border-border bg-muted/40 text-muted-foreground",children:e.jsx(s.Users,{className:"h-4 w-4"})}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:"No groups yet"}),e.jsx("div",{className:"max-w-[320px] text-[11.5px] leading-[1.55] text-muted-foreground",children:"Groups let you grant shared access to dashboards. Create one and add members."}),e.jsxs("button",{type:"button",onClick:t,className:"mt-1 inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90",children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"New group"]})]})}function Ts({group:t,isTenantViewer:n,canEdit:a,canDelete:r,canManageMembers:o,onBack:c,onMembersChanged:x,onUpdated:h,onRequestDelete:p}){const{data:j,isLoading:l,error:m,refetch:v}=s.useGroupMembers(t.id),f=(j==null?void 0:j.members)??Ps,D=m?Mt(m,"Unable to load members for this group."):null,w=t.type==="TENANT_GROUP"?"tenant":"organization",{users:u}=s.useUnifiedUsers({type:w,tenantId:t.tenantId||void 0,active:!0,limit:200}),k=g.useMemo(()=>new Set(f.map(b=>b.userId)),[f]),S=Es(),E=As(),N=Is(),[y,q]=g.useState(!1),[B,$]=g.useState(t.name),[Se,G]=g.useState(!1),[W,z]=g.useState(t.description||""),[J,X]=g.useState(""),[le,Q]=g.useState(!1),Ce=g.useMemo(()=>{const b=J.trim().toLowerCase();return u.filter(A=>!k.has(A.id)).filter(A=>!b||(A.name||"").toLowerCase().includes(b)||(A.email||"").toLowerCase().includes(b)).slice(0,50)},[u,k,J]),Y=async()=>{const b=B.trim();if(q(!1),b.length>=3&&b!==t.name)try{await N.mutateAsync({groupId:t.id,data:{name:b}}),h()}catch{}},ce=async()=>{const b=W.trim();if(G(!1),b!==(t.description||""))try{await N.mutateAsync({groupId:t.id,data:{description:b}}),h()}catch{}},ue=async b=>{if(o){X(""),Q(!1);try{await S.mutateAsync({groupId:t.id,data:{userIds:[b.id],userType:w==="tenant"?"tenant":"org"}}),v(),x()}catch{}}},ke=async b=>{if(o)try{await E.mutateAsync({groupId:t.id,data:{userIds:[b]}}),v(),x()}catch{}};let F="";try{F=yt.format(new Date(t.createdAt),"MMM d, yyyy")}catch{F=""}return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1.5 border-b border-border px-5",children:[e.jsx("button",{type:"button",onClick:c,"aria-label":"Back",className:"-ml-1 flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground hover:bg-accent hover:text-foreground",children:e.jsx(s.ArrowLeft,{className:"h-3.5 w-3.5"})}),y?e.jsx("input",{autoFocus:!0,value:B,onChange:b=>$(b.target.value),onBlur:Y,onKeyDown:b=>{b.key==="Enter"&&Y(),b.key==="Escape"&&($(t.name),q(!1))},className:"h-6 min-w-0 flex-1 rounded-[3px] border border-border bg-background px-1.5 text-[13px] font-medium text-foreground focus:border-foreground/40 focus:outline-none"}):e.jsx("button",{type:"button",onClick:()=>{a&&($(t.name),q(!0))},title:a?"Click to rename":t.name,disabled:!a,className:"truncate rounded-[3px] px-1 text-[13px] font-medium text-foreground enabled:hover:bg-accent disabled:cursor-default",children:t.name}),e.jsxs("span",{className:"ml-1 inline-flex shrink-0 items-center gap-1 text-[10.5px] text-muted-foreground",children:[e.jsx(jt,{className:"h-2.5 w-2.5"}),f.length," member",f.length===1?"":"s"]})]}),e.jsx("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:Se?e.jsxs("div",{children:[e.jsx("textarea",{autoFocus:!0,rows:2,value:W,onChange:b=>z(b.target.value),maxLength:200,onKeyDown:b=>{b.key==="Escape"&&(z(t.description||""),G(!1)),b.key==="Enter"&&(b.metaKey||b.ctrlKey)&&ce()},placeholder:"What is this group for?",className:"block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[10.5px] text-muted-foreground",children:[W.length,"/200 · Esc to cancel · ⌘↩ to save"]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>{z(t.description||""),G(!1)},className:"h-6 rounded-[5px] px-2 text-[11px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:ce,className:"inline-flex h-6 items-center rounded-[5px] bg-foreground px-2 text-[11px] font-medium text-background hover:opacity-90",children:"Save"})]})]})]}):e.jsxs("button",{type:"button",onClick:()=>{a&&(z(t.description||""),G(!0))},disabled:!a,title:a?"Click to edit description":void 0,className:"block w-full rounded-[3px] px-1 py-0.5 text-left enabled:hover:bg-accent/40 disabled:cursor-default",children:[t.description?e.jsx("p",{className:"text-[12px] leading-[1.55] text-foreground/90",children:t.description}):e.jsx("p",{className:"text-[12px] leading-[1.55] text-muted-foreground",children:a?"Add a description…":"No description"}),e.jsxs("p",{className:"mt-1 text-[10.5px] text-muted-foreground",children:[F?`Created ${F}`:"Recently created",a?" · You can edit this group":""]})]})}),o&&e.jsx(qs,{query:J,setQuery:X,open:le,setOpen:Q,candidates:Ce,showKindChip:!n,onAdd:ue,busy:S.isPending}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:l?e.jsx("div",{className:"space-y-px p-3",children:[1,2,3].map(b=>e.jsx("div",{className:"h-10 animate-pulse rounded-[4px] bg-muted/60"},b))}):D?e.jsx(It,{title:"Can't load members",message:D,onRetry:()=>v()}):f.length===0?e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-1 py-10 text-center",children:[e.jsx("div",{className:"text-[12px] text-foreground",children:"No members yet"}),e.jsx("div",{className:"text-[11px] text-muted-foreground",children:o?"Search above to add people to this group.":"This group does not have any members."})]}):f.map(b=>{var A,Z,_,ee,H,me;return e.jsxs("div",{className:"group flex items-center gap-2 border-b border-border/60 px-5 py-2",children:[e.jsx(Lt,{name:((A=b.user)==null?void 0:A.name)||((Z=b.user)==null?void 0:Z.email)||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12.5px] font-medium text-foreground",children:((_=b.user)==null?void 0:_.name)||((ee=b.user)==null?void 0:ee.email)||"Unknown"}),((H=b.user)==null?void 0:H.email)&&b.user.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:b.user.email})]}),!n&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:b.userType}),e.jsx("button",{type:"button",onClick:()=>ke(b.userId),disabled:!o||E.isPending,"aria-label":`Remove ${((me=b.user)==null?void 0:me.name)||"member"}`,className:"flex h-6 w-6 items-center justify-center rounded-[3px] text-muted-foreground opacity-0 transition-opacity hover:bg-accent hover:text-foreground group-hover:opacity-100 disabled:opacity-30",children:e.jsx(U.X,{className:"h-3 w-3"})})]},b.id)})}),r&&e.jsx("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:e.jsxs("button",{type:"button",onClick:p,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] border border-rose-200 bg-background px-2.5 text-[12px] font-medium text-rose-600 hover:bg-rose-50 dark:border-rose-900/60 dark:text-rose-400 dark:hover:bg-rose-950/30",children:[e.jsx(s.Trash2,{className:"h-3 w-3"}),"Delete group"]})})]})}function Vs({isTenantUser:t,tenantId:n,onCancel:a,onCreated:r}){const[o,c]=g.useState(""),[x,h]=g.useState(""),[p,j]=g.useState(null),l=Ms(),m=o.trim().length>=3&&o.trim().length<=50,v=async()=>{if(!m)return;j(null);const f={name:o.trim(),description:x.trim()||void 0,type:t?"TENANT_GROUP":"ORG_GROUP",...t&&n?{tenantId:n}:{}};try{const D=await l.mutateAsync(f),w=D==null?void 0:D.id;w?r(w):a()}catch(D){j(D instanceof Error?D.message:"Failed to create group")}};return e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4",children:[e.jsx(gt,{children:"Name"}),e.jsx("input",{autoFocus:!0,value:o,onChange:f=>c(f.target.value),placeholder:"Marketing leads, North America sales, …",maxLength:50,className:"mt-1 block h-7 w-full rounded-[5px] border border-border bg-background px-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsx("div",{className:"mt-1 text-[10.5px] text-muted-foreground",children:"3–50 characters."}),e.jsxs("div",{className:"mt-4",children:[e.jsx(gt,{children:"Description (optional)"}),e.jsx("textarea",{rows:2,value:x,onChange:f=>h(f.target.value),maxLength:200,placeholder:"What is this group for?",className:"mt-1 block w-full resize-none rounded-[5px] border border-border bg-background px-2 py-1.5 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-foreground/40 focus:outline-none"}),e.jsxs("div",{className:"mt-1 flex justify-end text-[10.5px] text-muted-foreground",children:[x.length,"/200"]})]}),p&&e.jsx("div",{className:"mt-3 rounded-[5px] border border-rose-200 bg-rose-50 px-2 py-1.5 text-[11.5px] text-rose-700 dark:border-rose-900/60 dark:bg-rose-950/30 dark:text-rose-300",children:p})]}),e.jsxs("div",{className:"flex shrink-0 items-center justify-end gap-1.5 border-t border-border bg-muted/30 px-5 py-2.5",children:[e.jsx("button",{type:"button",onClick:a,disabled:l.isPending,className:"h-7 rounded-[5px] px-2.5 text-[12px] font-medium text-foreground/80 hover:bg-accent",children:"Cancel"}),e.jsx("button",{type:"button",onClick:v,disabled:!m||l.isPending,className:"inline-flex h-7 items-center gap-1.5 rounded-[5px] bg-foreground px-2.5 text-[12px] font-medium text-background hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-60",children:l.isPending?e.jsxs(e.Fragment,{children:[e.jsx(d.LoaderCircle,{className:"h-3 w-3 animate-spin"}),"Creating…"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Plus,{className:"h-3 w-3"}),"Create group"]})})]})]})}function qs({query:t,setQuery:n,open:a,setOpen:r,candidates:o,showKindChip:c,onAdd:x,busy:h}){const p=g.useRef(null),j=g.useRef(null),[l,m]=g.useState(null);g.useLayoutEffect(()=>{if(!a){m(null);return}const f=()=>{const D=p.current;if(!D)return;const w=D.getBoundingClientRect(),u=240,S=window.innerHeight-w.bottom<u+16&&w.top>u;m({left:w.left,top:S?w.top-6:w.bottom+6,width:w.width,above:S})};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[a,o.length]),g.useEffect(()=>{if(!a)return;const f=D=>{var u,k;const w=D.target;(u=p.current)!=null&&u.contains(w)||(k=j.current)!=null&&k.contains(w)||r(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[a,r]);const v=a&&o.length>0&&l;return e.jsxs("div",{className:"shrink-0 border-b border-border px-5 py-2.5",children:[e.jsxs("div",{ref:p,className:"flex items-center gap-2 rounded-[5px] border border-border bg-background px-2 focus-within:border-foreground/40",children:[e.jsx(ds,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("input",{value:t,onChange:f=>{n(f.target.value),r(!0)},onFocus:()=>r(!0),placeholder:"Add a member by name or email…",disabled:h,className:"h-7 flex-1 bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none disabled:cursor-not-allowed"})]}),v&&typeof document<"u"&&Xt.createPortal(e.jsx("div",{ref:j,style:{position:"fixed",left:l.left,top:l.top,width:l.width,transform:l.above?"translateY(-100%)":void 0},className:"z-[60] max-h-[240px] overflow-y-auto rounded-[5px] border border-border bg-background shadow-[0_8px_24px_-12px_rgba(0,0,0,0.18)]",children:o.map(f=>e.jsxs("button",{type:"button",onClick:()=>x(f),className:"flex w-full items-center gap-2 border-b border-border/60 px-2.5 py-2 text-left last:border-b-0 hover:bg-accent",children:[e.jsx(Lt,{name:f.name||f.email||"?"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"truncate text-[12px] font-medium text-foreground",children:f.name||f.email||"Unknown"}),f.email&&f.name&&e.jsx("div",{className:"truncate text-[10.5px] text-muted-foreground",children:f.email})]}),c&&f.type&&e.jsx("span",{className:"text-[10px] uppercase tracking-[0.06em] text-muted-foreground",children:f.type==="tenant"?"tenant":"org"})]},f.id))}),document.body)]})}function Mt(t,n){if(!t)return n;if(t instanceof Error){const a=t.message||"",r=a.match(/\{[\s\S]*"error"\s*:\s*"([^"]+)"[\s\S]*\}/);return r?r[1]:a||n}return typeof t=="string"?t:n}function It({title:t,message:n,onRetry:a}){return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 py-10 text-center",children:[e.jsx("div",{className:"text-[12.5px] font-medium text-foreground",children:t}),e.jsx("div",{className:"max-w-[360px] text-[11.5px] leading-[1.55] text-muted-foreground",children:n}),a&&e.jsx("button",{type:"button",onClick:a,className:"mt-1 inline-flex h-7 items-center rounded-[5px] border border-border bg-background px-2.5 text-[11.5px] font-medium text-foreground hover:bg-accent",children:"Try again"})]})}function gt({children:t}){return e.jsx("label",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:t})}function Lt({name:t}){const n=t.split(" ").map(a=>a[0]).filter(Boolean).slice(0,2).join("").toUpperCase();return e.jsx(Ct,{className:"h-6 w-6 shrink-0",children:e.jsx(kt,{className:"text-[9px] font-semibold",children:n||"?"})})}function ie(t,n,a){var c,x;const r=(t.controls||[]).find(h=>h.id===a);if(r)return r.label;const o=(x=(c=d.findCardById(t,n))==null?void 0:c.controls)==null?void 0:x.find(h=>h.id===a);return(o==null?void 0:o.label)||a}function de(t,n){var a;return((a=d.findCardById(t,n))==null?void 0:a.title)||n}function Bs(t){const{errors:n,dashboard:a}=t;if(!a)return n;const r=new Map;for(const o of n){const c=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing metric '(.+)'\.$/);if(c){const[,l,m]=c,v=`${l}:${m}:missing-metric`;r.has(v)||r.set(v,`"${de(a,l)}" has an outdated "${ie(a,l,m)}" mapping. Some choices still point to metrics that are no longer available on this card. Open the card controls and choose replacements.`);continue}const x=o.match(/^Card '(.+)' binding for control '(.+)' maps to missing group-by field '(.+)'\.$/);if(x){const[,l,m]=x,v=`${l}:${m}:missing-group-by`;r.has(v)||r.set(v,`"${de(a,l)}" has an outdated "${ie(a,l,m)}" mapping. Some choices still point to fields that are no longer available on this card. Open the card controls and choose replacements.`);continue}const h=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid metric target\.$/);if(h){const[,l,m]=h,v=`${l}:${m}:invalid-metric`;r.has(v)||r.set(v,`"${de(a,l)}" has an invalid "${ie(a,l,m)}" metric mapping. Open the card controls and choose a valid metric for each option.`);continue}const p=o.match(/^Card '(.+)' binding for control '(.+)' maps to an invalid group-by target\.$/);if(p){const[,l,m]=p,v=`${l}:${m}:invalid-group-by`;r.has(v)||r.set(v,`"${de(a,l)}" has an invalid "${ie(a,l,m)}" field mapping. Open the card controls and choose a valid field for each option.`);continue}const j=o.match(/^Card '(.+)' binding for control '(.+)' requires at least one temporal group-by field\.$/);if(j){const[,l,m]=j,v=`${l}:${m}:missing-temporal-group-by`;r.has(v)||r.set(v,`"${de(a,l)}" can no longer use "${ie(a,l,m)}" for time grain because the card does not currently group by a date field.`);continue}r.set(o,o)}return Array.from(r.values())}function $s({visible:t,onSelect:n}){return t?e.jsxs(s.DropdownMenuItem,{onSelect:n,children:[e.jsx(s.CalendarClock,{className:"h-3.5 w-3.5"}),"Schedule email report"]}):null}function Gs({scheduleReportVisible:t,analyticalBriefingVisible:n,onScheduleReport:a,onCreateAnalyticalBriefing:r}){return e.jsxs(e.Fragment,{children:[e.jsx($s,{visible:t,onSelect:a}),n?e.jsxs(s.DropdownMenuItem,{onSelect:r,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Create analytical briefing"]}):null]})}function bt(t,n){return{dashboard:s.cloneDeep(t),semanticExecutionPayload:s.cloneDeep(n)}}function zs(){var it,dt,lt,ct,ut,mt,ht;V.useExportRecovery(),V.useExportPolling();const{authToken:t,tokenProps:n,id:a,showBriefings:r}=s.useSemaphorContext(),o=s.useBriefingUiCapabilities(),{isLocalDev:c}=s.useDashboardPreferences(),{openBrandStudioPreview:x}=s.useBrandStudioPreview(),{permissions:h}=xs(),p=s.useHasDashboardId(),{isLoading:j}=s.useDashboardQuery(),l=d.useDashboardStore(i=>i.theme),m=d.useDashboardStore(i=>i.isDownloadingPdf),v=d.useDashboardStore(i=>i.dashboardAssistantDraftScopeKey),f=d.useDashboardStore(i=>i.lenses),D=d.useDashboardStore(i=>i.selectedLensId),w=f==null?void 0:f.find(i=>i.id===D),u=d.useDashboardStore(i=>i.dashboard),k=d.useDashboardStore(i=>i.selectedSheetId),S=(it=u==null?void 0:u.sheets)==null?void 0:it.find(i=>i.id===k),E=d.isDocumentSheet(S),N=E?(dt=S==null?void 0:S.document)==null?void 0:dt.page:void 0,y=d.useDashboardStore(i=>i.isDashboardEditing),{setDashboardTitle:q}=d.useDashboardStore(i=>i.actions),[B,$]=g.useState(!1),[Se,G]=g.useState(!1),[W,z]=g.useState(!1),[J,X]=g.useState(!1),[le,Q]=g.useState(null),[Ce,Y]=g.useState(!1),[ce,ue]=g.useState(!1),[ke,F]=g.useState(!1),[b,A]=g.useState(null),[Z,_]=g.useState([]),[ee,H]=g.useState(!1),[me,He]=g.useState(!1),Ke=d.useDashboardStore(i=>i.filterValues),M=d.useDashboardStore(i=>i.isVisualEditing);d.useEditorStore(i=>i.card);const te=s.useManagementStore(i=>i.selectedDashboard),he=s.useManagementStore(i=>i.initialDashboard);s.useManagementStore(i=>i.selectedVisual),d.useDashboardStore(i=>i.selectedFrameId),d.useEditorStore(i=>i.frame);const pe=te?(ct=te==null?void 0:te.permissions)==null?void 0:ct.canEdit:(lt=he==null?void 0:he.permissions)==null?void 0:lt.canEdit,Qe=d.useDashboardStore(i=>i.showDashboardJSON),Me=d.useDashboardStore(i=>i.onSaveFunction),{setIsDashboardEditing:We,setShowDashboardJSON:Je}=d.useDashboardStore(i=>i.actions),{setInitialDashboard:Xe,clearSelectedDashboard:Ie}=s.useManagementStore(i=>i.actions),se=!!n.orgUserId||!!(n.tenantId&&n.endUserId&&n.endUserEmail),{resources:xe}=s.useResourceManagement(s.ResourceType.DASHBOARD),{data:Le}=s.useUserPreferences(),Et=((ut=Le==null?void 0:Le.preference)==null?void 0:ut.defaultDashboardId)||null,{mutate:At,isPending:Pt}=s.useDefaultDashboardMutation(),{currentUser:Rt}=s.useCurrentUserInfo(),Ut=s.canUserManageGroups(Rt),O=te||he,Ye=O?{id:O.id,title:(u==null?void 0:u.title)||O.title||"Dashboard"}:null,{handleAddNewFrame:Ft}=s.useAddNewFrame(),[Ee,Ae]=g.useState(!1),[Ot,re]=g.useState(!1),[Pe,fe]=g.useState("close"),ae=s.useUpdateResource(s.ResourceType.DASHBOARD),[P,ge]=g.useState(null),Tt=async(i,C)=>{if(!(u!=null&&u.id)){console.log("No dashboard ID found");return}console.log("Updating dashboard title:",{dashboardId:u.id,newTitle:i,previousTitle:C}),ae.mutate({resourceId:u.id,data:{title:i}},{onSuccess:()=>{console.log("Dashboard title updated successfully"),s.ue.success("Dashboard title updated")},onError:R=>{console.error("Failed to update dashboard title:",R),s.ue.error("Failed to update dashboard title"),q(C)}})};g.useEffect(()=>{if(xe&&xe.length>0){const i=u==null?void 0:u.id;if(i){const C=xe.find(R=>R.id===i);C&&Xe(C)}}},[xe,u==null?void 0:u.id,Xe]);const ne=n.orgUserId||n.tenantId,Re=g.useMemo(()=>_s({accessToken:t==null?void 0:t.accessToken,dashboardId:(u==null?void 0:u.id)||a||n.dashboard_id,selectedSheetId:E?k:void 0,pageSize:N==null?void 0:N.size,orientation:N==null?void 0:N.orientation,theme:l}),[t==null?void 0:t.accessToken,a,u==null?void 0:u.id,E,N==null?void 0:N.orientation,N==null?void 0:N.size,k,l,n.dashboard_id]),Ze=y&&!M&&ne&&pe,{setDashboard:et}=d.useDashboardStore(i=>i.actions),tt=d.useDashboardStore(i=>i.semanticExecutionPayload),Vt=()=>{We(!0)},Ue=()=>{We(!1),Je(!1),ge(null)};g.useEffect(()=>{if(!y){P&&ge(null);return}P||!u||j||ge(bt(u,tt))},[u,P,y,j,tt]);const be=(P==null?void 0:P.dashboard)??null,{isDirty:st,isDirtyPending:qt,resetDirty:ve}=Zt.useDebouncedDirtyCheck(u,be,300,1e3,qe.serializeDashboardForDirtyCheck),rt=g.useCallback(()=>be?qe.serializeDashboardForDirtyCheck(u)!==qe.serializeDashboardForDirtyCheck(be):!1,[u,be]),at=st||qt,ye=Ee||ae.isPending,Bt=()=>{rt()?(fe("close"),re(!0)):(Ue(),ve())},$t=async()=>{await Fe({closeAfterSave:!0,navigateHomeAfterSave:Pe==="home"})},Gt=()=>{const i=Pe==="home"&&!!se;P&&et(P.dashboard,{semanticExecutionPayload:P.semanticExecutionPayload}),Ue(),i&&Ie(),fe("close"),re(!1),ve()},zt=()=>{P&&(et(P.dashboard,{semanticExecutionPayload:P.semanticExecutionPayload}),ve())},_t=()=>{if(se){if(y&&rt()){fe("home"),re(!0);return}Ie()}};async function Fe(i){const C=d.useDashboardStore.getState().dashboard;if(!C)return;const R=(i==null?void 0:i.closeAfterSave)??ee,Oe=(i==null?void 0:i.navigateHomeAfterSave)??!1;H(R),R&&re(!1);const Te=s.cloneDeep(C);F(!0),A(null),_([]),Ae(!0);const Jt={template:C};ae.mutate({resourceId:C.id,data:Jt},{onSuccess:I=>{var je,we,pt;const K=(I==null?void 0:I.id)||((je=I==null?void 0:I.dashboard)==null?void 0:je.id)||((we=I==null?void 0:I.resource)==null?void 0:we.id)||((pt=I==null?void 0:I.template)==null?void 0:pt.id)||null;if(!C.id&&K){const Ve=d.useAIInteractionStore.getState(),De=Ve.pendingDashboardDraftMigration;(De==null?void 0:De.scopeKey)===v?Ve.actions.setPendingDashboardDraftMigrationExpectedDashboardId(K):De&&Ve.actions.clearPendingDashboardDraftMigration()}Ae(!1),s.ue.success("Dashboard saved!"),ge(bt(Te,d.useDashboardStore.getState().semanticExecutionPayload)),F(!1),H(!1),R&&(Ue(),ve(),Oe&&se&&Ie()),fe("close")},onError:I=>{Ae(!1),A("Failed to save dashboard. Please try again.");const K=I.details,je=Array.isArray(K==null?void 0:K.errors)?(K.errors||[]).filter(we=>typeof we=="string"):[];_(Bs({errors:je,dashboard:C||void 0})),s.ue.error("Failed to save dashboard")}})}async function Ht(){if($(!0),!D||!w)return;const i=d.useDashboardStore.getState().dashboard;if(!i){$(!1);return}const C=JSON.stringify(i),R=d.useDashboardStore.getState(),Oe=wt({dashboard:i,dashboardInputValues:R.dashboardInputValues,filterValues:Ke,controlValues:R.controlValues,inlineFilterValuesMap:R.inlineFilterValuesMap,cardControlValuesMap:R.cardControlValuesMap}),Te={...w,template:C,filterValues:Ke,inputValues:Oe};await Be(n.apiServiceUrl,Te,t==null?void 0:t.accessToken),s.ue.success("Lens saved"),Me==null||Me(i),$(!1)}const nt=(w==null?void 0:w.name)||u.title;ae.isPending&&console.log("Title during update:",{title:nt,dashboardStateTitle:u.title,dashboardId:u==null?void 0:u.id,currentLensName:w==null?void 0:w.name});const Kt=se&&!!(t!=null&&t.accessToken)&&!!(n!=null&&n.apiServiceUrl),Qt=p&&se,T=(u==null?void 0:u.id)||null,ot=s.resolveDashboardBriefingsVisibility((mt=n.config)==null?void 0:mt.showBriefings,r),oe=!!T&&Et===T,Wt=()=>{T&&At({dashboardId:oe?null:T})};return!p&&!M?null: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:[Qt&&!M&&e.jsx(s.IconButton,{"aria-label":"Dashboard Hub",tooltip:"Dashboard Hub",onClick:_t,className:"h-7 w-7 px-0",buttonProps:{size:"xs"},children:e.jsx(s.House,{className:"h-3.5 w-3.5"})}),!M&&p&&(j?e.jsx("div",{className:"h-4 w-28 animate-pulse rounded-md bg-muted/70","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:nt||"Untitled Dashboard",onSave:i=>{console.log("EditableText onSave called:",{newTitle:i,canEditDashboard:pe,dashboardId:u==null?void 0:u.id});const C=(u==null?void 0:u.title)||"";q(i),Tt(i,C)},isEditable:pe&&!w,displayClassName:"text-[13px] font-medium",inputClassName:"text-[13px] font-medium",placeholder:"Dashboard Title",isPending:ae.isPending}),oe&&e.jsx("span",{className:"shrink-0 rounded-[4px] border border-border/60 px-1.5 py-px text-[10px] font-medium uppercase tracking-[0.06em] text-muted-foreground",title:"Default dashboard",children:"Default"}),Kt&&T&&e.jsx(d.TooltipProvider,{children:e.jsxs(d.Tooltip,{children:[e.jsx(d.TooltipTrigger,{asChild:!0,children:e.jsx(d.Button,{variant:"ghost",size:"xs",onClick:Wt,disabled:Pt||!(t!=null&&t.accessToken)||!(n!=null&&n.apiServiceUrl),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":oe?"Clear default dashboard":"Set as default dashboard",children:oe?e.jsx(s.PinOff,{className:"h-3.5 w-3.5"}):e.jsx(s.Pin,{className:"h-3.5 w-3.5"})})}),e.jsx(d.TooltipContent,{children:e.jsx("p",{children:oe?"Clear default":"Set as default"})})]})})]}))]}),e.jsxs("div",{className:"flex items-center gap-2",children:[M&&e.jsxs(e.Fragment,{children:[e.jsx(V.AdvancedModeToggle,{}),e.jsx(V.VisualEditingControls,{})]}),!M&&p&&((ht=O==null?void 0:O.permissions)==null?void 0:ht.canShare)&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:()=>G(!0),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),!M&&y&&h.canUseFilters&&p&&e.jsx(V.DashboardFilterControlsLauncher,{}),y&&!M&&ne&&w&&c&&p&&e.jsxs(d.Button,{variant:"secondary",size:"xs",disabled:B,onClick:Ht,children:[e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),"Save Lens"]}),y&&!M&&p&&!E&&e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background",children:[e.jsxs(d.Button,{variant:"ghost",size:"xs",disabled:!y,onClick:()=>void Ft(),className:"h-full rounded-none border-0 shadow-none hover:bg-accent",children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Visual"]}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(d.Button,{variant:"ghost",size:"xs",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent","aria-label":"Open visual options",disabled:!y,children:e.jsx(U.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(s.DropdownMenuContent,{align:"end",className:"z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm",children:e.jsxs(s.DropdownMenuItem,{onClick:()=>He(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"From library..."]})})]}),e.jsx(V.VisualsLibraryDialog,{open:me,onOpenChange:He})]}),!M&&!y&&pe&&p&&e.jsxs(d.Button,{size:"xs",onClick:Vt,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit"]}),Ze&&p&&st&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:zt,disabled:ye,children:[e.jsx(s.Undo2,{className:"h-3.5 w-3.5"}),"Undo"]}),Ze&&p&&e.jsxs(d.Button,{size:"xs",className:d.cn(!at&&"opacity-60"),disabled:ye||!at,onClick:()=>Fe(),children:[ye?e.jsx(d.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(xt.Save,{className:"h-3.5 w-3.5"}),ye?"Saving...":"Save"]}),y&&!M&&p&&e.jsxs(d.Button,{variant:"outline",size:"xs",onClick:Bt,children:[e.jsx(s.Cross2Icon,{className:"h-3.5 w-3.5"}),"Close"]}),!M&&p&&e.jsx("div",{className:"ml-2",children:e.jsx(V.NotificationBell,{})}),!M&&c&&e.jsx(ls,{}),!M&&p&&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-control border border-border/60 p-1 shadow-sm",children:[e.jsx(s.DropdownMenuLabel,{children:"Reports & briefings"}),e.jsxs(s.DropdownMenuItem,{disabled:m,onSelect:()=>ue(!0),children:[e.jsx(s.Download,{className:"h-3.5 w-3.5"}),"Export"]}),e.jsx(Gs,{scheduleReportVisible:!!(ot&&o.surfaceVisible&&T&&!y),analyticalBriefingVisible:!!(ot&&o.surfaceVisible&&T&&!y),onScheduleReport:()=>Q("scheduled_report"),onCreateAnalyticalBriefing:()=>Q("analytical_briefing")}),e.jsx(s.DropdownMenuSeparator,{}),Ut&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuLabel,{children:"Access"}),e.jsxs(s.DropdownMenuItem,{onClick:()=>z(!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:()=>X(!0),children:[e.jsx(s.Calendar,{className:"h-3.5 w-3.5"}),"Calendar Preferences"]}),c&&p&&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&&e.jsxs(s.DropdownMenuItem,{disabled:!Re,onSelect:()=>{var i;if(!Re){s.ue.error("Open a document sheet with a token to copy the local PDF URL");return}(i=navigator==null?void 0:navigator.clipboard)!=null&&i.writeText?navigator.clipboard.writeText(Re).then(()=>s.ue.success("Local document PDF URL copied to clipboard")).catch(()=>s.ue.error("Unable to copy local document PDF URL")):s.ue.error("Clipboard not available")},children:[e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),"Copy local document PDF URL"]}),e.jsxs(s.DropdownMenuItem,{onSelect:()=>d.invalidateToken(n.apiServiceUrl),children:[e.jsx(os,{className:"h-3.5 w-3.5"}),"Invalidate token"]}),e.jsxs(s.DropdownMenuItem,{onSelect:x,children:[e.jsx(es.Palette,{className:"h-3.5 w-3.5"}),"Brand Studio"]}),y&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Je(!Qe),children:[e.jsx(ts.Braces,{className:"h-3.5 w-3.5"}),Qe?"Hide dashboard JSON":"Show dashboard JSON"]}),ne&&y&&e.jsxs(s.DropdownMenuItem,{onSelect:()=>Y(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add lens"]}),ne&&e.jsxs(s.DropdownMenuSub,{children:[e.jsxs(s.DropdownMenuSubTrigger,{children:[e.jsx(rs,{className:"h-3.5 w-3.5"}),"Lenses"]}),e.jsx(s.DropdownMenuSubContent,{className:"w-60",children:e.jsx(ps,{})})]})]})]})]}),Se&&Ye&&e.jsx(s.ShareDialog,{resource:Ye,resourceType:s.ResourceType.DASHBOARD,onClose:()=>G(!1)}),e.jsx(Rs,{open:W,onOpenChange:z}),e.jsx(Yt.CalendarPreferencesDialog,{open:J,onOpenChange:X}),T&&le?e.jsx(V.DashboardBriefingLauncher,{dashboardId:T,dashboardTitle:(u==null?void 0:u.title)||(O==null?void 0:O.title),open:!0,onOpenChange:i=>{i||Q(null)},hideTrigger:!0,workflowIntent:le}):null,c&&ne&&p&&e.jsx(hs,{open:Ce,onOpenChange:Y}),p&&e.jsx(s.DownloadPdf,{open:ce,onOpenChange:ue}),e.jsx(s.AlertDialog,{open:ke,onOpenChange:i=>{!i&&Ee&&!b||(F(i),i||(A(null),_([]),H(!1)))},children:e.jsxs(s.AlertDialogContent,{className:"max-w-sm",children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:b?"Save failed":"Saving dashboard"}),e.jsx(s.AlertDialogDescription,{className:"pt-2",children:b?"We could not save the dashboard. Please try again.":"Please wait while we save your changes."}),Z.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:Z.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:b?e.jsxs(e.Fragment,{children:[e.jsx(s.AlertDialogCancel,{onClick:()=>{F(!1),A(null),_([]),H(!1)},className:"m-0",children:"Close"}),e.jsx(s.AlertDialogAction,{onClick:()=>Fe({closeAfterSave:ee,navigateHomeAfterSave:Pe==="home"}),className:"m-0",children:"Retry"})]}):e.jsxs(s.AlertDialogAction,{disabled:!0,className:"m-0 cursor-default",children:[e.jsx(d.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]})})]})}),e.jsx(V.UnsavedChangesAlert,{open:Ot,onOpenChange:i=>{re(i)},onSave:$t,onDiscard:Gt,isSaving:Ee,saveLabel:"Save",discardLabel:"Discard"})]})]})}function _s({accessToken:t,dashboardId:n,selectedSheetId:a,pageSize:r,orientation:o,theme:c}){if(!t||!a)return null;const x=new URL("http://localhost:5173/print-document");x.searchParams.set("token",t),n&&x.searchParams.set("dashboardId",n),x.searchParams.set("selectedSheetId",a),c&&x.searchParams.set("theme",c);const h=new URL("http://127.0.0.1:3002/");return h.searchParams.set("pdfMode","document"),h.searchParams.set("pageSize",r||"letter"),h.searchParams.set("orientation",o||"portrait"),h.searchParams.set("url",x.toString()),h.toString()}exports.default=zs;
|