react-semaphor 0.1.208 → 0.1.210

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 (46) hide show
  1. package/dist/chunks/dashboard-controls-BAOrAMV9.js +42 -0
  2. package/dist/chunks/{dashboard-controls-yOzrvYwI.js → dashboard-controls-C08300Wi.js} +504 -456
  3. package/dist/chunks/{dashboard-json-BuLoVNV4.js → dashboard-json-DlEE5-WA.js} +1 -1
  4. package/dist/chunks/{dashboard-json-DqChvVCF.js → dashboard-json-GjDBGO26.js} +1 -1
  5. package/dist/chunks/{dashboard-summary-settings-dialog-tJueBNph.js → dashboard-summary-settings-dialog-QUuhhXU9.js} +1 -1
  6. package/dist/chunks/{dashboard-summary-settings-dialog-DmccX33N.js → dashboard-summary-settings-dialog-THx-gjnG.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-CV4JsCTg.js → edit-dashboard-visual-Bsmow1Pa.js} +3422 -3536
  8. package/dist/chunks/edit-dashboard-visual-PfWJXb2-.js +164 -0
  9. package/dist/chunks/editor-action-buttons-DNbp_ZWy.js +404 -0
  10. package/dist/chunks/editor-action-buttons-FPyaC09X.js +21 -0
  11. package/dist/chunks/{index-CBcPi9pm.js → index-CAVrkf9d.js} +24248 -23818
  12. package/dist/chunks/index-CXKjmjfB.js +1104 -0
  13. package/dist/chunks/normalize-dashboard-for-dirty-check-D9x96J2F.js +1 -0
  14. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  15. package/dist/chunks/notification-bell-BqvKQSw9.js +6 -0
  16. package/dist/chunks/notification-bell-C3a7wC1u.js +871 -0
  17. package/dist/chunks/resource-management-panel-BVTgbma8.js +913 -0
  18. package/dist/chunks/resource-management-panel-C5NjrVsA.js +6 -0
  19. package/dist/chunks/{use-role-aware-display-preferences-DTSpe_ZT.js → use-role-aware-display-preferences-DxCPoCgr.js} +1 -1
  20. package/dist/chunks/{use-role-aware-display-preferences-B4QJkliF.js → use-role-aware-display-preferences-l7NFLYnn.js} +1 -1
  21. package/dist/chunks/{use-visual-utils-ChR-Jti8.js → use-visual-utils-B82Q-Ytl.js} +1 -1
  22. package/dist/chunks/{use-visual-utils-CCT3ABI5.js → use-visual-utils-D9IJz9R0.js} +34 -34
  23. package/dist/dashboard/index.cjs +1 -1
  24. package/dist/dashboard/index.js +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +44 -40
  27. package/dist/shared/index.cjs +1 -0
  28. package/dist/shared/index.js +6 -0
  29. package/dist/style.css +1 -1
  30. package/dist/surfboard/index.cjs +1 -1
  31. package/dist/surfboard/index.js +2 -2
  32. package/dist/types/dashboard.d.ts +12 -1
  33. package/dist/types/main.d.ts +52 -2
  34. package/dist/types/shared.d.ts +1762 -0
  35. package/dist/types/surfboard.d.ts +12 -1
  36. package/dist/types/types.d.ts +12 -1
  37. package/package.json +6 -1
  38. package/dist/chunks/dashboard-controls-K5zNLdtH.js +0 -42
  39. package/dist/chunks/edit-dashboard-visual-CKNlwaCO.js +0 -179
  40. package/dist/chunks/editor-action-buttons-CAjqJiT_.js +0 -340
  41. package/dist/chunks/editor-action-buttons-DQVh7L5i.js +0 -11
  42. package/dist/chunks/index-DQOwJyRp.js +0 -1104
  43. package/dist/chunks/notification-bell-B-OVf20Q.js +0 -862
  44. package/dist/chunks/notification-bell-DyzIftQU.js +0 -11
  45. package/dist/chunks/resource-management-panel-D_mSi7Cm.js +0 -914
  46. package/dist/chunks/resource-management-panel-NqaNfAq3.js +0 -6
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DQOwJyRp.js"),c=require("react"),de=require("./use-visual-utils-ChR-Jti8.js"),pe=require("./use-role-aware-display-preferences-B4QJkliF.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 fe=t.createLucideIcon("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);function ge(s,f={}){const{enabled:m=!0,eventType:r="mousedown"}=f,o=c.useRef(null);return c.useEffect(()=>{const g=j=>{const a=j.target;o.current&&o.current.contains(a)||a instanceof Element&&(a.closest("[data-radix-popper-content-wrapper]")||a.closest("[data-radix-select-content]")||a.closest("[data-radix-popover-content]")||a.closest("[data-radix-dropdown-menu-content]")||a.closest("[data-radix-tooltip-content]")||a.closest('[role="listbox"]')||a.closest('[role="option"]')||a.closest('[role="combobox"]'))||a instanceof Element&&a.hasAttribute("data-radix-")||s()};return m&&document.addEventListener(r,g),()=>{document.removeEventListener(r,g)}},[s,m,r]),o}function ce(){return e.jsx("div",{className:"space-y-1 px-2 py-2",children:[...Array(5)].map((s,f)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-md px-2 py-2",children:[e.jsx("div",{className:"mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-3/5 rounded bg-muted/60"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted/40"})]})]},f))})}const je=s=>{const f=t.useDashboardStore(o=>o.isVisualEditing),m=t.useDashboardStore(o=>o.selectedFrameId),r=t.useEditorStore(o=>o.frame);return!!(f&&m&&(r==null?void 0:r.visualId)===s)};function De({visual:s,isDeleting:f,isDuplicating:m,onAddVisual:r,onOpenVisual:o,onEditDetails:g,onDeleteClick:j,onDuplicateVisual:a,onShareVisual:D,formatDate:y}){var T,S,M,C;const{selectVisual:d}=t.useManagementActions(),u=t.useIsVisualSelected(s.id),x=je(s.id),{isConsoleMode:b}=t.useDashboardPreferences(),E=c.useRef(null),[w,v]=c.useState(!1),[A,V]=c.useState(!1);c.useEffect(()=>{m?(v(!0),V(!0)):A&&(v(!1),V(!1))},[m,A]),c.useEffect(()=>{x&&E.current&&E.current.scrollIntoView({behavior:"smooth",block:"center"})},[x]);const O=()=>{d(s),o==null||o(s)};return e.jsxs("div",{ref:E,className:t.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",x?"bg-purple-500/10":u&&"bg-muted/80"),onClick:O,children:[e.jsx(t.ChartLine,{className:"mt-0.5 h-4 w-4 flex-shrink-0 text-muted-foreground/50"}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(T=s.description)!=null&&T.trim()?s.description:"No description"})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",onClick:p=>p.stopPropagation(),children:[e.jsx("div",{className:"opacity-0 transition-opacity group-hover:opacity-100",children:e.jsxs(t.DropdownMenu,{modal:!1,open:w,onOpenChange:v,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",children:e.jsx(t.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-40",children:[e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.stopPropagation(),r(s)},children:[e.jsx(t.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.stopPropagation(),o==null||o(s)},children:[e.jsx(fe,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.preventDefault(),p.stopPropagation(),a(s.id)},disabled:m,children:[m?e.jsx(t.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(t.Copy,{className:"mr-2 h-3 w-3"}),m?"Duplicating...":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.stopPropagation(),g==null||g(s)},children:[e.jsx(t.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.stopPropagation(),D(s)},children:[e.jsx(t.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:p=>{p.stopPropagation(),j(s)},className:"text-destructive",disabled:f,children:[e.jsx(t.Trash2,{className:"mr-2 h-3 w-3"}),f?"Deleting...":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400",children:[(((S=s.ownership.createdBy)==null?void 0:S.type)==="tenant"||((M=s.ownership.createdBy)==null?void 0:M.type)==="organization"&&b)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((C=s.ownership.createdBy)==null?void 0:C.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:y(s.lastModified)})]})]})]})]})}),e.jsx(t.IconButton,{tooltip:"Add to dashboard",buttonProps:{variant:"ghost",size:"sm",onClick:p=>{p.stopPropagation(),r(s)}},className:"h-6 w-6 p-0",children:e.jsx(t.Plus,{className:"h-3.5 w-3.5"})})]})]})})]},s.id)}function Ne({searchQuery:s}){const[f,m]=c.useState(!1),[r,o]=c.useState(null),[g,j]=c.useState(!1),[a,D]=c.useState(null),[y,d]=c.useState(null),[u,x]=c.useState(null),{selectVisual:b}=t.useManagementActions(),{handleEditLibraryVisual:E,handleAddLibraryVisual:w}=de.useVisualUtils(),{resources:v,isLoading:A,isError:V,isFetching:O,updateResource:T,deleteResource:S,duplicateResource:M,isDeleting:C,isDuplicating:p,isUpdating:B}=t.useVisualManagement(()=>{j(!1),D(null)});t.useCurrentUserInfo();const J=v.filter(i=>{var L,l;return((L=i==null?void 0:i.title)==null?void 0:L.toLowerCase().includes(s.toLowerCase()))||((l=i==null?void 0:i.description)==null?void 0:l.toLowerCase().includes(s.toLowerCase()))}),U=i=>new Date(i).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),$=i=>{D(i),j(!0)},q=()=>{a&&S(a.id)},{startUpdating:Q,stopUpdating:R,isUpdating:X}=t.useResourceUpdateState(),Z=(i,L,l)=>{var ee;const G=Object.fromEntries(Object.entries(L).filter(([,I])=>I!==void 0));if(Object.keys(G).length===0){(ee=l==null?void 0:l.onSuccess)==null||ee.call(l);return}const W=Object.keys(G),Y=W.length===1?W[0]:void 0;Q(i,Y),T({resourceId:i,data:G},{onSuccess:()=>{var I;R(i,Y),(I=l==null?void 0:l.onSuccess)==null||I.call(l)},onError:()=>{var I;R(i,Y),(I=l==null?void 0:l.onError)==null||I.call(l)}})},z=i=>{d(i),M(i,{onSettled:()=>d(null)})},F=i=>{E(i)},_=i=>{w(i)},N=i=>{const L=v.find(l=>l.id===i);L&&T({resourceId:i,data:{isPrivate:!L.isPrivate}})},K=i=>{o(i),m(!0)},k=i=>{x(i)},te=()=>{x(null)},se=({title:i,description:L})=>{if(!u)return;const l={};i!==u.title&&(l.title=i),(u.description||"")!==L&&(l.description=L),Z(u.id,l,{onSuccess:()=>{x(null)}})};return A?e.jsx(ce,{}):V?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:()=>window.location.reload(),children:"Retry"})]})}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:J.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:s?"Try adjusting your search":'Click "Create" above to add your first visual'})]}):J.map(i=>e.jsx(De,{visual:i,onAddVisual:_,onOpenVisual:F,onEditDetails:k,onDeleteClick:$,onDuplicateVisual:z,onTogglePrivacy:N,onShareVisual:K,isDeleting:C,isDuplicating:y===i.id,formatDate:U},i.id))}),f&&r&&e.jsx(t.ShareDialog,{resource:r,resourceType:t.ResourceType.VISUAL,onClose:()=>{m(!1),o(null)}}),u&&e.jsx(t.ResourceEditDialog,{open:!!u,resourceLabel:"Visual",initialTitle:u.title||"",initialDescription:u.description||"",onClose:te,onSave:se,isSaving:X(u.id)}),e.jsx(t.AlertDialog,{open:g,onOpenChange:i=>{!i&&C||(j(i),i||D(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',a==null?void 0:a.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:C,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:i=>{i.preventDefault(),i.stopPropagation(),q()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:C,children:[C?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),C?"Deleting...":"Delete"]})]})]})})]})}function we({dashboard:s,isDeleting:f,isDuplicating:m,isDefault:r,onLoadDashboard:o,onEditDetails:g,onDeleteClick:j,onDuplicateDashboard:a,onShareDashboard:D,formatDate:y,onDashboardItemClick:d}){var T,S;const{selectDashboard:u}=t.useManagementActions(),x=t.useIsDashboardSelected(s.id),{userContext:b,isLoading:E}=t.useCurrentUserInfo(),{mutate:w}=t.useDefaultDashboardMutation(),v=((T=b==null?void 0:b.permissions)==null?void 0:T.canEdit)??!1,A=E||!v,V=()=>{u(s),o(s.id),d==null||d(s.id)},O=M=>{M.stopPropagation(),w({dashboardId:r?null:s.id})};return e.jsx(t.TooltipProvider,{children:e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-3 rounded-md px-2 py-2 transition-colors hover:bg-muted",x&&"bg-muted/80"),onClick:V,children:[e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("button",{onClick:O,className:"mt-0.5 flex-shrink-0 rounded p-0.5 hover:bg-muted",children:e.jsx(t.Star,{className:t.cn("h-4 w-4 transition-colors",r?"fill-yellow-400 text-yellow-400":"text-muted-foreground/40 hover:text-yellow-400")})})}),e.jsx(t.TooltipContent,{side:"right",className:"text-xs",children:r?"Remove as default":"Set as default"})]}),e.jsx("div",{className:"min-w-0 flex-1",children:e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-xs text-muted-foreground",title:s.description||"No description",children:(S=s.description)!=null&&S.trim()?s.description:"No description"})]}),e.jsx("div",{className:"flex-shrink-0 opacity-0 transition-opacity group-hover:opacity-100",children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:f,isDuplicating:m,shouldHideActions:A,onEditDetails:g,onDeleteClick:j,onDuplicateDashboard:a,onShareDashboard:D,formatDate:y})})]})})]},s.id)})}function Ce({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[e.jsx("p",{className:"text-sm text-destructive",children:"Failed to load dashboards"}),e.jsx(t.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:s,children:"Retry"})]})})}function ve(s){var ae,re;const{searchQuery:f,onLoadDashboard:m,onEditDashboard:r,onDashboardItemClick:o}=s,[g,j]=c.useState(!1),[a,D]=c.useState(null),[y,d]=c.useState(!1),[u,x]=c.useState(null),[b,E]=c.useState(null),[w,v]=c.useState(null),A=t.useManagementStore(n=>n.lastSelectedDashboard),V=t.useManagementStore(n=>n.selectedDashboard),O=t.useManagementStore(n=>n.actions.selectDashboard),T=t.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:S,id:M}=t.useSemaphorContext();pe.useRoleAwareDisplayPreferences();const{resources:C,isLoading:p,isError:B,isFetching:J,updateResource:U,deleteResource:$,duplicateResource:q,isUpdating:Q,isDeleting:R,isDuplicating:X,refetch:Z}=t.useDashboardManagement(()=>{d(!1);const n=u==null?void 0:u.id;x(null),(V==null?void 0:V.id)===n&&(!(S!=null&&S.dashboard_id)&&!M?T():A&&A.id!==n&&O(A))}),{currentUser:z,userContext:F}=t.useCurrentUserInfo(),_=((ae=F==null?void 0:F.permissions)==null?void 0:ae.canCreateDashboard)??!1,{data:N}=t.useUserPreferences(),K=((re=N==null?void 0:N.preference)==null?void 0:re.defaultDashboardId)||null,k=C.filter(n=>{var P,h;return((P=n==null?void 0:n.title)==null?void 0:P.toLowerCase().includes(f.toLowerCase()))||((h=n==null?void 0:n.description)==null?void 0:h.toLowerCase().includes(f.toLowerCase()))}),te=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),se=n=>{m==null||m(n)},i=n=>{x(n),d(!0)},L=()=>{u&&$(u.id)},l=n=>{E(n),q(n,{onSettled:()=>E(null)})},{startUpdating:G,stopUpdating:W,isUpdating:Y}=t.useResourceUpdateState(),ee=(n,P,h)=>{var le;const ne=Object.fromEntries(Object.entries(P).filter(([,H])=>H!==void 0));if(Object.keys(ne).length===0){(le=h==null?void 0:h.onSuccess)==null||le.call(h);return}const oe=Object.keys(ne),ie=oe.length===1?oe[0]:void 0;G(n,ie),U({resourceId:n,data:ne},{onSuccess:()=>{var H;W(n,ie),(H=h==null?void 0:h.onSuccess)==null||H.call(h)},onError:()=>{var H;W(n,ie),(H=h==null?void 0:h.onError)==null||H.call(h)}})},I=n=>{const P=C.find(h=>h.id===n);P&&U({resourceId:n,data:{isPrivate:!P.isPrivate}})},ue=n=>{D(n),z==null||z.type,j(!0)},he=n=>{r==null||r(n.id),v(n)},me=()=>{v(null)},xe=({title:n,description:P})=>{if(!w)return;const h={};n!==w.title&&(h.title=n),(w.description||"")!==P&&(h.description=P),ee(w.id,h,{onSuccess:()=>{v(null)}})};return p?e.jsx(ce,{}):B?e.jsx(Ce,{onRetry:()=>window.location.reload()}):e.jsxs("div",{className:"flex h-full flex-1 flex-col",children:[e.jsx("div",{className:"flex flex-1 basis-0 flex-col gap-3 overflow-y-auto",children:k.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(t.ChartColumn,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:f?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:f?"Try adjusting your search":_?'Click "Create" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):k.map(n=>e.jsx(we,{dashboard:n,isDeleting:R,isDuplicating:b===n.id,isDefault:n.id===K,onLoadDashboard:se,onEditDetails:he,onDeleteClick:i,onDuplicateDashboard:l,onTogglePrivacy:I,onShareDashboard:ue,formatDate:te,onDashboardItemClick:o},n.id))}),g&&a&&e.jsx(t.ShareDialog,{resource:a,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(t.AlertDialog,{open:y,onOpenChange:n=>{!n&&R||(d(n),n||x(null))},children:e.jsxs(t.AlertDialogContent,{children:[e.jsxs(t.AlertDialogHeader,{children:[e.jsx(t.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(t.AlertDialogDescription,{children:['Are you sure you want to delete "',u==null?void 0:u.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:R,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),L()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:R,children:[R?e.jsx(t.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"mr-2 h-3.5 w-3.5"}),R?"Deleting...":"Delete"]})]})]})}),w&&e.jsx(t.ResourceEditDialog,{open:!!w,resourceLabel:"Dashboard",initialTitle:w.title||"",initialDescription:w.description||"",onClose:me,onSave:xe,isSaving:Y(w.id)})]})}function ye({open:s,onOpenChange:f,onSubmit:m,isCreating:r}){const[o,g]=c.useState(""),[j,a]=c.useState("");c.useEffect(()=>{s||(g(""),a(""))},[s]);const D=()=>{o.trim()&&m({title:o,description:j})},y=d=>{f(d)};return e.jsx(t.Dialog,{open:s,onOpenChange:y,children:e.jsxs(t.DialogContent,{children:[e.jsxs(t.DialogHeader,{children:[e.jsx(t.DialogTitle,{children:"Create New Visual"}),e.jsx(t.DialogDescription,{children:"Add a new visual to your library. You can configure it after creation."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(t.Input$1,{id:"title",placeholder:"Enter visual title...",value:o,onChange:d=>g(d.target.value),disabled:r,onKeyDown:d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),D())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(t.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(t.Input$1,{id:"description",placeholder:"Enter visual description...",value:j,onChange:d=>a(d.target.value),disabled:r})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>y(!1),disabled:r,children:"Cancel"}),e.jsx(t.Button,{onClick:D,disabled:!o.trim()||r,children:r?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function Se({isOpen:s,onClose:f,className:m,onDashboardItemClick:r,variant:o="inline"}){var F,_;const g=t.useDashboardStore(N=>N.isDashboardEditing),[j,a]=c.useState(!1),[D,y]=c.useState(""),[d,u]=c.useState(!1),{currentUser:x,userContext:b}=t.useCurrentUserInfo(),E=((F=b==null?void 0:b.permissions)==null?void 0:F.canCreateDashboard)??!1,{onCreateSuccess:w}=t.useDashboardCreation({onDashboardSelect:r}),{selectVisual:v}=t.useManagementActions(),{handleEditLibraryVisual:A}=de.useVisualUtils(),{createResource:V,isCreating:O,refetch:T}=t.useDashboardManagement(),{createResource:S,isCreating:M}=t.useVisualManagement(void 0,N=>{a(!1),N&&(v(N),A(N))}),C=o==="overlay",p=((x==null?void 0:x.name)??"").trim(),B=((x==null?void 0:x.email)??"").trim(),U=p&&p.toLowerCase()!=="undefined"?p:B||"Current user",$=((_=U.charAt(0))==null?void 0:_.toUpperCase())||"?",q=B&&B.toLowerCase()!=="undefined"?B:"",Q=ge(f,{enabled:s&&C}),R=t.cn("flex h-full flex-col border-r bg-background",C?t.cn("absolute inset-y-0 left-0 z-[51] w-60 shadow-lg transition-transform duration-300 ease-in-out",s?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[17rem] min-w-[11rem] overflow-hidden shadow-sm",m),X=N=>{},Z=N=>{console.log("Editing dashboard:",N)},z=N=>{V(N,{onSuccess:K=>{a(!1),w(K,T)}})};return e.jsx(e.Fragment,{children:(!C||s)&&e.jsxs("div",{ref:Q,className:R,children:[e.jsxs("div",{className:"border-b border-border",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-1.5",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"whitespace-nowrap text-sm font-semibold",children:g?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-0",children:[e.jsx(t.Button,{size:"sm",variant:"ghost",onClick:()=>u(!d),className:"h-8 w-8 p-0",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(g||E)&&e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-8 w-8 whitespace-nowrap p-0",onClick:()=>a(!0),children:e.jsx(t.Plus,{className:"h-3.5 w-3.5"})})]})]}),d&&e.jsx("div",{className:"bg-muted/30 px-4 pb-3",children:e.jsx(t.Input$1,{placeholder:"Search...",value:D,onChange:N=>y(N.target.value),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",autoFocus:!0})})]}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-2 py-2",children:g?e.jsx(Ne,{searchQuery:D}):e.jsx(ve,{searchQuery:D,onLoadDashboard:X,onEditDashboard:Z,onDashboardItemClick:r})}),x&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border px-4 py-2",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-6 w-6 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:$})})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:U}),q&&e.jsx("div",{className:"text-xs text-muted-foreground",children:q}),x.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",t.toTitleCase(x.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs text-muted-foreground",children:U})]})})}),g?e.jsx(ye,{open:j,onOpenChange:a,onSubmit:S,isCreating:M}):e.jsx(t.CreateDashboardDialog,{open:j,onOpenChange:a,onSubmit:z,isCreating:O})]})})}exports.ResourceManagementPanel=Se;