react-semaphor 0.1.210 → 0.1.211

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 (32) hide show
  1. package/dist/chunks/{dashboard-controls-C08300Wi.js → dashboard-controls-7KpXzAWL.js} +592 -585
  2. package/dist/chunks/dashboard-controls-CnDq9Uh_.js +42 -0
  3. package/dist/chunks/{dashboard-json-GjDBGO26.js → dashboard-json-dqey5VK0.js} +1 -1
  4. package/dist/chunks/{dashboard-json-DlEE5-WA.js → dashboard-json-stWvjp2O.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-THx-gjnG.js → dashboard-summary-settings-dialog-DPEe6XBC.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-QUuhhXU9.js → dashboard-summary-settings-dialog-DuxhidK1.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-Bsmow1Pa.js → edit-dashboard-visual-CQAk_UsI.js} +483 -484
  8. package/dist/chunks/{edit-dashboard-visual-PfWJXb2-.js → edit-dashboard-visual-D_XPr8f8.js} +2 -2
  9. package/dist/chunks/{editor-action-buttons-FPyaC09X.js → editor-action-buttons-CH7W6KdH.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-DNbp_ZWy.js → editor-action-buttons-D34_GSZu.js} +27 -27
  11. package/dist/chunks/{index-CAVrkf9d.js → index-BDS2sWhv.js} +27718 -27508
  12. package/dist/chunks/index-BfiIPyeS.js +1109 -0
  13. package/dist/chunks/{notification-bell-C3a7wC1u.js → notification-bell-Cu3qDd9V.js} +251 -285
  14. package/dist/chunks/notification-bell-hijGST9g.js +6 -0
  15. package/dist/chunks/{resource-management-panel-BVTgbma8.js → resource-management-panel-BvHqslqC.js} +73 -73
  16. package/dist/chunks/{resource-management-panel-C5NjrVsA.js → resource-management-panel-gK3a6OEj.js} +1 -1
  17. package/dist/chunks/{use-role-aware-display-preferences-l7NFLYnn.js → use-role-aware-display-preferences-BlR29aKQ.js} +1 -1
  18. package/dist/chunks/{use-role-aware-display-preferences-DxCPoCgr.js → use-role-aware-display-preferences-a5FH9Y0k.js} +1 -1
  19. package/dist/chunks/{use-visual-utils-B82Q-Ytl.js → use-visual-utils-B11AA2fd.js} +1 -1
  20. package/dist/chunks/{use-visual-utils-D9IJz9R0.js → use-visual-utils-ptPsQ3nC.js} +23 -23
  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 +251 -216
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/main.d.ts +49 -0
  29. package/package.json +1 -1
  30. package/dist/chunks/dashboard-controls-BAOrAMV9.js +0 -42
  31. package/dist/chunks/index-CXKjmjfB.js +0 -1104
  32. package/dist/chunks/notification-bell-BqvKQSw9.js +0 -6
