@leverege/imaginarium-ui 1.2.0 → 1.2.2

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.
@@ -0,0 +1,5 @@
1
+ "use strict";const Ie=require("./PluginTypes-C4a2lmPj.cjs"),e=require("react/jsx-runtime"),y=require("react"),g=require("./Card-CHVaz_7u.cjs"),de=require("./SystemConfigsContext-yOuS10VO.cjs"),I=require("@tanstack/react-query"),S=require("lucide-react"),be=require("@leverege/plugin"),T=require("./Label-BhnvyUcc.cjs"),he=require("./Tooltip-DQn1fHhM.cjs");function Le({open:t,onOpenChange:s,onCreated:n}){const r=be.Config.get("Release","apiPath","/releases"),{toast:o}=g.useToast(),{fetchJson:c}=g.useImaginariumApi(),a=I.useQueryClient(),{configs:d}=de.useSystemConfigs(),[h,v]=y.useState(""),[N,l]=y.useState(""),[m,O]=y.useState(""),[B,Q]=y.useState([]),H=["imaginarium","releases",r],U=()=>{v(""),l(""),O(""),Q([])},z=y.useMemo(()=>d.filter(f=>f.id!==m),[d,m]),A=f=>{O(f),Q(E=>E.filter(x=>x!==f))},L=f=>{Q(E=>E.includes(f)?E.filter(x=>x!==f):[...E,f])},p=I.useMutation({mutationFn:async()=>{const f=await c(r,{method:"POST",body:JSON.stringify({name:h.trim(),description:N.trim()||null,originConfigId:m,targetConfigIds:B})});return await c(`${r}/${f.id}/snapshot-from-compare`,{method:"POST",body:JSON.stringify({})}),f},onSuccess:f=>{a.invalidateQueries({queryKey:H}),o({title:"Success",description:"Release created and snapshotted"}),s(!1),U(),n(f.id)},onError:f=>{o({title:"Error",description:f.message,variant:"destructive"})},onSettled:()=>{a.invalidateQueries({queryKey:H})}}),w=f=>{f||U(),s(f)},k=!!(h.trim()&&m&&B.length>0);return e.jsx(T.Dialog,{open:t,onOpenChange:w,children:e.jsxs(T.DialogContent,{children:[e.jsxs(T.DialogHeader,{children:[e.jsx(T.DialogTitle,{children:"New Release"}),e.jsx(T.DialogDescription,{children:"Create a release from an origin cluster and snapshot the diff against its targets."})]}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:"release-name",children:"Name"}),e.jsx(T.Input,{id:"release-name",value:h,onChange:f=>v(f.target.value),placeholder:"2026.05 Release"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:"release-description",children:"Description (Optional)"}),e.jsx(T.Input,{id:"release-description",value:N,onChange:f=>l(f.target.value),placeholder:"What this release contains"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:"release-origin",children:"Origin Cluster"}),e.jsxs("select",{id:"release-origin",value:m,onChange:f=>A(f.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"",children:"Select origin…"}),d.map(f=>e.jsx("option",{value:f.id,children:f.displayName},f.id))]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{children:"Target Clusters"}),z.length>0?e.jsx("div",{className:"space-y-1 rounded-md border border-input p-2 max-h-48 overflow-y-auto",children:z.map(f=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:B.includes(f.id),onChange:()=>L(f.id)}),f.displayName]},f.id))}):e.jsx("p",{className:"text-xs text-muted-foreground",children:m?"No other clusters available as targets.":"Select an origin first."})]})]}),e.jsxs(T.DialogFooter,{children:[e.jsxs(g.Button,{variant:"outline",onClick:()=>w(!1),disabled:p.isPending,children:[e.jsx(S.X,{className:"w-4 h-4 mr-2"}),"Cancel"]}),e.jsx(g.Button,{onClick:()=>p.mutate(),disabled:!k||p.isPending,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(S.Loader2,{className:"w-4 h-4 mr-2 animate-spin"}),"Snapshotting…"]}):e.jsxs(e.Fragment,{children:[e.jsx(S.Save,{className:"w-4 h-4 mr-2"}),"Create & snapshot"]})})]})]})})}function Ne({status:t}){const s=t==="pushed"?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":"bg-muted text-muted-foreground border-border";return e.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium border ${s}`,children:t})}function Je({onOpen:t}){const s=be.Config.get("Release","apiPath","/releases"),{fetchJson:n}=g.useImaginariumApi(),{configs:r}=de.useSystemConfigs(),[o,c]=y.useState(!1),a=["imaginarium","releases",s],{data:d,isLoading:h}=I.useQuery({queryKey:a,queryFn:async()=>{const l=await n(s);return[...Array.isArray(l)?l:(l==null?void 0:l.items)??[]].sort((O,B)=>(B.createdAt??"").localeCompare(O.createdAt??""))}}),v=y.useMemo(()=>{const l=new Map;return r.forEach(m=>l.set(String(m.id),m.displayName)),l},[r]),N=l=>v.get(l)??l;return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"flex items-center justify-end",children:e.jsxs(g.Button,{onClick:()=>c(!0),children:[e.jsx(S.Plus,{className:"w-4 h-4 mr-2"}),"New Release"]})}),h?e.jsx("div",{className:"text-center text-muted-foreground",children:"Loading…"}):d&&d.length>0?e.jsx(g.Card,{children:e.jsx(g.CardContent,{className:"p-0",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"p-3 font-medium",children:"Name"}),e.jsx("th",{className:"p-3 font-medium",children:"Origin"}),e.jsx("th",{className:"p-3 font-medium",children:"Targets"}),e.jsx("th",{className:"p-3 font-medium",children:"Status"}),e.jsx("th",{className:"p-3 font-medium",children:"Snapshot"}),e.jsx("th",{className:"p-3 font-medium",children:"Pushed"}),e.jsx("th",{className:"p-3 font-medium"})]})}),e.jsx("tbody",{children:d.map(l=>e.jsxs("tr",{className:"border-b last:border-0 cursor-pointer hover:bg-muted/50",onClick:()=>t(l.id),children:[e.jsxs("td",{className:"p-3",children:[e.jsx("div",{className:"font-medium",children:l.name}),l.description?e.jsx("div",{className:"text-xs text-muted-foreground",children:l.description}):null]}),e.jsx("td",{className:"p-3",children:N(l.originConfigId)}),e.jsx("td",{className:"p-3",children:e.jsx("div",{className:"flex flex-wrap gap-1",children:(l.targetConfigIds??[]).map(m=>e.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:N(m)},m))})}),e.jsx("td",{className:"p-3",children:e.jsx(Ne,{status:l.status})}),e.jsx("td",{className:"p-3 text-muted-foreground",children:l.snapshotAt?new Date(l.snapshotAt).toLocaleString():"—"}),e.jsx("td",{className:"p-3 text-muted-foreground",children:l.pushedAt?new Date(l.pushedAt).toLocaleString():"—"}),e.jsx("td",{className:"p-3 text-right",children:e.jsx(g.Button,{variant:"ghost",size:"sm",onClick:m=>{m.stopPropagation(),t(l.id)},children:"Open →"})})]},l.id))})]})})}):e.jsx(g.Card,{children:e.jsxs(g.CardContent,{className:"py-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No releases yet"}),e.jsxs(g.Button,{onClick:()=>c(!0),children:[e.jsx(S.Plus,{className:"w-4 h-4 mr-2"}),"Create Your First Release"]})]})}),e.jsx(Le,{open:o,onOpenChange:c,onCreated:t})]})}function Ve({originName:t,className:s}){const n=t?`Skipped in your last release from ${t}.`:"Skipped in your last release.";return e.jsx(he.TooltipProvider,{children:e.jsxs(he.Tooltip,{children:[e.jsx(he.TooltipTrigger,{asChild:!0,children:e.jsx("span",{className:g.cn("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","bg-muted text-muted-foreground cursor-default select-none",s),children:"previously skipped"})}),e.jsx(he.TooltipContent,{side:"top",children:n})]})})}function He({className:t}){return e.jsx("span",{className:g.cn("inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium","bg-red-500/10 text-red-600 dark:text-red-400 border border-red-500/25",t),children:"ignored"})}function Ue({ignoreRule:t,createPayload:s,apiPath:n="/release-ignores",onChange:r,className:o}){const{toast:c}=g.useToast(),{fetchJson:a}=g.useImaginariumApi(),d=I.useQueryClient(),[h,v]=y.useState(!1),N=!!t,l=()=>{d.invalidateQueries({queryKey:["imaginarium","release-ignores"]}),r==null||r()},m=I.useMutation({mutationFn:()=>a(n,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{c({title:"Item ignored",description:"Will be excluded from all future snapshots."}),v(!1),l()},onError:Q=>{c({title:"Error",description:Q.message,variant:"destructive"})}}),O=I.useMutation({mutationFn:()=>a(`${n}/${t.id}`,{method:"DELETE"}),onSuccess:()=>{c({title:"Item un-ignored",description:"Will appear normally in future snapshots."}),l()},onError:Q=>{c({title:"Error",description:Q.message,variant:"destructive"})}}),B=m.isPending||O.isPending;return e.jsxs(e.Fragment,{children:[e.jsx(g.Button,{variant:"ghost",size:"icon",title:N?"Remove from ignore list":"Ignore this item",disabled:B,onClick:()=>N?O.mutate():v(!0),className:g.cn(N&&"text-red-500 hover:text-red-500 dark:text-red-400 dark:hover:text-red-400",o),children:e.jsx(S.Ban,{})}),e.jsx(T.Dialog,{open:h,onOpenChange:v,children:e.jsxs(T.DialogContent,{children:[e.jsxs(T.DialogHeader,{children:[e.jsx(T.DialogTitle,{children:"Ignore this item?"}),e.jsxs(T.DialogDescription,{children:["Ignoring excludes this item from ",e.jsx("strong",{children:"this and all future releases"})," for this origin cluster — it will never be pushed to any destination. You can un-ignore it later from the Ignored tab."]})]}),e.jsxs(T.DialogFooter,{children:[e.jsx(g.Button,{variant:"outline",onClick:()=>v(!1),disabled:m.isPending,children:"Cancel"}),e.jsxs(g.Button,{variant:"destructive",onClick:()=>m.mutate(),disabled:m.isPending,children:[e.jsx(S.Ban,{className:"w-4 h-4 mr-2"}),"Ignore item"]})]})]})})]})}function Ye({releaseId:t,apiPath:s="/releases",onReset:n}){const{toast:r}=g.useToast(),{fetchJson:o}=g.useImaginariumApi(),c=I.useQueryClient(),a=I.useMutation({mutationFn:()=>o(`${s}/${t}/reset-exclusions`,{method:"POST"}),onSuccess:d=>{c.invalidateQueries({queryKey:["imaginarium","release-items",t]}),r({title:"Exclusions reset",description:`${d.reset} item${d.reset===1?"":"s"} re-enabled.`}),n==null||n(d.reset)},onError:d=>{r({title:"Error",description:d.message,variant:"destructive"})}});return e.jsxs(g.Button,{variant:"outline",size:"sm",onClick:()=>a.mutate(),disabled:a.isPending,children:[e.jsx(S.RotateCcw,{}),a.isPending?"Resetting…":"Reset exclusions"]})}function pe({label:t,value:s,highlightLines:n}){return e.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[e.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:t}),e.jsx("pre",{className:"flex-1 overflow-auto rounded border bg-muted/30 p-3 text-xs",children:n===void 0?s===void 0?"null":JSON.stringify(s,null,2):(s===void 0?"null":JSON.stringify(s,null,2)).split(`
2
+ `).map((r,o)=>e.jsx("div",{className:n[o]?"bg-yellow-200/70 text-yellow-950 dark:bg-yellow-400/20 dark:text-yellow-100":void 0,children:r===""?" ":r},o))})]})}function Ee(t){return t===void 0?"null":JSON.stringify(t,null,2)}function _e(t,s,n){let r=Ee(t);if(n&&n.length>0)for(const{replace:m,with:O}of n)m&&(r=r.split(m).join(O));const o=r.split(`
3
+ `),c=Ee(s).split(`
4
+ `),a=o.length,d=c.length,h=Array.from({length:a+1},()=>new Array(d+1).fill(0));for(let m=a-1;m>=0;m-=1)for(let O=d-1;O>=0;O-=1)h[m][O]=o[m]===c[O]?h[m+1][O+1]+1:Math.max(h[m+1][O],h[m][O+1]);const v=new Array(a).fill(!0);let N=0,l=0;for(;N<a&&l<d;)o[N]===c[l]?(v[N]=!1,N+=1,l+=1):h[N+1][l]>=h[N][l+1]?N+=1:l+=1;return v}function ge({title:t,values:s,excluded:n,editable:r,onToggle:o,formatLabel:c}){const[a,d]=y.useState(n.length>0);return y.useEffect(()=>{n.length>0&&d(!0)},[n.length]),e.jsxs("div",{className:"border-b p-2",children:[e.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-2",onClick:()=>d(h=>!h),"aria-expanded":a,children:[e.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[a?e.jsx(S.ChevronDown,{size:12}):e.jsx(S.ChevronRight,{size:12}),t," (",n.length,")"]}),r?null:e.jsx("span",{className:"text-[10px] text-muted-foreground",children:"read-only"})]}),a?e.jsx("div",{className:"mt-1 flex flex-col gap-1",children:s.map(h=>{const v=!n.includes(h);return e.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 shrink-0",checked:v,disabled:!r,onChange:N=>o==null?void 0:o(h,N.target.checked)}),e.jsx("span",{className:`min-w-0 break-all font-mono ${v?"":"text-muted-foreground line-through"}`,children:c?c(h):h})]},h)})}):null]})}function Xe({item:t,targets:s,onClose:n,unmetDependencyNames:r=[],tags:o=[],excludedTags:c=[],editable:a=!0,onToggleTag:d,metadataKeys:h=[],excludedMetadataKeys:v=[],onToggleMetadataKey:N,i18nPaths:l=[],excludedI18nPaths:m=[],onToggleI18nPath:O,permissionKeys:B=[],excludedPermissions:Q=[],onTogglePermission:H,formatPermissionLabel:U,replacementMaps:z}){var Y,J,V,q;const A=((Y=s[0])==null?void 0:Y.id)??null,[L,p]=y.useState(A);y.useEffect(()=>{var D;p(((D=s[0])==null?void 0:D.id)??null)},[t==null?void 0:t.id]);const w=s.find(D=>D.id===L)??s[0]??null,k=(J=t==null?void 0:t.diff)==null?void 0:J.byTarget,f=k!=null,E=f?k[(w==null?void 0:w.id)??""]:(V=t==null?void 0:t.diff)==null?void 0:V.target,x=f&&w!=null&&!(w.id in k),F=y.useMemo(()=>{var D;return x?void 0:_e((D=t==null?void 0:t.diff)==null?void 0:D.origin,E,z==null?void 0:z[(w==null?void 0:w.id)??""])},[t,E,x,z,w==null?void 0:w.id]);return t?e.jsxs("div",{className:"flex h-full flex-col rounded-md border bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium",children:t.itemName}),e.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:t.itemType})]}),e.jsx(g.Button,{variant:"ghost",size:"icon",title:"Close",onClick:n,children:e.jsx(S.X,{})})]}),r.length>0?e.jsxs("div",{className:"flex items-start gap-2 border-b bg-amber-50 p-2 text-xs text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",children:[e.jsx(S.AlertTriangle,{size:14,className:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),e.jsxs("span",{children:["Depends on excluded items: ",r.join(", "),". Push will fail for this item until they're included."]})]}):null,o.length>0?e.jsx(ge,{title:"Tag Overrides",values:o,excluded:c,editable:a,onToggle:d}):null,h.length>0?e.jsx(ge,{title:"Metadata Overrides",values:h,excluded:v,editable:a,onToggle:N}):null,l.length>0?e.jsx(ge,{title:"Translation Overrides",values:l,excluded:m,editable:a,onToggle:O}):null,B.length>0?e.jsx(ge,{title:"Permission Overrides",values:B,excluded:Q,editable:a,onToggle:H,formatLabel:U}):null,s.length>0?e.jsx("div",{className:"flex flex-wrap gap-1 border-b p-2",children:s.map(D=>{const W=f&&!(D.id in k);return e.jsxs("button",{type:"button",onClick:()=>p(D.id),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs ${D.id===(w==null?void 0:w.id)?"bg-muted font-medium":"hover:bg-muted/50"}`,children:[W?e.jsx(S.Check,{size:12,className:"text-green-600"}):e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-red-500","aria-hidden":!0}),D.name]},D.id)})}):null,e.jsxs("div",{className:"flex flex-1 gap-3 overflow-auto p-3",children:[e.jsx(pe,{label:"Origin",value:(q=t.diff)==null?void 0:q.origin,highlightLines:F}),x?e.jsxs("div",{className:"flex min-w-0 flex-1 items-center justify-center rounded border bg-muted/30 p-3 text-xs text-muted-foreground",children:["Matches ",w==null?void 0:w.name," — no differences."]}):e.jsx(pe,{label:(w==null?void 0:w.name)??"Target",value:E})]})]}):null}function jt({state:t}){switch(t.status){case"pushing":return e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(S.Loader2,{className:"h-4 w-4 animate-spin"}),"Pushing…"]});case"success":return e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-emerald-600",children:[e.jsx(S.Check,{className:"h-4 w-4"}),"Success"]});case"partial":return e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-amber-600",children:[e.jsx(S.AlertTriangle,{className:"h-4 w-4"}),"Partial — ",t.failed??0," failed"]});case"failed":return e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-destructive",title:t.error,children:[e.jsx(S.X,{className:"h-4 w-4"}),"Failed"]});default:return e.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-muted-foreground",children:[e.jsx(S.Circle,{className:"h-3 w-3"}),"Pending"]})}}function We({open:t,onOpenChange:s,releaseId:n,targetConfigIds:r,targetNames:o,apiPath:c="/releases",onComplete:a,dependencyWarnings:d=[]}){const{toast:h}=g.useToast(),{fetchJson:v}=g.useImaginariumApi(),N=I.useQueryClient(),[l,m]=y.useState(!1),[O,B]=y.useState({}),[Q,H]=y.useState(!1),U=p=>(o==null?void 0:o[p])??p,z=(p,w)=>B(k=>({...k,[p]:w})),A=async()=>{m(!0),H(!1),B(Object.fromEntries(r.map(k=>[k,{status:"idle"}])));let p=0,w=0;for(const k of r){z(k,{status:"pushing"});try{const f=await v(`${c}/${n}/push`,{method:"POST",body:JSON.stringify({destConfigId:k})}),E=(f.results??[]).filter(x=>!x.ok);f.status==="success"?(p+=1,z(k,{status:"success"})):f.status==="partial"?(w+=1,z(k,{status:"partial",failed:E.length,failures:E})):(w+=1,z(k,{status:"failed",failures:E}))}catch(f){w+=1;const E=f instanceof Error?f.message:String(f);z(k,{status:"failed",error:E})}}N.invalidateQueries({queryKey:["imaginarium","releases"]}),N.invalidateQueries({queryKey:["imaginarium","release",n]}),N.invalidateQueries({queryKey:["imaginarium","release-items",n]}),N.invalidateQueries({queryKey:["imaginarium","release-pushes",n]}),h(w===0?{title:"Push complete",description:`Pushed to ${p} target${p===1?"":"s"}.`}:{title:"Push finished with errors",description:`${w} target${w===1?"":"s"} did not fully succeed.`,variant:"destructive"}),m(!1),H(!0),a==null||a()},L=p=>{l||(p||(B({}),H(!1)),s(p))};return e.jsx(T.Dialog,{open:t,onOpenChange:L,children:e.jsxs(T.DialogContent,{children:[e.jsxs(T.DialogHeader,{children:[e.jsx(T.DialogTitle,{children:"Push release"}),e.jsx(T.DialogDescription,{children:"Pushes the included items to each target cluster, one at a time. Each target re-compares against the latest origin before applying."})]}),d.length>0?e.jsxs("div",{className:"space-y-1 rounded border border-amber-200 bg-amber-50 p-3 text-xs text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-300",children:[e.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[e.jsx(S.AlertTriangle,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),d.length," item",d.length===1?"":"s"," reference excluded dependencies"]}),e.jsx("ul",{className:"list-disc space-y-0.5 pl-8",children:d.map(p=>e.jsxs("li",{children:[p.itemName," → ",p.missing.join(", ")]},p.itemName))}),e.jsx("p",{className:"pl-8 text-amber-600",children:"Push may fail for these items. You can proceed anyway."})]}):null,e.jsx("div",{className:"space-y-2 py-2",children:r.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"This release has no targets."}):r.map(p=>{const w=O[p]??{status:"idle"},k=w.failures??[];return e.jsxs("div",{className:"rounded border px-3 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium",children:U(p)}),e.jsx(jt,{state:w})]}),k.length>0?e.jsx("ul",{className:"mt-2 max-h-48 space-y-1 overflow-auto border-t pt-2 text-xs",children:k.map((f,E)=>e.jsxs("li",{className:"text-destructive",children:[e.jsxs("span",{className:"font-mono",children:[f.action?`${f.action} `:"",f.itemKey??"item"]}),f.error?e.jsxs("span",{className:"text-muted-foreground",children:[" — ",f.error]}):null]},`${f.itemKey??"item"}-${E}`))}):null]},p)})}),e.jsxs(T.DialogFooter,{children:[e.jsx(g.Button,{variant:"outline",onClick:()=>L(!1),disabled:l,children:"Close"}),e.jsxs(g.Button,{variant:"destructive",onClick:A,disabled:l||Q||r.length===0,children:[e.jsx(S.Send,{className:"w-4 h-4 mr-2"}),l?"Pushing…":"Confirm push"]})]})]})})}function bt(t){var s;return(((s=t.diff)==null?void 0:s.versions)??[]).filter(n=>!n.existsOnTarget)}function Nt({item:t,disabled:s,onChange:n}){var o;const r=((o=t.diff)==null?void 0:o.versions)??[];return e.jsxs("select",{value:t.selectedVersion??"",disabled:s,onClick:c=>c.stopPropagation(),onChange:c=>n(c.target.value),className:"h-7 rounded-md border border-input bg-background px-2 py-0.5 text-xs disabled:cursor-not-allowed disabled:opacity-50","aria-label":"Rule version",children:[e.jsx("option",{value:"",disabled:!0,children:"Select a version"}),r.map(c=>{const a=String(c.version),d=c.existsOnTarget?`v${c.version} — already on target`:`v${c.version}${c.isPublished?" (published)":""}`;return e.jsx("option",{value:a,disabled:c.existsOnTarget,children:d},a)})]})}const vt={blueprint:"bg-blue-100 text-blue-700 dark:bg-blue-500/15 dark:text-blue-300",rule:"bg-orange-100 text-orange-700 dark:bg-orange-500/15 dark:text-orange-300",messageRoute:"bg-teal-100 text-teal-700 dark:bg-teal-500/15 dark:text-teal-300",role:"bg-purple-100 text-purple-700 dark:bg-purple-500/15 dark:text-purple-300",enum:"bg-yellow-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300",resourceEnum:"bg-yellow-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300",timer:"bg-slate-100 text-slate-600 dark:bg-slate-500/20 dark:text-slate-300",network:"bg-green-100 text-green-700 dark:bg-green-500/15 dark:text-green-300",module:"bg-indigo-100 text-indigo-700 dark:bg-indigo-500/15 dark:text-indigo-300",permission:"bg-pink-100 text-pink-700 dark:bg-pink-500/15 dark:text-pink-300",template:"bg-red-100 text-red-800 dark:bg-red-500/15 dark:text-red-300",script:"bg-amber-100 text-amber-800 dark:bg-amber-500/15 dark:text-amber-300",scenario:"bg-cyan-100 text-cyan-700 dark:bg-cyan-500/15 dark:text-cyan-300",system:"bg-gray-200 text-gray-700 dark:bg-gray-500/20 dark:text-gray-300",attribute:"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300",enumValue:"bg-violet-100 text-violet-700 dark:bg-violet-500/15 dark:text-violet-300",project:"bg-fuchsia-50 text-fuchsia-800 dark:bg-fuchsia-500/15 dark:text-fuchsia-300"};function re({type:t}){const s=vt[t]??"bg-muted text-muted-foreground";return e.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-semibold ${s}`,children:t})}function fe({checked:t,onChange:s,disabled:n=!1}){return e.jsxs("label",{className:`relative inline-block h-[18px] w-8 shrink-0 ${n?"cursor-not-allowed opacity-40":"cursor-pointer"}`,children:[e.jsx("input",{type:"checkbox",className:"peer sr-only",checked:t,disabled:n,onChange:r=>s(r.target.checked)}),e.jsx("span",{className:"absolute inset-0 rounded-full bg-input transition-colors peer-checked:bg-primary"}),e.jsx("span",{className:"absolute left-0.5 top-0.5 h-3.5 w-3.5 rounded-full bg-white transition-transform peer-checked:translate-x-3.5"})]})}function Ge(t){const s=new Map;for(const r of t){const o=s.get(r.destConfigId);(!o||r.createdAt>o.createdAt)&&s.set(r.destConfigId,r)}const n=new Map;for(const r of s.values())for(const o of r.results??[]){if(!o.itemKey)continue;let c=n.get(o.itemKey);c||(c=new Map,n.set(o.itemKey,c)),c.set(r.destConfigId,{ok:o.ok,error:o.error})}return n}function Ze(t,s,n){var r;return(r=t.get(s))==null?void 0:r.get(n)}function Ct(t,s){return t.filter(n=>!(s.type!=="all"&&n.itemType!==s.type||s.included==="enabled"&&(!n.included||n.ignored)||s.included==="disabled"&&n.included&&!n.ignored))}function et(t){const s={};for(const n of t)s[n.itemType]=(s[n.itemType]??0)+1;return s}function wt(t){const s=t.indexOf(":"),n=s>=0?t.slice(0,s):t,r=s>=0?t.slice(s+1):t;return{id:"",releaseId:"",itemKey:t,itemType:n,itemName:r,parentKey:null,selectedVersion:null,status:"updated",included:!0,carriedOver:!1,ignored:!1,diff:null,createdAt:"",updatedAt:""}}function tt(t){var c;const s=new Set(t.filter(a=>!a.parentKey).map(a=>a.itemKey)),n=[],r=new Map;for(const a of t){if(a.parentKey)continue;const d={item:a,children:[]};n.push(d),r.set(a.itemKey,d)}const o=new Map;for(const a of t){if(!a.parentKey)continue;if(s.has(a.parentKey)){(c=r.get(a.parentKey))==null||c.children.push(a);continue}let d=o.get(a.parentKey);d||(d={item:wt(a.parentKey),children:[],synthetic:!0},o.set(a.parentKey,d),n.push(d)),d.children.push(a)}return n}function kt(t){const s=t.indexOf(":"),n=s>=0?t.slice(0,s):t,r=s>=0?t.slice(s+1):t;return{itemKey:t,itemType:n,itemName:r,parentKey:null,cells:{}}}function st(t){var c;const s=new Set(t.filter(a=>!a.parentKey).map(a=>a.itemKey)),n=[],r=new Map;for(const a of t){if(a.parentKey)continue;const d={row:a,children:[]};n.push(d),r.set(a.itemKey,d)}const o=new Map;for(const a of t){if(!a.parentKey)continue;if(s.has(a.parentKey)){(c=r.get(a.parentKey))==null||c.children.push(a);continue}let d=o.get(a.parentKey);d||(d={row:kt(a.parentKey),children:[],synthetic:!0},o.set(a.parentKey,d),n.push(d)),d.children.push(a)}return n}function nt(t){let s=0;for(const n of t.children)n.included&&!n.ignored&&(s+=1);return{included:s,total:t.children.length}}function it(t){var r,o;const s=[];for(const c of t){if(c.status!=="new")continue;const a=(r=c.diff)==null?void 0:r.origin,d=a==null?void 0:a.id;if(typeof d=="string"&&d&&s.push({token:d,depKey:c.itemKey}),c.itemType==="enum"){const h=a==null?void 0:a.type;typeof h=="string"&&h&&s.push({token:h,depKey:c.itemKey})}}const n=new Map;for(const c of t){const a=new Set,d=JSON.stringify(((o=c.diff)==null?void 0:o.origin)??null);for(const{token:h,depKey:v}of s)v!==c.itemKey&&d.includes(h)&&a.add(v);n.set(c.itemKey,a)}return n}function oe(t,s,n){const r=s.get(t.itemKey);if(!r||r.size===0)return[];const o=[];for(const c of r){const a=n.get(c);a&&a.status==="new"&&(!a.included||a.ignored)&&o.push(a)}return o}const Me=["blueprint","system","network","enum","resourceEnum","timer","messageRoute","role","permission","module","scenario","template","project","rule","script"];function Oe(t){const s=Me.indexOf(t);return s===-1?Me.length:s}function ye(t,s){const n=Oe(t)-Oe(s);return n!==0?n:t.localeCompare(s)}function St(t){return t.tags+t.metadataKeys+t.i18nPaths+t.permissions}function Tt(t){const s=[];return t.tags>0&&s.push(`${t.tags} tag${t.tags===1?"":"s"}`),t.metadataKeys>0&&s.push(`${t.metadataKeys} metadata key${t.metadataKeys===1?"":"s"}`),t.i18nPaths>0&&s.push(`${t.i18nPaths} translation${t.i18nPaths===1?"":"s"}`),t.permissions>0&&s.push(`${t.permissions} permission${t.permissions===1?"":"s"}`),s.length===0?"":`${s.join(", ")} excluded from push`}const Pt=[{value:"all",label:"All"},{value:"enabled",label:"Enabled"},{value:"disabled",label:"Disabled"}];function De(t,s){return s==="all"?!0:s==="enabled"?t.included&&!t.ignored:!t.included||t.ignored}function Re({status:t}){return e.jsx("span",{className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium border bg-muted text-muted-foreground border-border",children:t})}function G(t){if(Array.isArray(t))return t.filter(s=>typeof s=="string");if(typeof t=="string"&&t.length>0)try{const s=JSON.parse(t);return Array.isArray(s)?s.filter(n=>typeof n=="string"):[]}catch{return[]}return[]}function Ae({item:t}){const s={tags:G(t.excludedTags).length,metadataKeys:G(t.excludedMetadataKeys).length,i18nPaths:G(t.excludedI18nPaths).length,permissions:G(t.excludedPermissions).length},n=St(s);return n<=0?null:e.jsxs("span",{title:Tt(s),className:"inline-flex items-center rounded px-1.5 py-0.5 text-xs bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300",children:[n," manual override",n===1?"":"s"]})}function Be({item:t,targetConfigIds:s,results:n,pushedDests:r,displayName:o}){const c=t.included&&!t.ignored,a=s.filter(d=>r.has(d)).map(d=>({id:d,result:Ze(n,t.itemKey,d)})).filter(d=>d.result!=null||c);return a.length===0?null:e.jsx("div",{className:"flex flex-wrap justify-end gap-1",children:a.map(({id:d,result:h})=>{const v=h?h.ok?"bg-green-100 text-green-700 dark:bg-green-500/15 dark:text-green-300":"bg-red-100 text-red-700 dark:bg-red-500/15 dark:text-red-300":"bg-muted text-muted-foreground",N=h?h.ok?"✓":"✗":"=",l=h?h.ok?void 0:h.error:"No change — already in sync";return e.jsxs("span",{title:l,className:`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${v}`,children:[o(d)," ",N]},d)})})}function rt({releaseId:t,onBack:s}){var Ce,we,ke;const n=be.Config.get("Release","apiPath","/releases"),{toast:r}=g.useToast(),{fetchJson:o}=g.useImaginariumApi(),{configs:c}=de.useSystemConfigs(),a=I.useQueryClient(),[d,h]=y.useState("all"),[v,N]=y.useState("all"),[l,m]=y.useState(null),[O,B]=y.useState(!1),[Q,H]=y.useState(()=>new Set),U=i=>H(b=>{const u=new Set(b);return u.has(i)?u.delete(i):u.add(i),u}),z=["imaginarium","release",t],A=["imaginarium","release-items",t],L=["imaginarium","release-pushes",t],{data:p,isLoading:w}=I.useQuery({queryKey:z,queryFn:()=>o(`${n}/${t}`)}),{data:k,isLoading:f}=I.useQuery({queryKey:A,queryFn:async()=>{const i=await o(`${n}/${t}/items`);return Array.isArray(i)?i:(i==null?void 0:i.items)??[]}}),{data:E}=I.useQuery({queryKey:L,queryFn:async()=>{const i=await o(`${n}/${t}/pushes`);return Array.isArray(i)?i:(i==null?void 0:i.items)??[]}}),x=y.useMemo(()=>Ge(E??[]),[E]),F=y.useMemo(()=>new Set((E??[]).map(i=>i.destConfigId)),[E]),Y=(E??[]).length>0,J=y.useMemo(()=>(p==null?void 0:p.targetConfigIds)??[],[p]),V=y.useMemo(()=>{const i=new Map;return c.forEach(b=>i.set(String(b.id),b.displayName)),i},[c]),q=i=>V.get(i)??i,D=y.useMemo(()=>tt(k??[]),[k]),W=y.useMemo(()=>D.map(i=>i.item),[D]),Z=y.useMemo(()=>it(k??[]),[k]),C=y.useMemo(()=>new Map((k??[]).map(i=>[i.itemKey,i])),[k]),R=i=>{var u;let b;if(i.parentKey){const M=(u=C.get(i.parentKey))==null?void 0:u.itemName,P=i.parentKey.indexOf(":");b=M??(P>=0?i.parentKey.slice(P+1):void 0)}return`${b?b+" ":""}${i.itemType} "${i.itemName}"`},$=y.useMemo(()=>{var b,u;const i=new Map;for(const M of k??[]){const P=(u=(b=M.diff)==null?void 0:b.origin)==null?void 0:u.id;typeof P=="string"&&P&&i.set(P,M.itemName)}return i},[k]),ie=y.useMemo(()=>(k??[]).filter(i=>i.included&&!i.ignored).map(i=>({itemName:i.itemName,missing:oe(i,Z,C).map(R)})).filter(i=>i.missing.length>0),[k,Z,C]),ae=y.useMemo(()=>et(W),[W]),ce=y.useMemo(()=>Object.keys(ae).sort(ye),[ae]),_=y.useMemo(()=>D.filter(i=>d==="all"||i.item.itemType===d).map(i=>{const b=v==="all"?i.children:i.children.filter(u=>De(u,v));return{node:i,renderChildren:b}}).filter(({node:i,renderChildren:b})=>v==="all"||De(i.item,v)||b.length>0).sort((i,b)=>{const u=ye(i.node.item.itemType,b.node.item.itemType);return u!==0?u:i.node.item.itemName.localeCompare(b.node.item.itemName)}),[D,d,v]),ee=I.useMutation({mutationFn:()=>o(`${n}/${t}/refresh`,{method:"POST"}),onSuccess:()=>{a.invalidateQueries({queryKey:A}),r({title:"Snapshot refreshed",description:"Items re-computed from origin."})},onError:i=>{r({title:"Error",description:i.message,variant:"destructive"})}}),ue=I.useMutation({mutationFn:({itemId:i,included:b})=>o(`${n}/${t}/items/${i}`,{method:"PATCH",body:JSON.stringify({included:b})}),onSuccess:()=>{a.invalidateQueries({queryKey:A})},onError:i=>{r({title:"Error",description:i.message,variant:"destructive"})}}),ve=I.useMutation({mutationFn:({itemId:i,selectedVersion:b})=>o(`${n}/${t}/items/${i}`,{method:"PATCH",body:JSON.stringify({selectedVersion:b})}),onSuccess:()=>{a.invalidateQueries({queryKey:A})},onError:i=>{r({title:"Error",description:i.message,variant:"destructive"})}}),me=i=>({mutationFn:({itemId:b,value:u})=>o(`${n}/${t}/items/${b}`,{method:"PATCH",body:JSON.stringify({[i]:u})}),onMutate:async({itemId:b,value:u})=>{await a.cancelQueries({queryKey:A});const M=a.getQueryData(A);return a.setQueryData(A,P=>(P??[]).map(se=>se.id===b?{...se,[i]:u}:se)),{prev:M}},onError:(b,u,M)=>{M!=null&&M.prev&&a.setQueryData(A,M.prev),r({title:"Error",description:b.message,variant:"destructive"})},onSettled:()=>{a.invalidateQueries({queryKey:A})}}),ut=I.useMutation(me("excludedTags")),mt=I.useMutation(me("excludedMetadataKeys")),xt=I.useMutation(me("excludedI18nPaths")),ht=I.useMutation(me("excludedPermissions")),gt=()=>a.invalidateQueries({queryKey:A}),te=(p==null?void 0:p.status)==="pushed",j=l?C.get(l.itemKey)??l:null;return w?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"}):p?e.jsxs("div",{className:"space-y-4",children:[te&&e.jsx("div",{className:"bg-muted text-muted-foreground rounded-md px-3 py-2 text-sm",children:"This release was pushed and is read-only."}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(g.Button,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(S.ArrowLeft,{}),"Back"]}),e.jsx("h3",{className:"text-lg font-semibold",children:p.name}),e.jsx(Ne,{status:p.status})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!te&&e.jsx(Ye,{releaseId:t,apiPath:n,onReset:gt}),e.jsxs(g.Button,{variant:"outline",size:"sm",onClick:()=>ee.mutate(),disabled:te||ee.isPending,children:[e.jsx(S.RefreshCw,{}),ee.isPending?"Refreshing…":"Refresh"]}),te?e.jsx(g.Button,{size:"sm",disabled:!0,children:"Pushed ✓"}):e.jsx(g.Button,{size:"sm",onClick:()=>B(!0),disabled:(p.targetConfigIds??[]).length===0,children:"Push"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[e.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:q(p.originConfigId)}),e.jsx("span",{children:"→"}),(p.targetConfigIds??[]).map(i=>e.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:q(i)},i)),e.jsxs("span",{className:"ml-2",children:["Snapshot: ",p.snapshotAt?new Date(p.snapshotAt).toLocaleString():"—"]}),e.jsxs("span",{children:["Pushed: ",p.pushedAt?new Date(p.pushedAt).toLocaleString():"—"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsxs(g.Button,{variant:d==="all"?"secondary":"ghost",size:"sm",onClick:()=>h("all"),children:["All types (",W.length,")"]}),ce.map(i=>e.jsxs(g.Button,{variant:d===i?"secondary":"ghost",size:"sm",onClick:()=>h(i),children:[i," (",ae[i],")"]},i))]}),e.jsx("div",{className:"flex flex-wrap items-center gap-1",children:Pt.map(i=>e.jsx(g.Button,{variant:v===i.value?"secondary":"outline",size:"sm",onClick:()=>N(i.value),children:i.label},i.value))})]}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"min-w-0 flex-1",children:f?e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading items…"}):_.length===0?e.jsx(g.Card,{children:e.jsx(g.CardContent,{className:"py-12 text-center text-muted-foreground",children:W.length===0?"No items in this release yet.":"No items match the current filters."})}):e.jsx(g.Card,{children:e.jsx(g.CardContent,{className:"p-0",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[e.jsx("th",{className:"p-3 font-medium w-10",children:"Inc."}),e.jsx("th",{className:"p-3 font-medium",children:"Type"}),e.jsx("th",{className:"p-3 font-medium",children:"Name"}),e.jsx("th",{className:"p-3 font-medium",children:"Status"}),e.jsx("th",{className:"p-3 font-medium"})]})}),e.jsx("tbody",{children:_.map(({node:i,renderChildren:b})=>{var $e;const u=i.item,M=b.length>0,P=Q.has(u.itemKey)||v!=="all",se=Q.has(u.itemKey),ne=nt(i),Se=(($e=u.diff)==null?void 0:$e.versions)??[],le=u.itemType==="rule"&&Se.length>0,Te=Se.some(K=>K.isPublished),pt=le?bt(u):[],Pe=le&&!Te,Ke=le&&Te&&pt.length===0,xe=Pe||Ke,ft=le&&!xe&&u.selectedVersion==null;return e.jsxs(y.Fragment,{children:[i.synthetic?e.jsxs("tr",{className:"border-b last:border-0 cursor-pointer hover:bg-muted/50",onClick:()=>U(u.itemKey),children:[e.jsx("td",{className:"p-3"}),e.jsx("td",{className:"p-3",children:e.jsx(re,{type:u.itemType})}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:K=>{K.stopPropagation(),U(u.itemKey)},"aria-label":se?"Collapse":"Expand",children:se?e.jsx(S.ChevronDown,{size:14}):e.jsx(S.ChevronRight,{size:14})}),e.jsx("span",{className:"font-medium",children:u.itemName}),e.jsxs("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs ${ne.included<ne.total?"bg-amber-100 text-amber-700 font-medium dark:bg-amber-500/15 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:[ne.included,"/",ne.total," changes included"]})]})}),e.jsx("td",{className:"p-3"}),e.jsx("td",{className:"p-3"})]}):e.jsxs("tr",{className:`border-b last:border-0 cursor-pointer hover:bg-muted/50 ${(l==null?void 0:l.id)===u.id?"bg-muted/50":""} ${xe?"opacity-60":""}`,onClick:()=>m(u),children:[e.jsx("td",{className:"p-3",onClick:K=>K.stopPropagation(),children:e.jsx(fe,{checked:u.included,disabled:u.ignored||ue.isPending||te||xe,onChange:K=>ue.mutate({itemId:u.id,included:K})})}),e.jsx("td",{className:"p-3",children:e.jsx(re,{type:u.itemType})}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[M?e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:K=>{K.stopPropagation(),U(u.itemKey)},"aria-label":se?"Collapse":"Expand",children:se?e.jsx(S.ChevronDown,{size:14}):e.jsx(S.ChevronRight,{size:14})}):null,e.jsx("span",{className:"font-medium",children:u.itemName}),(()=>{if(!u.included||u.ignored)return null;const K=oe(u,Z,C);return K.length===0?null:e.jsx("span",{title:`Depends on excluded: ${K.map(X=>X.itemName).join(", ")}`,children:e.jsx(S.AlertTriangle,{size:14,className:"shrink-0 text-amber-600"})})})(),e.jsx(Ae,{item:u}),M?e.jsxs("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs ${ne.included<ne.total?"bg-amber-100 text-amber-700 font-medium dark:bg-amber-500/15 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:[ne.included,"/",ne.total," changes included"]}):null,u.carriedOver?e.jsx(Ve,{originName:q(p.originConfigId)}):null,u.ignored?e.jsx(He,{}):null,le&&!xe?e.jsx("span",{onClick:K=>K.stopPropagation(),children:e.jsx(Nt,{item:u,disabled:te||ve.isPending,onChange:K=>ve.mutate({itemId:u.id,selectedVersion:K})})}):null,Pe?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Rules without a published version cannot be pushed"}):null,Ke?e.jsx("span",{className:"text-xs text-muted-foreground",children:"Nothing to push — all versions exist on target"}):null,ft?e.jsx("span",{className:"text-xs text-amber-600",children:"Pushable version not selected"}):null]})}),e.jsx("td",{className:"p-3",children:e.jsx(Re,{status:u.status})}),e.jsx("td",{className:"p-3 text-right",onClick:K=>K.stopPropagation(),children:e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[Y?e.jsx(Be,{item:u,targetConfigIds:J,results:x,pushedDests:F,displayName:q}):null,!u.ignored&&!te&&e.jsx(Ue,{createPayload:{originConfigId:p.originConfigId,itemKey:u.itemKey,itemType:u.itemType,itemName:u.itemName},onChange:()=>{a.setQueryData(A,K=>(K??[]).map(X=>X.id===u.id?{...X,ignored:!0,included:!1}:X)),ee.mutate()}})]})})]}),M&&P?b.map(K=>e.jsxs("tr",{className:`border-b last:border-0 cursor-pointer hover:bg-muted/50 ${(l==null?void 0:l.id)===K.id?"bg-muted/50":""}`,onClick:()=>m(K),children:[e.jsx("td",{className:"p-3 pl-8",onClick:X=>X.stopPropagation(),children:e.jsx(fe,{checked:K.included,disabled:K.ignored||ue.isPending||te,onChange:X=>ue.mutate({itemId:K.id,included:X})})}),e.jsx("td",{className:"p-3 pl-8",children:e.jsx(re,{type:K.itemType})}),e.jsx("td",{className:"p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:K.itemName}),(()=>{if(!K.included||K.ignored)return null;const X=oe(K,Z,C);return X.length===0?null:e.jsx("span",{title:`Depends on excluded: ${X.map(yt=>yt.itemName).join(", ")}`,children:e.jsx(S.AlertTriangle,{size:14,className:"shrink-0 text-amber-600"})})})(),e.jsx(Ae,{item:K})]})}),e.jsx("td",{className:"p-3",children:e.jsx(Re,{status:K.status})}),e.jsx("td",{className:"p-3 text-right",onClick:X=>X.stopPropagation(),children:Y?e.jsx(Be,{item:K,targetConfigIds:J,results:x,pushedDests:F,displayName:q}):null})]},K.id)):null]},i.synthetic?u.itemKey:u.id)})})]})})})}),l?e.jsx("div",{className:"w-[28rem] shrink-0 self-start sticky top-4 max-h-[calc(100vh-2rem)] overflow-auto",children:e.jsx(Xe,{item:j,targets:(p.targetConfigIds??[]).map(i=>({id:i,name:q(i)})),onClose:()=>m(null),unmetDependencyNames:j&&j.included&&!j.ignored?oe(j,Z,C).map(R):[],tags:Array.isArray((we=(Ce=j==null?void 0:j.diff)==null?void 0:Ce.origin)==null?void 0:we.tags)?((ke=j==null?void 0:j.diff)==null?void 0:ke.origin).tags??[]:[],excludedTags:G(j==null?void 0:j.excludedTags),metadataKeys:(()=>{var b,u;const i=(u=(b=j==null?void 0:j.diff)==null?void 0:b.origin)==null?void 0:u.metadata;return i!=null&&typeof i=="object"&&!Array.isArray(i)?Object.keys(i):[]})(),excludedMetadataKeys:G(j==null?void 0:j.excludedMetadataKeys),i18nPaths:(()=>{var u,M;const i=(M=(u=j==null?void 0:j.diff)==null?void 0:u.origin)==null?void 0:M.i18n;if(!Array.isArray(i))return[];const b=i.map(P=>P==null?void 0:P.path).filter(P=>typeof P=="string");return Array.from(new Set(b))})(),excludedI18nPaths:G(j==null?void 0:j.excludedI18nPaths),permissionKeys:(()=>{var u,M;if((j==null?void 0:j.itemType)!=="role")return[];const i=(M=(u=j==null?void 0:j.diff)==null?void 0:u.origin)==null?void 0:M.permissions;if(!Array.isArray(i))return[];const b=i.map(P=>`${(P==null?void 0:P.module)??""}/${(P==null?void 0:P.name)??(P==null?void 0:P.id)??""}`).filter(P=>P!=="/");return Array.from(new Set(b))})(),excludedPermissions:G(j==null?void 0:j.excludedPermissions),formatPermissionLabel:i=>i.split(/([/.])/).map(b=>{var u,M;return((M=(u=j==null?void 0:j.diff)==null?void 0:u.nameMap)==null?void 0:M[b])??$.get(b)??b}).join(""),replacementMaps:p.replacementMaps??void 0,editable:!te,onToggleTag:(i,b)=>{if(!j)return;const u=G(j.excludedTags),M=b?u.filter(P=>P!==i):Array.from(new Set([...u,i]));ut.mutate({itemId:j.id,value:M})},onToggleMetadataKey:(i,b)=>{if(!j)return;const u=G(j.excludedMetadataKeys),M=b?u.filter(P=>P!==i):Array.from(new Set([...u,i]));mt.mutate({itemId:j.id,value:M})},onToggleI18nPath:(i,b)=>{if(!j)return;const u=G(j.excludedI18nPaths),M=b?u.filter(P=>P!==i):Array.from(new Set([...u,i]));xt.mutate({itemId:j.id,value:M})},onTogglePermission:(i,b)=>{if(!j)return;const u=G(j.excludedPermissions),M=b?u.filter(P=>P!==i):Array.from(new Set([...u,i]));ht.mutate({itemId:j.id,value:M})}})}):null]}),e.jsx(We,{open:O,onOpenChange:B,releaseId:t,apiPath:n,targetConfigIds:p.targetConfigIds??[],targetNames:Object.fromEntries((p.targetConfigIds??[]).map(i=>[i,q(i)])),dependencyWarnings:ie})]}):e.jsxs("div",{className:"space-y-4",children:[e.jsxs(g.Button,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(S.ArrowLeft,{}),"Back"]}),e.jsx("p",{className:"text-muted-foreground",children:"Release not found."})]})}function je({value:t,onChange:s,configs:n,label:r}){const o=`cluster-select-${r.toLowerCase().replace(/\s+/g,"-")}`;return e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:o,children:r}),e.jsxs("select",{id:o,value:t,onChange:c=>s(c.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[e.jsx("option",{value:"",children:"Select cluster…"}),n.map(c=>e.jsx("option",{value:c.id,children:c.displayName},c.id))]})]})}function at({item:t,onClose:s}){var r,o;const n=y.useMemo(()=>{var c,a;return _e((c=t==null?void 0:t.diff)==null?void 0:c.origin,(a=t==null?void 0:t.diff)==null?void 0:a.target)},[t]);return t?e.jsxs("div",{className:"flex h-full flex-col rounded-md border bg-background",children:[e.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"truncate font-medium",children:t.itemName}),e.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:t.itemType})]}),e.jsx(g.Button,{variant:"ghost",size:"icon",title:"Close",onClick:s,children:e.jsx(S.X,{})})]}),e.jsxs("div",{className:"flex flex-1 gap-3 overflow-auto p-3",children:[e.jsx(pe,{label:"Origin",value:(r=t.diff)==null?void 0:r.origin,highlightLines:n}),e.jsx(pe,{label:"Target",value:(o=t.diff)==null?void 0:o.target})]})]}):null}const Fe={match:{symbol:"✓",className:"text-muted-foreground",label:"Match"},diff:{symbol:"≠",className:"text-red-500 dark:text-red-400 font-semibold",label:"Diff"},translated:{symbol:"≈",className:"text-blue-600 dark:text-blue-400 font-semibold",label:"Translated"},missing:{symbol:"✗",className:"text-red-500 dark:text-red-400 font-semibold",label:"Missing"},extra:{symbol:"+",className:"text-amber-600 font-semibold",label:"Extra"},skip:{symbol:"—",className:"text-muted-foreground/50",label:"Ignored"}};function qe({state:t,onClick:s,active:n}){const r=Fe[t]??Fe.match,o=t!=="match"&&t!=="skip"&&!!s;return e.jsx("button",{type:"button",onClick:o?s:void 0,disabled:!o,title:r.label,className:g.cn("w-full text-center text-sm py-1 rounded",r.className,o&&"hover:bg-muted cursor-pointer",!o&&"cursor-default",n&&"bg-muted ring-1 ring-ring"),children:r.symbol})}function Kt({stats:t,destConfigIds:s}){return e.jsx("div",{className:"flex gap-6 text-xs text-muted-foreground py-2 px-1",children:s.map(n=>{const r=t[n];if(!r)return null;const o=r.match+r.diff+r.missing+r.extra;return e.jsxs("span",{children:[e.jsxs("span",{className:"font-mono font-medium",children:[r.match,"/",o]})," match",r.diff>0&&e.jsxs("span",{className:"text-destructive ml-2",children:[r.diff," diff"]}),r.missing>0&&e.jsxs("span",{className:"text-destructive ml-2",children:[r.missing," missing"]}),r.extra>0&&e.jsxs("span",{className:"text-amber-600 ml-2",children:[r.extra," extra"]})]},n)})})}function Qe(t){return Object.values(t.cells).some(s=>s==="diff"||s==="missing"||s==="extra")}function lt({originConfigId:t,destConfigIds:s,apiPath:n="/release-status"}){const{toast:r}=g.useToast(),{fetchJson:o}=g.useImaginariumApi(),{configs:c}=de.useSystemConfigs(),a=I.useQueryClient(),[d,h]=y.useState("issues"),[v,N]=y.useState(!1),[l,m]=y.useState(null),[O,B]=y.useState(new Set),[Q,H]=y.useState(()=>new Set),U=C=>H(R=>{const $=new Set(R);return $.has(C)?$.delete(C):$.add(C),$}),z=y.useMemo(()=>{const C=new Map;return c.forEach(R=>C.set(R.id,R.displayName)),C},[c]),A=C=>z.get(C)??C,L=s.filter(C=>!O.has(C)),p=new URLSearchParams;p.set("originConfigId",t),L.forEach(C=>p.append("destConfigIds[]",C));const w=["imaginarium","release-status",t,L],{data:k,isLoading:f,isError:E}=I.useQuery({queryKey:w,queryFn:()=>o(`${n}?${p.toString()}`),enabled:L.length>0}),x=I.useMutation({mutationFn:()=>o(`${n}/refresh`,{method:"POST",body:JSON.stringify({originConfigId:t,destConfigIds:L})}),onSuccess:()=>{a.invalidateQueries({queryKey:w}),r({title:"Cache cleared",description:"Refreshing comparison data…"})},onError:C=>{r({title:"Error",description:C.message,variant:"destructive"})}}),{data:F,isLoading:Y,isError:J}=I.useQuery({queryKey:["imaginarium","release-status-diff",t,l==null?void 0:l.destConfigId,l==null?void 0:l.itemKey],queryFn:()=>o(`${n}/diff?originConfigId=${encodeURIComponent(t)}&destConfigId=${encodeURIComponent(l.destConfigId)}&itemKey=${encodeURIComponent(l.itemKey)}`),enabled:!!l}),V=C=>{B(R=>{const $=new Set(R);return $.has(C)?$.delete(C):$.add(C),$})},q=(C,R)=>{m($=>($==null?void 0:$.itemKey)===C&&$.destConfigId===R?null:{itemKey:C,destConfigId:R})},D=(k==null?void 0:k.rows)??[],W=(k==null?void 0:k.stats)??{},Z=y.useMemo(()=>st(D).map(R=>{const $=d==="issues"?R.children.filter(Qe):R.children;return{node:R,renderChildren:$}}).filter(({node:R,renderChildren:$})=>d==="all"||Qe(R.row)||$.length>0).sort((R,$)=>{const ie=ye(R.node.row.itemType,$.node.row.itemType);return ie!==0?ie:R.node.row.itemName.localeCompare($.node.row.itemName)}),[D,d]);return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("div",{className:"flex rounded-md border text-sm overflow-hidden",children:[e.jsx("button",{className:g.cn("px-3 py-1.5",d==="issues"?"bg-muted font-medium":"hover:bg-muted/50"),onClick:()=>h("issues"),children:"Issues only"}),e.jsx("button",{className:g.cn("px-3 py-1.5 border-l",d==="all"?"bg-muted font-medium":"hover:bg-muted/50"),onClick:()=>h("all"),children:"All"})]}),e.jsxs(g.Button,{variant:"ghost",size:"sm",onClick:()=>N(C=>!C),children:[e.jsx(S.BarChart2,{}),"Stats"]}),e.jsxs(g.Button,{variant:"ghost",size:"sm",onClick:()=>x.mutate(),disabled:x.isPending,children:[e.jsx(S.RefreshCw,{className:g.cn(x.isPending&&"animate-spin")}),"Refresh"]}),[...O].map(C=>e.jsxs("button",{onClick:()=>V(C),className:"text-xs border rounded px-2 py-1 text-muted-foreground hover:bg-muted",children:["+ ",A(C)]},C))]}),v&&k&&e.jsx(Kt,{stats:W,destConfigIds:L}),f&&e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"}),E&&e.jsx("div",{className:"text-center text-destructive py-8",children:"Failed to load comparison data."}),!f&&!E&&e.jsxs("div",{className:"flex gap-4",children:[e.jsx("div",{className:"min-w-0 flex-1 rounded-md border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-4 py-2 text-left font-medium min-w-[200px]",children:"Item"}),L.map(C=>e.jsx("th",{className:"px-2 py-2 text-center font-medium min-w-[80px]",children:e.jsxs("div",{className:"flex items-center justify-center gap-1",children:[e.jsx("span",{className:"truncate max-w-[120px]",title:A(C),children:A(C)}),e.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>V(C),title:"Hide column",children:"×"})]})},C))]})}),e.jsx("tbody",{children:Z.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:L.length+1,className:"text-center text-muted-foreground py-8",children:d==="issues"?"No issues found — all clusters in sync.":"No items."})}):Z.map(({node:C,renderChildren:R})=>{const $=C.row,ie=R.length>0,ae=Q.has($.itemKey)||d==="issues",ce=Q.has($.itemKey);return e.jsxs(y.Fragment,{children:[e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[e.jsx("td",{className:"px-4 py-1.5",children:e.jsxs("div",{className:"flex items-center gap-2",children:[ie?e.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>U($.itemKey),"aria-label":ce?"Collapse":"Expand",children:ce?e.jsx(S.ChevronDown,{size:14}):e.jsx(S.ChevronRight,{size:14})}):null,e.jsx("span",{className:"inline-flex align-middle",children:e.jsx(re,{type:$.itemType})}),e.jsx("span",{className:"font-medium",children:$.itemName})]})}),L.map(_=>e.jsx("td",{className:"px-2 py-1",children:e.jsx(qe,{state:$.cells[_]??"match",active:(l==null?void 0:l.itemKey)===$.itemKey&&l.destConfigId===_,onClick:()=>q($.itemKey,_)})},_))]}),ie&&ae?R.map(_=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[e.jsx("td",{className:"px-4 py-1.5 pl-8",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"inline-flex align-middle",children:e.jsx(re,{type:_.itemType})}),e.jsx("span",{className:"font-medium",children:_.itemName})]})}),L.map(ee=>e.jsx("td",{className:"px-2 py-1",children:e.jsx(qe,{state:_.cells[ee]??"match",active:(l==null?void 0:l.itemKey)===_.itemKey&&l.destConfigId===ee,onClick:()=>q(_.itemKey,ee)})},ee))]},_.itemKey)):null]},$.itemKey)})})]})}),l?e.jsx("div",{className:"w-[28rem] shrink-0 self-start sticky top-4 max-h-[calc(100vh-2rem)] overflow-auto",children:Y?e.jsx("div",{className:"flex h-full items-center justify-center rounded-md border bg-background p-4 text-sm text-muted-foreground",children:"Loading diff…"}):J||!F?e.jsx("div",{className:"flex h-full items-center justify-center rounded-md border bg-background p-4 text-sm text-muted-foreground",children:"No diff available."}):e.jsx(at,{item:{itemName:F.itemName,itemType:F.itemType,diff:{origin:F.origin,target:F.target}},onClose:()=>m(null)})}):null]})]})}const ze=t=>({name:"",description:"",values:Object.fromEntries(t.map(s=>[s,""]))});function ot({configIds:t,clusterNames:s={},apiPath:n="/release-translations"}){const{toast:r}=g.useToast(),{fetchJson:o}=g.useImaginariumApi(),c=I.useQueryClient(),[a,d]=y.useState(!1),[h,v]=y.useState(null),[N,l]=y.useState(ze(t)),m=["imaginarium","release-translations"],{data:O,isLoading:B}=I.useQuery({queryKey:m,queryFn:async()=>{const x=await o(n);return(x==null?void 0:x.items)??[]}}),Q=I.useMutation({mutationFn:async x=>{const F=await o(n,{method:"POST",body:JSON.stringify({name:x.name.trim(),description:x.description.trim()||null})});await z(F.id,x.values)},onSuccess:()=>{c.invalidateQueries({queryKey:m}),r({title:"Translation created"}),p()},onError:x=>r({title:"Error",description:x.message,variant:"destructive"})}),H=I.useMutation({mutationFn:async x=>{await o(`${n}/${h.id}`,{method:"PATCH",body:JSON.stringify({name:x.name.trim(),description:x.description.trim()||null})}),await z(h.id,x.values)},onSuccess:()=>{c.invalidateQueries({queryKey:m}),r({title:"Translation updated"}),p()},onError:x=>r({title:"Error",description:x.message,variant:"destructive"})}),U=I.useMutation({mutationFn:x=>o(`${n}/${x}`,{method:"DELETE"}),onSuccess:()=>{c.invalidateQueries({queryKey:m}),r({title:"Translation deleted"})},onError:x=>r({title:"Error",description:x.message,variant:"destructive"})});async function z(x,F){var J;const Y=(h==null?void 0:h.values)??[];for(const V of t){const q=(J=F[V])==null?void 0:J.trim(),D=Y.find(Z=>Z.configId===V),W=`${n}/${x}/values`;D&&q?await o(`${W}/${D.id}`,{method:"PATCH",body:JSON.stringify({value:q})}):D&&!q?await o(`${W}/${D.id}`,{method:"DELETE"}):!D&&q&&await o(W,{method:"POST",body:JSON.stringify({translationId:x,configId:V,value:q})})}}const A=()=>{v(null),l(ze(t)),d(!0)},L=x=>{v(x);const F=x.values??[],Y=Object.fromEntries(t.map(J=>{var V;return[J,((V=F.find(q=>q.configId===J))==null?void 0:V.value)??""]}));l({name:x.name,description:x.description??"",values:Y}),d(!0)},p=()=>{d(!1),v(null)},w=()=>{h?H.mutate(N):Q.mutate(N)},k=Q.isPending||H.isPending,f=!!N.name.trim();if(B)return e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"});const E=O??[];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:E.length===0?"No translation rules yet.":`${E.length} translation rule${E.length===1?"":"s"}.`}),e.jsxs(g.Button,{size:"sm",onClick:A,children:[e.jsx(S.Plus,{}),"Add translation"]})]}),E.length>0&&e.jsx("div",{className:"rounded-md border overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Name"}),t.map(x=>e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:s[x]??x},x)),e.jsx("th",{className:"px-4 py-2 text-right font-medium"})]})}),e.jsx("tbody",{children:E.map(x=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[e.jsxs("td",{className:"px-4 py-2",children:[e.jsx("div",{className:"font-medium",children:x.name}),x.description&&e.jsx("div",{className:"text-xs text-muted-foreground",children:x.description})]}),t.map(F=>{var J;const Y=(J=x.values)==null?void 0:J.find(V=>V.configId===F);return e.jsx("td",{className:"px-4 py-2 font-mono text-xs",children:Y?Y.value:e.jsx("span",{className:"text-muted-foreground",children:"—"})},F)}),e.jsx("td",{className:"px-4 py-2 text-right",children:e.jsxs("div",{className:"flex gap-1 justify-end",children:[e.jsx(g.Button,{variant:"ghost",size:"icon",onClick:()=>L(x),children:e.jsx(S.Pencil,{})}),e.jsx(g.Button,{variant:"ghost",size:"icon",onClick:()=>{window.confirm(`Delete translation "${x.name}"?`)&&U.mutate(x.id)},children:e.jsx(S.Trash2,{})})]})})]},x.id))})]})}),e.jsx(T.Dialog,{open:a,onOpenChange:d,children:e.jsxs(T.DialogContent,{className:"max-w-lg",children:[e.jsxs(T.DialogHeader,{children:[e.jsx(T.DialogTitle,{children:h?`Edit ${h.name}`:"New Translation Rule"}),e.jsx(T.DialogDescription,{children:"Set the equivalent values for each cluster. Rules with values on only one side of a pair are silently skipped for that comparison."})]}),e.jsxs("div",{className:"space-y-4 py-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:"tr-name",children:"Name"}),e.jsx(T.Input,{id:"tr-name",value:N.name,onChange:x=>l({...N,name:x.target.value}),placeholder:"API Base URL"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(T.Label,{htmlFor:"tr-desc",children:"Description (optional)"}),e.jsx(T.Input,{id:"tr-desc",value:N.description,onChange:x=>l({...N,description:x.target.value}),placeholder:"Explain what this value represents"})]}),e.jsxs("div",{className:"space-y-3 pt-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Values per cluster"}),t.map(x=>e.jsxs("div",{className:"space-y-1",children:[e.jsx(T.Label,{htmlFor:`tr-val-${x}`,className:"text-xs text-muted-foreground",children:s[x]??x}),e.jsx(T.Input,{id:`tr-val-${x}`,value:N.values[x]??"",onChange:F=>l({...N,values:{...N.values,[x]:F.target.value}}),placeholder:"Leave blank to remove",className:"font-mono text-xs"})]},x))]})]}),e.jsxs(T.DialogFooter,{children:[e.jsxs(g.Button,{variant:"outline",onClick:p,children:[e.jsx(S.X,{}),"Cancel"]}),e.jsxs(g.Button,{onClick:w,disabled:!f||k,children:[e.jsx(S.Save,{}),k?"Saving…":"Save"]})]})]})})]})}function dt({originConfigId:t,apiPath:s="/release-ignores"}){const{toast:n}=g.useToast(),{fetchJson:r}=g.useImaginariumApi(),o=I.useQueryClient(),c=["imaginarium","release-ignores",t],{data:a,isLoading:d}=I.useQuery({queryKey:c,queryFn:async()=>{const m=await r(`${s}?where[originConfigId]=${encodeURIComponent(t)}`);return(m==null?void 0:m.items)??[]}}),h=I.useMutation({mutationFn:m=>r(`${s}/${m}`,{method:"DELETE"}),onSuccess:()=>{o.invalidateQueries({queryKey:c}),n({title:"Item removed from ignore list"})},onError:m=>{n({title:"Error",description:m.message,variant:"destructive"})}}),v=I.useMutation({mutationFn:()=>r(`${s}?originConfigId=${encodeURIComponent(t)}`,{method:"DELETE"}),onSuccess:()=>{o.invalidateQueries({queryKey:c}),n({title:"All ignore rules cleared"})},onError:m=>{n({title:"Error",description:m.message,variant:"destructive"})}}),N=()=>{window.confirm("Remove all ignore rules for this cluster? Items will appear normally in future snapshots.")&&v.mutate()};if(d)return e.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"});const l=a??[];return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:l.length===0?"No items are permanently ignored.":`${l.length} item${l.length===1?"":"s"} permanently ignored for this cluster.`}),l.length>0&&e.jsxs(g.Button,{variant:"outline",size:"sm",onClick:N,disabled:v.isPending,children:[e.jsx(S.Ban,{}),v.isPending?"Clearing…":"Clear all"]})]}),l.length>0&&e.jsx("div",{className:"rounded-md border",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b bg-muted/50",children:[e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Type"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Name"}),e.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Reason"}),e.jsx("th",{className:"px-4 py-2 text-right font-medium"})]})}),e.jsx("tbody",{children:l.map(m=>e.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[e.jsx("td",{className:"px-4 py-2 text-muted-foreground font-mono text-xs",children:m.itemType}),e.jsx("td",{className:"px-4 py-2 font-medium",children:m.itemName}),e.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:m.reason??e.jsx("span",{className:"italic text-xs",children:"—"})}),e.jsx("td",{className:"px-4 py-2 text-right",children:e.jsx(g.Button,{variant:"ghost",size:"icon",title:"Remove from ignore list",onClick:()=>h.mutate(m.id),disabled:h.isPending,children:e.jsx(S.Trash2,{})})})]},m.id))})]})})]})}const $t=[{id:"releases",label:"Releases"},{id:"status",label:"Status"},{id:"translations",label:"Translations"},{id:"ignored",label:"Ignored"}];function ct(){var N;const[t,s]=y.useState("releases"),[n,r]=y.useState(null),{configs:o}=de.useSystemConfigs(),[c,a]=y.useState("");y.useEffect(()=>{!c&&o.length>0&&a(o[0].id)},[c,o]);const d=y.useMemo(()=>{const l={};return o.forEach(m=>{l[m.id]=m.displayName}),l},[o]),h=c||((N=o[0])==null?void 0:N.id)||"",v=o.map(l=>l.id).filter(l=>l!==h);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold",children:"imp"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage releases across clusters"})]}),e.jsx("div",{className:"flex items-center gap-1 border-b pb-2",children:$t.map(({id:l,label:m})=>e.jsx(g.Button,{variant:t===l?"secondary":"ghost",size:"sm",onClick:()=>s(l),children:m},l))}),t==="releases"&&(n==null?e.jsx(Je,{onOpen:r}):e.jsx(rt,{releaseId:n,onBack:()=>r(null)})),t==="status"&&(o.length===0?e.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"max-w-xs",children:e.jsx(je,{label:"Reference",value:h,onChange:a,configs:o})}),h?e.jsx(lt,{originConfigId:h,destConfigIds:v}):e.jsx("div",{className:"text-muted-foreground",children:"Select a reference cluster."})]})),t==="translations"&&(o.length===0?e.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):e.jsx(ot,{configIds:o.map(l=>l.id),clusterNames:d})),t==="ignored"&&(o.length===0?e.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"max-w-xs",children:e.jsx(je,{label:"Cluster",value:h,onChange:a,configs:o})}),h?e.jsx(dt,{originConfigId:h}):e.jsx("div",{className:"text-muted-foreground",children:"Select a cluster."})]}))]})}const It={id:"imaginarium.ui.ImpPage",path:"/imp",element:ct},Et={id:"imaginarium.ui.ImpNavItem",path:"/imp",label:"imp",icon:S.Bot,sort:150},Mt={install(t){t.addPlugin(Ie.PageType,It),t.addPlugin(Ie.NavItemType,Et)}};exports.ClusterSelect=je;exports.CreateReleaseModal=Le;exports.DiffPanel=at;exports.EntityTag=re;exports.IgnoreButton=Ue;exports.IgnoredPill=He;exports.IgnoredTab=dt;exports.PreviouslySkippedBadge=Ve;exports.PushDialog=We;exports.ReleaseDetail=rt;exports.ReleaseDiffPanel=Xe;exports.ReleaseList=Je;exports.ReleaseSetup=Mt;exports.ReleaseStatusBadge=Ne;exports.ReleaseView=ct;exports.ResetExclusionsButton=Ye;exports.StatusMatrix=lt;exports.Toggle=fe;exports.TranslationsTab=ot;exports.buildItemTree=tt;exports.buildPushResultMap=Ge;exports.computeDependsOn=it;exports.filterItems=Ct;exports.groupStatusRows=st;exports.includedChildCounts=nt;exports.pushResultFor=Ze;exports.typeCounts=et;exports.unmetDependencies=oe;
5
+ //# sourceMappingURL=PluginSetup-DoIf-dYR.cjs.map