react-semaphor 0.1.307 → 0.1.309

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 (43) hide show
  1. package/dist/brand-studio/index.cjs +1 -1
  2. package/dist/brand-studio/index.js +4 -4
  3. package/dist/chunks/{braces-CkL8POe0.js → braces-BHDm9arh.js} +1 -1
  4. package/dist/chunks/{braces-e5qkN-I_.js → braces-DEq8EJtw.js} +1 -1
  5. package/dist/chunks/chevrons-up-down-Cbtggnqv.js +14 -0
  6. package/dist/chunks/chevrons-up-down-DDEY9beZ.js +6 -0
  7. package/dist/chunks/{dashboard-controls-Dwet_9h0.js → dashboard-controls-C_vjMmt2.js} +8 -3
  8. package/dist/chunks/{dashboard-controls-5bibC_5a.js → dashboard-controls-Cp41403T.js} +233 -223
  9. package/dist/chunks/{dashboard-filter-controls-button-D0k9NDci.js → dashboard-filter-controls-button-DFKZjkD4.js} +304 -303
  10. package/dist/chunks/dashboard-filter-controls-button-tfjDO4D4.js +11 -0
  11. package/dist/chunks/{dashboard-json-CfRKLL7C.js → dashboard-json-Cc8S_uIr.js} +2 -2
  12. package/dist/chunks/{dashboard-json-Bi5XdgG5.js → dashboard-json-QR7WNDuO.js} +1 -1
  13. package/dist/chunks/dashboard-summary-settings-dialog-CxXxzyRP.js +1 -0
  14. package/dist/chunks/{dashboard-summary-settings-dialog-Bj4_wBW9.js → dashboard-summary-settings-dialog-qH6FOt7O.js} +33 -32
  15. package/dist/chunks/{edit-dashboard-visual-Wfs53Kbn.js → edit-dashboard-visual-J7cHkCD6.js} +32 -32
  16. package/dist/chunks/{edit-dashboard-visual-DIuzuJfj.js → edit-dashboard-visual-_BZQa5yI.js} +130 -129
  17. package/dist/chunks/index-AerZtbg0.js +1330 -0
  18. package/dist/chunks/{index-DMFCfjgD.js → index-CSgoL0P9.js} +59994 -61918
  19. package/dist/chunks/{palette-Oa4O9jWG.js → palette-CNKSAIrt.js} +1 -1
  20. package/dist/chunks/{palette-D5Lorzf2.js → palette-CteErylX.js} +1 -1
  21. package/dist/chunks/{resource-management-panel-Dqc3gfYn.js → resource-management-panel-CcFT7lpL.js} +52 -52
  22. package/dist/chunks/resource-management-panel-DbYkAk1I.js +6 -0
  23. package/dist/chunks/{save-CDX2p4v1.js → save-B1-nDZwS.js} +1 -1
  24. package/dist/chunks/{save-zEdICevW.js → save-BVVnWGeb.js} +1 -1
  25. package/dist/chunks/{switch-BPFzGTzF.js → switch-BG4RWnrq.js} +25 -25
  26. package/dist/chunks/{switch-CKiXRRoh.js → switch-BZn7R_Cp.js} +696 -697
  27. package/dist/chunks/{use-create-flow-overlay-state-CLyv5c2m.js → use-create-flow-overlay-state-CczjbVZY.js} +49 -49
  28. package/dist/chunks/{use-create-flow-overlay-state-CSMe5Ls6.js → use-create-flow-overlay-state-DImkf832.js} +1 -1
  29. package/dist/chunks/{use-visual-utils-DDAs4dCz.js → use-visual-utils-BdHwrbtr.js} +1 -1
  30. package/dist/chunks/{use-visual-utils-Det6M3Wd.js → use-visual-utils-DczvWVbd.js} +2 -2
  31. package/dist/dashboard/index.cjs +1 -1
  32. package/dist/dashboard/index.js +1 -1
  33. package/dist/index.cjs +1 -1
  34. package/dist/index.js +76 -76
  35. package/dist/style.css +1 -1
  36. package/dist/surfboard/index.cjs +1 -1
  37. package/dist/surfboard/index.js +2 -2
  38. package/dist/types/main.d.ts +10 -2
  39. package/package.json +1 -1
  40. package/dist/chunks/dashboard-filter-controls-button-ZeYO5jux.js +0 -11
  41. package/dist/chunks/dashboard-summary-settings-dialog-DD9Aj2XH.js +0 -1
  42. package/dist/chunks/index-DQCMUspd.js +0 -1350
  43. package/dist/chunks/resource-management-panel-CNr6uMMf.js +0 -6
