react-semaphor 0.1.100 → 0.1.101

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 (31) hide show
  1. package/dist/chunks/{dashboard-controls-DW1JJWP7.js → dashboard-controls-BOWrupBW.js} +599 -599
  2. package/dist/chunks/dashboard-controls-DZ3mfITk.js +26 -0
  3. package/dist/chunks/{dashboard-json-C0CKQW3d.js → dashboard-json-37BidbHV.js} +1 -1
  4. package/dist/chunks/{dashboard-json-BDAEIUep.js → dashboard-json-BHLhFEdC.js} +1 -1
  5. package/dist/chunks/{edit-dashboard-visual-BtV3RWgf.js → edit-dashboard-visual-BJD5eZpR.js} +31 -31
  6. package/dist/chunks/{edit-dashboard-visual-DQzy1fUR.js → edit-dashboard-visual-D7Ic8u1b.js} +30 -21
  7. package/dist/chunks/{editor-action-buttons-CReBF7FV.js → editor-action-buttons-DPAlJF2w.js} +1 -1
  8. package/dist/chunks/{editor-action-buttons-BJRrkj_n.js → editor-action-buttons-DpbEl7Rx.js} +2 -2
  9. package/dist/chunks/{index-f2IZ7tlh.js → index-CGyjzIO0.js} +7985 -7967
  10. package/dist/chunks/{index-BDtdPUUE.js → index-DUJ50AjE.js} +160 -160
  11. package/dist/chunks/resource-management-panel-Ddyzqha7.js +11 -0
  12. package/dist/chunks/resource-management-panel-DpASGkNn.js +924 -0
  13. package/dist/chunks/{schedule-dashboard-D8ctQToc.js → schedule-dashboard-Dy7czCFY.js} +1 -1
  14. package/dist/chunks/{schedule-dashboard-CfeYnMXp.js → schedule-dashboard-e0SVfJ6s.js} +3 -3
  15. package/dist/chunks/use-click-outside-B9T3lmcw.js +1 -0
  16. package/dist/chunks/use-click-outside-CMeO_QFI.js +16 -0
  17. package/dist/chunks/{use-visual-utils-BN4h1-xa.js → use-visual-utils-CFuV8lsO.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-CRA2-3Z2.js → use-visual-utils-CfCFNHJ6.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +4 -4
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +1 -1
  26. package/package.json +1 -1
  27. package/dist/chunks/dashboard-controls-DKci3my0.js +0 -26
  28. package/dist/chunks/resource-management-panel-BQVERuRi.js +0 -11
  29. package/dist/chunks/resource-management-panel-DNpbhYNu.js +0 -982
  30. package/dist/chunks/use-local-storage-state-CWjTT77L.js +0 -26
  31. package/dist/chunks/use-local-storage-state-DXYWw213.js +0 -1
@@ -0,0 +1,11 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("./index-DUJ50AjE.js"),m=require("react"),ae=require("./use-visual-utils-CFuV8lsO.js"),le=require("./use-click-outside-B9T3lmcw.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 de=s.createLucideIcon("ChartSpline",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]]);/**
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 ce=s.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 ie(){return e.jsx(s.ScrollArea,{className:"w-full flex-1",children:e.jsxs("div",{className:"space-y-4 px-4 py-2",children:[e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"h-9 w-full rounded bg-muted animate-pulse"}),e.jsx("div",{className:"space-y-3 pt-2",children:[...Array(3)].map((t,f)=>e.jsxs("div",{className:"flex gap-3 animate-pulse",children:[e.jsx("div",{className:"h-8 w-8 rounded bg-muted flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-1.5",children:[e.jsx("div",{className:"h-4 w-2/3 rounded bg-muted"}),e.jsx("div",{className:"h-3 w-4/5 rounded bg-muted"})]})]},f))})]})})}const ue=t=>{const f=s.useDashboardStore(a=>a.isVisualEditing),p=s.useDashboardStore(a=>a.selectedFrameId),l=s.useEditorStore(a=>a.frame);return!!(f&&p&&(l==null?void 0:l.visualId)===t)};function he({visual:t,isDeleting:f,isDuplicating:p,onAddVisual:l,onOpenVisual:a,onEditDetails:g,onDeleteClick:D,onDuplicateVisual:x,onShareVisual:N,formatDate:C}){var U,y,L,P;const{selectVisual:h}=s.useManagementActions(),o=s.useIsVisualSelected(t.id),d=ue(t.id),{isConsoleMode:T}=s.useDashboardPreferences(),A=m.useRef(null),[w,v]=m.useState(!1),[V,S]=m.useState(!1);m.useEffect(()=>{p?(v(!0),S(!0)):V&&(v(!1),S(!1))},[p,V]),m.useEffect(()=>{d&&A.current&&A.current.scrollIntoView({behavior:"smooth",block:"center"})},[d]);const E=()=>e.jsx(de,{className:"h-4 w-4"}),R=()=>{h(t),a==null||a(t)};return e.jsx(s.Card,{ref:A,className:s.cn("group cursor-pointer border border-border/50 p-2 shadow-none transition-colors hover:bg-muted/50",d?"border-purple-500/50 bg-purple-500/10":o&&"border-primary/50 bg-muted/30"),onClick:R,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded bg-muted p-1.5",children:E()}),e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"truncate text-sm font-medium text-foreground",title:t.title||"Untitled Visual",children:t.title||"Untitled Visual"}),t.ownership.status==="shared"&&e.jsxs(s.Badge,{variant:"outline",className:"text-xs",children:[e.jsx(s.Users,{className:"mr-1 h-2.5 w-2.5"}),"Shared"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"line-clamp-2 flex-1 text-xs text-muted-foreground",title:t.description||"No description",children:(U=t.description)!=null&&U.trim()?t.description:"No description"}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{className:s.cn("invisible flex items-center gap-1 transition-opacity duration-150 group-hover:visible",o&&"visible"),children:[t.ownership.isOwner&&e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",onClick:c=>{c.stopPropagation(),g==null||g(t)},title:"Edit details",children:e.jsx(s.PenLine,{className:"h-3 w-3"})}),e.jsxs(s.DropdownMenu,{modal:!1,open:w,onOpenChange:v,children:[e.jsx(s.DropdownMenuTrigger,{asChild:!0,children:e.jsx(s.Button,{size:"sm",variant:"ghost",className:"h-6 w-6 p-0",children:e.jsx(s.Ellipsis,{className:"h-3 w-3"})})}),e.jsxs(s.DropdownMenuContent,{align:"end",className:"z-[51] w-40",children:[e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),l(t)},children:[e.jsx(s.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),a==null||a(t)},children:[e.jsx(ce,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.preventDefault(),c.stopPropagation(),x(t.id)},disabled:p,children:[p?e.jsx(s.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(s.Copy,{className:"mr-2 h-3 w-3"}),p?"Duplicating...":"Duplicate"]}),t.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),g==null||g(t)},children:[e.jsx(s.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),N(t)},children:[e.jsx(s.Users,{className:"mr-2 h-3 w-3"}),"Share"]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs(s.DropdownMenuItem,{onClick:c=>{c.stopPropagation(),D(t)},className:"text-destructive",disabled:f,children:[e.jsx(s.Trash2,{className:"mr-2 h-3 w-3"}),f?"Deleting...":"Delete"]})]}),e.jsx(s.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs text-slate-500 dark:text-slate-400",children:[(((y=t.ownership.createdBy)==null?void 0:y.type)==="tenant"||((L=t.ownership.createdBy)==null?void 0:L.type)==="organization"&&T)&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=t.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(s.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:C(t.lastModified)})]})]})]})]})]}),e.jsx(s.IconButton,{tooltip:"Add to dashboard",buttonProps:{variant:"outline",size:"sm",onClick:c=>{c.stopPropagation(),l(t)}},className:"h-6 px-2",children:e.jsx(s.Plus,{className:"h-3.5 w-3.5"})})]})]})]})]})},t.id)}function me({searchQuery:t}){const[f,p]=m.useState(!1),[l,a]=m.useState(null),[g,D]=m.useState(!1),[x,N]=m.useState(null),[C,h]=m.useState(null),[o,d]=m.useState(null),{selectVisual:T}=s.useManagementActions(),{handleEditLibraryVisual:A,handleAddLibraryVisual:w}=ae.useVisualUtils(),{resources:v,isLoading:V,isError:S,updateResource:E,deleteResource:R,duplicateResource:U,isDeleting:y}=s.useVisualManagement(()=>{D(!1),N(null)});s.useCurrentUserInfo();const L=v.filter(r=>{var b,i;return((b=r==null?void 0:r.title)==null?void 0:b.toLowerCase().includes(t.toLowerCase()))||((i=r==null?void 0:r.description)==null?void 0:i.toLowerCase().includes(t.toLowerCase()))}),P=r=>new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),c=r=>{N(r),D(!0)},z=()=>{x&&R(x.id)},{startUpdating:q,stopUpdating:H,isUpdating:M}=s.useResourceUpdateState(),j=(r,b,i)=>{var Y;const _=Object.fromEntries(Object.entries(b).filter(([,O])=>O!==void 0));if(Object.keys(_).length===0){(Y=i==null?void 0:i.onSuccess)==null||Y.call(i);return}const W=Object.keys(_),K=W.length===1?W[0]:void 0;q(r,K),E({resourceId:r,data:_},{onSuccess:()=>{var O;H(r,K),(O=i==null?void 0:i.onSuccess)==null||O.call(i)},onError:()=>{var O;H(r,K),(O=i==null?void 0:i.onError)==null||O.call(i)}})},B=r=>{h(r),U(r,{onSettled:()=>h(null)})},J=r=>{A(r)},G=r=>{w(r)},Q=r=>{const b=v.find(i=>i.id===r);b&&E({resourceId:r,data:{isPrivate:!b.isPrivate}})},X=r=>{a(r),p(!0)},Z=r=>{d(r)},$=()=>{d(null)},k=({title:r,description:b})=>{if(!o)return;const i={};r!==o.title&&(i.title=r),(o.description||"")!==b&&(i.description=b),j(o.id,i,{onSuccess:()=>{d(null)}})};return V?e.jsx(ie,{}):S?e.jsx(s.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(s.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:L.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.Grid3x3,{className:"mx-auto h-12 w-12 text-muted-foreground/50"})}),e.jsx("h3",{className:"mb-1 font-medium text-foreground",children:t?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t?"Try adjusting your search":'Click "Create" above to add your first visual'})]}):L.map(r=>e.jsx(he,{visual:r,onAddVisual:G,onOpenVisual:J,onEditDetails:Z,onDeleteClick:c,onDuplicateVisual:B,onTogglePrivacy:Q,onShareVisual:X,isDeleting:y,isDuplicating:C===r.id,formatDate:P},r.id))}),f&&l&&e.jsx(s.ShareDialog,{resource:l,resourceType:s.ResourceType.VISUAL,onClose:()=>{p(!1),a(null)}}),o&&e.jsx(s.ResourceEditDialog,{open:!!o,resourceLabel:"Visual",initialTitle:o.title||"",initialDescription:o.description||"",onClose:$,onSave:k,isSaving:M(o.id)}),e.jsx(s.AlertDialog,{open:g,onOpenChange:r=>{!r&&y||(D(r),r||N(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Visual"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',x==null?void 0:x.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:y,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:r=>{r.preventDefault(),r.stopPropagation(),z()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:y,children:[y?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),y?"Deleting...":"Delete"]})]})]})})]})}function xe({dashboard:t,isDeleting:f,isDuplicating:p,onLoadDashboard:l,onEditDetails:a,onDeleteClick:g,onDuplicateDashboard:D,onShareDashboard:x,formatDate:N,onDashboardItemClick:C}){var S,E;const{selectDashboard:h}=s.useManagementActions(),o=s.useIsDashboardSelected(t.id),{userContext:d,isLoading:T}=s.useCurrentUserInfo(),A=((S=d==null?void 0:d.permissions)==null?void 0:S.canEdit)??!1,w=T||!A,v=()=>e.jsx(s.LayoutDashboard,{className:"h-4 w-4"}),V=()=>{h(t),l(t.id),C==null||C(t.id)};return e.jsx(s.Card,{className:s.cn("group cursor-pointer border border-border/50 p-2 shadow-none transition-colors hover:bg-muted/50",o&&"border-primary/50 bg-muted/30"),onClick:V,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"mt-0.5 rounded bg-muted p-1.5",children:v()}),e.jsxs("div",{className:"min-w-0 flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",title:t.title||"Untitled Dashboard",children:t.title||"Untitled Dashboard"}),t.ownership.status==="shared"&&e.jsxs(s.Badge,{variant:"outline",className:"text-xs",children:[e.jsx(s.Users,{className:"mr-1 h-2.5 w-2.5"}),"Shared"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2 flex-1",title:t.description||"No description",children:(E=t.description)!=null&&E.trim()?t.description:"No description"}),e.jsx(s.DashboardActionsMenu,{dashboard:t,isDeleting:f,isDuplicating:p,shouldHideActions:w,onEditDetails:a,onDeleteClick:g,onDuplicateDashboard:D,onShareDashboard:x,formatDate:N})]})]})]})},t.id)}function pe({onRetry:t}){return e.jsx(s.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(s.Button,{variant:"outline",size:"sm",className:"mt-2",onClick:t,children:"Retry"})]})})}function ge(t){var te;const{searchQuery:f,onLoadDashboard:p,onEditDashboard:l,onDashboardItemClick:a}=t,[g,D]=m.useState(!1),[x,N]=m.useState(null),[C,h]=m.useState(!1),[o,d]=m.useState(null),[T,A]=m.useState(null),[w,v]=m.useState(null),V=s.useManagementStore(n=>n.lastSelectedDashboard),S=s.useManagementStore(n=>n.selectedDashboard),E=s.useManagementStore(n=>n.actions.selectDashboard),R=s.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:U,id:y}=s.useSemaphorContext();s.useRoleAwareDisplayPreferences();const{resources:L,isLoading:P,isError:c,updateResource:z,deleteResource:q,duplicateResource:H,isDeleting:M}=s.useDashboardManagement(()=>{h(!1);const n=o==null?void 0:o.id;d(null),(S==null?void 0:S.id)===n&&(!(U!=null&&U.dashboard_id)&&!y?R():V&&V.id!==n&&E(V))}),{currentUser:j,userContext:B}=s.useCurrentUserInfo(),J=((te=B==null?void 0:B.permissions)==null?void 0:te.canCreateDashboard)??!1,G=L.filter(n=>{var I,u;return((I=n==null?void 0:n.title)==null?void 0:I.toLowerCase().includes(f.toLowerCase()))||((u=n==null?void 0:n.description)==null?void 0:u.toLowerCase().includes(f.toLowerCase()))}),Q=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),X=n=>{p==null||p(n)},Z=n=>{d(n),h(!0)},$=()=>{o&&q(o.id)},k=n=>{A(n),H(n,{onSettled:()=>A(null)})},{startUpdating:r,stopUpdating:b,isUpdating:i}=s.useResourceUpdateState(),_=(n,I,u)=>{var re;const ee=Object.fromEntries(Object.entries(I).filter(([,F])=>F!==void 0));if(Object.keys(ee).length===0){(re=u==null?void 0:u.onSuccess)==null||re.call(u);return}const ne=Object.keys(ee),se=ne.length===1?ne[0]:void 0;r(n,se),z({resourceId:n,data:ee},{onSuccess:()=>{var F;b(n,se),(F=u==null?void 0:u.onSuccess)==null||F.call(u)},onError:()=>{var F;b(n,se),(F=u==null?void 0:u.onError)==null||F.call(u)}})},W=n=>{const I=L.find(u=>u.id===n);I&&z({resourceId:n,data:{isPrivate:!I.isPrivate}})},K=n=>{N(n),j==null||j.type,D(!0)},Y=n=>{l==null||l(n.id),v(n)},O=()=>{v(null)},oe=({title:n,description:I})=>{if(!w)return;const u={};n!==w.title&&(u.title=n),(w.description||"")!==I&&(u.description=I),_(w.id,u,{onSuccess:()=>{v(null)}})};return P?e.jsx(ie,{}):c?e.jsx(pe,{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:G.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx("div",{className:"mb-3",children:e.jsx(s.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":J?'Click "Create" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):G.map(n=>e.jsx(xe,{dashboard:n,isDeleting:M,isDuplicating:T===n.id,onLoadDashboard:X,onEditDetails:Y,onDeleteClick:Z,onDuplicateDashboard:k,onTogglePrivacy:W,onShareDashboard:K,formatDate:Q,onDashboardItemClick:a},n.id))}),g&&x&&e.jsx(s.ShareDialog,{resource:x,resourceType:s.ResourceType.DASHBOARD,onClose:()=>{D(!1),N(null)}}),e.jsx(s.AlertDialog,{open:C,onOpenChange:n=>{!n&&M||(h(n),n||d(null))},children:e.jsxs(s.AlertDialogContent,{children:[e.jsxs(s.AlertDialogHeader,{children:[e.jsx(s.AlertDialogTitle,{children:"Delete Dashboard"}),e.jsxs(s.AlertDialogDescription,{children:['Are you sure you want to delete "',o==null?void 0:o.title,'"? This action cannot be undone.']})]}),e.jsxs(s.AlertDialogFooter,{children:[e.jsx(s.AlertDialogCancel,{disabled:M,children:"Cancel"}),e.jsxs(s.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),$()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:M,children:[M?e.jsx(s.LoaderCircle,{className:"mr-2 h-3.5 w-3.5 animate-spin"}):e.jsx(s.Trash2,{className:"mr-2 h-3.5 w-3.5"}),M?"Deleting...":"Delete"]})]})]})}),w&&e.jsx(s.ResourceEditDialog,{open:!!w,resourceLabel:"Dashboard",initialTitle:w.title||"",initialDescription:w.description||"",onClose:O,onSave:oe,isSaving:i(w.id)})]})}function fe({open:t,onOpenChange:f,onSubmit:p,isCreating:l}){const[a,g]=m.useState(""),[D,x]=m.useState("");m.useEffect(()=>{t||(g(""),x(""))},[t]);const N=()=>{a.trim()&&p({title:a,description:D})},C=h=>{f(h)};return e.jsx(s.Dialog,{open:t,onOpenChange:C,children:e.jsxs(s.DialogContent,{children:[e.jsxs(s.DialogHeader,{children:[e.jsx(s.DialogTitle,{children:"Create New Visual"}),e.jsx(s.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(s.Label,{htmlFor:"title",children:"Visual Title"}),e.jsx(s.Input,{id:"title",placeholder:"Enter visual title...",value:a,onChange:h=>g(h.target.value),disabled:l,onKeyDown:h=>{h.key==="Enter"&&!h.shiftKey&&(h.preventDefault(),N())}})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(s.Label,{htmlFor:"description",children:"Description (optional)"}),e.jsx(s.Input,{id:"description",placeholder:"Enter visual description...",value:D,onChange:h=>x(h.target.value),disabled:l})]})]}),e.jsxs(s.DialogFooter,{children:[e.jsx(s.Button,{variant:"outline",onClick:()=>C(!1),disabled:l,children:"Cancel"}),e.jsx(s.Button,{onClick:N,disabled:!a.trim()||l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(s.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function je({isOpen:t,onClose:f,className:p,onDashboardItemClick:l,variant:a="inline"}){var M;const g=s.useDashboardStore(j=>j.isDashboardEditing),[D,x]=m.useState(!1),[N,C]=m.useState(""),[h,o]=m.useState(!1),{currentUser:d,userContext:T}=s.useCurrentUserInfo(),A=((M=T==null?void 0:T.permissions)==null?void 0:M.canCreateDashboard)??!1,{onCreateSuccess:w}=s.useDashboardCreation({onDashboardSelect:l}),{selectVisual:v}=s.useManagementActions(),{handleEditLibraryVisual:V}=ae.useVisualUtils(),{createResource:S,isCreating:E,refetch:R}=s.useDashboardManagement(),{createResource:U,isCreating:y}=s.useVisualManagement(void 0,j=>{x(!1),j&&(v(j),V(j))}),L=a==="overlay",P=le.useClickOutside(f,{enabled:t&&L}),c=s.cn("flex h-full flex-col border-r bg-background",L?s.cn("absolute inset-y-0 left-0 z-[51] w-96 shadow-lg transition-transform duration-300 ease-in-out",t?"translate-x-0":"pointer-events-none -translate-x-full"):"w-full max-w-[28rem] min-w-[18rem] overflow-hidden shadow-sm",p),z=j=>{},q=j=>{console.log("Editing dashboard:",j)},H=j=>{S(j,{onSuccess:B=>{x(!1),w(B,R)}})};return e.jsx(s.TooltipProvider,{children:(!L||t)&&e.jsxs("div",{ref:P,className:c,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.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"whitespace-nowrap pl-2 text-sm font-semibold",children:g?"Library Visuals":"Dashboards"}),e.jsx(s.Button,{size:"sm",variant:"ghost",onClick:()=>o(!h),className:"h-8 w-8 p-0",children:e.jsx(s.Search,{className:"h-3.5 w-3.5 text-muted-foreground"})})]}),e.jsx("div",{className:"flex items-center gap-2",children:(g||A)&&e.jsxs(s.Button,{size:"sm",variant:"ghost",className:"h-8 whitespace-nowrap px-3",onClick:()=>x(!0),children:[e.jsx(s.Plus,{className:"mr-1 h-4 w-4"}),"Create"]})})]}),h&&e.jsx("div",{className:"bg-muted/30 px-4 pb-3",children:e.jsx(s.Input,{placeholder:"Search...",value:N,onChange:j=>C(j.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-4 py-4",children:g?e.jsx(me,{searchQuery:N}):e.jsx(ge,{searchQuery:N,onLoadDashboard:z,onEditDashboard:q,onDashboardItemClick:l})}),d&&e.jsx("div",{className:"border-t border-border px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{asChild:!0,children:e.jsx("div",{className:"flex h-8 w-8 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-sm font-medium text-primary",children:d.name.charAt(0).toUpperCase()})})}),e.jsx(s.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"font-medium",children:d.name}),e.jsx("div",{className:"text-xs text-muted-foreground",children:d.email}),d.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role:"," ",s.toTitleCase(d.role.replace(/_/g," "))]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["ID: ",d.id]})]})})]}),e.jsx("span",{className:"truncate text-sm font-medium text-foreground",children:d.name})]})}),g?e.jsx(fe,{open:D,onOpenChange:x,onSubmit:U,isCreating:y}):e.jsx(s.CreateDashboardDialog,{open:D,onOpenChange:x,onSubmit:H,isCreating:E})]})})}exports.ResourceManagementPanel=je;