react-semaphor 0.1.271 → 0.1.273
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-controls-CXi0Kc8w.js → dashboard-controls-CWk_VHYO.js} +1 -1
- package/dist/chunks/{dashboard-controls-Dfgvs7VL.js → dashboard-controls-DXVPvtdv.js} +4 -4
- package/dist/chunks/{dashboard-filter-controls-button-YHsKcBkN.js → dashboard-filter-controls-button-BwfVbMAn.js} +251 -267
- package/dist/chunks/dashboard-filter-controls-button-CjRyfVQK.js +11 -0
- package/dist/chunks/{dashboard-json-CeiZb0oM.js → dashboard-json-BZQnb-zu.js} +1 -1
- package/dist/chunks/{dashboard-json-BgtFUcgD.js → dashboard-json-DF2gJo97.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CoEmX_jV.js → dashboard-summary-settings-dialog-BpELD3wD.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CuZFi7eP.js → dashboard-summary-settings-dialog-DdwG-S3r.js} +1 -1
- package/dist/chunks/{edit-dashboard-visual-CGYJdPQ8.js → edit-dashboard-visual-0hFfcZi2.js} +6766 -6740
- package/dist/chunks/edit-dashboard-visual-DGPiHVW5.js +193 -0
- package/dist/chunks/index-BOOgwnhm.js +1404 -0
- package/dist/chunks/{index-B9iVxfst.js → index-YLHt8XOf.js} +26260 -25953
- package/dist/chunks/{resource-management-panel-CDPB0Wn6.js → resource-management-panel-B9apTPo3.js} +2 -2
- package/dist/chunks/{resource-management-panel-Cqi9uzkw.js → resource-management-panel-ShFnXy_K.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-4H0O4LVk.js → use-create-flow-overlay-state-DSVyfQTu.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-B5mMajCH.js → use-create-flow-overlay-state-_csxpz3-.js} +1 -1
- package/dist/chunks/{use-visual-utils-S6wmOnYK.js → use-visual-utils-B1ukb8iy.js} +1 -1
- package/dist/chunks/{use-visual-utils-iRJXiZv1.js → use-visual-utils-Ck8d5hcW.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +5 -5
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/dashboard.d.ts +7 -1
- package/dist/types/main.d.ts +7 -1
- package/dist/types/shared.d.ts +7 -1
- package/dist/types/surfboard.d.ts +7 -1
- package/dist/types/types.d.ts +7 -1
- package/package.json +1 -1
- package/dist/chunks/dashboard-filter-controls-button-EN4T7uuF.js +0 -11
- package/dist/chunks/edit-dashboard-visual-D8AIf9tr.js +0 -193
- package/dist/chunks/index-Dx42zDJJ.js +0 -1404
package/dist/surfboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("../chunks/index-BOOgwnhm.js"),e=require("../types/index.cjs"),r=require("../chunks/dashboard-summary-settings-dialog-DdwG-S3r.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;
|
package/dist/surfboard/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as o } from "../chunks/index-
|
|
1
|
+
import { a as o } from "../chunks/index-YLHt8XOf.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-
|
|
3
|
+
import { C as m, D as t } from "../chunks/dashboard-summary-settings-dialog-BpELD3wD.js";
|
|
4
4
|
export {
|
|
5
5
|
s as CONTROL_CARD_DEFAULT_VALUE,
|
|
6
6
|
m as CalendarPreferencesDialog,
|
|
@@ -813,7 +813,7 @@ declare interface FilterCondition {
|
|
|
813
813
|
*/
|
|
814
814
|
declare type FilterDisplayMode = 'canvas' | 'toolbar' | 'inherit';
|
|
815
815
|
|
|
816
|
-
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role'>> & {
|
|
816
|
+
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'id' | 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role' | 'fieldScope'>> & {
|
|
817
817
|
entityName?: Field['entityName'];
|
|
818
818
|
entityType?: string;
|
|
819
819
|
expression?: string;
|
|
@@ -1525,6 +1525,11 @@ export declare type TCard = {
|
|
|
1525
1525
|
* Configured by editors via the visual editor settings.
|
|
1526
1526
|
*/
|
|
1527
1527
|
inlineFilters?: TInlineFilter[];
|
|
1528
|
+
/**
|
|
1529
|
+
* Card-scoped calculated fields that should remain available even when they
|
|
1530
|
+
* are not actively selected in the chart configuration.
|
|
1531
|
+
*/
|
|
1532
|
+
calculatedFields?: Field[];
|
|
1528
1533
|
/**
|
|
1529
1534
|
* Card-scoped control definitions for this card.
|
|
1530
1535
|
*/
|
|
@@ -2077,6 +2082,7 @@ export declare type TSheet = {
|
|
|
2077
2082
|
layouts?: ReactGridLayout.Layouts;
|
|
2078
2083
|
cards?: TCard[];
|
|
2079
2084
|
frames?: TFrame[];
|
|
2085
|
+
calculatedFields?: Field[];
|
|
2080
2086
|
};
|
|
2081
2087
|
|
|
2082
2088
|
/**
|
package/dist/types/main.d.ts
CHANGED
|
@@ -2314,7 +2314,7 @@ export declare interface FilterCondition {
|
|
|
2314
2314
|
*/
|
|
2315
2315
|
declare type FilterDisplayMode = 'canvas' | 'toolbar' | 'inherit';
|
|
2316
2316
|
|
|
2317
|
-
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role'>> & {
|
|
2317
|
+
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'id' | 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role' | 'fieldScope'>> & {
|
|
2318
2318
|
entityName?: Field['entityName'];
|
|
2319
2319
|
entityType?: string;
|
|
2320
2320
|
expression?: string;
|
|
@@ -3655,6 +3655,11 @@ export declare type TCard = {
|
|
|
3655
3655
|
* Configured by editors via the visual editor settings.
|
|
3656
3656
|
*/
|
|
3657
3657
|
inlineFilters?: TInlineFilter[];
|
|
3658
|
+
/**
|
|
3659
|
+
* Card-scoped calculated fields that should remain available even when they
|
|
3660
|
+
* are not actively selected in the chart configuration.
|
|
3661
|
+
*/
|
|
3662
|
+
calculatedFields?: Field[];
|
|
3658
3663
|
/**
|
|
3659
3664
|
* Card-scoped control definitions for this card.
|
|
3660
3665
|
*/
|
|
@@ -4453,6 +4458,7 @@ export declare type TSheet = {
|
|
|
4453
4458
|
layouts?: ReactGridLayout.Layouts;
|
|
4454
4459
|
cards?: TCard[];
|
|
4455
4460
|
frames?: TFrame[];
|
|
4461
|
+
calculatedFields?: Field[];
|
|
4456
4462
|
};
|
|
4457
4463
|
|
|
4458
4464
|
/**
|
package/dist/types/shared.d.ts
CHANGED
|
@@ -693,7 +693,7 @@ declare interface FilterCondition {
|
|
|
693
693
|
*/
|
|
694
694
|
declare type FilterDisplayMode = 'canvas' | 'toolbar' | 'inherit';
|
|
695
695
|
|
|
696
|
-
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role'>> & {
|
|
696
|
+
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'id' | 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role' | 'fieldScope'>> & {
|
|
697
697
|
entityName?: Field['entityName'];
|
|
698
698
|
entityType?: string;
|
|
699
699
|
expression?: string;
|
|
@@ -1367,6 +1367,11 @@ declare type TCard = {
|
|
|
1367
1367
|
* Configured by editors via the visual editor settings.
|
|
1368
1368
|
*/
|
|
1369
1369
|
inlineFilters?: TInlineFilter[];
|
|
1370
|
+
/**
|
|
1371
|
+
* Card-scoped calculated fields that should remain available even when they
|
|
1372
|
+
* are not actively selected in the chart configuration.
|
|
1373
|
+
*/
|
|
1374
|
+
calculatedFields?: Field[];
|
|
1370
1375
|
/**
|
|
1371
1376
|
* Card-scoped control definitions for this card.
|
|
1372
1377
|
*/
|
|
@@ -1874,6 +1879,7 @@ declare type TSheet = {
|
|
|
1874
1879
|
layouts?: ReactGridLayout.Layouts;
|
|
1875
1880
|
cards?: TCard[];
|
|
1876
1881
|
frames?: TFrame[];
|
|
1882
|
+
calculatedFields?: Field[];
|
|
1877
1883
|
};
|
|
1878
1884
|
|
|
1879
1885
|
/**
|
|
@@ -833,7 +833,7 @@ declare interface FilterCondition {
|
|
|
833
833
|
*/
|
|
834
834
|
declare type FilterDisplayMode = 'canvas' | 'toolbar' | 'inherit';
|
|
835
835
|
|
|
836
|
-
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role'>> & {
|
|
836
|
+
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'id' | 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role' | 'fieldScope'>> & {
|
|
837
837
|
entityName?: Field['entityName'];
|
|
838
838
|
entityType?: string;
|
|
839
839
|
expression?: string;
|
|
@@ -1547,6 +1547,11 @@ export declare type TCard = {
|
|
|
1547
1547
|
* Configured by editors via the visual editor settings.
|
|
1548
1548
|
*/
|
|
1549
1549
|
inlineFilters?: TInlineFilter[];
|
|
1550
|
+
/**
|
|
1551
|
+
* Card-scoped calculated fields that should remain available even when they
|
|
1552
|
+
* are not actively selected in the chart configuration.
|
|
1553
|
+
*/
|
|
1554
|
+
calculatedFields?: Field[];
|
|
1550
1555
|
/**
|
|
1551
1556
|
* Card-scoped control definitions for this card.
|
|
1552
1557
|
*/
|
|
@@ -2099,6 +2104,7 @@ export declare type TSheet = {
|
|
|
2099
2104
|
layouts?: ReactGridLayout.Layouts;
|
|
2100
2105
|
cards?: TCard[];
|
|
2101
2106
|
frames?: TFrame[];
|
|
2107
|
+
calculatedFields?: Field[];
|
|
2102
2108
|
};
|
|
2103
2109
|
|
|
2104
2110
|
/**
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1102,7 +1102,7 @@ declare interface FilterCondition {
|
|
|
1102
1102
|
*/
|
|
1103
1103
|
declare type FilterDisplayMode = 'canvas' | 'toolbar' | 'inherit';
|
|
1104
1104
|
|
|
1105
|
-
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role'>> & {
|
|
1105
|
+
declare type FilterFieldMeta = Pick<Field, 'name' | 'qualifiedFieldName'> & Partial<Pick<Field, 'id' | 'qualifiedEntityName' | 'entityId' | 'dataType' | 'role' | 'fieldScope'>> & {
|
|
1106
1106
|
entityName?: Field['entityName'];
|
|
1107
1107
|
entityType?: string;
|
|
1108
1108
|
expression?: string;
|
|
@@ -1875,6 +1875,11 @@ export declare type TCard = {
|
|
|
1875
1875
|
* Configured by editors via the visual editor settings.
|
|
1876
1876
|
*/
|
|
1877
1877
|
inlineFilters?: TInlineFilter[];
|
|
1878
|
+
/**
|
|
1879
|
+
* Card-scoped calculated fields that should remain available even when they
|
|
1880
|
+
* are not actively selected in the chart configuration.
|
|
1881
|
+
*/
|
|
1882
|
+
calculatedFields?: Field[];
|
|
1878
1883
|
/**
|
|
1879
1884
|
* Card-scoped control definitions for this card.
|
|
1880
1885
|
*/
|
|
@@ -2656,6 +2661,7 @@ export declare type TSheet = {
|
|
|
2656
2661
|
layouts?: ReactGridLayout.Layouts;
|
|
2657
2662
|
cards?: TCard[];
|
|
2658
2663
|
frames?: TFrame[];
|
|
2664
|
+
calculatedFields?: Field[];
|
|
2659
2665
|
};
|
|
2660
2666
|
|
|
2661
2667
|
/**
|
package/package.json
CHANGED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";const g=require("react"),e=require("./index-Dx42zDJJ.js"),t=require("react/jsx-runtime"),I=require("./use-create-flow-overlay-state-B5mMajCH.js"),M=require("./use-visual-utils-iRJXiZv1.js"),T=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 L=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 P=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"}]]),V=1e4,O=15e3,z=3e4,R=3e4,$=12e4,k=2*60*60*1e3;function H(s){const r=Date.now()-s.getTime();return r<R?V:r<$?O:z}function q(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),p=e.useExportStore(h=>h.activeExports),[c,d]=g.useState(typeof document<"u"?!document.hidden:!0),u=g.useRef(null),n=g.useRef(!1),l=g.useRef(void 0),m=r==null?void 0:r.apiServiceUrl,o=s==null?void 0:s.accessToken,f=g.useCallback(()=>{const h=e.useExportStore.getState().activeExports;return Array.from(h.values()).filter(C=>e.isExportInProgress(C.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const h=()=>{d(!document.hidden)};return document.addEventListener("visibilitychange",h),()=>{document.removeEventListener("visibilitychange",h)}},[]);const b=g.useCallback(async()=>{if(!m||!o){n.current=!1;return}const h=f();if(h.length===0){n.current=!1;return}const C=Date.now(),D=h.filter(a=>C-a.startedAt.getTime()>k);if(D.length>0){const{updateExport:a}=e.useExportStore.getState().actions;for(const i of D)a(i.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const x=h.filter(a=>C-a.startedAt.getTime()<=k);if(x.length===0){n.current=!1;return}const j=await Promise.allSettled(x.map(async a=>{try{const i=await e.getExportStatus(m,o,a.id);let v;if(i.status==="completed")try{v=await e.getDownloadUrl(m,o,a.id)}catch(A){console.error(`[useExportPolling] Failed to get download URL for ${a.id}:`,A)}return{id:a.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:v}}catch(i){return console.error(`[useExportPolling] Failed to poll export ${a.id}:`,i),null}})),{updateExport:E}=e.useExportStore.getState().actions;for(const a of j)a.status==="fulfilled"&&a.value&&E(a.value.id,a.value);const w=f();if(w.length>0&&!document.hidden){const a=w.reduce((v,A)=>A.startedAt<v?A.startedAt:v,w[0].startedAt),i=H(a);u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{var v;(v=l.current)==null||v.call(l)},i)}else n.current=!1},[m,o,f]);return g.useEffect(()=>{l.current=b},[b]),g.useEffect(()=>{var C;f().length>0&&c&&!n.current&&(n.current=!0,(C=l.current)==null||C.call(l))},[p,c,f]),g.useEffect(()=>{var C;const h=f();c&&h.length>0&&!n.current&&(n.current=!0,(C=l.current)==null||C.call(l))},[c,f]),g.useEffect(()=>{!c&&u.current&&(clearTimeout(u.current),u.current=null,n.current=!1)},[c]),g.useEffect(()=>()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),{isPolling:n.current,isTabVisible:c,inProgressCount:f().length}}function _(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),p=e.useExportStore(l=>l.activeExports),{addExport:c}=e.useExportActions(),d=g.useRef(!1),u=r==null?void 0:r.apiServiceUrl,n=s==null?void 0:s.accessToken;g.useEffect(()=>{if(d.current||!u||!n)return;(async()=>{try{const{exports:m}=await e.getExports(u,n,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const o of m){if(p.has(o.id))continue;const f=o.totalChunks?Math.round(o.completedChunks/o.totalChunks*100):0;let b;if(o.status==="completed")try{b=await e.getDownloadUrl(u,n,o.id)}catch(C){console.error(`[useExportRecovery] Failed to get download URL for ${o.id}:`,C)}const h={id:o.id,status:o.status,progress:f,title:X(o),totalRows:o.totalRows,totalChunks:o.totalChunks,completedChunks:o.completedChunks,startedAt:new Date(o.createdAt),lastUpdatedAt:new Date,completedAt:o.completedAt?new Date(o.completedAt):void 0,fileSize:o.fileSize,error:o.error,expiresAt:new Date(o.expiresAt),downloadUrl:b};c(h)}d.current=!0}catch(m){console.error("[useExportRecovery] Failed to recover exports:",m),d.current=!0}})()},[u,n,c,p])}function X(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 G({open:s,onOpenChange:r,isLibraryVisual:p,currentVisualName:c,isSaving:d=!1,destinationMode:u="both",onConfirm:n}){const[l,m]=g.useState(p&&c?`Copy of ${c}`:c||""),[o,f]=g.useState("");g.useEffect(()=>{s&&(m(p&&c?`Copy of ${c}`:c||""),f(""))},[s,p,c]);const b=!!l.trim(),h=u==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:u==="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"},C=()=>{!b||d||n({name:l.trim(),description:o.trim()||void 0,saveToLibrary:h.saveToLibrary,saveToCurrentDashboard:h.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"}),h.badgeType!=="local"&&t.jsx(I.VisualBadge,{type:h.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),t.jsx(e.DialogDescription,{children:h.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$1,{id:"name",value:l,onChange:D=>m(D.target.value),placeholder:"Enter visual name",disabled:d})]}),t.jsxs("div",{className:"grid gap-2",children:[t.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),t.jsx(e.Textarea,{id:"description",value:o,onChange:D=>f(D.target.value),placeholder:"Enter visual description",rows:3,disabled:d})]})]}),t.jsxs(e.DialogFooter,{children:[t.jsx(e.Button,{variant:"outline",onClick:()=>r(!1),disabled:d,children:"Cancel"}),t.jsxs(e.Button,{onClick:C,disabled:!b||d,children:[d&&t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),h.actionLabel]})]})]})})}function K(){const[s,r]=g.useState(!1),[p,c]=g.useState(!1),[d,u]=g.useState(null),n=e.useEditorStore(i=>i.frame),l=e.useEditorStore(i=>i.card),m=e.useSelectedVisual(),o=e.useDashboardStore(i=>i.selectedSheetId),f=e.useDashboardStore(i=>i.actions.setIsDashboardPanelOpen),{getUpdatedFrame:b}=M.useVisualUtils(),{selectVisual:h}=e.useManagementActions(),{addFrame:C,setSelectedFrameId:D,setIsVisualEditing:x}=e.useDashboardActions(),j=!!(n!=null&&n.visualId),E=(()=>{var i,v;return((i=n==null?void 0:n.cards)==null?void 0:i.length)===1&&((v=n.cards[0])!=null&&v.title)?n.cards[0].title:m!=null&&m.title?m.title:(l==null?void 0:l.title)||"Untitled Visual"})(),w=e.useCreateVisualWithFrame(i=>{if(i!=null&&i.id){if(h(i),p&&d&&o){const v={...d,id:e.v4(),visualId:i.id};C(o,v,"end"),D(v.id),c(!1),u(null),x(!1)}f(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async i=>{if(!o){e.ue.error("No sheet selected");return}const v=b(),A=e.getDynamicFrameSaveIssue(v);if(A){e.ue.error(A);return}const N=v.cards.length===1?{...v,cards:v.cards.map(y=>({...y,title:i.name}))}:v;if(i.saveToLibrary){c(i.saveToCurrentDashboard),u(N);const y={title:i.name,description:i.description,frameObject:N,isPrivate:!1};w.mutate(y)}else if(i.saveToCurrentDashboard){const y={...N,id:e.v4(),visualId:void 0};C(o,y,"end"),D(y.id),e.ue.success("Visual saved to dashboard"),r(!1),x(!1)}},isLibraryVisual:j,currentVisualName:E,isSaving:w.isPending}}function W({className:s}){const r=e.useEditorStore(S=>S.frame),p=e.useManagementStore(S=>S.selectedVisual),c=e.useDashboardStore(S=>S.selectedFrameId),d=e.useDashboardStore(S=>S.selectedSheetId),{setIsVisualEditing:u,updateFrame:n}=e.useDashboardActions(),[l,m]=g.useState(!1),[o,f]=g.useState("both"),b=!!(r!=null&&r.visualId||p!=null&&p.id),h=!!(r!=null&&r.visualId&&c),C=b&&!h,{saveAsDialogOpen:D,setSaveAsDialogOpen:x,handleSaveAs:j,isLibraryVisual:E,currentVisualName:w,isSaving:a}=K(),{getUpdatedFrame:i}=M.useVisualUtils(),v=()=>{if(!d){e.ue.error("No sheet selected");return}if(l)return;m(!0);const S=i(),N=e.getDynamicFrameSaveIssue(S);if(N){m(!1),e.ue.error(N);return}const y={...S,visualId:void 0};n(d,y),setTimeout(()=>{m(!1),e.ue.success("Changes applied. Visual is now local to this dashboard"),u(!1)},300)},A=S=>{f(S),x(!0)};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-md border border-input",children:[!b&&t.jsx(I.EditorAcceptButton,{className:e.cn(s,"rounded-none border-0"),variant:"default"}),b&&C&&t.jsx(I.VisualSaveButton,{className:e.cn(s,"rounded-none border-0"),variant:"default"}),b&&h&&t.jsx(I.VisualSaveAndApplyButton,{className:e.cn(s,"rounded-none border-0")}),t.jsxs(e.DropdownMenu,{modal:!1,children:[t.jsx(e.DropdownMenuTrigger,{className:"h-8",asChild:!0,children:t.jsx(e.Button,{variant:"default",size:"sm",className:e.cn(s,"w-8 rounded-none border-0 border-l border-primary-foreground/30 px-2"),"aria-label":"Open visual save options",disabled:a||l,children:t.jsx(e.ChevronDown,{className:"h-4 w-4"})})}),t.jsxs(e.DropdownMenuContent,{align:"end",children:[h&&t.jsxs(t.Fragment,{children:[t.jsxs(e.DropdownMenuItem,{onClick:v,disabled:l,children:[t.jsx(e.Check,{className:"mr-2 h-4 w-4"}),l?"Applying...":"Apply Locally"]}),t.jsx(e.DropdownMenuSeparator,{})]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("local"),disabled:a,children:[t.jsx(e.Plus,{className:"mr-2 h-4 w-4"}),"Add to Dashboard (Local)"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("library"),disabled:a,children:[t.jsx(I.Library,{className:"mr-2 h-4 w-4"}),"Save as Library Visual"]}),t.jsxs(e.DropdownMenuItem,{onClick:()=>A("both"),disabled:a,children:[t.jsx(I.Link2,{className:"mr-2 h-4 w-4"}),"Save Copy as Linked Visual"]})]})]})]}),t.jsx(I.EditorCancelButton,{className:s}),t.jsx(G,{open:D,onOpenChange:S=>{a||x(S)},isLibraryVisual:E,currentVisualName:w,isSaving:a,destinationMode:o,onConfirm:j})]})}function Q({className:s,switchClassName:r}){const p=e.useEditorStore(l=>l.isDevMode),c=e.useDashboardStore(l=>l.isVisualEditing),{setIsDevMode:d}=e.useEditorActions(),{config:u}=g.useContext(e.SemaphorContext).tokenProps,n=(u==null?void 0:u.showAdvancedMode)!==!1;return!c||!n?null:t.jsxs("div",{className:e.cn("flex items-center space-x-2",s),children:[t.jsx(e.DevModeSwitch,{className:e.cn("",r),checked:p,onCheckedChange:()=>d(!p),id:"advanced-mode",icon:t.jsx(e.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),t.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function Y({open:s,onOpenChange:r,onSave:p,onDiscard:c,isSaving:d,title:u="Unsaved Changes",description:n="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:l="Cancel",discardLabel:m="Discard",saveLabel:o="Save & Close"}){const f=b=>{!b&&d||r(b)};return t.jsx(e.AlertDialog,{open:s,onOpenChange:f,children:t.jsxs(e.AlertDialogContent,{className:"max-w-[520px] border-border/70 p-6",children:[t.jsxs(e.AlertDialogHeader,{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-amber-50 ring-1 ring-amber-200/70",children:t.jsx(e.TriangleAlert,{className:"h-[18px] w-[18px] text-amber-600"})}),t.jsx(e.AlertDialogTitle,{className:"text-lg font-semibold tracking-tight",children:u})]}),t.jsx(e.AlertDialogDescription,{className:"text-sm leading-6 text-muted-foreground",children:n})]}),t.jsxs(e.AlertDialogFooter,{className:"mt-2 flex-col gap-1.5 sm:flex-row sm:justify-end",children:[t.jsx(e.AlertDialogCancel,{disabled:d,className:"order-1 m-0 h-auto min-h-9 whitespace-normal border-border/60 px-4 py-2 text-center leading-5 sm:order-1",children:l}),t.jsx("button",{onClick:c,disabled:d,className:"order-2 h-auto min-h-9 whitespace-normal rounded-md border border-destructive/30 bg-destructive/10 px-4 py-2 text-center text-sm font-medium leading-5 text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:m}),t.jsx(e.AlertDialogAction,{onClick:p,disabled:d,className:"order-3 m-0 h-auto min-h-9 whitespace-normal px-4 py-2 text-center leading-5 sm:order-3",children:d?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):o})]})]})})}function Z(s,r,p,c){g.useEffect(()=>{s&&!p&&r&&c(e.cloneDeep(r))},[s,p,r,c])}function U({export:s,onRemove:r}){const p=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},c=l=>{l.stopPropagation(),r==null||r(s.id)},d=()=>{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"})}},u=e.isExportInProgress(s.status),n=(()=>{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:[d(),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)})]})]}),u&&t.jsx("div",{className:"text-xs text-muted-foreground",children:n}),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:c,"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:T.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&t.jsxs(e.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:p,children:[t.jsx(e.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),u&&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:T.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function B(){const{authToken:s,tokenProps:r}=e.useSemaphorContext(),p=e.useExportStore(x=>x.activeExports),{clearCompleted:c,removeExport:d,updateExport:u}=e.useExportActions(),[n,l]=g.useState(!1),[m,o]=g.useState(!1),f=Array.from(p.values()).sort((x,j)=>j.startedAt.getTime()-x.startedAt.getTime()),b=f.some(x=>x.status==="completed"||x.status==="failed"),h=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!x||!j)){l(!0);try{const E=Array.from(p.values());await Promise.all(E.map(async w=>{try{const a=await e.getExportStatus(x,j,w.id);let i;if(a.status==="completed")try{i=await e.getDownloadUrl(x,j,w.id)}catch(v){console.error(`Failed to get download URL for ${w.id}:`,v)}u(w.id,{status:a.status,progress:a.progress,completedChunks:a.completedChunks,completedAt:a.completedAt?new Date(a.completedAt):void 0,lastUpdatedAt:new Date,fileSize:a.fileSize,error:a.error,downloadUrl:i})}catch(a){console.error(`Failed to refresh export ${w.id}:`,a)}}))}finally{l(!1)}}},[p,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,u]),C=g.useCallback(async()=>{const x=r==null?void 0:r.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!x||!j){c();return}o(!0);try{const E=f.filter(a=>a.status==="completed"||a.status==="failed"),w=await Promise.allSettled(E.map(async a=>(await e.cancelExport(x,j,a.id),a.id)));for(const a of w)a.status==="fulfilled"?d(a.value):console.error("Failed to delete export:",a.reason)}finally{o(!1)}},[f,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,c,d]),D=g.useCallback(async x=>{const j=r==null?void 0:r.apiServiceUrl,E=s==null?void 0:s.accessToken;if(j&&E)try{await e.cancelExport(j,E,x),d(x);return}catch(w){console.error(`Failed to cancel export ${x}:`,w)}d(x)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,d]);return f.length===0?t.jsxs("div",{className:"p-6 text-center",children:[t.jsx(L,{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(L,{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:h,disabled:n,title:"Refresh status",children:t.jsx(e.RefreshCw,{className:`h-4 w-4 ${n?"animate-spin":""}`})}),b&&t.jsx(e.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:C,disabled:m,children:m?"Clearing...":"Clear all"})]})]}),t.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:t.jsx("div",{className:"divide-y",children:f.map(x=>t.jsx(U,{export:x,onRemove:D},x.id))})})]})}function J({variant:s}){const r=e.useExportStore(m=>m.activeExports),p=e.useInProgressExportsCount(),c=r.size>0,d=Array.from(r.values()).some(m=>m.status==="completed"||m.status==="failed"),n=p>0?p>9?"9+":String(p):null,l=c;return t.jsxs(e.Popover,{children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{variant:s??"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[t.jsx(e.Bell,{className:"h-4 w-4"}),l&&t.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${n?"-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:n})]})}),t.jsx(e.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:t.jsx(B,{})})]})}function ee(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 te({open:s,onOpenChange:r,trigger:p,showTrigger:c=!0,initialMode:d="manage"}){const u=d==="create",{forceClose:n,handleOpenChange:l,isCreateFlowActive:m,preventPassiveDismissDuringCreate:o,resolvedOpen:f,setIsCreateFlowActive:b}=I.useCreateFlowOverlayState({open:s,onOpenChange:r,initialCreateFlowActive:d==="create"}),h=e.useDashboardStore(N=>N.dashboard),{setDashboardControlsModel:C}=e.useDashboardActions(),{participants:D}=e.useDashboardStructuralParticipants(e.getDashboardCards(h)),x=Array.from(new Map(D.flatMap(N=>N.fieldChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.fieldTargetMap)==null?void 0:F[y.value]}]}))).values()),j=Array.from(new Map(D.flatMap(N=>N.metricChoices.map(y=>{var F;return[y.value,{option:y,target:(F=N.metricTargetMap)==null?void 0:F[y.value]}]}))).values()),E=e.collectDashboardControlIds({...h||{},controls:[]}),w=e.buildDashboardStructuralParticipantIdsByControlId(h),a=(N,y,F)=>{C(N,y,ee(F))},i=g.useCallback(()=>{if(u){n();return}b(!1)},[u,n,b]),v=t.jsx(I.ControlDefinitionListEditor,{scope:"dashboard",controls:h.controls||[],reservedControlIds:E,defaultValues:h.defaultControlValues||{},usageByControlId:e.buildDashboardControlUsageById(h),availableFieldChoices:x,availableMetricChoices:j,structuralParticipants:D,structuralParticipantIdsByControlId:w,initialCreateFlow:d==="create",onCreateFlowActiveChange:b,onCreateFlowComplete:i,onChange:a,emptyMessage:"No dashboard controls yet."}),A=m?"Add dashboard control":"Dashboard Controls",S=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."})]}),v]});return c?t.jsxs(e.Popover,{open:f,onOpenChange:l,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:p||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:o,onPointerDownOutside:o,children:S})]}):t.jsx(e.Dialog,{open:f,onOpenChange:l,children:t.jsxs(e.DialogContent,{className:"flex max-h-[88vh] max-w-[980px] flex-col overflow-hidden",showCloseButton:!m,onEscapeKeyDown:o,onPointerDownOutside:o,children:[t.jsxs(e.DialogHeader,{className:m?"space-y-0":void 0,children:[t.jsx(e.DialogTitle,{children:A}),t.jsx(e.DialogDescription,{className:m?"sr-only":void 0,children:m?"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:v})]})})}function se({showFilters:s,onToggleFilters:r,onAddFilter:p,onAddControl:c,onManageControls:d,size:u="default",className:n,primaryButtonClassName:l,secondaryButtonClassName:m,dropdownContentClassName:o}){const f=u==="toolbar";return t.jsxs("div",{className:e.cn("relative inline-flex items-stretch overflow-visible rounded-md border border-input bg-background shadow-none",n),children:[t.jsxs(e.Button,{variant:"ghost",className:e.cn(f?"h-8":"h-7","rounded-none border-0 bg-transparent pl-3 pr-2 shadow-none hover:bg-accent/50",l),onClick:r,size:"sm",children:[s?t.jsx(P,{className:"mr-2 h-4 w-4"}):t.jsx(e.Filter,{className:"mr-2 h-4 w-4"}),"Filter"]}),t.jsxs(e.DropdownMenu,{children:[t.jsx(e.DropdownMenuTrigger,{asChild:!0,children:t.jsx(e.Button,{className:e.cn(f?"h-8 w-8":"h-7 w-8","rounded-none border-0 bg-transparent px-1 shadow-none hover:bg-accent/50",m),variant:"ghost",size:"sm","aria-label":"Filter and control actions",children:t.jsx(e.ChevronDown,{className:"h-4 w-4"})})}),t.jsxs(e.DropdownMenuContent,{align:"start",className:e.cn("rounded-xl border border-border/60 p-1 shadow-sm",o),children:[t.jsxs(e.DropdownMenuItem,{onSelect:p,children:[t.jsx(e.Filter,{className:"mr-2 h-4 w-4"}),"Add filter"]}),t.jsxs(e.DropdownMenuItem,{onSelect:c,children:[t.jsx(e.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Add control"]}),t.jsxs(e.DropdownMenuItem,{onSelect:d,children:[t.jsx(e.Pencil,{className:"mr-2 h-4 w-4"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=Q;exports.DashboardControlsSettings=te;exports.DashboardFilterControlsButton=se;exports.ExportNotificationItem=U;exports.ExportNotificationList=B;exports.NotificationBell=J;exports.UnsavedChangesAlert=Y;exports.VisualEditingControls=W;exports.useExportPolling=q;exports.useExportRecovery=_;exports.usePristineSnapshotInitializer=Z;
|