@@ -0,0 +1,11 @@
1
+ "use strict";const e=require("react/jsx-runtime"),r=require("./switch-BG4RWnrq.js"),t=require("./index-AerZtbg0.js"),F=require("./use-create-flow-overlay-state-DImkf832.js"),g=require("react"),R=require("./use-visual-utils-BdHwrbtr.js"),U=require("./date-formatter-D9Bvw5Qk.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 V=r.createLucideIcon("FileDown",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"m9 15 3 3 3-3",key:"1npd3o"}]]);/**
7
+ * @license lucide-react v0.453.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const $=r.createLucideIcon("FilterX",[["path",{d:"M13.013 3H2l8 9.46V19l4 2v-8.54l.9-1.055",key:"1fi1da"}],["path",{d:"m22 3-5 5",key:"12jva0"}],["path",{d:"m17 3 5 5",key:"k36vhe"}]]);function _({open:s,onOpenChange:a,isLibraryVisual:v,currentVisualName:d,isSaving:i=!1,destinationMode:c="both",onConfirm:u}){const[m,l]=g.useState(v&&d?`Copy of ${d}`:d||""),[o,p]=g.useState("");g.useEffect(()=>{s&&(l(v&&d?`Copy of ${d}`:d||""),p(""))},[s,v,d]);const C=!!m.trim(),x=c==="local"?{saveToLibrary:!1,saveToCurrentDashboard:!0,badgeType:"local",description:"Creates a local copy on the current dashboard.",actionLabel:"Add to Dashboard (Local)"}:c==="library"?{saveToLibrary:!0,saveToCurrentDashboard:!1,badgeType:"library",description:"Creates a reusable visual in Visual Library.",actionLabel:"Save as Library Visual"}:{saveToLibrary:!0,saveToCurrentDashboard:!0,badgeType:"linked",description:"Creates a new library visual and adds a linked copy to this dashboard.",actionLabel:"Save Copy as Linked Visual"},y=()=>{!C||i||u({name:m.trim(),description:o.trim()||void 0,saveToLibrary:x.saveToLibrary,saveToCurrentDashboard:x.saveToCurrentDashboard})};return e.jsx(t.Dialog,{open:s,onOpenChange:a,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"}),x.badgeType!=="local"&&e.jsx(F.VisualBadge,{type:x.badgeType,showLabel:!0,className:"px-2 py-0.5"})]}),e.jsx(t.DialogDescription,{children:x.description})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(r.Label,{htmlFor:"name",children:"Name"}),e.jsx(r.Input,{id:"name",value:m,onChange:N=>l(N.target.value),placeholder:"Enter visual name",disabled:i})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(r.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Textarea,{id:"description",value:o,onChange:N=>p(N.target.value),placeholder:"Enter visual description",rows:3,disabled:i})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(r.Button,{variant:"outline",onClick:()=>a(!1),disabled:i,children:"Cancel"}),e.jsxs(r.Button,{onClick:y,disabled:!C||i,children:[i&&e.jsx(r.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),x.actionLabel]})]})]})})}function q(){const[s,a]=g.useState(!1),[v,d]=g.useState(!1),[i,c]=g.useState(null),[u,m]=g.useState(null),l=r.useEditorStore(h=>h.frame),o=r.useEditorStore(h=>h.card),p=t.useSelectedVisual(),C=r.useDashboardStore(h=>h.selectedSheetId),x=r.useDashboardStore(h=>h.dashboard),y=r.useDashboardStore(h=>h.actions.setIsDashboardPanelOpen),{getUpdatedFrame:N}=R.useVisualUtils(),{selectVisual:f}=t.useManagementActions(),{addFrame:j,setSelectedFrameId:A,setIsVisualEditing:D}=r.useDashboardActions(),n=t.useResolveExistingFrameSemanticExecutionPayload(),w=!!(l!=null&&l.visualId),E=(()=>{var h,b;return((h=l==null?void 0:l.cards)==null?void 0:h.length)===1&&((b=l.cards[0])!=null&&b.title)?l.cards[0].title:p!=null&&p.title?p.title:(o==null?void 0:o.title)||"Untitled Visual"})(),L=t.useCreateVisualWithFrame(h=>{h!=null&&h.id&&(f(h),v&&i&&u&&C&&(async()=>{try{const b={...i,id:r.v4(),visualId:h.id};j(C,b,{position:"end",semanticExecutionPayload:u}),A(b.id),d(!1),c(null),m(null),D(!1)}catch(b){console.error("Failed to promote semantic metadata for saved visual:",b),t.ue.error(b instanceof Error?b.message:"Failed to prepare semantic metadata for the saved visual")}})(),y(!0),a(!1))});return{saveAsDialogOpen:s,setSaveAsDialogOpen:a,handleSaveAs:async h=>{if(!C){t.ue.error("No sheet selected");return}const b=N(),I=r.getDynamicFrameSaveIssue(b);if(I){t.ue.error(I);return}const P=b.cards.length===1?{...b,cards:b.cards.map(T=>({...T,title:h.name}))}:b;if(h.saveToLibrary){let T=null;if(h.saveToCurrentDashboard)try{T=await n(P,{previousFrame:t.findDashboardFrameById(x,P.id)})}catch(M){console.error("Failed to prepare semantic metadata before saving visual:",M),t.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for the saved visual");return}d(h.saveToCurrentDashboard),c(P),m(T);const B={title:h.name,description:h.description,frameObject:P,isPrivate:!1};L.mutate(B)}else if(h.saveToCurrentDashboard){const T={...P,id:r.v4(),visualId:void 0};try{const B=await n(P,{previousFrame:t.findDashboardFrameById(x,P.id)});j(C,T,{position:"end",semanticExecutionPayload:B}),A(T.id),t.ue.success("Visual saved to dashboard"),a(!1),D(!1)}catch(B){console.error("Failed to save visual to dashboard:",B),t.ue.error(B instanceof Error?B.message:"Failed to prepare semantic metadata for the visual")}}},isLibraryVisual:w,currentVisualName:E,isSaving:L.isPending}}function X(s={}){const a=r.useEditorStore(S=>S.frame),v=r.useEditorStore(S=>S.editorContext),d=t.useManagementStore(S=>S.selectedVisual),i=r.useDashboardStore(S=>S.selectedFrameId),c=r.useDashboardStore(S=>S.selectedSheetId),u=r.useDashboardStore(S=>S.dashboard),{setIsVisualEditing:m,updateFrame:l}=r.useDashboardActions(),[o,p]=g.useState(!1),[C,x]=g.useState("both"),y=t.useResolveExistingFrameSemanticExecutionPayload(),N=(v==null?void 0:v.type)==="documentSection",f=!!(a!=null&&a.visualId||d!=null&&d.id),j=!!(a!=null&&a.visualId&&i),A=f&&!j,{saveAsDialogOpen:D,setSaveAsDialogOpen:n,handleSaveAs:w,isLibraryVisual:E,currentVisualName:L,isSaving:k}=q(),{getUpdatedFrame:h}=R.useVisualUtils();if(N)return e.jsxs(e.Fragment,{children:[e.jsx(F.EditorAcceptButton,{className:"rounded-control",variant:"default"}),e.jsx(F.EditorCancelButton,{})]});const b=async()=>{if(!c){t.ue.error("No sheet selected");return}if(o)return;p(!0);const S=h(),P=r.getDynamicFrameSaveIssue(S);if(P){p(!1),t.ue.error(P);return}const T={...S,visualId:void 0},B=t.findDashboardFrameById(u,T.id);try{const M=await y(T,{previousFrame:B});l(c,T,{semanticExecutionPayload:M})}catch(M){console.error("Failed to apply local semantic metadata:",M),p(!1),t.ue.error(M instanceof Error?M.message:"Failed to prepare semantic metadata for this visual");return}setTimeout(()=>{p(!1),t.ue.success("Changes applied. Visual is now local to this dashboard"),m(!1)},300)},I=S=>{x(S),n(!0)};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"inline-flex items-center overflow-hidden rounded-control",children:[!f&&e.jsx(F.EditorAcceptButton,{className:"!rounded-none",variant:"default"}),f&&A&&e.jsx(F.VisualSaveButton,{className:"!rounded-none",variant:"default"}),f&&j&&e.jsx(F.VisualSaveAndApplyButton,{className:"!rounded-none"}),e.jsxs(t.DropdownMenu,{modal:!1,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(r.Button,{variant:"default",size:"xs",className:"w-7 !rounded-none border-l border-primary-foreground/20 px-0","aria-label":"Open visual save options",disabled:k||o,children:e.jsx(r.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",children:[j&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:b,disabled:o,children:[e.jsx(r.Check,{className:"h-3.5 w-3.5"}),o?"Applying...":"Apply Locally"]}),e.jsx(t.DropdownMenuSeparator,{})]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("local"),disabled:k,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add to Dashboard (Local)"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("library"),disabled:k,children:[e.jsx(F.Library,{className:"h-3.5 w-3.5"}),"Save as Library Visual"]}),e.jsxs(t.DropdownMenuItem,{onClick:()=>I("both"),disabled:k,children:[e.jsx(F.Link2,{className:"h-3.5 w-3.5"}),"Save Copy as Linked Visual"]})]})]})]}),e.jsx(F.EditorCancelButton,{}),e.jsx(_,{open:D,onOpenChange:S=>{k||n(S)},isLibraryVisual:E,currentVisualName:L,isSaving:k,destinationMode:C,onConfirm:w})]})}function G({className:s}){const a=r.useEditorStore(o=>o.isDevMode),v=r.useDashboardStore(o=>o.isVisualEditing),{setIsDevMode:d}=r.useEditorActions(),{config:i}=g.useContext(t.SemaphorContext).tokenProps,c=(i==null?void 0:i.showAdvancedMode)!==!1;if(!v||!c)return null;const u=a?r.SlidersHorizontal:t.CodeXml,m=a?"Drag & drop":"SQL",l=a?"Switch to drag-and-drop mode":"Switch to SQL mode";return e.jsxs("button",{type:"button","aria-label":l,title:l,onClick:()=>d(!a),className:r.cn("inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",s),children:[e.jsx(u,{className:"h-3 w-3 text-muted-foreground"}),m]})}function Q({open:s,onOpenChange:a,onSave:v,onDiscard:d,isSaving:i,title:c="Unsaved changes",description:u="You have unsaved changes to this dashboard. What would you like to do?",cancelLabel:m="Cancel",discardLabel:l="Discard",saveLabel:o="Save"}){const p=C=>{!C&&i||a(C)};return e.jsx(t.AlertDialog,{open:s,onOpenChange:p,children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:c}),e.jsx(t.AlertDialogDescription,{children:u})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(r.Button,{type:"button",size:"xs",onClick:d,disabled:i,variant:"ghost",className:"mr-auto text-muted-foreground hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",children:l}),e.jsx(t.AlertDialogCancel,{disabled:i,children:m}),e.jsx(r.Button,{type:"button",size:"xs",onClick:v,disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(r.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}),"Saving..."]}):o})]})]})})}const K=1e4,W=15e3,Y=3e4,Z=3e4,J=12e4,O=2*60*60*1e3;function ee(s){const a=Date.now()-s.getTime();return a<Z?K:a<J?W:Y}function te(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(x=>x.activeExports),[d,i]=g.useState(typeof document<"u"?!document.hidden:!0),c=g.useRef(null),u=g.useRef(!1),m=g.useRef(void 0),l=a==null?void 0:a.apiServiceUrl,o=s==null?void 0:s.accessToken,p=g.useCallback(()=>{const x=t.useExportStore.getState().activeExports;return Array.from(x.values()).filter(y=>t.isExportInProgress(y.status))},[]);g.useEffect(()=>{if(typeof document>"u")return;const x=()=>{i(!document.hidden)};return document.addEventListener("visibilitychange",x),()=>{document.removeEventListener("visibilitychange",x)}},[]);const C=g.useCallback(async()=>{if(!l||!o){u.current=!1;return}const x=p();if(x.length===0){u.current=!1;return}const y=Date.now(),N=x.filter(n=>y-n.startedAt.getTime()>O);if(N.length>0){const{updateExport:n}=t.useExportStore.getState().actions;for(const w of N)n(w.id,{status:"failed",error:"Export timed out. Please try again or contact support.",lastUpdatedAt:new Date})}const f=x.filter(n=>y-n.startedAt.getTime()<=O);if(f.length===0){u.current=!1;return}const j=await Promise.allSettled(f.map(async n=>{try{const w=await t.getExportStatus(l,o,n.id);let E;if(w.status==="completed")try{E=await t.getDownloadUrl(l,o,n.id)}catch(L){console.error(`[useExportPolling] Failed to get download URL for ${n.id}:`,L)}return{id:n.id,status:w.status,progress:w.progress,completedChunks:w.completedChunks,completedAt:w.completedAt?new Date(w.completedAt):void 0,lastUpdatedAt:new Date,fileSize:w.fileSize,error:w.error,downloadUrl:E}}catch(w){return console.error(`[useExportPolling] Failed to poll export ${n.id}:`,w),null}})),{updateExport:A}=t.useExportStore.getState().actions;for(const n of j)n.status==="fulfilled"&&n.value&&A(n.value.id,n.value);const D=p();if(D.length>0&&!document.hidden){const n=D.reduce((E,L)=>L.startedAt<E?L.startedAt:E,D[0].startedAt),w=ee(n);c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{var E;(E=m.current)==null||E.call(m)},w)}else u.current=!1},[l,o,p]);return g.useEffect(()=>{m.current=C},[C]),g.useEffect(()=>{var y;p().length>0&&d&&!u.current&&(u.current=!0,(y=m.current)==null||y.call(m))},[v,d,p]),g.useEffect(()=>{var y;const x=p();d&&x.length>0&&!u.current&&(u.current=!0,(y=m.current)==null||y.call(m))},[d,p]),g.useEffect(()=>{!d&&c.current&&(clearTimeout(c.current),c.current=null,u.current=!1)},[d]),g.useEffect(()=>()=>{c.current&&(clearTimeout(c.current),c.current=null)},[]),{isPolling:u.current,isTabVisible:d,inProgressCount:p().length}}function se(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(m=>m.activeExports),{addExport:d}=t.useExportActions(),i=g.useRef(!1),c=a==null?void 0:a.apiServiceUrl,u=s==null?void 0:s.accessToken;g.useEffect(()=>{if(i.current||!c||!u)return;(async()=>{try{const{exports:l}=await t.getExports(c,u,{status:["pending","processing","chunking","compacting","completed","failed"],limit:20});for(const o of l){if(v.has(o.id))continue;const p=o.totalChunks?Math.round(o.completedChunks/o.totalChunks*100):0;let C;if(o.status==="completed")try{C=await t.getDownloadUrl(c,u,o.id)}catch(y){console.error(`[useExportRecovery] Failed to get download URL for ${o.id}:`,y)}const x={id:o.id,status:o.status,progress:p,title:re(o),totalRows:o.totalRows,totalChunks:o.totalChunks,completedChunks:o.completedChunks,startedAt:new Date(o.createdAt),lastUpdatedAt:new Date,completedAt:o.completedAt?new Date(o.completedAt):void 0,fileSize:o.fileSize,error:o.error,expiresAt:new Date(o.expiresAt),downloadUrl:C};d(x)}i.current=!0}catch(l){console.error("[useExportRecovery] Failed to recover exports:",l),i.current=!0}})()},[c,u,d,v])}function re(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 z({export:s,onRemove:a}){const v=()=>{s.downloadUrl&&window.open(s.downloadUrl,"_blank")},d=m=>{m.stopPropagation(),a==null||a(s.id)},i=()=>{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(F.CircleX,{className:"mt-0.5 h-5 w-5 shrink-0 text-destructive"});default:return e.jsx(r.LoaderCircle,{className:"text-foreground-muted mt-0.5 h-5 w-5 shrink-0 animate-spin"})}},c=t.isExportInProgress(s.status),u=(()=>{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:[i(),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)})]})]}),c&&e.jsx("div",{className:"text-xs text-muted-foreground",children:u}),s.status==="failed"&&e.jsx("div",{className:"line-clamp-2 text-xs text-destructive",children:s.error||"Export failed"})]})]}),e.jsx(r.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",onClick:d,"aria-label":"Remove notification",children:e.jsx(r.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:U.formatDistanceToNow(s.startedAt,{addSuffix:!0})}),s.downloadUrl&&e.jsxs(r.Button,{size:"sm",variant:"outline",className:"h-8 bg-transparent",onClick:v,children:[e.jsx(t.Download,{className:"mr-1.5 h-3.5 w-3.5"}),"Download"]})]}),c&&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:U.formatDistanceToNow(s.startedAt,{addSuffix:!0})})]})]})}function H(){const{authToken:s,tokenProps:a}=t.useSemaphorContext(),v=t.useExportStore(f=>f.activeExports),{clearCompleted:d,removeExport:i,updateExport:c}=t.useExportActions(),[u,m]=g.useState(!1),[l,o]=g.useState(!1),p=Array.from(v.values()).sort((f,j)=>j.startedAt.getTime()-f.startedAt.getTime()),C=p.some(f=>f.status==="completed"||f.status==="failed"),x=g.useCallback(async()=>{const f=a==null?void 0:a.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!(!f||!j)){m(!0);try{const A=Array.from(v.values());await Promise.all(A.map(async D=>{try{const n=await t.getExportStatus(f,j,D.id);let w;if(n.status==="completed")try{w=await t.getDownloadUrl(f,j,D.id)}catch(E){console.error(`Failed to get download URL for ${D.id}:`,E)}c(D.id,{status:n.status,progress:n.progress,completedChunks:n.completedChunks,completedAt:n.completedAt?new Date(n.completedAt):void 0,lastUpdatedAt:new Date,fileSize:n.fileSize,error:n.error,downloadUrl:w})}catch(n){console.error(`Failed to refresh export ${D.id}:`,n)}}))}finally{m(!1)}}},[v,s==null?void 0:s.accessToken,a==null?void 0:a.apiServiceUrl,c]),y=g.useCallback(async()=>{const f=a==null?void 0:a.apiServiceUrl,j=s==null?void 0:s.accessToken;if(!f||!j){d();return}o(!0);try{const A=p.filter(n=>n.status==="completed"||n.status==="failed"),D=await Promise.allSettled(A.map(async n=>(await t.cancelExport(f,j,n.id),n.id)));for(const n of D)n.status==="fulfilled"?i(n.value):console.error("Failed to delete export:",n.reason)}finally{o(!1)}},[p,a==null?void 0:a.apiServiceUrl,s==null?void 0:s.accessToken,d,i]),N=g.useCallback(async f=>{const j=a==null?void 0:a.apiServiceUrl,A=s==null?void 0:s.accessToken;if(j&&A)try{await t.cancelExport(j,A,f),i(f);return}catch(D){console.error(`Failed to cancel export ${f}:`,D)}i(f)},[a==null?void 0:a.apiServiceUrl,s==null?void 0:s.accessToken,i]);return p.length===0?e.jsxs("div",{className:"p-6 text-center",children:[e.jsx(V,{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(V,{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(r.Button,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",onClick:x,disabled:u,title:"Refresh status",children:e.jsx(t.RefreshCw,{className:`h-4 w-4 ${u?"animate-spin":""}`})}),C&&e.jsx(r.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-sm",onClick:y,disabled:l,children:l?"Clearing...":"Clear all"})]})]}),e.jsx("div",{className:"max-h-[350px] overflow-y-auto",children:e.jsx("div",{className:"divide-y",children:p.map(f=>e.jsx(z,{export:f,onRemove:N},f.id))})})]})}function ae({variant:s}){const a=t.useExportStore(l=>l.activeExports),v=t.useInProgressExportsCount(),d=a.size>0,i=Array.from(a.values()).some(l=>l.status==="completed"||l.status==="failed"),u=v>0?v>9?"9+":String(v):null,m=d;return e.jsxs(r.Popover,{children:[e.jsx(r.PopoverTrigger,{asChild:!0,children:e.jsxs(r.Button,{variant:s??"ghost",size:"xs",className:"relative w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Export notifications",children:[e.jsx(t.Bell,{className:"h-3.5 w-3.5"}),m&&e.jsx("span",{className:`absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${u?"-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold":"right-1 top-1 h-1.5 w-1.5"}`,children:u})]})}),e.jsx(r.PopoverContent,{className:"w-80 p-0",align:"end",sideOffset:8,children:e.jsx(H,{})})]})}function oe(s){if(s)return{renamed:s.type==="rename"?{oldId:s.oldId,newId:s.newId}:void 0,removedControlId:s.type==="remove"?s.controlId:void 0,cardBindingsById:s.type==="add"||s.type==="update"?s.cardBindingsById:void 0,affectedBindingControlIds:s.type==="add"||s.type==="update"?s.affectedBindingControlIds:void 0}}function ne({open:s,onOpenChange:a,trigger:v,showTrigger:d=!0,initialMode:i="manage"}){const c=i==="create",{forceClose:u,handleOpenChange:m,isCreateFlowActive:l,preventPassiveDismissDuringCreate:o,resolvedOpen:p,setIsCreateFlowActive:C}=F.useCreateFlowOverlayState({open:s,onOpenChange:a,initialCreateFlowActive:i==="create",dismissMode:d?"passive":"explicit-only"}),x=r.useDashboardStore(h=>h.dashboard),{setDashboardControlsModel:y}=r.useDashboardActions(),{participants:N}=t.useDashboardStructuralParticipants(r.getDashboardCards(x)),f=Array.from(new Map(N.flatMap(h=>h.fieldChoices.map(b=>{var I;return[b.value,{option:b,target:(I=h.fieldTargetMap)==null?void 0:I[b.value]}]}))).values()),j=Array.from(new Map(N.flatMap(h=>h.metricChoices.map(b=>{var I;return[b.value,{option:b,target:(I=h.metricTargetMap)==null?void 0:I[b.value]}]}))).values()),A=r.collectDashboardControlIds({...x||{},controls:[]}),D=t.buildDashboardStructuralParticipantIdsByControlId(x),n=(h,b,I)=>{y(h,b,oe(I))},w=g.useCallback(()=>{if(c){u();return}C(!1)},[c,u,C]),E=e.jsx(F.ControlDefinitionListEditor,{scope:"dashboard",controls:x.controls||[],reservedControlIds:A,defaultValues:x.defaultControlValues||{},usageByControlId:t.buildDashboardControlUsageById(x),availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:N,structuralParticipantIdsByControlId:D,initialCreateFlow:i==="create",onCreateFlowActiveChange:C,onCreateFlowComplete:w,onChange:n,emptyMessage:"No dashboard controls yet."}),L=l?"Add dashboard control":"Dashboard Controls",k=e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("h4",{className:"text-sm font-medium",children:"Dashboard Controls"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),E]});return d?e.jsxs(r.Popover,{open:p,onOpenChange:m,children:[e.jsx(r.PopoverTrigger,{asChild:!0,children:v||e.jsxs(r.Button,{variant:"outline",className:"h-7 px-2",size:"sm",children:[e.jsx(r.SlidersHorizontal,{className:"mr-2 h-4 w-4"}),"Controls"]})}),e.jsx(r.PopoverContent,{className:"w-[620px] max-w-[95vw] space-y-4",align:"end",onEscapeKeyDown:o,onPointerDownOutside:o,children:k})]}):e.jsx(t.Dialog,{open:p,onOpenChange:m,children:e.jsxs(t.DialogContent,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",onEscapeKeyDown:o,onPointerDownOutside:o,children:[e.jsxs(t.DialogHeader,{className:l?"space-y-0":void 0,children:[e.jsx(t.DialogTitle,{className:"text-[15px]",children:L}),e.jsx(t.DialogDescription,{className:l?"sr-only":"text-[13px]",children:l?"Configure and add a shared dashboard control.":"Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."})]}),e.jsx("div",{className:"min-h-0 overflow-y-auto pr-1",children:E})]})})}function ie({showFilters:s,onToggleFilters:a,onAddFilter:v,onAddControl:d,onManageControls:i,size:c="default",className:u,primaryButtonClassName:m,secondaryButtonClassName:l,dropdownContentClassName:o}){const p=c==="toolbar";return e.jsxs("div",{className:r.cn("relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",p?"h-8":"h-7",u),children:[e.jsxs(r.Button,{variant:"ghost",size:"xs",className:r.cn("h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50",m),onClick:a,children:[s?e.jsx($,{className:"h-3.5 w-3.5"}):e.jsx(t.Filter,{className:"h-3.5 w-3.5"}),"Filter"]}),e.jsxs(t.DropdownMenu,{children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(r.Button,{variant:"ghost",size:"xs",className:r.cn("h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50",l),"aria-label":"Filter and control actions",children:e.jsx(r.ChevronDown,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"start",className:r.cn("min-w-[180px] rounded-control border border-border/60 p-1 shadow-sm",o),children:[e.jsxs(t.DropdownMenuItem,{onSelect:v,children:[e.jsx(t.Filter,{className:"h-3.5 w-3.5"}),"Add filter"]}),e.jsxs(t.DropdownMenuItem,{onSelect:d,children:[e.jsx(r.SlidersHorizontal,{className:"h-3.5 w-3.5"}),"Add control"]}),e.jsxs(t.DropdownMenuItem,{onSelect:i,children:[e.jsx(t.Pencil,{className:"h-3.5 w-3.5"}),"Manage controls"]})]})]})]})}exports.AdvancedModeToggle=G;exports.DashboardControlsSettings=ne;exports.DashboardFilterControlsButton=ie;exports.ExportNotificationItem=z;exports.ExportNotificationList=H;exports.NotificationBell=ae;exports.UnsavedChangesAlert=Q;exports.VisualEditingControls=X;exports.useExportPolling=te;exports.useExportRecovery=se;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as i, jsx as t } from "react/jsx-runtime";
2
2
  import { useMemo as m, useState as b, useRef as f, useEffect as S } from "react";
