react-semaphor 0.1.501 → 0.1.502

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +1 -1
  3. package/dist/chunks/{dashboard-briefing-launcher-DfC-k5P3.js → dashboard-briefing-launcher-BeSH0Fcx.js} +872 -861
  4. package/dist/chunks/dashboard-briefing-launcher-CkyDaDQm.cjs +21 -0
  5. package/dist/chunks/{dashboard-controls-DQt2D99m.cjs → dashboard-controls-CJKV_UEh.cjs} +10 -10
  6. package/dist/chunks/{dashboard-controls-CUQUph1I.js → dashboard-controls-CMrdk5DH.js} +603 -593
  7. package/dist/chunks/{dashboard-json-H9GxGLRA.cjs → dashboard-json-Dtt-ZcDP.cjs} +1 -1
  8. package/dist/chunks/{dashboard-json-BHZYDA2F.js → dashboard-json-Hp3rxYdE.js} +2 -2
  9. package/dist/chunks/{edit-dashboard-visual-B8p6XTig.cjs → edit-dashboard-visual-BxsmmZ0X.cjs} +1 -1
  10. package/dist/chunks/{edit-dashboard-visual-hYQMdpjN.js → edit-dashboard-visual-DriCPFXz.js} +3 -3
  11. package/dist/chunks/{editor-action-buttons-DjVEnfLQ.js → editor-action-buttons-Ld5MY-XV.js} +2 -2
  12. package/dist/chunks/{editor-action-buttons-DiRpbCIR.cjs → editor-action-buttons-aAD93tZz.cjs} +1 -1
  13. package/dist/chunks/{index-se8e2QhO.cjs → index-CriMt9Bn.cjs} +123 -123
  14. package/dist/chunks/{index-D-UGbMFA.js → index-tzbGUY7m.js} +3628 -3603
  15. package/dist/chunks/{report-preferences-dialog-B4pIkowU.js → report-preferences-dialog-CabpgTu7.js} +2 -2
  16. package/dist/chunks/{report-preferences-dialog-DwBFTNNN.cjs → report-preferences-dialog-Dtz8hYSB.cjs} +1 -1
  17. package/dist/chunks/{switch-DVjKkt22.cjs → switch-6The8BTM.cjs} +1 -1
  18. package/dist/chunks/{switch-B4wVqV4L.js → switch-Lw3Hbryg.js} +1 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/data-app-builder/index.cjs +1 -1
  22. package/dist/data-app-builder/index.js +2 -2
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +97 -96
  25. package/dist/surfboard/index.cjs +1 -1
  26. package/dist/surfboard/index.js +2 -2
  27. package/dist/types/main.d.ts +8 -1
  28. package/package.json +1 -1
  29. package/dist/chunks/dashboard-briefing-launcher-D6z_n26J.cjs +0 -21
