react-semaphor 0.1.159 → 0.1.161

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 (27) hide show
  1. package/dist/chunks/{dashboard-controls-DnlJRUpY.js → dashboard-controls-Bj4t5-el.js} +191 -190
  2. package/dist/chunks/{dashboard-controls-DIo_VMBS.js → dashboard-controls-BlxwV3BR.js} +6 -6
  3. package/dist/chunks/{dashboard-export-dialog-D6bmvl-v.js → dashboard-export-dialog-CIzU-4eS.js} +22 -22
  4. package/dist/chunks/{dashboard-export-dialog-CZhtshog.js → dashboard-export-dialog-CT050NhP.js} +1 -1
  5. package/dist/chunks/{dashboard-json-D1jy0qDk.js → dashboard-json-BozpGO6V.js} +1 -1
  6. package/dist/chunks/{dashboard-json-Bagczd1F.js → dashboard-json-rd13AclB.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-ANoND-SH.js → edit-dashboard-visual-CfKKFELr.js} +1 -1
  8. package/dist/chunks/{edit-dashboard-visual-B6Q0AUbn.js → edit-dashboard-visual-CxCLmkDv.js} +656 -656
  9. package/dist/chunks/{editor-action-buttons-B1yfEUpI.js → editor-action-buttons-Bu2ZxWgU.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-CMNOhq91.js → editor-action-buttons-Ca2pHbvu.js} +2 -2
  11. package/dist/chunks/{index-Dy-VUjSy.js → index-BXm1zeXQ.js} +205 -205
  12. package/dist/chunks/{index-CMymongy.js → index-CO0YJSQz.js} +14042 -14052
  13. package/dist/chunks/resource-management-panel-C7J2WWQy.js +6 -0
  14. package/dist/chunks/{resource-management-panel-BPl4Mk9m.js → resource-management-panel-DTJwukgb.js} +343 -335
  15. package/dist/chunks/use-role-aware-display-preferences-CBkOVEcY.js +1 -0
  16. package/dist/chunks/use-role-aware-display-preferences-CJv8NgDG.js +29 -0
  17. package/dist/chunks/{use-visual-utils-BH4FZWUV.js → use-visual-utils-8weKmT25.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-H7arppWh.js → use-visual-utils-B39LEQMe.js} +24 -24
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +2 -2
  22. package/dist/index.js +67 -65
  23. package/dist/surfboard/index.cjs +1 -1
  24. package/dist/surfboard/index.js +1 -1
  25. package/dist/types/main.d.ts +68 -1
  26. package/package.json +1 -1
  27. package/dist/chunks/resource-management-panel--vwXhI58.js +0 -6
@@ -0,0 +1,6 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-BXm1zeXQ.js"),c=require("react"),de=require("./use-visual-utils-8weKmT25.js"),pe=require("./use-role-aware-display-preferences-CBkOVEcY.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 Q=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"}),K=i=>{D(i),j(!0)},q=()=>{a&&S(a.id)},{startUpdating:X,stopUpdating:R,isUpdating:Z}=t.useResourceUpdateState(),$=(i,L,l)=>{var ee;const W=Object.fromEntries(Object.entries(L).filter(([,I])=>I!==void 0));if(Object.keys(W).length===0){(ee=l==null?void 0:l.onSuccess)==null||ee.call(l);return}const Y=Object.keys(W),J=Y.length===1?Y[0]:void 0;X(i,J),T({resourceId:i,data:W},{onSuccess:()=>{var I;R(i,J),(I=l==null?void 0:l.onSuccess)==null||I.call(l)},onError:()=>{var I;R(i,J),(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}})},G=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),$(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:Q.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'})]}):Q.map(i=>e.jsx(De,{visual:i,onAddVisual:_,onOpenVisual:F,onEditDetails:k,onDeleteClick:K,onDuplicateVisual:z,onTogglePrivacy:N,onShareVisual:G,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:Z(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:Q,updateResource:U,deleteResource:K,duplicateResource:q,isUpdating:X,isDeleting:R,isDuplicating:Z,refetch:$}=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(),G=((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&&K(u.id)},l=n=>{E(n),q(n,{onSettled:()=>E(null)})},{startUpdating:W,stopUpdating:Y,isUpdating:J}=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;W(n,ie),U({resourceId:n,data:ne},{onSuccess:()=>{var H;Y(n,ie),(H=h==null?void 0:h.onSuccess)==null||H.call(h)},onError:()=>{var H;Y(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===G,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:J(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,{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,{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",K=((_=U.charAt(0))==null?void 0:_.toUpperCase())||"?",q=B&&B.toLowerCase()!=="undefined"?B:"",X=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),Z=N=>{},$=N=>{console.log("Editing dashboard:",N)},z=N=>{V(N,{onSuccess:G=>{a(!1),w(G,T)}})};return e.jsx(e.Fragment,{children:(!C||s)&&e.jsxs("div",{ref:X,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,{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:Z,onEditDashboard:$,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:K})})}),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;