3
- import { u as o, a as N, B as p, X as D, C as J } from "./switch-CKiXRRoh.js";
4
- import "./index-DMFCfjgD.js";
3
+ import { u as o, a as N, B as p, X as D, C as J } from "./switch-BZn7R_Cp.js";
4
+ import "./index-CSgoL0P9.js";
5
5
  import "./index-CJdxSyQq.js";
6
6
  import "react-dom";
7
7
  function C() {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),s=require("./switch-BPFzGTzF.js");require("./index-DQCMUspd.js");require("./index-DRlMUglg.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),c=s.useDashboardStore(e=>e.actions.setDashboard),u=s.useDashboardStore(e=>e.showDashboardJSON),h=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=o.useState(a),n=o.useRef(a);return o.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),r.jsxs("div",{className:s.cn("relative p-2",{hidden:!u}),children:[r.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>h(!1),children:[r.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),r.jsx("div",{className:"h-[550px] overflow-hidden",children:r.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const i=JSON.parse(e);n.current=JSON.stringify(i,null,2),c(i)}catch{}},language:"json"})})]})}exports.default=b;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),o=require("react"),s=require("./switch-BG4RWnrq.js");require("./index-AerZtbg0.js");require("./index-DRlMUglg.js");require("react-dom");function b(){const t=s.useDashboardStore(e=>e.dashboard),c=s.useDashboardStore(e=>e.actions.setDashboard),u=s.useDashboardStore(e=>e.showDashboardJSON),h=s.useDashboardStore(e=>e.actions.setShowDashboardJSON),a=o.useMemo(()=>t?JSON.stringify(t,null,2):"",[t]),[l,d]=o.useState(a),n=o.useRef(a);return o.useEffect(()=>{a!==n.current&&(d(a),n.current=a)},[a]),r.jsxs("div",{className:s.cn("relative p-2",{hidden:!u}),children:[r.jsxs(s.Button,{variant:"secondary",size:"sm",className:"absolute right-2 top-2 z-10 h-8",onClick:()=>h(!1),children:[r.jsx(s.X,{className:"mr-2 h-4 w-4"}),"Close"]}),r.jsx("div",{className:"h-[550px] overflow-hidden",children:r.jsx(s.CodeEditor,{value:l,onValueChange:e=>{d(e);try{const i=JSON.parse(e);n.current=JSON.stringify(i,null,2),c(i)}catch{}},language:"json"})})]})}exports.default=b;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),o=require("react"),a=require("./index-AerZtbg0.js"),s=require("./switch-BG4RWnrq.js"),q=require("./chevrons-up-down-DDEY9beZ.js");function X(n={}){var k,P,A,D;const{authToken:c,tokenProps:t}=a.useSemaphorContext(),v=n.enabled??!0,u=(c==null?void 0:c.accessToken)??null,f=(t==null?void 0:t.apiServiceUrl)??null,[N,j]=o.useState(!1),[S,b]=o.useState(!1),[h,l]=o.useState(!1),[y,d]=o.useState(null),[p,w]=o.useState(null),T=p||{tz:((P=(k=t==null?void 0:t.params)==null?void 0:k.calendarContext)==null?void 0:P.tz)||null,weekStart:((D=(A=t==null?void 0:t.params)==null?void 0:A.calendarContext)==null?void 0:D.weekStart)??null},g=o.useCallback(async()=>{if(!(!v||!u||!f)){j(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"GET",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to fetch preferences")}const i=await m.json();w({tz:i.tz,weekStart:i.weekStart,source:i.source,isInherited:i.isInherited,userHasPrefs:i.userHasPrefs,inherited:i.inherited})}catch(m){const i=m instanceof Error?m.message:"Unknown error";d(i)}finally{j(!1)}}},[u,f,v]);o.useEffect(()=>{v&&g()},[v,g]);const I=o.useCallback(async m=>{if(!u||!f)return d("Not authenticated"),!1;b(!0),d(null);try{const i=await fetch(`${f}/v1/user-preferences/calendar`,{method:"PATCH",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(m)});if(!i.ok){const x=await i.json().catch(()=>({}));throw new Error(x.error||"Failed to update preferences")}return await g(),!0}catch(i){const x=i instanceof Error?i.message:"Unknown error";return d(x),!1}finally{b(!1)}},[u,f,g]),C=o.useCallback(async()=>{if(!u||!f)return d("Not authenticated"),!1;l(!0),d(null);try{const m=await fetch(`${f}/v1/user-preferences/calendar`,{method:"DELETE",headers:{Authorization:`Bearer ${u}`}});if(!m.ok){const x=await m.json().catch(()=>({}));throw new Error(x.error||"Failed to clear preferences")}const i=await m.text();if(i)try{const x=JSON.parse(i);return w({tz:x.tz,weekStart:x.weekStart,source:x.source,isInherited:x.isInherited??!0,userHasPrefs:!1,inherited:x.inherited}),!0}catch{}return await g(),!0}catch(m){const i=m instanceof Error?m.message:"Unknown error";return d(i),!1}finally{l(!1)}},[u,f,g]);return{preferences:T,isLoading:N,isSaving:S,isClearing:h,error:y,updatePreferences:I,clearPreferences:C,refetch:g}}const z=[{value:"America/New_York",label:"Eastern Time (US & Canada)"},{value:"America/Chicago",label:"Central Time (US & Canada)"},{value:"America/Denver",label:"Mountain Time (US & Canada)"},{value:"America/Los_Angeles",label:"Pacific Time (US & Canada)"},{value:"America/Phoenix",label:"Arizona"},{value:"America/Anchorage",label:"Alaska"},{value:"Pacific/Honolulu",label:"Hawaii"},{value:"Europe/London",label:"London"},{value:"Europe/Paris",label:"Paris, Berlin, Rome"},{value:"Asia/Tokyo",label:"Tokyo"},{value:"Asia/Shanghai",label:"Beijing, Shanghai"},{value:"Asia/Kolkata",label:"Mumbai, New Delhi"},{value:"Australia/Sydney",label:"Sydney"},{value:"UTC",label:"UTC"}],$=[{value:0,label:"Sunday"},{value:1,label:"Monday"},{value:6,label:"Saturday"}],B="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Z(){try{const n=Intl;if(n.supportedValuesOf)return n.supportedValuesOf("timeZone")}catch{}return z.map(n=>n.value)}function J(n){switch(n){case"tenant":return"tenant";case"organization":return"organization";case"system":return"system";default:return"default"}}function _(n){const c=z.find(t=>t.value===n);return c?c.label:n}function K(n){const c=$.find(t=>t.value===n);return c?c.label:String(n)}function Y({open:n,onOpenChange:c}){var M,U,F;const{preferences:t,isLoading:v,isSaving:u,isClearing:f,updatePreferences:N,clearPreferences:j}=X({enabled:n}),S=t.tz||((M=t.inherited)==null?void 0:M.tz)||Intl.DateTimeFormat().resolvedOptions().timeZone,b=t.weekStart??((U=t.inherited)==null?void 0:U.weekStart)??1,[h,l]=o.useState(!t.userHasPrefs),[y,d]=o.useState(!1),[p,w]=o.useState(S),[T,g]=o.useState(b),[I,C]=o.useState(!1),k=o.useMemo(()=>Z(),[]),P=o.useMemo(()=>k.filter(r=>!z.some(V=>V.value===r)),[k]),A=o.useMemo(()=>_(p),[p]),D=t.inherited?_(t.inherited.tz):"UTC",m=t.inherited?K(t.inherited.weekStart):"Monday",i=J((F=t.inherited)==null?void 0:F.source);o.useEffect(()=>{if(!n){d(!1);return}y||(t.userHasPrefs!==void 0&&l(!t.userHasPrefs),w(S),g(b))},[n,y,t.userHasPrefs,S,b]);const x=async()=>{if(v){a.ue.error("Preferences are still loading. Please try again.");return}h?await j()?(a.ue.success("Now using default settings. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again."):await N({tz:p,weekStart:T})?(a.ue.success("Preferences saved. Please refresh the page to apply changes.",{duration:5e3}),c(!1)):a.ue.error("Failed to save preferences. Please try again.")},G=()=>{c(!1)},L=u||f,W=L||v;return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Calendar preferences"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Set your timezone and week-start for date calculations and displays."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs(a.RadioGroup,{value:h?"defaults":"custom",onValueChange:r=>{d(!0),l(r==="defaults")},className:"space-y-0.5",children:[e.jsxs("label",{htmlFor:"mode-defaults",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",h&&"bg-muted/50"),onClick:()=>{d(!0),l(!0)},children:[e.jsx(a.RadioGroupItem,{value:"defaults",id:"mode-defaults",className:"mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-[13px] font-medium text-foreground",children:["Use ",i," defaults"]}),e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[D,", week starts ",m]})]})]}),e.jsxs("label",{htmlFor:"mode-custom",className:s.cn("flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",!h&&"bg-muted/50"),onClick:()=>{d(!0),l(!1)},children:[e.jsx(a.RadioGroupItem,{value:"custom",id:"mode-custom",className:"mt-0.5"}),e.jsx("p",{className:"flex-1 text-[13px] font-medium text-foreground",children:"Use custom settings"})]})]}),e.jsxs("div",{className:s.cn("space-y-4 border-t border-border/60 pt-4 transition-opacity",h&&"pointer-events-none opacity-50"),children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Timezone"}),e.jsxs(s.Popover,{open:I,onOpenChange:C,modal:!0,children:[e.jsx(s.PopoverTrigger,{asChild:!0,children:e.jsxs(s.Button,{variant:"outline",size:"xs",role:"combobox","aria-expanded":I,className:"w-full justify-between text-[12px] font-normal",disabled:h,children:[e.jsx("span",{className:"truncate",children:A}),e.jsx(q.ChevronsUpDown,{className:"ml-2 h-3.5 w-3.5 shrink-0 opacity-50"})]})}),e.jsx(s.PopoverContent,{className:"z-50 w-[--radix-popover-trigger-width] p-0",align:"start",children:e.jsxs(a.Command,{className:"overflow-visible",children:[e.jsx(a.CommandInput,{placeholder:"Search timezones…"}),e.jsxs(a.CommandList,{children:[e.jsx(a.CommandEmpty,{children:"No timezone found."}),e.jsx(a.CommandGroup,{heading:"Common",children:z.map(r=>e.jsxs(a.CommandItem,{value:`${r.value} ${r.label}`,onSelect:()=>{d(!0),w(r.value),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r.value?"opacity-100":"opacity-0")}),e.jsx("span",{className:"flex-1",children:r.label}),e.jsx("span",{className:"text-[11px] text-muted-foreground",children:r.value})]},r.value))}),e.jsx(a.CommandSeparator,{}),e.jsx(a.CommandGroup,{heading:"All timezones",children:P.map(r=>e.jsxs(a.CommandItem,{value:r,onSelect:()=>{d(!0),w(r),C(!1)},children:[e.jsx(s.Check,{className:s.cn("h-3.5 w-3.5",p===r?"opacity-100":"opacity-0")}),r]},r))})]})]})})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{className:B,children:"Week starts on"}),e.jsx(a.RadioGroup,{value:String(T),onValueChange:r=>{d(!0),g(Number(r))},className:"flex gap-4",disabled:h,children:$.map(r=>e.jsxs("label",{htmlFor:`week-start-${r.value}`,className:s.cn("flex cursor-pointer items-center gap-2 text-[13px]",h&&"cursor-not-allowed"),children:[e.jsx(a.RadioGroupItem,{value:String(r.value),id:`week-start-${r.value}`,disabled:h}),r.label]},r.value))})]})]})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:G,disabled:L,children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:x,disabled:W,children:L?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving…"]}):"Save"})]})]})})}const E=6,O=1,R=20,H="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";function Q(n){return Number.isNaN(n)?E:Math.min(R,Math.max(O,n))}function ee({open:n,onOpenChange:c,dashboard:t,onApply:v,disabled:u=!1}){const[f,N]=o.useState(!1),[j,S]=o.useState("top"),[b,h]=o.useState(String(E)),l=t.summary;o.useEffect(()=>{n&&(N((l==null?void 0:l.enabled)===!0),S((l==null?void 0:l.position)==="bottom"?"bottom":"top"),h(String((l==null?void 0:l.maxItems)??E)))},[n,l==null?void 0:l.enabled,l==null?void 0:l.position,l==null?void 0:l.maxItems]);const y=o.useMemo(()=>Q(Number.parseInt(b||`${E}`,10)),[b]),d=()=>{v({enabled:f,position:j,maxItems:y}),c(!1)};return e.jsx(a.Dialog,{open:n,onOpenChange:c,children:e.jsxs(a.DialogContent,{className:"rounded-control border-border/60 sm:max-w-[420px] sm:rounded-control",children:[e.jsxs(a.DialogHeader,{children:[e.jsx(a.DialogTitle,{className:"text-[15px]",children:"Summary Settings"}),e.jsx(a.DialogDescription,{className:"text-[13px] leading-5",children:"Configure dashboard-level summary display. Card-level summary settings still control which cards contribute."})]}),e.jsxs("div",{className:"space-y-4 py-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-enabled",className:"text-[13px]",children:"Enable dashboard summary"}),e.jsx(s.Switch,{size:"xs",id:"dashboard-summary-enabled",checked:f,disabled:u,onCheckedChange:N})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-position",className:H,children:"Position"}),e.jsxs(s.Select,{value:j,disabled:u,onValueChange:p=>S(p),children:[e.jsx(s.SelectTrigger,{id:"dashboard-summary-position",size:"xs",children:e.jsx(s.SelectValue,{placeholder:"Select position"})}),e.jsxs(s.SelectContent,{children:[e.jsx(s.SelectItem,{value:"top",children:"Top"}),e.jsx(s.SelectItem,{value:"bottom",children:"Bottom"})]})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(s.Label,{htmlFor:"dashboard-summary-max-items",className:H,children:"Max items"}),e.jsx(s.Input,{size:"xs",id:"dashboard-summary-max-items",type:"number",min:O,max:R,disabled:u,value:b,onChange:p=>h(p.target.value),onBlur:()=>h(String(y))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Display limit only. Computation is unchanged."})]}),u&&e.jsx("p",{className:"text-[12px] text-amber-700",children:"Enter dashboard edit mode to modify summary settings."})]}),e.jsxs(a.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",size:"xs",onClick:()=>c(!1),children:"Cancel"}),e.jsx(s.Button,{size:"xs",onClick:d,disabled:u,children:"Apply"})]})]})})}exports.CalendarPreferencesDialog=Y;exports.DashboardSummarySettingsDialog=ee;
@@ -1,7 +1,8 @@
1
1
  import { jsx as e, jsxs as a, Fragment as ue } from "react/jsx-runtime";
2
2
  import me, { useState as f, useCallback as H, useEffect as q, useMemo as U } from "react";
3
- import { u as he, b as Q, c as ee, d as ae, e as te, f as se, R, g as $, C as fe, h as pe, i as be, j as ve, k as ge, l as V, m as G, n as xe, o as re, p as I } from "./index-DMFCfjgD.js";
4
- import { a as k, L as P, P as Se, b as ye, B as A, d as Ne, e as X, f as we, S as ke, g as Ce, h as Te, i as Ie, j as Pe, k as Z, I as Ae } from "./switch-CKiXRRoh.js";
3
+ import { u as he, b as Q, c as ee, d as ae, e as te, f as se, R, g as $, C as fe, h as pe, i as be, j as ve, k as V, l as G, m as ge, n as re, o as I } from "./index-CSgoL0P9.js";
4
+ import { a as C, L as P, P as xe, b as Se, B as A, d as ye, e as X, f as Ne, S as we, g as Ce, h as ke, i as Te, j as Ie, k as Z, I as Pe } from "./switch-BZn7R_Cp.js";
5
+ import { C as Ae } from "./chevrons-up-down-Cbtggnqv.js";
5
6
  function ze(r = {}) {
6
7
  var T, L, D, M;
7
8
  const { authToken: i, tokenProps: t } = he(), g = r.enabled ?? !0, o = (i == null ? void 0 : i.accessToken) ?? null, h = (t == null ? void 0 : t.apiServiceUrl) ?? null, [N, S] = f(!1), [x, b] = f(!1), [u, n] = f(!1), [y, c] = f(null), [p, w] = f(null), z = p || {
@@ -68,7 +69,7 @@ function ze(r = {}) {
68
69
  }
69
70
  },
70
71
  [o, h, v]
71
- ), C = H(async () => {
72
+ ), k = H(async () => {
72
73
  if (!o || !h)
73
74
  return c("Not authenticated"), !1;
74
75
  n(!0), c(null);
@@ -112,7 +113,7 @@ function ze(r = {}) {
112
113
  isClearing: u,
113
114
  error: y,
114
115
  updatePreferences: E,
115
- clearPreferences: C,
116
+ clearPreferences: k,
116
117
  refetch: v
117
118
  };
118
119
  }
@@ -165,7 +166,7 @@ function De(r) {
165
166
  const i = ne.find((t) => t.value === r);
166
167
  return i ? i.label : String(r);
167
168
  }
168
- function He({
169
+ function $e({
169
170
  open: r,
170
171
  onOpenChange: i
171
172
  }) {
@@ -181,7 +182,7 @@ function He({
181
182
  x
182
183
  ), [z, v] = f(
183
184
  b
184
- ), [E, C] = f(!1), T = U(() => Ee(), []), L = U(
185
+ ), [E, k] = f(!1), T = U(() => Ee(), []), L = U(
185
186
  () => T.filter(
186
187
  (s) => !_.some((de) => de.value === s)
187
188
  ),
@@ -239,7 +240,7 @@ function He({
239
240
  "label",
240
241
  {
241
242
  htmlFor: "mode-defaults",
242
- className: k(
243
+ className: C(
243
244
  "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
244
245
  u && "bg-muted/50"
245
246
  ),
@@ -274,7 +275,7 @@ function He({
274
275
  "label",
275
276
  {
276
277
  htmlFor: "mode-custom",
277
- className: k(
278
+ className: C(
278
279
  "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
279
280
  !u && "bg-muted/50"
280
281
  ),
@@ -300,7 +301,7 @@ function He({
300
301
  /* @__PURE__ */ a(
301
302
  "div",
302
303
  {
303
- className: k(
304
+ className: C(
304
305
  "space-y-4 border-t border-border/60 pt-4 transition-opacity",
305
306
  u && "pointer-events-none opacity-50"
306
307
  ),
@@ -308,13 +309,13 @@ function He({
308
309
  /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
309
310
  /* @__PURE__ */ e(P, { className: J, children: "Timezone" }),
310
311
  /* @__PURE__ */ a(
311
- Se,
312
+ xe,
312
313
  {
313
314
  open: E,
314
- onOpenChange: C,
315
+ onOpenChange: k,
315
316
  modal: !0,
316
317
  children: [
317
- /* @__PURE__ */ e(ye, { asChild: !0, children: /* @__PURE__ */ a(
318
+ /* @__PURE__ */ e(Se, { asChild: !0, children: /* @__PURE__ */ a(
318
319
  A,
319
320
  {
320
321
  variant: "outline",
@@ -325,31 +326,31 @@ function He({
325
326
  disabled: u,
326
327
  children: [
327
328
  /* @__PURE__ */ e("span", { className: "truncate", children: D }),
328
- /* @__PURE__ */ e(fe, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
329
+ /* @__PURE__ */ e(Ae, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
329
330
  ]
330
331
  }
331
332
  ) }),
332
333
  /* @__PURE__ */ e(
333
- Ne,
334
+ ye,
334
335
  {
335
336
  className: "z-50 w-[--radix-popover-trigger-width] p-0",
336
337
  align: "start",
337
- children: /* @__PURE__ */ a(pe, { className: "overflow-visible", children: [
338
- /* @__PURE__ */ e(be, { placeholder: "Search timezones…" }),
339
- /* @__PURE__ */ a(ve, { children: [
340
- /* @__PURE__ */ e(ge, { children: "No timezone found." }),
338
+ children: /* @__PURE__ */ a(fe, { className: "overflow-visible", children: [
339
+ /* @__PURE__ */ e(pe, { placeholder: "Search timezones…" }),
340
+ /* @__PURE__ */ a(be, { children: [
341
+ /* @__PURE__ */ e(ve, { children: "No timezone found." }),
341
342
  /* @__PURE__ */ e(V, { heading: "Common", children: _.map((s) => /* @__PURE__ */ a(
342
343
  G,
343
344
  {
344
345
  value: `${s.value} ${s.label}`,
345
346
  onSelect: () => {
346
- c(!0), w(s.value), C(!1);
347
+ c(!0), w(s.value), k(!1);
347
348
  },
348
349
  children: [
349
350
  /* @__PURE__ */ e(
350
351
  X,
351
352
  {
352
- className: k(
353
+ className: C(
353
354
  "h-3.5 w-3.5",
354
355
  p === s.value ? "opacity-100" : "opacity-0"
355
356
  )
@@ -361,19 +362,19 @@ function He({
361
362
  },
362
363
  s.value
363
364
  )) }),
364
- /* @__PURE__ */ e(xe, {}),
365
+ /* @__PURE__ */ e(ge, {}),
365
366
  /* @__PURE__ */ e(V, { heading: "All timezones", children: L.map((s) => /* @__PURE__ */ a(
366
367
  G,
367
368
  {
368
369
  value: s,
369
370
  onSelect: () => {
370
- c(!0), w(s), C(!1);
371
+ c(!0), w(s), k(!1);
371
372
  },
372
373
  children: [
373
374
  /* @__PURE__ */ e(
374
375
  X,
375
376
  {
376
- className: k(
377
+ className: C(
377
378
  "h-3.5 w-3.5",
378
379
  p === s ? "opacity-100" : "opacity-0"
379
380
  )
@@ -407,7 +408,7 @@ function He({
407
408
  "label",
408
409
  {
409
410
  htmlFor: `week-start-${s.value}`,
410
- className: k(
411
+ className: C(
411
412
  "flex cursor-pointer items-center gap-2 text-[13px]",
412
413
  u && "cursor-not-allowed"
413
414
  ),
@@ -444,7 +445,7 @@ function He({
444
445
  }
445
446
  ),
446
447
  /* @__PURE__ */ e(A, { size: "xs", onClick: m, disabled: ce, children: j ? /* @__PURE__ */ a(ue, { children: [
447
- /* @__PURE__ */ e(we, { className: "h-3.5 w-3.5 animate-spin" }),
448
+ /* @__PURE__ */ e(Ne, { className: "h-3.5 w-3.5 animate-spin" }),
448
449
  "Saving…"
449
450
  ] }) : "Save" })
450
451
  ] })
@@ -454,7 +455,7 @@ const F = 6, le = 1, ie = 20, Y = "text-[10px] font-medium uppercase tracking-[0
454
455
  function Me(r) {
455
456
  return Number.isNaN(r) ? F : Math.min(ie, Math.max(le, r));
456
457
  }
457
- function $e({
458
+ function Be({
458
459
  open: r,
459
460
  onOpenChange: i,
460
461
  dashboard: t,
@@ -478,7 +479,7 @@ function $e({
478
479
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between", children: [
479
480
  /* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-enabled", className: "text-[13px]", children: "Enable dashboard summary" }),
480
481
  /* @__PURE__ */ e(
481
- ke,
482
+ we,
482
483
  {
483
484
  size: "xs",
484
485
  id: "dashboard-summary-enabled",
@@ -497,8 +498,8 @@ function $e({
497
498
  disabled: o,
498
499
  onValueChange: (p) => x(p),
499
500
  children: [
500
- /* @__PURE__ */ e(Te, { id: "dashboard-summary-position", size: "xs", children: /* @__PURE__ */ e(Ie, { placeholder: "Select position" }) }),
501
- /* @__PURE__ */ a(Pe, { children: [
501
+ /* @__PURE__ */ e(ke, { id: "dashboard-summary-position", size: "xs", children: /* @__PURE__ */ e(Te, { placeholder: "Select position" }) }),
502
+ /* @__PURE__ */ a(Ie, { children: [
502
503
  /* @__PURE__ */ e(Z, { value: "top", children: "Top" }),
503
504
  /* @__PURE__ */ e(Z, { value: "bottom", children: "Bottom" })
504
505
  ] })
@@ -509,7 +510,7 @@ function $e({
509
510
  /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
510
511
  /* @__PURE__ */ e(P, { htmlFor: "dashboard-summary-max-items", className: Y, children: "Max items" }),
511
512
  /* @__PURE__ */ e(
512
- Ae,
513
+ Pe,
513
514
  {
514
515
  size: "xs",
515
516
  id: "dashboard-summary-max-items",
@@ -539,6 +540,6 @@ function $e({
539
540
  ] }) });
540
541
  }
541
542
  export {
542
- He as C,
543
- $e as D
543
+ $e as C,
544
+ Be as D
544
545
  };