react-semaphor 0.1.284 → 0.1.286

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 (32) hide show
  1. package/dist/chunks/{dashboard-controls-4pDdG3me.js → dashboard-controls-ItYogy_p.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-Dhry2k8x.js → dashboard-controls-L0PZjJCt.js} +318 -341
  3. package/dist/chunks/dashboard-filter-controls-button-BBM66Kjx.js +1107 -0
  4. package/dist/chunks/dashboard-filter-controls-button-C0aCuD2T.js +11 -0
  5. package/dist/chunks/{dashboard-json-CYnf5rdp.js → dashboard-json-BQ-vAiN1.js} +1 -1
  6. package/dist/chunks/{dashboard-json-D-KsLEGl.js → dashboard-json-DVGKEKGc.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-B4jsBFro.js → dashboard-summary-settings-dialog-DlXqW4ur.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-Cn4-fB2h.js → dashboard-summary-settings-dialog-jRhWndnZ.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-BQnApBvr.js → edit-dashboard-visual-BFIX635s.js} +2 -2
  10. package/dist/chunks/{edit-dashboard-visual-BDIt_S2F.js → edit-dashboard-visual-DOyPqIRy.js} +4 -4
  11. package/dist/chunks/{index-DBuN9Zf6.js → index-5fuOmhsI.js} +170 -170
  12. package/dist/chunks/{index-y1uW2fuZ.js → index-BJLFSwZr.js} +10190 -10214
  13. package/dist/chunks/resource-management-panel-DMIhpLZ1.js +933 -0
  14. package/dist/chunks/resource-management-panel-DPJ6MzLA.js +6 -0
  15. package/dist/chunks/{use-create-flow-overlay-state-Cr9AFdXx.js → use-create-flow-overlay-state-BU00QaON.js} +142 -145
  16. package/dist/chunks/use-create-flow-overlay-state-CvuLpw1f.js +21 -0
  17. package/dist/chunks/{use-visual-utils-DNp8XO6G.js → use-visual-utils-DUV4E_sx.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-Ccmzx7-m.js → use-visual-utils-DlwYqcbg.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 +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/dist/types/main.d.ts +18 -2
  27. package/package.json +1 -1
  28. package/dist/chunks/dashboard-filter-controls-button-BZXrmJP2.js +0 -1072
  29. package/dist/chunks/dashboard-filter-controls-button-DEUvxIWD.js +0 -11
  30. package/dist/chunks/resource-management-panel-BC-cvjI9.js +0 -920
  31. package/dist/chunks/resource-management-panel-PSvKnmq5.js +0 -6
  32. package/dist/chunks/use-create-flow-overlay-state-COe7Ekru.js +0 -21
@@ -1,6 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-DBuN9Zf6.js"),h=require("react"),re=require("./use-visual-utils-DNp8XO6G.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 ie=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 ae(s,g={}){const{enabled:x=!0,eventType:d="mousedown"}=g,i=h.useRef(null);return h.useEffect(()=>{const m=j=>{const o=j.target;i.current&&i.current.contains(o)||o instanceof Element&&(o.closest("[data-radix-popper-content-wrapper]")||o.closest("[data-radix-select-content]")||o.closest("[data-radix-popover-content]")||o.closest("[data-radix-dropdown-menu-content]")||o.closest("[data-radix-tooltip-content]")||o.closest('[role="listbox"]')||o.closest('[role="option"]')||o.closest('[role="combobox"]'))||o instanceof Element&&o.hasAttribute("data-radix-")||s()};return x&&document.addEventListener(d,m),()=>{document.removeEventListener(d,m)}},[s,x,d]),i}function ne(){return e.jsx("div",{className:"space-y-1.5 py-1",children:[...Array(5)].map((s,g)=>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"})]})]},g))})}const de=s=>{const g=t.useDashboardStore(i=>i.isVisualEditing),x=t.useDashboardStore(i=>i.selectedFrameId),d=t.useEditorStore(i=>i.frame);return!!(g&&x&&(d==null?void 0:d.visualId)===s)};function le({visual:s,isDeleting:g,isDuplicating:x,onAddVisual:d,onOpenVisual:i,onEditDetails:m,onDeleteClick:j,onDuplicateVisual:o,onShareVisual:D,formatDate:N}){var O,T,U,P;const{selectVisual:p}=t.useManagementActions(),c=t.useIsVisualSelected(s.id),u=de(s.id),A=t.useDashboardStore(a=>a.isVisualEditing),{isConsoleMode:R}=t.useDashboardPreferences(),b=h.useRef(null),[C,S]=h.useState(!1),[E,L]=h.useState(!1);h.useEffect(()=>{x?(S(!0),L(!0)):E&&(S(!1),L(!1))},[x,E]),h.useEffect(()=>{u&&b.current&&b.current.scrollIntoView({behavior:"smooth",block:"center"})},[u]);const y=()=>{p(s),i==null||i(s)},v=a=>{a.currentTarget===a.target&&(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),y())};return e.jsxs("div",{ref:b,className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",u?"border-primary/30 bg-primary/10":c&&"border-border/60 bg-muted/50"),onClick:y,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-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:(O=s.description)!=null&&O.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex flex-shrink-0 items-center gap-1 transition-opacity",c||u||C?"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 items-center overflow-hidden rounded-lg border border-border/60 bg-background/95 shadow-sm",children:[e.jsxs(t.Button,{size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-none border-0 px-2 text-xs font-medium shadow-none hover:bg-muted/50",disabled:A,onClick:a=>{a.stopPropagation(),d(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:C,onOpenChange:S,children:[e.jsx(t.DropdownMenuTrigger,{asChild:!0,children:e.jsx(t.Button,{size:"sm",variant:"ghost",className:"h-7 w-7 rounded-none border-0 border-l border-border/60 p-0 shadow-none hover:bg-muted/50","aria-label":"Open visual actions",children:e.jsx(t.EllipsisVertical,{className:"h-3 w-3"})})}),e.jsxs(t.DropdownMenuContent,{align:"end",className:"z-[51] w-44 rounded-xl border border-border/60 p-1 shadow-sm",children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),d(s)},disabled:A,children:[e.jsx(t.Plus,{className:"mr-2 h-3 w-3"}),"Add"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),i==null||i(s)},children:[e.jsx(ie,{className:"mr-2 h-3 w-3"}),"Open"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.preventDefault(),a.stopPropagation(),o(s.id)},disabled:x,children:[x?e.jsx(t.LoaderCircle,{className:"mr-2 h-3 w-3 animate-spin"}):e.jsx(t.Copy,{className:"mr-2 h-3 w-3"}),x?"Duplicating...":"Duplicate"]}),s.ownership.isOwner&&e.jsxs(e.Fragment,{children:[e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.stopPropagation(),m==null||m(s)},children:[e.jsx(t.PenLine,{className:"mr-2 h-3 w-3"}),"Edit details"]}),e.jsxs(t.DropdownMenuItem,{onClick:a=>{a.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:a=>{a.stopPropagation(),j(s)},className:"text-destructive",disabled:g,children:[e.jsx(t.Trash2,{className:"mr-2 h-3 w-3"}),g?"Deleting...":"Delete"]})]}),e.jsx(t.DropdownMenuSeparator,{}),e.jsxs("div",{className:"space-y-1 px-2 py-2 text-xs 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",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",children:[e.jsx(t.Calendar,{className:"h-3 w-3"}),e.jsx("span",{children:N(s.lastModified)})]})]})]})]})]})})]})}function ce({searchQuery:s}){const[g,x]=h.useState(!1),[d,i]=h.useState(null),[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(null),[c,u]=h.useState(null),{handleEditLibraryVisual:A,handleAddLibraryVisual:R}=re.useVisualUtils(),{resources:b,isLoading:C,isError:S,updateResource:E,deleteResource:L,duplicateResource:y,isDeleting:v}=t.useVisualManagement(()=>{j(!1),D(null)}),O=b.filter(n=>{var M,l;return((M=n==null?void 0:n.title)==null?void 0:M.toLowerCase().includes(s.toLowerCase()))||((l=n==null?void 0:n.description)==null?void 0:l.toLowerCase().includes(s.toLowerCase()))}),T=n=>new Date(n).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),U=n=>{D(n),j(!0)},P=()=>{o&&L(o.id)},{startUpdating:a,stopUpdating:_,isUpdating:F}=t.useResourceUpdateState(),V=(n,M,l)=>{var X;const B=Object.fromEntries(Object.entries(M).filter(([,I])=>I!==void 0));if(Object.keys(B).length===0){(X=l==null?void 0:l.onSuccess)==null||X.call(l);return}const w=Object.keys(B),H=w.length===1?w[0]:void 0;a(n,H),E({resourceId:n,data:B},{onSuccess:()=>{var I;_(n,H),(I=l==null?void 0:l.onSuccess)==null||I.call(l)},onError:()=>{var I;_(n,H),(I=l==null?void 0:l.onError)==null||I.call(l)}})},G=n=>{p(n),y(n,{onSettled:()=>p(null)})},z=n=>{A(n)},W=n=>{R(n)},Y=n=>{i(n),x(!0)},$=n=>{u(n)},J=()=>{u(null)},Q=({title:n,description:M})=>{if(!c)return;const l={};n!==c.title&&(l.title=n),(c.description||"")!==M&&(l.description=M),V(c.id,l,{onSuccess:()=>{u(null)}})};return C?e.jsx(ne,{}):S?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 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-1.5 overflow-y-auto px-0.5",children:O.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 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 "New" above to add your first visual'})]}):O.map(n=>e.jsx(le,{visual:n,onAddVisual:W,onOpenVisual:z,onEditDetails:$,onDeleteClick:U,onDuplicateVisual:G,onShareVisual:Y,isDeleting:v,isDuplicating:N===n.id,formatDate:T},n.id))}),g&&d&&e.jsx(t.ShareDialog,{resource:d,resourceType:t.ResourceType.VISUAL,onClose:()=>{x(!1),i(null)}}),c&&e.jsx(t.ResourceEditDialog,{open:!!c,resourceLabel:"Visual",initialTitle:c.title||"",initialDescription:c.description||"",onClose:J,onSave:Q,isSaving:F(c.id)}),e.jsx(t.AlertDialog,{open:m,onOpenChange:n=>{!n&&v||(j(n),n||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 "',o==null?void 0:o.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(),P()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:v,children:[v?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"}),v?"Deleting...":"Delete"]})]})]})})]})}function ue({dashboard:s,isDeleting:g,isDuplicating:x,onLoadDashboard:d,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D,onDashboardItemClick:N}){var E,L;const{selectDashboard:p}=t.useManagementActions(),c=t.useIsDashboardSelected(s.id),{userContext:u,isLoading:A}=t.useCurrentUserInfo(),R=((E=u==null?void 0:u.permissions)==null?void 0:E.canEdit)??!1,b=A||!R,C=()=>{p(s),d(s.id),N==null||N(s.id)},S=y=>{y.currentTarget===y.target&&(y.key==="Enter"||y.key===" ")&&(y.preventDefault(),C())};return e.jsxs("div",{className:t.cn("group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",c&&"border-border/60 bg-muted/50"),onClick:C,children:[e.jsxs("div",{role:"button",tabIndex:0,className:"min-w-0 flex-1 cursor-pointer focus-visible:outline-none",onKeyDown:S,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:(L=s.description)!=null&&L.trim()?s.description:"No description"})]}),e.jsx("div",{className:t.cn("flex-shrink-0 transition-opacity",c?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:e.jsx(t.DashboardActionsMenu,{dashboard:s,isDeleting:g,isDuplicating:x,shouldHideActions:b,onEditDetails:i,onDeleteClick:m,onDuplicateDashboard:j,onShareDashboard:o,formatDate:D})})]})}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 me(s){var ee;const{searchQuery:g,onLoadDashboard:x,onEditDashboard:d,onDashboardItemClick:i}=s,[m,j]=h.useState(!1),[o,D]=h.useState(null),[N,p]=h.useState(!1),[c,u]=h.useState(null),[A,R]=h.useState(null),[b,C]=h.useState(null),S=t.useManagementStore(r=>r.lastSelectedDashboard),E=t.useManagementStore(r=>r.selectedDashboard),L=t.useManagementStore(r=>r.actions.selectDashboard),y=t.useManagementStore(r=>r.actions.clearSelectedDashboard),{tokenProps:v,id:O}=t.useSemaphorContext(),{resources:T,isLoading:U,isError:P,updateResource:a,deleteResource:_,duplicateResource:F,isDeleting:V}=t.useDashboardManagement(()=>{p(!1);const r=c==null?void 0:c.id;u(null),(E==null?void 0:E.id)===r&&(!(v!=null&&v.dashboard_id)&&!O?y():S&&S.id!==r&&L(S))}),{userContext:G}=t.useCurrentUserInfo(),z=((ee=G==null?void 0:G.permissions)==null?void 0:ee.canCreateDashboard)??!1,W=T.filter(r=>{var K,f;return((K=r==null?void 0:r.title)==null?void 0:K.toLowerCase().includes(g.toLowerCase()))||((f=r==null?void 0:r.description)==null?void 0:f.toLowerCase().includes(g.toLowerCase()))}),Y=r=>new Date(r).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),$=r=>{x==null||x(r)},J=r=>{u(r),p(!0)},Q=()=>{c&&_(c.id)},n=r=>{R(r),F(r,{onSettled:()=>R(null)})},{startUpdating:M,stopUpdating:l,isUpdating:B}=t.useResourceUpdateState(),w=(r,K,f)=>{var se;const Z=Object.fromEntries(Object.entries(K).filter(([,q])=>q!==void 0));if(Object.keys(Z).length===0){(se=f==null?void 0:f.onSuccess)==null||se.call(f);return}const te=Object.keys(Z),k=te.length===1?te[0]:void 0;M(r,k),a({resourceId:r,data:Z},{onSuccess:()=>{var q;l(r,k),(q=f==null?void 0:f.onSuccess)==null||q.call(f)},onError:()=>{var q;l(r,k),(q=f==null?void 0:f.onError)==null||q.call(f)}})},H=r=>{D(r),j(!0)},X=r=>{d==null||d(r.id),C(r)},I=()=>{C(null)},oe=({title:r,description:K})=>{if(!b)return;const f={};r!==b.title&&(f.title=r),(b.description||"")!==K&&(f.description=K),w(b.id,f,{onSuccess:()=>{C(null)}})};return U?e.jsx(ne,{}):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-1.5 overflow-y-auto px-0.5",children:W.length===0?e.jsxs("div",{className:"rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 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:g?"No dashboards found":"No dashboards yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:g?"Try adjusting your search":z?'Click "New" above to add your first dashboard':"No dashboards have been shared with you yet"})]}):W.map(r=>e.jsx(ue,{dashboard:r,isDeleting:V,isDuplicating:A===r.id,onLoadDashboard:$,onEditDetails:X,onDeleteClick:J,onDuplicateDashboard:n,onShareDashboard:H,formatDate:Y,onDashboardItemClick:i},r.id))}),m&&o&&e.jsx(t.ShareDialog,{resource:o,resourceType:t.ResourceType.DASHBOARD,onClose:()=>{j(!1),D(null)}}),e.jsx(t.AlertDialog,{open:N,onOpenChange:r=>{!r&&V||(p(r),r||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 "',c==null?void 0:c.title,'"? This action cannot be undone.']})]}),e.jsxs(t.AlertDialogFooter,{children:[e.jsx(t.AlertDialogCancel,{disabled:V,children:"Cancel"}),e.jsxs(t.AlertDialogAction,{onClick:r=>{r.preventDefault(),r.stopPropagation(),Q()},className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",disabled:V,children:[V?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"}),V?"Deleting...":"Delete"]})]})]})}),b&&e.jsx(t.ResourceEditDialog,{open:!!b,resourceLabel:"Dashboard",initialTitle:b.title||"",initialDescription:b.description||"",onClose:I,onSave:oe,isSaving:B(b.id)})]})}function pe({open:s,onOpenChange:g,onSubmit:x,isCreating:d}){const[i,m]=h.useState(""),[j,o]=h.useState("");h.useEffect(()=>{s||(m(""),o(""))},[s]);const D=()=>{i.trim()&&x({title:i,description:j})},N=p=>{g(p)};return e.jsx(t.Dialog,{open:s,onOpenChange:N,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:p=>m(p.target.value),disabled:d,onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&(p.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:p=>o(p.target.value),disabled:d})]})]}),e.jsxs(t.DialogFooter,{children:[e.jsx(t.Button,{variant:"outline",onClick:()=>N(!1),disabled:d,children:"Cancel"}),e.jsx(t.Button,{onClick:D,disabled:!i.trim()||d,children:d?e.jsxs(e.Fragment,{children:[e.jsx(t.LoaderCircle,{className:"mr-2 h-4 w-4 animate-spin"}),"Creating..."]}):"Create Visual"})]})]})})}function xe({isOpen:s,onClose:g,className:x,onDashboardItemClick:d,variant:i="inline"}){var l,B;const m=t.useDashboardStore(w=>w.isDashboardEditing),[j,o]=h.useState(!1),[D,N]=h.useState(""),[p,c]=h.useState(!1),{currentUser:u,userContext:A}=t.useCurrentUserInfo(),R=((l=A==null?void 0:A.permissions)==null?void 0:l.canCreateDashboard)??!1,{onCreateSuccess:b}=t.useDashboardCreation({onDashboardSelect:d}),{selectVisual:C}=t.useManagementActions(),{handleEditLibraryVisual:S}=re.useVisualUtils(),{createResource:E,isCreating:L,refetch:y}=t.useDashboardManagement(),{createResource:v,isCreating:O}=t.useVisualManagement(void 0,w=>{o(!1),w&&(C(w),S(w))}),T=i==="overlay",U=m?"New Visual":"New",P=m?"New Visual":"New Dashboard",a=m?"Search visuals...":"Search dashboards...",_=m?"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())||"?",Y=V&&V.toLowerCase()!=="undefined"?V:"",$=ae(g,{enabled:s&&T}),J=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",x),Q=w=>{},n=w=>{console.log("Editing dashboard:",w)},M=w=>{E(w,{onSuccess:H=>{o(!1),b(H,y)}})};return e.jsx(e.Fragment,{children:(!T||s)&&e.jsxs("div",{ref:$,className:J,children:[e.jsxs("div",{className:"border-b border-border/60 bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[e.jsx("div",{className:"flex items-center gap-2",children:e.jsx("h2",{className:"whitespace-nowrap text-sm font-semibold",children:m?"Visuals":"Dashboards"})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(t.Button,{size:"sm",variant:"ghost",onClick:()=>c(!p),className:"h-8 w-8 rounded-md p-0 text-muted-foreground hover:bg-muted/50 hover:text-foreground","aria-label":p?"Hide search":"Show search",children:e.jsx(t.Search,{className:"h-3.5 w-3.5"})}),(m||R)&&e.jsxs(t.Button,{size:"sm",variant:"secondary",className:"h-8 gap-1.5 whitespace-nowrap rounded-md border border-border/60 bg-muted/30 px-2 text-xs font-medium hover:bg-muted/55",onClick:()=>o(!0),"aria-label":P,children:[e.jsx(t.Plus,{className:"h-3.5 w-3.5"}),U]}),e.jsx(t.Button,{size:"sm",variant:"outline",className:"h-8 w-8 rounded-md border-border/60 bg-background p-0.5 text-muted-foreground hover:bg-muted/35 hover:text-foreground",onClick:g,"aria-label":_,children:e.jsx(t.PanelLeft,{className:"h-3.5 w-3.5"})})]})]}),p&&e.jsx("div",{className:"border-t border-border/50 bg-muted/20 px-3 pb-3 pt-2",children:e.jsx(t.Input,{placeholder:a,value:D,onChange:w=>N(w.target.value),className:"h-9 border-border/60 bg-background text-sm focus-visible:border-ring/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.5 py-2.5",children:m?e.jsx(ce,{searchQuery:D}):e.jsx(me,{searchQuery:D,onLoadDashboard:Q,onEditDashboard:n,onDashboardItemClick:d})}),u&&e.jsx(t.TooltipProvider,{children:e.jsx("div",{className:"border-t border-border/60 bg-muted/20 px-3 py-2.5",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-7 w-7 cursor-default items-center justify-center rounded-full bg-primary/10",children:e.jsx("span",{className:"text-xs font-medium text-primary",children:W})})}),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:z}),Y&&e.jsx("div",{className:"text-xs text-muted-foreground",children:Y}),u.role&&e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Role: ",t.toTitleCase(u.role.replace(/_/g," "))]})]})})]}),e.jsx("span",{className:"truncate text-xs font-medium text-muted-foreground",children:z})]})})}),m?e.jsx(pe,{open:j,onOpenChange:o,onSubmit:v,isCreating:O}):e.jsx(t.CreateDashboardDialog,{open:j,onOpenChange:o,onSubmit:M,isCreating:L})]})})}exports.ResourceManagementPanel=xe;
@@ -1,21 +0,0 @@
1
- "use strict";const e=require("./index-DBuN9Zf6.js"),t=require("react/jsx-runtime"),C=require("react"),se=require("./use-visual-utils-DNp8XO6G.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 je=e.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 fe=e.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 he=e.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=e.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 le(){var f,j;const a=e.useEditorStore(y=>y.card),l=e.useEditorStore(y=>y.frame),i=C.useMemo(()=>e.findCustomVisualConfigCard(l,a),[l,a]),{manifest:d}=e.useCustomVisual(((f=i==null?void 0:i.customCardPreferences)==null?void 0:f.url)||""),x=C.useMemo(()=>{var y;return(y=d==null?void 0:d.visuals)==null?void 0:y.find(p=>{var g;return p.name===((g=i==null?void 0:i.customCardPreferences)==null?void 0:g.componentName)})},[d,(j=i==null?void 0:i.customCardPreferences)==null?void 0:j.componentName]),u=e.resolveMultiInputType(i,x),h=C.useMemo(()=>e.getCustomVisualInputCards({frame:l,configCard:i,isMultiInputVisual:u==="multiple"}),[l,i,u]),v=C.useMemo(()=>{const y=h.findIndex(p=>(p==null?void 0:p.id)===a.id);return y<0?-1:e.getSlotIndexForCard(a,y)},[h,a]);return C.useMemo(()=>!i||u!=="multiple"||v<0?a.type:e.getEffectiveCardTypeForSlot(a,v,x==null?void 0:x.slots)??a.type,[i,u,v,a,x==null?void 0:x.slots])}function ke({type:a,isLinked:l,className:i,showLabel:d=!1,showLocal:x=!1}){const u=e.useDashboardStore(T=>T.selectedFrameId),h=e.useManagementStore(T=>T.selectedVisual),v=e.useEditorStore(T=>T.frame);let f;if(a)f=a;else if(l!==void 0)f=l?"linked":"library";else if(!!!(v!=null&&v.visualId||h!=null&&h.id)&&u)f="local";else if(h&&!u)f="library";else if(v!=null&&v.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"},y={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"},g={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},S={local:t.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:t.jsx(he,{className:"h-3.5 w-3.5"}),library:t.jsx(fe,{className:"h-3.5 w-3.5"})},V={local:"Local",linked:"Linked",library:"Library"};return t.jsx(e.TooltipProvider,{children:t.jsxs(e.Tooltip,{delayDuration:300,children:[t.jsx(e.TooltipTrigger,{asChild:!0,children:t.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",j[f],i),children:[S[f],d&&t.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:V[f]})]})}),t.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",p[f]),children:[t.jsx(e.TooltipArrow,{className:g[f]}),t.jsx("p",{children:y[f]})]})]})})}function Se(a,l){return{...a,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,dynamicCardPreferences:void 0,customCardPreferences:l?a.customCardPreferences:void 0,visualizationMode:"builtin",type:l?a.type:"bar"}}function ae(a){const l=e.getDynamicFrameSaveIssue(a);return l?(e.ue.error(l),!1):!0}function Ne({className:a,variant:l="outline"}){const i=e.useEditorStore(u=>u.onSave),{getUpdatedFrame:d}=se.useVisualUtils();function x(){const u=d();ae(u)&&(i==null||i(u))}return t.jsxs(e.Button,{onClick:x,className:e.cn("h-8",a),size:"sm",variant:l,children:[t.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function De({className:a,variant:l="default"}){const i=e.useQueryClient(),[d,x]=C.useState(!1),u=e.useDashboardStore(g=>g.actions.setIsDashboardPanelOpen),{setIsVisualEditing:h}=e.useDashboardActions(),{getUpdatedFrame:v}=se.useVisualUtils(),f=e.useSelectedVisual(),j=e.useEditorStore(g=>g.frame),y=e.useUpdateVisualMutation(),p=()=>{const g=v();if(!ae(g))return;const S=(j==null?void 0:j.visualId)||(f==null?void 0:f.id);if(!S){e.ue.error("No visual to save");return}x(!0),y.mutate({visualId:S,data:{frameObject:g}},{onSuccess:()=>{x(!1),u(!0),e.ue.success("Visual updated successfully"),i.invalidateQueries({queryKey:["resource-by-id","visual",S],exact:!0})},onError:()=>{x(!1),e.ue.error("Failed to update visual")}})};return t.jsxs(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:l,children:[d&&t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!d&&t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function we({className:a}){const l=e.useQueryClient(),[i,d]=C.useState(!1),x=e.useSelectedVisual(),u=e.useEditorStore(g=>g.frame),h=e.useDashboardStore(g=>g.selectedSheetId),{updateFrame:v,setIsVisualEditing:f}=e.useDashboardActions(),{getUpdatedFrame:j}=se.useVisualUtils(),y=e.useUpdateVisualMutation(),p=async()=>{if(!h){e.ue.error("No sheet selected");return}const g=(u==null?void 0:u.visualId)||(x==null?void 0:x.id);if(!g){e.ue.error("No visual to update");return}d(!0);try{const S=j();if(!ae(S)){d(!1);return}await y.mutateAsync({visualId:g,data:{frameObject:S}});const V={...S,visualId:g};v(h,V),l.invalidateQueries({queryKey:["visuals"]}),l.invalidateQueries({queryKey:["visual",g]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{f(!1)},300)}catch(S){console.error("Failed to save and apply:",S),e.ue.error("Failed to save and apply changes")}finally{d(!1)}};return t.jsx(e.Button,{onClick:p,className:e.cn("h-8",a),size:"sm",variant:"default",disabled:i,children:i?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(re,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function Ee({className:a}){const{setTempQueryData:l,setSqlGen:i}=e.useEditorActions(),d=e.useQueryClient(),x=e.useEditorStore(p=>p.tempQueryData),u=e.useEditorStore(p=>p.onClose),h=e.useEditorStore(p=>p.card),v=le(),f=C.useMemo(()=>v!==h.type?{...h,type:v}:h,[h,v]),{queryKey:j}=e.useDashboardCardQuery(f);function y(){if(x){const{queryKey:p,queryData:g}=x;p&&g&&d.setQueryData(p,g)}i({}),u==null||u()}return t.jsxs(e.Button,{onClick:y,className:e.cn("h-8",a),size:"sm",variant:"outline",children:[t.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function Ve({label:a="Clear",variant:l="secondary",className:i}={}){const{setTempQueryData:d}=e.useEditorActions(),x=e.useQueryClient(),u=e.useEditorStore(r=>r.tempQueryData),h=e.useEditorStore(r=>r.card),v=le(),f=C.useMemo(()=>v!==h.type?{...h,type:v}:h,[h,v]),{queryKey:j}=e.useDashboardCardQuery(f),{setCardSql:y,setSqlGen:p,setCardPython:g,setCardCustomCfg:S,setCardPreferences:V,clearQueryConfig:T,setCardConfig:H,setCardType:G,setFrame:K,setCard:O,setActiveTabCardId:J}=e.useEditorActions();function M(){var I,R,q,X;const r=x.getQueryData(j);u!=null&&u.queryData||d({queryKey:j,queryData:r}),x.setQueryData(j,null),x.removeQueries({queryKey:j,exact:!0}),y(""),p({}),T(),H(void 0),g(""),S(""),V({});const N=e.useEditorStore.getState().frame,B=e.useEditorStore.getState().card,E=e.findCustomVisualConfigCard(N,B),Q=((I=E==null?void 0:E.customCardPreferences)==null?void 0:I.visualType)==="multiple"||!!((R=E==null?void 0:E.customCardPreferences)!=null&&R.dataInputCardIds)||(((q=E==null?void 0:E.customCardPreferences)==null?void 0:q.minInputs)||0)>1||(((X=E==null?void 0:E.customCardPreferences)==null?void 0:X.maxInputs)||0)>1,_=Se(B,Q);K({...N,cards:N.cards.map(U=>U.id===_.id?_:U)}),J(_.id),O(_),Q||G("bar")}return t.jsxs(e.Button,{onClick:M,className:e.cn("h-8",i),size:"sm",variant:l,children:[t.jsx(e.X,{className:"mr-2 size-3.5"}),a]})}function ge(a){const{control:l,onChange:i}=a;return t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),t.jsx(e.Input,{size:"xs",value:l.label,placeholder:"Control label",onChange:d=>i(d.target.value)})]})}function Te(a){const{currentStep:l,labels:i}=a;return t.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:t.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===l,v=u<l;return t.jsxs(C.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:e.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":v?"border-foreground/30 bg-foreground/10 text-foreground":"border-border/60 bg-background text-muted-foreground"),children:u}),t.jsx("span",{className:e.cn("text-[12px]",h?"font-medium text-foreground":"text-muted-foreground"),children:d})]}),x<i.length-1?t.jsx("span",{className:"h-px w-4 bg-border/60 sm:w-6","aria-hidden":"true"}):null]},d)})})})}function $(a){const{secondary:l,tertiary:i,primary:d}=a;return t.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:[l,i,d]})}function Ie(a){const{control:l,scope:i,detail:d}=a;return t.jsxs("div",{className:"flex items-start gap-2.5 rounded-[6px] border border-border/60 bg-muted/30 px-3 py-2.5",children:[t.jsx(e.CircleCheck,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-foreground"}),t.jsxs("div",{className:"min-w-0 space-y-0.5",children:[t.jsx("div",{className:"text-[13px] font-medium text-foreground",children:l.label}),t.jsxs("div",{className:"text-[12px] text-muted-foreground",children:[e.getFriendlyTypeOption(l.type).label," ·"," ",e.getControlOptionPreview(l)," ·"," ",e.getPlacementLabel(i,l.placement)]}),d?t.jsx("div",{className:"text-[12px] text-muted-foreground",children:d}):null]})]})}function pe(a){const{control:l,defaultValue:i,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,onControlChange:v,onLabelChange:f,onDefaultValueChange:j,onBack:y,onNext:p,nextDisabled:g}=a;return t.jsxs("div",{className:"space-y-3",children:[t.jsx(ge,{control:l,onChange:f}),t.jsx(e.ControlDefinitionOptionsEditor,{control:l,availableFieldChoices:d,availableMetricChoices:x,previewControlDefinitions:u,previewControlValues:h,controlLifecycle:"create",onChange:v}),t.jsx(e.ControlDefaultValueEditor,{control:l,value:i,onChange:j,allowNoDefault:!0,allowCardDefault:!0,hint:"This is the value viewers will see first.",previewControlDefinitions:u,previewControlValues:h}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:y,children:"Back"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:p,disabled:g,children:"Next"})})]})}const Le=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]);function me(a){const{text:l,ariaLabel:i}=a,[d,x]=C.useState(!1);return t.jsxs("button",{type:"button","aria-label":i,onClick:async()=>{try{await navigator.clipboard.writeText(l),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:[t.jsx("code",{className:"min-w-0 truncate font-mono text-[12px] text-foreground",children:l}),t.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 xe(a){const{control:l,scope:i,createdReference:d,explorerContent:x,sqlDescription:u,summaryDetail:h,onBack:v,onCancel:f,onDone:j}=a,y=Le.has(l.type),p=d.match(/\[\[param\.(.+?)\]\]/),g=p?`{{ param('${p[1]}') }}`:"";return t.jsxs("div",{className:"space-y-4",children:[t.jsx(Ie,{control:l,scope:i,detail:h}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-[13px] font-medium text-foreground",children:"How cards use this control"}),t.jsxs("div",{className:"divide-y divide-border/60 overflow-hidden rounded-[6px] border border-border/60",children:[y?t.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Explorer cards"}),t.jsx("div",{className:"text-[12px] text-muted-foreground",children:x})]}):null,t.jsxs("div",{className:"space-y-1.5 px-3 py-2.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"SQL cards"}),t.jsx(me,{text:d,ariaLabel:"Copy SQL control reference"}),g?t.jsx(me,{text:g,ariaLabel:"Copy Jinja control reference"}):null,t.jsxs("p",{className:"text-[12px] text-muted-foreground",children:[u," ",t.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"}),"."]})]})]})]}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:v,children:"Back"}),tertiary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:f,children:"Cancel"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:j,children:"Done"})})]})}function Fe(a){const l=e.createBlankControl(a.scope,a.existingControls,a.reservedIds),i=a.type===l.type?{...l,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}:{...e.applyControlTypeChange({controls:[{...l,label:e.DEFAULT_LABEL_BY_TYPE[a.type]}],controlId:l.id,nextType:a.type}).controls[0],label:e.DEFAULT_LABEL_BY_TYPE[a.type]};return{step:2,control:i,defaultValue:e.getDefaultValueForType(i,void 0)}}function Be({scope:a,controls:l,reservedControlIds:i,defaultValues:d,onChange:x,emptyMessage:u,initialCreateFlow:h=!1,usageByControlId:v,availableFieldChoices:f,availableMetricChoices:j,structuralParticipants:y,structuralParticipantIdsByControlId:p,card:g,onCreateFlowActiveChange:S,onCreateFlowComplete:V}){const T=C.useMemo(()=>new Set(i||[]),[i]),H=e.getPlacementOptionsForScope(a),G=e.getDefaultPlacement(a),[K,O]=C.useState(null),[J,M]=C.useState(null),[r,N]=C.useState(()=>h?{step:1,control:e.createBlankControl(a,l,Array.from(T))}:null),B=C.useRef({}),E=C.useRef(void 0),Q=C.useRef(h),_=C.useMemo(()=>e.getFriendlyControlTypeOptions({scope:a,card:g}),[g,a]),I=C.useCallback(s=>a==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[a]),R=C.useMemo(()=>r?e.getEligibleParticipantsForStructuralControl(y||[],r.control.type):[],[r,y]),q=C.useMemo(()=>{if(!r)return{fields:f||[],metrics:j||[]};if(!I(r.control.type))return{fields:f||[],metrics:j||[]};const s=r.selectedCardIds||[],o=e.getCompatibleStructuralChoiceCatalog({controlType:r.control.type,participants:y||[],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,y]);C.useEffect(()=>{S==null||S(!!r)},[r,S]),C.useEffect(()=>{const s=h&&!Q.current;Q.current=h,s&&(N({step:1,control:e.createBlankControl(a,l,Array.from(T))}),M(null),O(null))},[l,h,T,a]);const X=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=e.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:y||[],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]})):[]}},U=s=>{if(!I(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const o=(p==null?void 0:p[s.control.id])||[],n=e.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:y||[],selectedCardIds:s.nextSelectedCardIds}),c=e.reconcileStructuralControlChoices({control:s.control,choices:n.choices}),b=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(b,e.buildStructuralControlBindingsForParticipants({control:c,participants:y||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:c,cardBindingsById:b}},F=C.useCallback((s,o=d,n={type:"update"})=>{const c=s.map(b=>(e.resolveAuthoringControlDefaultValue({control:b,defaultValues:o}),e.syncSqlQueryControlExecutionRequirement(b)));x(c,o,n)},[d,x]),P=(s,o)=>{const n=l.find(w=>w.id===s);let c=l.map(w=>w.id!==s?w:o(w));const b=c.find(w=>w.id===s);let D,m;if(b&&a==="dashboard"&&(b.type==="field_selector"||b.type==="metric_selector")){const w=(p==null?void 0:p[b.id])||[],z=U({control:b,nextSelectedCardIds:w});c=c.map(A=>A.id===s?z.nextControl:A),D=z.cardBindingsById,m=[b.id]}else if(n&&a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")){const w=(p==null?void 0:p[n.id])||[];D=Object.fromEntries(w.map(z=>[z,void 0])),m=[n.id]}const k=c.find(w=>w.id===s);let L=d;if(n&&k){const w=e.resolveAuthoringControlDefaultValue({control:n,defaultValues:d});n.source.kind==="manual"&&k.source.kind==="sql_query"&&(B.current[s]=w);const z=w===void 0&&n.source.kind==="sql_query"&&k.source.kind==="manual"?B.current[s]:w,A=e.getNextEditedControlDefaultValue({previousControl:n,nextControl:k,currentDefaultValue:z});k.source.kind==="manual"&&(B.current[s]=A),d&&(L={...d},A===void 0?delete L[s]:L[s]=A),c=c.map(ue=>ue.id===s?{...k,defaultValue:A}:ue)}F(c,L,{type:"update",cardBindingsById:D,affectedBindingControlIds:m})},be=(s,o)=>{const n=o.trim();if(n.length===0||n===s||T.has(n)||l.some(D=>D.id===n&&D.id!==s))return;const c=l.map(D=>D.id===s?{...D,id:n}:D);if(!d){F(c,void 0,{type:"rename",oldId:s,newId:n});return}const b={...d};Object.prototype.hasOwnProperty.call(b,s)&&(b[n]=b[s],delete b[s]),F(c,b,{type:"rename",oldId:s,newId:n})},ye=s=>{const o=l.filter(c=>c.id!==s);if(!d){F(o,void 0,{type:"remove",controlId:s});return}const n={...d};delete n[s],F(o,n,{type:"remove",controlId:s})},ve=C.useCallback(()=>{E.current=void 0,N({step:1,control:e.createBlankControl(a,l,Array.from(T))}),M(null),O(null)},[l,T,a]),Y=s=>{N(o=>o&&(()=>{const n=s(o.control);o.control.source.kind==="manual"&&n.source.kind==="sql_query"&&(E.current=o.defaultValue);const c=o.defaultValue===void 0&&o.control.source.kind==="sql_query"&&n.source.kind==="manual"?E.current:o.defaultValue,b=e.getNextEditedControlDefaultValue({previousControl:o.control,nextControl:n,currentDefaultValue:c});return n.source.kind==="manual"&&(E.current=b),{...o,control:n,defaultValue:b}})())},ne=s=>{N(o=>o&&(o.control.source.kind==="manual"&&(E.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:e.ensureManualSource(r.control);if(o.source.kind==="manual"&&(e.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:b}=o.source;return n.trim().length>0&&c.trim().length>0&&b.trim().length>0}return e.hasConcreteDefaultValue(e.getDefaultValueForType(o,r.defaultValue))})(),oe=()=>{var D;if(!r)return;const s=e.ensureManualSource(r.control),o=e.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:l,reservedIds:Array.from(T)}),n={...s,id:o},c=a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")&&((D=r.selectedCardIds)!=null&&D.length)?e.buildStructuralControlBindingsForParticipants({control:n,participants:y||[],selectedCardIds:r.selectedCardIds}):void 0,b=e.getDefaultValueForType(n,r.defaultValue);N({step:a==="dashboard"&&(n.type==="field_selector"||n.type==="metric_selector")?4:3,control:n,defaultValue:b,createdControlId:o,selectedCardIds:r.selectedCardIds,cardBindingsById:c})},Z=C.useCallback(()=>{N(null)},[]),ie=C.useCallback(()=>{if(!(r!=null&&r.createdControlId)){N(null);return}const s=r.control,o=r.createdControlId,n=e.getDefaultValueForType(s,r.defaultValue);if(d){const c={...d};n===void 0?delete c[o]:c[o]=n,F([...l,{...s,defaultValue:n}],c,{type:"add",cardBindingsById:r.cardBindingsById})}else F([...l,{...s,defaultValue:n}],void 0,{type:"add",cardBindingsById:r.cardBindingsById});M(o),N(null),V==null||V()},[l,r,d,F,V]),Ce=r?I(r.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],de=r!=null&&r.createdControlId?`[[param.${r.createdControlId}]]`:r?`[[param.${e.slugifyControlValue(r.control.label)||r.control.id}]]`:"",ee=e.buildAuthoringPreviewControlValues({controls:l,defaultValues:d}),te=r?[...l,r.control]:l,ce=r?e.buildAuthoringPreviewControlValues({controls:te,defaultValues:d,overrides:[{controlId:r.control.id,value:r.defaultValue}]}):ee;return t.jsxs("div",{className:"space-y-4",children:[r?t.jsxs("div",{className:"space-y-4 pb-1",children:[t.jsx(Te,{currentStep:r.step,labels:Ce}),r.step===1&&(()=>{const s=new Set(["grain_selector","aggregation_selector","field_selector","metric_selector"]),o=_.filter(b=>!s.has(b.value)),n=_.filter(b=>s.has(b.value)),c=b=>t.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:()=>N(Fe({scope:a,existingControls:l,reservedIds:Array.from(T),type:b.value})),children:[t.jsx("div",{className:"text-[13px] font-medium text-foreground",children:b.label}),t.jsx("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:b.description})]},b.value);return t.jsxs("div",{className:"space-y-4",children:[a==="card"&&(g==null?void 0:g.sql)==null?t.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&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Input controls"}),t.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:o.map(c)})]}),n.length>0&&t.jsxs("div",{className:"space-y-1.5",children:[t.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Data-driven controls"}),t.jsx("div",{className:"grid gap-1.5 sm:grid-cols-2",children:n.map(c)})]}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:Z,children:"Back to controls"})})]})})(),r.step===2&&I(r.control.type)&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(ge,{control:r.control,onChange:s=>Y(o=>({...o,label:s}))}),t.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),R.length===0?t.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."}):t.jsx("div",{className:"space-y-1 rounded-[6px] border border-border/60 bg-background p-2",children:R.map(s=>{const o=(r.selectedCardIds||[]).includes(s.cardId);return t.jsxs("label",{className:"flex items-start gap-2 rounded-[4px] px-1.5 py-1 text-[13px] hover:bg-muted/40",children:[t.jsx(e.Checkbox,{checked:o,onCheckedChange:n=>N(c=>c&&{...c,selectedCardIds:n===!0?[...c.selectedCardIds||[],s.cardId]:(c.selectedCardIds||[]).filter(b=>b!==s.cardId)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium text-foreground",children:s.title}),t.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)})}),t.jsx($,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",size:"xs",onClick:()=>N(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:t.jsx(e.Button,{type:"button",size:"xs",onClick:()=>N(s=>s&&{...s,step:3}),disabled:!W,children:"Next"})})]}),r.step===2&&!I(r.control.type)&&t.jsx(pe,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:q.fields,availableMetricChoices:q.metrics,previewControlDefinitions:te,previewControlValues:ce,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(o=>({...o,label:s})),onDefaultValueChange:ne,onBack:()=>N(s=>s&&{...s,step:1}),onNext:oe,nextDisabled:!W}),r.step===3&&I(r.control.type)&&t.jsx(pe,{control:r.control,defaultValue:r.defaultValue,availableFieldChoices:q.fields,availableMetricChoices:q.metrics,previewControlDefinitions:te,previewControlValues:ce,onControlChange:s=>Y(()=>s),onLabelChange:s=>Y(o=>({...o,label:s})),onDefaultValueChange:ne,onBack:()=>N(s=>s&&{...s,step:2}),onNext:oe,nextDisabled:!W}),r.step===3&&!I(r.control.type)&&t.jsx(xe,{control:r.control,scope:a,createdReference:de,explorerContent:t.jsxs(t.Fragment,{children:["Open the card and use"," ",t.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:()=>N(s=>s&&{...s,step:2}),onCancel:Z,onDone:ie}),r.step===4&&I(r.control.type)&&t.jsx(xe,{control:r.control,scope:a,createdReference:de,summaryDetail:t.jsxs(t.Fragment,{children:["Used by ",(r.selectedCardIds||[]).length," ","selected card",(r.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:t.jsx(t.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:()=>N(s=>s&&{...s,step:3}),onCancel:Z,onDone:ie})]}):null,!r&&l.length===0?t.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:u}):null,!r&&l.map(s=>{const o=X(s),n=v==null?void 0:v[s.id],c=e.resolveAuthoringControlDefaultValue({control:s,defaultValues:d}),b=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 t.jsxs("div",{className:"rounded-[6px] border border-border/60",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2.5",children:[t.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=>m===s.id?null:s.id),children:[b?t.jsx(e.ChevronDown,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}):t.jsx(e.ChevronRight,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",children:s.label||"Untitled control"}),t.jsx("span",{className:D,children:e.getFriendlyTypeOption(s.type).label}),t.jsx("span",{className:D,children:e.getPlacementLabel(a,s.placement)})]}),t.jsxs("div",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[e.getControlOptionPreview(s),n!=null&&n.status?` · ${n.status}`:""]})]})]}),t.jsx(e.Button,{type:"button",size:"xs",variant:"ghost",className:"h-7 w-7 shrink-0 p-0 text-muted-foreground",onClick:()=>ye(s.id),"aria-label":`Remove ${s.label}`,children:t.jsx(e.Trash2,{className:"h-3.5 w-3.5"})})]}),b&&t.jsxs("div",{className:"space-y-4 border-t border-border/60 px-3 py-3",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Label"}),t.jsx(e.Input,{size:"xs",value:s.label,placeholder:"Control label",onChange:m=>P(s.id,k=>({...k,label:m.target.value}))})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Type"}),t.jsxs(e.Select,{value:s.type,onValueChange:m=>{const k=e.applyControlTypeChange({controls:l,controlId:s.id,nextType:m,defaultValues:d});F(k.controls,k.defaultValues)},children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.getFriendlyControlTypeOptions({scope:a,card:g,includeType:s.type}).map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Show in"}),t.jsxs(e.Select,{value:s.placement||G,onValueChange:m=>P(s.id,k=>({...k,placement:m})),children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:H.map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),I(s.type)?t.jsx(e.StructuralParticipantSelector,{type:s.type,participants:e.getEligibleParticipantsForStructuralControl(y||[],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 k=U({control:s,nextSelectedCardIds:m}),L=l.map(w=>w.id===s.id?k.nextControl:w);F(L,d,{type:"update",cardBindingsById:k.cardBindingsById})}}):null,t.jsx(e.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:o.fields,availableMetricChoices:o.metrics,previewControlDefinitions:l,previewControlValues:ee,controlLifecycle:"edit",onChange:m=>P(s.id,()=>m)}),s.initialValueStrategy==="saved_default"&&t.jsx(e.ControlDefaultValueEditor,{control:s,value:c,allowNoDefault:!0,allowCardDefault:!0,previewControlDefinitions:l,previewControlValues:ee,onChange:m=>{const k=l.map(L=>L.id===s.id?{...L,defaultValue:m}:L);if(s.source.kind==="manual"&&(B.current[s.id]=m),d){const L={...d};m===void 0?delete L[s.id]:L[s.id]=m,F(k,L);return}F(k,void 0)}}),t.jsxs(e.Collapsible,{open:K===s.id,onOpenChange:m=>O(m?s.id:null),children:[t.jsx(e.CollapsibleTrigger,{asChild:!0,children:t.jsxs(e.Button,{type:"button",variant:"ghost",size:"xs",className:"-ml-2 gap-1 text-muted-foreground hover:text-foreground",children:[K===s.id?t.jsx(e.ChevronDown,{className:"h-3.5 w-3.5"}):t.jsx(e.ChevronRight,{className:"h-3.5 w-3.5"}),"Advanced"]})}),t.jsxs(e.CollapsibleContent,{className:"space-y-3 pt-2",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Control ID"}),t.jsx(e.ControlIdInput,{controlId:s.id,onCommit:m=>be(s.id,m)},s.id)]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(e.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Initial value"}),t.jsxs(e.Select,{value:s.initialValueStrategy,onValueChange:m=>P(s.id,k=>({...k,initialValueStrategy:m})),children:[t.jsx(e.SelectTrigger,{size:"xs",children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.INITIAL_VALUE_STRATEGY_OPTIONS.map(m=>t.jsx(e.SelectItem,{value:m.value,children:m.label},m.value))})]})]})]}),t.jsx(e.ControlVisibilitySettings,{control:s,onChange:m=>P(s.id,()=>m)})]})]})]})]},s.id)}),!r&&t.jsxs(e.Button,{type:"button",variant:"outline",size:"xs",onClick:ve,children:[t.jsx(e.Plus,{className:"h-3.5 w-3.5"}),"Add control"]})]})}function _e(a){const{open:l,onOpenChange:i,initialCreateFlowActive:d=!1,dismissMode:x="passive"}=a,u=l!==void 0,[h,v]=C.useState(!1),[f,j]=C.useState(d),y=u?l:h,p=C.useCallback(V=>{!V&&f&&x==="passive"||(u||v(V),V||j(!1),i==null||i(V))},[u,f,x,i]),g=C.useCallback(()=>{u||v(!1),j(!1),i==null||i(!1)},[u,i]);C.useEffect(()=>{y||j(!1)},[y]);const S=C.useCallback(V=>{f&&V.preventDefault()},[f]);return{forceClose:g,handleOpenChange:p,isCreateFlowActive:f,preventPassiveDismissDuringCreate:S,resolvedOpen:y,setIsCreateFlowActive:j}}exports.CircleX=je;exports.ControlDefinitionListEditor=Be;exports.EditorAcceptButton=Ne;exports.EditorCancelButton=Ee;exports.EditorClearButton=Ve;exports.Library=fe;exports.Link2=he;exports.Save=re;exports.VisualBadge=ke;exports.VisualSaveAndApplyButton=we;exports.VisualSaveButton=De;exports.useCreateFlowOverlayState=_e;exports.useEffectiveEditorCardType=le;