react-semaphor 0.1.296 → 0.1.297

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 (35) hide show
  1. package/dist/chunks/{braces-DVrX_3Q_.js → braces-BT-cB4J_.js} +1 -1
  2. package/dist/chunks/{braces-BNXseceK.js → braces-CSunPeAg.js} +1 -1
  3. package/dist/chunks/{dashboard-controls-CKKZcVA5.js → dashboard-controls-C6254Ugx.js} +5 -5
  4. package/dist/chunks/{dashboard-controls-DS2xJxHU.js → dashboard-controls-Za3WPtTh.js} +1 -1
  5. package/dist/chunks/{dashboard-filter-controls-button-xPaIlNHP.js → dashboard-filter-controls-button-DZnR5IgP.js} +178 -210
  6. package/dist/chunks/dashboard-filter-controls-button-dYWccDmw.js +11 -0
  7. package/dist/chunks/{dashboard-json-cuj9vYY9.js → dashboard-json-CuI5gkwY.js} +1 -1
  8. package/dist/chunks/{dashboard-json-ovQyHWw6.js → dashboard-json-DjpkfbSZ.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-BUg3Qyhh.js → dashboard-summary-settings-dialog-C6FUhXQy.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-DF076HeJ.js → dashboard-summary-settings-dialog-vC2shhM-.js} +1 -1
  11. package/dist/chunks/edit-dashboard-visual-CoG-tE_T.js +188 -0
  12. package/dist/chunks/{edit-dashboard-visual-32TAM00c.js → edit-dashboard-visual-TBI9_Pyh.js} +5738 -5867
  13. package/dist/chunks/{index-Dbrs96G8.js → index--CoasbAE.js} +272 -282
  14. package/dist/chunks/{index-BDeJH9hO.js → index-D0iNspb-.js} +34113 -33792
  15. package/dist/chunks/{resource-management-panel-2qcXsKwg.js → resource-management-panel-Cf4FTR33.js} +1 -1
  16. package/dist/chunks/{resource-management-panel-C4qoxy_g.js → resource-management-panel-HOWOJUap.js} +2 -2
  17. package/dist/chunks/{use-create-flow-overlay-state-CHeppRNE.js → use-create-flow-overlay-state-B7bE6z5B.js} +2 -2
  18. package/dist/chunks/{use-create-flow-overlay-state-BMD3YRzU.js → use-create-flow-overlay-state-BqiJrgeK.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-dOYWf6nM.js → use-visual-utils-DP6ty2_T.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-BIHLaVwh.js → use-visual-utils-DyvrB6Zh.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/dashboard.d.ts +10 -0
  29. package/dist/types/main.d.ts +29 -11
  30. package/dist/types/shared.d.ts +10 -0
  31. package/dist/types/surfboard.d.ts +10 -0
  32. package/dist/types/types.d.ts +10 -0
  33. package/package.json +1 -1
  34. package/dist/chunks/dashboard-filter-controls-button-nqfmscB7.js +0 -11
  35. package/dist/chunks/edit-dashboard-visual-BtiMcO-L.js +0 -183
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-Dbrs96G8.js"),e=require("../types/index.cjs"),r=require("../chunks/dashboard-summary-settings-dialog-BUg3Qyhh.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index--CoasbAE.js"),e=require("../types/index.cjs"),r=require("../chunks/dashboard-summary-settings-dialog-C6FUhXQy.js");exports.Surfboard=a.DashboardPlus;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;exports.CalendarPreferencesDialog=r.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=r.DashboardSummarySettingsDialog;
@@ -1,6 +1,6 @@
1
- import { a as o } from "../chunks/index-BDeJH9hO.js";
1
+ import { a as o } from "../chunks/index-D0iNspb-.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as s, EMPTY_SELECTION as D } from "../types/index.js";
3
- import { C as m, D as t } from "../chunks/dashboard-summary-settings-dialog-DF076HeJ.js";
3
+ import { C as m, D as t } from "../chunks/dashboard-summary-settings-dialog-vC2shhM-.js";
4
4
  export {
5
5
  s as CONTROL_CARD_DEFAULT_VALUE,
6
6
  m as CalendarPreferencesDialog,
@@ -743,6 +743,7 @@ export declare type DocumentTableSection = {
743
743
  repeatHeaderOnPageBreak?: boolean;
744
744
  rowHeightPx?: number;
745
745
  style?: DocumentTableStyle;
746
+ totalsStyle?: DocumentTableTotalsStyle;
746
747
  };
747
748
  };
748
749
 
@@ -756,6 +757,15 @@ export declare type DocumentTableStyle = {
756
757
  wrapText?: boolean;
757
758
  };
758
759
 
760
+ export declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
761
+
762
+ export declare type DocumentTableTotalsStyle = {
763
+ backgroundColor?: string;
764
+ textColor?: string;
765
+ fontWeight?: DocumentTableTotalsFontWeight;
766
+ borderTop?: boolean;
767
+ };
768
+
759
769
  export declare type DocumentTextContent = DocumentTextNode[];
760
770
 
761
771
  export declare type DocumentTextInlineFormat = {
@@ -330,21 +330,16 @@ declare type AddFrameOptions = {
330
330
  };
331
331
 
332
332
  /**
333
- * Segmented control that flips the editor between Drag-and-drop and SQL
334
- * modes. Replaces the earlier single-switch toggletwo labeled buttons
335
- * read more clearly than a toggle whose state requires translating an
336
- * icon.
337
- *
338
- * Layout matches the Filter split-button: a bordered shell with two
339
- * ghost-button segments inside. The active segment gets a muted fill;
340
- * the inactive segment is transparent so the surface behind shows
341
- * through.
333
+ * Single-button mode toggle (action pattern). The label reflects where
334
+ * a click will take you, not where you currently are e.g. while in
335
+ * drag-and-drop mode the button shows `</> SQL`. Compact, matches the
336
+ * "Edit / Done" toggle convention.
342
337
  */
343
338
  export declare function AdvancedModeToggle({ className }: AdvancedModeToggleProps): JSX.Element | null;
344
339
 
345
340
  declare interface AdvancedModeToggleProps {
346
- /** @deprecated Kept for API compatibility; the segmented control
347
- * handles its own layout. */
341
+ /** @deprecated Kept for API compatibility; the toggle handles its
342
+ * own layout. */
348
343
  className?: string;
349
344
  /** @deprecated The old DevModeSwitch prop has no analogue here. */
350
345
  labelClassName?: string;
@@ -1889,6 +1884,7 @@ export declare type DocumentTableSection = {
1889
1884
  repeatHeaderOnPageBreak?: boolean;
1890
1885
  rowHeightPx?: number;
1891
1886
  style?: DocumentTableStyle;
1887
+ totalsStyle?: DocumentTableTotalsStyle;
1892
1888
  };
1893
1889
  };
1894
1890
 
@@ -1902,6 +1898,15 @@ export declare type DocumentTableStyle = {
1902
1898
  wrapText?: boolean;
1903
1899
  };
1904
1900
 
1901
+ export declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
1902
+
1903
+ export declare type DocumentTableTotalsStyle = {
1904
+ backgroundColor?: string;
1905
+ textColor?: string;
1906
+ fontWeight?: DocumentTableTotalsFontWeight;
1907
+ borderTop?: boolean;
1908
+ };
1909
+
1905
1910
  export declare type DocumentTextContent = DocumentTextNode[];
1906
1911
 
1907
1912
  export declare type DocumentTextInlineFormat = {
@@ -2751,6 +2756,8 @@ declare type FixedMonthDefaultDateFilter = {
2751
2756
  month: number;
2752
2757
  };
2753
2758
 
2759
+ export declare type FlatTableTotalsBehavior = 'sum' | 'avg' | 'count' | 'label';
2760
+
2754
2761
  export declare function fmt(str: string): string;
2755
2762
 
2756
2763
  /**
@@ -3452,6 +3459,7 @@ export declare interface QueryExecutionResponse {
3452
3459
  subtotalColumns?: string[];
3453
3460
  columnSubtotalMeta?: any;
3454
3461
  columnKeyMap?: QueryColumnKeyMap;
3462
+ tableTotalsByColumnId?: Record<string, string | number | null>;
3455
3463
  metadata?: any;
3456
3464
  }
3457
3465
 
@@ -3865,6 +3873,16 @@ declare type TablePreferences = {
3865
3873
  documentWrapText?: boolean;
3866
3874
  };
3867
3875
 
3876
+ export declare type TableTotalsRequest = {
3877
+ source: 'documentFlatTable';
3878
+ columns: Array<{
3879
+ fieldId: string;
3880
+ role: 'detail' | 'groupby' | 'metric';
3881
+ behavior: FlatTableTotalsBehavior;
3882
+ label?: string;
3883
+ }>;
3884
+ };
3885
+
3868
3886
  /**
3869
3887
  * Target column configuration for multi-field filters.
3870
3888
  * Allows a single filter to target multiple columns from the SAME table,
@@ -617,6 +617,7 @@ declare type DocumentTableSection = {
617
617
  repeatHeaderOnPageBreak?: boolean;
618
618
  rowHeightPx?: number;
619
619
  style?: DocumentTableStyle;
620
+ totalsStyle?: DocumentTableTotalsStyle;
620
621
  };
621
622
  };
622
623
 
@@ -630,6 +631,15 @@ declare type DocumentTableStyle = {
630
631
  wrapText?: boolean;
631
632
  };
632
633
 
634
+ declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
635
+
636
+ declare type DocumentTableTotalsStyle = {
637
+ backgroundColor?: string;
638
+ textColor?: string;
639
+ fontWeight?: DocumentTableTotalsFontWeight;
640
+ borderTop?: boolean;
641
+ };
642
+
633
643
  declare type DocumentTextContent = DocumentTextNode[];
634
644
 
635
645
  declare type DocumentTextInlineFormat = {
@@ -763,6 +763,7 @@ export declare type DocumentTableSection = {
763
763
  repeatHeaderOnPageBreak?: boolean;
764
764
  rowHeightPx?: number;
765
765
  style?: DocumentTableStyle;
766
+ totalsStyle?: DocumentTableTotalsStyle;
766
767
  };
767
768
  };
768
769
 
@@ -776,6 +777,15 @@ export declare type DocumentTableStyle = {
776
777
  wrapText?: boolean;
777
778
  };
778
779
 
780
+ export declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
781
+
782
+ export declare type DocumentTableTotalsStyle = {
783
+ backgroundColor?: string;
784
+ textColor?: string;
785
+ fontWeight?: DocumentTableTotalsFontWeight;
786
+ borderTop?: boolean;
787
+ };
788
+
779
789
  export declare type DocumentTextContent = DocumentTextNode[];
780
790
 
781
791
  export declare type DocumentTextInlineFormat = {
@@ -1032,6 +1032,7 @@ export declare type DocumentTableSection = {
1032
1032
  repeatHeaderOnPageBreak?: boolean;
1033
1033
  rowHeightPx?: number;
1034
1034
  style?: DocumentTableStyle;
1035
+ totalsStyle?: DocumentTableTotalsStyle;
1035
1036
  };
1036
1037
  };
1037
1038
 
@@ -1045,6 +1046,15 @@ export declare type DocumentTableStyle = {
1045
1046
  wrapText?: boolean;
1046
1047
  };
1047
1048
 
1049
+ export declare type DocumentTableTotalsFontWeight = 'normal' | 'medium' | 'semibold' | 'bold';
1050
+
1051
+ export declare type DocumentTableTotalsStyle = {
1052
+ backgroundColor?: string;
1053
+ textColor?: string;
1054
+ fontWeight?: DocumentTableTotalsFontWeight;
1055
+ borderTop?: boolean;
1056
+ };
1057
+
1048
1058
  export declare type DocumentTextContent = DocumentTextNode[];
1049
1059
 
1050
1060
  export declare type DocumentTextInlineFormat = {
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.296",
8
+ "version": "0.1.297",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -1,11 +0,0 @@
1
- "use strict";const v=require("react"),e=require("./index-Dbrs96G8.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-BMD3YRzU.js"),z=require("./use-visual-utils-dOYWf6nM.js"),M=require("./date-formatter-CqXdM6JO.js");/**
2
- * @license lucide-react v0.453.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const U=e.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
7
- * @license lucide-react v0.453.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const H=e.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]),$=1e4,_=15e3,q=3e4,X=3e4,G=12e4,V=2*60*60*1e3;function K(s){const r=Date.now()-s.getTime();return r<X?$:r<G?_:q}function Q(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(p=>p.activeExports),[l,n]=v.useState(typeof document<"u"?!document.hidden:!0),c=v.useRef(null),d=v.useRef(!1),u=v.useRef(void 0),i=r==null?void 0:r.apiServiceUrl,a=s==null?void 0:s.accessToken,h=v.useCallback(()=>{const p=e.useExportStore.getState().activeExports;return Array.from(p.values()).filter(w=>e.isExportInProgress(w.status))},[]);v.useEffect(()=>{if(typeof document>"u")return;const p=()=>{n(!document.hidden)};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]);const b=v.useCallback(async()=>{if(!i||!a){d.current=!1;return}const p=h();if(p.length===0){d.current=!1;return}const w=Date.now(),E=p.filter(o=>w-o.startedAt.getTime()>V);if(E.length>0){const{updateExport:o}=e.useExportStore.getState().actions;for(const C of E)o(C.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=p.filter(o=>w-o.startedAt.getTime()<=V);if(x.length===0){d.current=!1;return}const y=await Promise.allSettled(x.map(async o=>{try{const C=await e.getExportStatus(i,a,o.id);let S;if(C.status==="completed")try{S=await e.getDownloadUrl(i,a,o.id)}catch(F){console.error(`[useExportPolling] Failed to get download URL for ${o.id}:`,F)}return{id:o.id,status:C.status,progress:C.progress,completedChunks:C.completedChunks,completedAt:C.completedAt?new Date(C.completedAt):void 0,lastUpdatedAt:new Date,fileSize:C.fileSize,error:C.error,downloadUrl:S}}catch(C){return console.error(`[useExportPolling] Failed to poll export ${o.id}:`,C),null}})),{updateExport:N}=e.useExportStore.getState().actions;for(const o of y)o.status==="fulfilled"&&o.value&&N(o.value.id,o.value);const j=h();if(j.length>0&&!document.hidden){const o=j.reduce((S,F)=>F.startedAt<S?F.startedAt:S,j[0].startedAt),C=K(o);c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{var S;(S=u.current)==null||S.call(u)},C)}else d.current=!1},[i,a,h]);return v.useEffect(()=>{u.current=b},[b]),v.useEffect(()=>{var w;h().length>0&&l&&!d.current&&(d.current=!0,(w=u.current)==null||w.call(u))},[f,l,h]),v.useEffect(()=>{var w;const p=h();l&&p.length>0&&!d.current&&(d.current=!0,(w=u.current)==null||w.call(u))},[l,h]),v.useEffect(()=>{!l&&c.current&&(clearTimeout(c.current),c.current=null,d.current=!1)},[l]),v.useEffect(()=>()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),{isPolling:d.current,isTabVisible:l,inProgressCount:h().length}}function W(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(u=>u.activeExports),{addExport:l}=e.useExportActions(),n=v.useRef(!1),c=r==null?void 0:r.apiServiceUrl,d=s==null?void 0:s.accessToken;v.useEffect(()=>{if(n.current||!c||!d)return;(async()=>{try{const{exports:i}=await e.getExports(c,d,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const a of i){if(f.has(a.id))continue;const h=a.totalChunks?Math.round(a.completedChunks/a.totalChunks*100):0;let b;if(a.status==="completed")try{b=await e.getDownloadUrl(c,d,a.id)}catch(w){console.error(`[useExportRecovery] Failed to get download URL for ${a.id}:`,w)}const p={id:a.id,status:a.status,progress:h,title:Y(a),totalRows:a.totalRows,totalChunks:a.totalChunks,completedChunks:a.completedChunks,startedAt:new Date(a.createdAt),lastUpdatedAt:new Date,completedAt:a.completedAt?new Date(a.completedAt):void 0,fileSize:a.fileSize,error:a.error,expiresAt:new Date(a.expiresAt),downloadUrl:b};l(p)}n.current=!0}catch(i){console.error("[useExportRecovery] Failed to recover exports:",i),n.current=!0}})()},[c,d,l,f])}function Y(s){return s.title?s.title:e.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function Z({open:s,onOpenChange:r,isLibraryVisual:f,currentVisualName:l,isSaving:n=!1,destinationMode:c="both",onConfirm:d}){const[u,i]=v.useState(f&&l?`Copy of ${l}`:l||""),[a,h]=v.useState("");v.useEffect(()=>{s&&(i(f&&l?`Copy of ${l}`:l||""),h(""))},[s,f,l]);const b=!!u.trim(),p=c==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:c==="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"},w=()=>{!b||n||d({name:u.trim(),description:a.trim()||void 0,saveToLibrary:p.saveToLibrary,saveToCurrentDashboard:p.saveToCurrentDashboard})};return t.jsx(e.Dialog,{open:s,onOpenChange:r,children:t.jsxs(e.DialogContent,{className:"sm:max-w-[500px]",children:[t.jsxs(e.DialogHeader,{children:[t.jsxs(e.DialogTitle,{className:"flex items-center gap-2",children:[t.jsx("span",{children:"Save Visual As"}),p.badgeType!=="local"&&t.jsx(I.VisualBadge,{type:p.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),t.jsx(e.DialogDescription,{children:p.description})]}),t.jsxs("div",{className:"grid gap-4 py-4",children:[t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"name",children:"Name"}),t.jsx(e.Input,{id:"name",value:u,onChange:E=>i(E.target.value),placeholder:"Enter visual name",disabled:n})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),t.jsx(e.Textarea,{id:"description",value:a,onChange:E=>h(E.target.value),placeholder:"Enter visual description",rows:3,disabled:n})]})]}),t.jsxs(e.DialogFooter,{children:[t.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:n,children:"Cancel"}),t.jsxs(e.Button,{onClick:w,disabled:!b||n,children:[n&&t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),p.actionLabel]})]})]})})}function J(){const[s,r]=v.useState(!1),[f,l]=v.useState(!1),[n,c]=v.useState(null),[d,u]=v.useState(null),i=e.useEditorStore(m=>m.frame),a=e.useEditorStore(m=>m.card),h=e.useSelectedVisual(),b=e.useDashboardStore(m=>m.selectedSheetId),p=e.useDashboardStore(m=>m.dashboard),w=e.useDashboardStore(m=>m.actions.setIsDashboardPanelOpen),{getUpdatedFrame:E}=z.useVisualUtils(),{selectVisual:x}=e.useManagementActions(),{addFrame:y,setSelectedFrameId:N,setIsVisualEditing:j}=e.useDashboardActions(),o=e.useResolveExistingFrameSemanticExecutionPayload(),C=!!(i!=null&&i.visualId),S=(()=>{var m,g;return((m=i==null?void 0:i.cards)==null?void 0:m.length)===1&&((g=i.cards[0])!=null&&g.title)?i.cards[0].title:h!=null&&h.title?h.title:(a==null?void 0:a.title)||"Untitled Visual"})(),F=e.useCreateVisualWithFrame(m=>{m!=null&&m.id&&(x(m),f&&n&&d&&b&&(async()=>{try{const g={...n,id:e.v4(),visualId:m.id};y(b,g,{position:"end",semanticExecutionPayload:d}),N(g.id),l(!1),c(null),u(null),j(!1)}catch(g){console.error("Failed to promote semantic metadata for saved visual:",g),e.ue.error(g instanceof Error?g.message:"Failed to prepare semantic metadata for the saved visual")}})(),w(!0),r(!1))});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async m=>{if(!b){e.ue.error("No sheet selected");return}const g=E(),A=e.getDynamicFrameSaveIssue(g);if(A){e.ue.error(A);return}const T=g.cards.length===1?{...g,cards:g.cards.map(L=>({...L,title:m.name}))}:g;if(m.saveToLibrary){let L=null;if(m.saveToCurrentDashboard)try{L=await o(T,{previousFrame:e.findDashboardFrameById(p,T.id)})}catch(P){console.error("Failed to prepare semantic metadata before saving visual:",P),e.ue.error(P instanceof Error?P.message:"Failed to prepare semantic metadata for the saved visual");return}l(m.saveToCurrentDashboard),c(T),u(L);const B={title:m.name,description:m.description,frameObject:T,isPrivate:!1};F.mutate(B)}else if(m.saveToCurrentDashboard){const L={...T,id:e.v4(),visualId:void 0};try{const B=await o(T,{previousFrame:e.findDashboardFrameById(p,T.id)});y(b,L,{position:"end",semanticExecutionPayload:B}),N(L.id),e.ue.success("Visual saved to dashboard"),r(!1),j(!1)}catch(B){console.error("Failed to save visual to dashboard:",B),e.ue.error(B instanceof Error?B.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:C,currentVisualName:S,isSaving:F.isPending}}function ee(s={}){const r=e.useEditorStore(D=>D.frame),f=e.useEditorStore(D=>D.editorContext),l=e.useManagementStore(D=>D.selectedVisual),n=e.useDashboardStore(D=>D.selectedFrameId),c=e.useDashboardStore(D=>D.selectedSheetId),d=e.useDashboardStore(D=>D.dashboard),{setIsVisualEditing:u,updateFrame:i}=e.useDashboardActions(),[a,h]=v.useState(!1),[b,p]=v.useState("both"),w=e.useResolveExistingFrameSemanticExecutionPayload(),E=(f==null?void 0:f.type)==="documentSection",x=!!(r!=null&&r.visualId||l!=null&&l.id),y=!!(r!=null&&r.visualId&&n),N=x&&!y,{saveAsDialogOpen:j,setSaveAsDialogOpen:o,handleSaveAs:C,isLibraryVisual:S,currentVisualName:F,isSaving:k}=J(),{getUpdatedFrame:m}=z.useVisualUtils();if(E)return t.jsxs(t.Fragment,{children:[t.jsx(I.EditorAcceptButton,{className:"rounded-[5px]",variant:"default"}),t.jsx(I.EditorCancelButton,{})]});const g=async()=>{if(!c){e.ue.error("No sheet selected");return}if(a)return;h(!0);const D=m(),T=e.getDynamicFrameSaveIssue(D);if(T){h(!1),e.ue.error(T);return}const L={...D,visualId:void 0},B=e.findDashboardFrameById(d,L.id);try{const P=await w(L,{previousFrame:B});i(c,L,{semanticExecutionPayload:P})}catch(P){console.error("Failed to apply local semantic metadata:",P),h(!1),e.ue.error(P instanceof Error?P.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{h(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),u(!1)},300)},A=D=>{p(D),o(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-[5px]",children:[!x&&t.jsx(I.EditorAcceptButton,{className:"rounded-none",variant:"default"}),x&&N&&t.jsx(I.VisualSaveButton,{className:"rounded-none",variant:"default"}),x&&y&&t.jsx(I.VisualSaveAndApplyButton,{className:"rounded-none"}),t.jsxs(e.DropdownMenu,{modal:!1,children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"default",size:"xs",className:"w-7 rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:k||a,children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-[6px] border border-border/60 p-1 shadow-sm",children:[y&&t.jsxs(t.Fragment,{children:[t.jsxs(e.DropdownMenuItem,{onClick:g,disabled:a,children:[t.jsx(e.Check,{className:"h-3.5 w-3.5"}),a?"Applying...":"Apply Locally"]}),t.jsx(e.DropdownMenuSeparator,{})]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("local"),disabled:k,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("library"),disabled:k,children:[t.jsx(I.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("both"),disabled:k,children:[t.jsx(I.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),t.jsx(I.EditorCancelButton,{}),t.jsx(Z,{open:j,onOpenChange:D=>{k||o(D)},isLibraryVisual:S,currentVisualName:F,isSaving:k,destinationMode:b,onConfirm:C})]})}function te({className:s}){const r=e.useEditorStore(i=>i.isDevMode),f=e.useDashboardStore(i=>i.isVisualEditing),{setIsDevMode:l}=e.useEditorActions(),{config:n}=v.useContext(e.SemaphorContext).tokenProps,c=(n==null?void 0:n.showAdvancedMode)!==!1;if(!f||!c)return null;const d="h-full rounded-none border-0 bg-transparent px-2.5 shadow-none text-muted-foreground hover:bg-accent/50 hover:text-foreground",u="bg-muted text-foreground hover:bg-muted";return t.jsxs("div",{role:"radiogroup","aria-label":"Editor mode",className:e.cn("inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-input bg-background",s),children:[t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":!r,className:e.cn(d,!r&&u),onClick:()=>l(!1),children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Drag & drop"]}),t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",role:"radio","aria-checked":r,className:e.cn(d,"border-l border-border/60",r&&u),onClick:()=>l(!0),children:[t.jsx(e.CodeXml,{className:"h-3.5 w-3.5"}),"SQL"]})]})}function se({open:s,onOpenChange:r,onSave:f,onDiscard:l,isSaving:n,title:c="Unsaved changes",description:d="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:u="Cancel",discardLabel:i="Discard",saveLabel:a="Save"}){const h=b=>{!b&&n||r(b)};return t.jsx(e.AlertDialog,{open:s,onOpenChange:h,children:t.jsxs(e.AlertDialogContent,{children:[t.jsxs(e.AlertDialogHeader,{children:[t.jsx(e.AlertDialogTitle,{children:c}),t.jsx(e.AlertDialogDescription,{children:d})]}),t.jsxs(e.AlertDialogFooter,{children:[t.jsx(e.Button,{type:"button",size:"xs",onClick:l,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:i}),t.jsx(e.AlertDialogCancel,{disabled:n,children:u}),t.jsx(e.Button,{type:"button",size:"xs",onClick:f,disabled:n,children:n?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):a})]})]})})}function O({export:s,onRemove:r}){const f=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},l=u=>{u.stopPropagation(),r==null||r(s.id)},n=()=>{switch(s.status){case"completed":return t.jsx(e.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return t.jsx(I.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return t.jsx(e.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},c=e.isExportInProgress(s.status),d=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return t.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[t.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[n(),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[t.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:"•"}),t.jsx("span",{children:e.formatFileSize(s.fileSize)})]})]}),c&&t.jsx("div",{className:"text-xs text-muted-foreground",children:d}),s.status==="failed"&&t.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),t.jsx(e.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:l,"aria-label":"Remove notification",children:t.jsx(e.X,{className:"h-4 w-4"})})]}),t.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:M.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&t.jsxs(e.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:f,children:[t.jsx(e.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),c&&t.jsxs("div",{children:[t.jsx(e.Progress,{value:s.progress,className:"h-1.5"}),t.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&t.jsx("span",{className:"text-xs text-muted-foreground",children:M.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function R(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),f=e.useExportStore(x=>x.activeExports),{clearCompleted:l,removeExport:n,updateExport:c}=e.useExportActions(),[d,u]=v.useState(!1),[i,a]=v.useState(!1),h=Array.from(f.values()).sort((x,y)=>y.startedAt.getTime()-x.startedAt.getTime()),b=h.some(x=>x.status==="completed"||x.status==="failed"),p=v.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,y=s==null?void 0:s.accessToken;if(!(!x||!y)){u(!0);try{const N=Array.from(f.values());await Promise.all(N.map(async j=>{try{const o=await e.getExportStatus(x,y,j.id);let C;if(o.status==="completed")try{C=await e.getDownloadUrl(x,y,j.id)}catch(S){console.error(`Failed to get download URL for ${j.id}:`,S)}c(j.id,{status:o.status,progress:o.progress,completedChunks:o.completedChunks,completedAt:o.completedAt?new Date(o.completedAt):void 0,lastUpdatedAt:new Date,fileSize:o.fileSize,error:o.error,downloadUrl:C})}catch(o){console.error(`Failed to refresh export ${j.id}:`,o)}}))}finally{u(!1)}}},[f,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,c]),w=v.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,y=s==null?void 0:s.accessToken;if(!x||!y){l();return}a(!0);try{const N=h.filter(o=>o.status==="completed"||o.status==="failed"),j=await Promise.allSettled(N.map(async o=>(await e.cancelExport(x,y,o.id),o.id)));for(const o of j)o.status==="fulfilled"?n(o.value):console.error("Failed to delete export:",o.reason)}finally{a(!1)}},[h,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,l,n]),E=v.useCallback(async x=>{const y=r==null?void 0:r.apiServiceUrl,N=s==null?void 0:s.accessToken;if(y&&N)try{await e.cancelExport(y,N,x),n(x);return}catch(j){console.error(`Failed to cancel export ${x}:`,j)}n(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,n]);return h.length===0?t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(U,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(U,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("h4",{className:"font-semibold",children:"Exports"})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:p,disabled:d,title:"Refresh status",children:t.jsx(e.RefreshCw,{className:`h-4 w-4 ${d?"animate-spin":""}`})}),b&&t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:w,disabled:i,children:i?"Clearing...":"Clear all"})]})]}),t.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:t.jsx("div",{className:"divide-y",children:h.map(x=>t.jsx(O,{export:x,onRemove:E},x.id))})})]})}function re({variant:s}){const r=e.useExportStore(i=>i.activeExports),f=e.useInProgressExportsCount(),l=r.size>0,n=Array.from(r.values()).some(i=>i.status==="completed"||i.status==="failed"),d=f>0?f>9?"9+":String(f):null,u=l;return t.jsxs(e.Popover,{children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[t.jsx(e.Bell,{className:"h-3.5 w-3.5"}),u&&t.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})]})}),t.jsx(e.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:t.jsx(R,{})})]})}function ae(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function oe({open:s,onOpenChange:r,trigger:f,showTrigger:l=!0,initialMode:n="manage"}){const c=n==="create",{forceClose:d,handleOpenChange:u,isCreateFlowActive:i,preventPassiveDismissDuringCreate:a,resolvedOpen:h,setIsCreateFlowActive:b}=I.useCreateFlowOverlayState({open:s,onOpenChange:r,initialCreateFlowActive:n==="create",dismissMode:l?"passive":"explicit-only"}),p=e.useDashboardStore(m=>m.dashboard),{setDashboardControlsModel:w}=e.useDashboardActions(),{participants:E}=e.useDashboardStructuralParticipants(e.getDashboardCards(p)),x=Array.from(new Map(E.flatMap(m=>m.fieldChoices.map(g=>{var A;return[g.value,{option:g,target:(A=m.fieldTargetMap)==null?void 0:A[g.value]}]}))).values()),y=Array.from(new Map(E.flatMap(m=>m.metricChoices.map(g=>{var A;return[g.value,{option:g,target:(A=m.metricTargetMap)==null?void 0:A[g.value]}]}))).values()),N=e.collectDashboardControlIds({...p||{},controls:[]}),j=e.buildDashboardStructuralParticipantIdsByControlId(p),o=(m,g,A)=>{w(m,g,ae(A))},C=v.useCallback(()=>{if(c){d();return}b(!1)},[c,d,b]),S=t.jsx(I.ControlDefinitionListEditor,{scope:"dashboard",controls:p.controls||[],reservedControlIds:N,defaultValues:p.defaultControlValues||{},usageByControlId:e.buildDashboardControlUsageById(p),availableFieldChoices:x,availableMetricChoices:y,structuralParticipants:E,structuralParticipantIdsByControlId:j,initialCreateFlow:n==="create",onCreateFlowActiveChange:b,onCreateFlowComplete:C,onChange:o,emptyMessage:"No dashboard controls yet."}),F=i?"Add dashboard control":"Dashboard Controls",k=t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"space-y-1",children:[t.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),S]});return l?t.jsxs(e.Popover,{open:h,onOpenChange:u,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:f||t.jsxs(e.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[t.jsx(e.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),t.jsx(e.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:a,onPointerDownOutside:a,children:k})]}):t.jsx(e.Dialog,{open:h,onOpenChange:u,children:t.jsxs(e.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:a,onPointerDownOutside:a,children:[t.jsxs(e.DialogHeader,{className:i?"space-y-0":void 0,children:[t.jsx(e.DialogTitle,{className:"text-[15px]",children:F}),t.jsx(e.DialogDescription,{className:i?"sr-only":"text-[13px]",children:i?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),t.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:S})]})})}function ne({showFilters:s,onToggleFilters:r,onAddFilter:f,onAddControl:l,onManageControls:n,size:c="default",className:d,primaryButtonClassName:u,secondaryButtonClassName:i,dropdownContentClassName:a}){const h=c==="toolbar";return t.jsxs("div",{className:e.cn("relative inline-flex items-stretch overflow-hidden rounded-[5px] border border-input bg-background",h?"h-8":"h-7",d),children:[t.jsxs(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",u),onClick:r,children:[s?t.jsx(H,{className:"h-3.5 w-3.5"}):t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),t.jsxs(e.DropdownMenu,{children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{variant:"ghost",size:"xs",className:e.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",i),"aria-label":"Filter and control actions",children:t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"})})}),t.jsxs(e.DropdownMenuContent,{align:"start",className:e.cn("min-w-[180px] rounded-[6px] border border-border/60 p-1 shadow-sm",a),children:[t.jsxs(e.DropdownMenuItem,{onSelect:f,children:[t.jsx(e.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),t.jsxs(e.DropdownMenuItem,{onSelect:l,children:[t.jsx(e.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),t.jsxs(e.DropdownMenuItem,{onSelect:n,children:[t.jsx(e.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=te;exports.DashboardControlsSettings=oe;exports.DashboardFilterControlsButton=ne;exports.ExportNotificationItem=O;exports.ExportNotificationList=R;exports.NotificationBell=re;exports.UnsavedChangesAlert=se;exports.VisualEditingControls=ee;exports.useExportPolling=Q;exports.useExportRecovery=W;