react-semaphor 0.1.172 → 0.1.173

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/chunks/{dashboard-controls-DA-lJWSK.js → dashboard-controls-B6WiXn_t.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-BuKUWOU1.js → dashboard-controls-ByOgk4Je.js} +1 -1
  3. package/dist/chunks/{dashboard-json-CUTAJhWz.js → dashboard-json--V83knyP.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BTWzsbui.js → dashboard-json-BhyQb37-.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-BEWMIe7g.js → edit-dashboard-visual-BBlXAIn6.js} +4632 -4607
  6. package/dist/chunks/{edit-dashboard-visual-_uEu62dm.js → edit-dashboard-visual-Cvaa7yWQ.js} +35 -35
  7. package/dist/chunks/{editor-action-buttons-C5Ejuo4M.js → editor-action-buttons-CY7ioULi.js} +2 -2
  8. package/dist/chunks/{editor-action-buttons-WGWavDMB.js → editor-action-buttons-FLYhmv28.js} +1 -1
  9. package/dist/chunks/{index-DMR0K1Nf.js → index-B9kLqSMl.js} +73 -73
  10. package/dist/chunks/{index-C8T45uat.js → index-CkciFx-7.js} +2318 -2262
  11. package/dist/chunks/{resource-management-panel-BKAs9Em0.js → resource-management-panel-DzIeyziH.js} +3 -3
  12. package/dist/chunks/{resource-management-panel-DFC27hgo.js → resource-management-panel-NzY4o_yO.js} +1 -1
  13. package/dist/chunks/{schedule-dashboard-DC7XeEaW.js → schedule-dashboard-CWqTX2_E.js} +2 -2
  14. package/dist/chunks/{schedule-dashboard-r_XMtRaW.js → schedule-dashboard-D6bnu51y.js} +38 -38
  15. package/dist/chunks/{use-role-aware-display-preferences-CAbBsXoz.js → use-role-aware-display-preferences-CHeIMGXz.js} +1 -1
  16. package/dist/chunks/{use-role-aware-display-preferences-BOpxNd8x.js → use-role-aware-display-preferences-vNHoh1Xk.js} +1 -1
  17. package/dist/chunks/use-visual-utils-BswYPLMe.js +1 -0
  18. package/dist/chunks/use-visual-utils-CK6cVt23.js +338 -0
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +4 -4
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +1 -1
  26. package/dist/types/main.d.ts +36 -0
  27. package/package.json +1 -1
  28. package/dist/chunks/use-visual-utils-BJxotk2m.js +0 -331
  29. package/dist/chunks/use-visual-utils-DG7j82aL.js +0 -1
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as a, Fragment as ge } from "react/jsx-runtime";
2
- import { l as $e, u as me, n as Qe, aB as re, b9 as Xe, ba as Ze, c as X, bb as ke, aS as et, aT as tt, B as _, aU as st, aV as at, aW as W, bc as pe, L as oe, bd as nt, be as it, bf as rt, bg as ve, bh as De, bi as ot, bj as lt, K as dt, bk as ye, e as le, bl as Se, bm as Ve, bn as ct, _ as Ee, V as Le, bo as Ae, a_ as Te, a$ as Oe, b0 as Re, b2 as Pe, b3 as Ue, b4 as Ie, b5 as je, b6 as Me, bp as ut, bq as ht, br as Fe, bs as Be, bt as ze, bu as mt, bv as He, bw as pt, R as ne, aA as ft, bx as _e, by as gt, bz as Dt, aF as xt, aG as Nt, aH as bt, aI as wt, aJ as vt, aK as Ce, aL as fe, aO as Ct, bA as yt, bB as St, bC as Vt, bD as Et } from "./index-C8T45uat.js";
2
+ import { l as $e, u as me, n as Qe, aB as re, b9 as Xe, ba as Ze, c as X, bb as ke, aS as et, aT as tt, B as _, aU as st, aV as at, aW as W, bc as pe, L as oe, bd as nt, be as it, bf as rt, bg as ve, bh as De, bi as ot, bj as lt, K as dt, bk as ye, e as le, bl as Se, bm as Ve, bn as ct, _ as Ee, V as Le, bo as Ae, a_ as Te, a$ as Oe, b0 as Re, b2 as Pe, b3 as Ue, b4 as Ie, b5 as je, b6 as Me, bp as ut, bq as ht, br as Fe, bs as Be, bt as ze, bu as mt, bv as He, bw as pt, R as ne, aA as ft, bx as _e, by as gt, bz as Dt, aF as xt, aG as Nt, aH as bt, aI as wt, aJ as vt, aK as Ce, aL as fe, aO as Ct, bA as yt, bB as St, bC as Vt, bD as Et } from "./index-CkciFx-7.js";
3
3
  import Lt, { useRef as At, useEffect as ie, useState as x } from "react";
