1import{i as _e,u as ze,r as a,j as e,L as Ce}from"./react-vendor-CSsSSEML.js";import{f as xe,E as $e,j as A,B as T,h as me,i as pe,D as he,M as Ge,I as oe,P as fe,S as Q,G as Be}from"./index-BVsjb7mB.js";import{D as Ue}from"./DetailSkeleton-BOcVjxYM.js";import{E as Fe}from"./ErrorState-CE1mnLGb.js";import{T as He}from"./Tabs-i18bnVDL.js";import{c as Ye}from"./useSchedules-BOmPAb2o.js";import{e as We,f as Ve,g as Ze,h as Ke,b as qe,c as Je}from"./useScheduleMutations-xfESBj0A.js";import{C as J}from"./ConfirmDialog-BvaLv-yh.js";import{S as Qe,O as ge}from"./OverrideCascadeWarning-C65gUL0d.js";import{u as Xe,R as je,V as be}from"./ReviewedBlastRadiusNote-BcVfqtRX.js";import{i as es,c as ye,a as ve,N as ae,S as ss,b as ts}from"./ScheduleForm-DtPY221R.js";import{u as Se}from"./useResources-Dn15QQUL.js";import{u as Ae}from"./useGroups-BAd--nxI.js";import{R as rs,T as ns}from"./TagsBadge-BD-3toVV.js";import{u as as}from"./useResourceFilterState-e6VKY49x.js";import{u as os}from"./useDebouncedValue-x0dK07ix.js";import{c as Ne}from"./TypeToConfirmInput-BRI3yPKX.js";import{I as is}from"./InfoTooltip-riKjpznF.js";import{R as cs}from"./ResourcePickerItem-B53tm2cN.js";import{u as ls,i as ds,N as us,b as xs}from"./useClusterNamespaces-Cwuybh9h.js";import{u as ms,a as ps}from"./useBulkResourceActions-CTD3vG1R.js";import"./tanstack-vendor-D2LStv3_.js";import"./sentry-vendor-DQkRq1-W.js";import"./useBlastReturnStore-CSaK7-O7.js";import"./cron-vendor-CU8bkBry.js";import"./dateUtils-DUSSJeme.js";import"./SearchableSelect-BM_5_tjW.js";import"./formDirty-KbNXPJ_S.js";import"./GroupedAccountDropdown-DnL0M513.js";import"./GroupedTypeDropdown-iViufUrm.js";import"./FilterChips-CaksgMJ0.js";import"./useCopyToClipboard-D1iEeEhF.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"33b2f1a2eb67da61a8a79f4c3c0fca45c630c2e5"};var l=new s.Error().stack;l&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[l]="00eeaac0-a0ec-4646-8b23-ef88f840b9db",s._sentryDebugIdIdentifier="sentry-dbid-00eeaac0-a0ec-4646-8b23-ef88f840b9db")}catch{}})();const hs=new Set(["eks-cluster","gke-cluster","aks-cluster"]),X=20;function fs({className:s="w-3.5 h-3.5"}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:s,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})})}function gs({className:s="w-3.5 h-3.5"}){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:s,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})}const B={dot:"bg-success-500",text:"text-success-600",bg:"bg-success-50"},U={dot:"bg-danger-500",text:"text-danger-600",bg:"bg-danger-50"},Y={dot:"bg-warning-500",text:"text-warning-600",bg:"bg-warning-50"},we={dot:"bg-text-muted",text:"text-text-muted",bg:"bg-neutral-100"},ke={running:B,active:B,available:B,ready:B,online:B,"in-use":B,stopped:U,suspended:U,deallocated:U,failed:U,error:U,terminated:U,pending:Y,creating:Y,starting:Y,stopping:Y,"shutting-down":Y,unknown:we,_default:we};function Le(){const{data:s=[]}=Be(),l=a.useMemo(()=>Object.fromEntries(s.map(t=>[t.cloudAccountId||t.id,t.permissionLevel])),[s]);return a.useCallback(t=>l[t]==="read_only",[l])}function js({attachedResources:s,onAttach:l,selected:t,onToggleSelect:h,showSelectedList:y,onToggleSelectedList:f,onClearAll:x}){const{data:d}=Ae(),[c,u]=a.useState(""),v=os(c,300),[w,j]=a.useState([1]),[k,o]=a.useState(!0),b=a.useMemo(()=>{const m={};for(const N of d??[])for(const g of N.members??[])m[g.resourceUid]=N.name;return m},[d]),n=a.useCallback(()=>{j([1]),o(!0)},[]),i=as({locked:{schedulable:"schedulable"},onFilterChange:n}),R=w[w.length-1],{isLoading:M}=Se({page:R,limit:X,search:v,...i.filterParams}),E=a.useMemo(()=>new Set((s||[]).map(m=>m.resourceId||m.id)),[s]);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsxs("div",{className:"shrink-0 mb-4 space-y-3 rounded-xl bg-surface-secondary/50 border border-border p-3",children:[e.jsxs("div",{className:"relative",children:[e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-text-muted pointer-events-none",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z"})}),e.jsx("input",{type:"text",placeholder:"Search resources...",value:c,onChange:m=>{u(m.target.value),n()},className:"w-full pl-9 pr-8 py-2 bg-surface border border-border-strong rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-primary-600/20 focus:border-primary-600/40 transition-all"}),c&&e.jsx("button",{type:"button",onClick:()=>{u(""),n()},className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary transition-colors",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-4 w-4",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})})]}),e.jsx(rs,{selectedAccountIds:i.selectedAccountIds,groupedAccountData:i.groupedAccountData,onAccountChange:i.setSelectedAccountIds,schedulableHidden:!0,status:i.status,statusOptions:i.statusOptions,onStatusChange:i.setStatus,selectedTypes:i.selectedTypes,availableTypes:i.availableTypes,onTypeChange:i.setSelectedTypes,region:i.region,regionOptions:i.regionOptions,onRegionChange:i.setRegion,activeFilterCount:i.activeFilterCount,onReset:i.resetFilters,isLoading:i.isFiltersLoading,compact:!0})]}),t.size>0&&e.jsxs("div",{className:"shrink-0 space-y-3",children:[e.jsx(Re,{type:"resources",selected:t,showList:y,onToggleList:f,onClearAll:x,onToggleSelect:h}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"flex-1 border-t border-border"}),e.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wide shrink-0",children:"All Resources"}),e.jsx("div",{className:"flex-1 border-t border-border"})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-3 px-3 py-2 border-b border-border bg-surface-secondary/50 rounded-t-lg text-[11px] font-medium uppercase tracking-wider text-text-muted",children:[e.jsx("span",{className:"w-4 shrink-0"}),e.jsx("span",{className:"w-5 shrink-0"}),e.jsx("span",{className:"flex-[3] min-w-0",children:"Name"}),e.jsx("span",{className:"flex-[1.5]",children:"Type"}),e.jsx("span",{className:"flex-[1]",children:"Inst. Type"}),e.jsx("span",{className:"w-10 text-center",children:"Tags"}),e.jsx("span",{className:"flex-[1.5]",children:"Region"}),e.jsx("span",{className:"flex-[1.2]",children:"Status"})]}),e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto",onScroll:m=>{const N=m.currentTarget;k&&!M&&N.scrollTop+N.clientHeight>=N.scrollHeight-20&&j(g=>{const D=g[g.length-1]+1;return g.includes(D)?g:[...g,D]})},children:[w.map(m=>e.jsx(bs,{page:m,search:v,filterParams:i.filterParams,attachedIds:E,selected:t,onToggleSelect:h,onAttach:l,groupedResources:b,onLoaded:N=>{m*X>=N&&o(!1)}},`${v}-${JSON.stringify(i.filterParams)}-${m}`)),!k&&e.jsx("p",{className:"text-xs text-text-muted text-center py-2 border-t border-border mt-1",children:"You've reached the end of the list"})]})]})})]})}function bs({page:s,search:l,filterParams:t={},attachedIds:h,selected:y,onToggleSelect:f,onAttach:x,onLoaded:d,groupedResources:c={}}){const{data:u,isLoading:v}=Se({page:s,limit:X,search:l,...t}),w=a.useMemo(()=>u?.items||[],[u?.items]),j=a.useMemo(()=>w.filter(n=>!h.has(n.id)),[w,h]),k=Le(),o=u?.hasMore,b=a.useRef(void 0);return a.useEffect(()=>{o!==void 0&&o!==b.current&&(b.current=o,o||d(s*X))},[o,d,s]),v?e.jsx(Q,{className:"w-4 h-4 mx-auto my-2"}):j.length===0&&s===1?e.jsx("p",{className:"text-xs text-text-muted",children:"No available resources to attach."}):j.map(n=>{const i=k(n.cloudAccountId),R=c[n.uid],M=!!R,E=i||M,m=n.status?.toLowerCase()??"",N=ke[m]||ke._default;return e.jsxs("div",{onClick:()=>!E&&f(n),className:`flex items-center gap-3 px-3 py-2 border-b border-border transition-colors ${E?"opacity-50 cursor-not-allowed":"cursor-pointer"} ${!E&&y.has(n.id)?"bg-primary-600/10":"hover:bg-surface-elevated"}`,title:M?`Part of group "${R}". Attach the schedule to the group instead.`:i?"This resource belongs to a read-only cloud account.":void 0,children:[e.jsx("input",{type:"checkbox",checked:y.has(n.id),onChange:()=>!E&&f(n),onClick:g=>g.stopPropagation(),disabled:E,className:"rounded border-border-strong bg-surface-tertiary accent-primary-600 shrink-0"}),e.jsx(oe,{provider:n.provider,className:"h-5 w-5 shrink-0"}),e.jsxs("div",{className:"min-w-0 flex-[3] shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[e.jsx(A,{content:n.name||n.uid,onlyOnOverflow:!0,children:e.jsx("span",{className:"font-medium text-sm text-text-primary truncate cursor-default",children:n.name||n.uid})}),M&&e.jsx(A,{content:`This resource is part of group "${R}". Attach the schedule to the group instead.`,className:"leading-relaxed",children:e.jsxs("span",{className:"shrink-0 inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[10px] text-text-muted bg-surface-tertiary/70",children:[e.jsx("svg",{className:"w-3 h-3",viewBox:"0 0 20 20",fill:"currentColor",children:e.jsx("path",{d:"M3.75 3A1.75 1.75 0 002 4.75v3.26a3.235 3.235 0 011.75-.51h12.5c.644 0 1.245.188 1.75.51V6.75A1.75 1.75 0 0016.25 5h-4.836a.25.25 0 01-.177-.073L9.823 3.513A1.75 1.75 0 008.586 3H3.75zM3.75 9A1.75 1.75 0 002 10.75v4.5c0 .966.784 1.75 1.75 1.75h12.5A1.75 1.75 0 0018 15.25v-4.5A1.75 1.75 0 0016.25 9H3.75z"})}),R]})}),i&&e.jsx("span",{className:"text-[10px] text-warning-500 font-medium shrink-0",children:"Read-only"})]}),n.uid&&n.name&&n.uid!==n.name&&e.jsx(A,{content:n.uid,onlyOnOverflow:!0,children:e.jsx("span",{className:"font-mono text-[11px] text-text-muted truncate block cursor-default",children:n.uid})})]}),e.jsx(A,{content:n.type||"â",onlyOnOverflow:!0,children:e.jsx("span",{className:"font-mono text-xs text-text-muted truncate flex-[1.5] shrink-0 cursor-default",children:n.type||"â"})}),n.instanceType?e.jsx(A,{content:n.instanceType,onlyOnOverflow:!0,children:e.jsx("span",{className:"font-mono text-xs bg-surface-tertiary/70 px-1.5 py-0.5 rounded text-text-secondary truncate flex-[1] shrink-0 cursor-default",children:n.instanceType})}):e.jsx("span",{className:"text-xs text-text-muted flex-[1] shrink-0",children:"â"}),e.jsx("span",{className:"w-10 shrink-0 flex justify-center",children:e.jsx(ns,{tags:n.tags})}),e.jsx(A,{content:n.region||"â",onlyOnOverflow:!0,children:e.jsx("span",{className:"font-mono text-xs text-text-muted truncate flex-[1.5] shrink-0 cursor-default",children:n.region||"â"})}),e.jsx("span",{className:"flex-[1.2] shrink-0",children:m?e.jsxs("span",{className:`inline-flex items-center gap-1 text-[10px] font-semibold px-1.5 py-0.5 rounded-md whitespace-nowrap ${N.bg}/60 ${N.text}`,children:[e.jsx("span",{className:`h-1.5 w-1.5 rounded-full shrink-0 ${N.dot}`}),m]}):e.jsx("span",{className:"text-xs text-text-muted",children:"â"})})]},n.id)})}function ys({attachedGroups:s,onAttach:l,selected:t,onToggleSelect:h,showSelectedList:y,onToggleSelectedList:f,onClearAll:x}){const[d,c]=a.useState(""),{data:u=[],isLoading:v}=Ae(),w=Le(),j=a.useMemo(()=>new Set((s||[]).map(o=>o.groupId||o.id)),[s]),k=a.useMemo(()=>{const o=u.filter(n=>!j.has(n.id));if(!d)return o;const b=d.toLowerCase();return o.filter(n=>(n.name||"").toLowerCase().includes(b))},[u,j,d]);return e.jsxs("div",{children:[e.jsxs("div",{className:"relative mb-3",children:[e.jsx("input",{type:"text",placeholder:"Search groups...",value:d,onChange:o=>c(o.target.value),className:"w-full px-3 pr-8 py-2 bg-surface-tertiary border border-border-strong rounded-lg text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-primary-600/30"}),d&&e.jsx("button",{type:"button",onClick:()=>c(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary transition-colors",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"h-3.5 w-3.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m9.75 9.75 4.5 4.5m0-4.5-4.5 4.5M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z"})})})]}),t.size>0&&e.jsxs(e.Fragment,{children:[e.jsx(Re,{type:"groups",selected:t,showList:y,onToggleList:f,onClearAll:x,onToggleSelect:h}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[e.jsx("div",{className:"flex-1 border-t border-border"}),e.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wide shrink-0",children:"All Groups"}),e.jsx("div",{className:"flex-1 border-t border-border"})]})]}),v?e.jsx(Q,{className:"w-4 h-4"}):k.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:"No available groups to attach."}):e.jsxs("div",{className:"space-y-1",children:[k.map(o=>e.jsxs("div",{onClick:()=>h(o),className:`flex items-start gap-3 text-xs px-3 py-2.5 rounded-lg border cursor-pointer transition-colors duration-fast ${t.has(o.id)?"bg-primary-600/10 border-primary-600/30":"border-transparent hover:bg-surface-elevated"}`,children:[e.jsx("input",{type:"checkbox",checked:t.has(o.id),onChange:()=>h(o),onClick:b=>b.stopPropagation(),className:"mt-0.5 rounded border-border-strong bg-surface-tertiary accent-primary-600 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary text-sm",children:o.name}),o.members?.length>0&&e.jsxs("span",{className:"text-xs text-text-muted",children:["(",o.members.length," resources)"]})]}),o.description&&e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:o.description}),o.members?.some(b=>w(b.cloudAccountId))&&e.jsxs("p",{className:"text-xs text-warning-500 mt-1",children:["Some resources in this group are read-only and won't be scheduled."," ",e.jsx(Ce,{to:"/settings/cloud-accounts",className:"text-primary-600 hover:text-primary-500 underline",onClick:b=>b.stopPropagation(),children:"Upgrade permissions"})]})]}),e.jsx("button",{onClick:b=>
1{b.stopPropagation(),l(o)},className:"text-xs text-text-link hover:text-text-link-hover font-medium ml-2 shrink-0",children:"Attach"})]},o.id)),e.jsx("p",{className:"text-xs text-text-muted text-center py-2 border-t border-border mt-1",children:"You've reached the end of the list"})]})]})}function Re({type:s,selected:l,showList:t,onToggleList:h,onClearAll:y,onToggleSelect:f}){const x=a.useMemo(()=>Array.from(l.values()),[l]),d=s==="resources"?"Resource":"Group";return e.jsxs("div",{className:"flex flex-col gap-2 mb-3",children:[e.jsxs("div",{className:"flex items-center justify-between bg-primary-600 text-text-inverse rounded-lg px-4 py-2.5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm font-semibold",children:[l.size," ",d,l.size>1?"s":""," Selected"]}),e.jsx("button",{type:"button",onClick:h,className:"text-sm underline underline-offset-2 opacity-90 hover:opacity-100 transition-opacity",children:t?"Hide":"See all"})]}),e.jsx("button",{type:"button",onClick:y,className:"text-sm underline underline-offset-2 opacity-90 hover:opacity-100 transition-opacity",children:"Clear all"})]}),t&&x.length>0&&e.jsx("div",{className:"max-h-60 overflow-y-auto space-y-1 border border-border rounded-lg p-2 bg-surface-secondary",children:x.map(c=>e.jsxs("div",{className:"flex items-start gap-3 text-xs px-3 py-2.5 rounded-lg border bg-primary-600/10 border-primary-600/30",children:[e.jsx("input",{type:"checkbox",checked:!0,onChange:()=>f(c),className:"mt-0.5 rounded border-border-strong bg-surface-tertiary accent-primary-600 shrink-0"}),s==="resources"?e.jsx(cs,{resource:c}):e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-text-primary text-sm",children:c.groupName||c.name}),c.members?.length>0&&e.jsxs("span",{className:"text-xs text-text-muted",children:["(",c.members.length," resources)"]}),c.description&&e.jsx("p",{className:"text-xs text-text-muted mt-0.5",children:c.description})]})]},c.id))})]})}function tt(){const{id:s}=_e(),l=ze(),{data:t,isLoading:h,isError:y,error:f,refetch:x}=Ye(s),[d,c]=a.useState("resources"),[u,v]=a.useState(null),[w,j]=a.useState(!1),[k,o]=a.useState(!1),[b,n]=a.useState(!1),[i,R]=a.useState(null),[M,E]=a.useState(!1),[m,N]=a.useState(!1);Xe(r=>{r?.kind==="update"?(R(r.pendingUpdate??null),n(!0)):r?.kind==="delete"&&j(!0),N(!0)});const g=xe(fe.SCHEDULE_UPDATE),D=xe(fe.SCHEDULE_DELETE),[C,z]=a.useState(null),[$,W]=a.useState(()=>new Map),[ie,F]=a.useState(!1),[Te,Pe]=a.useState(()=>new Set),[I,ee]=a.useState(null),[_,se]=a.useState(null),Ee=a.useCallback(r=>{Pe(p=>{const S=new Set(p);return S.has(r)?S.delete(r):S.add(r),S})},[]),ce=a.useCallback(r=>{W(p=>{const S=new Map(p);return S.has(r.id)?S.delete(r.id):S.set(r.id,r),S})},[]),G=a.useCallback(()=>{v(null),W(new Map),F(!1)},[]),De=We(s),te=Ve(s),Ie=Ze(s),re=Ke(s),le=qe(),de=Je(),Oe=a.useCallback(()=>{const r=Array.from($.values());if(r.length===0){G();return}z({type:u==="resources"?"resource":"group",items:r}),G()},[u,$,G]),O=a.useMemo(()=>es(t?.crons||[]),[t?.crons]),ne=a.useMemo(()=>ye(t?.crons||[],O),[t?.crons,O]),P=a.useMemo(()=>ve(ne,O),[ne,O]),V=t?.resources??[];if(h)return e.jsx(Ue,{});if(y)return e.jsx(Fe,{title:"Failed to load schedule details",error:f,onRetry:x,resource:"schedule details"});if(!t)return e.jsx($e,{title:"Schedule not found",description:"The schedule you are looking for does not exist or has been deleted."});const Z=t.groups??[],Me=[{value:"resources",label:"Resources",count:V.length},{value:"groups",label:"Groups",count:Z.length}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 min-w-0",children:[e.jsx("button",{onClick:()=>l(-1),className:"text-text-muted hover:text-text-primary transition-colors mt-1 shrink-0",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-5 h-5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18"})})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary truncate",children:t.name}),e.jsx("span",{className:"text-sm text-text-secondary shrink-0",children:t.timezone})]}),t.description&&e.jsx(A,{content:t.description,onlyOnOverflow:!0,children:e.jsx("p",{className:"text-sm text-text-secondary mt-0.5 line-clamp-2",children:t.description})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(T,{variant:"action",size:"sm",onClick:()=>o(!0),disabled:!g,title:g?void 0:"You don't have permission. Contact your admin.",children:"Edit"}),e.jsx(T,{variant:"delete",size:"sm",onClick:()=>j(!0),disabled:!D,title:D?void 0:"You don't have permission. Contact your admin.",children:"Delete"})]})]}),e.jsx(J,{open:b,onClose:()=>{n(!1),R(null),N(!1)},onConfirm:()=>{if(i){const{newSavingsPercent:r,...p}=i;me(pe.SCHEDULE_UPDATED,{schedule_id:p.id??s,cron_count:p.crons?.length,timezone:p.timezone}),de.mutate(p,{onSuccess:()=>{o(!1),n(!1),R(null)}})}},title:"Update Schedule",message:`Are you sure you want to update "${t.name}"? Start/stop timing will change for all attached resources.`,confirmLabel:"Update Schedule",variant:"primary",isLoading:de.isPending,children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(ae,{crons:i?.crons,timezone:i?.timezone}),m&&e.jsx(je,{}),e.jsx(be,{targetId:t.id,targetType:"schedule",operation:"modify",extraParams:{scheduleSavingsPercent:P.savingsPercent,scheduleNewSavingsPercent:i?.newSavingsPercent??P.savingsPercent,from:"schedules"},reopen:{kind:"update",label:"schedule",pendingUpdate:i},onClose:()=>n(!1)})]})}),e.jsx(J,{open:w,onClose:()=>{j(!1),N(!1)},onConfirm:()=>{le.mutate(t.id,{onSuccess:()=>l("/schedules")})},title:"Delete Schedule",message:`Are you sure you want to delete "${Ne(t)}"? Resources will no longer be automatically started/stopped.`,confirmLabel:"Delete",loadingLabel:"Deleting...",variant:"delete",isLoading:le.isPending,typeToConfirm:Ne(t),requireTypeToConfirm:!0,children:e.jsxs("div",{className:"space-y-3",children:[m&&e.jsx(je,{}),e.jsx(Qe,{}),e.jsx(be,{targetId:t.id,targetType:"schedule",operation:"delete",extraParams:{scheduleSavingsPercent:P.savingsPercent,from:"schedules"},reopen:{kind:"delete",label:"schedule"},onClose:()=>j(!1)})]})}),e.jsx(he,{open:k,onClose:()=>o(!1),title:"Edit Schedule",half:!0,footer:e.jsxs(e.Fragment,{children:[e.jsx(T,{type:"button",variant:"secondary",onClick:()=>o(!1),children:"Cancel"}),e.jsx(T,{type:"submit",form:"schedule-edit-form",disabled:!M,children:"Update"})]}),children:e.jsx(ss,{onDirtyChange:E,defaultValues:{name:t.name||"",description:t.description||"",timezone:t.timezone||"UTC",crons:t.crons?.length?t.crons.map(r=>({cronExpression:r.cronExpression,action:r.action})):[{cronExpression:"",action:"stop"}]},formId:"schedule-edit-form",onSubmit:r=>{const p=ye(r.crons||[],O),S=ve(p,O);R({id:t.id,...r,newSavingsPercent:S.savingsPercent}),n(!0)}})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline gap-6",children:[e.jsxs("div",{className:"inline-flex items-center gap-1",children:[e.jsxs("span",{className:"text-2xl font-semibold text-text-primary",children:[P.savingsPercent,"%"]}),e.jsx("span",{className:"text-text-secondary ml-1.5",children:"Estimated Savings"}),e.jsx(is,{text:P.savingsPercent===0?"Resources run all week â no scheduled downtime.":P.savingsPercent===100?"Resources are stopped all week.":`Resources are stopped ${P.inactiveHours} of 168 hours per week, saving an estimated ${P.savingsPercent}% on compute costs.`})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-2xl font-semibold text-text-primary",children:P.activeHours}),e.jsx("span",{className:"text-text-secondary ml-1.5",children:"Active Hours"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-2xl font-semibold text-text-primary",children:P.inactiveHours}),e.jsx("span",{className:"text-text-secondary ml-1.5",children:"Inactive Hours"})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 shrink-0",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 px-3 py-1 rounded-md border border-border text-xs font-medium text-text-secondary",children:[O===60?"1 hour":`${O} min`," interval"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-text-muted",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-success-400"}),"Running"]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs text-text-muted",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-danger-200"}),"Stopped"]})]})]}),e.jsx(ae,{crons:t.crons,timezone:t.timezone}),e.jsx("div",{className:"overflow-x-auto",children:e.jsx(ts,{grid:ne,onChange:()=>{},slotMinutes:O,readOnly:!0,labelBgClass:"bg-surface-secondary"})}),e.jsx(He,{tabs:Me,active:d,onChange:c}),d==="resources"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Attached Resources"}),e.jsx(T,{variant:"primary",size:"xs",onClick:()=>g&&v("resources"),disabled:!g,title:g?void 0:"You don't have permission. Contact your admin.",children:"+ Attach"})]}),V.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No resources attached."}):e.jsx("div",{className:"bg-surface border border-border rounded-xl overflow-hidden shadow-xs",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-[700px] w-full divide-y divide-border table-fixed",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"18%"}}),e.jsx("col",{style:{width:"18%"}}),e.jsx("col",{className:"w-12"})]}),e.jsx("thead",{className:"bg-surface-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 text-[10px] font-semibold uppercase tracking-wider text-text-muted text-left",children:"Resource"}),e.jsx("th",{className:"px-3 py-3 text-[10px] font-semibold uppercase tracking-wider text-text-muted text-left",children:"Type"}),e.jsx("th",{className:"px-3 py-3 text-[10px] font-semibold uppercase tracking-wider text-text-muted text-left",children:"Region"}),e.jsx("th",{className:"px-3 py-3 text-[10px] font-semibold uppercase tracking-wider text-text-muted text-center",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-border",children:V.map((r,p)=>e.jsx(vs,{resource:r,idx:p,canUpdate:g,onDetach:()=>se(r)},r.id))})]})})})]}),C&&e.jsxs(Ge,{open:!!C,onClose:()=>z(null),title:C.type==="resource"?`Attach Resource${C.items.length>
11?"s":""}`:`Attach Group${C.items.length>1?"s":""}`,children:[e.jsxs("p",{className:"text-sm text-text-secondary mb-2",children:["Are you sure you want to attach the following"," ",C.type==="resource"?"resource":"group",C.items.length>1?"s":""," to this schedule?"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-4",children:C.items.map(r=>e.jsx("span",{className:"font-mono font-semibold text-text-primary bg-surface-tertiary px-1.5 py-0.5 rounded text-sm",children:C.type==="resource"?r.name||r.uid:r.name||r.groupName},r.id))}),e.jsx("div",{className:"mb-4",children:e.jsx(ae,{crons:t.crons,timezone:t.timezone,note:"Attaching won't start or stop anything now â attached items follow the schedule from its next trigger onward."})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx(T,{onClick:()=>{const r=[];for(const p of C.items)C.type==="resource"?r.push(De.mutateAsync(p)):r.push(Ie.mutateAsync(p.id));Promise.all(r).then(()=>{me(pe.SCHEDULE_ATTACHED,{schedule_id:s,target_type:C.type,count:C.items.length})}).catch(()=>{}),z(null)},children:"Attach"}),e.jsx(T,{variant:"secondary",onClick:()=>z(null),children:"Cancel"})]})]}),d==="groups"&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Attached Groups"}),e.jsx(T,{variant:"primary",size:"xs",onClick:()=>g&&v("groups"),disabled:!g,title:g?void 0:"You don't have permission. Contact your admin.",children:"+ Attach"})]}),Z.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:"No groups attached."}):e.jsx("div",{className:"bg-surface border border-border rounded-xl overflow-hidden shadow-xs",children:e.jsx("div",{className:"divide-y divide-border",children:Z.map(r=>{const p=r.id||r.groupId,S=r.name||r.groupName,ue=r.description||r.groupDescription,H=r.members??[],K=Te.has(p),q=H.length>0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs px-4 py-3",children:[e.jsx("button",{type:"button",onClick:()=>q&&Ee(p),disabled:!q,title:q?K?"Collapse":"Expand resources":"No resources in this group",className:`shrink-0 w-6 h-6 inline-flex items-center justify-center rounded-md transition-all ${q?"hover:bg-surface-tertiary text-text-secondary cursor-pointer":"text-text-muted/40 cursor-not-allowed"}`,"aria-expanded":K,children:e.jsx(fs,{className:`w-3.5 h-3.5 transition-transform duration-fast ${K?"rotate-90":""}`})}),e.jsxs("div",{className:"flex-1 min-w-0 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx(Ce,{to:`/resource-groups/${p}`,className:"font-semibold text-text-primary text-sm hover:text-primary-600 transition-colors truncate",children:S}),e.jsxs("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-semibold bg-primary-600/10 text-primary-700",children:[H.length," ",H.length===1?"resource":"resources"]})]}),ue&&e.jsx("p",{className:"text-xs text-text-muted mt-0.5 line-clamp-1",children:ue})]}),e.jsx("button",{onClick:()=>D&&ee(r),disabled:!D,title:D?"Detach Group":"You don't have permission. Contact your admin.",className:`transition-colors duration-fast shrink-0 ml-2 mr-1 ${D?"text-danger-500 hover:text-danger-400":"text-text-muted cursor-not-allowed opacity-40"}`,children:e.jsx(gs,{})})]}),K&&H.length>0&&e.jsxs("div",{className:"border-t border-border bg-surface-secondary/40 px-4 py-2",children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-text-muted mb-2",children:"Resources in this group"}),e.jsx("ul",{className:"divide-y divide-border/60",children:H.map(L=>e.jsxs("li",{className:"flex items-center gap-2.5 py-2",children:[e.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg bg-surface-tertiary border border-border shrink-0",children:e.jsx(oe,{provider:L.provider,className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(A,{content:L.resourceName||L.resourceUid,onlyOnOverflow:!0,children:e.jsx("p",{className:"text-xs font-semibold text-text-primary truncate cursor-default",children:L.resourceName||L.resourceUid})}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 text-[10px] text-text-muted",children:[L.resourceType&&e.jsx("span",{className:"font-mono",children:L.resourceType}),L.region&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx("span",{children:L.region})]})]})]})]},L.id||L.resourceId||L.resourceUid))})]})]},p)})})})]}),e.jsx(J,{open:!!I,onClose:()=>{re.isPending||ee(null)},onConfirm:async()=>
1{if(I)try{await re.mutateAsync(I.groupId||I.id)}catch{}finally{ee(null)}},title:"Detach Group from Schedule",message:I?`Detach "${I.name||I.groupName}" from this schedule? The group's resources will no longer follow this schedule.`:"",confirmLabel:"Detach",variant:"delete",isLoading:re.isPending,children:e.jsx(ge,{groupId:I?.groupId||I?.id})}),e.jsx(J,{open:!!_,onClose:()=>{te.isPending||se(null)},onConfirm:async()=>{if(_)try{await te.mutateAsync(_.resourceId)}catch{}finally{se(null)}},title:"Detach Resource from Schedule",message:_?`Detach "${_.resourceName||_.resourceUid}" from this schedule? It will no longer be automatically started/stopped.`:"",confirmLabel:"Detach",variant:"delete",isLoading:te.isPending,children:e.jsx(ge,{resourceUid:_?.resourceUid})}),e.jsxs(he,{open:!!u,onClose:G,title:u==="resources"?"Attach Resources":"Attach Groups",half:!0,footer:$.size>0&&e.jsx("div",{className:"flex justify-end w-full",children:e.jsxs(T,{size:"sm",onClick:Oe,children:["Attach ",$.size," Selected"]})}),children:[u==="resources"&&e.jsx(js,{attachedResources:V,selected:$,onToggleSelect:ce,showSelectedList:ie,onToggleSelectedList:()=>F(r=>!r),onClearAll:()=>{W(new Map),F(!1)},onAttach:r=>{z({type:"resource",items:[r]}),G()}}),u==="groups"&&e.jsx(ys,{attachedGroups:Z,selected:$,onToggleSelect:ce,showSelectedList:ie,onToggleSelectedList:()=>F(r=>!r),onClearAll:()=>{W(new Map),F(!1)},onAttach:r=>{z({type:"group",items:[r]}),G()}})]})]})}function vs({resource:s,idx:l,canUpdate:t,onDetach:h}){const y=hs.has(s.resourceType),[f,x]=a.useState(!1),d=l%2===1?"bg-surface-secondary/30":"";return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{className:`hover:bg-primary-50/20 transition-colors ${d}`,children:[e.jsx("td",{className:"px-4 py-3 max-w-0",children:e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[y?e.jsx("button",{type:"button",onClick:()=>x(c=>!c),"aria-label":f?"Collapse cluster":"Expand cluster to show namespaces","aria-expanded":f,className:"w-5 h-5 flex items-center justify-center rounded hover:bg-primary-50 text-text-secondary transition-transform shrink-0",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:`w-3 h-3 transition-transform ${f?"rotate-90":""}`,children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m8.25 4.5 7.5 7.5-7.5 7.5"})})}):e.jsx("span",{className:"w-5 h-5 shrink-0","aria-hidden":"true"}),e.jsx("div",{className:"w-7 h-7 flex items-center justify-center rounded-lg bg-surface border border-border shadow-xs shrink-0",children:e.jsx(oe,{provider:s.provider,className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx(A,{content:s.resourceName||s.resourceUid,onlyOnOverflow:!0,children:e.jsx("p",{className:"text-sm font-semibold text-text-primary truncate cursor-default",children:s.resourceName||s.resourceUid})}),s.resourceUid&&s.resourceName&&e.jsx(A,{content:s.resourceUid,onlyOnOverflow:!0,children:e.jsx("p",{className:"text-[10px] font-mono text-text-muted mt-0.5 truncate cursor-default",children:s.resourceUid})})]})]})}),e.jsx("td",{className:"px-3 py-3 max-w-0",children:e.jsx(A,{content:s.resourceType??"â",onlyOnOverflow:!0,children:e.jsx("span",{className:"font-mono text-xs text-text-muted truncate block cursor-default",children:s.resourceType??"â"})})}),e.jsx("td",{className:"px-3 py-3 max-w-0",children:e.jsx(A,{content:s.region??"â",onlyOnOverflow:!0,children:e.jsx("span",{className:"text-xs font-medium text-text-secondary whitespace-nowrap truncate block cursor-default",children:s.region??"â"})})}),e.jsx("td",{className:"px-3 py-3 text-center",children:e.jsx("button",{onClick:()=>t&&h(),disabled:!t,title:t?"Detach Resource":"You don't have permission. Contact your admin.",className:`transition-colors duration-fast ${t?"text-danger-500 hover:text-danger-400":"text-text-muted cursor-not-allowed opacity-40"}`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",className:"w-3.5 h-3.5",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0"})})})})]}),y&&f&&e.jsx("tr",{className:d,children:e.jsx("td",{colSpan:4,className:"p-0",children:e.jsx(Ns,{clusterResourceUid:s.resourceUid,clusterType:s.resourceType,clusterProvider:s.provider,clusterCloudAccountId:s.cloudAccountId,clusterRegion:s.region,canUpdate:t})})})]})}function Ns({clusterResourceUid:s,clusterType:l,clusterProvider:t,clusterCloudAccountId:h,clusterRegion:y,canUpdate:f}){const x=us[l],{data:d,isLoading:c,isError:u,error:v,refetch:w,isFetching:j}=ls({clusterResourceUid:s,clusterType:l,enabled:!0}),k=d?.namespaces??[],o=k.filter(i=>!ds(i.name)),b=d?.truncated??!1,n=d?.total??k.length;return c?e.jsxs("div",{className:"px-12 py-3 text-xs text-text-muted",children:[e.jsx(Q,{size:"xs"}),e.jsx("span",{className:"ml-2",children:"Loading namespacesâ¦"})]}):u?e.jsxs("div",{className:"px-12 py-3 text-xs",children:[e.jsxs("span",{className:"text-danger-600",children:["Failed to load namespaces: ",v?.message||"unknown error","."]}),e.jsx("button",{type:"button",onClick:()=>w(),className:"ml-2 text-primary-600 hover:text-primary-500 underline",children:"Retry"})]}):o.length?e.jsxs("div",{className:"bg-surface-secondary/40",children:[o.map(i=>e.jsx(ws,{ns:i,namespaceType:x,clusterResourceUid:s,clusterProvider:t,clusterCloudAccountId:h,clusterRegion:y,canUpdate:f},i.id||i.uid)),b&&e.jsxs("div",{className:"pl-12 pr-3 py-2 text-[11px] text-warning-600 border-t border-border/60",children:["Showing first ",k.length," of ",n," namespaces. Refine the cluster filter to see the rest."]}),j&&e.jsxs("div",{className:"pl-12 py-1 text-[10px] text-text-muted",children:[e.jsx(Q,{size:"xs"}),e.jsx("span",{className:"ml-1",children:"Refreshingâ¦"})]})]}):e.jsx("div",{className:"px-12 py-3 text-xs text-text-muted",children:"No schedulable namespaces under this cluster."})}function ws({ns:s,namespaceType:l,clusterResourceUid:t,clusterProvider:h,clusterCloudAccountId:y,clusterRegion:f,canUpdate:x}){const d=xs(),c=()=>d(t),u=ms({onSettled:c}),v=ps({onSettled:c}),w={uid:s.uid,provider:s.provider??h,type:l,cloudAccountId:s.cloudAccountId??y,region:s.region??f},j=u.isPending||v.isPending;return e.jsxs("div",{className:"flex items-center gap-3 pl-12 pr-3 py-2 border-t border-border/60",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-xs font-medium text-text-primary truncate",children:s.name}),e.jsx(A,{content:s.uid,onlyOnOverflow:!0,children:e.jsx("p",{className:"text-[10px] font-mono text-text-muted truncate cursor-default",children:s.uid})})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx(T,{size:"xs",variant:"secondary",disabled:!x||j,onClick:()=>x&&u.mutate([w]),title:x?"Start namespace":"You don't have permission. Contact your admin.",children:"Start"}),e.jsx(T,{size:"xs",variant:"danger",disabled:!x||j,onClick:()=>x&&v.mutate([w]),title:x?"Stop namespace":"You don't have permission. Contact your admin.",children:"Stop"})]})]})}export{tt as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.