react-semaphor 0.1.205 → 0.1.207

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 (30) hide show
  1. package/dist/chunks/{dashboard-controls-DekrQ0yg.js → dashboard-controls-CwMm9_ki.js} +1 -1
  2. package/dist/chunks/{dashboard-controls-n5_oB_dp.js → dashboard-controls-HlEsqiRq.js} +5 -5
  3. package/dist/chunks/{dashboard-json-VG8uFdaU.js → dashboard-json-CI8wIOzY.js} +1 -1
  4. package/dist/chunks/{dashboard-json-B5YyWsMv.js → dashboard-json-DoYcT7tI.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-DnfxWTj2.js → dashboard-summary-settings-dialog-eQcHYcAI.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-B7_fbNYb.js → dashboard-summary-settings-dialog-ioe7ZyFE.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-bl33bktZ.js → edit-dashboard-visual-BotbTTiL.js} +2 -2
  8. package/dist/chunks/{edit-dashboard-visual-BxDQKLvc.js → edit-dashboard-visual-Cl_qfIV_.js} +1 -1
  9. package/dist/chunks/{editor-action-buttons-DngVSXyw.js → editor-action-buttons-B0-mScSZ.js} +2 -2
  10. package/dist/chunks/{editor-action-buttons-BUAzU5tX.js → editor-action-buttons-CcXUQDy4.js} +1 -1
  11. package/dist/chunks/{index-em2ecoK3.js → index-CqOQuBxB.js} +9028 -9078
  12. package/dist/chunks/{index-CtLqMYAL.js → index-plgMsXq1.js} +215 -220
  13. package/dist/chunks/{notification-bell-Ck-SNMez.js → notification-bell-BI-XywDI.js} +271 -272
  14. package/dist/chunks/notification-bell-BSBRPw38.js +11 -0
  15. package/dist/chunks/{resource-management-panel-Ji1DZtnk.js → resource-management-panel-D0q51oXw.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-BGJ4XMn5.js → resource-management-panel-Z8x52dx2.js} +3 -3
  17. package/dist/chunks/{use-role-aware-display-preferences-C0-SK5cT.js → use-role-aware-display-preferences-BWghO18e.js} +1 -1
  18. package/dist/chunks/{use-role-aware-display-preferences-DEkMGyx9.js → use-role-aware-display-preferences-C-m9KEuJ.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-BYBat4tj.js → use-visual-utils-BbVM0bck.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-BLdGPBdR.js → use-visual-utils-DHmGIepC.js} +1 -1
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +5 -5
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/main.d.ts +13 -1
  29. package/package.json +1 -1
  30. package/dist/chunks/notification-bell-BWh1ZNB4.js +0 -11