@@ -0,0 +1,6 @@
1
+ "use strict";const x=require("react"),t=require("./index-BfiIPyeS.js"),e=require("react/jsx-runtime"),A=require("./editor-action-buttons-CH7W6KdH.js"),U=require("./use-visual-utils-B11AA2fd.js"),I=require("./date-formatter-Sz6QDaM8.js");/**
2
+ * @license lucide-react v0.453.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const L=t.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]),V=1e4,M=15e3,P=3e4,R=3e4,B=12e4,T=2*60*60*1e3;function z(s){const r=Date.now()-s.getTime();return r<R?V:r<B?M:P}function O(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(p=>p.activeExports),[c,u]=x.useState(typeof document<"u"?!document.hidden:!0),d=x.useRef(null),i=x.useRef(!1),n=x.useRef(void 0),g=r==null?void 0:r.apiServiceUrl,l=s==null?void 0:s.accessToken,f=x.useCallback(()=>{const p=t.useExportStore.getState().activeExports;return Array.from(p.values()).filter(b=>t.isExportInProgress(b.status))},[]);x.useEffect(()=>{if(typeof document>"u")return;const p=()=>{u(!document.hidden)};return document.addEventListener("visibilitychange",p),()=>{document.removeEventListener("visibilitychange",p)}},[]);const j=x.useCallback(async()=>{if(!g||!l){i.current=!1;return}const p=f();if(p.length===0){i.current=!1;return}const b=Date.now(),E=p.filter(a=>b-a.startedAt.getTime()>T);if(E.length>0){const{updateExport:a}=t.useExportStore.getState().actions;for(const o of E)a(o.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const h=p.filter(a=>b-a.startedAt.getTime()<=T);if(h.length===0){i.current=!1;return}const C=await Promise.allSettled(h.map(async a=>{try{const o=await t.getExportStatus(g,l,a.id);let v;if(o.status==="completed")try{v=await t.getDownloadUrl(g,l,a.id)}catch(N){console.error(`[useExportPolling] Failed to get download URL for ${a.id}:`,N)}return{id:a.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:v}}catch(o){return console.error(`[useExportPolling] Failed to poll export ${a.id}:`,o),null}})),{updateExport:S}=t.useExportStore.getState().actions;for(const a of C)a.status==="fulfilled"&&a.value&&S(a.value.id,a.value);const w=f();if(w.length>0&&!document.hidden){const a=w.reduce((v,N)=>N.startedAt<v?N.startedAt:v,w[0].startedAt),o=z(a);d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{var v;(v=n.current)==null||v.call(n)},o)}else i.current=!1},[g,l,f]);return x.useEffect(()=>{n.current=j},[j]),x.useEffect(()=>{var b;f().length>0&&c&&!i.current&&(i.current=!0,(b=n.current)==null||b.call(n))},[m,c,f]),x.useEffect(()=>{var b;const p=f();c&&p.length>0&&!i.current&&(i.current=!0,(b=n.current)==null||b.call(n))},[c,f]),x.useEffect(()=>{!c&&d.current&&(clearTimeout(d.current),d.current=null,i.current=!1)},[c]),x.useEffect(()=>()=>{d.current&&(clearTimeout(d.current),d.current=null)},[]),{isPolling:i.current,isTabVisible:c,inProgressCount:f().length}}function $(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(n=>n.activeExports),{addExport:c}=t.useExportActions(),u=x.useRef(!1),d=r==null?void 0:r.apiServiceUrl,i=s==null?void 0:s.accessToken;x.useEffect(()=>{if(u.current||!d||!i)return;(async()=>{try{const{exports:g}=await t.getExports(d,i,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const l of g){if(m.has(l.id))continue;const f=l.totalChunks?Math.round(l.completedChunks/l.totalChunks*100):0;let j;if(l.status==="completed")try{j=await t.getDownloadUrl(d,i,l.id)}catch(b){console.error(`[useExportRecovery] Failed to get download URL for ${l.id}:`,b)}const p={id:l.id,status:l.status,progress:f,title:q(l),totalRows:l.totalRows,totalChunks:l.totalChunks,completedChunks:l.completedChunks,startedAt:new Date(l.createdAt),lastUpdatedAt:new Date,completedAt:l.completedAt?new Date(l.completedAt):void 0,fileSize:l.fileSize,error:l.error,expiresAt:new Date(l.expiresAt),downloadUrl:j};c(p)}u.current=!0}catch(g){console.error("[useExportRecovery] Failed to recover exports:",g),u.current=!0}})()},[d,i,c,m])}function q(s){return s.title?s.title:t.isExportInProgress(s.status)?"Export in progress...":s.status==="completed"?"Export completed":s.status==="failed"?"Export failed":"Export"}function _({open:s,onOpenChange:r,isLibraryVisual:m,currentVisualName:c,isSaving:u=!1,destinationMode:d="both",onConfirm:i}){const[n,g]=x.useState(m&&c?`Copy of ${c}`:c||""),[l,f]=x.useState("");x.useEffect(()=>{s&&(g(m&&c?`Copy of ${c}`:c||""),f(""))},[s,m,c]);const j=!!n.trim(),p=d==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:d==="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"},b=()=>{!j||u||i({name:n.trim(),description:l.trim()||void 0,saveToLibrary:p.saveToLibrary,saveToCurrentDashboard:p.saveToCurrentDashboard})};return e.jsx(t.Dialog,{open:s,onOpenChange:r,children:e.jsxs(t.DialogContent,{className:"sm:max-w-[500px]",children:[e.jsxs(t.DialogHeader,{children:[e.jsxs(t.DialogTitle,{className:"flex items-center gap-2",children:[e.jsx("span",{children:"Save Visual As"}),p.badgeType!=="local"&&e.jsx(A.VisualBadge,{type:p.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(t.DialogDescription,{children:p.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"name",children:"Name"}),e.jsx(t.Input$1,{id:"name",value:n,onChange:E=>g(E.target.value),placeholder:"Enter visual name",disabled:u})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:l,onChange:E=>f(E.target.value),placeholder:"Enter visual description",rows:3,disabled:u})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>r(!1),disabled:u,children:"Cancel"}),e.jsxs(t.Button,{onClick:b,disabled:!j||u,children:[u&&e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),p.actionLabel]})]})]})})}function H(){const[s,r]=x.useState(!1),[m,c]=x.useState(!1),[u,d]=x.useState(null),i=t.useEditorStore(o=>o.frame),n=t.useEditorStore(o=>o.card),g=t.useSelectedVisual(),l=t.useDashboardStore(o=>o.selectedSheetId),f=t.useDashboardStore(o=>o.actions.setIsDashboardPanelOpen),{getUpdatedFrame:j}=U.useVisualUtils(),{selectVisual:p}=t.useManagementActions(),{addFrame:b,setSelectedFrameId:E,setIsVisualEditing:h}=t.useDashboardActions(),C=!!(i!=null&&i.visualId),S=(()=>{var o,v;return((o=i==null?void 0:i.cards)==null?void 0:o.length)===1&&((v=i.cards[0])!=null&&v.title)?i.cards[0].title:g!=null&&g.title?g.title:(n==null?void 0:n.title)||"Untitled Visual"})(),w=t.useCreateVisualWithFrame(o=>{if(o!=null&&o.id){if(p(o),m&&u&&l){const v={...u,id:t.v4(),visualId:o.id};b(l,v,"end"),E(v.id),c(!1),d(null),h(!1)}f(!0),r(!1)}});return{saveAsDialogOpen:s,setSaveAsDialogOpen:r,handleSaveAs:async o=>{if(!l){t.ue.error("No sheet selected");return}const v=j(),y=v.cards.length===1?{...v,cards:v.cards.map(D=>({...D,title:o.name}))}:v;if(o.saveToLibrary){c(o.saveToCurrentDashboard),d(y);const D={title:o.name,description:o.description,frameObject:y,isPrivate:!1};w.mutate(D)}else if(o.saveToCurrentDashboard){const D={...y,id:t.v4(),visualId:void 0};b(l,D,"end"),E(D.id),t.ue.success("Visual saved to dashboard"),r(!1),h(!1)}},isLibraryVisual:C,currentVisualName:S,isSaving:w.isPending}}function X({className:s}){const r=t.useEditorStore(y=>y.frame),m=t.useManagementStore(y=>y.selectedVisual),c=t.useDashboardStore(y=>y.selectedFrameId),u=t.useDashboardStore(y=>y.selectedSheetId),{setIsVisualEditing:d,updateFrame:i}=t.useDashboardActions(),[n,g]=x.useState(!1),[l,f]=x.useState("both"),j=!!(r!=null&&r.visualId||m!=null&&m.id),p=!!(r!=null&&r.visualId&&c),b=j&&!p,{saveAsDialogOpen:E,setSaveAsDialogOpen:h,handleSaveAs:C,isLibraryVisual:S,currentVisualName:w,isSaving:a}=H(),{getUpdatedFrame:o}=U.useVisualUtils(),v=()=>{if(!u){t.ue.error("No sheet selected");return}if(n)return;g(!0);const D={...o(),visualId:void 0};i(u,D),setTimeout(()=>{g(!1),t.ue.success("Changes applied. Visual is now local to this dashboard"),d(!1)},300)},N=y=>{f(y),h(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-md border border-input",children:[!j&&e.jsx(A.EditorAcceptButton,{className:t.cn(s,"rounded-none border-0"),variant:"default"}),j&&b&&e.jsx(A.VisualSaveButton,{className:t.cn(s,"rounded-none border-0"),variant:"default"}),j&&p&&e.jsx(A.VisualSaveAndApplyButton,{className:t.cn(s,"rounded-none border-0")}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{className:"h-8",asChild:!0,children:e.jsx(t.Button,{variant:"default",size:"sm",className:t.cn(s,"w-8 rounded-none border-0 border-l border-primary-foreground/30 px-2"),"aria-label":"Open visual save options",disabled:a||n,children:e.jsx(t.ChevronDown,{className:"h-4 w-4"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",children:[p&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:v,disabled:n,children:[e.jsx(t.Check,{className:"mr-2 h-4 w-4"}),n?"Applying...":"Apply Locally"]}),e.jsx(t.DropdownMenuSeparator,{})]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>N("local"),disabled:a,children:[e.jsx(t.Plus,{className:"mr-2 h-4 w-4"}),"Add to Dashboard (Local)"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>N("library"),disabled:a,children:[e.jsx(A.Library,{className:"mr-2 h-4 w-4"}),"Save as Library Visual"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>N("both"),disabled:a,children:[e.jsx(A.Link2,{className:"mr-2 h-4 w-4"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(A.EditorCancelButton,{className:s}),e.jsx(_,{open:E,onOpenChange:y=>{a||h(y)},isLibraryVisual:S,currentVisualName:w,isSaving:a,destinationMode:l,onConfirm:C})]})}function G({className:s,switchClassName:r}){const m=t.useEditorStore(n=>n.isDevMode),c=t.useDashboardStore(n=>n.isVisualEditing),{setIsDevMode:u}=t.useEditorActions(),{config:d}=x.useContext(t.SemaphorContext).tokenProps,i=(d==null?void 0:d.showAdvancedMode)!==!1;return!c||!i?null:e.jsxs("div",{className:t.cn("flex items-center space-x-2",s),children:[e.jsx(t.DevModeSwitch,{className:t.cn("",r),checked:m,onCheckedChange:()=>u(!m),id:"advanced-mode",icon:e.jsx(t.CodeXml,{className:"h-4 w-4"}),tooltip:"Advanced Mode"}),e.jsx("label",{htmlFor:"advanced-mode",className:"sr-only",children:"Advanced Mode"})]})}function W({open:s,onOpenChange:r,onSave:m,onDiscard:c,isSaving:u,title:d="Unsaved Changes",description:i="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:n="Cancel",discardLabel:g="Discard",saveLabel:l="Save & Close"}){const f=j=>{!j&&u||r(j)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:f,children:e.jsxs(t.AlertDialogContent,{className:"max-w-[520px] border-border/70 p-6",children:[e.jsxs(t.AlertDialogHeader,{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-9 w-9 items-center justify-center rounded-full bg-amber-50 ring-1 ring-amber-200/70",children:e.jsx(t.TriangleAlert,{className:"h-[18px] w-[18px] text-amber-600"})}),e.jsx(t.AlertDialogTitle,{className:"text-lg font-semibold tracking-tight",children:d})]}),e.jsx(t.AlertDialogDescription,{className:"text-sm leading-6 text-muted-foreground",children:i})]}),e.jsxs(t.AlertDialogFooter,{className:"mt-2 flex-col gap-1.5 sm:flex-row sm:justify-end",children:[e.jsx(t.AlertDialogCancel,{disabled:u,className:"order-1 m-0 h-9 border-border/60 px-4 sm:order-1",children:n}),e.jsx("button",{onClick:c,disabled:u,className:"order-2 h-9 rounded-md border border-destructive/30 bg-destructive/10 px-4 text-sm font-medium text-destructive transition-colors hover:bg-destructive/20 disabled:pointer-events-none disabled:opacity-50 sm:order-2",children:g}),e.jsx(t.AlertDialogAction,{onClick:m,disabled:u,className:"order-3 m-0 h-9 px-4 sm:order-3",children:u?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Saving..."]}):l})]})]})})}function Q(s,r,m,c){x.useEffect(()=>{s&&!m&&r&&c(t.cloneDeep(r))},[s,m,r,c])}function k({export:s,onRemove:r}){const m=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},c=n=>{n.stopPropagation(),r==null||r(s.id)},u=()=>{switch(s.status){case"completed":return e.jsx(t.CircleCheck,{className:"mt-0.5 h-5 w-5 shrink-0 text-green-600"});case"failed":return e.jsx(A.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(t.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},d=t.isExportInProgress(s.status),i=(()=>{switch(s.status){case"pending":return"Queued...";case"processing":return"Processing...";case"chunking":return"Processing...";case"compacting":return"Finalizing...";default:return"Processing..."}})();return e.jsxs("div",{className:"group p-4 transition-colors hover:bg-muted/50",children:[e.jsxs("div",{className:"mb-2 flex items-start justify-between gap-3",children:[e.jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[u(),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h4",{className:"mb-1 truncate text-sm font-medium",children:s.title}),s.status==="completed"&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[s.totalRows.toLocaleString()," rows"]}),s.fileSize&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"•"}),e.jsx("span",{children:t.formatFileSize(s.fileSize)})]})]}),d&&e.jsx("div",{className:"text-xs text-muted-foreground",children:i}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(t.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:c,"aria-label":"Remove notification",children:e.jsx(t.X,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"ml-8",children:[s.status==="completed"&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(t.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:m,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),d&&e.jsxs("div",{children:[e.jsx(t.Progress,{value:s.progress,className:"h-1.5"}),e.jsxs("span",{className:"mt-1 block text-xs text-muted-foreground",children:[s.progress,"% complete"]})]}),s.status==="failed"&&e.jsx("span",{className:"text-xs text-muted-foreground",children:I.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function F(){const{authToken:s,tokenProps:r}=t.useSemaphorContext(),m=t.useExportStore(h=>h.activeExports),{clearCompleted:c,removeExport:u,updateExport:d}=t.useExportActions(),[i,n]=x.useState(!1),[g,l]=x.useState(!1),f=Array.from(m.values()).sort((h,C)=>C.startedAt.getTime()-h.startedAt.getTime()),j=f.some(h=>h.status==="completed"||h.status==="failed"),p=x.useCallback(async()=>{const h=r==null?void 0:r.apiServiceUrl,C=s==null?void 0:s.accessToken;if(!(!h||!C)){n(!0);try{const S=Array.from(m.values());await Promise.all(S.map(async w=>{try{const a=await t.getExportStatus(h,C,w.id);let o;if(a.status==="completed")try{o=await t.getDownloadUrl(h,C,w.id)}catch(v){console.error(`Failed to get download URL for ${w.id}:`,v)}d(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:o})}catch(a){console.error(`Failed to refresh export ${w.id}:`,a)}}))}finally{n(!1)}}},[m,s==null?void 0:s.accessToken,r==null?void 0:r.apiServiceUrl,d]),b=x.useCallback(async()=>{const h=r==null?void 0:r.apiServiceUrl,C=s==null?void 0:s.accessToken;if(!h||!C){c();return}l(!0);try{const S=f.filter(a=>a.status==="completed"||a.status==="failed"),w=await Promise.allSettled(S.map(async a=>(await t.cancelExport(h,C,a.id),a.id)));for(const a of w)a.status==="fulfilled"?u(a.value):console.error("Failed to delete export:",a.reason)}finally{l(!1)}},[f,r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,c,u]),E=x.useCallback(async h=>{const C=r==null?void 0:r.apiServiceUrl,S=s==null?void 0:s.accessToken;if(C&&S)try{await t.cancelExport(C,S,h),u(h);return}catch(w){console.error(`Failed to cancel export ${h}:`,w)}u(h)},[r==null?void 0:r.apiServiceUrl,s==null?void 0:s.accessToken,u]);return f.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(L,{className:"mx-auto mb-2 h-8 w-8 text-muted-foreground"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active exports"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Large exports will appear here"})]}):e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-4 py-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"h-5 w-5 text-muted-foreground"}),e.jsx("h4",{className:"font-semibold",children:"Exports"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:p,disabled:i,title:"Refresh status",children:e.jsx(t.RefreshCw,{className:`h-4 w-4 ${i?"animate-spin":""}`})}),j&&e.jsx(t.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:b,disabled:g,children:g?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:f.map(h=>e.jsx(k,{export:h,onRemove:E},h.id))})})]})}function Y(){const s=t.useExportStore(n=>n.activeExports),r=t.useInProgressExportsCount(),m=s.size>0,c=Array.from(s.values()).some(n=>n.status==="completed"||n.status==="failed"),d=r>0?r>9?"9+":String(r):null,i=m;return e.jsxs(t.Popover,{children:[e.jsx(t.PopoverTrigger,{asChild:!0,children:e.jsxs(t.Button,{variant:"ghost",size:"icon",className:"relative h-8 w-8","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-4 w-4"}),i&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${d?"-right-0.5 -top-0.5 h-4 min-w-4 px-0.5 text-[10px] font-semibold":"right-0.5 top-0.5 h-2 w-2"}`,children:d})]})}),e.jsx(t.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(F,{})})]})}exports.AdvancedModeToggle=G;exports.ExportNotificationItem=k;exports.ExportNotificationList=F;exports.NotificationBell=Y;exports.UnsavedChangesAlert=W;exports.VisualEditingControls=X;exports.useExportPolling=O;exports.useExportRecovery=$;exports.usePristineSnapshotInitializer=Q;
@@ -1,8 +1,8 @@
1
1
  import { jsx as e, jsxs as n, Fragment as ge } from "react/jsx-runtime";
2
- import { bP as _e, u as ie, bA as qe, bL as le, c2 as Ge, c3 as Ke, B as U, c4 as pe, c5 as We, c6 as Ye, c7 as Xe, c8 as Je, c9 as X, H as de, ca as Qe, cb as Ze, cc as $e, cd as ve, ce as De, cf as ke, cg as et, c as re, ch as be, e as ce, ci as ye, cj as Se, ck as tt, ai as Ee, ag as Ve, cl as Le, cm as Ae, cn as Oe, co as Te, cp as Re, cq as Pe, cr as Ue, cs as je, ct as Ie, cu as st, cv as nt, bE as ae, l as at, cw as Me, cx as it, m as rt, n as ot, o as lt, p as dt, q as ct, L as Ce, cy as fe, G as ut, cz as ht, cA as mt, cB as pt, bW as ft, bX as gt, bY as Dt, b_ as xt, cC as Nt, cD as wt } from "./index-CAVrkf9d.js";
2
+ import { bS as _e, u as ie, a1 as Ge, W as le, c5 as qe, c6 as Ke, B as U, c7 as pe, c8 as We, c9 as Ye, ca as Ze, cb as $e, cc as Z, H as de, cd as Je, ce as Qe, cf as Xe, cg as ve, ch as De, ci as ke, cj as et, c as re, ck as be, e as ce, cl as ye, cm as Se, cn as tt, au as Ee, as as Ve, co as Le, cp as Ae, cq as Oe, cr as Te, cs as Re, ct as Pe, cu as Ue, cv as je, cw as Fe, cx as st, cy as nt, bO as ae, l as at, cz as Ie, cA as it, m as rt, n as ot, o as lt, p as dt, q as ct, L as Ce, cB as fe, G as ut, cC as ht, cD as mt, cE as pt, bZ as ft, b_ as gt, b$ as Dt, c1 as xt, cF as Nt, cG as wt } from "./index-BDS2sWhv.js";
3
3
  import vt, { useRef as Ct, useEffect as oe, useState as N } from "react";
4
- import { a as Fe } from "./use-visual-utils-D9IJz9R0.js";
5
- import { u as bt } from "./use-role-aware-display-preferences-DxCPoCgr.js";
4
+ import { a as Me } from "./use-visual-utils-ptPsQ3nC.js";
5
+ import { u as bt } from "./use-role-aware-display-preferences-a5FH9Y0k.js";
6
6
  /**
7
7
  * @license lucide-react v0.453.0 - ISC
8
8
  *
@@ -47,7 +47,7 @@ function ze() {
47
47
  )) });
48
48
  }
49
49
  const Et = (t) => {
50
- const g = ie((r) => r.isVisualEditing), p = ie((r) => r.selectedFrameId), o = qe((r) => r.frame);
50
+ const g = ie((r) => r.isVisualEditing), p = ie((r) => r.selectedFrameId), o = Ge((r) => r.frame);
51
51
  return !!(g && p && (o == null ? void 0 : o.visualId) === t);
52
52
  };
53
53
  function Vt({
@@ -63,10 +63,10 @@ function Vt({
63
63
  onShareVisual: w,
64
64
  formatDate: b
65
65
  }) {
66
- var T, I, v, z;
67
- const { selectVisual: u } = le(), h = Ge(t.id), d = Et(t.id), A = ie((f) => f.isVisualEditing), { isConsoleMode: O } = Ke(), x = vt.useRef(null), [V, y] = N(!1), [S, F] = N(!1);
66
+ var T, F, v, z;
67
+ const { selectVisual: u } = le(), h = qe(t.id), d = Et(t.id), A = ie((f) => f.isVisualEditing), { isConsoleMode: O } = Ke(), x = vt.useRef(null), [V, y] = N(!1), [S, M] = N(!1);
68
68
  oe(() => {
69
- p ? (y(!0), F(!0)) : S && (y(!1), F(!1));
69
+ p ? (y(!0), M(!0)) : S && (y(!1), M(!1));
70
70
  }, [p, S]), oe(() => {
71
71
  d && x.current && x.current.scrollIntoView({
72
72
  behavior: "smooth",
@@ -140,12 +140,12 @@ function Vt({
140
140
  variant: "outline",
141
141
  className: "h-7 w-7 rounded-none border-0 border-l border-input p-0 shadow-none",
142
142
  "aria-label": "Open visual actions",
143
- children: /* @__PURE__ */ e(Xe, { className: "h-3 w-3" })
143
+ children: /* @__PURE__ */ e(Ze, { className: "h-3 w-3" })
144
144
  }
