react-semaphor 0.1.301 → 0.1.303

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 (66) hide show
  1. package/dist/appearance/index.cjs +1 -0
  2. package/dist/appearance/index.js +9 -0
  3. package/dist/brand-studio/index.cjs +21 -0
  4. package/dist/brand-studio/index.js +1461 -0
  5. package/dist/chunks/dashboard-controls-BCJZOzrL.js +2226 -0
  6. package/dist/chunks/dashboard-controls-CVFoOPti.js +47 -0
  7. package/dist/chunks/dashboard-filter-controls-button-C-e7230k.js +11 -0
  8. package/dist/chunks/{dashboard-filter-controls-button-DjALRkvg.js → dashboard-filter-controls-button-Cfbac4Jw.js} +205 -216
  9. package/dist/chunks/dashboard-json-BM5ywMgp.js +1 -0
  10. package/dist/chunks/{dashboard-json-D-zIG46N.js → dashboard-json-BzvLPhGM.js} +14 -12
  11. package/dist/chunks/dashboard-summary-settings-dialog-BdxKl1UF.js +1 -0
  12. package/dist/chunks/{dashboard-summary-settings-dialog-D-F1eEJI.js → dashboard-summary-settings-dialog-ChK3344r.js} +64 -63
  13. package/dist/chunks/date-formatter-D9Bvw5Qk.js +1 -0
  14. package/dist/chunks/date-formatter-DyIOb6uC.js +333 -0
  15. package/dist/chunks/{edit-dashboard-visual-BjflrL8w.js → edit-dashboard-visual-D725CWD5.js} +6690 -6679
  16. package/dist/chunks/edit-dashboard-visual-nNaZ2IK1.js +183 -0
  17. package/dist/chunks/index-BWjB_9uz.js +1356 -0
  18. package/dist/chunks/index-CJdxSyQq.js +2578 -0
  19. package/dist/chunks/{index-DDA12yqV.js → index-CYWgnME0.js} +48994 -66425
  20. package/dist/chunks/index-D7KJindZ.js +1 -0
  21. package/dist/chunks/index-DFOb_6HB.js +1657 -0
  22. package/dist/chunks/index-DRlMUglg.js +4 -0
  23. package/dist/chunks/palette-B9DJXMGo.js +11 -0
  24. package/dist/chunks/palette-DGOzbtsn.js +43 -0
  25. package/dist/chunks/{resource-management-panel-B2558XA1.js → resource-management-panel-CE0-NcLL.js} +116 -115
  26. package/dist/chunks/resource-management-panel-mJmc5dMT.js +6 -0
  27. package/dist/chunks/rotate-ccw-Bs7YJn10.js +6 -0
  28. package/dist/chunks/rotate-ccw-YsjQwpKm.js +14 -0
  29. package/dist/chunks/save-Bj1y1rug.js +6 -0
  30. package/dist/chunks/save-CUrexoNl.js +21 -0
  31. package/dist/chunks/switch-CiEX68py.js +163 -0
  32. package/dist/chunks/switch-oojO-gal.js +19730 -0
  33. package/dist/chunks/{use-create-flow-overlay-state-BUw_JtLs.js → use-create-flow-overlay-state-BHDKxe7I.js} +396 -412
  34. package/dist/chunks/use-create-flow-overlay-state-D2I2wNey.js +16 -0
  35. package/dist/chunks/{use-visual-utils-C45OxsOf.js → use-visual-utils-CjFzlR0P.js} +54 -53
  36. package/dist/chunks/use-visual-utils-DYDXMl5v.js +1 -0
  37. package/dist/dashboard/index.cjs +1 -1
  38. package/dist/dashboard/index.js +1 -1
  39. package/dist/format-utils/index.cjs +1 -1
  40. package/dist/format-utils/index.js +2 -2
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +210 -207
  43. package/dist/style.css +1 -1
  44. package/dist/surfboard/index.cjs +1 -1
  45. package/dist/surfboard/index.js +2 -2
  46. package/dist/types/appearance.d.ts +176 -0
  47. package/dist/types/brand-studio.d.ts +245 -0
  48. package/dist/types/dashboard.d.ts +134 -0
  49. package/dist/types/main.d.ts +142 -1
  50. package/dist/types/surfboard.d.ts +134 -0
  51. package/dist/types/types.d.ts +139 -0
  52. package/package.json +13 -1
  53. package/dist/chunks/braces-Bhqo4iW1.js +0 -23
  54. package/dist/chunks/braces-BwK7fWd_.js +0 -6
  55. package/dist/chunks/dashboard-controls-BIRiWCUK.js +0 -47
  56. package/dist/chunks/dashboard-controls-DIlnYo96.js +0 -2219
  57. package/dist/chunks/dashboard-filter-controls-button-CK1-mKQh.js +0 -11
  58. package/dist/chunks/dashboard-json-DK4mQ1gS.js +0 -1
  59. package/dist/chunks/dashboard-summary-settings-dialog-DSxNqxFI.js +0 -1
  60. package/dist/chunks/date-formatter-CqXdM6JO.js +0 -1
  61. package/dist/chunks/date-formatter-vkCj9Ct-.js +0 -1982
  62. package/dist/chunks/edit-dashboard-visual-DCsrtJr_.js +0 -193
  63. package/dist/chunks/index-8GnvL1_L.js +0 -1523
  64. package/dist/chunks/resource-management-panel-CKp4_aem.js +0 -6
  65. package/dist/chunks/use-create-flow-overlay-state-CWcCdPbC.js +0 -21
  66. package/dist/chunks/use-visual-utils-DyaThRzf.js +0 -1
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-8GnvL1_L.js"),h=require("react"),ne=require("./use-visual-utils-DyaThRzf.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 ae=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 ie(s,m={}){const{enabled:p=!0,eventType:l="mousedown"}=m,i=h.useRef(null);return h.useEffect(()=>{const x=w=>{const r=w.target;i.current&&i.current.contains(r)||r instanceof Element&&(r.closest("[data-radix-popper-content-wrapper]")||r.closest("[data-radix-select-content]")||r.closest("[data-radix-popover-content]")||r.closest("[data-radix-dropdown-menu-content]")||r.closest("[data-radix-tooltip-content]")||r.closest('[role="listbox"]')||r.closest('[role="option"]')||r.closest('[role="combobox"]'))||r instanceof Element&&r.hasAttribute("data-radix-")||s()};return p&&document.addEventListener(l,x),()=>{document.removeEventListener(l,x)}},[s,p,l]),i}function oe(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,m)=>e.jsxs("div",{className:"flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",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"})]})]},m))})}const le=s=>{const m=t.useDashboardStore(i=>i.isVisualEditing),p=t.useDashboardStore(i=>i.selectedFrameId),l=t.useEditorStore(i=>i.frame);return!!(m&&p&&(l==null?void 0:l.visualId)===s)};function de({visual:s,isDeleting:m,isDuplicating:p,onAddVisual:l,onOpenVisual:i,onEditDetails:x,onDeleteClick:w,onDuplicateVisual:r,onShareVisual:N,formatDate:b}){var O,T,U,P;const{selectVisual:f}=t.useManagementActions(),d=t.useIsVisualSelected(s.id),u=le(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),j=h.useRef(null),[S,v]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{p?(v(!0),L(!0)):E&&(v(!1),L(!1))},[p,E]),h.useEffect(()=>{u&&j.current&&j.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const C=()=>{f(s),i==null||i(s)},y=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),C())};return e.jsxs("div",{ref:j,className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",u?"bg-muted ring-1 ring-inset ring-foreground/20":d&&"bg-muted"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:y,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Visual",children:s.title||"Untitled Visual"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex shrink-0 items-center transition-opacity",d||u||S?"pointer-events-auto opacity-100":"pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"),onClick:a=>a.stopPropagation(),children:e.jsxs("div",{className:"inline-flex h-7 items-stretch overflow-hidden rounded-[5px] border border-border/60 bg-background",children:[e.jsxs(t.Button,{size:"xs",variant:"ghost",className:"h-full rounded-none border-0 shadow-none hover:bg-accent/50",disabled:A,onClick:a=>{a.stopPropagation(),l(s)},"aria-label":`Add ${s.title||"visual"}`,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenu,{modal:!1,open:S,onOpenChange:v,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"xs",variant:"ghost",className:"h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3.5 w-3.5"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-[6px] border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),l(s)},disabled:A,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ae,{className:"h-3.5 w-3.5"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),r(s.id)},disabled:p,children:[p?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Copy,{className:"h-3.5 w-3.5"}),p?"Duplicating…":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),x==null||x(s)},children:[e.jsx(t.PenLine,{className:"h-3.5 w-3.5"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),N(s)},children:[e.jsx(t.Users,{className:"h-3.5 w-3.5"}),"Share"]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),w(s)},className:"text-destructive focus:bg-destructive/10 focus:text-destructive",disabled:m,children:[e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),m?"Deleting…":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground",children:[(((T=s.ownership.createdBy)==null?void 0:T.type)==="tenant"||((U=s.ownership.createdBy)==null?void 0:U.type)==="organization"&&R)&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.User,{className:"h-3 w-3"}),e.jsx("span",{children:((P=s.ownership.createdBy)==null?void 0:P.name)||"Unknown"})]}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:b(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[m,p]=h.useState(!1),[l,i]=h.useState(null),[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(null),[d,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=ne.useVisualUtils(),{resources:j,isLoading:S,isError:v,updateResource:E,deleteResource:L,duplicateResource:C,isDeleting:y}=t.useVisualManagement(()=>{w(!1),N(null)}),O=j.filter(o=>{var M,c;return((M=o==null?void 0:o.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((c=o==null?void 0:o.description)==null?void 0:c.toLowerCase().includes(s.toLowerCase()))}),T=o=>new Date(o).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=o=>{N(o),w(!0)},P=()=>{r&&L(r.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(o,M,c)=>{var Q;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(Q=c==null?void 0:c.onSuccess)==null||Q.call(c);return}const D=Object.keys(B),H=D.length===1?D[0]:void 0;a(o,H),E({resourceId:o,data:B},{onSuccess:()=>{var I;_(o,H),(I=c==null?void 0:c.onSuccess)==null||I.call(c)},onError:()=>{var I;_(o,H),(I=c==null?void 0:c.onError)==null||I.call(c)}})},G=o=>{f(o),C(o,{onSettled:()=>f(null)})},z=o=>{A(o)},W=o=>{R(o)},X=o=>{i(o),p(!0)},Y=o=>{u(o)},$=()=>{u(null)},J=({title:o,description:M})=>{if(!d)return;const c={};o!==d.title&&(c.title=o),(d.description||"")!==M&&(c.description=M),V(d.id,c,{onSuccess:()=>{u(null)}})};return S?e.jsx(oe,{}):v?e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx("p",{className:"text-[12px] text-destructive",children:"Failed to load visuals"}),e.jsx(t.Button,{variant:"outline",size:"xs",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-0.5 overflow-y-auto",children:O.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.Grid3x3,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:s?"No visuals found":"No visuals yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:s?"Try adjusting your search.":'Click "New" above to add your first visual.'})]}):O.map(o=>e.jsx(de,{visual:o,onAddVisual:W,onOpenVisual:z,onEditDetails:Y,onDeleteClick:U,onDuplicateVisual:G,onShareVisual:X,isDeleting:y,isDuplicating:b===o.id,formatDate:T},o.id))}),m&&l&&e.jsx(t.ShareDialog,{resource:l,resourceType:t.ResourceType.VISUAL,onClose:()=>{p(!1),i(null)}}),d&&e.jsx(t.ResourceEditDialog,{open:!!d,resourceLabel:"Visual",initialTitle:d.title||"",initialDescription:d.description||"",onClose:$,onSave:J,isSaving:F(d.id)}),e.jsx(t.AlertDialog,{open:x,onOpenChange:o=>{!o&&y||(w(o),o||N(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 "',r==null?void 0:r.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:y,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:o=>{o.preventDefault(),o.stopPropagation(),P()},disabled:y,children:[y?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),y?"Deleting…":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:m,isDuplicating:p,onLoadDashboard:l,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N,onDashboardItemClick:b}){var E,L;const{selectDashboard:f}=t.useManagementActions(),d=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,j=A||!R,S=()=>{f(s),l(s.id),b==null||b(s.id)},v=C=>{C.currentTarget===C.target&&(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),S())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-1 rounded-[5px] px-2 py-1.5 transition-colors hover:bg-muted/50 focus-within:bg-muted/50",d&&"bg-muted"),onClick:S,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:v,children:[e.jsx("p",{className:"truncate text-[13px] font-medium leading-5 text-foreground",title:s.title||"Untitled Dashboard",children:s.title||"Untitled Dashboard"}),e.jsx("p",{className:"truncate text-[11px] leading-4 text-muted-foreground",title:s.description||"No description",children:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("shrink-0 transition-opacity",d?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:m,isDuplicating:p,shouldHideActions:j,onEditDetails:i,onDeleteClick:x,onDuplicateDashboard:w,onShareDashboard:r,formatDate:N})})]})}function he({onRetry:s}){return e.jsx(t.ScrollArea,{className:"w-full flex-1 pr-2",children:e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 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 xe(s){var ee;const{searchQuery:m,onLoadDashboard:p,onEditDashboard:l,onDashboardItemClick:i}=s,[x,w]=h.useState(!1),[r,N]=h.useState(null),[b,f]=h.useState(!1),[d,u]=h.useState(null),[A,R]=h.useState(null),[j,S]=h.useState(null),v=t.useManagementStore(n=>n.lastSelectedDashboard),E=t.useManagementStore(n=>n.selectedDashboard),L=t.useManagementStore(n=>n.actions.selectDashboard),C=t.useManagementStore(n=>n.actions.clearSelectedDashboard),{tokenProps:y,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{f(!1);const n=d==null?void 0:d.id;u(null),(E==null?void 0:E.id)===n&&(!(y!=null&&y.dashboard_id)&&!O?C():v&&v.id!==n&&L(v))}),{userContext:G}=t.useCurrentUserInfo(),z=((ee=G==null?void 0:G.permissions)==null?void 0:ee.canCreateDashboard)??!1,W=T.filter(n=>{var K,g;return((K=n==null?void 0:n.title)==null?void 0:K.toLowerCase().includes(m.toLowerCase()))||((g=n==null?void 0:n.description)==null?void 0:g.toLowerCase().includes(m.toLowerCase()))}),X=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),Y=n=>{p==null||p(n)},$=n=>{u(n),f(!0)},J=()=>{d&&_(d.id)},o=n=>{R(n),F(n,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:c,isUpdating:B}=t.useResourceUpdateState(),D=(n,K,g)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=g==null?void 0:g.onSuccess)==null||se.call(g);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(n,k),a({resourceId:n,data:Z},{onSuccess:()=>{var q;c(n,k),(q=g==null?void 0:g.onSuccess)==null||q.call(g)},onError:()=>{var q;c(n,k),(q=g==null?void 0:g.onError)==null||q.call(g)}})},H=n=>{N(n),w(!0)},Q=n=>{l==null||l(n.id),S(n)},I=()=>{S(null)},re=({title:n,description:K})=>{if(!j)return;const g={};n!==j.title&&(g.title=n),(j.description||"")!==K&&(g.description=K),D(j.id,g,{onSuccess:()=>{S(null)}})};return U?e.jsx(oe,{}):P?e.jsx(he,{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-0.5 overflow-y-auto",children:W.length===0?e.jsxs("div",{className:"flex flex-col items-center gap-1.5 px-4 py-10 text-center",children:[e.jsx(t.ChartColumn,{className:"h-5 w-5 text-muted-foreground/60"}),e.jsx("h3",{className:"text-[13px] font-medium text-foreground",children:m?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:m?"Try adjusting your search.":z?'Click "New" above to add your first dashboard.':"No dashboards have been shared with you yet."})]}):W.map(n=>e.jsx(ue,{dashboard:n,isDeleting:V,isDuplicating:A===n.id,onLoadDashboard:Y,onEditDetails:Q,onDeleteClick:$,onDuplicateDashboard:o,onShareDashboard:H,formatDate:X,onDashboardItemClick:i},n.id))}),x&&r&&e.jsx(t.ShareDialog,{resource:r,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{w(!1),N(null)}}),e.jsx(t.AlertDialog,{open:b,onOpenChange:n=>{!n&&V||(f(n),n||u(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 "',d==null?void 0:d.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:n=>{n.preventDefault(),n.stopPropagation(),J()},disabled:V,children:[V?e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(t.Trash2,{className:"h-3.5 w-3.5"}),V?"Deleting…":"Delete"]})]})]})}),j&&e.jsx(t.ResourceEditDialog,{open:!!j,resourceLabel:"Dashboard",initialTitle:j.title||"",initialDescription:j.description||"",onClose:I,onSave:re,isSaving:B(j.id)})]})}function pe({open:s,onOpenChange:m,onSubmit:p,isCreating:l}){const[i,x]=h.useState(""),[w,r]=h.useState("");h.useEffect(()=>{s||(x(""),r(""))},[s]);const N=()=>{i.trim()&&p({title:i,description:w})},b=f=>{m(f)};return e.jsx(t.Dialog,{open:s,onOpenChange:b,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:i,onChange:f=>x(f.target.value),disabled:l,onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),N())}})]}),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:w,onChange:f=>r(f.target.value),disabled:l})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>b(!1),disabled:l,children:"Cancel"}),e.jsx(t.Button,{onClick:N,disabled:!i.trim()||l,children:l?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function me({isOpen:s,onClose:m,className:p,onDashboardItemClick:l,variant:i="inline"}){var c,B;const x=t.useDashboardStore(D=>D.isDashboardEditing),[w,r]=h.useState(!1),[N,b]=h.useState(""),[f,d]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((c=A==null?void 0:A.permissions)==null?void 0:c.canCreateDashboard)??!1,{onCreateSuccess:j}=t.useDashboardCreation({onDashboardSelect:l}),{selectVisual:S}=t.useManagementActions(),{handleEditLibraryVisual:v}=ne.useVisualUtils(),{createResource:E,isCreating:L,refetch:C}=t.useDashboardManagement(),{createResource:y,isCreating:O}=t.useVisualManagement(void 0,D=>{r(!1),D&&(S(D),v(D))}),T=i==="overlay",U=x?"New Visual":"New",P=x?"New Visual":"New Dashboard",a=x?"Search visuals...":"Search dashboards...",_=x?"Collapse visuals panel":"Collapse dashboard panel",F=((u==null?void 0:u.name)??"").trim(),V=((u==null?void 0:u.email)??"").trim(),z=F&&F.toLowerCase()!=="undefined"?F:V||"Current user",W=((B=z.charAt(0))==null?void 0:B.toUpperCase())||"?",X=V&&V.toLowerCase()!=="undefined"?V:"",Y=ie(m,{enabled:s&&T}),$=t.cn("flex h-full flex-col border-r border-border/60 bg-background",T?t.cn("absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden 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",p),J=D=>{},o=D=>{console.log("Editing dashboard:",D)},M=D=>{E(D,{onSuccess:H=>{r(!1),j(H,C)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:Y,className:$,children:[e.jsx("div",{className:"border-b border-border/60 bg-background",children:f?e.jsxs("div",{className:"flex h-10 items-center gap-1 px-3",children:[e.jsx(t.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsx("input",{autoFocus:!0,value:N,onChange:D=>b(D.target.value),onKeyDown:D=>{D.key==="Escape"&&(b(""),d(!1))},placeholder:a,className:"h-7 min-w-0 flex-1 bg-transparent text-[13px] text-foreground placeholder:text-muted-foreground focus:outline-none","aria-label":a}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>{b(""),d(!1)},"aria-label":"Close search",children:e.jsx(t.X,{className:"h-3.5 w-3.5"})})]}):e.jsxs("div",{className:"flex h-10 items-center justify-between gap-2 px-3",children:[e.jsx("h2",{className:"whitespace-nowrap text-[13px] font-medium text-foreground",children:x?"Visuals":"Dashboards"}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx(t.Button,{size:"xs",variant:"ghost",onClick:()=>d(!0),className:"w-7 px-0 text-muted-foreground hover:text-foreground","aria-label":"Search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(x||R)&&e.jsxs(t.Button,{size:"xs",variant:"outline",onClick:()=>r(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"xs",variant:"ghost",className:"w-7 px-0 text-muted-foreground hover:text-foreground",onClick:m,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]})}),e.jsx("div",{className:"flex flex-1 flex-col overflow-auto px-1.5 py-2",children:x?e.jsx(ce,{searchQuery:N}):e.jsx(xe,{searchQuery:N,onLoadDashboard:J,onEditDashboard:o,onDashboardItemClick:l})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 px-3 py-2",children:e.jsxs(t.Tooltip,{children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs("div",{className:"flex cursor-default items-center gap-2",children:[e.jsx("div",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-muted text-[10px] font-medium text-muted-foreground",children:W}),e.jsx("span",{className:"truncate text-[12px] text-muted-foreground",children:z})]})}),e.jsx(t.TooltipContent,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"space-y-0.5",children:[e.jsx("div",{className:"font-medium",children:z}),X&&e.jsx("div",{className:"text-[11px] opacity-80",children:X}),u.role&&e.jsxs("div",{className:"text-[11px] opacity-80",children:["Role:"," ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]})})}),x?e.jsx(pe,{open:w,onOpenChange:r,onSubmit:y,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:w,onOpenChange:r,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=me;
@@ -1,21 +0,0 @@
1
- "use strict";const t=require("./index-8GnvL1_L.js"),e=require("react/jsx-runtime"),v=require("react"),se=require("./use-visual-utils-DyaThRzf.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 Se=t.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
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 he=t.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
12
- * @license lucide-react v0.453.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const ge=t.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
17
- * @license lucide-react v0.453.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const re=t.createLucideIcon("Save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function ae(){var f,j;const l=t.useEditorStore(b=>b.card),a=t.useEditorStore(b=>b.frame),i=v.useMemo(()=>t.findCustomVisualConfigCard(a,l),[a,l]),{manifest:d}=t.useCustomVisual(((f=i==null?void 0:i.customCardPreferences)==null?void 0:f.url)||""),x=v.useMemo(()=>{var b;return(b=d==null?void 0:d.visuals)==null?void 0:b.find(p=>{var C;return p.name===((C=i==null?void 0:i.customCardPreferences)==null?void 0:C.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=t.resolveMultiInputType(i,x),h=v.useMemo(()=>t.getCustomVisualInputCards({frame:a,configCard:i,isMultiInputVisual:u==="multiple"}),[a,i,u]),y=v.useMemo(()=>{const b=h.findIndex(p=>(p==null?void 0:p.id)===l.id);return b<0?-1:t.getSlotIndexForCard(l,b)},[h,l]);return v.useMemo(()=>!i||u!=="multiple"||y<0?l.type:t.getEffectiveCardTypeForSlot(l,y,x==null?void 0:x.slots)??l.type,[i,u,y,l,x==null?void 0:x.slots])}function Ne({type:l,isLinked:a,className:i,showLabel:d=!1,showLocal:x=!1}){const u=t.useDashboardStore(S=>S.selectedFrameId),h=t.useManagementStore(S=>S.selectedVisual),y=t.useEditorStore(S=>S.frame);let f;if(l)f=l;else if(a!==void 0)f=a?"linked":"library";else if(!!!(y!=null&&y.visualId||h!=null&&h.id)&&u)f="local";else if(h&&!u)f="library";else if(y!=null&&y.visualId&&u)f="linked";else if(h!=null&&h.id&&u)f="library";else return null;if(f==="local"&&!x)return null;const j={local:"border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",linked:"border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",library:"border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},p={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},C={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},w={local:e.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:e.jsx(ge,{className:"h-3.5 w-3.5"}),library:e.jsx(he,{className:"h-3.5 w-3.5"})},k={local:"Local",linked:"Linked",library:"Library"};return e.jsx(t.TooltipProvider,{children:e.jsxs(t.Tooltip,{delayDuration:300,children:[e.jsx(t.TooltipTrigger,{asChild:!0,children:e.jsxs(t.Badge,{variant:"outline",className:t.cn("cursor-help select-none transition-all",j[f],i),children:[w[f],d&&e.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:k[f]})]})}),e.jsxs(t.TooltipContent,{side:"bottom",className:t.cn("max-w-xs",p[f]),children:[e.jsx(t.TooltipArrow,{className:C[f]}),e.jsx("p",{children:b[f]})]})]})})}function De(l,a){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:a?l.customCardPreferences:void 0,visualizationMode:"builtin",type:a?l.type:"bar"}}function le(l){const a=t.getDynamicFrameSaveIssue(l);return a?(t.ue.error(a),!1):!0}function Ee({className:l,variant:a="outline"}){const i=t.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=se.useVisualUtils();function x(){const u=d();le(u)&&(i==null||i(u))}return e.jsxs(t.Button,{onClick:x,className:l,size:"xs",variant:a,children:[e.jsx(t.Check,{className:"h-3.5 w-3.5"}),"Accept"]})}function we({className:l,variant:a="default"}){const i=t.useQueryClient(),[d,x]=v.useState(!1),u=t.useDashboardStore(C=>C.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=t.useDashboardActions(),{getUpdatedFrame:y}=se.useVisualUtils(),f=t.useSelectedVisual(),j=t.useEditorStore(C=>C.frame),b=t.useUpdateVisualMutation(),p=()=>{const C=y();if(!le(C))return;const w=(j==null?void 0:j.visualId)||(f==null?void 0:f.id);if(!w){t.ue.error("No visual to save");return}x(!0),b.mutate({visualId:w,data:{frameObject:C}},{onSuccess:()=>{x(!1),u(!0),t.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",w],exact:!0})},onError:()=>{x(!1),t.ue.error("Failed to update visual")}})};return e.jsx(t.Button,{onClick:p,className:l,size:"xs",variant:a,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving"]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save to Library"]})})}function Ve({className:l}){const a=t.useQueryClient(),[i,d]=v.useState(!1),x=t.useSelectedVisual(),u=t.useEditorStore(k=>k.frame),h=t.useDashboardStore(k=>k.selectedSheetId),y=t.useDashboardStore(k=>k.dashboard),{updateFrame:f,setIsVisualEditing:j}=t.useDashboardActions(),{getUpdatedFrame:b}=se.useVisualUtils(),p=t.useUpdateVisualMutation(),C=t.useResolveExistingFrameSemanticExecutionPayload(),w=async()=>{if(!h){t.ue.error("No sheet selected");return}const k=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!k){t.ue.error("No visual to update");return}d(!0);try{const S=b();if(!le(S)){d(!1);return}const F={...S,visualId:k},Q=t.findDashboardFrameById(y,F.id),R=await C(F,{previousFrame:Q});await p.mutateAsync({visualId:k,data:{frameObject:S}}),f(h,F,{semanticExecutionPayload:R}),a.invalidateQueries({queryKey:["visuals"]}),a.invalidateQueries({queryKey:["visual",k]}),t.ue.success("Saved to library and applied locally"),setTimeout(()=>{j(!1)},300)}catch(S){console.error("Failed to save and apply:",S),t.ue.error(S instanceof Error?S.message:"Failed to save and apply changes")}finally{d(!1)}};return e.jsx(t.Button,{onClick:w,className:l,size:"xs",variant:"default",disabled:i,children:i?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Saving..."]}):e.jsxs(e.Fragment,{children:[e.jsx(re,{className:"h-3.5 w-3.5"}),"Save & Apply"]})})}function Te({className:l}){const{setTempQueryData:a,setSqlGen:i}=t.useEditorActions(),d=t.useQueryClient(),x=t.useEditorStore(p=>p.tempQueryData),u=t.useEditorStore(p=>p.onClose),h=t.useEditorStore(p=>p.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f);function b(){if(x){const{queryKey:p,queryData:C}=x;p&&C&&d.setQueryData(p,C)}i({}),u==null||u()}return e.jsxs(t.Button,{onClick:b,className:l,size:"xs",variant:"outline",children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),"Close"]})}function Ie({label:l="Clear",variant:a="secondary",className:i}={}){const{setTempQueryData:d}=t.useEditorActions(),x=t.useQueryClient(),u=t.useEditorStore(_=>_.tempQueryData),h=t.useEditorStore(_=>_.card),y=ae(),f=v.useMemo(()=>y!==h.type?{...h,type:y}:h,[h,y]),{queryKey:j}=t.useEditorCardQuery(f),{setCardSql:b,setSqlGen:p,setCardPython:C,setCardCustomCfg:w,setCardPreferences:k,clearQueryConfig:S,setCardConfig:F,setCardType:Q,setFrame:R,setCard:$,setActiveTabCardId:U}=t.useEditorActions();function J(){var P,H,I,Y;const _=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:_}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),b(""),p({}),S(),F(void 0),C(""),w(""),k({});const r=t.useEditorStore.getState().frame,V=t.useEditorStore.getState().card,T=t.findCustomVisualConfigCard(r,V),q=((P=T==null?void 0:T.customCardPreferences)==null?void 0:P.visualType)==="multiple"||!!((H=T==null?void 0:T.customCardPreferences)!=null&&H.dataInputCardIds)||(((I=T==null?void 0:T.customCardPreferences)==null?void 0:I.minInputs)||0)>1||(((Y=T==null?void 0:T.customCardPreferences)==null?void 0:Y.maxInputs)||0)>1,A=De(V,q);R({...r,cards:r.cards.map(M=>M.id===A.id?A:M)}),U(A.id),$(A),q||Q("bar")}return e.jsxs(t.Button,{onClick:J,className:i,size:"xs",variant:a,children:[e.jsx(t.X,{className:"h-3.5 w-3.5"}),l]})}function be(l){const{control:a,onChange:i}=l;return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:a.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Fe(l){const{currentStep:a,labels:i}=l;return e.jsx("div",{className:"sticky top-0 z-10 -mx-1 border-b border-border/60 bg-background/95 px-1 pb-2.5 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:e.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-2.5",children:i.map((d,x)=>{const u=x+1,h=u===a,y=u<a;return e.jsxs(v.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:t.cn("flex h-5 w-5 items-center justify-center rounded-full border text-[10px] font-medium tabular-nums",h?"border-foreground bg-foreground text-background":y?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),e.jsx("span",{className:t.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?e.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function G(l){const{secondary:a,tertiary:i,primary:d}=l;return e.jsxs("div",{className:"sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85",children:[a,i,d]})}function Le(l){const{control:a,scope:i,detail:d}=l;return e.jsxs("div",{className:"flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5",children:[e.jsx(t.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),e.jsxs("div",{className:"min-w-0 space-y-0.5",children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:a.label}),e.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[t.getFriendlyTypeOption(a.type).label," ·"," ",t.getControlOptionPreview(a)," ·"," ",t.getPlacementLabel(i,a.placement)]}),d?e.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function me(l){const{control:a,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:y,onLabelChange:f,onDefaultValueChange:j,onBack:b,onNext:p,nextDisabled:C}=l;return e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:a,onChange:f}),e.jsx(t.ControlDefinitionOptionsEditor,{control:a,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:y}),e.jsx(t.ControlDefaultValueEditor,{control:a,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:b,children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:p,disabled:C,children:"Next"})})]})}const Be=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function xe(l){const{text:a,ariaLabel:i}=l,[d,x]=v.useState(!1);return e.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(a),x(!0),setTimeout(()=>x(!1),1200)}catch(u){console.error("Failed to copy",u)}},className:"group flex w-full items-center justify-between gap-2 rounded-[4px] bg-muted/40 px-2 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none",children:[e.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:a}),e.jsx("span",{className:"shrink-0 text-[11px] text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100",children:d?"Copied":"Click to copy"})]})}function fe(l){const{control:a,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:y,onCancel:f,onDone:j}=l,b=Be.has(a.type),p=d.match(/\[\[param\.(.+?)\]\]/),C=p?`{{ param('${p[1]}') }}`:"";return e.jsxs("div",{className:"space-y-4",children:[e.jsx(Le,{control:a,scope:i,detail:h}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),e.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60",children:[b?e.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,e.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),e.jsx(xe,{text:d,ariaLabel:"Copy SQL control reference"}),C?e.jsx(xe,{text:C,ariaLabel:"Copy Jinja control reference"}):null,e.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",e.jsx("a",{href:"https://docs.semaphor.cloud/docs/concepts/template-expressions",target:"_blank",rel:"noreferrer",className:"underline underline-offset-2 hover:text-foreground",children:"Template expressions docs"}),"."]})]})]})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),tertiary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:f,children:"Cancel"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function _e(l){const a=t.createBlankControl(l.scope,l.existingControls,l.reservedIds),i=l.type===a.type?{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}:{...t.applyControlTypeChange({controls:[{...a,label:t.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:a.id,nextType:l.type}).controls[0],label:t.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:i,defaultValue:t.getDefaultValueForType(i,void 0)}}function qe({scope:l,controls:a,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:y,availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:b,structuralParticipantIdsByControlId:p,card:C,allowedControlTypes:w,onCreateFlowActiveChange:k,onCreateFlowComplete:S}){const F=v.useMemo(()=>new Set(i||[]),[i]),Q=t.getPlacementOptionsForScope(l),R=t.getDefaultPlacement(l),[$,U]=v.useState(null),[J,_]=v.useState(null),[r,V]=v.useState(()=>h?{step:1,control:t.createBlankControl(l,a,Array.from(F))}:null),T=v.useRef({}),q=v.useRef(void 0),A=v.useRef(h),P=v.useMemo(()=>{const s=t.getFriendlyControlTypeOptions({scope:l,card:C});if(!w)return s;const o=new Set(w);return s.filter(n=>o.has(n.value))},[w,C,l]),H=v.useCallback(s=>{const o=t.getFriendlyControlTypeOptions({scope:l,card:C,includeType:w?void 0:s});if(!w)return o;const n=new Set(w);return o.filter(c=>n.has(c.value))},[w,C,l]),I=v.useCallback(s=>l==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[l]),Y=v.useMemo(()=>r?t.getEligibleParticipantsForStructuralControl(b||[],r.control.type):[],[r,b]),M=v.useMemo(()=>{if(!r)return{fields:f||[],metrics:j||[]};if(!I(r.control.type))return{fields:f||[],metrics:j||[]};const s=r.selectedCardIds||[],o=t.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:b||[],selectedCardIds:s});return{fields:r.control.type==="field_selector"?o.choices.map(n=>({option:n,target:o.fieldTargetMap[n.value]})):[],metrics:r.control.type==="metric_selector"?o.choices.map(n=>({option:n,target:o.metricTargetMap[n.value]})):[]}},[f,j,r,I,b]);v.useEffect(()=>{k==null||k(!!r)},[r,k]),v.useEffect(()=>{const s=h&&!A.current;A.current=h,s&&(V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null))},[a,h,F,l]);const ye=s=>{if(!I(s.type))return{fields:f||[],metrics:j||[]};const o=(p==null?void 0:p[s.id])||[];if(o.length===0)return{fields:f||[],metrics:j||[]};const n=t.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:b||[],selectedCardIds:o});return{fields:s.type==="field_selector"?n.choices.map(c=>({option:c,target:n.fieldTargetMap[c.value]})):[],metrics:s.type==="metric_selector"?n.choices.map(c=>({option:c,target:n.metricTargetMap[c.value]})):[]}},ne=s=>{if(!I(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const o=(p==null?void 0:p[s.control.id])||[],n=t.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:b||[],selectedCardIds:s.nextSelectedCardIds}),c=t.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),g=Object.fromEntries(o.filter(D=>!s.nextSelectedCardIds.includes(D)).map(D=>[D,void 0]));return s.nextSelectedCardIds.length>0&&c.source.kind==="manual"&&c.source.options.length>0&&Object.assign(g,t.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:c,cardBindingsById:g}},B=v.useCallback((s,o=d,n={type:"update"})=>{const c=s.map(g=>(t.resolveAuthoringControlDefaultValue({control:g,defaultValues:o}),t.syncSqlQueryControlExecutionRequirement(g)));x(c,o,n)},[d,x]),K=(s,o)=>{const n=a.find(E=>E.id===s);let c=a.map(E=>E.id!==s?E:o(E));const g=c.find(E=>E.id===s);let D,m;if(g&&l==="dashboard"&&(g.type==="field_selector"||g.type==="metric_selector")){const E=(p==null?void 0:p[g.id])||[],z=ne({control:g,nextSelectedCardIds:E});c=c.map(O=>O.id===s?z.nextControl:O),D=z.cardBindingsById,m=[g.id]}else if(n&&l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const E=(p==null?void 0:p[n.id])||[];D=Object.fromEntries(E.map(z=>[z,void 0])),m=[n.id]}const N=c.find(E=>E.id===s);let L=d;if(n&&N){const E=t.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&N.source.kind==="sql_query"&&(T.current[s]=E);const z=E===void 0&&n.source.kind==="sql_query"&&N.source.kind==="manual"?T.current[s]:E,O=t.getNextEditedControlDefaultValue({previousControl:n,nextControl:N,currentDefaultValue:z});N.source.kind==="manual"&&(T.current[s]=O),d&&(L={...d},O===void 0?delete L[s]:L[s]=O),c=c.map(pe=>pe.id===s?{...N,defaultValue:O}:pe)}B(c,L,{type:"update",cardBindingsById:D,affectedBindingControlIds:m})},ve=(s,o)=>{const n=o.trim();if(n.length===0||n===s||F.has(n)||a.some(D=>D.id===n&&D.id!==s))return;const c=a.map(D=>D.id===s?{...D,id:n}:D);if(!d){B(c,void 0,{type:"rename",oldId:s,newId:n});return}const g={...d};Object.prototype.hasOwnProperty.call(g,s)&&(g[n]=g[s],delete g[s]),B(c,g,{type:"rename",oldId:s,newId:n})},Ce=s=>{const o=a.filter(c=>c.id!==s);if(!d){B(o,void 0,{type:"remove",controlId:s});return}const n={...d};delete n[s],B(o,n,{type:"remove",controlId:s})},je=v.useCallback(()=>{q.current=void 0,V({step:1,control:t.createBlankControl(l,a,Array.from(F))}),_(null),U(null)},[a,F,l]),X=s=>{V(o=>o&&(()=>{const n=s(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(q.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?q.current:o.defaultValue,g=t.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(q.current=g),{...o,control:n,defaultValue:g}})())},oe=s=>{V(o=>o&&(o.control.source.kind==="manual"&&(q.current=s),{...o,defaultValue:s}))},W=(()=>{if(!r)return!1;if(r.step===2&&I(r.control.type))return(r.selectedCardIds||[]).length>0;if(r.step!==2&&r.step!==3||!r.control.label.trim())return!1;const o=r.control.source.kind==="sql_query"?r.control:t.ensureManualSource(r.control);if(o.source.kind==="manual"&&(t.needsManualOptions(o)&&o.source.options.length===0||o.source.options.some(c=>c.label.trim().length===0||c.value.trim().length===0)))return!1;if(o.source.kind==="sql_query"){const{connectionId:n,sql:c,valueColumn:g}=o.source;return n.trim().length>0&&c.trim().length>0&&g.trim().length>0}return t.hasConcreteDefaultValue(t.getDefaultValueForType(o,r.defaultValue))})(),ie=()=>{var D;if(!r)return;const s=t.ensureManualSource(r.control),o=t.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:a,reservedIds:Array.from(F)}),n={...s,id:o},c=l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((D=r.selectedCardIds)!=null&&D.length)?t.buildStructuralControlBindingsForParticipants({control:n,participants:b||[],selectedCardIds:r.selectedCardIds}):void 0,g=t.getDefaultValueForType(n,r.defaultValue);V({step:l==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:g,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},Z=v.useCallback(()=>{V(null)},[]),de=v.useCallback(()=>{if(!(r!=null&&r.createdControlId)){V(null);return}const s=r.control,o=r.createdControlId,n=t.getDefaultValueForType(s,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,B([...a,{...s,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else B([...a,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});_(o),V(null),S==null||S()},[a,r,d,B,S]),ke=r?I(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],ce=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${t.slugifyControlValue(r.control.label)||r.control.id}]]`:"",ee=t.buildAuthoringPreviewControlValues({controls:a,defaultValues:d}),te=r?[...a,r.control]:a,ue=r?t.buildAuthoringPreviewControlValues({controls:te,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):ee;return e.jsxs("div",{className:"space-y-4",children:[r?e.jsxs("div",{className:"space-y-4 pb-1",children:[e.jsx(Fe,{currentStep:r.step,labels:ke}),r.step===1&&(()=>{const s=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=P.filter(g=>!s.has(g.value)),n=P.filter(g=>s.has(g.value)),c=g=>e.jsxs("button",{type:"button",className:"rounded-[6px] border border-border/60 bg-background px-3 py-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:outline-none",onClick:()=>V(_e({scope:l,existingControls:a,reservedIds:Array.from(F),type:g.value})),children:[e.jsx("div",{className:"text-[13px] font-medium text-foreground",children:g.label}),e.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:g.description})]},g.value);return e.jsxs("div",{className:"space-y-4",children:[l==="card"&&(C==null?void 0:C.sql)==null?e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Explorer cards support displayed metric, group by field, aggregation, and time grain controls here."}):null,o.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),e.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:Z,children:"Back to controls"})})]})})(),r.step===2&&I(r.control.type)&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx(be,{control:r.control,onChange:s=>X(o=>({...o,label:s}))}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),Y.length===0?e.jsx("div",{className:"rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5 text-[12px] text-muted-foreground",children:"No eligible cards are available yet. Add compatible metrics or group-by fields to cards first."}):e.jsx("div",{className:"space-y-1 rounded-[6px] border border-border/60 bg-background p-2",children:Y.map(s=>{const o=(r.selectedCardIds||[]).includes(s.cardId);return e.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[e.jsx(t.Checkbox,{checked:o,onCheckedChange:n=>V(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],s.cardId]:(c.selectedCardIds||[]).filter(g=>g!==s.cardId)})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-medium text-foreground",children:s.title}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:r.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),e.jsx(G,{secondary:e.jsx(t.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>V(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:e.jsx(t.Button,{type:"button",size:"xs",onClick:()=>V(s=>s&&{...s,step:3}),disabled:!W,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:1}),onNext:ie,nextDisabled:!W}),r.step===3&&I(r.control.type)&&e.jsx(me,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:M.fields,availableMetricChoices:M.metrics,previewControlDefinitions:te,previewControlValues:ue,onControlChange:s=>X(()=>s),onLabelChange:s=>X(o=>({...o,label:s})),onDefaultValueChange:oe,onBack:()=>V(s=>s&&{...s,step:2}),onNext:ie,nextDisabled:!W}),r.step===3&&!I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,explorerContent:e.jsxs(e.Fragment,{children:["Open the card and use"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Settings → Controls"})," ","to choose what this control changes."]}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:2}),onCancel:Z,onDone:de}),r.step===4&&I(r.control.type)&&e.jsx(fe,{control:r.control,scope:l,createdReference:ce,summaryDetail:e.jsxs(e.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:e.jsx(e.Fragment,{children:"Selected cards have been set up to respond to this control automatically."}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>V(s=>s&&{...s,step:3}),onCancel:Z,onDone:de})]}):null,!r&&a.length===0?e.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&a.map(s=>{const o=ye(s),n=y==null?void 0:y[s.id],c=t.resolveAuthoringControlDefaultValue({control:s,defaultValues:d}),g=J===s.id,D="inline-flex shrink-0 items-center rounded-[4px] border border-border/60 bg-muted/40 px-1.5 py-0.5 text-[11px] font-medium text-muted-foreground";return e.jsxs("div",{className:"rounded-[6px] border border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[e.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 rounded-[4px] text-left focus:outline-none focus-visible:bg-muted/40",onClick:()=>_(m=>m===s.id?null:s.id),children:[g?e.jsx(t.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):e.jsx(t.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:s.label||"Untitled control"}),e.jsx("span",{className:D,children:t.getFriendlyTypeOption(s.type).label}),e.jsx("span",{className:D,children:t.getPlacementLabel(l,s.placement)})]}),e.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[t.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),e.jsx(t.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>Ce(s.id),"aria-label":`Remove ${s.label}`,children:e.jsx(t.Trash2,{className:"h-3.5 w-3.5"})})]}),g&&e.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),e.jsx(t.Input,{size:"xs",value:s.label,placeholder:"Control label",onChange:m=>K(s.id,N=>({...N,label:m.target.value}))})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),e.jsxs(t.Select,{value:s.type,onValueChange:m=>{const N=t.applyControlTypeChange({controls:a,controlId:s.id,nextType:m,defaultValues:d});B(N.controls,N.defaultValues)},children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:H(s.type).map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),e.jsxs(t.Select,{value:s.placement||R,onValueChange:m=>K(s.id,N=>({...N,placement:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:Q.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),I(s.type)?e.jsx(t.StructuralParticipantSelector,{type:s.type,participants:t.getEligibleParticipantsForStructuralControl(b||[],s.type).map(m=>({cardId:m.cardId,title:m.title,choiceCount:s.type==="field_selector"?m.fieldChoices.length:m.metricChoices.length})),selectedCardIds:(p==null?void 0:p[s.id])||[],onChange:m=>{const N=ne({control:s,nextSelectedCardIds:m}),L=a.map(E=>E.id===s.id?N.nextControl:E);B(L,d,{type:"update",cardBindingsById:N.cardBindingsById})}}):null,e.jsx(t.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:a,previewControlValues:ee,controlLifecycle:"edit",onChange:m=>K(s.id,()=>m)}),s.initialValueStrategy==="saved_default"&&e.jsx(t.ControlDefaultValueEditor,{control:s,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:a,previewControlValues:ee,onChange:m=>{const N=a.map(L=>L.id===s.id?{...L,defaultValue:m}:L);if(s.source.kind==="manual"&&(T.current[s.id]=m),d){const L={...d};m===void 0?delete L[s.id]:L[s.id]=m,B(N,L);return}B(N,void 0)}}),e.jsxs(t.Collapsible,{open:$===s.id,onOpenChange:m=>U(m?s.id:null),children:[e.jsx(t.CollapsibleTrigger,{asChild:!0,children:e.jsxs(t.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[$===s.id?e.jsx(t.ChevronDown,{className:"h-3.5 w-3.5"}):e.jsx(t.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),e.jsxs(t.CollapsibleContent,{className:"space-y-3 pt-2",children:[e.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),e.jsx(t.ControlIdInput,{controlId:s.id,onCommit:m=>ve(s.id,m)},s.id)]}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx(t.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),e.jsxs(t.Select,{value:s.initialValueStrategy,onValueChange:m=>K(s.id,N=>({...N,initialValueStrategy:m})),children:[e.jsx(t.SelectTrigger,{size:"xs",children:e.jsx(t.SelectValue,{})}),e.jsx(t.SelectContent,{children:t.INITIAL_VALUE_STRATEGY_OPTIONS.map(m=>e.jsx(t.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),e.jsx(t.ControlVisibilitySettings,{control:s,onChange:m=>K(s.id,()=>m)})]})]})]})]},s.id)}),!r&&e.jsxs(t.Button,{type:"button",variant:"outline",size:"xs",onClick:je,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function Ae(l){const{open:a,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=l,u=a!==void 0,[h,y]=v.useState(!1),[f,j]=v.useState(d),b=u?a:h,p=v.useCallback(k=>{!k&&f&&x==="passive"||(u||y(k),k||j(!1),i==null||i(k))},[u,f,x,i]),C=v.useCallback(()=>{u||y(!1),j(!1),i==null||i(!1)},[u,i]);v.useEffect(()=>{b||j(!1)},[b]);const w=v.useCallback(k=>{f&&k.preventDefault()},[f]);return{forceClose:C,handleOpenChange:p,isCreateFlowActive:f,preventPassiveDismissDuringCreate:w,resolvedOpen:b,setIsCreateFlowActive:j}}exports.CircleX=Se;exports.ControlDefinitionListEditor=qe;exports.EditorAcceptButton=Ee;exports.EditorCancelButton=Te;exports.EditorClearButton=Ie;exports.Library=he;exports.Link2=ge;exports.Save=re;exports.VisualBadge=Ne;exports.VisualSaveAndApplyButton=Ve;exports.VisualSaveButton=we;exports.useCreateFlowOverlayState=Ae;exports.useEffectiveEditorCardType=ae;
@@ -1 +0,0 @@
1
- "use strict";const a=require("./index-8GnvL1_L.js"),p=require("react");function J(e){const[o,s]=p.useState(null),[r,t]=p.useState(null),n=a.useEnsureReactGlobals();return p.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!n)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const c=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(c,{method:"HEAD"})).ok)throw new Error(`Module not found at ${c}`)}catch{}const h=await import(c);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>h.useChartStore),t(null)}catch(i){const c=i instanceof Error?i.message:"Unknown error";console.error("Failed to load remote chart store:",c),t(c),s(null)}})()},[e,n]),o}function K(e,o){if(e.length===0)return"";const s=e.find(r=>{var t,n;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((n=r.customCardPreferences)!=null&&n.dataInputCardIds)});if(s)return s.id;if(o){const r=e.find(t=>t.id===o);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const u=t.split("__")[0],i=e.find(c=>c.tabTitle===u);return i?i.id:e[0].id}return o}}return e[0].id}const D=new Set;function X(e){return D.add(e),()=>{D.delete(e)}}function q(){D.forEach(e=>{e()})}const Y=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:o,...s}=e;return s};async function B(e,o,s,r){if(!o||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],n=r.getQueryData(t);if(n)return console.log("Using cached visual data for:",s),{data:n,fromCache:!0};console.log("Fetching visual data from network for:",s);const u=a.ue.loading("Loading visual...",{position:"top-center"});try{const i=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${o}`}});if(!i.ok)throw new Error("Failed to load visual");const c=await i.json();return r.setQueryData(t,c),a.ue.dismiss(u),{data:c,fromCache:!1}}catch(i){throw a.ue.dismiss(u),i}}function z(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Z(e,o){var n,u;const s=(e==null?void 0:e.frameObject)??((n=e==null?void 0:e.visual)==null?void 0:n.frameObject);if(!s)return!1;const r=z(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(u=r.cards)==null?void 0:u.find(i=>i.id===r.activeCardId);return t?(a.setupEditorWithCard({...o,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function ee(){const e=a.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),o=J(e);return{getUpdatedFrame:p.useCallback(()=>{var g;q();const{frame:r,card:t,isDevMode:n,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C}=a.useEditorStore.getState(),y=t.sql,I=(g=o==null?void 0:o.getState())==null?void 0:g.settings,U=a.buildSavedEditorCard(t,{isDevMode:n,cardSql:y,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C,remoteChartSettings:I,stripConfig:Y}),S=r.cards.map(b=>b.id===t.id?U:b);return{...r,cards:S,activeCardId:K(S,r.activeCardId)}},[o])}}function te(){const{authToken:e,tokenProps:o}=a.useSemaphorContext(),s=a.useQueryClient(),r=a.useAddFrameWithFreshSemanticExecutionPayload(),t=a.useSelectedVisual(),{selectVisual:n}=a.useManagementActions(),{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,clearEditorContext:k}=a.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:L,setSelectedFrameId:T,clearSelectedFrameId:j,setIsDashboardPanelOpen:N}=a.useDashboardActions(),E=a.useDashboardStore(d=>d.selectedSheetId),R=a.useDashboardStore(d=>d.selectedFrameId),W=a.useDashboardStore(d=>d.dashboard),$=a.useDashboardStore(d=>d.filterValues),x=a.useDashboardStore(d=>d.inlineFilterValuesMap),w=a.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),H=p.useCallback(async d=>{try{n(d),j(),k();const{data:f,fromCache:v}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s);if(!Z(f,{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,setIsDashboardEditing:V,setIsVisualEditing:L,dashboard:W,selectedSheetId:E,selectedFrameId:R,filterValues:$,inlineFilterValuesMap:x}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:v}}catch(f){return console.error("Error editing visual:",f),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,u,i,V,L,c,h,m,C,y,I,U,S,g,b,A,P,M,k,j,W,E,R,$,x]),Q=p.useCallback(async d=>{var v;const f=l=>(a.ue.error(l),{success:!1,error:l});try{if(n(d),!E)return f("No sheet selected. Please select a sheet first.");const{data:l,fromCache:G}=await B(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s),O=(l==null?void 0:l.frameObject)??((v=l==null?void 0:l.visual)==null?void 0:v.frameObject);if(!O)return f("Visual has no frame data");const F=z(O);if(!(F!=null&&F.cards)||F.cards.length===0)return f("Visual frame is malformed");const _={...a.cloneLinkedFrameWithSourceMapping(F),visualId:d.id};return await r(E,_,"end"),V(!0),T(_.id),N(!1),{success:!0,fromCache:G}}catch(l){return console.error("Error adding visual:",l),f(l instanceof Error?l.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,E,V,T,N,r]);return{visual:w.data,isLoading:w.isLoading,isError:w.isError,error:w.error,handleEditLibraryVisual:H,handleAddLibraryVisual:Q,getUpdatedFrame:ee().getUpdatedFrame,refetch:w.refetch}}exports.flushPendingEditorDrafts=q;exports.registerPendingEditorDraftFlusher=X;exports.useVisualUtils=te;