@@ -0,0 +1,11 @@
1
+ "use strict";const p=require("react"),t=require("./index-plgMsXq1.js"),e=require("react/jsx-runtime"),N=require("./editor-action-buttons-CcXUQDy4.js"),T=require("./use-visual-utils-DHmGIepC.js"),I=require("./date-formatter-Sz6QDaM8.js");/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const P=t.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);/**
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 k=t.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"}]]),L=1e4,V=15e3,B=3e4,R=3e4,z=12e4,U=2*60*60*1e3;function O(s){const r=Date.now()-s.getTime();return r<R?L:r<z?V:B}function $(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(f=>f.activeExports),[n,c]=p.useState(typeof document<"u"?!document.hidden:!0),d=p.useRef(null),a=p.useRef(!1),o=p.useRef(void 0),j=r==null?void 0:r.apiServiceUrl,u=s==null?void 0:s.accessToken,g=p.useCallback(()=>{const f=t.useExportStore.getState().activeExports;return Array.from(f.values()).filter(b=>t.isExportInProgress(b.status))},[]);p.useEffect(()=>{if(typeof document>"u")return;const f=()=>{c(!document.hidden)};return document.addEventListener("visibilitychange",f),()=>{document.removeEventListener("visibilitychange",f)}},[]);const C=p.useCallback(async()=>{if(!j||!u){a.current=!1;return}const f=g();if(f.length===0){a.current=!1;return}const b=Date.now(),E=f.filter(l=>b-l.startedAt.getTime()>U);if(E.length>0){const{updateExport:l}=t.useExportStore.getState().actions;for(const i of E)l(i.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=f.filter(l=>b-l.startedAt.getTime()<=U);if(x.length===0){a.current=!1;return}const v=await Promise.allSettled(x.map(async l=>{try{const i=await t.getExportStatus(j,u,l.id);let w;if(i.status==="completed")try{w=await t.getDownloadUrl(j,u,l.id)}catch(y){console.error(`[useExportPolling] Failed to get download URL for ${l.id}:`,y)}return{id:l.id,status:i.status,progress:i.progress,completedChunks:i.completedChunks,completedAt:i.completedAt?new Date(i.completedAt):void 0,lastUpdatedAt:new Date,fileSize:i.fileSize,error:i.error,downloadUrl:w}}catch(i){return console.error(`[useExportPolling] Failed to poll export ${l.id}:`,i),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const l of v)l.status==="fulfilled"&&l.value&&S(l.value.id,l.value);const h=g();if(h.length>0&&!document.hidden){const l=h.reduce((w,y)=>y.startedAt<w?y.startedAt:w,h[0].startedAt),i=O(l);d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var w;(w=o.current)==null||w.call(o)},i)}else a.current=!1},[j,u,g]);return p.useEffect(()=>{o.current=C},[C]),p.useEffect(()=>{var b;g().length>0&&n&&!a.current&&(a.current=!0,(b=o.current)==null||b.call(o))},[m,n,g]),p.useEffect(()=>{var b;const f=g();n&&f.length>0&&!a.current&&(a.current=!0,(b=o.current)==null||b.call(o))},[n,g]),p.useEffect(()=>{!n&&d.current&&(clearTimeout(d.current),d.current=null,a.current=!1)},[n]),p.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),{isPolling:a.current,isTabVisible:n,inProgressCount:g().length}}function q(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(o=>o.activeExports),{addExport:n}=t.useExportActions(),c=p.useRef(!1),d=r==null?void 0:r.apiServiceUrl,a=s==null?void 0:s.accessToken;p.useEffect(()=>{if(c.current||!d||!a)return;(async()=>{try{const{exports:j}=await t.getExports(d,a,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const u of j){if(m.has(u.id))continue;const g=u.totalChunks?Math.round(u.completedChunks/u.totalChunks*100):0;let C;if(u.status==="completed")try{C=await t.getDownloadUrl(d,a,u.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${u.id}:`,b)}const f={id:u.id,status:u.status,progress:g,title:_(u),totalRows:u.totalRows,totalChunks:u.totalChunks,completedChunks:u.completedChunks,startedAt:new Date(u.createdAt),lastUpdatedAt:new Date,completedAt:u.completedAt?new Date(u.completedAt):void 0,fileSize:u.fileSize,error:u.error,expiresAt:new Date(u.expiresAt),downloadUrl:C};n(f)}c.current=!0}catch(j){console.error("[useExportRecovery] Failed to recover exports:",j),c.current=!0}})()},[d,a,n,m])}function _(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function H({open:s,onOpenChange:r,isLibraryVisual:m,currentVisualName:n,isSaving:c=!1,onConfirm:d}){const[a,o]=p.useState(m&&n?`Copy of ${n}`:n||""),[j,u]=p.useState(""),[g,C]=p.useState(!m),[f,b]=p.useState(!0);p.useEffect(()=>{s&&(o(m&&n?`Copy of ${n}`:n||""),u(""),C(!m),b(!0))},[s,m,n]);const E=()=>{a.trim()&&(!g&&!f||d({name:a.trim(),description:j.trim()||void 0,saveToLibrary:g,saveToCurrentDashboard:f}))},x=a.trim()&&(g||f);return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[425px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Save Visual As"}),e.jsx(t.DialogDescription,{children:m?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input$1,{id:"name",value:a,onChange:v=>o(v.target.value),placeholder:"Enter visual name",disabled:c})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:j,onChange:v=>u(v.target.value),placeholder:"Enter visual description",rows:3,disabled:c})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(t.Label,{children:"Save to:"}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-dashboard",checked:f,onCheckedChange:v=>b(!!v),disabled:c}),e.jsxs("label",{htmlFor:"save-to-dashboard",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Current Dashboard",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:m?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(t.Checkbox,{id:"save-to-library",checked:g,onCheckedChange:v=>C(!!v),disabled:c}),e.jsxs("label",{htmlFor:"save-to-library",className:"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",children:["Visual Library",e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:m?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!g&&!f&&e.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:c,children:"Cancel"}),e.jsxs(t.Button,{onClick:E,disabled:!x||c,children:[c&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),c?"Saving...":"Save"]})]})]})})}function X(){const[s,r]=p.useState(!1),[m,n]=p.useState(!1),[c,d]=p.useState(null),a=t.useEditorStore(i=>i.frame),o=t.useEditorStore(i=>i.card),j=t.useSelectedVisual(),u=t.useDashboardStore(i=>i.selectedSheetId),g=t.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),{getUpdatedFrame:C}=T.useVisualUtils(),{selectVisual:f}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:x}=t.useDashboardActions(),v=!!(a!=null&&a.visualId),S=(()=>{var i,w;return((i=a==null?void 0:a.cards)==null?void 0:i.length)===1&&((w=a.cards[0])!=null&&w.title)?a.cards[0].title:j!=null&&j.title?j.title:(o==null?void 0:o.title)||"Untitled Visual"})(),h=t.useCreateVisualWithFrame(i=>{if(i!=null&&i.id){if(f(i),m&&c&&u){const w={...c,id:t.v4(),visualId:i.id};b(u,w,"end"),E(w.id),n(!1),d(null),x(!1)}g(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async i=>{if(!u){t.ue.error("No sheet selected");return}const w=C(),A=w.cards.length===1?{...w,cards:w.cards.map(D=>({...D,title:i.name}))}:w;if(i.saveToLibrary){n(i.saveToCurrentDashboard),d(A);const D={title:i.name,description:i.description,frameObject:A,isPrivate:!1};h.mutate(D)}else if(i.saveToCurrentDashboard){const D={...A,id:t.v4(),visualId:void 0};b(u,D,"end"),E(D.id),t.ue.success("Visual saved to dashboard"),r(!1),x(!1)}},isLibraryVisual:v,currentVisualName:S,isSaving:h.isPending}}function G({className:s}){const r=t.useEditorStore(h=>h.frame),m=t.useEditorStore(h=>h.card),n=t.useManagementStore(h=>h.selectedVisual),c=t.useDashboardStore(h=>h.selectedFrameId),d=t.useDashboardStore(h=>h.selectedSheetId),{setIsVisualEditing:a}=t.useDashboardActions(),o=!!(r!=null&&r.visualId||n!=null&&n.id),j=!!(r!=null&&r.visualId&&c),u=o&&!j,{saveAsDialogOpen:g,setSaveAsDialogOpen:C,handleSaveAs:f,isLibraryVisual:b,currentVisualName:E,isSaving:x}=X(),{handleAddLibraryVisual:v}=T.useVisualUtils(),S=async()=>{if(!d){t.ue.error("No dashboard sheet selected");return}if(!n){t.ue.error("No visual selected");return}const h=await v(n);h.success?(t.ue.success("Visual added to dashboard"),a(!1)):t.ue.error(h.error||"Failed to add visual to dashboard")};return e.jsxs(e.Fragment,{children:[!o&&e.jsx(N.EditorAcceptButton,{className:s,variant:"default"}),o&&e.jsxs(e.Fragment,{children:[j&&e.jsx(N.VisualApplyLocalButton,{className:s}),u&&d&&m&&(m.sql||t.hasValidCardConfig(m.config))&&e.jsxs(t.Button,{onClick:S,className:t.cn(s),size:"sm",variant:"outline",children:[e.jsx(P,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),u&&e.jsx(N.VisualSaveButton,{className:s,variant:"default"}),j&&e.jsx(N.VisualSaveAndApplyButton,{className:s}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:h=>{h.stopPropagation(),C(!0)},children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!o&&e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{variant:"outline",size:"sm",className:t.cn(s,"w-8 p-0"),children:e.jsx(t.EllipsisVertical,{className:"h-4 w-4"})})}),e.jsx(t.DropdownMenuContent,{align:"end",children:e.jsxs(t.DropdownMenuItem,{onClick:()=>C(!0),children:[e.jsx(N.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),e.jsx(N.EditorCancelButton,{className:s}),e.jsx(H,{open:g,onOpenChange:h=>{x||C(h)},isLibraryVisual:b,currentVisualName:E,isSaving:x,onConfirm:f})]})}function W({className:s,switchClassName:r}){const m=t.useEditorStore(o=>o.isDevMode),n=t.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:c}=t.useEditorActions(),{config:d}=p.useContext(t.SemaphorContext).tokenProps,a=(d==null?void 0:d.showAdvancedMode)!==!1;return!n||!a?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:m,onCheckedChange:()=>c(!m),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Q({open:s,onOpenChange:r,onSave:m,onDiscard:n,isSaving:c}){const d=a=>{!a&&c||r(a)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:d,children:e.jsxs(t.AlertDialogContent,{className:"max-w-md",children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:e.jsx(t.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),e.jsx(t.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),e.jsxs(t.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[e.jsx(t.AlertDialogCancel,{disabled:c,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),e.jsx("button",{onClick:n,disabled:c,className:"order-2 rounded-md border border-destructive/20 bg-destructive/10 px-4 py-2 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:"Discard"}),e.jsx(t.AlertDialogAction,{onClick:m,disabled:c,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:c?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function Y(s,r,m,n){p.useEffect(()=>{s&&!m&&r&&n(t.cloneDeep(r))},[s,m,r,n])}function Z({triggerButtonClassName:s,variant:r="ghost"}){const[m,n]=p.useState(!1),c=t.useDashboardStore(a=>{var o;return(o=a.dashboard)==null?void 0:o.id}),d=t.useDashboardStore(a=>{var o;return(o=a.dashboard)==null?void 0:o.title});return c?e.jsxs(e.Fragment,{children:[e.jsx(t.IconButton,{tooltip:"Schedule Dashboard",className:t.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>n(!0),children:e.jsx(t.Clock,{className:"size-4"})}),e.jsx(t.EmailScheduleDialog,{open:m,onOpenChange:n,dashboardId:c,dashboardName:d})]}):null}function F({export:s,onRemove:r}){const m=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},n=o=>{o.stopPropagation(),r==null||r(s.id)},c=()=>{switch(s.status){case"completed":return e.jsx(t.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(N.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},d=t.isExportInProgress(s.status),a=(()=>{switch(s.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:[c(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:a}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:n,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:m,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),d&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function M(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(x=>x.activeExports),{clearCompleted:n,removeExport:c,updateExport:d}=t.useExportActions(),[a,o]=p.useState(!1),[j,u]=p.useState(!1),g=Array.from(m.values()).sort((x,v)=>v.startedAt.getTime()-x.startedAt.getTime()),C=g.some(x=>x.status==="completed"||x.status==="failed"),f=p.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,v=s==null?void 0:s.accessToken;if(!(!x||!v)){o(!0);try{const S=Array.from(m.values());await Promise.all(S.map(async h=>{try{const l=await t.getExportStatus(x,v,h.id);let i;if(l.status==="completed")try{i=await t.getDownloadUrl(x,v,h.id)}catch(w){console.error(`Failed to get download URL for ${h.id}:`,w)}d(h.id,{status:l.status,progress:l.progress,completedChunks:l.completedChunks,completedAt:l.completedAt?new Date(l.completedAt):void 0,lastUpdatedAt:new Date,fileSize:l.fileSize,error:l.error,downloadUrl:i})}catch(l){console.error(`Failed to refresh export ${h.id}:`,l)}}))}finally{o(!1)}}},[m,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,d]),b=p.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,v=s==null?void 0:s.accessToken;if(!x||!v){n();return}u(!0);try{const S=g.filter(l=>l.status==="completed"||l.status==="failed"),h=await Promise.allSettled(S.map(async l=>(await t.cancelExport(x,v,l.id),l.id)));for(const l of h)l.status==="fulfilled"?c(l.value):console.error("Failed to delete export:",l.reason)}finally{u(!1)}},[g,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,n,c]),E=p.useCallback(async x=>{const v=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(v&&S)try{await t.cancelExport(v,S,x),c(x);return}catch(h){console.error(`Failed to cancel export ${x}:`,h)}c(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,c]);return g.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(k,{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(k,{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(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:f,disabled:a,title:"Refresh status",children:e.jsx(t.RefreshCw,{className:`h-4 w-4 ${a?"animate-spin":""}`})}),C&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:j,children:j?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:g.map(x=>e.jsx(F,{export:x,onRemove:E},x.id))})})]})}function J(){const s=t.useExportStore(o=>o.activeExports),r=t.useInProgressExportsCount(),m=s.size>0,n=Array.from(s.values()).some(o=>o.status==="completed"||o.status==="failed"),d=r>0?r>9?"9+":String(r):null,a=m;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),a&&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-4 min-w-4 px-0.5 text-[10px] font-semibold":"right-0.5 top-0.5 h-2 w-2"}`,children:d})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(M,{})})]})}exports.AdvancedModeToggle=W;exports.ExportNotificationItem=F;exports.ExportNotificationList=M;exports.NotificationBell=J;exports.ScheduleDashboard=Z;exports.UnsavedChangesAlert=Q;exports.VisualEditingControls=G;exports.useExportPolling=$;exports.useExportRecovery=q;exports.usePristineSnapshotInitializer=Y;
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-CtLqMYAL.js"),c=require("react"),de=require("./use-visual-utils-BLdGPBdR.js"),pe=require("./use-role-aware-display-preferences-C0-SK5cT.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-plgMsXq1.js"),c=require("react"),de=require("./use-visual-utils-DHmGIepC.js"),pe=require("./use-role-aware-display-preferences-BWghO18e.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as n, Fragment as ge } from "react/jsx-runtime";
2
- import { bI as $e, u as me, bA as Je, bU as re, bY as Qe, bZ as Xe, b_ as ke, b$ as et, c0 as tt, B as _, c1 as st, c2 as nt, c3 as K, c4 as pe, H as oe, c5 as at, c6 as it, c7 as rt, c8 as Ce, c9 as De, ca as ot, cb as lt, a2 as dt, c as Q, cc as be, e as le, cd as Se, ce as Ee, cf as ct, ai as Ve, ag as Le, cg as Ae, ch as Te, ci as Oe, cj as Re, ck as Pe, cl as Ue, cm as Ie, cn as je, co as Me, cp as ut, cq as ht, cr as Fe, cs as ze, ct as Be, cu as mt, cv as He, cw as pt, bE as ae, l as ft, cx as _e, cy as gt, cz as Dt, m as xt, n as Nt, o as wt, p as vt, q as Ct, L as ye, cA as fe, G as yt, cB as bt, cC as St, cD as Et, cE as Vt } from "./index-em2ecoK3.js";
2
+ import { bI as $e, u as me, bA as Je, bU as re, bY as Qe, bZ as Xe, b_ as ke, b$ as et, c0 as tt, B as _, c1 as st, c2 as nt, c3 as K, c4 as pe, H as oe, c5 as at, c6 as it, c7 as rt, c8 as Ce, c9 as De, ca as ot, cb as lt, a2 as dt, c as Q, cc as be, e as le, cd as Se, ce as Ee, cf as ct, ai as Ve, ag as Le, cg as Ae, ch as Te, ci as Oe, cj as Re, ck as Pe, cl as Ue, cm as Ie, cn as je, co as Me, cp as ut, cq as ht, cr as Fe, cs as ze, ct as Be, cu as mt, cv as He, cw as pt, bE as ae, l as ft, cx as _e, cy as gt, cz as Dt, m as xt, n as Nt, o as wt, p as vt, q as Ct, L as ye, cA as fe, G as yt, cB as bt, cC as St, cD as Et, cE as Vt } from "./index-CqOQuBxB.js";
3
3
  import Lt, { useRef as At, useEffect as ie, useState as x } from "react";
4
- import { a as qe } from "./use-visual-utils-BYBat4tj.js";
5
- import { u as Tt } from "./use-role-aware-display-preferences-DEkMGyx9.js";
4
+ import { a as qe } from "./use-visual-utils-BbVM0bck.js";
5
+ import { u as Tt } from "./use-role-aware-display-preferences-C-m9KEuJ.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -1 +1 @@
1
- "use strict";const a=require("./index-CtLqMYAL.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
1
+ "use strict";const a=require("./index-plgMsXq1.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
@@ -1,4 +1,4 @@
1
- import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-em2ecoK3.js";
1
+ import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-CqOQuBxB.js";
2
2
  import { useMemo as i } from "react";
3
3
  function S() {
4
4
  const { displayPreferences: n, shouldShowElement: c } = m(), { currentUser: a, userContext: s } = t(), r = i(
@@ -1,4 +1,4 @@
1
- import { bT as G, l as Y, bP as J, bQ as K, bU as X, by as Q, bs as Z, u as v, bV as q, bW as ee, I as $, bX as te, bA as f } from "./index-em2ecoK3.js";
1
+ import { bT as G, l as Y, bP as J, bQ as K, bU as X, by as Q, bs as Z, u as v, bV as q, bW as ee, I as $, bX as te, bA as f } from "./index-CqOQuBxB.js";
2
2
  import { useState as j, useEffect as re, useCallback as A } from "react";
3
3
  function se(e) {
4
4
  const a = e.toUpperCase().indexOf("WHERE"), t = e.toUpperCase().indexOf("GROUP BY"), r = e.toUpperCase().indexOf("LIMIT"), s = e.toUpperCase().indexOf("ORDER BY");
@@ -1 +1 @@
1
- "use strict";const a=require("./index-CtLqMYAL.js"),g=require("react");function H(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),o=e.substring(n);return`${d} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),o=e.substring(t);return`${d} {{ filters | where }} ${o}`}else{const d=e.substring(0,c),o=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",o),o?`${d} {{ filters | where }} ${o}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function k(e){const[n,t]=g.useState(null),[r,s]=g.useState(null),c=a.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function Q(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],o=e.find(l=>l.tabTitle===d);return o?o.id:e[0].id}return n}}return e[0].id}const z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function M(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=a.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(s,l),a.ue.dismiss(d),{data:l,fromCache:!1}}catch(o){throw a.ue.dismiss(d),o}}function L(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function G(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=L(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(o=>o.id===r.activeCardId);return s?(a.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function Y(){var C;const{setCardSql:e}=a.useEditorActions(),n=a.useEditorStore(i=>i.frame),t=a.useEditorStore(i=>i.card),r=a.useEditorStore(i=>i.isDevMode),s=k(((C=t.customCardPreferences)==null?void 0:C.url)||""),c=a.useEditorStore(i=>i.selectedSchemaName),d=a.useEditorStore(i=>i.selectedDatamodelId),o=a.useEditorStore(i=>i.selectedDatabaseName),l=a.useEditorStore(i=>i.selectedTableName),h=a.useEditorStore(i=>i.selectedConnectionId),m=a.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let i=p;p&&!p.includes("{{")&&(i=H(p),e(i));const w=(I=s==null?void 0:s.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:z(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...w&&{customCardPreferences:{...t.customCardPreferences,settings:w}}},E=n.cards.map(S=>S.id===t.id?v:S);return{...n,cards:E,activeCardId:Q(E,n.activeCardId)}},[t,n,r,m,c,d,o,l,h,e,s,p])}}function J(){const{authToken:e,tokenProps:n}=a.useSemaphorContext(),t=a.useQueryClient(),r=a.useSelectedVisual(),{selectVisual:s}=a.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I}=a.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:V,setSelectedFrameId:$,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=a.useDashboardActions(),y=a.useDashboardStore(u=>u.selectedSheetId),O=a.useDashboardStore(u=>u.selectedFrameId),T=a.useDashboardStore(u=>u.dashboard),x=a.useDashboardStore(u=>u.filterValues),F=a.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),j=g.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await M(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!G(b,{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I,setIsDashboardEditing:S,setIsVisualEditing:V,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,S,V,o,l,h,m,p,D,C,i,w,v,E,I,A,T,y,O,x]),_=g.useCallback(async u=>{var b;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:B}=await M(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),P=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!P)return{success:!1,error:"Visual has no frame data"};const U=L(P);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const W={...a.cloneFrameWithNewIds(U),visualId:u.id};return N(y,W,"end"),S(!0),$(W.id),R(!1),{success:!0,fromCache:B}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,N,S,$,R]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:j,handleAddLibraryVisual:_,getUpdatedFrame:Y().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=k;exports.useVisualUtils=J;
1
+ "use strict";const a=require("./index-plgMsXq1.js"),g=require("react");function H(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),o=e.substring(n);return`${d} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),o=e.substring(t);return`${d} {{ filters | where }} ${o}`}else{const d=e.substring(0,c),o=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",o),o?`${d} {{ filters | where }} ${o}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function k(e){const[n,t]=g.useState(null),[r,s]=g.useState(null),c=a.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function Q(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],o=e.find(l=>l.tabTitle===d);return o?o.id:e[0].id}return n}}return e[0].id}const z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function M(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=a.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(s,l),a.ue.dismiss(d),{data:l,fromCache:!1}}catch(o){throw a.ue.dismiss(d),o}}function L(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function G(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=L(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(o=>o.id===r.activeCardId);return s?(a.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function Y(){var C;const{setCardSql:e}=a.useEditorActions(),n=a.useEditorStore(i=>i.frame),t=a.useEditorStore(i=>i.card),r=a.useEditorStore(i=>i.isDevMode),s=k(((C=t.customCardPreferences)==null?void 0:C.url)||""),c=a.useEditorStore(i=>i.selectedSchemaName),d=a.useEditorStore(i=>i.selectedDatamodelId),o=a.useEditorStore(i=>i.selectedDatabaseName),l=a.useEditorStore(i=>i.selectedTableName),h=a.useEditorStore(i=>i.selectedConnectionId),m=a.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let i=p;p&&!p.includes("{{")&&(i=H(p),e(i));const w=(I=s==null?void 0:s.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:z(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...w&&{customCardPreferences:{...t.customCardPreferences,settings:w}}},E=n.cards.map(S=>S.id===t.id?v:S);return{...n,cards:E,activeCardId:Q(E,n.activeCardId)}},[t,n,r,m,c,d,o,l,h,e,s,p])}}function J(){const{authToken:e,tokenProps:n}=a.useSemaphorContext(),t=a.useQueryClient(),r=a.useSelectedVisual(),{selectVisual:s}=a.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I}=a.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:V,setSelectedFrameId:$,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=a.useDashboardActions(),y=a.useDashboardStore(u=>u.selectedSheetId),O=a.useDashboardStore(u=>u.selectedFrameId),T=a.useDashboardStore(u=>u.dashboard),x=a.useDashboardStore(u=>u.filterValues),F=a.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),j=g.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await M(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!G(b,{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I,setIsDashboardEditing:S,setIsVisualEditing:V,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,S,V,o,l,h,m,p,D,C,i,w,v,E,I,A,T,y,O,x]),_=g.useCallback(async u=>{var b;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:B}=await M(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),P=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!P)return{success:!1,error:"Visual has no frame data"};const U=L(P);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const W={...a.cloneFrameWithNewIds(U),visualId:u.id};return N(y,W,"end"),S(!0),$(W.id),R(!1),{success:!0,fromCache:B}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,N,S,$,R]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:j,handleAddLibraryVisual:_,getUpdatedFrame:Y().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=k;exports.useVisualUtils=J;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-CtLqMYAL.js"),o=require("../chunks/common-types-CfJLrTJd.js");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=o.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-plgMsXq1.js"),o=require("../chunks/common-types-CfJLrTJd.js");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=o.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as a } from "../chunks/index-em2ecoK3.js";
1
+ import { D as a } from "../chunks/index-CqOQuBxB.js";
2
2
  import { E as s } from "../chunks/common-types-DhqlRVrq.js";
3
3
  export {
4
4
  a as Dashboard,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-CtLqMYAL.js"),j=require("./chunks/common-types-CfJLrTJd.js"),D=require("./chunks/dashboard-summary-settings-dialog-B7_fbNYb.js"),t=require("react/jsx-runtime"),C=require("react"),v=require("./chunks/resource-management-panel-Ji1DZtnk.js"),N=require("./types/index.cjs");require("react-dom");const c=require("./chunks/notification-bell-BWh1ZNB4.js");function P(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(a,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}return a.default=r,Object.freeze(a)}const h=P(C);function M(r){const{displayPreferences:a,...o}=r,i={...o,id:r.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:r.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",...i,children:t.jsx(_,{cardId:r.cardId})})})})]})})}function _({cardId:r}){const a=e.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.sheets}),{card:o,frame:i}=C.useMemo(()=>{const n=a==null?void 0:a.flatMap(s=>s.frames),l=n==null?void 0:n.flatMap(s=>s==null?void 0:s.cards),x=l==null?void 0:l.find(s=>(s==null?void 0:s.id)===r),u=n==null?void 0:n.find(s=>{var p;return(p=s==null?void 0:s.cards)==null?void 0:p.find(m=>(m==null?void 0:m.id)===r)});return{card:x,frame:u}},[a,r]);return!o||!i?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${r}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:l})=>t.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:l,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:o,frame:i})})})}function I({name:r,items:a,value:o,onChange:i,isLoading:n,isError:l,refetch:x,className:u,icon:s,showNone:p=!1}){const m=h.useRef(null),[f,y]=h.useState(!1),[E,S]=h.useState("100%"),g=p?[...a||[],{id:"none",name:"None"}]:a;h.useLayoutEffect(()=>{m.current&&S(m.current.offsetWidth)},[]);function b(){var d;return n?"Loading...":l?"Error":o?(d=a==null?void 0:a.find(A=>A.id===o))==null?void 0:d.name:`Select ${r}`}function T(d,A){i(A),y(!1)}return t.jsxs(e.Popover,{open:f,onOpenChange:y,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:m,variant:"outline",role:"combobox","aria-expanded":f,className:e.cn("flex h-9 w-full justify-between",u),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[s&&t.jsx("div",{className:"mr-2",children:s}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:b()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:E},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:x,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",r==null?void 0:r.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:g==null?void 0:g.map(d=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:A=>T(A,d.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",o===d.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}function R(r,a){C.useEffect(()=>(r&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{r&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[r,a])}function w(){var l,x;const{quotasQuery:r,usageQuery:a}=e.useAlertQuotas(),o=((l=r.data)==null?void 0:l.quotas)||[],i=((x=a.data)==null?void 0:x.usage)||[],n=new Map(i.map(u=>[u.tenantId||"org",u]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{r.refetch(),a.refetch()},children:"Refresh"})]}),r.isLoading||a.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:o.map(u=>{const s=u.tenantId||"org",p=n.get(s);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:s}),t.jsx("td",{className:"px-3 py-2",children:(p==null?void 0:p.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:u.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[u.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:u.policy.maxContextSources})]},s)})})]})})]})}exports.AlertCreationDialog=e.AlertCreationDialog;exports.AlertManagementPage=e.AlertManagementPage;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.interpretAlertContext=e.interpretAlertContext;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAlertActions=e.useAlertActions;exports.useAlertBacktest=e.useAlertBacktest;exports.useAlertContextBuilder=e.useAlertContextBuilder;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=j.EMPTY_SELECTION;exports.CalendarPreferencesDialog=D.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=D.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=v.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=N.DEFAULT_CALENDAR_CONTEXT;exports.AdvancedModeToggle=c.AdvancedModeToggle;exports.ExportNotificationItem=c.ExportNotificationItem;exports.ExportNotificationList=c.ExportNotificationList;exports.NotificationBell=c.NotificationBell;exports.ScheduleDashboard=c.ScheduleDashboard;exports.UnsavedChangesAlert=c.UnsavedChangesAlert;exports.VisualEditingControls=c.VisualEditingControls;exports.useExportPolling=c.useExportPolling;exports.useExportRecovery=c.useExportRecovery;exports.usePristineSnapshotInitializer=c.usePristineSnapshotInitializer;exports.Combobox=I;exports.TenantQuotaPage=w;exports.Visual=M;exports.useExposePrintState=R;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-plgMsXq1.js"),j=require("./chunks/common-types-CfJLrTJd.js"),D=require("./chunks/dashboard-summary-settings-dialog-ioe7ZyFE.js"),t=require("react/jsx-runtime"),C=require("react"),v=require("./chunks/resource-management-panel-D0q51oXw.js"),N=require("./types/index.cjs");require("react-dom");const c=require("./chunks/notification-bell-BSBRPw38.js");function P(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const o in r)if(o!=="default"){const i=Object.getOwnPropertyDescriptor(r,o);Object.defineProperty(a,o,i.get?i:{enumerable:!0,get:()=>r[o]})}}return a.default=r,Object.freeze(a)}const h=P(C);function M(r){const{displayPreferences:a,...o}=r,i={...o,id:r.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:i,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:r.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:a,children:t.jsx(e.Container,{type:"visual",...i,children:t.jsx(_,{cardId:r.cardId})})})})]})})}function _({cardId:r}){const a=e.useDashboardStore(n=>{var l;return(l=n.dashboard)==null?void 0:l.sheets}),{card:o,frame:i}=C.useMemo(()=>{const n=a==null?void 0:a.flatMap(s=>s.frames),l=n==null?void 0:n.flatMap(s=>s==null?void 0:s.cards),x=l==null?void 0:l.find(s=>(s==null?void 0:s.id)===r),u=n==null?void 0:n.find(s=>{var p;return(p=s==null?void 0:s.cards)==null?void 0:p.find(m=>(m==null?void 0:m.id)===r)});return{card:x,frame:u}},[a,r]);return!o||!i?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${r}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:n,resetErrorBoundary:l})=>t.jsx(e.FallbackVisual,{error:n,resetErrorBoundary:l,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:o,frame:i})})})}function I({name:r,items:a,value:o,onChange:i,isLoading:n,isError:l,refetch:x,className:u,icon:s,showNone:p=!1}){const m=h.useRef(null),[f,y]=h.useState(!1),[E,S]=h.useState("100%"),g=p?[...a||[],{id:"none",name:"None"}]:a;h.useLayoutEffect(()=>{m.current&&S(m.current.offsetWidth)},[]);function b(){var d;return n?"Loading...":l?"Error":o?(d=a==null?void 0:a.find(A=>A.id===o))==null?void 0:d.name:`Select ${r}`}function T(d,A){i(A),y(!1)}return t.jsxs(e.Popover,{open:f,onOpenChange:y,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:m,variant:"outline",role:"combobox","aria-expanded":f,className:e.cn("flex h-9 w-full justify-between",u),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[s&&t.jsx("div",{className:"mr-2",children:s}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:b()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:E},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:x,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",n&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",r==null?void 0:r.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:g==null?void 0:g.map(d=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:d.name,onSelect:A=>T(A,d.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",o===d.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:d.name,children:d.name})]})},d.id))})]})]})})]})}function R(r,a){C.useEffect(()=>(r&&a&&(window.__SEMAPHOR_PRINT_STATE__={...a}),()=>{r&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[r,a])}function w(){var l,x;const{quotasQuery:r,usageQuery:a}=e.useAlertQuotas(),o=((l=r.data)==null?void 0:l.quotas)||[],i=((x=a.data)==null?void 0:x.usage)||[],n=new Map(i.map(u=>[u.tenantId||"org",u]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{r.refetch(),a.refetch()},children:"Refresh"})]}),r.isLoading||a.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:o.map(u=>{const s=u.tenantId||"org",p=n.get(s);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:s}),t.jsx("td",{className:"px-3 py-2",children:(p==null?void 0:p.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:u.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[u.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:u.policy.maxContextSources})]},s)})})]})})]})}exports.AlertCreationDialog=e.AlertCreationDialog;exports.AlertManagementPage=e.AlertManagementPage;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.interpretAlertContext=e.interpretAlertContext;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAlertActions=e.useAlertActions;exports.useAlertBacktest=e.useAlertBacktest;exports.useAlertContextBuilder=e.useAlertContextBuilder;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=j.EMPTY_SELECTION;exports.CalendarPreferencesDialog=D.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=D.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=v.ResourceManagementPanel;exports.DEFAULT_CALENDAR_CONTEXT=N.DEFAULT_CALENDAR_CONTEXT;exports.AdvancedModeToggle=c.AdvancedModeToggle;exports.ExportNotificationItem=c.ExportNotificationItem;exports.ExportNotificationList=c.ExportNotificationList;exports.NotificationBell=c.NotificationBell;exports.ScheduleDashboard=c.ScheduleDashboard;exports.UnsavedChangesAlert=c.UnsavedChangesAlert;exports.VisualEditingControls=c.VisualEditingControls;exports.useExportPolling=c.useExportPolling;exports.useExportRecovery=c.useExportRecovery;exports.usePristineSnapshotInitializer=c.usePristineSnapshotInitializer;exports.Combobox=I;exports.TenantQuotaPage=w;exports.Visual=M;exports.useExposePrintState=R;
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { T as y, U as T, V as P, W as _, Y as w, Z as M, _ as I, u as R, $ as g, a0 as F, P as L, s as k, B as E, a1 as B, c as A, t as Q, v as U, w as V, a2 as q, a3 as z, x as H, y as O, z as j, A as W, E as G, a4 as K } from "./chunks/index-em2ecoK3.js";
2
- import { a5 as ie, a6 as de, a7 as ce, a8 as ue, a9 as me, aa as pe, ab as he, D as be, ac as fe, ad as Ae, ae as xe, af as Ce, ag as ge, ah as ye, ah as Ee, ai as Ne, aj as De, a as ve, ak as Se, al as Te, am as Pe, an as _e, ao as we, ap as Me, aq as Ie, ar as Re, as as Fe, at as Le, au as ke, av as Be, aw as Qe, ax as Ue, ay as Ve, az as qe, aA as ze, aB as He, aC as Oe, aD as je, aE as We, aF as Ge, aG as Ke, aH as Ye, aI as $e, aJ as Xe, aK as Ze, aL as Je, aM as ea, aN as aa, aO as sa, aP as ta, aQ as ra, aR as oa, aS as na, aT as la, aU as ia, aV as da, aW as ca, aX as ua, aY as ma, aZ as pa, a_ as ha, a$ as ba, b0 as fa, b1 as Aa, b2 as xa, b3 as Ca, b4 as ga, b5 as ya, b6 as Ea, b7 as Na, b8 as Da, b9 as va, ba as Sa, bb as Ta, bc as Pa, bd as _a, be as wa, bf as Ma, bg as Ia, bh as Ra, bi as Fa, bj as La, bk as ka, bl as Ba, bm as Qa, bn as Ua, bo as Va, bp as qa, bq as za, br as Ha, bs as Oa, bt as ja, bu as Wa, bv as Ga, bw as Ka, bx as Ya, by as $a, bz as Xa, bA as Za, bB as Ja, bC as es, bD as as, bE as ss, bF as ts, bG as rs, bH as os } from "./chunks/index-em2ecoK3.js";
1
+ import { T as y, U as T, V as P, W as _, Y as w, Z as M, _ as I, u as R, $ as g, a0 as F, P as L, s as k, B as E, a1 as B, c as A, t as Q, v as U, w as V, a2 as q, a3 as z, x as H, y as O, z as j, A as W, E as G, a4 as K } from "./chunks/index-CqOQuBxB.js";
2
+ import { a5 as ie, a6 as de, a7 as ce, a8 as ue, a9 as me, aa as pe, ab as he, D as be, ac as fe, ad as Ae, ae as xe, af as Ce, ag as ge, ah as ye, ah as Ee, ai as Ne, aj as De, a as ve, ak as Se, al as Te, am as Pe, an as _e, ao as we, ap as Me, aq as Ie, ar as Re, as as Fe, at as Le, au as ke, av as Be, aw as Qe, ax as Ue, ay as Ve, az as qe, aA as ze, aB as He, aC as Oe, aD as je, aE as We, aF as Ge, aG as Ke, aH as Ye, aI as $e, aJ as Xe, aK as Ze, aL as Je, aM as ea, aN as aa, aO as sa, aP as ta, aQ as ra, aR as oa, aS as na, aT as la, aU as ia, aV as da, aW as ca, aX as ua, aY as ma, aZ as pa, a_ as ha, a$ as ba, b0 as fa, b1 as Aa, b2 as xa, b3 as Ca, b4 as ga, b5 as ya, b6 as Ea, b7 as Na, b8 as Da, b9 as va, ba as Sa, bb as Ta, bc as Pa, bd as _a, be as wa, bf as Ma, bg as Ia, bh as Ra, bi as Fa, bj as La, bk as ka, bl as Ba, bm as Qa, bn as Ua, bo as Va, bp as qa, bq as za, br as Ha, bs as Oa, bt as ja, bu as Wa, bv as Ga, bw as Ka, bx as Ya, by as $a, bz as Xa, bA as Za, bB as Ja, bC as es, bD as as, bE as ss, bF as ts, bG as rs, bH as os } from "./chunks/index-CqOQuBxB.js";
3
3
  import { E as ls } from "./chunks/common-types-DhqlRVrq.js";
4
- import { C as ds, D as cs } from "./chunks/dashboard-summary-settings-dialog-DnfxWTj2.js";
4
+ import { C as ds, D as cs } from "./chunks/dashboard-summary-settings-dialog-eQcHYcAI.js";
5
5
  import { jsx as e, jsxs as o } from "react/jsx-runtime";
6
6
  import * as b from "react";
7
7
  import { useMemo as Y, useEffect as $ } from "react";
8
- import { ResourceManagementPanel as ms } from "./chunks/resource-management-panel-BGJ4XMn5.js";
8
+ import { ResourceManagementPanel as ms } from "./chunks/resource-management-panel-Z8x52dx2.js";
9
9
  import { DEFAULT_CALENDAR_CONTEXT as hs } from "./types/index.js";
10
10
  import "react-dom";
11
- import { A as fs, E as As, a as xs, N as Cs, S as gs, U as ys, V as Es, u as Ns, b as Ds, c as vs } from "./chunks/notification-bell-Ck-SNMez.js";
11
+ import { A as fs, E as As, a as xs, N as Cs, S as gs, U as ys, V as Es, u as Ns, b as Ds, c as vs } from "./chunks/notification-bell-BI-XywDI.js";
12
12
  function se(a) {
13
13
  const { displayPreferences: s, ...i } = a, c = {
14
14
  ...i,