react-semaphor 0.1.314 → 0.1.316
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/brand-studio/index.js +65 -65
- package/dist/briefings/index.cjs +1 -0
- package/dist/briefings/index.js +848 -0
- package/dist/chunks/{braces-CWi8x9ww.js → braces-CDPz6CF2.js} +1 -1
- package/dist/chunks/{calendar-preferences-dialog-D70CuT-1.js → calendar-preferences-dialog-9NlFzHX8.js} +3 -3
- package/dist/chunks/{calendar-preferences-dialog-BzpQ5u4h.js → calendar-preferences-dialog-BDdxi7Xm.js} +1 -1
- package/dist/chunks/{chevrons-up-down-B2viXO2I.js → chevrons-up-down-BsdQRmJL.js} +1 -1
- package/dist/chunks/dashboard-briefing-launcher-5fM_KJoT.js +7321 -0
- package/dist/chunks/dashboard-briefing-launcher-CVxLt10p.js +96 -0
- package/dist/chunks/dashboard-controls-9YV-D1tD.js +2009 -0
- package/dist/chunks/dashboard-controls-UR_m0wD1.js +57 -0
- package/dist/chunks/{dashboard-json-CJCAen1R.js → dashboard-json-CKPID8Am.js} +2 -2
- package/dist/chunks/{dashboard-json-v2C6Tmqf.js → dashboard-json-ws4tortP.js} +1 -1
- package/dist/chunks/edit-dashboard-visual-CmxnZI8I.js +178 -0
- package/dist/chunks/{edit-dashboard-visual-DljWvnMy.js → edit-dashboard-visual-ifKJLMTS.js} +807 -822
- package/dist/chunks/index-Xdag_85e.js +1298 -0
- package/dist/chunks/{index-P5hPTTzm.js → index-gcA9Rs35.js} +41178 -46390
- package/dist/chunks/{palette-CIuwlEiG.js → palette-BlxLchHy.js} +1 -1
- package/dist/chunks/{resource-management-panel-CAxXzMdi.js → resource-management-panel-BduJanWW.js} +1 -1
- package/dist/chunks/{resource-management-panel-Dk0DzgVm.js → resource-management-panel-paSAzVj2.js} +81 -81
- package/dist/chunks/{save-_ALpoMy6.js → save-DVRQBMeb.js} +1 -1
- package/dist/chunks/{switch-B6fh8nb-.js → switch-sauemjyY.js} +199 -199
- package/dist/chunks/{use-create-flow-overlay-state-Cqf7GaFm.js → use-create-flow-overlay-state-DKV6tIc5.js} +254 -225
- package/dist/chunks/use-create-flow-overlay-state-DWnzVVlP.js +26 -0
- package/dist/chunks/{use-visual-utils-CQQ3jvDn.js → use-visual-utils-C8PDxg2w.js} +1 -1
- package/dist/chunks/{use-visual-utils-CPMQLBYR.js → use-visual-utils-Cs0-baCK.js} +48 -48
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +232 -485
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings.d.ts +240 -0
- package/dist/types/dashboard.d.ts +1 -0
- package/dist/types/main.d.ts +619 -1017
- package/dist/types/surfboard.d.ts +1 -0
- package/dist/types/types.d.ts +411 -261
- package/package.json +7 -2
- package/dist/chunks/dashboard-controls-BS_aZcxs.js +0 -57
- package/dist/chunks/dashboard-controls-DbKtbw1V.js +0 -2021
- package/dist/chunks/dashboard-filter-controls-launcher-C8Wm2Smj.js +0 -1540
- package/dist/chunks/dashboard-filter-controls-launcher-CMXpudFJ.js +0 -11
- package/dist/chunks/edit-dashboard-visual-lRn3FeaP.js +0 -183
- package/dist/chunks/index-XYIIY48z.js +0 -1330
- package/dist/chunks/use-create-flow-overlay-state-DMZTflFt.js +0 -16
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),o=require("./switch-DPaKnsb8.js"),s=require("./index-XYIIY48z.js"),k=require("./use-create-flow-overlay-state-DMZTflFt.js"),v=require("react"),_=require("./use-visual-utils-CQQ3jvDn.js"),V=require("./date-formatter-D9Bvw5Qk.js");require("./index-DRlMUglg.js");require("react-dom");/**
|
|
2
|
-
* @license lucide-react v0.453.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const U=o.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
|
|
7
|
-
* @license lucide-react v0.453.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const X=o.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);function K({open:t,onOpenChange:a,isLibraryVisual:h,currentVisualName:u,isSaving:n=!1,destinationMode:p="both",onConfirm:d}){const[c,l]=v.useState(h&&u?`Copy of ${u}`:u||""),[r,x]=v.useState("");v.useEffect(()=>{t&&(l(h&&u?`Copy of ${u}`:u||""),x(""))},[t,h,u]);const C=!!c.trim(),i=p==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:p==="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"},m=()=>{!C||n||d({name:c.trim(),description:r.trim()||void 0,saveToLibrary:i.saveToLibrary,saveToCurrentDashboard:i.saveToCurrentDashboard})};return e.jsx(s.Dialog,{open:t,onOpenChange:a,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"}),i.badgeType!=="local"&&e.jsx(k.VisualBadge,{type:i.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(s.DialogDescription,{children:i.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(o.Label,{htmlFor:"name",children:"Name"}),e.jsx(o.Input,{id:"name",value:c,onChange:j=>l(j.target.value),placeholder:"Enter visual name",disabled:n})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(o.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Textarea,{id:"description",value:r,onChange:j=>x(j.target.value),placeholder:"Enter visual description",rows:3,disabled:n})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(o.Button,{variant:"outline",onClick:()=>a(!1),disabled:n,children:"Cancel"}),e.jsxs(o.Button,{onClick:m,disabled:!C||n,children:[n&&e.jsx(o.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),i.actionLabel]})]})]})})}function Q(){const[t,a]=v.useState(!1),[h,u]=v.useState(!1),[n,p]=v.useState(null),[d,c]=v.useState(null),l=o.useEditorStore(g=>g.frame),r=o.useEditorStore(g=>g.card),x=s.useSelectedVisual(),C=o.useDashboardStore(g=>g.selectedSheetId),i=o.useDashboardStore(g=>g.dashboard),m=o.useDashboardStore(g=>g.actions.setIsDashboardPanelOpen),{getUpdatedFrame:j}=_.useVisualUtils(),{selectVisual:b}=s.useManagementActions(),{addFrame:D,setSelectedFrameId:N,setIsVisualEditing:E}=o.useDashboardActions(),f=s.useResolveExistingFrameSemanticExecutionPayload(),S=!!(l!=null&&l.visualId),I=(()=>{var g,y;return((g=l==null?void 0:l.cards)==null?void 0:g.length)===1&&((y=l.cards[0])!=null&&y.title)?l.cards[0].title:x!=null&&x.title?x.title:(r==null?void 0:r.title)||"Untitled Visual"})(),F=s.useCreateVisualWithFrame(g=>{g!=null&&g.id&&(b(g),h&&n&&d&&C&&(async()=>{try{const y={...n,id:o.v4(),visualId:g.id};D(C,y,{position:"end",semanticExecutionPayload:d}),N(y.id),u(!1),p(null),c(null),E(!1)}catch(y){console.error("Failed to promote semantic metadata for saved visual:",y),s.ue.error(y instanceof Error?y.message:"Failed to prepare semantic metadata for the saved visual")}})(),m(!0),a(!1))});return{saveAsDialogOpen:t,setSaveAsDialogOpen:a,handleSaveAs:async g=>{if(!C){s.ue.error("No sheet selected");return}const y=j(),P=o.getDynamicFrameSaveIssue(y);if(P){s.ue.error(P);return}const L=y.cards.length===1?{...y,cards:y.cards.map(T=>({...T,title:g.name}))}:y;if(g.saveToLibrary){let T=null;if(g.saveToCurrentDashboard)try{T=await f(L,{previousFrame:s.findDashboardFrameById(i,L.id)})}catch(O){console.error("Failed to prepare semantic metadata before saving visual:",O),s.ue.error(O instanceof Error?O.message:"Failed to prepare semantic metadata for the saved visual");return}u(g.saveToCurrentDashboard),p(L),c(T);const M={title:g.name,description:g.description,frameObject:L,isPrivate:!1};F.mutate(M)}else if(g.saveToCurrentDashboard){const T={...L,id:o.v4(),visualId:void 0};try{const M=await f(L,{previousFrame:s.findDashboardFrameById(i,L.id)});D(C,T,{position:"end",semanticExecutionPayload:M}),N(T.id),s.ue.success("Visual saved to dashboard"),a(!1),E(!1)}catch(M){console.error("Failed to save visual to dashboard:",M),s.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:S,currentVisualName:I,isSaving:F.isPending}}function Y(t={}){const a=o.useEditorStore(A=>A.frame),h=o.useEditorStore(A=>A.editorContext),u=s.useManagementStore(A=>A.selectedVisual),n=o.useDashboardStore(A=>A.selectedFrameId),p=o.useDashboardStore(A=>A.selectedSheetId),d=o.useDashboardStore(A=>A.dashboard),{setIsVisualEditing:c,updateFrame:l}=o.useDashboardActions(),[r,x]=v.useState(!1),[C,i]=v.useState("both"),m=s.useResolveExistingFrameSemanticExecutionPayload(),j=(h==null?void 0:h.type)==="documentSection",b=!!(a!=null&&a.visualId||u!=null&&u.id),D=!!(a!=null&&a.visualId&&n),N=b&&!D,{saveAsDialogOpen:E,setSaveAsDialogOpen:f,handleSaveAs:S,isLibraryVisual:I,currentVisualName:F,isSaving:w}=Q(),{getUpdatedFrame:g}=_.useVisualUtils();if(j)return e.jsxs(e.Fragment,{children:[e.jsx(k.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(k.EditorCancelButton,{})]});const y=async()=>{if(!p){s.ue.error("No sheet selected");return}if(r)return;x(!0);const A=g(),L=o.getDynamicFrameSaveIssue(A);if(L){x(!1),s.ue.error(L);return}const T={...A,visualId:void 0},M=s.findDashboardFrameById(d,T.id);try{const O=await m(T,{previousFrame:M});l(p,T,{semanticExecutionPayload:O})}catch(O){console.error("Failed to apply local semantic metadata:",O),x(!1),s.ue.error(O instanceof Error?O.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{x(!1),s.ue.success("Changes applied. Visual is now local to this dashboard"),c(!1)},300)},P=A=>{i(A),f(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!b&&e.jsx(k.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),b&&N&&e.jsx(k.VisualSaveButton,{className:"!rounded-none",variant:"default"}),b&&D&&e.jsx(k.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(s.DropdownMenu,{modal:!1,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(o.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:w||r,children:e.jsx(o.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:[D&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:y,disabled:r,children:[e.jsx(o.Check,{className:"h-3.5 w-3.5"}),r?"Applying...":"Apply Locally"]}),e.jsx(s.DropdownMenuSeparator,{})]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>P("local"),disabled:w,children:[e.jsx(s.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>P("library"),disabled:w,children:[e.jsx(k.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(s.DropdownMenuItem,{onClick:()=>P("both"),disabled:w,children:[e.jsx(k.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(k.EditorCancelButton,{}),e.jsx(K,{open:E,onOpenChange:A=>{w||f(A)},isLibraryVisual:I,currentVisualName:F,isSaving:w,destinationMode:C,onConfirm:S})]})}function Z({className:t}){const a=o.useEditorStore(r=>r.isDevMode),h=o.useDashboardStore(r=>r.isVisualEditing),{setIsDevMode:u}=o.useEditorActions(),{config:n}=v.useContext(s.SemaphorContext).tokenProps,p=(n==null?void 0:n.showAdvancedMode)!==!1;if(!h||!p)return null;const d=a?o.SlidersHorizontal:s.CodeXml,c=a?"Drag & drop":"SQL",l=a?"Switch to drag-and-drop mode":"Switch to SQL mode";return e.jsxs("button",{type:"button","aria-label":l,title:l,onClick:()=>u(!a),className:o.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(d,{className:"h-3 w-3 text-muted-foreground"}),c]})}function J({open:t,onOpenChange:a,onSave:h,onDiscard:u,isSaving:n,title:p="Unsaved changes",description:d="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:c="Cancel",discardLabel:l="Discard",saveLabel:r="Save"}){const x=C=>{!C&&n||a(C)};return e.jsx(s.AlertDialog,{open:t,onOpenChange:x,children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:p}),e.jsx(s.AlertDialogDescription,{children:d})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(o.Button,{type:"button",size:"xs",onClick:u,disabled:n,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:l}),e.jsx(s.AlertDialogCancel,{disabled:n,children:c}),e.jsx(o.Button,{type:"button",size:"xs",onClick:h,disabled:n,children:n?e.jsxs(e.Fragment,{children:[e.jsx(o.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):r})]})]})})}const ee=1e4,te=15e3,se=3e4,oe=3e4,ae=12e4,R=2*60*60*1e3;function re(t){const a=Date.now()-t.getTime();return a<oe?ee:a<ae?te:se}function ne(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),h=s.useExportStore(i=>i.activeExports),[u,n]=v.useState(typeof document<"u"?!document.hidden:!0),p=v.useRef(null),d=v.useRef(!1),c=v.useRef(void 0),l=a==null?void 0:a.apiServiceUrl,r=t==null?void 0:t.accessToken,x=v.useCallback(()=>{const i=s.useExportStore.getState().activeExports;return Array.from(i.values()).filter(m=>s.isExportInProgress(m.status))},[]);v.useEffect(()=>{if(typeof document>"u")return;const i=()=>{n(!document.hidden)};return document.addEventListener("visibilitychange",i),()=>{document.removeEventListener("visibilitychange",i)}},[]);const C=v.useCallback(async()=>{if(!l||!r){d.current=!1;return}const i=x();if(i.length===0){d.current=!1;return}const m=Date.now(),j=i.filter(f=>m-f.startedAt.getTime()>R);if(j.length>0){const{updateExport:f}=s.useExportStore.getState().actions;for(const S of j)f(S.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const b=i.filter(f=>m-f.startedAt.getTime()<=R);if(b.length===0){d.current=!1;return}const D=await Promise.allSettled(b.map(async f=>{try{const S=await s.getExportStatus(l,r,f.id);let I;if(S.status==="completed")try{I=await s.getDownloadUrl(l,r,f.id)}catch(F){console.error(`[useExportPolling] Failed to get download URL for ${f.id}:`,F)}return{id:f.id,status:S.status,progress:S.progress,completedChunks:S.completedChunks,completedAt:S.completedAt?new Date(S.completedAt):void 0,lastUpdatedAt:new Date,fileSize:S.fileSize,error:S.error,downloadUrl:I}}catch(S){return console.error(`[useExportPolling] Failed to poll export ${f.id}:`,S),null}})),{updateExport:N}=s.useExportStore.getState().actions;for(const f of D)f.status==="fulfilled"&&f.value&&N(f.value.id,f.value);const E=x();if(E.length>0&&!document.hidden){const f=E.reduce((I,F)=>F.startedAt<I?F.startedAt:I,E[0].startedAt),S=re(f);p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{var I;(I=c.current)==null||I.call(c)},S)}else d.current=!1},[l,r,x]);return v.useEffect(()=>{c.current=C},[C]),v.useEffect(()=>{var m;x().length>0&&u&&!d.current&&(d.current=!0,(m=c.current)==null||m.call(c))},[h,u,x]),v.useEffect(()=>{var m;const i=x();u&&i.length>0&&!d.current&&(d.current=!0,(m=c.current)==null||m.call(c))},[u,x]),v.useEffect(()=>{!u&&p.current&&(clearTimeout(p.current),p.current=null,d.current=!1)},[u]),v.useEffect(()=>()=>{p.current&&(clearTimeout(p.current),p.current=null)},[]),{isPolling:d.current,isTabVisible:u,inProgressCount:x().length}}function ie(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),h=s.useExportStore(c=>c.activeExports),{addExport:u}=s.useExportActions(),n=v.useRef(!1),p=a==null?void 0:a.apiServiceUrl,d=t==null?void 0:t.accessToken;v.useEffect(()=>{if(n.current||!p||!d)return;(async()=>{try{const{exports:l}=await s.getExports(p,d,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const r of l){if(h.has(r.id))continue;const x=r.totalChunks?Math.round(r.completedChunks/r.totalChunks*100):0;let C;if(r.status==="completed")try{C=await s.getDownloadUrl(p,d,r.id)}catch(m){console.error(`[useExportRecovery] Failed to get download URL for ${r.id}:`,m)}const i={id:r.id,status:r.status,progress:x,title:le(r),totalRows:r.totalRows,totalChunks:r.totalChunks,completedChunks:r.completedChunks,startedAt:new Date(r.createdAt),lastUpdatedAt:new Date,completedAt:r.completedAt?new Date(r.completedAt):void 0,fileSize:r.fileSize,error:r.error,expiresAt:new Date(r.expiresAt),downloadUrl:C};u(i)}n.current=!0}catch(l){console.error("[useExportRecovery] Failed to recover exports:",l),n.current=!0}})()},[p,d,u,h])}function le(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 q({export:t,onRemove:a}){const h=()=>{t.downloadUrl&&window.open(t.downloadUrl,"_blank")},u=c=>{c.stopPropagation(),a==null||a(t.id)},n=()=>{switch(t.status){case"completed":return e.jsx(s.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(k.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(o.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},p=s.isExportInProgress(t.status),d=(()=>{switch(t.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[n(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:t.title}),t.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[t.totalRows.toLocaleString()," rows"]}),t.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:s.formatFileSize(t.fileSize)})]})]}),p&&e.jsx("div",{className:"text-xs text-muted-foreground",children:d}),t.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:t.error||"Export failed"})]})]}),e.jsx(o.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:u,"aria-label":"Remove notification",children:e.jsx(o.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[t.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:V.formatDistanceToNow(t.startedAt,{addSuffix:!0})}),t.downloadUrl&&e.jsxs(o.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:h,children:[e.jsx(s.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),p&&e.jsxs("div",{children:[e.jsx(s.Progress,{value:t.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[t.progress,"% complete"]})]}),t.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:V.formatDistanceToNow(t.startedAt,{addSuffix:!0})})]})]})}function H(){const{authToken:t,tokenProps:a}=s.useSemaphorContext(),h=s.useExportStore(b=>b.activeExports),{clearCompleted:u,removeExport:n,updateExport:p}=s.useExportActions(),[d,c]=v.useState(!1),[l,r]=v.useState(!1),x=Array.from(h.values()).sort((b,D)=>D.startedAt.getTime()-b.startedAt.getTime()),C=x.some(b=>b.status==="completed"||b.status==="failed"),i=v.useCallback(async()=>{const b=a==null?void 0:a.apiServiceUrl,D=t==null?void 0:t.accessToken;if(!(!b||!D)){c(!0);try{const N=Array.from(h.values());await Promise.all(N.map(async E=>{try{const f=await s.getExportStatus(b,D,E.id);let S;if(f.status==="completed")try{S=await s.getDownloadUrl(b,D,E.id)}catch(I){console.error(`Failed to get download URL for ${E.id}:`,I)}p(E.id,{status:f.status,progress:f.progress,completedChunks:f.completedChunks,completedAt:f.completedAt?new Date(f.completedAt):void 0,lastUpdatedAt:new Date,fileSize:f.fileSize,error:f.error,downloadUrl:S})}catch(f){console.error(`Failed to refresh export ${E.id}:`,f)}}))}finally{c(!1)}}},[h,t==null?void 0:t.accessToken,a==null?void 0:a.apiServiceUrl,p]),m=v.useCallback(async()=>{const b=a==null?void 0:a.apiServiceUrl,D=t==null?void 0:t.accessToken;if(!b||!D){u();return}r(!0);try{const N=x.filter(f=>f.status==="completed"||f.status==="failed"),E=await Promise.allSettled(N.map(async f=>(await s.cancelExport(b,D,f.id),f.id)));for(const f of E)f.status==="fulfilled"?n(f.value):console.error("Failed to delete export:",f.reason)}finally{r(!1)}},[x,a==null?void 0:a.apiServiceUrl,t==null?void 0:t.accessToken,u,n]),j=v.useCallback(async b=>{const D=a==null?void 0:a.apiServiceUrl,N=t==null?void 0:t.accessToken;if(D&&N)try{await s.cancelExport(D,N,b),n(b);return}catch(E){console.error(`Failed to cancel export ${b}:`,E)}n(b)},[a==null?void 0:a.apiServiceUrl,t==null?void 0:t.accessToken,n]);return x.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(U,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(o.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:i,disabled:d,title:"Refresh status",children:e.jsx(s.RefreshCw,{className:`h-4 w-4 ${d?"animate-spin":""}`})}),C&&e.jsx(o.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:m,disabled:l,children:l?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:x.map(b=>e.jsx(q,{export:b,onRemove:j},b.id))})})]})}function de({variant:t}){const a=s.useExportStore(l=>l.activeExports),h=s.useInProgressExportsCount(),u=a.size>0,n=Array.from(a.values()).some(l=>l.status==="completed"||l.status==="failed"),d=h>0?h>9?"9+":String(h):null,c=u;return e.jsxs(o.Popover,{children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:e.jsxs(o.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"}),c&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${d?"-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:d})]})}),e.jsx(o.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(H,{})})]})}function ce(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 $({open:t,onOpenChange:a,trigger:h,showTrigger:u=!0,initialMode:n="manage"}){const p=n==="create",{forceClose:d,handleOpenChange:c,isCreateFlowActive:l,preventPassiveDismissDuringCreate:r,resolvedOpen:x,setIsCreateFlowActive:C}=k.useCreateFlowOverlayState({open:t,onOpenChange:a,initialCreateFlowActive:n==="create",dismissMode:u?"passive":"explicit-only"}),i=o.useDashboardStore(g=>g.dashboard),{setDashboardControlsModel:m}=o.useDashboardActions(),{participants:j}=s.useDashboardStructuralParticipants(o.getDashboardCards(i)),b=Array.from(new Map(j.flatMap(g=>g.fieldChoices.map(y=>{var P;return[y.value,{option:y,target:(P=g.fieldTargetMap)==null?void 0:P[y.value]}]}))).values()),D=Array.from(new Map(j.flatMap(g=>g.metricChoices.map(y=>{var P;return[y.value,{option:y,target:(P=g.metricTargetMap)==null?void 0:P[y.value]}]}))).values()),N=o.collectDashboardControlIds({...i||{},controls:[]}),E=s.buildDashboardStructuralParticipantIdsByControlId(i),f=(g,y,P)=>{m(g,y,ce(P))},S=v.useCallback(()=>{if(p){d();return}C(!1)},[p,d,C]),I=e.jsx(k.ControlDefinitionListEditor,{scope:"dashboard",controls:i.controls||[],reservedControlIds:N,defaultValues:i.defaultControlValues||{},usageByControlId:s.buildDashboardControlUsageById(i),availableFieldChoices:b,availableMetricChoices:D,structuralParticipants:j,structuralParticipantIdsByControlId:E,initialCreateFlow:n==="create",onCreateFlowActiveChange:C,onCreateFlowComplete:S,onChange:f,emptyMessage:"No dashboard controls yet."}),F=l?"Add dashboard control":"Dashboard Controls",w=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."})]}),I]});return u?e.jsxs(o.Popover,{open:x,onOpenChange:c,children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:h||e.jsxs(o.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(o.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(o.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:r,onPointerDownOutside:r,children:w})]}):e.jsx(s.Dialog,{open:x,onOpenChange:c,children:e.jsxs(s.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:r,onPointerDownOutside:r,children:[e.jsxs(s.DialogHeader,{className:l?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:F}),e.jsx(s.DialogDescription,{className:l?"sr-only":"text-[13px]",children:l?"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:I})]})})}const ue=["enum","multi_enum","text","number","boolean","date"];function G({open:t,onOpenChange:a,initialMode:h="manage"}){var w;const u=h==="create",{forceClose:n,handleOpenChange:p,isCreateFlowActive:d,preventPassiveDismissDuringCreate:c,resolvedOpen:l,setIsCreateFlowActive:r}=k.useCreateFlowOverlayState({open:t,onOpenChange:a,initialCreateFlowActive:h==="create",dismissMode:"explicit-only"}),x=o.useDashboardStore(g=>g.dashboard),C=o.useDashboardStore(g=>g.selectedSheetId),{setDashboardInputs:i}=o.useDashboardActions(),m=(w=x.sheets)==null?void 0:w.find(g=>g.id===C),j=(m==null?void 0:m.kind)==="document"&&!!m.document,b=v.useMemo(()=>j&&(m!=null&&m.document)?s.getDocumentSheetDashboardInputs(x,m.id):[],[x,j,m==null?void 0:m.document,m==null?void 0:m.id]),D=v.useMemo(()=>b.filter(g=>g.kind==="control"),[b]),N=v.useMemo(()=>D.map(g=>g.control),[D]),E=v.useMemo(()=>he(N),[N]),f=v.useMemo(()=>me(x),[x]),S=v.useCallback(()=>{if(u){n();return}r(!1)},[u,n,r]),I=v.useCallback((g,y,P)=>{!j||!(m!=null&&m.document)||i(xe({allInputs:x.inputs||[],documentSheetId:m.id,currentDocumentInputs:b,nextControls:g,nextDefaultValues:y,change:P}))},[x.inputs,b,j,m,i]);if(!j||!(m!=null&&m.document))return null;const F=d?"Add document control":"Document Controls";return 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:c,onPointerDownOutside:c,children:[e.jsxs(s.DialogHeader,{className:d?"space-y-0":void 0,children:[e.jsx(s.DialogTitle,{className:"text-[15px]",children:F}),e.jsx(s.DialogDescription,{className:d?"sr-only":"text-[13px]",children:d?"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(k.ControlDefinitionListEditor,{scope:"dashboard",controls:N,reservedControlIds:f,defaultValues:E,usageByControlId:{},availableFieldChoices:[],availableMetricChoices:[],structuralParticipants:[],structuralParticipantIdsByControlId:{},allowedControlTypes:ue,initialCreateFlow:h==="create",onCreateFlowActiveChange:r,onCreateFlowComplete:S,onChange:I,emptyMessage:"No document controls yet."})})]})})}function me(t){return(t.controls||[]).map(a=>a.id)}function he(t){const a={};for(const h of t)h.defaultValue!==void 0&&(a[h.id]=h.defaultValue);return a}function pe(t,a){return a?Object.prototype.hasOwnProperty.call(a,t.id)?{...t,defaultValue:a[t.id]}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}:t.defaultValue===void 0?t:{...t,defaultValue:void 0}}function xe({allInputs:t,documentSheetId:a,currentDocumentInputs:h,nextControls:u,nextDefaultValues:n,change:p}){const d=new Map(u.map(i=>[i.id,pe(i,n)])),c=(p==null?void 0:p.type)==="rename"?{oldId:p.oldId,newId:p.newId}:null,l=new Set,r=[];for(const i of h){if(i.kind!=="control"){r.push(i);continue}const m=d.get(i.control.id)||((c==null?void 0:c.oldId)===i.control.id?d.get(c.newId):void 0);if(!m)continue;l.add(m.id);const j=s.createUniqueDashboardInputVariableNameFromName(m.id,[...t,...r].filter(D=>D.id!==i.id)),b=m.id===j?m:{...m,id:j};r.push({...i,label:b.label,variableName:j,requiredAtExecution:b.requiredAtExecution,control:b})}for(const i of d.values())l.has(i.id)||r.push(s.createDashboardControlInputFromControl({control:i,existingInputs:[...t,...r],sheetId:a}));const x=new Set(h.map(i=>i.id));return[...t.filter(i=>!x.has(i.id)),...r]}function W({showFilters:t,onShowFiltersChange:a,pickerContent:h,settingsContent:u,size:n="default",className:p,primaryButtonClassName:d,secondaryButtonClassName:c,pickerContentClassName:l,settingsContentClassName:r}){const x=n==="toolbar",[C,i]=v.useState(!1),m=s.useSurfaceAppearance("interactive");return e.jsxs("div",{className:o.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",x?"h-8":"h-7",p),children:[e.jsxs(o.Popover,{open:t,onOpenChange:a,children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:e.jsxs(o.Button,{variant:"ghost",size:"xs",className:o.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",d),children:[t?e.jsx(X,{className:"h-3.5 w-3.5"}):e.jsx(s.Filter,{className:"h-3.5 w-3.5"}),"Filter"]})}),e.jsx(o.PopoverContent,{align:"end",sideOffset:6,className:o.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",l),style:m.contentStyle,children:h})]}),e.jsxs(o.Popover,{open:C,onOpenChange:i,children:[e.jsx(o.PopoverTrigger,{asChild:!0,children:e.jsx(o.Button,{variant:"ghost",size:"xs",className:o.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",c),"aria-label":"Filter and control actions",children:e.jsx(o.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsx(o.PopoverContent,{align:"end",sideOffset:6,className:o.cn("w-auto rounded-card border border-border/60 p-0 shadow-sm",r),style:m.contentStyle,children:u(()=>i(!1))})]})]})}function fe(){k.useSyncLegacyEditorState();const t=o.useDashboardStore(l=>l.selectedSheetId),a=o.useDashboardStore(l=>l.selectedFrameId),h=o.useDashboardStore(l=>l.dashboard),u=o.useDashboardStore(l=>l.actions.getSelectedFrame),{setSelectedFrameId:n}=o.useDashboardActions(),{setCard:p}=o.useEditorActions(),d=o.useEditorStore(l=>l.card.dataSource);return v.useEffect(()=>{var r,x;let l=u();if(!l){const C=(r=h==null?void 0:h.sheets)==null?void 0:r.find(m=>m.id===t),i=(x=C==null?void 0:C.frames)==null?void 0:x[0];i&&(n(i.id),l=i)}if(l){const C=l.cards.find(i=>i.id===l.activeCardId);C&&p(C)}},[u,t,a,h,n,p]),{hasEntities:!!(d!=null&&d.selectedEntities&&d.selectedEntities.length>0)}}function ge(){const t=o.useDashboardStore(c=>c.dashboard),a=o.useDashboardStore(c=>c.semanticExecutionPayload),h=o.useDashboardStore(c=>c.actions.addFilter),{hasEntities:u}=fe(),n=v.useMemo(()=>s.getGlobalDateFilterCoverage(t,a),[t,a]),d=!s.getGlobalDateFilter(t.filters)&&n.hasEligibleCards;return e.jsxs("div",{className:"flex h-[520px] w-[400px] flex-col",children:[d&&e.jsxs("div",{className:"border-b border-border/60 p-2",children:[e.jsxs("p",{className:"mb-1 flex items-center gap-1 px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[e.jsx(s.Sparkles,{className:"h-2.5 w-2.5"}),"Suggested"]}),e.jsxs("button",{type:"button",onClick:()=>h(s.createDefaultGlobalDateFilter()),title:`Eligible: ${n.eligibleCardCount} of ${n.totalCardCount} cards`,className:"flex w-full items-start gap-2 rounded-[4px] 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(s.CalendarRange,{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:"Global date filter"}),e.jsx("span",{className:"text-[11px] leading-[1.4] text-muted-foreground",children:"One date range, applied across every date-aware card on the dashboard."})]})]})]}),!u&&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."})]}),u&&e.jsx("div",{className:"flex flex-1 overflow-hidden",children:e.jsx(s.FilterableFieldsPanel,{context:"filter"})})]})}const z=!1;function ve({onAddFilter:t,onAddControl:a,onManageControls:h,onDismiss:u}){const n=o.useDashboardStore(c=>c.dashboard.filterLayout),{setFilterLayout:p}=o.useDashboardActions();n!=null&&n.displayMode;const d=(n==null?void 0:n.toolbarWrap)??!1;return n==null||n.showDownloadButton,e.jsxs("div",{className:"w-[300px]",children:[e.jsxs("div",{className:"p-1",children:[e.jsx(B,{icon:s.Filter,label:"Add filter",onClick:()=>{t(),u()}}),e.jsx(B,{icon:o.SlidersHorizontal,label:"Add control",onClick:()=>{a(),u()}}),e.jsx(B,{icon:s.Pencil,label:"Manage controls",onClick:()=>{h(),u()}})]}),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"}),z,e.jsx(be,{id:"filter-display-wrap",label:"Wrap to multiple lines",checked:d,onCheckedChange:c=>p({toolbarWrap:c===!0})}),z]})]})}function B({icon:t,label:a,onClick:h}){return e.jsxs("button",{type:"button",onClick:h,className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted/40",children:[e.jsx(t,{className:"h-3.5 w-3.5 text-muted-foreground"}),a]})}function be({id:t,label:a,checked:h,onCheckedChange:u}){return e.jsxs("div",{className:"flex items-center gap-2 rounded-[4px] px-1 py-1 transition-colors hover:bg-muted/40",children:[e.jsx(s.Checkbox,{id:t,checked:h,onCheckedChange:u}),e.jsx(o.Label,{htmlFor:t,className:"cursor-pointer text-[12px] font-normal leading-[1.3]",children:a})]})}function Ce({size:t,className:a,primaryButtonClassName:h,secondaryButtonClassName:u,pickerContentClassName:n,settingsContentClassName:p}){var F;const[d,c]=v.useState(null),l=o.useDashboardStore(w=>w.dashboard),r=o.useDashboardStore(w=>w.selectedSheetId),x=o.useDashboardStore(w=>w.showFilters),C=s.useAssistantLayoutStore(w=>w.setPanelOpen),i=o.useDashboardStore(w=>w.actions),{setDocumentInspectorTab:m,setShowFilters:j}=i,b=(F=l.sheets)==null?void 0:F.find(w=>w.id===r),D=o.isDocumentSheet(b),N=v.useCallback(w=>{window.setTimeout(()=>{c(w)},0)},[]),E=v.useCallback(w=>{if(D&&r){w&&m(r,"inputs");return}w&&C("dashboard",!1),j(w)},[D,r,m,C,j]),f=v.useCallback(()=>{E(!0)},[E]),S=v.useCallback(()=>{N("create")},[N]),I=v.useCallback(()=>{N("manage")},[N]);return e.jsxs(e.Fragment,{children:[e.jsx(W,{showFilters:D?!1:x,onShowFiltersChange:E,pickerContent:e.jsx(ge,{}),settingsContent:w=>e.jsx(ve,{onAddFilter:f,onAddControl:S,onManageControls:I,onDismiss:w}),size:t,className:a,primaryButtonClassName:h,secondaryButtonClassName:u,pickerContentClassName:n,settingsContentClassName:p}),d?D?e.jsx(G,{open:!0,onOpenChange:w=>{w||c(null)},initialMode:d}):e.jsx($,{open:!0,onOpenChange:w=>{w||c(null)},showTrigger:!1,initialMode:d}):null]})}exports.AdvancedModeToggle=Z;exports.DashboardControlsSettings=$;exports.DashboardFilterControlsButton=W;exports.DashboardFilterControlsLauncher=Ce;exports.DocumentControlsSettings=G;exports.ExportNotificationItem=q;exports.ExportNotificationList=H;exports.NotificationBell=de;exports.UnsavedChangesAlert=J;exports.VisualEditingControls=Y;exports.useExportPolling=ne;exports.useExportRecovery=ie;
|