@@ -0,0 +1,21 @@
1
+ "use strict";const e=require("react/jsx-runtime"),m=require("react"),n=require("./switch-6The8BTM.cjs"),s=require("./index-CriMt9Bn.cjs"),ye=require("./layout-grid-xm8pqtx0.cjs"),Y=require("./x-B6ghREd2.cjs"),R=require("./editor-action-buttons-aAD93tZz.cjs"),Ce=require("./constants-DNgpRMaX.cjs");require("./validators-D2F_uxxP.cjs");require("./matrix-operation-contract-thtFuUYf.cjs");require("../value-format-preferences/index.cjs");const Ve=require("./search-BqqhaMx9.cjs"),De=require("./normalize-dashboard-for-dirty-check-BYtBA708.cjs"),_e=require("./mouse-pointer-2-DX4A_XZw.cjs"),Oe=require("./matrix-formatter-CWtdnbfv.cjs");require("./appearance-runtime-provider-Ca8rxO86.cjs");require("./appearance-context-tNjvTJj3.cjs");require("./index-C8XCKzB6.cjs");require("./field-aggregations-mlkON_QA.cjs");require("zod");require("./matrix-continuation-6nhDy-lF.cjs");require("./color-CyB5o13F.cjs");require("react-dom");const K=require("./index-Bh3SlWJS.cjs");/**
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 ze=Y.createLucideIcon("ArrowUpRight",[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]]);/**
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 $e=Y.createLucideIcon("CalendarRange",[["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h18",key:"8toen8"}],["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M17 14h-6",key:"bkmgh3"}],["path",{d:"M13 18H7",key:"bb0bb7"}],["path",{d:"M7 14h.01",key:"1qa3f1"}],["path",{d:"M17 18h.01",key:"1bdyru"}]]);/**
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 qe=Y.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"}]]);/**
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 We=Y.createLucideIcon("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);function He(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((t,r)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},r))})}function Ge({open:t,onOpenChange:r,onSubmit:i,isCreating:a}){const d=s.useSurfaceAppearance("interactive"),[o,u]=m.useState(""),[p,c]=m.useState("");m.useEffect(()=>{t||(u(""),c(""))},[t]);const f=()=>{o.trim()&&i({title:o,description:p})},l=x=>{r(x)};return e.jsx(s.Dialog,{open:t,onOpenChange:l,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",style:d.dialogStyle,children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(ye.LayoutGrid,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"New library visual"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Visual"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>l(!1),"aria-label":"Close",disabled:a,children:e.jsx(Y.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"space-y-3 px-4 py-3",children:[e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Create a saved visual that can be reused across dashboards."}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-title",className:"text-[12px]",children:"Name"}),e.jsx(n.Input,{id:"visual-title",size:"sm",placeholder:"Untitled visual",value:o,onChange:x=>u(x.target.value),disabled:a,onKeyDown:x=>{x.key==="Enter"&&!x.shiftKey&&(x.preventDefault(),f())}})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(n.Label,{htmlFor:"visual-description",className:"text-[12px]",children:"Description"}),e.jsx(n.Input,{id:"visual-description",size:"sm",placeholder:"Optional",value:p,onChange:x=>c(x.target.value),disabled:a})]})]}),e.jsxs("div",{className:"flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>l(!1),disabled:a,children:"Cancel"}),e.jsx(n.Button,{size:"xs",onClick:f,disabled:!o.trim()||a,children:a?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Creating..."]}):"Create library visual"})]})]})})}function ke(t){return t?new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}):"Unknown"}function Ae(t,r){var a;const i=(a=t.ownership.createdBy)==null?void 0:a.type;return i==="tenant"||i==="organization"&&r}function we(t,r){var i,a;return Ae(t,r)?((i=t.ownership.createdBy)==null?void 0:i.name)||((a=t.createdByTenantUserRel)==null?void 0:a.name)||t.lastModifiedBy||"Unknown":"Organization"}function Ke(t,r){return we(t,r).split(/\s+/).filter(Boolean).slice(0,2).map(a=>a.charAt(0).toUpperCase()).join("")||"?"}function Xe(t){const r=(t||"").toLowerCase();return r.includes("table")?n.Table2:r.includes("pie")||r.includes("donut")?s.ChartPie:r.includes("line")?s.ChartLine:r.includes("bar")?n.ChartColumn:ye.LayoutGrid}function Qe({visual:t}){const r=t.ownership.status==="public"?"Public":t.ownership.status==="shared"||t.ownership.sharedCount>0?"Shared":"Private";return e.jsx("span",{className:"inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground",children:r})}function Ye({open:t,onOpenChange:r}){const i=s.useSurfaceAppearance("interactive"),[a,d]=m.useState(""),[o,u]=m.useState(new Set),[p,c]=m.useState(!1),[f,l]=m.useState(null),[x,h]=m.useState(null),[g,b]=m.useState(!1),[k,j]=m.useState(null),[E,S]=m.useState(null),w=()=>{u(new Set),l(null),h(null),b(!1),j(null)},N=()=>{r(!1),w()},{selectVisual:A}=s.useManagementActions(),{handleAddLibraryVisual:T,handleEditLibraryVisual:v}=R.useVisualUtils(),{isConsoleMode:C}=s.useDashboardPreferences(),{resources:L,isLoading:F,isError:$,createResource:B,updateResource:M,deleteResourceAsync:O,duplicateResource:oe,isCreating:X,isDeleting:J}=s.useVisualManagement(void 0,y=>{c(!1),y&&(A(y),v(y),N())}),{startUpdating:he,stopUpdating:xe,isUpdating:ee}=s.useResourceUpdateState(),z=L,H=m.useMemo(()=>{const y=a.trim().toLowerCase();return y?z.filter(I=>{var U,Q,se;return((U=I.title)==null?void 0:U.toLowerCase().includes(y))||((Q=I.description)==null?void 0:Q.toLowerCase().includes(y))||((se=I.kind)==null?void 0:se.toLowerCase().includes(y))}):z},[a,z]),te=m.useMemo(()=>z.filter(y=>o.has(y.id)),[o,z]),G=te.filter(y=>y.permissions.canDelete),me=te.filter(y=>y.permissions.canShare),ie=H.length>0&&H.every(y=>o.has(y.id)),re=H.some(y=>o.has(y.id)),ne=y=>{const I=new Set(o);y(I),u(I)},W=y=>{ne(I=>{I.has(y)?I.delete(y):I.add(y)})},le=()=>{u(y=>{const I=new Set(y);return ie?H.forEach(U=>I.delete(U.id)):H.forEach(U=>I.add(U.id)),I})},V=async y=>{(await T(y)).success&&N()},_=async()=>{const y=te;if(y.length===0)return;let I=!1;for(const U of y)if(!(await T(U)).success){I=!0;break}I||N()},Z=y=>{v(y),N()},ae=y=>{S(y),oe(y,{onSettled:()=>S(null)})},pe=()=>{if(G.length===0){n.ue.error("Select a visual you can delete");return}j(null),b(!0)},ve=async()=>{const y=k?[k]:G;try{for(const I of y)await O(I.id);u(I=>{const U=new Set(I);return y.forEach(Q=>U.delete(Q.id)),U}),b(!1),j(null)}catch{}},de=()=>{if(te.length!==1){n.ue.error("Select one visual to share");return}const[y]=te;if(!y.permissions.canShare){n.ue.error("You do not have permission to share this visual");return}l(y)},ce=({title:y,description:I})=>{if(!x)return;const U={};if(y!==x.title&&(U.title=y),(x.description||"")!==I&&(U.description=I),Object.keys(U).length===0){h(null);return}const Q=Object.keys(U),se=Q.length===1?Q[0]:void 0;he(x.id,se),M({resourceId:x.id,data:U},{onSuccess:()=>{xe(x.id,se),h(null)},onError:()=>{xe(x.id,se)}})},q=y=>{r(y),y||w()},ue=k?1:G.length;return e.jsxs(e.Fragment,{children:[e.jsx(s.Dialog,{open:t,onOpenChange:q,children:e.jsxs(s.DialogContent,{showCloseButton:!1,className:"flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",style:i.dialogStyle,children:[e.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx(n.Table2,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsx(s.DialogTitle,{className:"truncate text-[13px] font-medium leading-none tracking-normal",children:"Visuals library"}),e.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground",children:"Add to dashboard"})]})]}),e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:()=>q(!1),"aria-label":"Close visuals library",children:"×"})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"relative min-w-[12rem] flex-1 md:max-w-md",children:[e.jsx(Ve.Search,{className:"pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:a,onChange:y=>d(y.target.value),placeholder:"Search visuals...",className:"h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none","aria-label":"Search visuals"})]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"ml-auto",onClick:()=>c(!0),children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"New library visual"]})]}),e.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:F?e.jsx("div",{className:"p-3",children:e.jsx(He,{})}):$?e.jsx("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:e.jsx("p",{className:"text-[13px] text-destructive",children:"Failed to load visuals"})}):H.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-2 px-4 py-12 text-center",children:[e.jsx(ye.LayoutGrid,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("p",{className:"text-[13px] font-medium",children:a?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:a?"Try a different search.":"Create a saved visual to add it here."})]}):e.jsx(Ze,{visuals:H,selectedIds:o,allFilteredSelected:ie,someFilteredSelected:re,onSelectAll:le,onToggleSelection:W,onAddVisual:V,onOpenVisual:Z,onEditDetails:h,onShareVisual:l,onDeleteVisual:y=>{j(y),b(!0)},onDuplicateVisual:ae,duplicatingId:E,isDeleting:J,isConsoleMode:C})}),e.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2",children:[e.jsx("div",{className:"flex min-w-0 items-center gap-1.5",children:o.size>0&&e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-[12px] text-muted-foreground",children:[e.jsx("span",{className:"font-medium tabular-nums text-foreground",children:o.size})," ","selected"]}),e.jsx(n.Button,{size:"xs",variant:"ghost",onClick:()=>u(new Set),children:"Clear"}),e.jsxs(n.Button,{size:"xs",variant:"outline",onClick:de,disabled:te.length!==1||me.length!==1,children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsxs(n.Button,{size:"xs",variant:"outline",className:"text-destructive hover:text-destructive",onClick:pe,disabled:G.length===0,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",G.length||o.size]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n.Button,{size:"xs",variant:"outline",onClick:()=>q(!1),children:"Close"}),e.jsxs(n.Button,{size:"xs",onClick:_,disabled:o.size===0,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),o.size===0?"Add to dashboard":`Add ${o.size} visual${o.size===1?"":"s"}`]})]})]})]})}),e.jsx(Ge,{open:p,onOpenChange:c,onSubmit:B,isCreating:X}),f&&e.jsx(s.ShareDialog,{resource:f,resourceType:s.ResourceType.VISUAL,onClose:()=>l(null)}),x&&e.jsx(s.ResourceEditDialog,{open:!!x,resourceLabel:"Visual",initialTitle:x.title||"",initialDescription:x.description||"",onClose:()=>h(null),onSave:ce,isSaving:ee(x.id)}),e.jsx(s.AlertDialog,{open:g,onOpenChange:y=>{!y&&J||(b(y),y||j(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete ",ue," visual",ue===1?"":"s","?"]}),e.jsx(s.AlertDialogDescription,{children:"This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately."})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:J,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:y=>{y.preventDefault(),ve()},disabled:J||ue===0,children:[J?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),J?"Deleting...":"Delete"]})]})]})})]})}function Ze({visuals:t,selectedIds:r,allFilteredSelected:i,someFilteredSelected:a,onSelectAll:d,onToggleSelection:o,onAddVisual:u,onOpenVisual:p,onEditDetails:c,onShareVisual:f,onDeleteVisual:l,onDuplicateVisual:x,duplicatingId:h,isDeleting:g,isConsoleMode:b}){return e.jsxs("div",{className:"min-w-[48rem]",children:[e.jsxs("div",{className:"grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(s.Checkbox,{checked:i?!0:a?"indeterminate":!1,onCheckedChange:d,"aria-label":"Select all visuals"}),e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Created by"}),e.jsx("span",{children:"Updated"}),e.jsx("span",{children:"Visibility"}),e.jsx("span",{className:"text-right",children:"Shared"}),e.jsx("span",{className:"text-right",children:"Actions"})]}),t.map(k=>e.jsx(Je,{visual:k,selected:r.has(k.id),onToggleSelection:o,onAddVisual:u,onOpenVisual:p,onEditDetails:c,onShareVisual:f,onDeleteVisual:l,onDuplicateVisual:x,duplicatingId:h,isDeleting:g,isConsoleMode:b},k.id))]})}function Je({visual:t,selected:r,onToggleSelection:i,onAddVisual:a,onOpenVisual:d,onEditDetails:o,onShareVisual:u,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:f,isDeleting:l,isConsoleMode:x}){var b;const h=Xe(t.kind),g=()=>{a(t)};return e.jsxs("div",{className:n.cn("group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",r&&"bg-muted/70"),children:[e.jsx("div",{children:e.jsx(s.Checkbox,{checked:r,onCheckedChange:()=>i(t.id),"aria-label":`Select ${t.title||"visual"}`})}),e.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",onClick:g,"aria-label":`Add ${t.title||"visual"} to dashboard`,children:[e.jsx(h,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),((b=t.description)==null?void 0:b.trim())&&e.jsx("div",{className:"truncate text-[11px] text-muted-foreground",title:t.description,children:t.description})]})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("div",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground",children:Ke(t,x)}),e.jsx("span",{className:"truncate text-muted-foreground",children:we(t,x)})]}),e.jsx("span",{className:"text-muted-foreground",children:ke(t.updatedAt)}),e.jsx(Qe,{visual:t}),e.jsx("span",{className:"text-right tabular-nums text-muted-foreground",children:t.ownership.sharedCount>0?t.ownership.sharedCount:"—"}),e.jsx(et,{visual:t,onOpenVisual:d,onEditDetails:o,onShareVisual:u,onDeleteVisual:p,onDuplicateVisual:c,duplicatingId:f,isDeleting:l,isConsoleMode:x})]})}function et({visual:t,onOpenVisual:r,onEditDetails:i,onShareVisual:a,onDeleteVisual:d,onDuplicateVisual:o,duplicatingId:u,isDeleting:p,isConsoleMode:c}){return e.jsxs("div",{className:"flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",onClick:f=>f.stopPropagation(),children:[e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0",onClick:()=>r(t),"aria-label":"Edit visual",children:e.jsx(s.PenLine,{className:"h-3.5 w-3.5"})}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.Button,{size:"xs",variant:"ghost",className:"w-7 px-0","aria-label":"More actions",children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",children:[e.jsxs(s.DropdownMenuItem,{onClick:()=>r(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>o(t.id),disabled:u===t.id,children:[u===t.id?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(s.Copy,{className:"h-3.5 w-3.5"}),u===t.id?"Duplicating...":"Duplicate"]}),t.permissions.canEdit&&e.jsxs(s.DropdownMenuItem,{onClick:()=>i(t),children:[e.jsx(s.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),t.permissions.canShare&&e.jsxs(s.DropdownMenuItem,{onClick:()=>a(t),children:[e.jsx(s.Share2,{className:"h-3.5 w-3.5"}),"Share"]}),t.permissions.canDelete&&e.jsxs(e.Fragment,{children:[e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{className:"text-destructive focus:bg-destructive/10 focus:text-destructive",onClick:()=>d(t),disabled:p,children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),p?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[Ae(t,c)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:we(t,c)})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:ke(t.updatedAt)})]})]})]})]})]})}function tt(t,r){const i=m.useCallback(()=>{const a=n.useDashboardStore.getState().dashboard;return r||!t||!a||a.id!==t.id?!1:De.serializeDashboardForDirtyCheck(a)!==De.serializeDashboardForDirtyCheck(t)},[t,r]);return m.useLayoutEffect(()=>(n.useDashboardStore.setState({checkUnsavedDashboardChanges:i}),()=>{n.useDashboardStore.getState().checkUnsavedDashboardChanges===i&&n.useDashboardStore.setState({checkUnsavedDashboardChanges:null})}),[i]),i}function st({open:t,onOpenChange:r,isLibraryVisual:i,currentVisualName:a,isSaving:d=!1,destinationMode:o="both",onConfirm:u}){const[p,c]=m.useState(i&&a?`Copy of ${a}`:a||""),[f,l]=m.useState("");m.useEffect(()=>{t&&(c(i&&a?`Copy of ${a}`:a||""),l(""))},[t,i,a]);const x=!!p.trim(),h=o==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:o==="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"},g=()=>{!x||d||u({name:p.trim(),description:f.trim()||void 0,saveToLibrary:h.saveToLibrary,saveToCurrentDashboard:h.saveToCurrentDashboard})};return e.jsx(s.Dialog,{open:t,onOpenChange:r,children:e.jsxs(s.DialogContent,{className:"sm:max-w-[500px]",children:[e.jsxs(s.DialogHeader,{children:[e.jsxs(s.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Save Visual As"}),h.badgeType!=="local"&&e.jsx(R.VisualBadge,{type:h.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(s.DialogDescription,{children:h.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"name",children:"Name"}),e.jsx(n.Input,{id:"name",value:p,onChange:b=>c(b.target.value),placeholder:"Enter visual name",disabled:d})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(n.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:f,onChange:b=>l(b.target.value),placeholder:"Enter visual description",rows:3,disabled:d})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(n.Button,{variant:"outline",onClick:()=>r(!1),disabled:d,children:"Cancel"}),e.jsxs(n.Button,{onClick:g,disabled:!x||d,children:[d&&e.jsx(n.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h.actionLabel]})]})]})})}function rt(){const[t,r]=m.useState(!1),[i,a]=m.useState(!1),[d,o]=m.useState(null),[u,p]=m.useState(null),c=n.useEditorStore(v=>v.frame),f=n.useEditorStore(v=>v.card),l=s.useSelectedVisual(),x=n.useDashboardStore(v=>v.selectedSheetId),h=n.useDashboardStore(v=>v.dashboard),{getUpdatedFrame:g}=R.useVisualUtils(),{selectVisual:b}=s.useManagementActions(),{addFrame:k,setSelectedFrameId:j,setIsVisualEditing:E}=n.useDashboardActions(),S=s.useResolveExistingFrameSemanticExecutionPayload(),w=!!(c!=null&&c.visualId),N=(()=>{var v,C;return((v=c==null?void 0:c.cards)==null?void 0:v.length)===1&&((C=c.cards[0])!=null&&C.title)?c.cards[0].title:l!=null&&l.title?l.title:(f==null?void 0:f.title)||"Untitled Visual"})(),A=s.useCreateVisualWithFrame(v=>{v!=null&&v.id&&(b(v),i&&d&&u&&x&&(async()=>{try{const C={...d,id:Ce.v4(),visualId:v.id};k(x,C,{position:"end",semanticExecutionPayload:u}),j(C.id),a(!1),o(null),p(null),E(!1)}catch(C){console.error("Failed to promote semantic metadata for saved visual:",C),n.ue.error(C instanceof Error?C.message:"Failed to prepare semantic metadata for the saved visual")}})(),r(!1))});return{saveAsDialogOpen:t,setSaveAsDialogOpen:r,handleSaveAs:async v=>{if(!x){n.ue.error("No sheet selected");return}const C=g(),L=n.getDynamicFrameSaveIssue(C);if(L){n.ue.error(L);return}const $=C.cards.length===1?{...C,cards:C.cards.map(B=>({...B,title:v.name}))}:C;if(v.saveToLibrary){let B=null;if(v.saveToCurrentDashboard)try{B=await S($,{previousFrame:n.findDashboardFrameById(h,$.id)})}catch(O){console.error("Failed to prepare semantic metadata before saving visual:",O),n.ue.error(O instanceof Error?O.message:"Failed to prepare semantic metadata for the saved visual");return}a(v.saveToCurrentDashboard),o($),p(B);const M={title:v.name,description:v.description,frameObject:$,isPrivate:!1};A.mutate(M)}else if(v.saveToCurrentDashboard){const B={...$,id:Ce.v4(),visualId:void 0};try{const M=await S($,{previousFrame:n.findDashboardFrameById(h,$.id)});k(x,B,{position:"end",semanticExecutionPayload:M}),j(B.id),n.ue.success("Visual saved to dashboard"),r(!1),E(!1)}catch(M){console.error("Failed to save visual to dashboard:",M),n.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:w,currentVisualName:N,isSaving:A.isPending}}function nt(t={}){const{isInspectionMode:r}=s.useDashboardInteractionMode(),i=n.useEditorStore(B=>B.frame),a=n.useEditorStore(B=>B.editorContext),d=s.useManagementStore(B=>B.selectedVisual),o=n.useDashboardStore(B=>B.selectedFrameId),u=n.useDashboardStore(B=>B.selectedSheetId),p=n.useDashboardStore(B=>B.dashboard),{setIsVisualEditing:c,updateFrame:f}=n.useDashboardActions(),[l,x]=m.useState(!1),[h,g]=m.useState("both"),b=s.useResolveExistingFrameSemanticExecutionPayload(),k=(a==null?void 0:a.type)==="documentSection",j=!!(i!=null&&i.visualId||d!=null&&d.id),E=!!(i!=null&&i.visualId&&o),S=j&&!E,{saveAsDialogOpen:w,setSaveAsDialogOpen:N,handleSaveAs:A,isLibraryVisual:T,currentVisualName:v,isSaving:C}=rt(),{getUpdatedFrame:L}=R.useVisualUtils();if(r)return e.jsxs(e.Fragment,{children:[e.jsx(R.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(R.EditorCancelButton,{})]});if(k)return e.jsxs(e.Fragment,{children:[e.jsx(R.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(R.EditorCancelButton,{})]});const F=async()=>{if(!u){n.ue.error("No sheet selected");return}if(l)return;x(!0);const B=L(),M=n.getDynamicFrameSaveIssue(B);if(M){x(!1),n.ue.error(M);return}const O={...B,visualId:void 0},oe=n.findDashboardFrameById(p,O.id);try{const X=await b(O,{previousFrame:oe});f(u,O,{semanticExecutionPayload:X})}catch(X){console.error("Failed to apply local semantic metadata:",X),x(!1),n.ue.error(X instanceof Error?X.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{x(!1),n.ue.success("Changes applied. Visual is now local to this dashboard"),c(!1)},300)},$=B=>{g(B),N(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!j&&e.jsx(R.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),j&&S&&e.jsx(R.VisualSaveButton,{className:"!rounded-none",variant:"default"}),j&&E&&e.jsx(R.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(n.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:C||l,children:e.jsx(Y.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[E&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:F,disabled:l,children:[e.jsx(n.Check,{className:"h-3.5 w-3.5"}),l?"Applying...":"Apply Locally"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("local"),disabled:C,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("library"),disabled:C,children:[e.jsx(R.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>$("both"),disabled:C,children:[e.jsx(R.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(R.EditorCancelButton,{}),e.jsx(st,{open:w,onOpenChange:B=>{C||N(B)},isLibraryVisual:T,currentVisualName:v,isSaving:C,destinationMode:h,onConfirm:A})]})}function at({className:t}){const r=n.useEditorStore(l=>l.isDevMode),i=n.useEditorStore(l=>l.card.type),a=n.useDashboardStore(l=>l.isVisualEditing),{setIsDevMode:d}=n.useEditorActions(),{config:o}=m.useContext(s.SemaphorContext).tokenProps,u=(o==null?void 0:o.showAdvancedMode)!==!1;if(!a||!u||!Ce.supportsSqlEditor(i))return null;const p=r?_e.MousePointer2:s.CodeXml,c=r?"Visual editor":"SQL editor",f=r?"Switch to visual editor":"Switch to SQL editor";return e.jsxs("button",{type:"button","aria-label":f,title:f,onClick:()=>d(!r),className:n.cn("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",t),children:[e.jsx(p,{className:"h-3 w-3 text-muted-foreground"}),c]})}function ot({open:t,onOpenChange:r,onSave:i,onDiscard:a,isSaving:d,title:o="Unsaved changes",description:u="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:p="Cancel",discardLabel:c="Discard changes",saveLabel:f="Save"}){const l=x=>{!x&&d||r(x)};return e.jsx(s.AlertDialog,{open:t,onOpenChange:l,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:o}),e.jsx(s.AlertDialogDescription,{children:u})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(n.Button,{type:"button",size:"xs",onClick:a,disabled:d,variant:"outline",className:"mr-auto text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:c}),e.jsx(s.AlertDialogCancel,{disabled:d,children:p}),e.jsx(n.Button,{type:"button",size:"xs",onClick:i,disabled:d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(n.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):f})]})]})})}function Ne(t,r){return{id:t.id,status:t.status,progress:t.progress!==void 0?t.progress:t.status==="completed"?100:t.totalChunks===null?null:t.totalChunks>0?Math.round(t.completedChunks/t.totalChunks*100):0,totalRows:t.totalRows,totalChunks:t.totalChunks,rowsProcessed:t.processedRows,completedChunks:t.completedChunks,completedAt:t.completedAt?new Date(t.completedAt):void 0,lastUpdatedAt:new Date,fileSize:t.fileSize,error:t.error,downloadUrl:r}}const it=1e4,lt=15e3,dt=3e4,ct=3e4,ut=12e4,Se=2*60*60*1e3;function ht(t){const r=Date.now()-t.getTime();return r<ct?it:r<ut?lt:dt}function xt(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),i=s.useExportStore(h=>h.activeExports),[a,d]=m.useState(typeof document<"u"?!document.hidden:!0),o=m.useRef(null),u=m.useRef(!1),p=m.useRef(void 0),c=r==null?void 0:r.apiServiceUrl,f=t==null?void 0:t.accessToken,l=m.useCallback(()=>{const h=s.useExportStore.getState().activeExports;return Array.from(h.values()).filter(g=>s.isExportInProgress(g.status))},[]);m.useEffect(()=>{if(typeof document>"u")return;const h=()=>{d(!document.hidden)};return document.addEventListener("visibilitychange",h),()=>{document.removeEventListener("visibilitychange",h)}},[]);const x=m.useCallback(async()=>{if(!c||!f){u.current=!1;return}const h=l();if(h.length===0){u.current=!1;return}const g=Date.now(),b=h.filter(w=>g-w.startedAt.getTime()>Se);if(b.length>0){const{updateExport:w}=s.useExportStore.getState().actions;for(const N of b)w(N.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const k=h.filter(w=>g-w.startedAt.getTime()<=Se);if(k.length===0){u.current=!1;return}const j=await Promise.allSettled(k.map(async w=>{try{const N=await s.getExportStatus(c,f,w.id);let A;if(N.status==="completed")try{A=await s.getDownloadUrl(c,f,w.id)}catch(T){console.error(`[useExportPolling] Failed to get download URL for ${w.id}:`,T)}return Ne(N,A)}catch(N){return console.error(`[useExportPolling] Failed to poll export ${w.id}:`,N),null}})),{updateExport:E}=s.useExportStore.getState().actions;for(const w of j)w.status==="fulfilled"&&w.value&&E(w.value.id,w.value);const S=l();if(S.length>0&&!document.hidden){const w=S.reduce((A,T)=>T.startedAt<A?T.startedAt:A,S[0].startedAt),N=ht(w);o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{var A;(A=p.current)==null||A.call(p)},N)}else u.current=!1},[c,f,l]);return m.useEffect(()=>{p.current=x},[x]),m.useEffect(()=>{var g;l().length>0&&a&&!u.current&&(u.current=!0,(g=p.current)==null||g.call(p))},[i,a,l]),m.useEffect(()=>{var g;const h=l();a&&h.length>0&&!u.current&&(u.current=!0,(g=p.current)==null||g.call(p))},[a,l]),m.useEffect(()=>{!a&&o.current&&(clearTimeout(o.current),o.current=null,u.current=!1)},[a]),m.useEffect(()=>()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),{isPolling:u.current,isTabVisible:a,inProgressCount:l().length}}function mt(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),i=s.useExportStore(p=>p.activeExports),{addExport:a}=s.useExportActions(),d=m.useRef(!1),o=r==null?void 0:r.apiServiceUrl,u=t==null?void 0:t.accessToken;m.useEffect(()=>{if(d.current||!o||!u)return;(async()=>{try{const{exports:c}=await s.getExports(o,u,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const f of c){if(i.has(f.id))continue;let l;if(f.status==="completed")try{l=await s.getDownloadUrl(o,u,f.id)}catch(h){console.error(`[useExportRecovery] Failed to get download URL for ${f.id}:`,h)}const x={...Ne(f,l),title:pt(f),startedAt:new Date(f.createdAt),expiresAt:new Date(f.expiresAt)};a(x)}d.current=!0}catch(c){console.error("[useExportRecovery] Failed to recover exports:",c),d.current=!0}})()},[o,u,a,i])}function pt(t){return t.title?t.title:s.isExportInProgress(t.status)?"Export in progress...":t.status==="completed"?"Export completed":t.status==="failed"?"Export failed":"Export"}function Be({export:t,onRemove:r,onDownload:i}){const[a,d]=m.useState("idle");m.useEffect(()=>{t.downloadUrl&&d("idle")},[t.downloadUrl]);const o=async()=>{if(!i){t.downloadUrl&&window.open(t.downloadUrl,"_blank");return}d("preparing");const b=await i(t);d(b==="denied"?"denied":"idle")},u=b=>{b.stopPropagation(),r==null||r(t.id)},p=s.isExportInProgress(t.status),c=(()=>{switch(t.status){case"pending":return"Queued...";case"compacting":return"Finalizing...";default:return"Processing..."}})(),f=t.status==="completed"?"bg-emerald-500":t.status==="failed"?"bg-destructive":t.status==="pending"?"bg-muted-foreground/40":"animate-pulse bg-muted-foreground/60",l=t.status==="completed"?"Ready":t.status==="failed"?"Failed":"In progress",x=Oe.formatDistanceToNow(t.startedAt,{addSuffix:!0}),h=[t.status==="completed"&&t.totalRows!==null?`${t.totalRows.toLocaleString()} rows`:null,t.status==="completed"&&t.fileSize?s.formatFileSize(t.fileSize):null].filter(b=>!!b),g=e.jsx("span",{className:"text-muted-foreground/50",children:"·"});return e.jsxs("div",{className:"group flex items-start gap-2.5 px-3 py-2 transition-colors hover:bg-muted/40 focus-within:bg-muted/40",children:[e.jsx("span",{className:"flex h-5 shrink-0 items-center","aria-hidden":"true",children:e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${f}`})}),e.jsx("span",{className:"sr-only",children:l}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex h-5 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] font-medium leading-5",children:t.title}),t.status==="completed"&&a==="preparing"&&e.jsxs("span",{role:"status",className:"inline-flex shrink-0 items-center gap-1.5 text-[12px] text-muted-foreground",children:[e.jsx(s.RefreshCw,{className:"h-3 w-3 animate-spin",strokeWidth:1.75}),"Preparing"]}),t.status==="completed"&&a!=="preparing"&&e.jsx("button",{type:"button",onClick:()=>void o(),className:"shrink-0 text-[12px] font-medium text-foreground/80 underline-offset-2 hover:text-foreground hover:underline focus-visible:underline focus-visible:outline-none",children:"Download"}),e.jsx(n.Button,{variant:"ghost",size:"xs",className:"-mr-1.5 h-5 w-5 shrink-0 px-0 text-muted-foreground opacity-0 transition-opacity hover:text-foreground focus-visible:opacity-100 group-hover:opacity-100 group-focus-within:opacity-100",onClick:u,"aria-label":"Remove notification",title:"Remove",children:e.jsx(Y.X,{className:"h-3.5 w-3.5",strokeWidth:1.75})})]}),!p&&t.status!=="failed"&&e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] leading-4 text-muted-foreground",children:[h.length>0&&e.jsxs("span",{className:"hidden group-hover:contents group-focus-within:contents",children:[h.map((b,k)=>e.jsxs(m.Fragment,{children:[k>0&&g,e.jsx("span",{children:b})]},k)),g]}),e.jsx("span",{children:x})]}),t.status==="completed"&&a==="denied"&&e.jsxs("div",{role:"alert",className:"mt-1 flex items-start gap-1.5 text-[12px] leading-4 text-foreground",children:[e.jsx(s.CircleAlert,{className:"mt-0.5 h-3 w-3 shrink-0 text-destructive",strokeWidth:1.75}),e.jsx("span",{children:"This link expired. Refresh the tray to sign the file again."})]}),p&&e.jsxs("div",{className:"text-[12px] leading-4 text-muted-foreground",children:[c,(t.progress!==null||t.rowsProcessed!==void 0)&&e.jsxs(e.Fragment,{children:[" ",g," ",e.jsx("span",{className:"tabular-nums",children:t.progress===null?`${t.rowsProcessed.toLocaleString()} rows processed`:`${t.progress}% complete`})]}),t.progress!==null&&e.jsx(s.Progress,{value:t.progress,className:"mt-1.5 h-1"})]}),t.status==="failed"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px] leading-4 text-muted-foreground",children:[e.jsx("span",{children:"Failed"}),g,e.jsx("span",{children:x})]}),e.jsx("div",{className:"mt-1 whitespace-pre-wrap break-words text-[12px] leading-4 text-destructive",children:t.error||"Export failed"})]})]})]})}function Fe(){const{authToken:t,tokenProps:r}=s.useSemaphorContext(),i=s.useExportStore(j=>j.activeExports),{clearCompleted:a,removeExport:d,updateExport:o}=s.useExportActions(),[u,p]=m.useState(!1),[c,f]=m.useState(!1),l=Array.from(i.values()).sort((j,E)=>E.startedAt.getTime()-j.startedAt.getTime()),x=l.some(j=>j.status==="completed"||j.status==="failed"),h=m.useCallback(async()=>{const j=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!(!j||!E)){p(!0);try{const S=Array.from(i.values());await Promise.all(S.map(async w=>{try{const N=await s.getExportStatus(j,E,w.id);let A;if(N.status==="completed")try{A=await s.getDownloadUrl(j,E,w.id)}catch(T){console.error(`Failed to get download URL for ${w.id}:`,T)}o(w.id,Ne(N,A))}catch(N){o(w.id,{downloadUrl:void 0}),console.error(`Failed to refresh export ${w.id}:`,N)}}))}finally{p(!1)}}},[i,t==null?void 0:t.accessToken,r==null?void 0:r.apiServiceUrl,o]),g=m.useCallback(async()=>{const j=r==null?void 0:r.apiServiceUrl,E=t==null?void 0:t.accessToken;if(!j||!E){a();return}f(!0);try{const S=l.filter(N=>N.status==="completed"||N.status==="failed"),w=await Promise.allSettled(S.map(async N=>(await s.cancelExport(j,E,N.id),N.id)));for(const N of w)N.status==="fulfilled"?d(N.value):console.error("Failed to delete export:",N.reason)}finally{f(!1)}},[l,r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,a,d]),b=m.useCallback(async j=>{const E=r==null?void 0:r.apiServiceUrl,S=t==null?void 0:t.accessToken;if(E&&S)try{await s.cancelExport(E,S,j),d(j);return}catch(w){console.error(`Failed to cancel export ${j}:`,w)}d(j)},[r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,d]),k=m.useCallback(async j=>{if(j.downloadUrl)return window.open(j.downloadUrl,"_blank"),"opened";const E=r==null?void 0:r.apiServiceUrl,S=t==null?void 0:t.accessToken;if(!E||!S)return"denied";try{const w=await s.getDownloadUrl(E,S,j.id);return o(j.id,{downloadUrl:w}),window.open(w,"_blank"),"opened"}catch(w){return console.error(`Failed to get download URL for ${j.id}:`,w),o(j.id,{downloadUrl:void 0}),"denied"}},[r==null?void 0:r.apiServiceUrl,t==null?void 0:t.accessToken,o]);return l.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-6 py-8 text-center",children:[e.jsx("span",{className:"flex h-8 w-8 items-center justify-center rounded-[6px] border border-border text-muted-foreground",children:e.jsx(qe,{className:"h-3.5 w-3.5",strokeWidth:1.75})}),e.jsx("p",{className:"text-[13px] font-medium",children:"No exports yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Large exports run in the background and land here."})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex h-8 items-center gap-2 border-b border-border px-3",children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Exports"}),e.jsx("span",{className:"text-[10px] tabular-nums text-muted-foreground/70",children:l.length}),e.jsxs("div",{className:"ml-auto flex items-center gap-0.5",children:[x&&e.jsx(n.Button,{variant:"ghost",size:"xs",className:"h-6 px-1.5 text-[12px] text-muted-foreground hover:text-foreground",onClick:g,disabled:c,children:c?"Clearing":"Clear all"}),e.jsx(n.Button,{variant:"ghost",size:"xs",className:"h-6 w-6 px-0 text-muted-foreground hover:text-foreground",onClick:h,disabled:u,title:"Refresh status","aria-label":"Refresh status",children:e.jsx(s.RefreshCw,{strokeWidth:1.75,className:`h-3.5 w-3.5 ${u?"animate-spin":""}`})})]})]}),e.jsx("div",{className:"max-h-[320px] overflow-y-auto",children:e.jsx("div",{className:"divide-y divide-border/70",children:l.map(j=>e.jsx(Be,{export:j,onRemove:b,onDownload:k},j.id))})})]})}function ft({variant:t}){const r=s.useExportStore(c=>c.activeExports),i=s.useInProgressExportsCount(),a=r.size>0,d=Array.from(r.values()).some(c=>c.status==="completed"||c.status==="failed"),u=i>0?i>9?"9+":String(i):null,p=a;return e.jsxs(n.Popover,{children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:t??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[e.jsx(s.Bell,{className:"h-3.5 w-3.5"}),p&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${u?"-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:u})]})}),e.jsx(n.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(Fe,{})})]})}function gt(t){if(t)return{renamed:t.type==="rename"?{oldId:t.oldId,newId:t.newId}:void 0,removedControlId:t.type==="remove"?t.controlId:void 0,cardBindingsById:t.type==="add"||t.type==="update"?t.cardBindingsById:void 0,affectedBindingControlIds:t.type==="add"||t.type==="update"?t.affectedBindingControlIds:void 0}}function Ie({open:t,onOpenChange:r,trigger:i,showTrigger:a=!0,initialMode:d="manage"}){const o=d==="create",{forceClose:u,handleOpenChange:p,isCreateFlowActive:c,preventPassiveDismissDuringCreate:f,resolvedOpen:l,setIsCreateFlowActive:x}=R.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:d==="create",dismissMode:a?"passive":"explicit-only"}),h=n.useDashboardStore(C=>C.dashboard),{setDashboardControlsModel:g}=n.useDashboardActions(),{participants:b}=s.useDashboardStructuralParticipants(n.getDashboardCards(h)),k=Array.from(new Map(b.flatMap(C=>C.fieldChoices.map(L=>{var F;return[L.value,{option:L,target:(F=C.fieldTargetMap)==null?void 0:F[L.value]}]}))).values()),j=Array.from(new Map(b.flatMap(C=>C.metricChoices.map(L=>{var F;return[L.value,{option:L,target:(F=C.metricTargetMap)==null?void 0:F[L.value]}]}))).values()),E=n.collectDashboardControlIds({...h||{},controls:[]}),S=s.buildDashboardStructuralParticipantIdsByControlId(h),w=(C,L,F)=>{g(C,L,gt(F))},N=m.useCallback(()=>{if(o){u();return}x(!1)},[o,u,x]),A=e.jsx(R.ControlDefinitionListEditor,{scope:"dashboard",controls:h.controls||[],reservedControlIds:E,defaultValues:h.defaultControlValues||{},usageByControlId:s.buildDashboardControlUsageById(h),availableFieldChoices:k,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:S,initialCreateFlow:d==="create",onCreateFlowActiveChange:x,onCreateFlowComplete:N,onChange:w,emptyMessage:"No dashboard controls yet."}),T=c?"Add dashboard control":"Dashboard Controls",v=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),e.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."})]}),A]});return a?e.jsxs(n.Popover,{open:l,onOpenChange:p,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:i||e.jsxs(n.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(n.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(n.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:f,onPointerDownOutside:f,children:v})]}):e.jsx(s.Dialog,{open:l,onOpenChange:p,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:f,onPointerDownOutside:f,children:[e.jsxs(s.DialogHeader,{className:c?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:c?"sr-only":"text-[13px]",children:c?"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."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:A})]})})}const bt=["enum","multi_enum","text","number","boolean","date"];function Le({open:t,onOpenChange:r,initialMode:i="manage"}){var v;const a=i==="create",{forceClose:d,handleOpenChange:o,isCreateFlowActive:u,preventPassiveDismissDuringCreate:p,resolvedOpen:c,setIsCreateFlowActive:f}=R.useCreateFlowOverlayState({open:t,onOpenChange:r,initialCreateFlowActive:i==="create",dismissMode:"explicit-only"}),l=n.useDashboardStore(C=>C.dashboard),x=n.useDashboardStore(C=>C.selectedSheetId),{setDashboardInputs:h}=n.useDashboardActions(),g=(v=l.sheets)==null?void 0:v.find(C=>C.id===x),b=(g==null?void 0:g.kind)==="document"&&!!g.document,k=m.useMemo(()=>b&&(g!=null&&g.document)?s.getDocumentSheetDashboardInputs(l,g.id):[],[l,b,g==null?void 0:g.document,g==null?void 0:g.id]),j=m.useMemo(()=>k.filter(C=>C.kind==="control"),[k]),E=m.useMemo(()=>j.map(C=>C.control),[j]),S=m.useMemo(()=>jt(E),[E]),w=m.useMemo(()=>vt(l),[l]),N=m.useCallback(()=>{if(a){d();return}f(!1)},[a,d,f]),A=m.useCallback((C,L,F)=>{!b||!(g!=null&&g.document)||h(yt({allInputs:l.inputs||[],documentSheetId:g.id,currentDocumentInputs:k,nextControls:C,nextDefaultValues:L,change:F}))},[l.inputs,k,b,g,h]);if(!b||!(g!=null&&g.document))return null;const T=u?"Add document control":"Document Controls";return e.jsx(s.Dialog,{open:c,onOpenChange:o,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:p,onPointerDownOutside:p,children:[e.jsxs(s.DialogHeader,{className:u?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:T}),e.jsx(s.DialogDescription,{className:u?"sr-only":"text-[13px]",children:u?"Configure and add a document-local control input.":"Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:e.jsx(R.ControlDefinitionListEditor,{scope:"dashboard",controls:E,reservedControlIds:w,defaultValues:S,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:bt,initialCreateFlow:i==="create",onCreateFlowActiveChange:f,onCreateFlowComplete:N,onChange:A,emptyMessage:"No document controls yet."})})]})})}function vt(t){return(t.controls||[]).map(r=>r.id)}function jt(t){const r={};for(const i of t)i.defaultValue!==void 0&&(r[i.id]=i.defaultValue);return r}function Ct(t,r){return r?Object.prototype.hasOwnProperty.call(r,t.id)?{...t,defaultValue:r[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function yt({allInputs:t,documentSheetId:r,currentDocumentInputs:i,nextControls:a,nextDefaultValues:d,change:o}){const u=new Map(a.map(h=>[h.id,Ct(h,d)])),p=(o==null?void 0:o.type)==="rename"?{oldId:o.oldId,newId:o.newId}:null,c=new Set,f=[];for(const h of i){if(h.kind!=="control"){f.push(h);continue}const g=u.get(h.control.id)||((p==null?void 0:p.oldId)===h.control.id?u.get(p.newId):void 0);if(!g)continue;c.add(g.id);const b=n.createUniqueDashboardInputVariableNameFromName(g.id,[...t,...f].filter(j=>j.id!==h.id)),k=g.id===b?g:{...g,id:b};f.push({...h,label:k.label,variableName:b,requiredAtExecution:k.requiredAtExecution,control:k})}for(const h of u.values())c.has(h.id)||f.push(s.createDashboardControlInputFromControl({control:h,existingInputs:[...t,...f],sheetId:r}));const l=new Set(i.map(h=>h.id));return[...t.filter(h=>!l.has(h.id)),...f]}function Te({showFilters:t,onShowFiltersChange:r,pickerContent:i,settingsContent:a,size:d="default",className:o,primaryButtonClassName:u,secondaryButtonClassName:p,pickerContentClassName:c,settingsContentClassName:f}){const l=d==="toolbar",[x,h]=m.useState(!1),g=s.useSurfaceAppearance("interactive");return e.jsxs("div",{className:n.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",l?"h-8":"h-7",o),children:[e.jsxs(n.Popover,{open:t,onOpenChange:r,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsxs(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",u),children:[t?e.jsx(R.FilterX,{className:"h-3.5 w-3.5"}):e.jsx(s.Filter,{className:"h-3.5 w-3.5"}),"Filter"]})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",c),style:g.contentStyle,children:i})]}),e.jsxs(n.Popover,{open:x,onOpenChange:h,children:[e.jsx(n.PopoverTrigger,{asChild:!0,children:e.jsx(n.Button,{variant:"ghost",size:"xs",className:n.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",p),"aria-label":"Filter and control actions",children:e.jsx(Y.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(n.PopoverContent,{align:"end",sideOffset:6,className:n.cn("w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",f),style:g.contentStyle,children:a(()=>h(!1))})]})]})}function wt(){R.useSyncLegacyEditorState();const t=n.useDashboardStore(c=>c.selectedSheetId),r=n.useDashboardStore(c=>c.selectedFrameId),i=n.useDashboardStore(c=>c.dashboard),a=n.useDashboardStore(c=>c.actions.getSelectedFrame),{setSelectedFrameId:d}=n.useDashboardActions(),{setCard:o}=n.useEditorActions(),u=n.useEditorStore(c=>c.card.dataSource);return m.useEffect(()=>{var f,l;let c=a();if(!c){const x=(f=i==null?void 0:i.sheets)==null?void 0:f.find(g=>g.id===t),h=(l=x==null?void 0:x.frames)==null?void 0:l[0];h&&(d(h.id),c=h)}if(c){const x=c.cards.find(h=>h.id===c.activeCardId);x&&o(x)}},[a,t,r,i,d,o]),{hasEntities:!!(u!=null&&u.selectedEntities&&u.selectedEntities.length>0)}}function Nt(){const t=n.useDashboardStore(c=>c.dashboard),r=n.useDashboardStore(c=>c.semanticExecutionPayload),i=n.useDashboardStore(c=>c.actions.addFilter),{hasEntities:a}=wt(),{isLoading:d}=s.useFilterableFields(),o=m.useMemo(()=>n.getGlobalDateFilterCoverage(t,r),[t,r]),p=!n.getGlobalDateFilter(t.filters)&&o.hasEligibleCards&&!d;return e.jsxs("div",{className:"flex h-[520px] w-[400px] flex-col",children:[p&&e.jsx("div",{className:"border-b border-border/60 p-2",children:e.jsxs("button",{type:"button",onClick:()=>i(n.createDefaultGlobalDateFilter()),title:`Applies to ${o.eligibleCardCount} of ${o.totalCardCount} date-aware cards`,className:"flex w-full items-start gap-2 rounded-control px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",children:[e.jsx($e,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("span",{className:"flex min-w-0 flex-col",children:[e.jsx("span",{className:"text-[12px] font-medium text-foreground",children:"Add global date filter"}),e.jsx("span",{className:"text-[11px] leading-[1.4] text-muted-foreground",children:"One date range across all date-aware cards."})]})]})}),!a&&e.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center px-6 py-8 text-center",children:[e.jsx(s.Database,{className:"mb-3 h-10 w-10 text-muted-foreground/50"}),e.jsx("h3",{className:"mb-1 text-[13px] font-medium text-foreground",children:"No fields configured"}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Configure a data source for this card to enable filtering."})]}),a&&e.jsx("div",{className:"flex flex-1 overflow-hidden",children:e.jsx(s.FilterableFieldsPanel,{context:"filter"})})]})}const Ee=!1;function Dt({onAddFilter:t,onAddControl:r,onManageControls:i,onDismiss:a}){const d=n.useDashboardStore(p=>p.dashboard.filterLayout),{setFilterLayout:o}=n.useDashboardActions();d!=null&&d.displayMode;const u=(d==null?void 0:d.toolbarWrap)??!1;return d==null||d.showDownloadButton,e.jsxs("div",{className:"w-[300px]",children:[e.jsxs("div",{className:"p-1",children:[e.jsx(je,{icon:s.Filter,label:"Add filter",onClick:()=>{t(),a()}}),e.jsx(je,{icon:n.SlidersHorizontal,label:"Add control",onClick:()=>{r(),a()}}),e.jsx(je,{icon:s.Pencil,label:"Manage controls",onClick:()=>{i(),a()}})]}),e.jsx("div",{className:"border-t border-border/60"}),e.jsxs("div",{className:"space-y-1 p-2",children:[e.jsx("p",{className:"px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display"}),Ee,e.jsx(St,{id:"filter-display-wrap",label:"Wrap to multiple lines",checked:u,onCheckedChange:p=>o({toolbarWrap:p===!0})}),Ee]})]})}function je({icon:t,label:r,onClick:i}){return e.jsxs("button",{type:"button",onClick:i,className:"flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-muted-foreground"}),r]})}function St({id:t,label:r,checked:i,onCheckedChange:a}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-control px-1 py-1 transition-colors hover:bg-muted/40 focus-within:bg-muted/40",children:[e.jsx(s.Checkbox,{id:t,checked:i,onCheckedChange:a}),e.jsx(n.Label,{htmlFor:t,className:"cursor-pointer text-[12px] font-normal leading-[1.3]",children:r})]})}function Et({size:t,className:r,primaryButtonClassName:i,secondaryButtonClassName:a,pickerContentClassName:d,settingsContentClassName:o}){var T;const[u,p]=m.useState(null),c=n.useDashboardStore(v=>v.dashboard),f=n.useDashboardStore(v=>v.selectedSheetId),l=n.useDashboardStore(v=>v.showFilters),x=s.useAssistantLayoutStore(v=>v.setPanelOpen),h=n.useDashboardStore(v=>v.actions),{setDocumentInspectorTab:g,setShowFilters:b}=h,k=(T=c.sheets)==null?void 0:T.find(v=>v.id===f),j=n.isDocumentSheet(k),E=m.useCallback(v=>{window.setTimeout(()=>{p(v)},0)},[]),S=m.useCallback(v=>{if(j&&f){v&&g(f,"inputs");return}v&&x("dashboard",!1),b(v)},[j,f,g,x,b]),w=m.useCallback(()=>{S(!0)},[S]),N=m.useCallback(()=>{E("create")},[E]),A=m.useCallback(()=>{E("manage")},[E]);return e.jsxs(e.Fragment,{children:[e.jsx(Te,{showFilters:j?!1:l,onShowFiltersChange:S,pickerContent:e.jsx(Nt,{}),settingsContent:v=>e.jsx(Dt,{onAddFilter:w,onAddControl:N,onManageControls:A,onDismiss:v}),size:t,className:r,primaryButtonClassName:i,secondaryButtonClassName:a,pickerContentClassName:d,settingsContentClassName:o}),u?j?e.jsx(Le,{open:!0,onOpenChange:v=>{v||p(null)},initialMode:u}):e.jsx(Ie,{open:!0,onOpenChange:v=>{v||p(null)},showTrigger:!1,initialMode:u}):null]})}function Me({disabled:t,briefingCount:r,className:i,onClick:a}){const d=typeof r=="number"&&r>0;return e.jsxs(n.Button,{type:"button",size:"xs",variant:"outline",disabled:t,className:n.cn("gap-1.5",i),onClick:a,"aria-label":"Reports & briefings",children:[e.jsx(We,{className:"h-3.5 w-3.5"}),"Reports & briefings",d?e.jsx("span",{className:"ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70",children:r}):null]})}const kt="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",Pe="inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50",be="inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";function At(t){return t==="dashboard"?"This dashboard":"Project"}function Bt(t){if(!t)return"Never";const r=new Date(t);if(Number.isNaN(r.getTime()))return"Unknown";const i=Date.now()-r.getTime(),a=Math.round(i/6e4);if(a<1)return"now";if(a<60)return`${a}m ago`;const d=Math.round(a/60);if(d<24)return`${d}h ago`;const o=Math.round(d/24);if(o<7)return`${o}d ago`;const u=Math.round(o/7);return u<5?`${u}w ago`:`${Math.round(o/30)}mo ago`}function Ft(t){return t.scheduleExpr?K.describeBriefingSchedule(t.scheduleExpr,t.timezone||"UTC")??"Invalid schedule":"On demand"}function It(t){if(t.lastRunStatus){const r=t.lastRunStatus.toString().toUpperCase();return r==="SUCCESS"?"Last run completed.":r==="FAILED"?"Last run failed.":`Last run ${t.lastRunStatus.toString().toLowerCase()}`}return null}function Re(t){return t.hasActiveRun?"Running":t.lastRunStatus?`Last run ${t.lastRunStatus.toString().toLowerCase()}`:"Idle"}function Lt(t){return t.source.type==="dashboard"?"This dashboard":"Project"}function Tt({activeView:t,onChange:r}){return e.jsx("div",{className:"flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",role:"tablist","aria-label":"Briefing source view",children:["dashboard","project"].map(i=>{const a=t===i;return e.jsx("button",{type:"button",role:"tab","aria-selected":a,onClick:()=>r(i),className:n.cn("h-6 rounded-[3px] px-2 text-[11px] transition-colors",a?"bg-background font-medium text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"),children:At(i)},i)})})}function Mt({briefings:t,dashboardLabel:r,sourceView:i,error:a,loading:d,onSourceViewChange:o,onClose:u,onEdit:p,onNew:c,canCreate:f,canCreateScheduledReport:l,analyticalBriefingsEnabled:x,onRunNow:h,onTogglePause:g,onDelete:b,selectingId:k,busyId:j,manageBriefingsHref:E,contentKind:S,hideHeader:w=!1}){const N=t.length,A=t.filter(F=>F.status==="ACTIVE").length,T=S==="reports"?N===1?"report":"reports":S==="briefings"?N===1?"briefing":"briefings":N===1?"item":"items",v=t.find(F=>F.hasActiveRun)??null,C=S??"reports & briefings",L=i==="dashboard"?r:`Project ${C}`;return e.jsxs("section",{"aria-label":`Dashboard ${C.replace("&","and")}`,className:"flex h-full min-h-0 flex-col bg-background text-foreground",children:[w?null:e.jsxs("header",{className:"flex items-start justify-between gap-3 border-b border-border px-4 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:kt,children:C}),e.jsx("h2",{className:"mt-0.5 truncate text-[14px] font-semibold leading-5",children:L})]}),e.jsx("button",{type:"button",onClick:u,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":`Close ${C.replace("&","and")} panel`,children:e.jsx(Y.X,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-border px-4 py-2",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx(Tt,{activeView:i,onChange:o}),e.jsx("div",{className:"flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground",children:d&&N===0?e.jsxs("span",{children:["Loading ",C,"…"]}):N===0?e.jsxs("span",{children:["No ",C," yet"]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"font-medium text-foreground/80",children:[N," ",T]}),e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:[A," active"]})]})})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[d?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground"}):null,N>0&&f?x&&l?e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsxs("button",{className:be,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New"]})}),e.jsxs(s.DropdownMenuContent,{align:"end",children:[e.jsx(s.DropdownMenuItem,{onClick:()=>c("scheduled_report"),children:"Schedule a report"}),e.jsx(s.DropdownMenuItem,{onClick:()=>c("analytical_briefing"),children:"Create analytical briefing"})]})]}):l?e.jsxs("button",{onClick:()=>c("scheduled_report"),className:be,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule report"]}):x?e.jsxs("button",{onClick:()=>c("analytical_briefing"),className:be,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," New briefing"]}):null:null]})]}),v?e.jsxs("div",{className:"flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]",children:[e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground"}),e.jsx("span",{className:"font-medium text-foreground",children:v.name}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{className:"truncate text-muted-foreground",children:Re(v)})]}):null,e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[a?e.jsx("div",{className:"m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive",children:a}):null,!d&&t.length===0&&!a?e.jsx(Pt,{onNew:c,canCreate:f,canCreateScheduledReport:l,analyticalBriefingsEnabled:x,contentKind:S}):null,t.map(F=>e.jsx(Ut,{briefing:F,isOpening:k===F.id,isBusy:j===F.id,onOpen:()=>p(F.id),onRunNow:()=>h(F),onTogglePause:()=>g(F),onDelete:()=>b(F)},F.id))]}),E?e.jsx("div",{className:"border-t border-border px-4 py-2.5",children:e.jsxs("a",{href:E,className:n.cn(Pe,"h-6 px-1 text-[11px]"),children:["Manage all reports & briefings",e.jsx(ze,{className:"h-3 w-3"})]})}):null]})}function Pt({onNew:t,canCreate:r,canCreateScheduledReport:i,analyticalBriefingsEnabled:a,contentKind:d}){const o=d==="reports"?{title:"No reports yet",description:"Schedule an emailed dashboard or visual report to see it here."}:d==="briefings"?{title:"No briefings yet",description:"Create an analytical briefing to monitor this dashboard and brief your team."}:null;return e.jsxs("div",{className:"flex h-full flex-col items-center justify-center px-8 py-12 text-center",children:[e.jsx(Rt,{className:"mb-5 h-[88px] w-[112px] text-border"}),e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:(o==null?void 0:o.title)??"Have an analyst brief your team"}),e.jsx("p",{className:"mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground",children:(o==null?void 0:o.description)??"Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose."}),r?e.jsxs("div",{className:"mt-4 flex flex-wrap justify-center gap-2",children:[i?e.jsxs("button",{onClick:()=>t("scheduled_report"),className:be,children:[e.jsx(s.Plus,{className:"h-3 w-3"})," Schedule a report"]}):null,a?e.jsx("button",{onClick:()=>t("analytical_briefing"),className:Pe,children:"Create analytical briefing"}):null]}):null]})}function Rt({className:t}){return e.jsxs("svg",{viewBox:"0 0 112 88",fill:"none",xmlns:"http://www.w3.org/2000/svg",role:"presentation","aria-hidden":"true",className:t,children:[e.jsx("rect",{x:"22",y:"6",width:"60",height:"72",rx:"3",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"30",y1:"16",x2:"64",y2:"16",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"}),e.jsx("line",{x1:"30",y1:"21",x2:"52",y2:"21",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",opacity:"0.5"}),e.jsx("circle",{cx:"31",cy:"32",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"32",x2:"72",y2:"32",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"38",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"38",x2:"68",y2:"38",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("circle",{cx:"31",cy:"44",r:"1",fill:"currentColor",opacity:"0.6"}),e.jsx("line",{x1:"35",y1:"44",x2:"74",y2:"44",stroke:"currentColor",strokeWidth:"1",opacity:"0.4",strokeLinecap:"round"}),e.jsx("rect",{x:"30",y:"64",width:"5",height:"8",rx:"0.5",fill:"currentColor",opacity:"0.55"}),e.jsx("rect",{x:"38",y:"60",width:"5",height:"12",rx:"0.5",fill:"currentColor",opacity:"0.7"}),e.jsx("rect",{x:"46",y:"56",width:"5",height:"16",rx:"0.5",fill:"currentColor",opacity:"0.85"}),e.jsx("rect",{x:"54",y:"62",width:"5",height:"10",rx:"0.5",fill:"currentColor",opacity:"0.6"}),e.jsx("rect",{x:"62",y:"58",width:"5",height:"14",rx:"0.5",fill:"currentColor",opacity:"0.75"}),e.jsx("circle",{cx:"86",cy:"62",r:"10",fill:"var(--background, white)",stroke:"currentColor",strokeWidth:"1.25"}),e.jsx("line",{x1:"93.5",y1:"69.5",x2:"100",y2:"76",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Ut({briefing:t,isOpening:r,isBusy:i,onOpen:a,onRunNow:d,onTogglePause:o,onDelete:u}){const p=t.status==="PAUSED",c=t.hasActiveRun,f=It(t),l=Bt(t.lastRunAt),x=t.lastRunStatus,h=K.getBriefingPresentation(t),g=x==="SUCCESS"?s.briefingTone.success.dot:x==="FAILED"?s.briefingTone.danger.dot:x?s.briefingTone.warning.dot:s.briefingTone.neutral.dot;return e.jsxs("div",{className:n.cn("group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",p&&"opacity-70"),children:[e.jsxs("div",{role:"button",tabIndex:0,onClick:a,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),a())},className:"cursor-pointer pr-8",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:t.name}),p?e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:"· Paused"}):null]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground",children:[e.jsx("span",{children:h.typeLabel}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx("span",{children:Lt(t)}),e.jsx("span",{className:"text-border",children:"·"}),e.jsx(s.Clock,{className:"h-3 w-3"}),e.jsx("span",{className:"truncate",children:Ft(t)}),t.lastRunAt?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-border",children:"·"}),e.jsxs("span",{children:["Last run ",l]})]}):null]}),f||c?e.jsxs("div",{className:"mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80",children:[c?e.jsx(n.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground/70"}):e.jsx("span",{className:n.cn("inline-block h-1.5 w-1.5 shrink-0 rounded-full",g)}),e.jsx("span",{className:"truncate",children:c?Re(t):f})]}):null]}),e.jsx("div",{className:"absolute right-3 top-3",children:i?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):r?e.jsx(n.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin text-muted-foreground/70"}):e.jsxs(s.DropdownMenu,{children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx("button",{type:"button",onClick:b=>b.stopPropagation(),className:"inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100","aria-label":`${h.noun==="report"?"Report":"Briefing"} actions`,children:e.jsx(s.Ellipsis,{className:"h-3.5 w-3.5"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"w-44",children:[e.jsxs(s.DropdownMenuItem,{onClick:a,children:[e.jsx(s.Pencil,{className:"h-3.5 w-3.5"}),"Edit ",h.noun]}),e.jsxs(s.DropdownMenuItem,{onClick:b=>{b.preventDefault(),d()},children:[e.jsx(s.Zap,{className:"h-3.5 w-3.5"}),"Run now"]}),t.scheduleExpr?e.jsx(s.DropdownMenuItem,{onClick:b=>{b.preventDefault(),o()},children:p?e.jsxs(e.Fragment,{children:[e.jsx(s.Play,{className:"h-3.5 w-3.5"}),"Resume"]}):e.jsxs(e.Fragment,{children:[e.jsx(s.Pause,{className:"h-3.5 w-3.5"}),"Pause"]})}):null,e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:b=>{b.preventDefault(),u()},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",children:[e.jsx(s.Trash2,{className:"h-3.5 w-3.5"}),"Delete ",h.noun]})]})]})})]})}const Vt=2e3,_t=20*6e4;function Ot(t){return(t==null?void 0:t.trim())||"This dashboard"}function zt(t){return t==="This dashboard"?"Watch this dashboard":`Watch ${t}`}function $t(t,r,i){return r!=="dashboard"?t:t.filter(a=>a.source.type==="dashboard"&&a.source.dashboardId===i)}async function qt(t){const i=[];let a=1,d=0,o=Number.POSITIVE_INFINITY;for(;d<o;){const u=await t.apiClient.listBriefings(t.apiServiceUrl,t.token,{scope:"organization",page:a,pageSize:100});if(i.push(...u.briefings),d+=u.briefings.length,o=u.total,u.briefings.length===0||d>=o)break;a+=1}return i}const Wt={listBriefings:s.listBriefings,getBriefing:s.getBriefing,pauseBriefing:s.pauseBriefing,resumeBriefing:s.resumeBriefing,deleteBriefing:s.deleteBriefing,runBriefingNow:s.runBriefingNow};function Ht({briefingId:t,initialRun:r,apiServiceUrl:i,token:a,onTerminal:d,onTimeout:o,onExpand:u}){const[p,c]=m.useState(r),{startRun:f}=s.useBriefingRunPolling({apiServiceUrl:i,token:a,intervalMs:Vt,timeoutMs:_t,fetchRun:({apiServiceUrl:x,token:h,runId:g})=>s.getBriefingRun(x,h,t,g),onRun:x=>{c(x)},onTerminalRun:x=>{d(x)},onTimeout:()=>{o()}}),l=m.useRef(!1);return m.useEffect(()=>{l.current||(l.current=!0,s.isActiveBriefingRunStatus(r.status)?f(r):s.isTerminalBriefingRunStatus(r.status)&&d(r))},[r,d,f]),e.jsx(s.BackgroundRunPill,{run:p,onExpand:u})}function Gt(t){return e.jsx(s.BriefingUiCapabilitiesBoundary,{children:e.jsx(Kt,{...t})})}function Kt({dashboardId:t,dashboardTitle:r,apiServiceUrl:i,token:a,disabled:d,className:o,manageBriefingsHref:u,open:p,onOpenChange:c,hideTrigger:f=!1,workflowIntent:l,client:x}){const{authToken:h,tokenProps:g}=s.useSemaphorContext(),b=s.useBriefingUiCapabilities(),k=!l||b.canCreate&&(l==="scheduled_report"||b.analyticalBriefingsEnabled),[j,E]=m.useState(!1),S=p??j,w=D=>{p===void 0&&E(D),c==null||c(D)},[N,A]=m.useState(l?"author":"list"),[T,v]=m.useState(l??"analytical_briefing"),[C,L]=m.useState("dashboard"),[F,$]=m.useState([]),[B,M]=m.useState(null),O=l&&!k&&!B?"list":N,[oe,X]=m.useState(!1),[J,he]=m.useState(null),[xe,ee]=m.useState(null),[z,H]=m.useState(null),[te,G]=m.useState(null),me=m.useRef(null),ie=m.useRef(S);m.useEffect(()=>{const D=S&&!ie.current;ie.current=S,!(!D||!l)&&(M(null),L("dashboard"),v(l),A("author"),G(null))},[S,l]);const[re,ne]=m.useState(null),[W,le]=m.useState(null),V=i??(g==null?void 0:g.apiServiceUrl),_=a??(h==null?void 0:h.accessToken),Z=m.useMemo(()=>({...Wt,...x}),[x]),ae=Ot(r),pe=m.useMemo(()=>{const D=$t(F,C,t);if(!l)return D;const P=l==="scheduled_report"?"report":"briefing";return D.filter(fe=>K.getBriefingPresentation(fe).noun===P)},[t,F,C,l]),ve=m.useMemo(()=>C==="dashboard"?{source:{type:"dashboard",dashboardId:t},label:ae,detail:zt(ae)}:{source:{type:"project"},label:"This project",detail:"Use any data in this project."},[t,ae,C]),de=!!(V&&_),ce=K.getBriefingCreationIntents({canCreate:b.canCreate,analyticalBriefingsEnabled:b.analyticalBriefingsEnabled,scheduledReportAvailable:C==="dashboard"}),q=m.useCallback(async()=>{if(!(!V||!_)){X(!0),G(null);try{$(await qt({apiClient:Z,apiServiceUrl:V,token:_}))}catch(D){G(D instanceof Error?D.message:"Could not load briefings.")}finally{X(!1)}}},[Z,V,_]);m.useEffect(()=>{!S||O!=="list"||!de||q()},[de,O,q,S]);const ue=()=>{M(null),L("dashboard"),A("list"),w(!0)},y=D=>{M(null),v(D),A("author")},I=async D=>{if(!(!V||!_)){he(D),G(null);try{const P=await Z.getBriefing(V,_,D);M(P.briefing),A("author")}catch(P){G(P instanceof Error?P.message:"Could not open briefing.")}finally{he(null)}}},U=async D=>{if(!(!V||!_)){ee(D.id);try{await Z.runBriefingNow(V,_,D.id,{requestId:Xt()}),q()}catch(P){n.ue.error(P instanceof Error?P.message:"Could not start the run.")}finally{ee(null)}}},Q=async D=>{if(!V||!_)return;const{noun:P}=K.getBriefingPresentation(D),fe=P==="report"?"Report":"Briefing";ee(D.id);try{const ge=D.status==="PAUSED"?await Z.resumeBriefing(V,_,D.id):await Z.pauseBriefing(V,_,D.id);n.ue.success(ge.briefing.status==="PAUSED"?`${fe} paused`:`${fe} resumed`),q()}catch(ge){n.ue.error(ge instanceof Error?ge.message:`Could not update the ${P} status.`)}finally{ee(null)}},se=async()=>{if(!z||!V||!_)return;const D=z;ee(D.id);try{await Z.deleteBriefing(V,_,D.id);const{noun:P}=K.getBriefingPresentation(D);n.ue.success(`${P==="report"?"Report":"Briefing"} deleted`),H(null),q()}catch(P){n.ue.error(P instanceof Error?P.message:"Could not delete the briefing.")}finally{ee(null)}},Ue=pe.length;return b.surfaceVisible?e.jsxs(s.Sheet,{open:S,onOpenChange:w,children:[f?null:e.jsx(Me,{disabled:d||!de,briefingCount:Ue,className:o,onClick:ue}),e.jsxs(s.SheetContent,{ref:me,side:"right",hideClose:!0,className:"flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",onOpenAutoFocus:D=>{var P;D.preventDefault(),(P=me.current)==null||P.focus({preventScroll:!0})},children:[e.jsxs(s.SheetHeader,{className:"sr-only",children:[e.jsx(s.SheetTitle,{children:"Reports & briefings"}),e.jsx(s.SheetDescription,{children:"Manage reports and briefings for this dashboard."})]}),l?e.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2",children:[e.jsxs("div",{className:"flex items-center gap-5",role:"tablist","aria-label":l==="scheduled_report"?"Email report workflow":"Analytical briefing workflow",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":O==="author",disabled:!k,className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",O==="author"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground",!k&&"cursor-not-allowed opacity-50"),onClick:()=>{k&&(M(null),v(l),L("dashboard"),A("author"))},children:B?`Edit ${K.getBriefingPresentation(B).noun}`:l==="scheduled_report"?"Schedule report":"Create briefing"}),e.jsx("button",{type:"button",role:"tab","aria-selected":O==="list",className:n.cn("-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",O==="list"?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),onClick:()=>A("list"),children:l==="scheduled_report"?"Manage reports":"Manage briefings"})]}),e.jsx("button",{type:"button",onClick:()=>w(!1),className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground","aria-label":l==="scheduled_report"?"Close email report workflow":"Close analytical briefing workflow",children:e.jsx(Y.X,{className:"h-3.5 w-3.5"})})]}):null,O==="list"?e.jsx(Mt,{briefings:pe,dashboardLabel:ae,sourceView:C,error:te,loading:oe,onSourceViewChange:L,onClose:()=>w(!1),onEdit:D=>{I(D)},onNew:y,canCreate:!l&&ce.length>0,canCreateScheduledReport:ce.includes("scheduled_report"),analyticalBriefingsEnabled:ce.includes("analytical_briefing"),onRunNow:D=>{U(D)},onTogglePause:D=>{Q(D)},onDelete:D=>H(D),selectingId:J,busyId:xe,manageBriefingsHref:u,contentKind:l==="scheduled_report"?"reports":l==="analytical_briefing"?"briefings":void 0,hideHeader:!!l}):e.jsx(s.BriefingAuthor,{apiServiceUrl:V,token:_,briefing:B,intent:T,sourceContext:B?void 0:ve,title:B?`Edit ${K.getBriefingPresentation(B).noun}`:T==="scheduled_report"?"Schedule report":"Create analytical briefing",hideHeader:!!l,className:"h-full min-h-0 max-w-none border-0 shadow-none",onBack:l?void 0:()=>A("list"),onCancel:()=>w(!1),onDeleted:()=>{const D=B?K.getBriefingPresentation(B).noun:"briefing";n.ue.success(`${D==="report"?"Report":"Briefing"} deleted`),M(null),A("list"),q()},onRunStarted:()=>{},onSaved:D=>{M(D),q()},onMinimizeRun:({briefing:D,run:P})=>{ne({briefing:D,run:P}),w(!1)}})]}),re&&V&&_?e.jsx(Ht,{briefingId:re.briefing.id,initialRun:re.run,apiServiceUrl:V,token:_,onTerminal:D=>{le({briefing:re.briefing,run:D}),ne(null),q()},onTimeout:()=>{ne(null),q()},onExpand:()=>{M(re.briefing),A("author"),ne(null),w(!0)}}):null,W?e.jsx("div",{className:"fixed bottom-4 right-4 z-50 w-[360px]",children:e.jsx(s.RunCompletionBanner,{title:W.run.status==="SUCCESS"?`${W.briefing.name} is ready`:`${W.briefing.name} run failed`,durationSeconds:W.run.startedAt&&W.run.completedAt?Math.max(0,Math.floor((new Date(W.run.completedAt).getTime()-new Date(W.run.startedAt).getTime())/1e3)):null,status:W.run.status==="SUCCESS"?"success":"failed",onView:()=>{M(W.briefing),A("author"),le(null),w(!0)},onDismiss:()=>le(null)})}):null,e.jsx(s.AlertDialog,{open:!!z,onOpenChange:D=>{D||H(null)},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsxs(s.AlertDialogTitle,{children:["Delete"," ",z?K.getBriefingPresentation(z).noun:"briefing","?"]}),e.jsxs(s.AlertDialogDescription,{children:["This permanently deletes ",e.jsx("strong",{children:z==null?void 0:z.name}),". Recipients will stop receiving it."]})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{children:"Cancel"}),e.jsxs(s.AlertDialogAction,{className:"bg-destructive/90 hover:bg-destructive",onClick:se,children:["Delete"," ",z?K.getBriefingPresentation(z).noun:"briefing"]})]})]})})]}):null}function Xt(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}exports.AdvancedModeToggle=at;exports.DashboardBriefingLauncher=Gt;exports.DashboardControlsSettings=Ie;exports.DashboardFilterControlsButton=Te;exports.DashboardFilterControlsLauncher=Et;exports.DocumentControlsSettings=Le;exports.ExportNotificationItem=Be;exports.ExportNotificationList=Fe;exports.NotificationBell=ft;exports.UnsavedChangesAlert=ot;exports.VisualEditingControls=nt;exports.VisualsLibraryDialog=Ye;exports.WatchDashboardButton=Me;exports.useDashboardUnsavedChangesCheck=tt;exports.useExportPolling=xt;exports.useExportRecovery=mt;