4
- import { a as Ke } from "./use-visual-utils-BJxotk2m.js";
5
- import { u as Tt } from "./use-role-aware-display-preferences-CAbBsXoz.js";
4
+ import { a as Ke } from "./use-visual-utils-CK6cVt23.js";
5
+ import { u as Tt } from "./use-role-aware-display-preferences-CHeIMGXz.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DMR0K1Nf.js"),c=require("react"),de=require("./use-visual-utils-DG7j82aL.js"),pe=require("./use-role-aware-display-preferences-BOpxNd8x.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-B9kLqSMl.js"),c=require("react"),de=require("./use-visual-utils-BswYPLMe.js"),pe=require("./use-role-aware-display-preferences-vNHoh1Xk.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1,6 +1,6 @@
1
- "use strict";const s=require("react/jsx-runtime"),e=require("./index-DMR0K1Nf.js"),C=require("./editor-action-buttons-WGWavDMB.js"),x=require("react"),y=require("./use-visual-utils-DG7j82aL.js");/**
1
+ "use strict";const s=require("react/jsx-runtime"),e=require("./index-B9kLqSMl.js"),C=require("./editor-action-buttons-FLYhmv28.js"),x=require("react"),y=require("./use-visual-utils-BswYPLMe.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const I=e.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function k({open:r,onOpenChange:d,isLibraryVisual:a,currentVisualName:t,isSaving:o=!1,onConfirm:h}){const[i,n]=x.useState(a&&t?`Copy of ${t}`:t||""),[c,v]=x.useState(""),[b,j]=x.useState(!a),[g,f]=x.useState(!0);x.useEffect(()=>{r&&(n(a&&t?`Copy of ${t}`:t||""),v(""),j(!a),f(!0))},[r,a,t]);const S=()=>{i.trim()&&(!b&&!g||h({name:i.trim(),description:c.trim()||void 0,saveToLibrary:b,saveToCurrentDashboard:g}))},D=i.trim()&&(b||g);return s.jsx(e.Dialog,{open:r,onOpenChange:d,children:s.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[s.jsxs(e.DialogHeader,{children:[s.jsx(e.DialogTitle,{children:"Save Visual As"}),s.jsx(e.DialogDescription,{children:a?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"name",children:"Name"}),s.jsx(e.Input,{id:"name",value:i,onChange:m=>n(m.target.value),placeholder:"Enter visual name",disabled:o})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),s.jsx(e.Textarea,{id:"description",value:c,onChange:m=>v(m.target.value),placeholder:"Enter visual description",rows:3,disabled:o})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(e.Label,{children:"Save to:"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-dashboard",checked:g,onCheckedChange:m=>f(!!m),disabled:o}),s.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",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:a?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-library",checked:b,onCheckedChange:m=>j(!!m),disabled:o}),s.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",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:a?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!b&&!g&&s.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),s.jsxs(e.DialogFooter,{children:[s.jsx(e.Button,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"}),s.jsxs(e.Button,{onClick:S,disabled:!D||o,children:[o&&s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Saving...":"Save"]})]})]})})}function F(){const[r,d]=x.useState(!1),[a,t]=x.useState(!1),[o,h]=x.useState(null),i=e.useEditorStore(l=>l.frame),n=e.useEditorStore(l=>l.card),c=e.useSelectedVisual(),v=e.useDashboardStore(l=>l.selectedSheetId),b=e.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:j}=y.useVisualUtils(),{selectVisual:g}=e.useManagementActions(),{addFrame:f,setSelectedFrameId:S,setIsVisualEditing:D}=e.useDashboardActions(),m=!!(i!=null&&i.visualId),w=(()=>{var l,p;return((l=i==null?void 0:i.cards)==null?void 0:l.length)===1&&((p=i.cards[0])!=null&&p.title)?i.cards[0].title:c!=null&&c.title?c.title:(n==null?void 0:n.title)||"Untitled Visual"})(),u=e.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(g(l),a&&o&&v){const p={...o,id:e.v4(),visualId:l.id};f(v,p,"end"),S(p.id),t(!1),h(null),D(!1)}b(!0),d(!1)}});return{saveAsDialogOpen:r,setSaveAsDialogOpen:d,handleSaveAs:async l=>{if(!v){e.ue.error("No sheet selected");return}const p=j(),N=p.cards.length===1?{...p,cards:p.cards.map(A=>({...A,title:l.name}))}:p;if(l.saveToLibrary){t(l.saveToCurrentDashboard),h(N);const A={title:l.name,description:l.description,frameObject:N,isPrivate:!1};u.mutate(A)}else if(l.saveToCurrentDashboard){const A={...N,id:e.v4(),visualId:void 0};f(v,A,"end"),S(A.id),e.ue.success("Visual saved to dashboard"),d(!1),D(!1)}},isLibraryVisual:m,currentVisualName:w,isSaving:u.isPending}}function M({className:r}){const d=e.useEditorStore(u=>u.frame),a=e.useEditorStore(u=>u.card),t=e.useManagementStore(u=>u.selectedVisual),o=e.useDashboardStore(u=>u.selectedFrameId),h=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:i}=e.useDashboardActions(),n=!!(d!=null&&d.visualId||t!=null&&t.id),c=!!(d!=null&&d.visualId&&o),v=n&&!c,{saveAsDialogOpen:b,setSaveAsDialogOpen:j,handleSaveAs:g,isLibraryVisual:f,currentVisualName:S,isSaving:D}=F(),{handleAddLibraryVisual:m}=y.useVisualUtils(),w=async()=>{if(!h){e.ue.error("No dashboard sheet selected");return}if(!t){e.ue.error("No visual selected");return}const u=await m(t);u.success?(e.ue.success("Visual added to dashboard"),i(!1)):e.ue.error(u.error||"Failed to add visual to dashboard")};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(C.EditorAcceptButton,{className:r,variant:"default"}),n&&s.jsxs(s.Fragment,{children:[c&&s.jsx(C.VisualApplyLocalButton,{className:r}),v&&h&&a&&(a.sql||e.hasValidCardConfig(a.config))&&s.jsxs(e.Button,{onClick:w,className:e.cn(r),size:"sm",variant:"outline",children:[s.jsx(I,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),v&&s.jsx(C.VisualSaveButton,{className:r,variant:"default"}),c&&s.jsx(C.VisualSaveAndApplyButton,{className:r}),s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(r,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),j(!0)},children:[s.jsx(C.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!n&&s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(r,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:()=>j(!0),children:[s.jsx(C.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),s.jsx(C.EditorCancelButton,{className:r}),s.jsx(k,{open:b,onOpenChange:u=>{D||j(u)},isLibraryVisual:f,currentVisualName:S,isSaving:D,onConfirm:g})]})}function V({className:r,switchClassName:d}){const a=e.useEditorStore(n=>n.isDevMode),t=e.useDashboardStore(n=>n.isVisualEditing),{setIsDevMode:o}=e.useEditorActions(),{config:h}=x.useContext(e.SemaphorContext).tokenProps,i=(h==null?void 0:h.showAdvancedMode)!==!1;return!t||!i?null:s.jsxs("div",{className:e.cn("flex items-center space-x-2",r),children:[s.jsx(e.DevModeSwitch,{className:e.cn("",d),checked:a,onCheckedChange:()=>o(!a),id:"advanced-mode",icon:s.jsx(e.CodeXml,{className:"h-4 w-4"}),tooltip:a?"Standard Mode":"Advanced Mode"}),s.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function E({open:r,onOpenChange:d,onSave:a,onDiscard:t,isSaving:o}){const h=i=>{!i&&o||d(i)};return s.jsx(e.AlertDialog,{open:r,onOpenChange:h,children:s.jsxs(e.AlertDialogContent,{className:"max-w-md",children:[s.jsxs(e.AlertDialogHeader,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:s.jsx(e.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),s.jsx(e.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),s.jsx(e.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),s.jsxs(e.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[s.jsx(e.AlertDialogCancel,{disabled:o,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),s.jsx("button",{onClick:t,disabled:o,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"}),s.jsx(e.AlertDialogAction,{onClick:a,disabled:o,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:o?s.jsxs(s.Fragment,{children:[s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function T(r,d,a,t){x.useEffect(()=>{r&&!a&&d&&t(e.cloneDeep(d))},[r,a,d,t])}function B({triggerButtonClassName:r}){const[d,a]=x.useState(!1),t=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.id}),o=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.title}),h=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.sheets}),i=e.useDashboardStore(n=>n.selectedSheetId);return h==null||h.find(n=>n.id===i),t?s.jsxs(s.Fragment,{children:[s.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",r),onClick:()=>a(!0),children:s.jsx(e.Clock,{className:"size-4"})}),s.jsx(e.EmailScheduleDialog,{open:d,onOpenChange:a,dashboardId:t,dashboardName:o})]}):null}exports.AdvancedModeToggle=V;exports.ScheduleDashboard=B;exports.UnsavedChangesAlert=E;exports.VisualEditingControls=M;exports.usePristineSnapshotInitializer=T;
6
+ */const I=e.createLucideIcon("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]);function k({open:r,onOpenChange:d,isLibraryVisual:t,currentVisualName:a,isSaving:o=!1,onConfirm:h}){const[i,n]=x.useState(t&&a?`Copy of ${a}`:a||""),[c,v]=x.useState(""),[b,j]=x.useState(!t),[g,f]=x.useState(!0);x.useEffect(()=>{r&&(n(t&&a?`Copy of ${a}`:a||""),v(""),j(!t),f(!0))},[r,t,a]);const S=()=>{i.trim()&&(!b&&!g||h({name:i.trim(),description:c.trim()||void 0,saveToLibrary:b,saveToCurrentDashboard:g}))},D=i.trim()&&(b||g);return s.jsx(e.Dialog,{open:r,onOpenChange:d,children:s.jsxs(e.DialogContent,{className:"sm:max-w-[425px]",children:[s.jsxs(e.DialogHeader,{children:[s.jsx(e.DialogTitle,{children:"Save Visual As"}),s.jsx(e.DialogDescription,{children:t?"Create a copy of this visual with a new name":"Save this visual to make it reusable"})]}),s.jsxs("div",{className:"grid gap-4 py-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"name",children:"Name"}),s.jsx(e.Input,{id:"name",value:i,onChange:m=>n(m.target.value),placeholder:"Enter visual name",disabled:o})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(e.Label,{htmlFor:"description",children:"Description (optional)"}),s.jsx(e.Textarea,{id:"description",value:c,onChange:m=>v(m.target.value),placeholder:"Enter visual description",rows:3,disabled:o})]}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(e.Label,{children:"Save to:"}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-dashboard",checked:g,onCheckedChange:m=>f(!!m),disabled:o}),s.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",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(add copy to this dashboard)":"(keep as local visual)"})]})]}),s.jsxs("div",{className:"flex items-center space-x-2",children:[s.jsx(e.Checkbox,{id:"save-to-library",checked:b,onCheckedChange:m=>j(!!m),disabled:o}),s.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",s.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:t?"(save as new reusable visual)":"(make available to all dashboards)"})]})]})]}),!b&&!g&&s.jsx("p",{className:"text-sm text-destructive",children:"Please select at least one destination"})]})]}),s.jsxs(e.DialogFooter,{children:[s.jsx(e.Button,{variant:"outline",onClick:()=>d(!1),disabled:o,children:"Cancel"}),s.jsxs(e.Button,{onClick:S,disabled:!D||o,children:[o&&s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),o?"Saving...":"Save"]})]})]})})}function F(){const[r,d]=x.useState(!1),[t,a]=x.useState(!1),[o,h]=x.useState(null),i=e.useEditorStore(l=>l.frame),n=e.useEditorStore(l=>l.card),c=e.useSelectedVisual(),v=e.useDashboardStore(l=>l.selectedSheetId),b=e.useDashboardStore(l=>l.actions.setIsDashboardPanelOpen),{getUpdatedFrame:j}=y.useVisualUtils(),{selectVisual:g}=e.useManagementActions(),{addFrame:f,setSelectedFrameId:S,setIsVisualEditing:D}=e.useDashboardActions(),m=!!(i!=null&&i.visualId),w=(()=>{var l,p;return((l=i==null?void 0:i.cards)==null?void 0:l.length)===1&&((p=i.cards[0])!=null&&p.title)?i.cards[0].title:c!=null&&c.title?c.title:(n==null?void 0:n.title)||"Untitled Visual"})(),u=e.useCreateVisualWithFrame(l=>{if(l!=null&&l.id){if(g(l),t&&o&&v){const p={...o,id:e.v4(),visualId:l.id};f(v,p,"end"),S(p.id),a(!1),h(null),D(!1)}b(!0),d(!1)}});return{saveAsDialogOpen:r,setSaveAsDialogOpen:d,handleSaveAs:async l=>{if(!v){e.ue.error("No sheet selected");return}const p=j(),N=p.cards.length===1?{...p,cards:p.cards.map(A=>({...A,title:l.name}))}:p;if(l.saveToLibrary){a(l.saveToCurrentDashboard),h(N);const A={title:l.name,description:l.description,frameObject:N,isPrivate:!1};u.mutate(A)}else if(l.saveToCurrentDashboard){const A={...N,id:e.v4(),visualId:void 0};f(v,A,"end"),S(A.id),e.ue.success("Visual saved to dashboard"),d(!1),D(!1)}},isLibraryVisual:m,currentVisualName:w,isSaving:u.isPending}}function M({className:r}){const d=e.useEditorStore(u=>u.frame),t=e.useEditorStore(u=>u.card),a=e.useManagementStore(u=>u.selectedVisual),o=e.useDashboardStore(u=>u.selectedFrameId),h=e.useDashboardStore(u=>u.selectedSheetId),{setIsVisualEditing:i}=e.useDashboardActions(),n=!!(d!=null&&d.visualId||a!=null&&a.id),c=!!(d!=null&&d.visualId&&o),v=n&&!c,{saveAsDialogOpen:b,setSaveAsDialogOpen:j,handleSaveAs:g,isLibraryVisual:f,currentVisualName:S,isSaving:D}=F(),{handleAddLibraryVisual:m}=y.useVisualUtils(),w=async()=>{if(!h){e.ue.error("No dashboard sheet selected");return}if(!a){e.ue.error("No visual selected");return}const u=await m(a);u.success?(e.ue.success("Visual added to dashboard"),i(!1)):e.ue.error(u.error||"Failed to add visual to dashboard")};return s.jsxs(s.Fragment,{children:[!n&&s.jsx(C.EditorAcceptButton,{className:r,variant:"default"}),n&&s.jsxs(s.Fragment,{children:[c&&s.jsx(C.VisualApplyLocalButton,{className:r}),v&&h&&t&&(t.sql||e.hasValidCardConfig(t.config))&&s.jsxs(e.Button,{onClick:w,className:e.cn(r),size:"sm",variant:"outline",children:[s.jsx(I,{className:"mr-2 size-4 font-bold"}),"Add to Dashboard"]}),v&&s.jsx(C.VisualSaveButton,{className:r,variant:"default"}),c&&s.jsx(C.VisualSaveAndApplyButton,{className:r}),s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(r,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:u=>{u.stopPropagation(),j(!0)},children:[s.jsx(C.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]})]}),!n&&s.jsxs(e.DropdownMenu,{modal:!1,children:[s.jsx(e.DropdownMenuTrigger,{asChild:!0,children:s.jsx(e.Button,{variant:"outline",size:"sm",className:e.cn(r,"w-8 p-0"),children:s.jsx(e.EllipsisVertical,{className:"h-4 w-4"})})}),s.jsx(e.DropdownMenuContent,{align:"end",children:s.jsxs(e.DropdownMenuItem,{onClick:()=>j(!0),children:[s.jsx(C.Save,{className:"mr-2 h-4 w-4"}),"Save As..."]})})]}),s.jsx(C.EditorCancelButton,{className:r}),s.jsx(k,{open:b,onOpenChange:u=>{D||j(u)},isLibraryVisual:f,currentVisualName:S,isSaving:D,onConfirm:g})]})}function V({className:r,switchClassName:d}){const t=e.useEditorStore(n=>n.isDevMode),a=e.useDashboardStore(n=>n.isVisualEditing),{setIsDevMode:o}=e.useEditorActions(),{config:h}=x.useContext(e.SemaphorContext).tokenProps,i=(h==null?void 0:h.showAdvancedMode)!==!1;return!a||!i?null:s.jsxs("div",{className:e.cn("flex items-center space-x-2",r),children:[s.jsx(e.DevModeSwitch,{className:e.cn("",d),checked:t,onCheckedChange:()=>o(!t),id:"advanced-mode",icon:s.jsx(e.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),s.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function E({open:r,onOpenChange:d,onSave:t,onDiscard:a,isSaving:o}){const h=i=>{!i&&o||d(i)};return s.jsx(e.AlertDialog,{open:r,onOpenChange:h,children:s.jsxs(e.AlertDialogContent,{className:"max-w-md",children:[s.jsxs(e.AlertDialogHeader,{children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-amber-100",children:s.jsx(e.TriangleAlert,{className:"h-5 w-5 text-amber-600"})}),s.jsx(e.AlertDialogTitle,{className:"text-xl",children:"Unsaved Changes"})]}),s.jsx(e.AlertDialogDescription,{className:"pt-2 text-base leading-relaxed",children:"You have unsaved changes to this dashboard. What would you like to do?"})]}),s.jsxs(e.AlertDialogFooter,{className:"flex-col gap-2 sm:flex-row sm:gap-2",children:[s.jsx(e.AlertDialogCancel,{disabled:o,className:"order-1 m-0 border-border/50 sm:order-1",children:"Cancel"}),s.jsx("button",{onClick:a,disabled:o,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"}),s.jsx(e.AlertDialogAction,{onClick:t,disabled:o,className:"order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",children:o?s.jsxs(s.Fragment,{children:[s.jsx(e.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):"Save & Close"})]})]})})}function T(r,d,t,a){x.useEffect(()=>{r&&!t&&d&&a(e.cloneDeep(d))},[r,t,d,a])}function B({triggerButtonClassName:r}){const[d,t]=x.useState(!1),a=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.id}),o=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.title}),h=e.useDashboardStore(n=>{var c;return(c=n.dashboard)==null?void 0:c.sheets}),i=e.useDashboardStore(n=>n.selectedSheetId);return h==null||h.find(n=>n.id===i),a?s.jsxs(s.Fragment,{children:[s.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",r),onClick:()=>t(!0),children:s.jsx(e.Clock,{className:"size-4"})}),s.jsx(e.EmailScheduleDialog,{open:d,onOpenChange:t,dashboardId:a,dashboardName:o})]}):null}exports.AdvancedModeToggle=V;exports.ScheduleDashboard=B;exports.UnsavedChangesAlert=E;exports.VisualEditingControls=M;exports.usePristineSnapshotInitializer=T;
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as a, Fragment as F } from "react/jsx-runtime";
2
- import { l as _, aF as $, aG as q, aH as K, aI as X, aJ as Y, aK as T, aL as G, aM as J, aN as E, aO as Q, B as I, L as H, n as k, q as Z, u as g, aB as ee, o as R, aP as ae, aQ as O, t as y, R as se, aR as te, c as w, aS as B, aT as P, aU as L, aV as U, aW as z, m as de, aX as le, aY as ne, aZ as re, a_ as oe, a$ as ie, b0 as ce, b1 as he, b2 as ue, b3 as me, b4 as ve, b5 as pe, b6 as be, a5 as fe, K as ge, b7 as Ce, b8 as De } from "./index-C8T45uat.js";
3
- import { E as xe, V as Ae, a as Se, b as Ne, S as j, c as ye } from "./editor-action-buttons-C5Ejuo4M.js";
2
+ import { l as _, aF as $, aG as q, aH as K, aI as X, aJ as Y, aK as T, aL as G, aM as J, aN as E, aO as Q, B as I, L as H, n as k, q as Z, u as g, aB as ee, o as R, aP as ae, aQ as O, t as y, R as se, aR as te, c as w, aS as B, aT as P, aU as L, aV as U, aW as z, m as de, aX as le, aY as ne, aZ as re, a_ as oe, a$ as ie, b0 as ce, b1 as he, b2 as ue, b3 as me, b4 as ve, b5 as pe, b6 as be, a5 as fe, K as ge, b7 as Ce, b8 as De } from "./index-CkciFx-7.js";
3
+ import { E as xe, V as Ae, a as Se, b as Ne, S as j, c as ye } from "./editor-action-buttons-CY7ioULi.js";
4
4
  import we, { useState as D, useContext as Ie, useEffect as ke } from "react";
5
- import { a as W } from "./use-visual-utils-BJxotk2m.js";
5
+ import { a as W } from "./use-visual-utils-CK6cVt23.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -17,19 +17,19 @@ const Fe = _("CirclePlus", [
17
17
  function Ve({
18
18
  open: l,
19
19
  onOpenChange: n,
20
- isLibraryVisual: s,
21
- currentVisualName: t,
20
+ isLibraryVisual: t,
21
+ currentVisualName: s,
22
22
  isSaving: r = !1,
23
23
  onConfirm: u
24
24
  }) {
25
25
  const [i, d] = D(
26
- s && t ? `Copy of ${t}` : t || ""
27
- ), [c, v] = D(""), [b, C] = D(!s), [f, x] = D(!0);
26
+ t && s ? `Copy of ${s}` : s || ""
27
+ ), [c, v] = D(""), [b, C] = D(!t), [f, x] = D(!0);
28
28
  we.useEffect(() => {
29
29
  l && (d(
30
- s && t ? `Copy of ${t}` : t || ""
31
- ), v(""), C(!s), x(!0));
32
- }, [l, s, t]);
30
+ t && s ? `Copy of ${s}` : s || ""
31
+ ), v(""), C(!t), x(!0));
32
+ }, [l, t, s]);
33
33
  const S = () => {
34
34
  i.trim() && (!b && !f || u({
35
35
  name: i.trim(),
@@ -41,7 +41,7 @@ function Ve({
41
41
  return /* @__PURE__ */ e($, { open: l, onOpenChange: n, children: /* @__PURE__ */ a(q, { className: "sm:max-w-[425px]", children: [
42
42
  /* @__PURE__ */ a(K, { children: [
43
43
  /* @__PURE__ */ e(X, { children: "Save Visual As" }),
44
- /* @__PURE__ */ e(Y, { children: s ? "Create a copy of this visual with a new name" : "Save this visual to make it reusable" })
44
+ /* @__PURE__ */ e(Y, { children: t ? "Create a copy of this visual with a new name" : "Save this visual to make it reusable" })
45
45
  ] }),
46
46
  /* @__PURE__ */ a("div", { className: "grid gap-4 py-4", children: [
47
47
  /* @__PURE__ */ a("div", { className: "grid gap-2", children: [
@@ -91,7 +91,7 @@ function Ve({
91
91
  className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
92
92
  children: [
93
93
  "Current Dashboard",
94
- /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: s ? "(add copy to this dashboard)" : "(keep as local visual)" })
94
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: t ? "(add copy to this dashboard)" : "(keep as local visual)" })
95
95
  ]
96
96
  }
97
97
  )
@@ -113,7 +113,7 @@ function Ve({
113
113
  className: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
114
114
  children: [
115
115
  "Visual Library",
116
- /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: s ? "(save as new reusable visual)" : "(make available to all dashboards)" })
116
+ /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-muted-foreground", children: t ? "(save as new reusable visual)" : "(make available to all dashboards)" })
117
117
  ]
118
118
  }
119
119
  )
@@ -140,21 +140,21 @@ function Ve({
140
140
  ] }) });
141
141
  }
142
142
  function Me() {
143
- const [l, n] = D(!1), [s, t] = D(!1), [r, u] = D(null), i = k((o) => o.frame), d = k((o) => o.card), c = Z(), v = g((o) => o.selectedSheetId), b = g(
143
+ const [l, n] = D(!1), [t, s] = D(!1), [r, u] = D(null), i = k((o) => o.frame), d = k((o) => o.card), c = Z(), v = g((o) => o.selectedSheetId), b = g(
144
144
  (o) => o.actions.setIsDashboardPanelOpen
145
145
  ), { getUpdatedFrame: C } = W(), { selectVisual: f } = ee(), { addFrame: x, setSelectedFrameId: S, setIsVisualEditing: A } = R(), m = !!(i != null && i.visualId), V = (() => {
146
146
  var o, p;
147
147
  return ((o = i == null ? void 0 : i.cards) == null ? void 0 : o.length) === 1 && ((p = i.cards[0]) != null && p.title) ? i.cards[0].title : c != null && c.title ? c.title : (d == null ? void 0 : d.title) || "Untitled Visual";
148
148
  })(), h = ae((o) => {
149
149
  if (o != null && o.id) {
150
- if (f(o), s && r && v) {
150
+ if (f(o), t && r && v) {
151
151
  const p = {
152
152
  ...r,
153
153
  id: O(),
154
154
  visualId: o.id
155
155
  // Link to the newly created library visual
156
156
  };
157
- x(v, p, "end"), S(p.id), t(!1), u(null), A(!1);
157
+ x(v, p, "end"), S(p.id), s(!1), u(null), A(!1);
158
158
  }
159
159
  b(!0), n(!1);
160
160
  }
@@ -176,7 +176,7 @@ function Me() {
176
176
  }))
177
177
  } : p;
178
178
  if (o.saveToLibrary) {
179
- t(o.saveToCurrentDashboard), u(M);
179
+ s(o.saveToCurrentDashboard), u(M);
180
180
  const N = {
181
181
  title: o.name,
182
182
  description: o.description,
@@ -204,7 +204,7 @@ function Me() {
204
204
  function ze({
205
205
  className: l
206
206
  }) {
207
- const n = k((h) => h.frame), s = k((h) => h.card), t = se((h) => h.selectedVisual), r = g((h) => h.selectedFrameId), u = g((h) => h.selectedSheetId), { setIsVisualEditing: i } = R(), d = !!(n != null && n.visualId || t != null && t.id), c = !!(n != null && n.visualId && r), v = d && !c, {
207
+ const n = k((h) => h.frame), t = k((h) => h.card), s = se((h) => h.selectedVisual), r = g((h) => h.selectedFrameId), u = g((h) => h.selectedSheetId), { setIsVisualEditing: i } = R(), d = !!(n != null && n.visualId || s != null && s.id), c = !!(n != null && n.visualId && r), v = d && !c, {
208
208
  saveAsDialogOpen: b,
209
209
  setSaveAsDialogOpen: C,
210
210
  handleSaveAs: f,
@@ -216,18 +216,18 @@ function ze({
216
216
  y.error("No dashboard sheet selected");
217
217
  return;
218
218
  }
219
- if (!t) {
219
+ if (!s) {
220
220
  y.error("No visual selected");
221
221
  return;
222
222
  }
223
- const h = await m(t);
223
+ const h = await m(s);
224
224
  h.success ? (y.success("Visual added to dashboard"), i(!1)) : y.error(h.error || "Failed to add visual to dashboard");
225
225
  };
226
226
  return /* @__PURE__ */ a(F, { children: [
227
227
  !d && /* @__PURE__ */ e(xe, { className: l, variant: "default" }),
228
228
  d && /* @__PURE__ */ a(F, { children: [
229
229
  c && /* @__PURE__ */ e(Ae, { className: l }),
230
- v && u && s && (s.sql || te(s.config)) && /* @__PURE__ */ a(
230
+ v && u && t && (t.sql || te(t.config)) && /* @__PURE__ */ a(
231
231
  I,
232
232
  {
233
233
  onClick: V,
@@ -302,17 +302,17 @@ function je({
302
302
  //labelClassName,
303
303
  switchClassName: n
304
304
  }) {
305
- const s = k((d) => d.isDevMode), t = g((d) => d.isVisualEditing), { setIsDevMode: r } = de(), { config: u } = Ie(le).tokenProps, i = (u == null ? void 0 : u.showAdvancedMode) !== !1;
306
- return !t || !i ? null : /* @__PURE__ */ a("div", { className: w("flex items-center space-x-2", l), children: [
305
+ const t = k((d) => d.isDevMode), s = g((d) => d.isVisualEditing), { setIsDevMode: r } = de(), { config: u } = Ie(le).tokenProps, i = (u == null ? void 0 : u.showAdvancedMode) !== !1;
306
+ return !s || !i ? null : /* @__PURE__ */ a("div", { className: w("flex items-center space-x-2", l), children: [
307
307
  /* @__PURE__ */ e(
308
308
  ne,
309
309
  {
310
310
  className: w("", n),
311
- checked: s,
312
- onCheckedChange: () => r(!s),
311
+ checked: t,
312
+ onCheckedChange: () => r(!t),
313
313
  id: "advanced-mode",
314
314
  icon: /* @__PURE__ */ e(re, { className: "h-4 w-4" }),
315
- tooltip: s ? "Standard Mode" : "Advanced Mode"
315
+ tooltip: "Advanced Mode"
316
316
  }
317
317
  ),
318
318
  /* @__PURE__ */ e("label", { htmlFor: "advanced-mode", className: "sr-only", children: "Advanced Mode" })
@@ -321,8 +321,8 @@ function je({
321
321
  function He({
322
322
  open: l,
323
323
  onOpenChange: n,
324
- onSave: s,
325
- onDiscard: t,
324
+ onSave: t,
325
+ onDiscard: s,
326
326
  isSaving: r
327
327
  }) {
328
328
  return /* @__PURE__ */ e(oe, { open: l, onOpenChange: (i) => {
@@ -347,7 +347,7 @@ function He({
347
347
  /* @__PURE__ */ e(
348
348
  "button",
349
349
  {
350
- onClick: t,
350
+ onClick: s,
351
351
  disabled: r,
352
352
  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",
353
353
  children: "Discard"
@@ -356,7 +356,7 @@ function He({
356
356
  /* @__PURE__ */ e(
357
357
  be,
358
358
  {
359
- onClick: s,
359
+ onClick: t,
360
360
  disabled: r,
361
361
  className: "order-3 m-0 bg-primary text-primary-foreground hover:bg-primary/90 sm:order-3",
362
362
  children: r ? /* @__PURE__ */ a(F, { children: [
@@ -368,15 +368,15 @@ function He({
368
368
  ] })
369
369
  ] }) });
370
370
  }
371
- function Re(l, n, s, t) {
371
+ function Re(l, n, t, s) {
372
372
  ke(() => {
373
- l && !s && n && t(fe(n));
374
- }, [l, s, n, t]);
373
+ l && !t && n && s(fe(n));
374
+ }, [l, t, n, s]);
375
375
  }
376
376
  function We({
377
377
  triggerButtonClassName: l
378
378
  }) {
379
- const [n, s] = D(!1), t = g((d) => {
379
+ const [n, t] = D(!1), s = g((d) => {
380
380
  var c;
381
381
  return (c = d.dashboard) == null ? void 0 : c.id;
382
382
  }), r = g((d) => {
@@ -386,13 +386,13 @@ function We({
386
386
  var c;
387
387
  return (c = d.dashboard) == null ? void 0 : c.sheets;
388
388
  }), i = g((d) => d.selectedSheetId);
389
- return u == null || u.find((d) => d.id === i), t ? /* @__PURE__ */ a(F, { children: [
389
+ return u == null || u.find((d) => d.id === i), s ? /* @__PURE__ */ a(F, { children: [
390
390
  /* @__PURE__ */ e(
391
391
  ge,
392
392
  {
393
393
  tooltip: "Schedule Dashboard",
394
394
  className: w("h-7 p-2", l),
395
- onClick: () => s(!0),
395
+ onClick: () => t(!0),
396
396
  children: /* @__PURE__ */ e(Ce, { className: "size-4" })
397
397
  }
398
398
  ),
@@ -400,8 +400,8 @@ function We({
400
400
  De,
401
401
  {
402
402
  open: n,
403
- onOpenChange: s,
404
- dashboardId: t,
403
+ onOpenChange: t,
404
+ dashboardId: s,
405
405
  dashboardName: r
406
406
  }
407
407
  )
@@ -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-C8T45uat.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-CkciFx-7.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 +1 @@
1
- "use strict";const a=require("./index-DMR0K1Nf.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-B9kLqSMl.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;
@@ -0,0 +1 @@
1
+ "use strict";const s=require("./index-B9kLqSMl.js"),g=require("react");function H(e){const a=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),c=e.toUpperCase().indexOf("ORDER BY");let d=e.length;if(c!==-1&&(d=c),r!==-1&&r<d&&(d=r),a!==-1){const i=e.substring(0,a),o=e.substring(a);return`${i} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const i=e.substring(0,t),o=e.substring(t);return`${i} {{ filters | where }} ${o}`}else{const i=e.substring(0,d),o=e.substring(d);return console.log("beforeClause",i),console.log("afterClause",o),o?`${i} {{ filters | where }} ${o}`:`${i.replace(/;$/,"")} {{ filters | where }}`}}function B(e){const[a,t]=g.useState(null),[r,c]=g.useState(null),d=s.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),c(null);return}if(!d)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),c(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),c(l),t(null)}})()},[e,d]),a}function Q(e,a){if(e.length===0)return"";if(a){const t=e.find(r=>r.id===a);if(t){const r=t.tabTitle;if(r=="All__Header")return e[0].id;if(r&&r.endsWith("__Header")){const d=r.split("__")[0],i=e.find(o=>o.tabTitle===d);return i?i.id:e[0].id}return a}}return e[0].id}async function j(e,a,t,r){if(!a||!t)throw new Error("Missing auth token or visual ID");const c=["resource-by-id","visual",t],d=r.getQueryData(c);if(d)return console.log("Using cached visual data for:",t),{data:d,fromCache:!0};console.log("Fetching visual data from network for:",t);const i=s.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${a}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(c,l),s.ue.dismiss(i),{data:l,fromCache:!1}}catch(o){throw s.ue.dismiss(i),o}}function T(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function z(e,a){var d,i;const t=(e==null?void 0:e.frameObject)??((d=e==null?void 0:e.visual)==null?void 0:d.frameObject);if(!t)return!1;const r=T(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const c=(i=r.cards)==null?void 0:i.find(o=>o.id===r.activeCardId);return c?(s.setupEditorWithCard({...a,frame:r,card:c,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function G(){var C;const{setCardSql:e}=s.useEditorActions(),a=s.useEditorStore(n=>n.frame),t=s.useEditorStore(n=>n.card),r=s.useEditorStore(n=>n.isDevMode),c=B(((C=t.customCardPreferences)==null?void 0:C.url)||""),d=s.useEditorStore(n=>n.selectedSchemaName),i=s.useEditorStore(n=>n.selectedDatamodelId),o=s.useEditorStore(n=>n.selectedDatabaseName),l=s.useEditorStore(n=>n.selectedTableName),h=s.useEditorStore(n=>n.selectedConnectionId),m=s.useEditorStore(n=>n.isShowingVisual),S=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let n=S;S&&!S.includes("{{")&&(n=H(S),e(n));const w=(I=c==null?void 0:c.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:d,lastSelectedDatamodelId:i,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?n:void 0,python:r?t.python:void 0,config:r?void 0:t.config,customCfg:m?t.customCfg:null,preferences:t.preferences,...w&&{customCardPreferences:{...t.customCardPreferences,settings:w}}},E=a.cards.map(p=>p.id===t.id?v:p);return{...a,cards:E,activeCardId:Q(E,a.activeCardId)}},[t,a,r,m,d,i,o,l,h,e,c,S])}}function Y(){const{authToken:e,tokenProps:a}=s.useSemaphorContext(),t=s.useQueryClient(),r=s.useSelectedVisual(),{selectVisual:c}=s.useManagementActions(),{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I}=s.useEditorActions(),{setIsDashboardEditing:p,setIsVisualEditing:$,setSelectedFrameId:D,clearSelectedFrameId:A,addFrame:N,setIsDashboardPanelOpen:R}=s.useDashboardActions(),y=s.useDashboardStore(u=>u.selectedSheetId),O=s.useDashboardStore(u=>u.selectedFrameId),x=s.useDashboardStore(u=>u.dashboard),W=s.useDashboardStore(u=>u.filterValues),F=s.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),k=g.useCallback(async u=>{try{c(u),A();const{data:b,fromCache:f}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!z(b,{setFrame:d,setCard:i,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:S,setSelectedConnectionId:V,setSelectedDatabaseName:C,setSelectedSchemaName:n,setSelectedTableName:w,setSelectedDatamodelId:v,setFilterValues:E,setApplyFilters:I,setIsDashboardEditing:p,setIsVisualEditing:$,dashboard:x,selectedSheetId:y,selectedFrameId:O,filterValues:W}))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,a.apiServiceUrl,t,c,d,i,p,$,o,l,h,m,S,V,C,n,w,v,E,I,A,x,y,O,W]),_=g.useCallback(async u=>{var b;try{if(c(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:M}=await j(a.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),L=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!L)return{success:!1,error:"Visual has no frame data"};const U=T(L);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...s.cloneFrameWithNewIds(U),visualId:u.id};return N(y,P,"end"),p(!0),D(P.id),R(!1),{success:!0,fromCache:M}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,a.apiServiceUrl,t,c,y,N,p,D,R]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:k,handleAddLibraryVisual:_,getUpdatedFrame:G().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=B;exports.useVisualUtils=Y;