145
145
  ) }),
146
- /* @__PURE__ */ n(Je, { align: "end", className: "z-[51] w-40", children: [
146
+ /* @__PURE__ */ n($e, { align: "end", className: "z-[51] w-40", children: [
147
147
  /* @__PURE__ */ n(
148
- X,
148
+ Z,
149
149
  {
150
150
  onClick: (f) => {
151
151
  f.stopPropagation(), o(t);
@@ -158,7 +158,7 @@ function Vt({
158
158
  }
159
159
  ),
160
160
  /* @__PURE__ */ n(
161
- X,
161
+ Z,
162
162
  {
163
163
  onClick: (f) => {
164
164
  f.stopPropagation(), r == null || r(t);
@@ -170,46 +170,46 @@ function Vt({
170
170
  }
171
171
  ),
172
172
  /* @__PURE__ */ n(
173
- X,
173
+ Z,
174
174
  {
175
175
  onClick: (f) => {
176
176
  f.preventDefault(), f.stopPropagation(), i(t.id);
177
177
  },
178
178
  disabled: p,
179
179
  children: [
180
- p ? /* @__PURE__ */ e(de, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Qe, { className: "mr-2 h-3 w-3" }),
180
+ p ? /* @__PURE__ */ e(de, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Je, { className: "mr-2 h-3 w-3" }),
181
181
  p ? "Duplicating..." : "Duplicate"
182
182
  ]
183
183
  }
184
184
  ),
185
185
  t.ownership.isOwner && /* @__PURE__ */ n(ge, { children: [
186
186
  /* @__PURE__ */ n(
187
- X,
187
+ Z,
188
188
  {
189
189
  onClick: (f) => {
190
190
  f.stopPropagation(), c == null || c(t);
191
191
  },
192
192
  children: [
193
- /* @__PURE__ */ e(Ze, { className: "mr-2 h-3 w-3" }),
193
+ /* @__PURE__ */ e(Qe, { className: "mr-2 h-3 w-3" }),
194
194
  "Edit details"
195
195
  ]
196
196
  }
197
197
  ),
198
198
  /* @__PURE__ */ n(
199
- X,
199
+ Z,
200
200
  {
201
201
  onClick: (f) => {
202
202
  f.stopPropagation(), w(t);
203
203
  },
204
204
  children: [
205
- /* @__PURE__ */ e($e, { className: "mr-2 h-3 w-3" }),
205
+ /* @__PURE__ */ e(Xe, { className: "mr-2 h-3 w-3" }),
206
206
  "Share"
207
207
  ]
208
208
  }
209
209
  ),
210
210
  /* @__PURE__ */ e(ve, {}),
211
211
  /* @__PURE__ */ n(
212
- X,
212
+ Z,
213
213
  {
214
214
  onClick: (f) => {
215
215
  f.stopPropagation(), D(t);
@@ -225,7 +225,7 @@ function Vt({
225
225
  ] }),
226
226
  /* @__PURE__ */ e(ve, {}),
227
227
  /* @__PURE__ */ n("div", { className: "space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400", children: [
228
- (((I = t.ownership.createdBy) == null ? void 0 : I.type) === "tenant" || ((v = t.ownership.createdBy) == null ? void 0 : v.type) === "organization" && O) && /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
228
+ (((F = t.ownership.createdBy) == null ? void 0 : F.type) === "tenant" || ((v = t.ownership.createdBy) == null ? void 0 : v.type) === "organization" && O) && /* @__PURE__ */ n("div", { className: "flex items-center gap-1", children: [
229
229
  /* @__PURE__ */ e(ke, { className: "h-3 w-3" }),
230
230
  /* @__PURE__ */ e("span", { children: ((z = t.ownership.createdBy) == null ? void 0 : z.name) || "Unknown" })
231
231
  ] }),
@@ -251,14 +251,14 @@ function Lt({ searchQuery: t }) {
251
251
  null
252
252
  ), [c, D] = N(!1), [i, w] = N(null), [b, u] = N(null), [h, d] = N(
253
253
  null
254
- ), { selectVisual: A } = le(), { handleEditLibraryVisual: O, handleAddLibraryVisual: x } = Fe(), {
254
+ ), { selectVisual: A } = le(), { handleEditLibraryVisual: O, handleAddLibraryVisual: x } = Me(), {
255
255
  resources: V,
256
256
  isLoading: y,
257
257
  isError: S,
258
- isFetching: F,
258
+ isFetching: M,
259
259
  updateResource: j,
260
260
  deleteResource: T,
261
- duplicateResource: I,
261
+ duplicateResource: F,
262
262
  isDeleting: v,
263
263
  isDuplicating: z,
264
264
  isUpdating: f
@@ -266,24 +266,24 @@ function Lt({ searchQuery: t }) {
266
266
  D(!1), w(null);
267
267
  });
268
268
  ce();
269
- const J = V.filter(
269
+ const $ = V.filter(
270
270
  (a) => {
271
271
  var L, l;
272
272
  return ((L = a == null ? void 0 : a.title) == null ? void 0 : L.toLowerCase().includes(t.toLowerCase())) || ((l = a == null ? void 0 : a.description) == null ? void 0 : l.toLowerCase().includes(t.toLowerCase()));
273
273
  }
274
- ), G = (a) => new Date(a).toLocaleDateString("en-US", {
274
+ ), q = (a) => new Date(a).toLocaleDateString("en-US", {
275
275
  month: "short",
276
276
  day: "numeric",
277
277
  year: "numeric"
278
278
  }), B = (a) => {
279
279
  w(a), D(!0);
280
- }, M = () => {
280
+ }, I = () => {
281
281
  i && T(i.id);
282
282
  }, {
283
283
  startUpdating: ue,
284
284
  stopUpdating: E,
285
285
  isUpdating: te
286
- } = ye(), Q = (a, L, l) => {
286
+ } = ye(), J = (a, L, l) => {
287
287
  var ne;
288
288
  const k = Object.fromEntries(
289
289
  Object.entries(L).filter(([, P]) => P !== void 0)
@@ -310,12 +310,12 @@ function Lt({ searchQuery: t }) {
310
310
  }
311
311
  );
312
312
  }, H = (a) => {
313
- u(a), I(a, {
313
+ u(a), F(a, {
314
314
  onSettled: () => u(null)
315
315
  });
316
316
  }, _ = (a) => {
317
317
  O(a);
318
- }, Z = (a) => {
318
+ }, Q = (a) => {
319
319
  x(a);
320
320
  }, K = (a) => {
321
321
  const L = V.find((l) => l.id === a);
@@ -325,7 +325,7 @@ function Lt({ searchQuery: t }) {
325
325
  isPrivate: !L.isPrivate
326
326
  }
327
327
  });
328
- }, $ = (a) => {
328
+ }, X = (a) => {
329
329
  r(a), p(!0);
330
330
  }, W = (a) => {
331
331
  d(a);
@@ -338,7 +338,7 @@ function Lt({ searchQuery: t }) {
338
338
  if (!h)
339
339
  return;
340
340
  const l = {};
341
- a !== h.title && (l.title = a), (h.description || "") !== L && (l.description = L), Q(h.id, l, {
341
+ a !== h.title && (l.title = a), (h.description || "") !== L && (l.description = L), J(h.id, l, {
342
342
  onSuccess: () => {
343
343
  d(null);
344
344
  }
@@ -357,24 +357,24 @@ function Lt({ searchQuery: t }) {
357
357
  }
358
358
  )
359
359
  ] }) }) : /* @__PURE__ */ n("div", { className: "flex h-full flex-1 flex-col", children: [
360
- /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: J.length === 0 ? /* @__PURE__ */ n("div", { className: "py-8 text-center", children: [
360
+ /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: $.length === 0 ? /* @__PURE__ */ n("div", { className: "py-8 text-center", children: [
361
361
  /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(tt, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
362
362
  /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: t ? "No visuals found" : "No visuals yet" }),
363
363
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t ? "Try adjusting your search" : 'Click "New" above to add your first visual' })
364
- ] }) : J.map((a) => /* @__PURE__ */ e(
364
+ ] }) : $.map((a) => /* @__PURE__ */ e(
365
365
  Vt,
366
366
  {
367
367
  visual: a,
368
- onAddVisual: Z,
368
+ onAddVisual: Q,
369
369
  onOpenVisual: _,
370
370
  onEditDetails: W,
371
371
  onDeleteClick: B,
372
372
  onDuplicateVisual: H,
373
373
  onTogglePrivacy: K,
374
- onShareVisual: $,
374
+ onShareVisual: X,
375
375
  isDeleting: v,
376
376
  isDuplicating: b === a.id,
377
- formatDate: G
377
+ formatDate: q
378
378
  },
379
379
  a.id
380
380
  )) }),
@@ -419,10 +419,10 @@ function Lt({ searchQuery: t }) {
419
419
  /* @__PURE__ */ n(Ue, { children: [
420
420
  /* @__PURE__ */ e(je, { disabled: v, children: "Cancel" }),
421
421
  /* @__PURE__ */ n(
422
- Ie,
422
+ Fe,
423
423
  {
424
424
  onClick: (a) => {
425
- a.preventDefault(), a.stopPropagation(), M();
425
+ a.preventDefault(), a.stopPropagation(), I();
426
426
  },
427
427
  className: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
428
428
  disabled: v,
@@ -514,34 +514,34 @@ function Tt(t) {
514
514
  (s) => s.lastSelectedDashboard
515
515
  ), S = ae(
516
516
  (s) => s.selectedDashboard
517
- ), F = ae(
517
+ ), M = ae(
518
518
  (s) => s.actions.selectDashboard
519
519
  ), j = ae(
520
520
  (s) => s.actions.clearSelectedDashboard
521
- ), { tokenProps: T, id: I } = at();
521
+ ), { tokenProps: T, id: F } = at();
522
522
  bt();
523
523
  const {
524
524
  resources: v,
525
525
  isLoading: z,
526
526
  isError: f,
527
- isFetching: J,
528
- updateResource: G,
527
+ isFetching: $,
528
+ updateResource: q,
529
529
  deleteResource: B,
530
- duplicateResource: M,
530
+ duplicateResource: I,
531
531
  isUpdating: ue,
532
532
  isDeleting: E,
533
533
  isDuplicating: te,
534
- refetch: Q
535
- } = Me(() => {
534
+ refetch: J
535
+ } = Ie(() => {
536
536
  u(!1);
537
537
  const s = h == null ? void 0 : h.id;
538
- d(null), (S == null ? void 0 : S.id) === s && (!(T != null && T.dashboard_id) && !I ? j() : y && y.id !== s && F(y));
539
- }), { currentUser: H, userContext: _ } = ce(), Z = ((xe = _ == null ? void 0 : _.permissions) == null ? void 0 : xe.canCreateDashboard) ?? !1, K = v.filter(
538
+ d(null), (S == null ? void 0 : S.id) === s && (!(T != null && T.dashboard_id) && !F ? j() : y && y.id !== s && M(y));
539
+ }), { currentUser: H, userContext: _ } = ce(), Q = ((xe = _ == null ? void 0 : _.permissions) == null ? void 0 : xe.canCreateDashboard) ?? !1, K = v.filter(
540
540
  (s) => {
541
541
  var R, m;
542
542
  return ((R = s == null ? void 0 : s.title) == null ? void 0 : R.toLowerCase().includes(g.toLowerCase())) || ((m = s == null ? void 0 : s.description) == null ? void 0 : m.toLowerCase().includes(g.toLowerCase()));
543
543
  }
544
- ), $ = (s) => new Date(s).toLocaleDateString("en-US", {
544
+ ), X = (s) => new Date(s).toLocaleDateString("en-US", {
545
545
  month: "short",
546
546
  day: "numeric",
547
547
  year: "numeric"
@@ -552,7 +552,7 @@ function Tt(t) {
552
552
  }, C = () => {
553
553
  h && B(h.id);
554
554
  }, a = (s) => {
555
- O(s), M(s, {
555
+ O(s), I(s, {
556
556
  onSettled: () => O(null)
557
557
  });
558
558
  }, {
@@ -562,26 +562,26 @@ function Tt(t) {
562
562
  } = ye(), se = (s, R, m) => {
563
563
  var we;
564
564
  const he = Object.fromEntries(
565
- Object.entries(R).filter(([, q]) => q !== void 0)
565
+ Object.entries(R).filter(([, G]) => G !== void 0)
566
566
  );
567
567
  if (Object.keys(he).length === 0) {
568
568
  (we = m == null ? void 0 : m.onSuccess) == null || we.call(m);
569
569
  return;
570
570
  }
571
571
  const Ne = Object.keys(he), me = Ne.length === 1 ? Ne[0] : void 0;
572
- L(s, me), G(
572
+ L(s, me), q(
573
573
  {
574
574
  resourceId: s,
575
575
  data: he
576
576
  },
577
577
  {
578
578
  onSuccess: () => {
579
- var q;
580
- l(s, me), (q = m == null ? void 0 : m.onSuccess) == null || q.call(m);
579
+ var G;
580
+ l(s, me), (G = m == null ? void 0 : m.onSuccess) == null || G.call(m);
581
581
  },
582
582
  onError: () => {
583
- var q;
584
- l(s, me), (q = m == null ? void 0 : m.onError) == null || q.call(m);
583
+ var G;
584
+ l(s, me), (G = m == null ? void 0 : m.onError) == null || G.call(m);
585
585
  }
586
586
  }
587
587
  );
@@ -589,7 +589,7 @@ function Tt(t) {
589
589
  const R = v.find(
590
590
  (m) => m.id === s
591
591
  );
592
- R && G({
592
+ R && q({
593
593
  resourceId: s,
594
594
  data: {
595
595
  isPrivate: !R.isPrivate
@@ -618,7 +618,7 @@ function Tt(t) {
618
618
  /* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-3 overflow-y-auto", children: K.length === 0 ? /* @__PURE__ */ n("div", { className: "py-8 text-center", children: [
619
619
  /* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(it, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
620
620
  /* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: g ? "No dashboards found" : "No dashboards yet" }),
621
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: g ? "Try adjusting your search" : Z ? 'Click "New" above to add your first dashboard' : "No dashboards have been shared with you yet" })
621
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: g ? "Try adjusting your search" : Q ? 'Click "New" above to add your first dashboard' : "No dashboards have been shared with you yet" })
622
622
  ] }) : K.map((s) => /* @__PURE__ */ e(
623
623
  At,
624
624
  {
@@ -631,7 +631,7 @@ function Tt(t) {
631
631
  onDuplicateDashboard: a,
632
632
  onTogglePrivacy: ee,
633
633
  onShareDashboard: ne,
634
- formatDate: $,
634
+ formatDate: X,
635
635
  onDashboardItemClick: r
636
636
  },
637
637
  s.id
@@ -665,7 +665,7 @@ function Tt(t) {
665
665
  /* @__PURE__ */ n(Ue, { children: [
666
666
  /* @__PURE__ */ e(je, { disabled: E, children: "Cancel" }),
667
667
  /* @__PURE__ */ n(
668
- Ie,
668
+ Fe,
669
669
  {
670
670
  onClick: (s) => {
671
671
  s.preventDefault(), s.stopPropagation(), C();
@@ -771,7 +771,7 @@ function Rt({
771
771
  ] })
772
772
  ] }) });
773
773
  }
774
- function Ft({
774
+ function Mt({
775
775
  isOpen: t,
776
776
  onClose: g,
777
777
  className: p,
@@ -783,17 +783,17 @@ function Ft({
783
783
  (C) => C.isDashboardEditing
784
784
  ), [D, i] = N(!1), [w, b] = N(""), [u, h] = N(!1), { currentUser: d, userContext: A } = ce(), O = ((W = A == null ? void 0 : A.permissions) == null ? void 0 : W.canCreateDashboard) ?? !1, { onCreateSuccess: x } = ht({
785
785
  onDashboardSelect: o
786
- }), { selectVisual: V } = le(), { handleEditLibraryVisual: y } = Fe(), {
786
+ }), { selectVisual: V } = le(), { handleEditLibraryVisual: y } = Me(), {
787
787
  createResource: S,
788
- isCreating: F,
788
+ isCreating: M,
789
789
  refetch: j
790
- } = Me(), { createResource: T, isCreating: I } = be(
790
+ } = Ie(), { createResource: T, isCreating: F } = be(
791
791
  void 0,
792
792
  // onDeleteSuccess (not needed here)
793
793
  (C) => {
794
794
  i(!1), C && (V(C), y(C));
795
795
  }
796
- ), v = r === "overlay", z = c ? "New Visual" : "New", f = c ? "New Visual" : "New Dashboard", J = c ? "Search visuals..." : "Search dashboards...", G = c ? "Collapse visuals panel" : "Collapse dashboard panel", B = ((d == null ? void 0 : d.name) ?? "").trim(), M = ((d == null ? void 0 : d.email) ?? "").trim(), E = B && B.toLowerCase() !== "undefined" ? B : M || "Current user", te = ((Y = E.charAt(0)) == null ? void 0 : Y.toUpperCase()) || "?", Q = M && M.toLowerCase() !== "undefined" ? M : "", H = St(g, {
796
+ ), v = r === "overlay", z = c ? "New Visual" : "New", f = c ? "New Visual" : "New Dashboard", $ = c ? "Search visuals..." : "Search dashboards...", q = c ? "Collapse visuals panel" : "Collapse dashboard panel", B = ((d == null ? void 0 : d.name) ?? "").trim(), I = ((d == null ? void 0 : d.email) ?? "").trim(), E = B && B.toLowerCase() !== "undefined" ? B : I || "Current user", te = ((Y = E.charAt(0)) == null ? void 0 : Y.toUpperCase()) || "?", J = I && I.toLowerCase() !== "undefined" ? I : "", H = St(g, {
797
797
  enabled: t && v
798
798
  }), _ = re(
799
799
  "flex h-full flex-col border-r bg-background",
@@ -802,10 +802,10 @@ function Ft({
802
802
  t ? "translate-x-0" : "pointer-events-none -translate-x-full"
803
803
  ) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",
804
804
  p
805
- ), Z = (C) => {
805
+ ), Q = (C) => {
806
806
  }, K = (C) => {
807
807
  console.log("Editing dashboard:", C);
808
- }, $ = (C) => {
808
+ }, X = (C) => {
809
809
  S(C, {
810
810
  onSuccess: (a) => {
811
811
  i(!1), x(a, j);
@@ -849,7 +849,7 @@ function Ft({
849
849
  variant: "secondary",
850
850
  className: "h-7 w-7 p-0.5",
851
851
  onClick: g,
852
- "aria-label": G,
852
+ "aria-label": q,
853
853
  children: /* @__PURE__ */ e(pt, { className: "h-3.5 w-3.5" })
854
854
  }
855
855
  )
@@ -858,7 +858,7 @@ function Ft({
858
858
  u && /* @__PURE__ */ e("div", { className: "bg-muted/30 px-4 pb-3", children: /* @__PURE__ */ e(
859
859
  fe,
860
860
  {
861
- placeholder: J,
861
+ placeholder: $,
862
862
  value: w,
863
863
  onChange: (C) => b(C.target.value),
864
864
  className: "h-8 border-muted-foreground/20 bg-background text-sm focus-visible:border-muted-foreground/40 focus-visible:ring-0 focus-visible:ring-offset-0",
@@ -870,7 +870,7 @@ function Ft({
870
870
  Tt,
871
871
  {
872
872
  searchQuery: w,
873
- onLoadDashboard: Z,
873
+ onLoadDashboard: Q,
874
874
  onEditDashboard: K,
875
875
  onDashboardItemClick: o
876
876
  }
@@ -880,7 +880,7 @@ function Ft({
880
880
  /* @__PURE__ */ e(Dt, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex h-6 w-6 cursor-default items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ e("span", { className: "text-xs font-medium text-primary", children: te }) }) }),
881
881
  /* @__PURE__ */ e(xt, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ n("div", { className: "space-y-1", children: [
882
882
  /* @__PURE__ */ e("div", { className: "font-medium", children: E }),
883
- Q && /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground", children: Q }),
883
+ J && /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground", children: J }),
884
884
  d.role && /* @__PURE__ */ n("div", { className: "text-xs text-muted-foreground", children: [
885
885
  "Role: ",
886
886
  Nt(d.role.replace(/_/g, " "))
@@ -895,19 +895,19 @@ function Ft({
895
895
  open: D,
896
896
  onOpenChange: i,
897
897
  onSubmit: T,
898
- isCreating: I
898
+ isCreating: F
899
899
  }
900
900
  ) : /* @__PURE__ */ e(
901
901
  wt,
902
902
  {
903
903
  open: D,
904
904
  onOpenChange: i,
905
- onSubmit: $,
906
- isCreating: F
905
+ onSubmit: X,
906
+ isCreating: M
907
907
  }
908
908
  )
909
909
  ] }) });
910
910
  }
911
911
  export {
912
- Ft as ResourceManagementPanel
912
+ Mt as ResourceManagementPanel
913
913
  };
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-CXKjmjfB.js"),c=require("react"),le=require("./use-visual-utils-B82Q-Ytl.js"),he=require("./use-role-aware-display-preferences-l7NFLYnn.js");/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-BfiIPyeS.js"),c=require("react"),le=require("./use-visual-utils-B11AA2fd.js"),he=require("./use-role-aware-display-preferences-BlR29aKQ.js");/**
2
2
  * @license lucide-react v0.453.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -1 +1 @@
1
- "use strict";const a=require("./index-CXKjmjfB.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-BfiIPyeS.js"),n=require("react");function f(){const{displayPreferences:c,shouldShowElement:o}=a.useDisplayPreferences(),{currentUser:e,userContext:s}=a.useCurrentUserInfo(),i=n.useMemo(()=>a.getRoleBasedDisplayOverrides(e),[e]),t=n.useMemo(()=>r=>i&&i[r]!==void 0&&i[r]===!1?!1:o(r),[i,o,c]),p=n.useMemo(()=>{var r,d,l,u,h;return{canEdit:((r=s==null?void 0:s.permissions)==null?void 0:r.canEdit)??a.canUserEdit(e),canUseFilters:((d=s==null?void 0:s.permissions)==null?void 0:d.canEdit)??a.canUserUseFilters(e),canManageDashboards:((l=s==null?void 0:s.permissions)==null?void 0:l.canCreateDashboard)??a.canUserManageDashboards(e),canCreateDashboards:((u=s==null?void 0:s.permissions)==null?void 0:u.canCreateDashboard)??a.canUserCreateDashboards(e),canAccessVisuals:((h=s==null?void 0:s.permissions)==null?void 0:h.canEdit)??a.canUserAccessVisuals(e)}},[e,s]);return{displayPreferences:c,shouldShowElement:t,permissions:p,currentUser:e}}exports.useRoleAwareDisplayPreferences=f;
@@ -1,4 +1,4 @@
1
- import { b as m, e as t, g as D, f as U, h as b, i as u, j as E, k as g } from "./index-CAVrkf9d.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-BDS2sWhv.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-CXKjmjfB.js"),g=require("react");function H(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),o=e.substring(n);return`${d} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),o=e.substring(t);return`${d} {{ filters | where }} ${o}`}else{const d=e.substring(0,c),o=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",o),o?`${d} {{ filters | where }} ${o}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function k(e){const[n,t]=g.useState(null),[r,s]=g.useState(null),c=a.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function Q(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],o=e.find(l=>l.tabTitle===d);return o?o.id:e[0].id}return n}}return e[0].id}const z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function W(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=a.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(s,l),a.ue.dismiss(d),{data:l,fromCache:!1}}catch(o){throw a.ue.dismiss(d),o}}function L(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function G(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=L(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(o=>o.id===r.activeCardId);return s?(a.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function Y(){var C;const{setCardSql:e}=a.useEditorActions(),n=a.useEditorStore(i=>i.frame),t=a.useEditorStore(i=>i.card),r=a.useEditorStore(i=>i.isDevMode),s=k(((C=t.customCardPreferences)==null?void 0:C.url)||""),c=a.useEditorStore(i=>i.selectedSchemaName),d=a.useEditorStore(i=>i.selectedDatamodelId),o=a.useEditorStore(i=>i.selectedDatabaseName),l=a.useEditorStore(i=>i.selectedTableName),h=a.useEditorStore(i=>i.selectedConnectionId),m=a.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let i=p;p&&!p.includes("{{")&&(i=H(p),e(i));const E=(I=s==null?void 0:s.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:z(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...E&&{customCardPreferences:{...t.customCardPreferences,settings:E}}},w=n.cards.map(S=>S.id===t.id?v:S);return{...n,cards:w,activeCardId:Q(w,n.activeCardId)}},[t,n,r,m,c,d,o,l,h,e,s,p])}}function J(){const{authToken:e,tokenProps:n}=a.useSemaphorContext(),t=a.useQueryClient(),r=a.useSelectedVisual(),{selectVisual:s}=a.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:E,setSelectedDatamodelId:v,setFilterValues:w,setApplyFilters:I}=a.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:V,setSelectedFrameId:$,clearSelectedFrameId:A,addFrame:R,setIsDashboardPanelOpen:N}=a.useDashboardActions(),y=a.useDashboardStore(u=>u.selectedSheetId),O=a.useDashboardStore(u=>u.selectedFrameId),T=a.useDashboardStore(u=>u.dashboard),x=a.useDashboardStore(u=>u.filterValues),F=a.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),j=g.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await W(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!G(b,{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:E,setSelectedDatamodelId:v,setFilterValues:w,setApplyFilters:I,setIsDashboardEditing:S,setIsVisualEditing:V,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,S,V,o,l,h,m,p,D,C,i,E,v,w,I,A,T,y,O,x]),_=g.useCallback(async u=>{var b;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:B}=await W(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),M=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!M)return{success:!1,error:"Visual has no frame data"};const U=L(M);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...a.cloneLinkedFrameWithSourceMapping(U),visualId:u.id};return R(y,P,"end"),S(!0),$(P.id),N(!1),{success:!0,fromCache:B}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,R,S,$,N]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:j,handleAddLibraryVisual:_,getUpdatedFrame:Y().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=k;exports.useVisualUtils=J;
1
+ "use strict";const a=require("./index-BfiIPyeS.js"),g=require("react");function H(e){const n=e.toUpperCase().indexOf("WHERE"),t=e.toUpperCase().indexOf("GROUP BY"),r=e.toUpperCase().indexOf("LIMIT"),s=e.toUpperCase().indexOf("ORDER BY");let c=e.length;if(s!==-1&&(c=s),r!==-1&&r<c&&(c=r),n!==-1){const d=e.substring(0,n),o=e.substring(n);return`${d} {{ filters | where }} AND ${o.substring(6)}`}else if(t!==-1){const d=e.substring(0,t),o=e.substring(t);return`${d} {{ filters | where }} ${o}`}else{const d=e.substring(0,c),o=e.substring(c);return console.log("beforeClause",d),console.log("afterClause",o),o?`${d} {{ filters | where }} ${o}`:`${d.replace(/;$/,"")} {{ filters | where }}`}}function k(e){const[n,t]=g.useState(null),[r,s]=g.useState(null),c=a.useEnsureReactGlobals();return g.useEffect(()=>{if(!e||e.trim()===""){t(null),s(null);return}if(!c)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const l=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(l,{method:"HEAD"})).ok)throw new Error(`Module not found at ${l}`)}catch{}const h=await import(l);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");t(()=>h.useChartStore),s(null)}catch(o){const l=o instanceof Error?o.message:"Unknown error";console.error("Failed to load remote chart store:",l),s(l),t(null)}})()},[e,c]),n}function Q(e,n){if(e.length===0)return"";const t=e.find(r=>{var s,c;return((s=r.customCardPreferences)==null?void 0:s.visualType)==="multiple"||!!((c=r.customCardPreferences)!=null&&c.dataInputCardIds)});if(t)return t.id;if(n){const r=e.find(s=>s.id===n);if(r){const s=r.tabTitle;if(s=="All__Header")return e[0].id;if(s&&s.endsWith("__Header")){const d=s.split("__")[0],o=e.find(l=>l.tabTitle===d);return o?o.id:e[0].id}return n}}return e[0].id}const z=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:n,...t}=e;return t};async function W(e,n,t,r){if(!n||!t)throw new Error("Missing auth token or visual ID");const s=["resource-by-id","visual",t],c=r.getQueryData(s);if(c)return console.log("Using cached visual data for:",t),{data:c,fromCache:!0};console.log("Fetching visual data from network for:",t);const d=a.ue.loading("Loading visual...",{position:"top-center"});try{const o=await fetch(`${e}/management/v1/visuals/${t}`,{headers:{Authorization:`Bearer ${n}`}});if(!o.ok)throw new Error("Failed to load visual");const l=await o.json();return r.setQueryData(s,l),a.ue.dismiss(d),{data:l,fromCache:!1}}catch(o){throw a.ue.dismiss(d),o}}function L(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function G(e,n){var c,d;const t=(e==null?void 0:e.frameObject)??((c=e==null?void 0:e.visual)==null?void 0:c.frameObject);if(!t)return!1;const r=L(t);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const s=(d=r.cards)==null?void 0:d.find(o=>o.id===r.activeCardId);return s?(a.setupEditorWithCard({...n,frame:r,card:s,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function Y(){var C;const{setCardSql:e}=a.useEditorActions(),n=a.useEditorStore(i=>i.frame),t=a.useEditorStore(i=>i.card),r=a.useEditorStore(i=>i.isDevMode),s=k(((C=t.customCardPreferences)==null?void 0:C.url)||""),c=a.useEditorStore(i=>i.selectedSchemaName),d=a.useEditorStore(i=>i.selectedDatamodelId),o=a.useEditorStore(i=>i.selectedDatabaseName),l=a.useEditorStore(i=>i.selectedTableName),h=a.useEditorStore(i=>i.selectedConnectionId),m=a.useEditorStore(i=>i.isShowingVisual),p=t.sql;return{getUpdatedFrame:g.useCallback(()=>{var I;let i=p;p&&!p.includes("{{")&&(i=H(p),e(i));const E=(I=s==null?void 0:s.getState())==null?void 0:I.settings,v={...t,dataSource:t.dataSource||{mode:"directSource"},lastSelectedSchema:c,lastSelectedDatamodelId:d,lastSelectedDatabase:o,lastSelectedTable:l,connectionId:h,sql:r?i:void 0,python:r?t.python:void 0,config:r?void 0:z(t.config),customCfg:m?t.customCfg:null,preferences:t.preferences,...E&&{customCardPreferences:{...t.customCardPreferences,settings:E}}},w=n.cards.map(S=>S.id===t.id?v:S);return{...n,cards:w,activeCardId:Q(w,n.activeCardId)}},[t,n,r,m,c,d,o,l,h,e,s,p])}}function J(){const{authToken:e,tokenProps:n}=a.useSemaphorContext(),t=a.useQueryClient(),r=a.useSelectedVisual(),{selectVisual:s}=a.useManagementActions(),{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:E,setSelectedDatamodelId:v,setFilterValues:w,setApplyFilters:I}=a.useEditorActions(),{setIsDashboardEditing:S,setIsVisualEditing:V,setSelectedFrameId:$,clearSelectedFrameId:A,addFrame:R,setIsDashboardPanelOpen:N}=a.useDashboardActions(),y=a.useDashboardStore(u=>u.selectedSheetId),O=a.useDashboardStore(u=>u.selectedFrameId),T=a.useDashboardStore(u=>u.dashboard),x=a.useDashboardStore(u=>u.filterValues),F=a.useVisualById((r==null?void 0:r.id)||"",{enabled:!!(r!=null&&r.id)&&!!(e!=null&&e.accessToken)}),j=g.useCallback(async u=>{try{s(u),A();const{data:b,fromCache:f}=await W(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t);if(!G(b,{setFrame:c,setCard:d,setIsDevMode:o,initializeModeDrafts:l,setActiveTabCardId:h,updateDataSource:m,setQueryResultColumns:p,setSelectedConnectionId:D,setSelectedDatabaseName:C,setSelectedSchemaName:i,setSelectedTableName:E,setSelectedDatamodelId:v,setFilterValues:w,setApplyFilters:I,setIsDashboardEditing:S,setIsVisualEditing:V,dashboard:T,selectedSheetId:y,selectedFrameId:O,filterValues:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:f}}catch(b){return console.error("Error editing visual:",b),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,c,d,S,V,o,l,h,m,p,D,C,i,E,v,w,I,A,T,y,O,x]),_=g.useCallback(async u=>{var b;try{if(s(u),!y)return{success:!1,error:"No sheet selected. Please select a sheet first."};const{data:f,fromCache:B}=await W(n.apiServiceUrl,(e==null?void 0:e.accessToken)||"",u.id,t),M=(f==null?void 0:f.frameObject)??((b=f==null?void 0:f.visual)==null?void 0:b.frameObject);if(!M)return{success:!1,error:"Visual has no frame data"};const U=L(M);if(!(U!=null&&U.cards)||U.cards.length===0)return{success:!1,error:"Visual frame is malformed"};const P={...a.cloneLinkedFrameWithSourceMapping(U),visualId:u.id};return R(y,P,"end"),S(!0),$(P.id),N(!1),{success:!0,fromCache:B}}catch(f){return console.error("Error adding visual:",f),{success:!1,error:"Failed to add visual to dashboard"}}},[e==null?void 0:e.accessToken,n.apiServiceUrl,t,s,y,R,S,$,N]);return{visual:F.data,isLoading:F.isLoading,isError:F.isError,error:F.error,handleEditLibraryVisual:j,handleAddLibraryVisual:_,getUpdatedFrame:Y().getUpdatedFrame,refetch:F.refetch}}exports.useRemoteChartStore=k;exports.useVisualUtils=J;