@leverege/imaginarium-ui 1.11.2 → 1.11.3
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.
- package/lib/PluginSetup-C6utOEKL.cjs +229 -0
- package/lib/PluginSetup-C6utOEKL.cjs.map +1 -0
- package/lib/PluginSetup-DCTgSUtC.js +5279 -0
- package/lib/PluginSetup-DCTgSUtC.js.map +1 -0
- package/lib/imp/release/ChangesPreviewDialog.d.ts +7 -1
- package/lib/imp/release/ChangesPreviewDialog.d.ts.map +1 -1
- package/lib/imp/release/DependencyCascadeDialog.d.ts +24 -0
- package/lib/imp/release/DependencyCascadeDialog.d.ts.map +1 -0
- package/lib/imp/release/ReleaseDetail.d.ts.map +1 -1
- package/lib/imp/release/dependencies.d.ts +49 -4
- package/lib/imp/release/dependencies.d.ts.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.js +1 -1
- package/lib/release.cjs +1 -1
- package/lib/release.js +1 -1
- package/package.json +1 -1
- package/src/imp/release/ChangesPreviewDialog.tsx +22 -1
- package/src/imp/release/DependencyCascadeDialog.tsx +98 -0
- package/src/imp/release/ReleaseDetail.tsx +79 -14
- package/src/imp/release/dependencies.ts +209 -19
- package/lib/PluginSetup-B08BP7mw.js +0 -5102
- package/lib/PluginSetup-B08BP7mw.js.map +0 -1
- package/lib/PluginSetup-BuIUAfOG.cjs +0 -229
- package/lib/PluginSetup-BuIUAfOG.cjs.map +0 -1
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
"use strict";const It=require("./PluginTypes-BmYA5_B9.cjs"),L=require("./MarkdownPageDoc-BqWCcgxM.cjs"),t=require("react/jsx-runtime"),I=require("react"),E=require("./Card-C8aJrYGF.cjs"),Ee=require("./SystemConfigsContext-iYeVV0p-.cjs"),Q=require("@tanstack/react-query"),M=require("lucide-react"),Ge=require("@leverege/plugin"),Ne=require("./Tooltip-E0BJTBYP.cjs"),zn=L.MarkdownPageDoc.create({path:"/imp",markdown:`# imp
|
|
2
|
+
|
|
3
|
+
Manage cross-cluster releases for your Imagine project. A release captures a snapshot of entities from an origin cluster and lets you review diffs and push to one or more destination clusters.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Releases tab
|
|
8
|
+
|
|
9
|
+
### Creating a release
|
|
10
|
+
|
|
11
|
+
A release snapshots all entities (blueprints, rules, scripts, attributes, enums, roles, etc.) from an origin cluster at a point in time and tracks what differs from one or more destination clusters.
|
|
12
|
+
|
|
13
|
+
### Reading the diff
|
|
14
|
+
|
|
15
|
+
Each row is one entity. The status column tells you what changed:
|
|
16
|
+
|
|
17
|
+
- new: exists on origin, not on any destination
|
|
18
|
+
- updated: exists on both but differs
|
|
19
|
+
- removed: exists on destination(s) but no longer on origin
|
|
20
|
+
- skip: automatically excluded (e.g. a rule with no published version, or all versions already exist on the destination)
|
|
21
|
+
|
|
22
|
+
Selecting a row opens the diff panel on the right, which shows a side-by-side JSON diff for updated items.
|
|
23
|
+
|
|
24
|
+
### Including / excluding items
|
|
25
|
+
|
|
26
|
+
The toggle at the left of each row controls whether that item is included in the push. The type chips and Enabled / Disabled filter help narrow down what you're looking at.
|
|
27
|
+
|
|
28
|
+
Items with children (e.g. a blueprint with changed attributes) show a child count chip. Expanding the row lets you include or exclude individual child changes. The top-level toggle only controls the parent entity's own changes (tags, metadata, etc.) and does not automatically include or exclude its children.
|
|
29
|
+
|
|
30
|
+
### Previously skipped
|
|
31
|
+
|
|
32
|
+
Items that were excluded in the most recent previous release are automatically carried over as excluded in the next one and marked "previously skipped." This prevents accidentally re-including something you intentionally left out last time. Manually toggling the item clears the badge and the carry-over behavior.
|
|
33
|
+
|
|
34
|
+
### Refreshing a snapshot
|
|
35
|
+
|
|
36
|
+
Refresh re-snapshots the origin against the current state of the destinations. New items appear, removed items drop out, and diffs update. Manual overrides (excluded tags, metadata keys, etc.) are preserved across refreshes.
|
|
37
|
+
|
|
38
|
+
### Pushing
|
|
39
|
+
|
|
40
|
+
Pushing sends all included items to the selected destination clusters. The release becomes read-only after a push. Each row surfaces its result as a success or failure chip. Hover a chip for error detail if something failed.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Manual overrides (diff panel)
|
|
45
|
+
|
|
46
|
+
When you click a row, the diff panel shows per-field overrides for that item. These let you include an item but exclude specific sub-fields from the push.
|
|
47
|
+
|
|
48
|
+
### Tags
|
|
49
|
+
|
|
50
|
+
Uncheck a tag to exclude it. The destination will keep its existing value for that tag and the origin's other tags will still be pushed.
|
|
51
|
+
|
|
52
|
+
### Metadata keys
|
|
53
|
+
|
|
54
|
+
Each key in the entity's \`metadata\` object can be individually excluded. Useful when one cluster carries environment-specific metadata (e.g. an API base URL or a feature flag) that should not be overwritten.
|
|
55
|
+
|
|
56
|
+
### i18n paths
|
|
57
|
+
|
|
58
|
+
Individual translation paths can be excluded so the destination keeps its own localized strings for specific fields while receiving the rest of the entity update.
|
|
59
|
+
|
|
60
|
+
### Permissions (roles)
|
|
61
|
+
|
|
62
|
+
For role entities, individual permission entries (module/action pairs) can be excluded. Useful when destination clusters have different access policies for specific modules.
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Ignoring items permanently
|
|
67
|
+
|
|
68
|
+
The ⊘ button on a release row permanently ignores that item for the origin cluster. Ignored items are excluded from this and all future releases for that origin, show an "Ignored" pill in the release list, and are not pushed even if their toggle is on.
|
|
69
|
+
|
|
70
|
+
The ⊘ button on a release row creates an ignore rule for that item, which excludes it immediately and refreshes the snapshot.
|
|
71
|
+
|
|
72
|
+
To remove an ignore, delete it from the Ignored tab. The item will reappear in any release draft the next time you refresh the snapshot.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Status tab
|
|
77
|
+
|
|
78
|
+
Shows a matrix of every entity in the origin cluster vs. every destination cluster. Cell states:
|
|
79
|
+
|
|
80
|
+
- match: origin and destination are identical
|
|
81
|
+
- diff: values differ
|
|
82
|
+
- translated: differs but a translation rule accounts for the difference (counts as match)
|
|
83
|
+
- missing: exists on origin, not on destination
|
|
84
|
+
- extra: exists on destination, not on origin
|
|
85
|
+
- skip: excluded from comparison
|
|
86
|
+
|
|
87
|
+
The Reference dropdown controls which cluster is treated as the source of truth.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Translations tab
|
|
92
|
+
|
|
93
|
+
Translation rules let you declare that two different values across clusters are intentionally equivalent. The Status matrix shows those cells as translated instead of diff.
|
|
94
|
+
|
|
95
|
+
A common use case: an API base URL that differs between dev and prod clusters. Without a translation rule, every blueprint referencing that URL shows as diff. With a rule mapping \`https://api.dev.example.com\` → \`https://api.prod.example.com\`, the diff is suppressed in the matrix.
|
|
96
|
+
|
|
97
|
+
Each rule has a name and a value per cluster. Leaving a cluster's field blank skips it for that pairing.
|
|
98
|
+
|
|
99
|
+
Translation rules affect both the Status matrix and releases. In the matrix they suppress diffs that are explained by a translation rule, showing the cell as translated instead of diff. In releases the substitutions are applied during push, so destination clusters receive the remapped values rather than the origin values verbatim.
|
|
100
|
+
|
|
101
|
+
### Systems with different aliases
|
|
102
|
+
|
|
103
|
+
If a system has a different alias on each cluster, add its aliases as a translation rule (the alias on each cluster) and imp will map them to the same system, so the Status matrix matches them instead of flagging missing/extra and rules that reference the system stop false-diffing.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Ignored tab
|
|
108
|
+
|
|
109
|
+
Lists all permanently-ignored items for the selected origin cluster. Removing a single item (trash icon) makes it reappear in future release snapshots. Clear all removes every ignore rule for that cluster at once.
|
|
110
|
+
|
|
111
|
+
After removing an ignore, refreshing an existing release draft will bring the item back.
|
|
112
|
+
`});function an({open:n,onOpenChange:s,onCreated:i}){const e=Ge.Config.get("Release","apiPath","/releases"),{toast:r}=E.useToast(),{fetchJson:l}=E.useImaginariumApi(),a=Q.useQueryClient(),{configs:o}=Ee.useSystemConfigs(),[d,u]=I.useState(""),[c,m]=I.useState(""),[x,f]=I.useState(""),[p,N]=I.useState([]),v=["imaginarium","releases",e],g=()=>{u(""),m(""),f(""),N([])},T=I.useMemo(()=>o.filter(h=>h.id!==x),[o,x]),S=h=>{f(h),N(j=>j.filter(k=>k!==h))},D=h=>{N(j=>j.includes(h)?j.filter(k=>k!==h):[...j,h])},y=Q.useMutation({mutationFn:async()=>{const h=await l(e,{method:"POST",body:JSON.stringify({name:d.trim(),description:c.trim()||null,originConfigId:x,targetConfigIds:p})});return await l(`${e}/${h.id}/snapshot-from-compare`,{method:"POST",body:JSON.stringify({})}),h},onSuccess:h=>{a.invalidateQueries({queryKey:v}),r({title:"Success",description:"Release created and snapshotted"}),s(!1),g(),i(h.id)},onError:h=>{r({title:"Error",description:h.message,variant:"destructive"})},onSettled:()=>{a.invalidateQueries({queryKey:v})}}),A=h=>{h||g(),s(h)},q=!!(d.trim()&&x&&p.length>0);return t.jsx(L.Dialog,{open:n,onOpenChange:A,children:t.jsxs(L.DialogContent,{children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:"New Release"}),t.jsx(L.DialogDescription,{children:"Create a release from an origin cluster and snapshot the diff against its targets."})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"release-name",children:"Name"}),t.jsx(L.Input,{id:"release-name",value:d,onChange:h=>u(h.target.value),placeholder:"2026.05 Release"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"release-description",children:"Description (Optional)"}),t.jsx(L.Input,{id:"release-description",value:c,onChange:h=>m(h.target.value),placeholder:"What this release contains"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"release-origin",children:"Origin Cluster"}),t.jsxs("select",{id:"release-origin",value:x,onChange:h=>S(h.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[t.jsx("option",{value:"",children:"Select origin…"}),o.map(h=>t.jsx("option",{value:h.id,children:h.displayName},h.id))]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{children:"Target Clusters"}),T.length>0?t.jsx("div",{className:"space-y-1 rounded-md border border-input p-2 max-h-48 overflow-y-auto",children:T.map(h=>t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:p.includes(h.id),onChange:()=>D(h.id)}),h.displayName]},h.id))}):t.jsx("p",{className:"text-xs text-muted-foreground",children:x?"No other clusters available as targets.":"Select an origin first."})]})]}),t.jsxs(L.DialogFooter,{children:[t.jsxs(E.Button,{variant:"outline",onClick:()=>A(!1),disabled:y.isPending,children:[t.jsx(M.X,{className:"w-4 h-4 mr-2"}),"Cancel"]}),t.jsx(E.Button,{onClick:()=>y.mutate(),disabled:!q||y.isPending,children:y.isPending?t.jsxs(t.Fragment,{children:[t.jsx(M.Loader2,{className:"w-4 h-4 mr-2 animate-spin"}),"Snapshotting…"]}):t.jsxs(t.Fragment,{children:[t.jsx(M.Save,{className:"w-4 h-4 mr-2"}),"Create & snapshot"]})})]})]})})}function Hn({open:n,onOpenChange:s,release:i,onDuplicated:e}){const r=Ge.Config.get("Release","apiPath","/releases"),{toast:l}=E.useToast(),{fetchJson:a}=E.useImaginariumApi(),o=Q.useQueryClient(),{configs:d}=Ee.useSystemConfigs(),u=["imaginarium","releases",r],[c,m]=I.useState(`Copy of ${i.name}`),[x,f]=I.useState([]),p=new Set((i.targetConfigIds??[]).filter(y=>y!==i.originConfigId)),N=d.filter(y=>y.id!==i.originConfigId),v=y=>{f(A=>A.includes(y)?A.filter(q=>q!==y):[...A,y])},g=()=>{m(`Copy of ${i.name}`),f([])},T=Q.useMutation({mutationFn:async()=>{const y=await a(`${r}/${i.id}/duplicate`,{method:"POST",body:JSON.stringify({name:c.trim(),targetConfigIds:x})});return await a(`${r}/${y.id}/snapshot-from-compare`,{method:"POST",body:JSON.stringify({})}),y},onSuccess:y=>{o.invalidateQueries({queryKey:u}),l({title:"Success",description:"Release duplicated and snapshotted"}),s(!1),g(),e(y.id)},onError:y=>{l({title:"Error",description:y.message,variant:"destructive"})},onSettled:()=>{o.invalidateQueries({queryKey:u})}}),S=y=>{y||g(),s(y)},D=!!(c.trim()&&x.length>0);return t.jsx(L.Dialog,{open:n,onOpenChange:S,children:t.jsxs(L.DialogContent,{children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:"Duplicate Release"}),t.jsxs(L.DialogDescription,{children:['Copy all include/exclude decisions from "',i.name,'" into a new release.']})]}),t.jsxs("div",{className:"space-y-4 py-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"dup-release-name",children:"Name"}),t.jsx(L.Input,{id:"dup-release-name",value:c,onChange:y=>m(y.target.value)})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{children:"Target Clusters"}),N.length>0?t.jsx("div",{className:"space-y-1 rounded-md border border-input p-2 max-h-48 overflow-y-auto",children:N.map(y=>t.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[t.jsx("input",{type:"checkbox",checked:x.includes(y.id),onChange:()=>v(y.id)}),y.displayName,p.has(y.id)?t.jsx("span",{className:"text-muted-foreground",children:" (original destination)"}):null]},y.id))}):t.jsx("p",{className:"text-xs text-muted-foreground",children:"No other clusters available."})]})]}),t.jsxs(L.DialogFooter,{children:[t.jsxs(E.Button,{variant:"outline",onClick:()=>S(!1),disabled:T.isPending,children:[t.jsx(M.X,{className:"w-4 h-4 mr-2"}),"Cancel"]}),t.jsx(E.Button,{onClick:()=>T.mutate(),disabled:!D||T.isPending,children:T.isPending?t.jsxs(t.Fragment,{children:[t.jsx(M.Loader2,{className:"w-4 h-4 mr-2 animate-spin"}),"Duplicating…"]}):t.jsxs(t.Fragment,{children:[t.jsx(M.Copy,{className:"w-4 h-4 mr-2"}),"Duplicate & snapshot"]})})]})]})})}const qn=/\b([A-Z]{2,}-\d+)\b/g;function Mt(n){return[...n.matchAll(qn)].map(s=>s[1])}function Wn(){return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"11",height:"11","aria-hidden":"true",className:"shrink-0",children:[t.jsx("path",{fill:"#2684FF",d:"M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.004-1.005z"}),t.jsx("path",{fill:"#0052CC",d:"M6.108 6.108a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 18.683 18.6V7.117a1.005 1.005 0 0 0-1.004-1.005l-11.571-.004z"}),t.jsx("path",{fill:"#2684FF",d:"M.536 0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 13.111 12.49V1.009A1.005 1.005 0 0 0 12.107.004L.536 0z"})]})}function Jn({ticket:n}){return t.jsxs("a",{href:`https://leverege.atlassian.net/browse/${n}`,target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded border border-blue-200 bg-blue-50 text-blue-700 text-xs font-medium hover:bg-blue-100 transition-colors",children:[t.jsx(Wn,{}),n,t.jsx(M.ArrowUpRight,{className:"w-3 h-3"})]})}function mt({status:n}){const s=n==="pushed"?"bg-emerald-500/15 text-emerald-700 dark:text-emerald-300 border-emerald-500/30":"bg-muted text-muted-foreground border-border";return t.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium border ${s}`,children:n})}function ln({onOpen:n}){const s=Ge.Config.get("Release","apiPath","/releases"),{toast:i}=E.useToast(),{fetchJson:e}=E.useImaginariumApi(),{configs:r}=Ee.useSystemConfigs(),l=Q.useQueryClient(),[a,o]=I.useState(!1),[d,u]=I.useState(null),c=["imaginarium","releases",s],{data:m,isLoading:x}=Q.useQuery({queryKey:c,queryFn:async()=>{const g=await e(s);return[...Array.isArray(g)?g:(g==null?void 0:g.items)??[]].sort((S,D)=>(D.createdAt??"").localeCompare(S.createdAt??""))}}),f=I.useMemo(()=>{const g=new Map;return r.forEach(T=>g.set(String(T.id),T.displayName)),g},[r]),p=g=>f.get(g)??g,N=Q.useMutation({mutationFn:g=>e(`${s}/${g}`,{method:"DELETE"}),onSuccess:()=>{l.invalidateQueries({queryKey:c}),i({title:"Release deleted"})},onError:g=>{i({title:"Error",description:g.message,variant:"destructive"})}}),v=(g,T)=>{g.stopPropagation(),window.confirm(`Delete "${T.name}"? This cannot be undone.`)&&N.mutate(T.id)};return t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"flex items-center justify-end",children:t.jsxs(E.Button,{onClick:()=>o(!0),children:[t.jsx(M.Plus,{className:"w-4 h-4 mr-2"}),"New Release"]})}),x?t.jsx("div",{className:"text-center text-muted-foreground",children:"Loading…"}):m&&m.length>0?t.jsx(E.Card,{children:t.jsx(E.CardContent,{className:"p-0",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[t.jsx("th",{className:"p-3 font-medium",children:"Name"}),t.jsx("th",{className:"p-3 font-medium",children:"Origin"}),t.jsx("th",{className:"p-3 font-medium",children:"Targets"}),t.jsx("th",{className:"p-3 font-medium",children:"Status"}),t.jsx("th",{className:"p-3 font-medium",children:"Snapshot"}),t.jsx("th",{className:"p-3 font-medium",children:"Pushed"}),t.jsx("th",{className:"p-3 font-medium"})]})}),t.jsx("tbody",{children:m.map(g=>t.jsxs("tr",{className:"border-b last:border-0 cursor-pointer hover:bg-muted/50",onClick:()=>n(g.id),children:[t.jsxs("td",{className:"p-3",children:[t.jsx("div",{className:"font-medium",children:g.name}),Mt(g.name).length>0?t.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:Mt(g.name).map(T=>t.jsx(Jn,{ticket:T},T))}):null,g.description?t.jsx("div",{className:"text-xs text-muted-foreground",children:g.description}):null]}),t.jsx("td",{className:"p-3",children:p(g.originConfigId)}),t.jsx("td",{className:"p-3",children:t.jsx("div",{className:"flex flex-wrap gap-1",children:(g.targetConfigIds??[]).map(T=>t.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:p(T)},T))})}),t.jsx("td",{className:"p-3",children:t.jsx(mt,{status:g.status})}),t.jsx("td",{className:"p-3 text-muted-foreground",children:g.snapshotAt?new Date(g.snapshotAt).toLocaleString():"—"}),t.jsx("td",{className:"p-3 text-muted-foreground",children:g.pushedAt?new Date(g.pushedAt).toLocaleString():"—"}),t.jsxs("td",{className:"p-3 text-right whitespace-nowrap",children:[g.status==="draft"?t.jsx(E.Button,{variant:"ghost",size:"sm",onClick:T=>v(T,g),title:"Delete draft",disabled:N.isPending,children:t.jsx(M.Trash2,{className:"w-4 h-4 text-destructive"})}):null,t.jsx(E.Button,{variant:"ghost",size:"sm",onClick:T=>{T.stopPropagation(),u(g)},title:"Duplicate",children:t.jsx(M.Copy,{className:"w-4 h-4"})}),t.jsx(E.Button,{variant:"ghost",size:"sm",onClick:T=>{T.stopPropagation(),n(g.id)},title:"Open",children:t.jsx(M.ArrowRight,{className:"w-4 h-4"})})]})]},g.id))})]})})}):t.jsx(E.Card,{children:t.jsxs(E.CardContent,{className:"py-12 text-center",children:[t.jsx("p",{className:"text-muted-foreground mb-4",children:"No releases yet"}),t.jsxs(E.Button,{onClick:()=>o(!0),children:[t.jsx(M.Plus,{className:"w-4 h-4 mr-2"}),"Create Your First Release"]})]})}),t.jsx(an,{open:a,onOpenChange:o,onCreated:n}),d?t.jsx(Hn,{open:!!d,onOpenChange:g=>{g||u(null)},release:d,onDuplicated:n}):null]})}function on({originName:n,className:s}){const i=n?`Skipped in your last release from ${n}.`:"Skipped in your last release.";return t.jsx(Ne.TooltipProvider,{children:t.jsxs(Ne.Tooltip,{children:[t.jsx(Ne.TooltipTrigger,{asChild:!0,children:t.jsx("span",{className:E.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"})}),t.jsx(Ne.TooltipContent,{side:"top",children:i})]})})}function nt({className:n}){return t.jsx("span",{className:E.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",n),children:"ignored"})}function st({ignoreRule:n,createPayload:s,apiPath:i="/release-ignores",onChange:e,hasAttributes:r=!1,className:l}){const{toast:a}=E.useToast(),{fetchJson:o}=E.useImaginariumApi(),d=Q.useQueryClient(),[u,c]=I.useState(!1),m=!!n,x=()=>{d.invalidateQueries({queryKey:["imaginarium","release-ignores"]}),e==null||e()},f=Q.useMutation({mutationFn:()=>o(i,{method:"POST",body:JSON.stringify(s)}),onSuccess:()=>{a({title:"Item ignored",description:"Will be excluded from all future snapshots."}),c(!1),x()},onError:v=>{a({title:"Error",description:v.message,variant:"destructive"})}}),p=Q.useMutation({mutationFn:()=>o(`${i}/${n.id}`,{method:"DELETE"}),onSuccess:()=>{a({title:"Item un-ignored",description:"Will appear normally in future snapshots."}),x()},onError:v=>{a({title:"Error",description:v.message,variant:"destructive"})}}),N=f.isPending||p.isPending;return t.jsxs(t.Fragment,{children:[t.jsx(E.Button,{variant:"ghost",size:"icon",title:m?"Remove from ignore list":"Ignore this item",disabled:N,onClick:()=>m?p.mutate():c(!0),className:E.cn(m&&"text-red-500 hover:text-red-500 dark:text-red-400 dark:hover:text-red-400",l),children:t.jsx(M.Ban,{})}),t.jsx(L.Dialog,{open:u,onOpenChange:c,children:t.jsxs(L.DialogContent,{children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:"Ignore this item?"}),t.jsxs(L.DialogDescription,{children:["Ignoring excludes this item from ",t.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.",r?" Its attributes are tracked independently and are not affected.":""]})]}),t.jsxs(L.DialogFooter,{children:[t.jsx(E.Button,{variant:"outline",onClick:()=>c(!1),disabled:f.isPending,children:"Cancel"}),t.jsxs(E.Button,{variant:"destructive",onClick:()=>f.mutate(),disabled:f.isPending,children:[t.jsx(M.Ban,{className:"w-4 h-4 mr-2"}),"Ignore item"]})]})]})})]})}function dn({releaseId:n,apiPath:s="/releases",onReset:i}){const{toast:e}=E.useToast(),{fetchJson:r}=E.useImaginariumApi(),l=Q.useQueryClient(),a=Q.useMutation({mutationFn:()=>r(`${s}/${n}/reset-exclusions`,{method:"POST"}),onSuccess:o=>{l.invalidateQueries({queryKey:["imaginarium","release-items",n]}),e({title:"Exclusions reset",description:`${o.reset} item${o.reset===1?"":"s"} re-enabled.`}),i==null||i(o.reset)},onError:o=>{e({title:"Error",description:o.message,variant:"destructive"})}});return t.jsxs(E.Button,{variant:"outline",size:"sm",onClick:()=>a.mutate(),disabled:a.isPending,children:[t.jsx(M.RotateCcw,{}),a.isPending?"Resetting…":"Reset exclusions"]})}function we(){}we.prototype={diff:function(s,i){var e,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=r.callback;typeof r=="function"&&(l=r,r={}),this.options=r;var a=this;function o(D){return l?(setTimeout(function(){l(void 0,D)},0),!0):D}s=this.castInput(s),i=this.castInput(i),s=this.removeEmpty(this.tokenize(s)),i=this.removeEmpty(this.tokenize(i));var d=i.length,u=s.length,c=1,m=d+u;r.maxEditLength&&(m=Math.min(m,r.maxEditLength));var x=(e=r.timeout)!==null&&e!==void 0?e:1/0,f=Date.now()+x,p=[{oldPos:-1,lastComponent:void 0}],N=this.extractCommon(p[0],i,s,0);if(p[0].oldPos+1>=u&&N+1>=d)return o([{value:this.join(i),count:i.length}]);var v=-1/0,g=1/0;function T(){for(var D=Math.max(v,-c);D<=Math.min(g,c);D+=2){var y=void 0,A=p[D-1],q=p[D+1];A&&(p[D-1]=void 0);var h=!1;if(q){var j=q.oldPos-D;h=q&&0<=j&&j<d}var k=A&&A.oldPos+1<u;if(!h&&!k){p[D]=void 0;continue}if(!k||h&&A.oldPos+1<q.oldPos?y=a.addToPath(q,!0,void 0,0):y=a.addToPath(A,void 0,!0,1),N=a.extractCommon(y,i,s,D),y.oldPos+1>=u&&N+1>=d)return o(_n(a,y.lastComponent,i,s,a.useLongestToken));p[D]=y,y.oldPos+1>=u&&(g=Math.min(g,D-1)),N+1>=d&&(v=Math.max(v,D+1))}c++}if(l)(function D(){setTimeout(function(){if(c>m||Date.now()>f)return l();T()||D()},0)})();else for(;c<=m&&Date.now()<=f;){var S=T();if(S)return S}},addToPath:function(s,i,e,r){var l=s.lastComponent;return l&&l.added===i&&l.removed===e?{oldPos:s.oldPos+r,lastComponent:{count:l.count+1,added:i,removed:e,previousComponent:l.previousComponent}}:{oldPos:s.oldPos+r,lastComponent:{count:1,added:i,removed:e,previousComponent:l}}},extractCommon:function(s,i,e,r){for(var l=i.length,a=e.length,o=s.oldPos,d=o-r,u=0;d+1<l&&o+1<a&&this.equals(i[d+1],e[o+1]);)d++,o++,u++;return u&&(s.lastComponent={count:u,previousComponent:s.lastComponent}),s.oldPos=o,d},equals:function(s,i){return this.options.comparator?this.options.comparator(s,i):s===i||this.options.ignoreCase&&s.toLowerCase()===i.toLowerCase()},removeEmpty:function(s){for(var i=[],e=0;e<s.length;e++)s[e]&&i.push(s[e]);return i},castInput:function(s){return s},tokenize:function(s){return s.split("")},join:function(s){return s.join("")}};function _n(n,s,i,e,r){for(var l=[],a;s;)l.push(s),a=s.previousComponent,delete s.previousComponent,s=a;l.reverse();for(var o=0,d=l.length,u=0,c=0;o<d;o++){var m=l[o];if(m.removed){if(m.value=n.join(e.slice(c,c+m.count)),c+=m.count,o&&l[o-1].added){var f=l[o-1];l[o-1]=l[o],l[o]=f}}else{if(!m.added&&r){var x=i.slice(u,u+m.count);x=x.map(function(N,v){var g=e[c+v];return g.length>N.length?g:N}),m.value=n.join(x)}else m.value=n.join(i.slice(u,u+m.count));u+=m.count,m.added||(c+=m.count)}}var p=l[d-1];return d>1&&typeof p.value=="string"&&(p.added||p.removed)&&n.equals("",p.value)&&(l[d-2].value+=p.value,l.pop()),l}function Un(n,s){if(typeof n=="function")s.callback=n;else if(n)for(var i in n)n.hasOwnProperty(i)&&(s[i]=n[i]);return s}var At=/^[A-Za-z\xC0-\u02C6\u02C8-\u02D7\u02DE-\u02FF\u1E00-\u1EFF]+$/,$t=/\S/,ft=new we;ft.equals=function(n,s){return this.options.ignoreCase&&(n=n.toLowerCase(),s=s.toLowerCase()),n===s||this.options.ignoreWhitespace&&!$t.test(n)&&!$t.test(s)};ft.tokenize=function(n){for(var s=n.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/),i=0;i<s.length-1;i++)!s[i+1]&&s[i+2]&&At.test(s[i])&&At.test(s[i+2])&&(s[i]+=s[i+2],s.splice(i+1,2),i--);return s};function Qn(n,s,i){return i=Un(i,{ignoreWhitespace:!0}),ft.diff(n,s,i)}var ht=new we;ht.tokenize=function(n){this.options.stripTrailingCr&&(n=n.replace(/\r\n/g,`
|
|
113
|
+
`));var s=[],i=n.split(/(\n|\r\n)/);i[i.length-1]||i.pop();for(var e=0;e<i.length;e++){var r=i[e];e%2&&!this.options.newlineIsToken?s[s.length-1]+=r:(this.options.ignoreWhitespace&&(r=r.trim()),s.push(r))}return s};function Vn(n,s,i){return ht.diff(n,s,i)}var Gn=new we;Gn.tokenize=function(n){return n.split(/(\S.+?[.!?])(?=\s+|$)/)};var Xn=new we;Xn.tokenize=function(n){return n.split(/([{}:;,]|\s+)/)};function qe(n){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qe=function(s){return typeof s}:qe=function(s){return s&&typeof Symbol=="function"&&s.constructor===Symbol&&s!==Symbol.prototype?"symbol":typeof s},qe(n)}function Ze(n){return Yn(n)||Zn(n)||es(n)||ts()}function Yn(n){if(Array.isArray(n))return it(n)}function Zn(n){if(typeof Symbol<"u"&&Symbol.iterator in Object(n))return Array.from(n)}function es(n,s){if(n){if(typeof n=="string")return it(n,s);var i=Object.prototype.toString.call(n).slice(8,-1);if(i==="Object"&&n.constructor&&(i=n.constructor.name),i==="Map"||i==="Set")return Array.from(n);if(i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return it(n,s)}}function it(n,s){(s==null||s>n.length)&&(s=n.length);for(var i=0,e=new Array(s);i<s;i++)e[i]=n[i];return e}function ts(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
114
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ns=Object.prototype.toString,Re=new we;Re.useLongestToken=!0;Re.tokenize=ht.tokenize;Re.castInput=function(n){var s=this.options,i=s.undefinedReplacement,e=s.stringifyReplacer,r=e===void 0?function(l,a){return typeof a>"u"?i:a}:e;return typeof n=="string"?n:JSON.stringify(rt(n,null,null,r),r," ")};Re.equals=function(n,s){return we.prototype.equals.call(Re,n.replace(/,([\r\n])/g,"$1"),s.replace(/,([\r\n])/g,"$1"))};function rt(n,s,i,e,r){s=s||[],i=i||[],e&&(n=e(r,n));var l;for(l=0;l<s.length;l+=1)if(s[l]===n)return i[l];var a;if(ns.call(n)==="[object Array]"){for(s.push(n),a=new Array(n.length),i.push(a),l=0;l<n.length;l+=1)a[l]=rt(n[l],s,i,e,r);return s.pop(),i.pop(),a}if(n&&n.toJSON&&(n=n.toJSON()),qe(n)==="object"&&n!==null){s.push(n),a={},i.push(a);var o=[],d;for(d in n)n.hasOwnProperty(d)&&o.push(d);for(o.sort(),l=0;l<o.length;l+=1)d=o[l],a[d]=rt(n[d],s,i,e,d);s.pop(),i.pop()}else a=n;return a}var at=new we;at.tokenize=function(n){return n.slice()};at.join=at.removeEmpty=function(n){return n};function ss(n,s,i,e,r,l,a){a||(a={}),typeof a.context>"u"&&(a.context=4);var o=Vn(i,e,a);if(!o)return;o.push({value:"",lines:[]});function d(g){return g.map(function(T){return" "+T})}for(var u=[],c=0,m=0,x=[],f=1,p=1,N=function(T){var S=o[T],D=S.lines||S.value.replace(/\n$/,"").split(`
|
|
115
|
+
`);if(S.lines=D,S.added||S.removed){var y;if(!c){var A=o[T-1];c=f,m=p,A&&(x=a.context>0?d(A.lines.slice(-a.context)):[],c-=x.length,m-=x.length)}(y=x).push.apply(y,Ze(D.map(function(_){return(S.added?"+":"-")+_}))),S.added?p+=D.length:f+=D.length}else{if(c)if(D.length<=a.context*2&&T<o.length-2){var q;(q=x).push.apply(q,Ze(d(D)))}else{var h,j=Math.min(D.length,a.context);(h=x).push.apply(h,Ze(d(D.slice(0,j))));var k={oldStart:c,oldLines:f-c+j,newStart:m,newLines:p-m+j,lines:x};if(T>=o.length-2&&D.length<=a.context){var B=/\n$/.test(i),$=/\n$/.test(e),w=D.length==0&&x.length>k.oldLines;!B&&w&&i.length>0&&x.splice(k.oldLines,0,"\"),(!B&&!w||!$)&&x.push("\")}u.push(k),c=0,m=0,x=[]}f+=D.length,p+=D.length}},v=0;v<o.length;v++)N(v);return{oldFileName:n,newFileName:s,oldHeader:r,newHeader:l,hunks:u}}function cn(n){if(Array.isArray(n))return n.map(cn).join(`
|
|
116
|
+
`);var s=[];n.oldFileName==n.newFileName&&s.push("Index: "+n.oldFileName),s.push("==================================================================="),s.push("--- "+n.oldFileName+(typeof n.oldHeader>"u"?"":" "+n.oldHeader)),s.push("+++ "+n.newFileName+(typeof n.newHeader>"u"?"":" "+n.newHeader));for(var i=0;i<n.hunks.length;i++){var e=n.hunks[i];e.oldLines===0&&(e.oldStart-=1),e.newLines===0&&(e.newStart-=1),s.push("@@ -"+e.oldStart+","+e.oldLines+" +"+e.newStart+","+e.newLines+" @@"),s.push.apply(s,e.lines)}return s.join(`
|
|
117
|
+
`)+`
|
|
118
|
+
`}function is(n,s,i,e,r,l,a){return cn(ss(n,s,i,e,r,l,a))}function Je(n,s,i,e,r,l){return is(n,n,s,i,e,r,l)}var ie;(function(n){n.INSERT="insert",n.DELETE="delete",n.CONTEXT="context"})(ie||(ie={}));const rs={LINE_BY_LINE:"line-by-line"},as={NONE:"none"},ls={WORD:"word"};var Te;(function(n){n.AUTO="auto",n.DARK="dark",n.LIGHT="light"})(Te||(Te={}));const os=["-","[","]","/","{","}","(",")","*","+","?",".","\\","^","$","|"],ds=RegExp("["+os.join("\\")+"]","g");function cs(n){return n.replace(ds,"\\$&")}function Lt(n){return n&&n.replace(/\\/g,"/")}function us(n){let s,i,e,r=0;for(s=0,e=n.length;s<e;s++)i=n.charCodeAt(s),r=(r<<5)-r+i,r|=0;return r}function un(n){const s=n.length;let i=-1/0;for(let e=0;e<s;e++)i=Math.max(i,n[e]);return i}function Rt(n,s){const i=n.split(".");return i.length>1?i[i.length-1]:s}function Ft(n,s){return s.reduce((i,e)=>i||n.startsWith(e),!1)}const Bt=["a/","b/","i/","w/","c/","o/"];function je(n,s,i){const e=i!==void 0?[...Bt,i]:Bt,r=s?new RegExp(`^${cs(s)} "?(.+?)"?$`):new RegExp('^"?(.+?)"?$'),[,l=""]=r.exec(n)||[],a=e.find(d=>l.indexOf(d)===0);return(a?l.slice(a.length):l).replace(/\s+\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}(?:\.\d+)? [+-]\d{4}.*$/,"")}function ms(n,s){return je(n,"---",s)}function fs(n,s){return je(n,"+++",s)}function hs(n,s={}){const i=[];let e=null,r=null,l=null,a=null,o=null,d=null,u=null;const c="--- ",m="+++ ",x="@@",f=/^old mode (\d{6})/,p=/^new mode (\d{6})/,N=/^deleted file mode (\d{6})/,v=/^new file mode (\d{6})/,g=/^copy from "?(.+)"?/,T=/^copy to "?(.+)"?/,S=/^rename from "?(.+)"?/,D=/^rename to "?(.+)"?/,y=/^similarity index (\d+)%/,A=/^dissimilarity index (\d+)%/,q=/^index ([\da-z]+)\.\.([\da-z]+)\s*(\d{6})?/,h=/^Binary files (.*) and (.*) differ/,j=/^GIT binary patch/,k=/^index ([\da-z]+),([\da-z]+)\.\.([\da-z]+)/,B=/^mode (\d{6}),(\d{6})\.\.(\d{6})/,$=/^new file mode (\d{6})/,w=/^deleted file mode (\d{6}),(\d{6})/,_=n.replace(/\/g,"").replace(/\r\n?/g,`
|
|
119
|
+
`).split(`
|
|
120
|
+
`);function F(){r!==null&&e!==null&&(e.blocks.push(r),r=null)}function Z(){e!==null&&(!e.oldName&&d!==null&&(e.oldName=d),!e.newName&&u!==null&&(e.newName=u),e.newName&&(i.push(e),e=null)),d=null,u=null}function ee(){F(),Z(),e={blocks:[],deletedLines:0,addedLines:0}}function V(C){F();let R;e!==null&&((R=/^@@ -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@.*/.exec(C))?(e.isCombined=!1,l=parseInt(R[1],10),o=parseInt(R[2],10)):(R=/^@@@ -(\d+)(?:,\d+)? -(\d+)(?:,\d+)? \+(\d+)(?:,\d+)? @@@.*/.exec(C))?(e.isCombined=!0,l=parseInt(R[1],10),a=parseInt(R[2],10),o=parseInt(R[3],10)):(C.startsWith(x)&&console.error("Failed to parse lines, starting in 0!"),l=0,o=0,e.isCombined=!1)),r={lines:[],oldStartLine:l,oldStartLine2:a,newStartLine:o,header:C}}function X(C){if(e===null||r===null||l===null||o===null)return;const R={content:C},O=e.isCombined?["+ "," +","++"]:["+"],U=e.isCombined?["- "," -","--"]:["-"];Ft(C,O)?(e.addedLines++,R.type=ie.INSERT,R.oldNumber=void 0,R.newNumber=o++):Ft(C,U)?(e.deletedLines++,R.type=ie.DELETE,R.oldNumber=l++,R.newNumber=void 0):(R.type=ie.CONTEXT,R.oldNumber=l++,R.newNumber=o++),r.lines.push(R)}function z(C,R){let O=R;for(;O<_.length-3;){if(C.startsWith("diff"))return!1;if(_[O].startsWith(c)&&_[O+1].startsWith(m)&&_[O+2].startsWith(x))return!0;O++}return!1}return _.forEach((C,R)=>{if(!C||C.startsWith("*"))return;let O;const U=_[R-1],ne=_[R+1],Y=_[R+2];if(C.startsWith("diff --git")||C.startsWith("diff --combined")){if(ee(),(O=/^diff --git "?([a-ciow]\/.+)"? "?([a-ciow]\/.+)"?/.exec(C))&&(d=je(O[1],void 0,s.dstPrefix),u=je(O[2],void 0,s.srcPrefix)),e===null)throw new Error("Where is my file !!!");e.isGitDiff=!0;return}if(C.startsWith("Binary files")&&!(e!=null&&e.isGitDiff)){if(ee(),(O=/^Binary files "?([a-ciow]\/.+)"? and "?([a-ciow]\/.+)"? differ/.exec(C))&&(d=je(O[1],void 0,s.dstPrefix),u=je(O[2],void 0,s.srcPrefix)),e===null)throw new Error("Where is my file !!!");e.isBinary=!0;return}if((!e||!e.isGitDiff&&e&&C.startsWith(c)&&ne.startsWith(m)&&Y.startsWith(x))&&ee(),e!=null&&e.isTooBig)return;if(e&&(typeof s.diffMaxChanges=="number"&&e.addedLines+e.deletedLines>s.diffMaxChanges||typeof s.diffMaxLineLength=="number"&&C.length>s.diffMaxLineLength)){e.isTooBig=!0,e.addedLines=0,e.deletedLines=0,e.blocks=[],r=null;const ae=typeof s.diffTooBigMessage=="function"?s.diffTooBigMessage(i.length):"Diff too big to be displayed";V(ae);return}if(C.startsWith(c)&&ne.startsWith(m)||C.startsWith(m)&&U.startsWith(c)){if(e&&!e.oldName&&C.startsWith("--- ")&&(O=ms(C,s.srcPrefix))){e.oldName=O,e.language=Rt(e.oldName,e.language);return}if(e&&!e.newName&&C.startsWith("+++ ")&&(O=fs(C,s.dstPrefix))){e.newName=O,e.language=Rt(e.newName,e.language);return}}if(e&&(C.startsWith(x)||e.isGitDiff&&e.oldName&&e.newName&&!r)){V(C);return}if(r&&(C.startsWith("+")||C.startsWith("-")||C.startsWith(" "))){X(C);return}const te=!z(C,R);if(e===null)throw new Error("Where is my file !!!");(O=f.exec(C))?e.oldMode=O[1]:(O=p.exec(C))?e.newMode=O[1]:(O=N.exec(C))?(e.deletedFileMode=O[1],e.isDeleted=!0):(O=v.exec(C))?(e.newFileMode=O[1],e.isNew=!0):(O=g.exec(C))?(te&&(e.oldName=O[1]),e.isCopy=!0):(O=T.exec(C))?(te&&(e.newName=O[1]),e.isCopy=!0):(O=S.exec(C))?(te&&(e.oldName=O[1]),e.isRename=!0):(O=D.exec(C))?(te&&(e.newName=O[1]),e.isRename=!0):(O=h.exec(C))?(e.isBinary=!0,e.oldName=je(O[1],void 0,s.srcPrefix),e.newName=je(O[2],void 0,s.dstPrefix),V("Binary file")):j.test(C)?(e.isBinary=!0,V(C)):(O=y.exec(C))?e.unchangedPercentage=parseInt(O[1],10):(O=A.exec(C))?e.changedPercentage=parseInt(O[1],10):(O=q.exec(C))?(e.checksumBefore=O[1],e.checksumAfter=O[2],O[3]&&(e.mode=O[3])):(O=k.exec(C))?(e.checksumBefore=[O[2],O[3]],e.checksumAfter=O[1]):(O=B.exec(C))?(e.oldMode=[O[2],O[3]],e.newMode=O[1]):(O=$.exec(C))?(e.newFileMode=O[1],e.isNew=!0):(O=w.exec(C))&&(e.deletedFileMode=O[1],e.isDeleted=!0)}),F(),Z(),i}class mn{diff(s,i,e={}){let r;typeof e=="function"?(r=e,e={}):"callback"in e&&(r=e.callback);const l=this.castInput(s,e),a=this.castInput(i,e),o=this.removeEmpty(this.tokenize(l,e)),d=this.removeEmpty(this.tokenize(a,e));return this.diffWithOptionsObj(o,d,e,r)}diffWithOptionsObj(s,i,e,r){var l;const a=T=>{if(T=this.postProcess(T,e),r){setTimeout(function(){r(T)},0);return}else return T},o=i.length,d=s.length;let u=1,c=o+d;e.maxEditLength!=null&&(c=Math.min(c,e.maxEditLength));const m=(l=e.timeout)!==null&&l!==void 0?l:1/0,x=Date.now()+m,f=[{oldPos:-1,lastComponent:void 0}];let p=this.extractCommon(f[0],i,s,0,e);if(f[0].oldPos+1>=d&&p+1>=o)return a(this.buildValues(f[0].lastComponent,i,s));let N=-1/0,v=1/0;const g=()=>{for(let T=Math.max(N,-u);T<=Math.min(v,u);T+=2){let S;const D=f[T-1],y=f[T+1];D&&(f[T-1]=void 0);let A=!1;if(y){const h=y.oldPos-T;A=y&&0<=h&&h<o}const q=D&&D.oldPos+1<d;if(!A&&!q){f[T]=void 0;continue}if(!q||A&&D.oldPos<y.oldPos?S=this.addToPath(y,!0,!1,0,e):S=this.addToPath(D,!1,!0,1,e),p=this.extractCommon(S,i,s,T,e),S.oldPos+1>=d&&p+1>=o)return a(this.buildValues(S.lastComponent,i,s))||!0;f[T]=S,S.oldPos+1>=d&&(v=Math.min(v,T-1)),p+1>=o&&(N=Math.max(N,T+1))}u++};if(r)(function T(){setTimeout(function(){if(u>c||Date.now()>x)return r(void 0);g()||T()},0)})();else for(;u<=c&&Date.now()<=x;){const T=g();if(T)return T}}addToPath(s,i,e,r,l){const a=s.lastComponent;return a&&!l.oneChangePerToken&&a.added===i&&a.removed===e?{oldPos:s.oldPos+r,lastComponent:{count:a.count+1,added:i,removed:e,previousComponent:a.previousComponent}}:{oldPos:s.oldPos+r,lastComponent:{count:1,added:i,removed:e,previousComponent:a}}}extractCommon(s,i,e,r,l){const a=i.length,o=e.length;let d=s.oldPos,u=d-r,c=0;for(;u+1<a&&d+1<o&&this.equals(e[d+1],i[u+1],l);)u++,d++,c++,l.oneChangePerToken&&(s.lastComponent={count:1,previousComponent:s.lastComponent,added:!1,removed:!1});return c&&!l.oneChangePerToken&&(s.lastComponent={count:c,previousComponent:s.lastComponent,added:!1,removed:!1}),s.oldPos=d,u}equals(s,i,e){return e.comparator?e.comparator(s,i):s===i||!!e.ignoreCase&&s.toLowerCase()===i.toLowerCase()}removeEmpty(s){const i=[];for(let e=0;e<s.length;e++)s[e]&&i.push(s[e]);return i}castInput(s,i){return s}tokenize(s,i){return Array.from(s)}join(s){return s.join("")}postProcess(s,i){return s}get useLongestToken(){return!1}buildValues(s,i,e){const r=[];let l;for(;s;)r.push(s),l=s.previousComponent,delete s.previousComponent,s=l;r.reverse();const a=r.length;let o=0,d=0,u=0;for(;o<a;o++){const c=r[o];if(c.removed)c.value=this.join(e.slice(u,u+c.count)),u+=c.count;else{if(!c.added&&this.useLongestToken){let m=i.slice(d,d+c.count);m=m.map(function(x,f){const p=e[u+f];return p.length>x.length?p:x}),c.value=this.join(m)}else c.value=this.join(i.slice(d,d+c.count));d+=c.count,c.added||(u+=c.count)}}return r}}class ps extends mn{}const gs=new ps;function xs(n,s,i){return gs.diff(n,s,i)}const Kt="a-zA-Z0-9_\\u{AD}\\u{C0}-\\u{D6}\\u{D8}-\\u{F6}\\u{F8}-\\u{2C6}\\u{2C8}-\\u{2D7}\\u{2DE}-\\u{2FF}\\u{1E00}-\\u{1EFF}";class bs extends mn{tokenize(s){const i=new RegExp(`(\\r?\\n)|[${Kt}]+|[^\\S\\n\\r]+|[^${Kt}]`,"ug");return s.match(i)||[]}}const ys=new bs;function vs(n,s,i){return ys.diff(n,s,i)}function js(n,s){if(n.length===0)return s.length;if(s.length===0)return n.length;const i=[];let e;for(e=0;e<=s.length;e++)i[e]=[e];let r;for(r=0;r<=n.length;r++)i[0][r]=r;for(e=1;e<=s.length;e++)for(r=1;r<=n.length;r++)s.charAt(e-1)===n.charAt(r-1)?i[e][r]=i[e-1][r-1]:i[e][r]=Math.min(i[e-1][r-1]+1,Math.min(i[e][r-1]+1,i[e-1][r]+1));return i[s.length][n.length]}function pt(n){return(s,i)=>{const e=n(s).trim(),r=n(i).trim();return js(e,r)/(e.length+r.length)}}function gt(n){function s(e,r,l=new Map){let a=1/0,o;for(let d=0;d<e.length;++d)for(let u=0;u<r.length;++u){const c=JSON.stringify([e[d],r[u]]);let m;l.has(c)&&(m=l.get(c))||(m=n(e[d],r[u]),l.set(c,m)),m<a&&(a=m,o={indexA:d,indexB:u,score:a})}return o}function i(e,r,l=0,a=new Map){const o=s(e,r,a);if(!o||e.length+r.length<3)return[[e,r]];const d=e.slice(0,o.indexA),u=r.slice(0,o.indexB),c=[e[o.indexA]],m=[r[o.indexB]],x=o.indexA+1,f=o.indexB+1,p=e.slice(x),N=r.slice(f),v=i(d,u,l+1,a),g=i(c,m,l+1,a),T=i(p,N,l+1,a);let S=g;return(o.indexA>0||o.indexB>0)&&(S=v.concat(S)),(e.length>x||r.length>f)&&(S=S.concat(T)),S}return i}const ce={INSERTS:"d2h-ins",DELETES:"d2h-del",CONTEXT:"d2h-cntx",INFO:"d2h-info",INSERT_CHANGES:"d2h-ins d2h-change",DELETE_CHANGES:"d2h-del d2h-change"},Xe={matching:as.NONE,matchWordsThreshold:.25,maxLineLengthHighlight:1e4,diffStyle:ls.WORD,colorScheme:Te.LIGHT},pe="/",fn=pt(n=>n.value),Ns=gt(fn);function et(n){return n.indexOf("dev/null")!==-1}function ws(n){return n.replace(/(<ins[^>]*>((.|\n)*?)<\/ins>)/g,"")}function Cs(n){return n.replace(/(<del[^>]*>((.|\n)*?)<\/del>)/g,"")}function _e(n){switch(n){case ie.CONTEXT:return ce.CONTEXT;case ie.INSERT:return ce.INSERTS;case ie.DELETE:return ce.DELETES}}function xt(n){switch(n){case Te.DARK:return"d2h-dark-color-scheme";case Te.AUTO:return"d2h-auto-color-scheme";case Te.LIGHT:default:return"d2h-light-color-scheme"}}function Ts(n){return n?2:1}function ke(n){return n.slice(0).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")}function xe(n,s,i=!0){const e=Ts(s);return{prefix:n.substring(0,e),content:i?ke(n.substring(e)):n.substring(e)}}function Ye(n){const s=Lt(n.oldName),i=Lt(n.newName);if(s!==i&&!et(s)&&!et(i)){const e=[],r=[],l=s.split(pe),a=i.split(pe),o=l.length,d=a.length;let u=0,c=o-1,m=d-1;for(;u<c&&u<m&&l[u]===a[u];)e.push(a[u]),u+=1;for(;c>u&&m>u&&l[c]===a[m];)r.unshift(a[m]),c-=1,m-=1;const x=e.join(pe),f=r.join(pe),p=l.slice(u,c+1).join(pe),N=a.slice(u,m+1).join(pe);return x.length&&f.length?x+pe+"{"+p+" → "+N+"}"+pe+f:x.length?x+pe+"{"+p+" → "+N+"}":f.length?"{"+p+" → "+N+"}"+pe+f:s+" → "+i}else return et(i)?s:i}function bt(n){return`d2h-${us(Ye(n)).toString().slice(-6)}`}function yt(n){let s="file-changed";return n.isRename||n.isCopy?s="file-renamed":n.isNew?s="file-added":n.isDeleted?s="file-deleted":n.newName!==n.oldName&&(s="file-renamed"),s}function hn(n,s,i,e={}){const{matching:r,maxLineLengthHighlight:l,matchWordsThreshold:a,diffStyle:o}=Object.assign(Object.assign({},Xe),e),d=xe(n,i,!1),u=xe(s,i,!1);if(d.content.length>l||u.content.length>l)return{oldLine:{prefix:d.prefix,content:ke(d.content)},newLine:{prefix:u.prefix,content:ke(u.content)}};const c=o==="char"?xs(d.content,u.content):vs(d.content,u.content),m=[];if(o==="word"&&r==="words"){const f=c.filter(v=>v.removed),p=c.filter(v=>v.added);Ns(p,f).forEach(v=>{v[0].length===1&&v[1].length===1&&fn(v[0][0],v[1][0])<a&&(m.push(v[0][0]),m.push(v[1][0]))})}const x=c.reduce((f,p)=>{const N=p.added?"ins":p.removed?"del":null,v=m.indexOf(p)>-1?' class="d2h-change"':"",g=ke(p.value);return N!==null?`${f}<${N}${v}>${g}</${N}>`:`${f}${g}`},"");return{oldLine:{prefix:d.prefix,content:ws(x)},newLine:{prefix:u.prefix,content:Cs(x)}}}const zt="file-summary",ks="icon",Ss={colorScheme:Xe.colorScheme};class Es{constructor(s,i={}){this.hoganUtils=s,this.config=Object.assign(Object.assign({},Ss),i)}render(s){const i=s.map(e=>this.hoganUtils.render(zt,"line",{fileHtmlId:bt(e),oldName:e.oldName,newName:e.newName,fileName:Ye(e),deletedLines:"-"+e.deletedLines,addedLines:"+"+e.addedLines},{fileIcon:this.hoganUtils.template(ks,yt(e))})).join(`
|
|
121
|
+
`);return this.hoganUtils.render(zt,"wrapper",{colorScheme:xt(this.config.colorScheme),filesNumber:s.length,files:i})}}const pn=Object.assign(Object.assign({},Xe),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),Ae="generic",Ht="line-by-line",Ps="icon",Ds="tag";class Os{constructor(s,i={}){this.hoganUtils=s,this.config=Object.assign(Object.assign({},pn),i)}render(s){const i=s.map(e=>{let r;return e.blocks.length?r=this.generateFileHtml(e):r=this.generateEmptyDiff(),this.makeFileDiffHtml(e,r)}).join(`
|
|
122
|
+
`);return this.hoganUtils.render(Ae,"wrapper",{colorScheme:xt(this.config.colorScheme),content:i})}makeFileDiffHtml(s,i){if(this.config.renderNothingWhenEmpty&&Array.isArray(s.blocks)&&s.blocks.length===0)return"";const e=this.hoganUtils.template(Ht,"file-diff"),r=this.hoganUtils.template(Ae,"file-path"),l=this.hoganUtils.template(Ps,"file"),a=this.hoganUtils.template(Ds,yt(s));return e.render({file:s,fileHtmlId:bt(s),diffs:i,filePath:r.render({fileDiffName:Ye(s)},{fileIcon:l,fileTag:a})})}generateEmptyDiff(){return this.hoganUtils.render(Ae,"empty-diff",{contentClass:"d2h-code-line",CSSLineClass:ce})}generateFileHtml(s){const i=gt(pt(e=>xe(e.content,s.isCombined).content));return s.blocks.map(e=>{let r=this.hoganUtils.render(Ae,"block-header",{CSSLineClass:ce,blockHeader:s.isTooBig?e.header:ke(e.header),lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line"});return this.applyLineGroupping(e).forEach(([l,a,o])=>{if(a.length&&o.length&&!l.length)this.applyRematchMatching(a,o,i).map(([d,u])=>{const{left:c,right:m}=this.processChangedLines(s,s.isCombined,d,u);r+=c,r+=m});else if(l.length)l.forEach(d=>{const{prefix:u,content:c}=xe(d.content,s.isCombined);r+=this.generateSingleLineHtml(s,{type:ce.CONTEXT,prefix:u,content:c,oldNumber:d.oldNumber,newNumber:d.newNumber})});else if(a.length||o.length){const{left:d,right:u}=this.processChangedLines(s,s.isCombined,a,o);r+=d,r+=u}else console.error("Unknown state reached while processing groups of lines",l,a,o)}),r}).join(`
|
|
123
|
+
`)}applyLineGroupping(s){const i=[];let e=[],r=[];for(let l=0;l<s.lines.length;l++){const a=s.lines[l];(a.type!==ie.INSERT&&r.length||a.type===ie.CONTEXT&&e.length>0)&&(i.push([[],e,r]),e=[],r=[]),a.type===ie.CONTEXT?i.push([[a],[],[]]):a.type===ie.INSERT&&e.length===0?i.push([[],[],[a]]):a.type===ie.INSERT&&e.length>0?r.push(a):a.type===ie.DELETE&&e.push(a)}return(e.length||r.length)&&(i.push([[],e,r]),e=[],r=[]),i}applyRematchMatching(s,i,e){const r=s.length*i.length,l=un(s.concat(i).map(o=>o.content.length));return r<this.config.matchingMaxComparisons&&l<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?e(s,i):[[s,i]]}processChangedLines(s,i,e,r){const l={right:"",left:""},a=Math.max(e.length,r.length);for(let o=0;o<a;o++){const d=e[o],u=r[o],c=d!==void 0&&u!==void 0?hn(d.content,u.content,i,this.config):void 0,m=d!==void 0&&d.oldNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.oldLine.prefix,content:c.oldLine.content,type:ce.DELETE_CHANGES}:Object.assign(Object.assign({},xe(d.content,i)),{type:_e(d.type)})),{oldNumber:d.oldNumber,newNumber:d.newNumber}):void 0,x=u!==void 0&&u.newNumber!==void 0?Object.assign(Object.assign({},c!==void 0?{prefix:c.newLine.prefix,content:c.newLine.content,type:ce.INSERT_CHANGES}:Object.assign(Object.assign({},xe(u.content,i)),{type:_e(u.type)})),{oldNumber:u.oldNumber,newNumber:u.newNumber}):void 0,{left:f,right:p}=this.generateLineHtml(s,m,x);l.left+=f,l.right+=p}return l}generateLineHtml(s,i,e){return{left:this.generateSingleLineHtml(s,i),right:this.generateSingleLineHtml(s,e)}}generateSingleLineHtml(s,i){if(i===void 0)return"";const e=this.hoganUtils.render(Ht,"numbers",{oldNumber:i.oldNumber||"",newNumber:i.newNumber||""});return this.hoganUtils.render(Ae,"line",{type:i.type,lineClass:"d2h-code-linenumber",contentClass:"d2h-code-line",prefix:i.prefix===" "?" ":i.prefix,content:i.content,lineNumber:e,line:i,file:s})}}const gn=Object.assign(Object.assign({},Xe),{renderNothingWhenEmpty:!1,matchingMaxComparisons:2500,maxLineSizeInBlockForComparison:200}),$e="generic",Is="side-by-side",Ms="icon",As="tag";class $s{constructor(s,i={}){this.hoganUtils=s,this.config=Object.assign(Object.assign({},gn),i)}render(s){const i=s.map(e=>{let r;return e.blocks.length?r=this.generateFileHtml(e):r=this.generateEmptyDiff(),this.makeFileDiffHtml(e,r)}).join(`
|
|
124
|
+
`);return this.hoganUtils.render($e,"wrapper",{colorScheme:xt(this.config.colorScheme),content:i})}makeFileDiffHtml(s,i){if(this.config.renderNothingWhenEmpty&&Array.isArray(s.blocks)&&s.blocks.length===0)return"";const e=this.hoganUtils.template(Is,"file-diff"),r=this.hoganUtils.template($e,"file-path"),l=this.hoganUtils.template(Ms,"file"),a=this.hoganUtils.template(As,yt(s));return e.render({file:s,fileHtmlId:bt(s),diffs:i,filePath:r.render({fileDiffName:Ye(s)},{fileIcon:l,fileTag:a})})}generateEmptyDiff(){return{right:"",left:this.hoganUtils.render($e,"empty-diff",{contentClass:"d2h-code-side-line",CSSLineClass:ce})}}generateFileHtml(s){const i=gt(pt(e=>xe(e.content,s.isCombined).content));return s.blocks.map(e=>{const r={left:this.makeHeaderHtml(e.header,s),right:this.makeHeaderHtml("")};return this.applyLineGroupping(e).forEach(([l,a,o])=>{if(a.length&&o.length&&!l.length)this.applyRematchMatching(a,o,i).map(([d,u])=>{const{left:c,right:m}=this.processChangedLines(s.isCombined,d,u);r.left+=c,r.right+=m});else if(l.length)l.forEach(d=>{const{prefix:u,content:c}=xe(d.content,s.isCombined),{left:m,right:x}=this.generateLineHtml({type:ce.CONTEXT,prefix:u,content:c,number:d.oldNumber},{type:ce.CONTEXT,prefix:u,content:c,number:d.newNumber});r.left+=m,r.right+=x});else if(a.length||o.length){const{left:d,right:u}=this.processChangedLines(s.isCombined,a,o);r.left+=d,r.right+=u}else console.error("Unknown state reached while processing groups of lines",l,a,o)}),r}).reduce((e,r)=>({left:e.left+r.left,right:e.right+r.right}),{left:"",right:""})}applyLineGroupping(s){const i=[];let e=[],r=[];for(let l=0;l<s.lines.length;l++){const a=s.lines[l];(a.type!==ie.INSERT&&r.length||a.type===ie.CONTEXT&&e.length>0)&&(i.push([[],e,r]),e=[],r=[]),a.type===ie.CONTEXT?i.push([[a],[],[]]):a.type===ie.INSERT&&e.length===0?i.push([[],[],[a]]):a.type===ie.INSERT&&e.length>0?r.push(a):a.type===ie.DELETE&&e.push(a)}return(e.length||r.length)&&(i.push([[],e,r]),e=[],r=[]),i}applyRematchMatching(s,i,e){const r=s.length*i.length,l=un(s.concat(i).map(o=>o.content.length));return r<this.config.matchingMaxComparisons&&l<this.config.maxLineSizeInBlockForComparison&&(this.config.matching==="lines"||this.config.matching==="words")?e(s,i):[[s,i]]}makeHeaderHtml(s,i){return this.hoganUtils.render($e,"block-header",{CSSLineClass:ce,blockHeader:i!=null&&i.isTooBig?s:ke(s),lineClass:"d2h-code-side-linenumber",contentClass:"d2h-code-side-line"})}processChangedLines(s,i,e){const r={right:"",left:""},l=Math.max(i.length,e.length);for(let a=0;a<l;a++){const o=i[a],d=e[a],u=o!==void 0&&d!==void 0?hn(o.content,d.content,s,this.config):void 0,c=o!==void 0&&o.oldNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.oldLine.prefix,content:u.oldLine.content,type:ce.DELETE_CHANGES}:Object.assign(Object.assign({},xe(o.content,s)),{type:_e(o.type)})),{number:o.oldNumber}):void 0,m=d!==void 0&&d.newNumber!==void 0?Object.assign(Object.assign({},u!==void 0?{prefix:u.newLine.prefix,content:u.newLine.content,type:ce.INSERT_CHANGES}:Object.assign(Object.assign({},xe(d.content,s)),{type:_e(d.type)})),{number:d.newNumber}):void 0,{left:x,right:f}=this.generateLineHtml(c,m);r.left+=x,r.right+=f}return r}generateLineHtml(s,i){return{left:this.generateSingleHtml(s),right:this.generateSingleHtml(i)}}generateSingleHtml(s){const i="d2h-code-side-linenumber",e="d2h-code-side-line";return this.hoganUtils.render($e,"line",{type:(s==null?void 0:s.type)||`${ce.CONTEXT} d2h-emptyplaceholder`,lineClass:s!==void 0?i:`${i} d2h-code-side-emptyplaceholder`,contentClass:s!==void 0?e:`${e} d2h-code-side-emptyplaceholder`,prefix:(s==null?void 0:s.prefix)===" "?" ":s==null?void 0:s.prefix,content:s==null?void 0:s.content,lineNumber:s==null?void 0:s.number})}}var xn={};(function(n){(function(s){var i=/\S/,e=/\"/g,r=/\n/g,l=/\r/g,a=/\\/g,o=/\u2028/,d=/\u2029/;s.tags={"#":1,"^":2,"<":3,$:4,"/":5,"!":6,">":7,"=":8,_v:9,"{":10,"&":11,_t:12},s.scan=function(j,k){var B=j.length,$=0,w=1,_=2,F=$,Z=null,ee=null,V="",X=[],z=!1,C=0,R=0,O="{{",U="}}";function ne(){V.length>0&&(X.push({tag:"_t",text:new String(V)}),V="")}function Y(){for(var le=!0,oe=R;oe<X.length;oe++)if(le=s.tags[X[oe].tag]<s.tags._v||X[oe].tag=="_t"&&X[oe].text.match(i)===null,!le)return!1;return le}function te(le,oe){if(ne(),le&&Y())for(var de=R,fe;de<X.length;de++)X[de].text&&((fe=X[de+1])&&fe.tag==">"&&(fe.indent=X[de].text.toString()),X.splice(de,1));else oe||X.push({tag:`
|
|
125
|
+
`});z=!1,R=X.length}function ae(le,oe){var de="="+U,fe=le.indexOf(de,oe),Pe=c(le.substring(le.indexOf("=",oe)+1,fe)).split(" ");return O=Pe[0],U=Pe[Pe.length-1],fe+de.length-1}for(k&&(k=k.split(" "),O=k[0],U=k[1]),C=0;C<B;C++)F==$?m(O,j,C)?(--C,ne(),F=w):j.charAt(C)==`
|
|
126
|
+
`?te(z):V+=j.charAt(C):F==w?(C+=O.length-1,ee=s.tags[j.charAt(C+1)],Z=ee?j.charAt(C+1):"_v",Z=="="?(C=ae(j,C),F=$):(ee&&C++,F=_),z=C):m(U,j,C)?(X.push({tag:Z,n:c(V),otag:O,ctag:U,i:Z=="/"?z-O.length:C+U.length}),V="",C+=U.length-1,F=$,Z=="{"&&(U=="}}"?C++:u(X[X.length-1]))):V+=j.charAt(C);return te(z,!0),X};function u(h){h.n.substr(h.n.length-1)==="}"&&(h.n=h.n.substring(0,h.n.length-1))}function c(h){return h.trim?h.trim():h.replace(/^\s*|\s*$/g,"")}function m(h,j,k){if(j.charAt(k)!=h.charAt(0))return!1;for(var B=1,$=h.length;B<$;B++)if(j.charAt(k+B)!=h.charAt(B))return!1;return!0}var x={_t:!0,"\n":!0,$:!0,"/":!0};function f(h,j,k,B){var $=[],w=null,_=null,F=null;for(_=k[k.length-1];h.length>0;){if(F=h.shift(),_&&_.tag=="<"&&!(F.tag in x))throw new Error("Illegal content in < super tag.");if(s.tags[F.tag]<=s.tags.$||p(F,B))k.push(F),F.nodes=f(h,F.tag,k,B);else if(F.tag=="/"){if(k.length===0)throw new Error("Closing tag without opener: /"+F.n);if(w=k.pop(),F.n!=w.n&&!N(F.n,w.n,B))throw new Error("Nesting error: "+w.n+" vs. "+F.n);return w.end=F.i,$}else F.tag==`
|
|
127
|
+
`&&(F.last=h.length==0||h[0].tag==`
|
|
128
|
+
`);$.push(F)}if(k.length>0)throw new Error("missing closing tag: "+k.pop().n);return $}function p(h,j){for(var k=0,B=j.length;k<B;k++)if(j[k].o==h.n)return h.tag="#",!0}function N(h,j,k){for(var B=0,$=k.length;B<$;B++)if(k[B].c==h&&k[B].o==j)return!0}function v(h){var j=[];for(var k in h)j.push('"'+S(k)+'": function(c,p,t,i) {'+h[k]+"}");return"{ "+j.join(",")+" }"}function g(h){var j=[];for(var k in h.partials)j.push('"'+S(k)+'":{name:"'+S(h.partials[k].name)+'", '+g(h.partials[k])+"}");return"partials: {"+j.join(",")+"}, subs: "+v(h.subs)}s.stringify=function(h,j,k){return"{code: function (c,p,i) { "+s.wrapMain(h.code)+" },"+g(h)+"}"};var T=0;s.generate=function(h,j,k){T=0;var B={code:"",subs:{},partials:{}};return s.walk(h,B),k.asString?this.stringify(B,j,k):this.makeTemplate(B,j,k)},s.wrapMain=function(h){return'var t=this;t.b(i=i||"");'+h+"return t.fl();"},s.template=s.Template,s.makeTemplate=function(h,j,k){var B=this.makePartials(h);return B.code=new Function("c","p","i",this.wrapMain(h.code)),new this.template(B,j,this,k)},s.makePartials=function(h){var j,k={subs:{},partials:h.partials,name:h.name};for(j in k.partials)k.partials[j]=this.makePartials(k.partials[j]);for(j in h.subs)k.subs[j]=new Function("c","p","t","i",h.subs[j]);return k};function S(h){return h.replace(a,"\\\\").replace(e,'\\"').replace(r,"\\n").replace(l,"\\r").replace(o,"\\u2028").replace(d,"\\u2029")}function D(h){return~h.indexOf(".")?"d":"f"}function y(h,j){var k="<"+(j.prefix||""),B=k+h.n+T++;return j.partials[B]={name:h.n,partials:{}},j.code+='t.b(t.rp("'+S(B)+'",c,p,"'+(h.indent||"")+'"));',B}s.codegen={"#":function(h,j){j.code+="if(t.s(t."+D(h.n)+'("'+S(h.n)+'",c,p,1),c,p,0,'+h.i+","+h.end+',"'+h.otag+" "+h.ctag+'")){t.rs(c,p,function(c,p,t){',s.walk(h.nodes,j),j.code+="});c.pop();}"},"^":function(h,j){j.code+="if(!t.s(t."+D(h.n)+'("'+S(h.n)+'",c,p,1),c,p,1,0,0,"")){',s.walk(h.nodes,j),j.code+="};"},">":y,"<":function(h,j){var k={partials:{},code:"",subs:{},inPartial:!0};s.walk(h.nodes,k);var B=j.partials[y(h,j)];B.subs=k.subs,B.partials=k.partials},$:function(h,j){var k={subs:{},code:"",partials:j.partials,prefix:h.n};s.walk(h.nodes,k),j.subs[h.n]=k.code,j.inPartial||(j.code+='t.sub("'+S(h.n)+'",c,p,i);')},"\n":function(h,j){j.code+=q('"\\n"'+(h.last?"":" + i"))},_v:function(h,j){j.code+="t.b(t.v(t."+D(h.n)+'("'+S(h.n)+'",c,p,0)));'},_t:function(h,j){j.code+=q('"'+S(h.text)+'"')},"{":A,"&":A};function A(h,j){j.code+="t.b(t.t(t."+D(h.n)+'("'+S(h.n)+'",c,p,0)));'}function q(h){return"t.b("+h+");"}s.walk=function(h,j){for(var k,B=0,$=h.length;B<$;B++)k=s.codegen[h[B].tag],k&&k(h[B],j);return j},s.parse=function(h,j,k){return k=k||{},f(h,"",[],k.sectionTags||[])},s.cache={},s.cacheKey=function(h,j){return[h,!!j.asString,!!j.disableLambda,j.delimiters,!!j.modelGet].join("||")},s.compile=function(h,j){j=j||{};var k=s.cacheKey(h,j),B=this.cache[k];if(B){var $=B.partials;for(var w in $)delete $[w].instance;return B}return B=this.generate(this.parse(this.scan(h,j.delimiters),h,j),h,j),this.cache[k]=B}})(n)})(xn);var bn={};(function(n){(function(s){s.Template=function(f,p,N,v){f=f||{},this.r=f.code||this.r,this.c=N,this.options=v||{},this.text=p||"",this.partials=f.partials||{},this.subs=f.subs||{},this.buf=""},s.Template.prototype={r:function(f,p,N){return""},v:m,t:c,render:function(p,N,v){return this.ri([p],N||{},v)},ri:function(f,p,N){return this.r(f,p,N)},ep:function(f,p){var N=this.partials[f],v=p[N.name];if(N.instance&&N.base==v)return N.instance;if(typeof v=="string"){if(!this.c)throw new Error("No compiler available.");v=this.c.compile(v,this.options)}if(!v)return null;if(this.partials[f].base=v,N.subs){p.stackText||(p.stackText={});for(key in N.subs)p.stackText[key]||(p.stackText[key]=this.activeSub!==void 0&&p.stackText[this.activeSub]?p.stackText[this.activeSub]:this.text);v=e(v,N.subs,N.partials,this.stackSubs,this.stackPartials,p.stackText)}return this.partials[f].instance=v,v},rp:function(f,p,N,v){var g=this.ep(f,N);return g?g.ri(p,N,v):""},rs:function(f,p,N){var v=f[f.length-1];if(!x(v)){N(f,p,this);return}for(var g=0;g<v.length;g++)f.push(v[g]),N(f,p,this),f.pop()},s:function(f,p,N,v,g,T,S){var D;return x(f)&&f.length===0?!1:(typeof f=="function"&&(f=this.ms(f,p,N,v,g,T,S)),D=!!f,!v&&D&&p&&p.push(typeof f=="object"?f:p[p.length-1]),D)},d:function(f,p,N,v){var g,T=f.split("."),S=this.f(T[0],p,N,v),D=this.options.modelGet,y=null;if(f==="."&&x(p[p.length-2]))S=p[p.length-1];else for(var A=1;A<T.length;A++)g=i(T[A],S,D),g!==void 0?(y=S,S=g):S="";return v&&!S?!1:(!v&&typeof S=="function"&&(p.push(y),S=this.mv(S,p,N),p.pop()),S)},f:function(f,p,N,v){for(var g=!1,T=null,S=!1,D=this.options.modelGet,y=p.length-1;y>=0;y--)if(T=p[y],g=i(f,T,D),g!==void 0){S=!0;break}return S?(!v&&typeof g=="function"&&(g=this.mv(g,p,N)),g):v?!1:""},ls:function(f,p,N,v,g,T){var S=this.options.delimiters;return this.options.delimiters=T,this.b(this.ct(c(f.call(p,g,N)),p,v)),this.options.delimiters=S,!1},ct:function(f,p,N){if(this.options.disableLambda)throw new Error("Lambda features disabled.");return this.c.compile(f,this.options).render(p,N)},b:function(f){this.buf+=f},fl:function(){var f=this.buf;return this.buf="",f},ms:function(f,p,N,v,g,T,S){var D,y=p[p.length-1],A=f.call(y);return typeof A=="function"?v?!0:(D=this.activeSub&&this.subsText&&this.subsText[this.activeSub]?this.subsText[this.activeSub]:this.text,this.ls(A,y,p,N,D.substring(g,T),S)):A},mv:function(f,p,N){var v=p[p.length-1],g=f.call(v);return typeof g=="function"?this.ct(c(g.call(v)),v,N):g},sub:function(f,p,N,v){var g=this.subs[f];g&&(this.activeSub=f,g(p,N,this,v),this.activeSub=!1)}};function i(f,p,N){var v;return p&&typeof p=="object"&&(p[f]!==void 0?v=p[f]:N&&p.get&&typeof p.get=="function"&&(v=p.get(f))),v}function e(f,p,N,v,g,T){function S(){}S.prototype=f;function D(){}D.prototype=f.subs;var y,A=new S;A.subs=new D,A.subsText={},A.buf="",v=v||{},A.stackSubs=v,A.subsText=T;for(y in p)v[y]||(v[y]=p[y]);for(y in v)A.subs[y]=v[y];g=g||{},A.stackPartials=g;for(y in N)g[y]||(g[y]=N[y]);for(y in g)A.partials[y]=g[y];return A}var r=/&/g,l=/</g,a=/>/g,o=/\'/g,d=/\"/g,u=/[&<>\"\']/;function c(f){return String(f??"")}function m(f){return f=c(f),u.test(f)?f.replace(r,"&").replace(l,"<").replace(a,">").replace(o,"'").replace(d,"""):f}var x=Array.isArray||function(f){return Object.prototype.toString.call(f)==="[object Array]"}})(n)})(bn);var Ue=xn;Ue.Template=bn.Template;Ue.template=Ue.Template;var se=Ue;const re={};re["file-summary-line"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<li class="d2h-file-list-line">'),e.b(`
|
|
129
|
+
`+i),e.b(' <span class="d2h-file-name-wrapper">'),e.b(`
|
|
130
|
+
`+i),e.b(e.rp("<fileIcon0",n,s," ")),e.b(' <a href="#'),e.b(e.v(e.f("fileHtmlId",n,s,0))),e.b('" class="d2h-file-name">'),e.b(e.v(e.f("fileName",n,s,0))),e.b("</a>"),e.b(`
|
|
131
|
+
`+i),e.b(' <span class="d2h-file-stats">'),e.b(`
|
|
132
|
+
`+i),e.b(' <span class="d2h-lines-added">'),e.b(e.v(e.f("addedLines",n,s,0))),e.b("</span>"),e.b(`
|
|
133
|
+
`+i),e.b(' <span class="d2h-lines-deleted">'),e.b(e.v(e.f("deletedLines",n,s,0))),e.b("</span>"),e.b(`
|
|
134
|
+
`+i),e.b(" </span>"),e.b(`
|
|
135
|
+
`+i),e.b(" </span>"),e.b(`
|
|
136
|
+
`+i),e.b("</li>"),e.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}}},subs:{}});re["file-summary-wrapper"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<div class="d2h-file-list-wrapper '),e.b(e.v(e.f("colorScheme",n,s,0))),e.b('">'),e.b(`
|
|
137
|
+
`+i),e.b(' <div class="d2h-file-list-header">'),e.b(`
|
|
138
|
+
`+i),e.b(' <span class="d2h-file-list-title">Files changed ('),e.b(e.v(e.f("filesNumber",n,s,0))),e.b(")</span>"),e.b(`
|
|
139
|
+
`+i),e.b(' <a class="d2h-file-switch d2h-hide">hide</a>'),e.b(`
|
|
140
|
+
`+i),e.b(' <a class="d2h-file-switch d2h-show">show</a>'),e.b(`
|
|
141
|
+
`+i),e.b(" </div>"),e.b(`
|
|
142
|
+
`+i),e.b(' <ol class="d2h-file-list">'),e.b(`
|
|
143
|
+
`+i),e.b(" "),e.b(e.t(e.f("files",n,s,0))),e.b(`
|
|
144
|
+
`+i),e.b(" </ol>"),e.b(`
|
|
145
|
+
`+i),e.b("</div>"),e.fl()},partials:{},subs:{}});re["generic-block-header"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b("<tr>"),e.b(`
|
|
146
|
+
`+i),e.b(' <td class="'),e.b(e.v(e.f("lineClass",n,s,0))),e.b(" "),e.b(e.v(e.d("CSSLineClass.INFO",n,s,0))),e.b('"></td>'),e.b(`
|
|
147
|
+
`+i),e.b(' <td class="'),e.b(e.v(e.d("CSSLineClass.INFO",n,s,0))),e.b('">'),e.b(`
|
|
148
|
+
`+i),e.b(' <div class="'),e.b(e.v(e.f("contentClass",n,s,0))),e.b('">'),e.s(e.f("blockHeader",n,s,1),n,s,0,156,173,"{{ }}")&&(e.rs(n,s,function(r,l,a){a.b(a.t(a.f("blockHeader",r,l,0)))}),n.pop()),e.s(e.f("blockHeader",n,s,1),n,s,1,0,0,"")||e.b(" "),e.b("</div>"),e.b(`
|
|
149
|
+
`+i),e.b(" </td>"),e.b(`
|
|
150
|
+
`+i),e.b("</tr>"),e.fl()},partials:{},subs:{}});re["generic-empty-diff"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b("<tr>"),e.b(`
|
|
151
|
+
`+i),e.b(' <td class="'),e.b(e.v(e.d("CSSLineClass.INFO",n,s,0))),e.b('">'),e.b(`
|
|
152
|
+
`+i),e.b(' <div class="'),e.b(e.v(e.f("contentClass",n,s,0))),e.b('">'),e.b(`
|
|
153
|
+
`+i),e.b(" File without changes"),e.b(`
|
|
154
|
+
`+i),e.b(" </div>"),e.b(`
|
|
155
|
+
`+i),e.b(" </td>"),e.b(`
|
|
156
|
+
`+i),e.b("</tr>"),e.fl()},partials:{},subs:{}});re["generic-file-path"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<span class="d2h-file-name-wrapper">'),e.b(`
|
|
157
|
+
`+i),e.b(e.rp("<fileIcon0",n,s," ")),e.b(' <span class="d2h-file-name">'),e.b(e.v(e.f("fileDiffName",n,s,0))),e.b("</span>"),e.b(`
|
|
158
|
+
`+i),e.b(e.rp("<fileTag1",n,s," ")),e.b("</span>"),e.b(`
|
|
159
|
+
`+i),e.b('<label class="d2h-file-collapse">'),e.b(`
|
|
160
|
+
`+i),e.b(' <input class="d2h-file-collapse-input" type="checkbox" name="viewed" value="viewed">'),e.b(`
|
|
161
|
+
`+i),e.b(" Viewed"),e.b(`
|
|
162
|
+
`+i),e.b("</label>"),e.fl()},partials:{"<fileIcon0":{name:"fileIcon",partials:{},subs:{}},"<fileTag1":{name:"fileTag",partials:{},subs:{}}},subs:{}});re["generic-line"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b("<tr>"),e.b(`
|
|
163
|
+
`+i),e.b(' <td class="'),e.b(e.v(e.f("lineClass",n,s,0))),e.b(" "),e.b(e.v(e.f("type",n,s,0))),e.b('">'),e.b(`
|
|
164
|
+
`+i),e.b(" "),e.b(e.t(e.f("lineNumber",n,s,0))),e.b(`
|
|
165
|
+
`+i),e.b(" </td>"),e.b(`
|
|
166
|
+
`+i),e.b(' <td class="'),e.b(e.v(e.f("type",n,s,0))),e.b('">'),e.b(`
|
|
167
|
+
`+i),e.b(' <div class="'),e.b(e.v(e.f("contentClass",n,s,0))),e.b('">'),e.b(`
|
|
168
|
+
`+i),e.s(e.f("prefix",n,s,1),n,s,0,162,238,"{{ }}")&&(e.rs(n,s,function(r,l,a){a.b(' <span class="d2h-code-line-prefix">'),a.b(a.t(a.f("prefix",r,l,0))),a.b("</span>"),a.b(`
|
|
169
|
+
`+i)}),n.pop()),e.s(e.f("prefix",n,s,1),n,s,1,0,0,"")||(e.b(' <span class="d2h-code-line-prefix"> </span>'),e.b(`
|
|
170
|
+
`+i)),e.s(e.f("content",n,s,1),n,s,0,371,445,"{{ }}")&&(e.rs(n,s,function(r,l,a){a.b(' <span class="d2h-code-line-ctn">'),a.b(a.t(a.f("content",r,l,0))),a.b("</span>"),a.b(`
|
|
171
|
+
`+i)}),n.pop()),e.s(e.f("content",n,s,1),n,s,1,0,0,"")||(e.b(' <span class="d2h-code-line-ctn"><br></span>'),e.b(`
|
|
172
|
+
`+i)),e.b(" </div>"),e.b(`
|
|
173
|
+
`+i),e.b(" </td>"),e.b(`
|
|
174
|
+
`+i),e.b("</tr>"),e.fl()},partials:{},subs:{}});re["generic-wrapper"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<div class="d2h-wrapper '),e.b(e.v(e.f("colorScheme",n,s,0))),e.b('">'),e.b(`
|
|
175
|
+
`+i),e.b(" "),e.b(e.t(e.f("content",n,s,0))),e.b(`
|
|
176
|
+
`+i),e.b("</div>"),e.fl()},partials:{},subs:{}});re["icon-file-added"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-added" height="16" title="added" version="1.1" viewBox="0 0 14 16"'),e.b(`
|
|
177
|
+
`+i),e.b(' width="14">'),e.b(`
|
|
178
|
+
`+i),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z"></path>'),e.b(`
|
|
179
|
+
`+i),e.b("</svg>"),e.fl()},partials:{},subs:{}});re["icon-file-changed"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"'),e.b(`
|
|
180
|
+
`+i),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
|
|
181
|
+
`+i),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>'),e.b(`
|
|
182
|
+
`+i),e.b("</svg>"),e.fl()},partials:{},subs:{}});re["icon-file-deleted"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-deleted" height="16" title="removed" version="1.1"'),e.b(`
|
|
183
|
+
`+i),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
|
|
184
|
+
`+i),e.b(' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z"></path>'),e.b(`
|
|
185
|
+
`+i),e.b("</svg>"),e.fl()},partials:{},subs:{}});re["icon-file-renamed"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<svg aria-hidden="true" class="d2h-icon d2h-moved" height="16" title="renamed" version="1.1"'),e.b(`
|
|
186
|
+
`+i),e.b(' viewBox="0 0 14 16" width="14">'),e.b(`
|
|
187
|
+
`+i),e.b(' <path d="M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z"></path>'),e.b(`
|
|
188
|
+
`+i),e.b("</svg>"),e.fl()},partials:{},subs:{}});re["icon-file"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">'),e.b(`
|
|
189
|
+
`+i),e.b(' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>'),e.b(`
|
|
190
|
+
`+i),e.b("</svg>"),e.fl()},partials:{},subs:{}});re["line-by-line-file-diff"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<div id="'),e.b(e.v(e.f("fileHtmlId",n,s,0))),e.b('" class="d2h-file-wrapper" data-lang="'),e.b(e.v(e.d("file.language",n,s,0))),e.b('">'),e.b(`
|
|
191
|
+
`+i),e.b(' <div class="d2h-file-header">'),e.b(`
|
|
192
|
+
`+i),e.b(" "),e.b(e.t(e.f("filePath",n,s,0))),e.b(`
|
|
193
|
+
`+i),e.b(" </div>"),e.b(`
|
|
194
|
+
`+i),e.b(' <div class="d2h-file-diff">'),e.b(`
|
|
195
|
+
`+i),e.b(' <div class="d2h-code-wrapper">'),e.b(`
|
|
196
|
+
`+i),e.b(' <table class="d2h-diff-table">'),e.b(`
|
|
197
|
+
`+i),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
|
|
198
|
+
`+i),e.b(" "),e.b(e.t(e.f("diffs",n,s,0))),e.b(`
|
|
199
|
+
`+i),e.b(" </tbody>"),e.b(`
|
|
200
|
+
`+i),e.b(" </table>"),e.b(`
|
|
201
|
+
`+i),e.b(" </div>"),e.b(`
|
|
202
|
+
`+i),e.b(" </div>"),e.b(`
|
|
203
|
+
`+i),e.b("</div>"),e.fl()},partials:{},subs:{}});re["line-by-line-numbers"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<div class="line-num1">'),e.b(e.v(e.f("oldNumber",n,s,0))),e.b("</div>"),e.b(`
|
|
204
|
+
`+i),e.b('<div class="line-num2">'),e.b(e.v(e.f("newNumber",n,s,0))),e.b("</div>"),e.fl()},partials:{},subs:{}});re["side-by-side-file-diff"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<div id="'),e.b(e.v(e.f("fileHtmlId",n,s,0))),e.b('" class="d2h-file-wrapper" data-lang="'),e.b(e.v(e.d("file.language",n,s,0))),e.b('">'),e.b(`
|
|
205
|
+
`+i),e.b(' <div class="d2h-file-header">'),e.b(`
|
|
206
|
+
`+i),e.b(" "),e.b(e.t(e.f("filePath",n,s,0))),e.b(`
|
|
207
|
+
`+i),e.b(" </div>"),e.b(`
|
|
208
|
+
`+i),e.b(' <div class="d2h-files-diff">'),e.b(`
|
|
209
|
+
`+i),e.b(' <div class="d2h-file-side-diff">'),e.b(`
|
|
210
|
+
`+i),e.b(' <div class="d2h-code-wrapper">'),e.b(`
|
|
211
|
+
`+i),e.b(' <table class="d2h-diff-table">'),e.b(`
|
|
212
|
+
`+i),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
|
|
213
|
+
`+i),e.b(" "),e.b(e.t(e.d("diffs.left",n,s,0))),e.b(`
|
|
214
|
+
`+i),e.b(" </tbody>"),e.b(`
|
|
215
|
+
`+i),e.b(" </table>"),e.b(`
|
|
216
|
+
`+i),e.b(" </div>"),e.b(`
|
|
217
|
+
`+i),e.b(" </div>"),e.b(`
|
|
218
|
+
`+i),e.b(' <div class="d2h-file-side-diff">'),e.b(`
|
|
219
|
+
`+i),e.b(' <div class="d2h-code-wrapper">'),e.b(`
|
|
220
|
+
`+i),e.b(' <table class="d2h-diff-table">'),e.b(`
|
|
221
|
+
`+i),e.b(' <tbody class="d2h-diff-tbody">'),e.b(`
|
|
222
|
+
`+i),e.b(" "),e.b(e.t(e.d("diffs.right",n,s,0))),e.b(`
|
|
223
|
+
`+i),e.b(" </tbody>"),e.b(`
|
|
224
|
+
`+i),e.b(" </table>"),e.b(`
|
|
225
|
+
`+i),e.b(" </div>"),e.b(`
|
|
226
|
+
`+i),e.b(" </div>"),e.b(`
|
|
227
|
+
`+i),e.b(" </div>"),e.b(`
|
|
228
|
+
`+i),e.b("</div>"),e.fl()},partials:{},subs:{}});re["tag-file-added"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<span class="d2h-tag d2h-added d2h-added-tag">ADDED</span>'),e.fl()},partials:{},subs:{}});re["tag-file-changed"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span>'),e.fl()},partials:{},subs:{}});re["tag-file-deleted"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span>'),e.fl()},partials:{},subs:{}});re["tag-file-renamed"]=new se.Template({code:function(n,s,i){var e=this;return e.b(i=i||""),e.b('<span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span>'),e.fl()},partials:{},subs:{}});class Ls{constructor({compiledTemplates:s={},rawTemplates:i={}}){const e=Object.entries(i).reduce((r,[l,a])=>{const o=se.compile(a,{asString:!1});return Object.assign(Object.assign({},r),{[l]:o})},{});this.preCompiledTemplates=Object.assign(Object.assign(Object.assign({},re),s),e)}static compile(s){return se.compile(s,{asString:!1})}render(s,i,e,r,l){const a=this.templateKey(s,i);try{return this.preCompiledTemplates[a].render(e,r,l)}catch{throw new Error(`Could not find template to render '${a}'`)}}template(s,i){return this.preCompiledTemplates[this.templateKey(s,i)]}templateKey(s,i){return`${s}-${i}`}}const Rs=Object.assign(Object.assign(Object.assign({},pn),gn),{outputFormat:rs.LINE_BY_LINE,drawFileList:!0});function Qe(n,s={}){const i=Object.assign(Object.assign({},Rs),s),e=typeof n=="string"?hs(n,i):n,r=new Ls(i),{colorScheme:l}=i,a={colorScheme:l},o=i.drawFileList?new Es(r,a).render(e):"",d=i.outputFormat==="side-by-side"?new $s(r,i).render(e):new Os(r,i).render(e);return o+d}function lt(n,s=""){if(n==null||typeof n!="object"||Array.isArray(n))return s?{[s]:n}:{};const i={};for(const[e,r]of Object.entries(n)){const l=s?`${s}.${e}`:e;r!=null&&typeof r=="object"&&!Array.isArray(r)?Object.assign(i,lt(r,l)):i[l]=r}return i}const qt={changed:0,added:1,deleted:2,same:3};function Fs(n,s,i){let e=n;if(i&&i.length>0){let d=n===void 0?"null":JSON.stringify(n,null,2);for(const{replace:u,with:c}of i)u&&(d=d.split(u).join(c));try{e=JSON.parse(d)}catch{}}const r=lt(e),l=lt(s),a=new Set([...Object.keys(r),...Object.keys(l)]),o=[];for(const d of a){const u=d in r,c=d in l,m=r[d],x=l[d];let f;u&&!c?f="added":!u&&c?f="deleted":JSON.stringify(m)!==JSON.stringify(x)?(x===""||x===null)&&m!==""&&m!==null?f="added":(m===""||m===null)&&x!==""&&x!==null?f="deleted":f="changed":f="same",o.push({path:d,status:f,originValue:m,targetValue:x})}return o.sort((d,u)=>{const c=qt[d.status]-qt[u.status];return c!==0?c:d.path.localeCompare(u.path)})}function Wt(n){return!!(n==null||typeof n=="string"&&n===""||Array.isArray(n)&&n.length===0)}function Bs(n){const s=n.split(".").pop()??"";return s==="id"||s.endsWith("Id")}function Ks(n,s){const i=new Set(n),e=new Set(s),r=[];for(const l of s)r.push({value:l,status:i.has(l)?"same":"removed"});for(const l of n)e.has(l)||r.push({value:l,status:"added"});return r}function zs(n){const s=n.some(r=>r.status==="added"),i=n.some(r=>r.status==="removed"),e=n.some(r=>r.status==="same");return!s&&!i?"same":s&&!i&&!e?"added":!s&&i&&!e?"deleted":"changed"}function Hs(n){const s=n.some(l=>l.status==="added"),i=n.some(l=>l.status==="deleted"),e=n.some(l=>l.status==="changed"),r=n.some(l=>l.status==="same");return!s&&!i&&!e?"same":s&&!i&&!e&&!r?"added":!s&&i&&!e&&!r?"deleted":"changed"}function ge(n){return n===void 0?"":JSON.stringify(n)}const qs=350;function Ws(n,s,i){const e=n==="changed"?typeof s=="string"||typeof i=="string":n==="deleted"?typeof i=="string":typeof s=="string",r=n==="changed"?Math.max(typeof s=="string"?s.length:0,typeof i=="string"?i.length:0):n==="deleted"?typeof i=="string"?i.length:0:typeof s=="string"?s.length:0;return{isString:e,maxLen:r,useModal:e&&r>=qs}}function Js({value:n,status:s}){const i=s==="added"?"bg-green-100 text-green-800 border-green-300 dark:bg-green-900/30 dark:text-green-300 dark:border-green-700":s==="removed"?"bg-red-100 text-red-800 border-red-300 dark:bg-red-900/30 dark:text-red-300 dark:border-red-700":"bg-muted text-muted-foreground border-border";return t.jsxs("span",{className:`inline-flex items-center gap-0.5 rounded-full border px-2 py-0.5 font-mono text-xs ${i}`,children:[s==="added"&&t.jsx(M.Plus,{size:10,"aria-hidden":!0}),s==="removed"&&t.jsx(M.Minus,{size:10,"aria-hidden":!0}),t.jsx("span",{className:s==="removed"?"line-through":void 0,children:n})]})}function Le({path:n,strikethrough:s}){return t.jsx(Ne.TooltipProvider,{children:t.jsxs(Ne.Tooltip,{children:[t.jsx(Ne.TooltipTrigger,{asChild:!0,children:t.jsx("span",{className:`w-36 shrink-0 truncate font-mono font-bold${s?" line-through":""}`,children:n})}),t.jsx(Ne.TooltipContent,{side:"top",children:t.jsx("span",{className:"font-mono",children:n})})]})})}function _s({entry:n}){const[s,i]=I.useState(!1),{path:e,status:r,originValue:l,targetValue:a}=n,o=Array.isArray(l)?l.filter(g=>typeof g=="string"):[],d=Array.isArray(a)?a.filter(g=>typeof g=="string"):[];let u;r==="added"?u=o.map(g=>({value:g,status:"added"})):r==="deleted"?u=d.map(g=>({value:g,status:"removed"})):r==="same"?u=o.map(g=>({value:g,status:"same"})):u=Ks(o,d);const c=u.filter(g=>g.status!=="same"),m=u.filter(g=>g.status==="same"),x=s?[...c,...m]:c,f=m.length>0,p=zs(u),N=p==="added"?"bg-green-50 dark:bg-green-900/20":p==="deleted"?"bg-red-50 dark:bg-red-900/20":p==="changed"?"bg-blue-50 dark:bg-blue-900/20":"",v=p==="added"?t.jsx(M.Plus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-green-600 dark:text-green-400"}):p==="deleted"?t.jsx(M.Minus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-600 dark:text-red-400"}):p==="changed"?t.jsx("span",{"aria-hidden":!0,className:"mt-0.5 shrink-0 text-blue-600 dark:text-blue-400",children:"Δ"}):t.jsx("span",{className:"w-3 shrink-0"});return t.jsxs("div",{className:`flex items-start gap-2 px-3 py-1.5 text-xs ${N}${f?" cursor-pointer":""}`,onClick:f?()=>i(g=>!g):void 0,children:[v,t.jsx(Le,{path:e}),t.jsxs("div",{className:"flex min-w-0 flex-1 flex-wrap gap-1",children:[x.map((g,T)=>t.jsx(Js,{value:g.value,status:g.status},`${g.value}-${T}`)),!s&&m.length>0&&t.jsxs("span",{className:"self-center text-muted-foreground",children:["+",m.length," unchanged tag",m.length!==1?"s":""]})]})]})}function Ke({open:n,onClose:s,path:i,status:e,originValue:r,targetValue:l}){const[a,o]=I.useState("inline"),d=I.useMemo(()=>e==="changed"&&typeof r=="string"&&typeof l=="string"?Qn(l,r):null,[e,r,l]);let u;if(d!=null&&a==="side-by-side"){const c=d.filter(x=>!x.added),m=d.filter(x=>!x.removed);u=t.jsxs("div",{className:"flex min-h-0 flex-1 divide-x overflow-auto",children:[t.jsx("div",{className:"min-w-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed",children:c.map((x,f)=>x.removed?t.jsx("span",{className:"bg-red-100 text-red-800 line-through dark:bg-red-900/30 dark:text-red-300",children:x.value},f):t.jsx("span",{children:x.value},f))})}),t.jsx("div",{className:"min-w-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed",children:m.map((x,f)=>x.added?t.jsx("span",{className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:x.value},f):t.jsx("span",{children:x.value},f))})})]})}else d!=null?u=t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed",children:d.map((c,m)=>c.removed?t.jsx("span",{className:"bg-red-100 text-red-800 line-through dark:bg-red-900/30 dark:text-red-300",children:c.value},m):c.added?t.jsx("span",{className:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",children:c.value},m):t.jsx("span",{children:c.value},m))})}):e==="added"?u=t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed text-green-800 dark:text-green-300",children:typeof r=="string"?r:ge(r)})}):e==="deleted"?u=t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed text-red-700 line-through dark:text-red-300",children:typeof l=="string"?l:ge(l)})}):e==="changed"?u=t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:t.jsxs("div",{className:"flex items-start gap-2 font-mono text-sm",children:[t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"mb-1 text-xs font-semibold text-muted-foreground",children:"Current"}),t.jsx("p",{className:"break-words leading-relaxed text-red-700 dark:text-red-300",children:ge(l)})]}),t.jsx(M.ArrowRight,{size:14,className:"mt-5 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"mb-1 text-xs font-semibold text-muted-foreground",children:"Incoming"}),t.jsx("p",{className:"break-words leading-relaxed text-green-700 dark:text-green-300",children:ge(r)})]})]})}):u=t.jsx("div",{className:"min-h-0 flex-1 overflow-auto p-4",children:t.jsx("p",{className:"break-words font-mono text-sm leading-relaxed",children:typeof r=="string"?r:ge(r)})});return t.jsx(L.Dialog,{open:n,onOpenChange:c=>{c||s()},children:t.jsxs(L.DialogContent,{className:"flex h-[80vh] max-w-3xl flex-col p-0",children:[t.jsxs("div",{className:"shrink-0 border-b",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 pr-10",children:[t.jsx(L.DialogTitle,{className:"font-mono text-sm font-medium",children:i}),d!=null&&t.jsxs("div",{className:"flex gap-1",children:[t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${a==="side-by-side"?"bg-muted":"text-muted-foreground"}`,title:"Side by side",onClick:()=>o("side-by-side"),children:t.jsx(M.Columns2,{size:14})}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${a==="inline"?"bg-muted":"text-muted-foreground"}`,title:"Inline diff",onClick:()=>o("inline"),children:t.jsx(M.AlignJustify,{size:14})})]})]}),d!=null&&t.jsxs("div",{className:"flex items-center gap-1 px-4 pb-2",children:[t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:["Target"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(current)"})]}),t.jsx(M.ArrowRight,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:["Origin"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(incoming)"})]})]})]}),u]})})}function Jt({entry:n}){const{path:s,status:i,originValue:e,targetValue:r}=n,[l,a]=I.useState(!1),[o,d]=I.useState(!1),[u,c]=I.useState(!1),m=I.useRef(null),x=I.useRef(null),{isString:f,useModal:p}=Ws(i,e,r);I.useLayoutEffect(()=>{if(!f)return;const T=m.current,S=x.current,D=T?T.scrollHeight>T.clientHeight:!1,y=S?S.scrollHeight>S.clientHeight:!1;c(D||y),a(!1)},[e,r,f]);const N=l||!f?"":"line-clamp-3",v=f&&(u||!p&&l)?()=>{!p&&l?a(!1):p?d(!0):a(!0)}:void 0,g=f&&(u&&!l||!p&&l)?t.jsx("span",{className:"mt-0.5 block text-xs text-muted-foreground",children:l?"see less":"see more"}):null;return s==="tags"&&(Array.isArray(e)||Array.isArray(r))?t.jsx(_s,{entry:n}):i==="same"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex items-start gap-2 px-3 py-1.5 text-xs text-muted-foreground${v?" cursor-pointer":""}`,onClick:v,children:[t.jsx("span",{className:"w-3 shrink-0"}),t.jsx(Le,{path:s}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{ref:m,className:`break-words font-mono${N?` ${N}`:""}`,children:ge(e)}),g]})]}),o&&t.jsx(Ke,{open:o,onClose:()=>d(!1),path:s,status:i,originValue:e,targetValue:r})]}):i==="added"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex items-start gap-2 bg-green-50 px-3 py-1.5 text-xs dark:bg-green-900/20${v?" cursor-pointer":""}`,onClick:v,children:[t.jsx(M.Plus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-green-600 dark:text-green-400"}),t.jsx(Le,{path:s}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{ref:m,className:`break-words font-mono text-green-800 dark:text-green-300${N?` ${N}`:""}`,children:ge(e)}),g]})]}),o&&t.jsx(Ke,{open:o,onClose:()=>d(!1),path:s,status:i,originValue:e,targetValue:r})]}):i==="deleted"?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex items-start gap-2 bg-red-50 px-3 py-1.5 text-xs dark:bg-red-900/20${v?" cursor-pointer":""}`,onClick:v,children:[t.jsx(M.Minus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-600 dark:text-red-400"}),t.jsx(Le,{path:s,strikethrough:!0}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{ref:m,className:`break-words font-mono text-red-700 line-through dark:text-red-300${N?` ${N}`:""}`,children:ge(r)}),g]})]}),o&&t.jsx(Ke,{open:o,onClose:()=>d(!1),path:s,status:i,originValue:e,targetValue:r})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex items-start gap-2 bg-blue-50 px-3 py-1.5 text-xs dark:bg-blue-900/20${v?" cursor-pointer":""}`,onClick:v,children:[t.jsx("span",{"aria-hidden":!0,className:"mt-0.5 shrink-0 text-blue-600 dark:text-blue-400",children:"Δ"}),t.jsx(Le,{path:s}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-start gap-1",children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{ref:m,className:`break-words font-mono text-red-700 dark:text-red-300${N?` ${N}`:""}`,children:ge(r)})}),t.jsx(M.ArrowRight,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-muted-foreground"}),t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("span",{ref:x,className:`break-words font-mono text-green-700 dark:text-green-300${N?` ${N}`:""}`,children:ge(e)})})]}),g]})]}),o&&t.jsx(Ke,{open:o,onClose:()=>d(!1),path:s,status:i,originValue:e,targetValue:r})]})}function Us({entries:n,originMetadata:s,targetMetadata:i,targetClusterName:e}){const[r,l]=I.useState(!1),[a,o]=I.useState("side-by-side"),d=I.useMemo(()=>{try{const x=JSON.stringify(i??null,null,2),f=JSON.stringify(s??null,null,2),p=Je("metadata.json",x,f,"Target (current)","Origin (incoming)");return Qe(p,{drawFileList:!1,matching:"lines",outputFormat:a})}catch{return null}},[s,i,a]),u=Hs(n),c=u==="added"?"bg-green-50 dark:bg-green-900/20":u==="deleted"?"bg-red-50 dark:bg-red-900/20":u==="changed"?"bg-blue-50 dark:bg-blue-900/20":"",m=u==="added"?t.jsx(M.Plus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-green-600 dark:text-green-400"}):u==="deleted"?t.jsx(M.Minus,{size:12,"aria-hidden":!0,className:"mt-0.5 shrink-0 text-red-600 dark:text-red-400"}):u==="changed"?t.jsx("span",{"aria-hidden":!0,className:"mt-0.5 shrink-0 text-blue-600 dark:text-blue-400",children:"Δ"}):t.jsx("span",{className:"w-3 shrink-0"});return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:`flex items-center gap-2 px-3 py-1.5 text-xs ${c}`,children:[m,t.jsx("span",{className:"w-36 shrink-0 truncate font-mono font-bold",children:"metadata"}),t.jsx("div",{className:"flex min-w-0 flex-1",children:t.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded border border-black/50 px-2 py-0.5 text-xs text-black/50 hover:bg-muted hover:text-foreground dark:border-white/60 dark:text-white/60",children:"View Changes"})})]}),t.jsx(L.Dialog,{open:r,onOpenChange:l,children:t.jsxs(L.DialogContent,{className:"flex h-[80vh] max-w-5xl flex-col p-0",children:[t.jsxs("div",{className:"shrink-0 border-b",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 pr-10",children:[t.jsx(L.DialogTitle,{className:"text-sm font-medium",children:"Metadata Changes"}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${a==="side-by-side"?"bg-muted":"text-muted-foreground"}`,title:"Side by side",onClick:()=>o("side-by-side"),children:t.jsx(M.Columns2,{size:14})}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${a==="line-by-line"?"bg-muted":"text-muted-foreground"}`,title:"Line by line",onClick:()=>o("line-by-line"),children:t.jsx(M.AlignJustify,{size:14})})]})]}),t.jsxs("div",{className:"flex items-center gap-1 px-4 pb-2",children:[t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:[e??"Target"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(current)"})]}),t.jsx(M.ArrowRight,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:["Origin"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(updates)"})]})]})]}),d!=null?t.jsx("div",{className:"diff2html-panel min-h-0 flex-1 overflow-auto p-3",dangerouslySetInnerHTML:{__html:d}}):t.jsx("div",{className:"flex flex-1 items-center justify-center p-3 text-xs text-muted-foreground",children:"Unable to render diff."})]})})]})}function Qs({entries:n,originMetadata:s,targetMetadata:i,targetClusterName:e}){const r=n.filter(c=>c.path.startsWith("metadata.")),l=n.filter(c=>!c.path.startsWith("metadata.")&&c.path!=="values"&&!(Wt(c.originValue)&&Wt(c.targetValue)));if(l.length===0&&r.length===0)return t.jsx("div",{className:"flex items-center justify-center p-6 text-xs text-muted-foreground",children:"No fields to display."});const a=l.filter(c=>c.status!=="same"),o=l.filter(c=>c.status==="same"),d=r.some(c=>c.status!=="same"),u=r.length>0?t.jsx(Us,{entries:r,originMetadata:s,targetMetadata:i,targetClusterName:e}):null;return t.jsxs("div",{className:"divide-y",children:[a.map(c=>t.jsx(Jt,{entry:c},c.path)),d?u:null,o.map(c=>t.jsx(Jt,{entry:c},c.path)),d?null:u]})}const _t={new:0,updated:1,removed:2,skip:3};function yn(n,s){return n!=null&&s==null?"new":n!=null&&s!=null?"updated":n==null&&s!=null?"removed":null}function Vs(n,s){var l,a;if(s.length<=1)return null;const i=(l=n.diff)==null?void 0:l.byTarget;if(i==null)return null;const e=(a=n.diff)==null?void 0:a.origin,r=new Map;for(const o of s){if(!(o in i))continue;const d=yn(e,i[o]);d!=null&&r.set(d,(r.get(d)??0)+1)}return r.size===0?null:[...r.entries()].map(([o,d])=>({status:o,count:d})).sort((o,d)=>_t[o.status]-_t[d.status])}function ze({title:n,values:s,excluded:i,editable:e,onToggle:r,formatLabel:l}){const[a,o]=I.useState(i.length>0);return I.useEffect(()=>{i.length>0&&o(!0)},[i.length]),t.jsxs("div",{className:"border-b p-2",children:[t.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-2",onClick:()=>o(d=>!d),"aria-expanded":a,children:[t.jsxs("span",{className:"flex items-center gap-1 text-xs font-medium text-muted-foreground",children:[a?t.jsx(M.ChevronDown,{size:12}):t.jsx(M.ChevronRight,{size:12}),n," (",i.length,")"]}),e?null:t.jsx("span",{className:"text-[10px] text-muted-foreground",children:"read-only"})]}),a?t.jsx("div",{className:"mt-1 flex flex-col gap-1",children:s.map(d=>{const u=!i.includes(d);return t.jsxs("label",{className:"flex items-start gap-2 text-xs",children:[t.jsx("input",{type:"checkbox",className:"mt-0.5 shrink-0",checked:u,disabled:!e,onChange:c=>r==null?void 0:r(d,c.target.checked)}),t.jsx("span",{className:`min-w-0 break-all font-mono ${u?"":"text-muted-foreground line-through"}`,children:l?l(d):d})]},d)})}):null]})}function vn({item:n,targets:s,onClose:i,unmetDependencyNames:e=[],tags:r=[],excludedTags:l=[],editable:a=!0,onToggleTag:o,metadataKeys:d=[],excludedMetadataKeys:u=[],onToggleMetadataKey:c,i18nPaths:m=[],excludedI18nPaths:x=[],onToggleI18nPath:f,permissionKeys:p=[],excludedPermissions:N=[],onTogglePermission:v,formatPermissionLabel:g,replacementMaps:T}){var z,C,R,O;const S=((z=s[0])==null?void 0:z.id)??null,[D,y]=I.useState(S),[A,q]=I.useState("info"),[h,j]=I.useState(!1),[k,B]=I.useState("side-by-side");I.useEffect(()=>{var U;y(((U=s[0])==null?void 0:U.id)??null),q("info")},[n==null?void 0:n.itemKey]);const $=s.find(U=>U.id===D)??s[0]??null,w=(C=n==null?void 0:n.diff)==null?void 0:C.byTarget,_=w!=null,F=_?w[($==null?void 0:$.id)??""]:(R=n==null?void 0:n.diff)==null?void 0:R.target,Z=_&&$!=null&&!($.id in w),ee=I.useMemo(()=>{var ae,le,oe;if(Z)return[];const U=(n==null?void 0:n.status)==="removed"&&F==null&&((ae=n==null?void 0:n.diff)==null?void 0:ae.origin)!=null,ne=U?null:(le=n==null?void 0:n.diff)==null?void 0:le.origin,Y=U?(oe=n==null?void 0:n.diff)==null?void 0:oe.origin:F;return Fs(ne,Y,T==null?void 0:T[($==null?void 0:$.id)??""]).filter(de=>!(Bs(de.path)||(n==null?void 0:n.itemType)==="blueprint"&&de.path==="attributes"))},[n,F,Z,T,$==null?void 0:$.id]),V=I.useMemo(()=>{var U;if(Z)return null;try{const ne=JSON.stringify(F??null,null,2),Y=JSON.stringify(((U=n==null?void 0:n.diff)==null?void 0:U.origin)??null,null,2),te=Je("data.json",ne,Y,"Target (current)","Origin (incoming)");return Qe(te,{drawFileList:!1,matching:"lines",outputFormat:"side-by-side"})}catch{return null}},[n,F,Z]),X=I.useMemo(()=>{var U;if(Z)return null;try{const ne=JSON.stringify(F??null,null,2),Y=JSON.stringify(((U=n==null?void 0:n.diff)==null?void 0:U.origin)??null,null,2),te=Je("data.json",ne,Y,"Target (current)","Origin (incoming)");return Qe(te,{drawFileList:!1,matching:"lines",outputFormat:k})}catch{return null}},[n,F,Z,k]);return n?t.jsxs("div",{className:"flex flex-col rounded-md border bg-background",children:[t.jsxs("div",{className:"sticky top-0 z-10 bg-background",children:[t.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate font-medium",children:n.itemName}),t.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:n.itemType})]}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Close",onClick:i,children:t.jsx(M.X,{})})]}),e.length>0?t.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:[t.jsx(M.AlertTriangle,{size:14,className:"mt-0.5 shrink-0 text-amber-600 dark:text-amber-400"}),t.jsxs("span",{children:["Depends on excluded items: ",e.join(", "),". Push will fail for this item until they're included."]})]}):null,r.length>0?t.jsx(ze,{title:"Tag Overrides",values:r,excluded:l,editable:a,onToggle:o}):null,d.length>0?t.jsx(ze,{title:"Metadata Overrides",values:d,excluded:u,editable:a,onToggle:c}):null,m.length>0?t.jsx(ze,{title:"Translation Overrides",values:m,excluded:x,editable:a,onToggle:f}):null,p.length>0?t.jsx(ze,{title:"Permission Overrides",values:p,excluded:N,editable:a,onToggle:v,formatLabel:g}):null,s.length>0?t.jsx("div",{className:"flex flex-wrap gap-1 border-b p-2",children:s.map(U=>{const ne=_&&!(U.id in w);return t.jsxs("button",{type:"button",onClick:()=>y(U.id),className:`inline-flex items-center gap-1 rounded px-2 py-1 text-xs ${U.id===($==null?void 0:$.id)?"bg-muted font-medium":"hover:bg-muted/50"}`,children:[ne?null:(()=>{var te;const Y=_?yn((te=n.diff)==null?void 0:te.origin,w[U.id]):n.status;return Y==="new"?t.jsx(M.Plus,{size:12,className:"shrink-0 text-green-500","aria-hidden":!0}):Y==="updated"?t.jsx(M.AlertTriangle,{size:12,className:"shrink-0 text-blue-500","aria-hidden":!0}):Y==="removed"?t.jsx(M.AlertTriangle,{size:12,className:"shrink-0 text-red-500","aria-hidden":!0}):null})(),U.name]},U.id)})}):null,t.jsxs("div",{className:"flex gap-1 border-b px-2 pb-1 pt-1.5",children:[t.jsx("button",{type:"button",onClick:()=>q("info"),className:`rounded px-2 py-1 text-xs ${A==="info"?"bg-muted font-medium":"hover:bg-muted/50"}`,children:"Info"}),t.jsx("button",{type:"button",onClick:()=>q("json-diff"),className:`rounded px-2 py-1 text-xs ${A==="json-diff"?"bg-muted font-medium":"hover:bg-muted/50"}`,children:"JSON"})]})]}),A==="info"?Z?t.jsxs("div",{className:"flex items-center justify-center p-3 text-xs text-muted-foreground",children:["Matches ",$==null?void 0:$.name," — no differences."]}):t.jsx(Qs,{entries:ee,originMetadata:((O=n==null?void 0:n.diff)==null?void 0:O.origin)!=null&&typeof n.diff.origin=="object"&&!Array.isArray(n.diff.origin)?n.diff.origin.metadata:void 0,targetMetadata:F!=null&&typeof F=="object"&&!Array.isArray(F)?F.metadata:void 0,targetClusterName:$==null?void 0:$.name},n==null?void 0:n.itemKey):Z?t.jsxs("div",{className:"flex items-center justify-center p-3 text-xs text-muted-foreground",children:["Matches ",$==null?void 0:$.name," — no differences."]}):V!=null?t.jsxs("div",{className:"flex flex-col",children:[t.jsxs("div",{className:"flex shrink-0 items-center gap-1 border-b px-2 py-1",children:[t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:[($==null?void 0:$.name)??"Target"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(current)"})]}),t.jsx(M.ArrowRight,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:["Origin"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(updates)"})]}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:"ml-1 h-6 w-6 shrink-0 text-muted-foreground",title:"Expand diff",onClick:()=>j(!0),children:t.jsx(M.Maximize2,{size:12})})]}),t.jsx("div",{className:"diff2html-panel diff2html-panel-compact p-2",dangerouslySetInnerHTML:{__html:V}}),t.jsx(L.Dialog,{open:h,onOpenChange:j,children:t.jsxs(L.DialogContent,{className:"flex h-[80vh] max-w-5xl flex-col p-0",children:[t.jsxs("div",{className:"shrink-0 border-b",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 pr-10",children:[t.jsxs(L.DialogTitle,{className:"text-sm font-medium",children:[n.itemName," — JSON Diff"]}),t.jsxs("div",{className:"flex gap-1",children:[t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${k==="side-by-side"?"bg-muted":"text-muted-foreground"}`,title:"Side by side",onClick:()=>B("side-by-side"),children:t.jsx(M.Columns2,{size:14})}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${k==="line-by-line"?"bg-muted":"text-muted-foreground"}`,title:"Line by line",onClick:()=>B("line-by-line"),children:t.jsx(M.AlignJustify,{size:14})})]})]}),t.jsxs("div",{className:"flex items-center gap-1 px-4 pb-2",children:[t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:[($==null?void 0:$.name)??"Target"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(current)"})]}),t.jsx(M.ArrowRight,{size:12,className:"shrink-0 text-muted-foreground"}),t.jsxs("span",{className:"flex-1 truncate text-xs font-medium",children:["Origin"," ",t.jsx("span",{className:"font-normal text-muted-foreground",children:"(updates)"})]})]})]}),t.jsx("div",{className:"diff2html-panel min-h-0 flex-1 overflow-auto p-3",dangerouslySetInnerHTML:{__html:X??""}})]})})]}):t.jsx("div",{className:"flex items-center justify-center p-3 text-xs text-muted-foreground",children:"Unable to render diff."})]}):null}const Ut=["blueprint","system","network","enum","resourceEnum","timer","messageRoute","role","permission","module","scenario","template","project","rule","script"];function Ve(n){const s=Ut.indexOf(n);return s===-1?Ut.length:s}function ot(n,s){const i=Ve(n)-Ve(s);return i!==0?i:n.localeCompare(s)}const We={create:"text-emerald-600",update:"text-amber-600",remove:"text-destructive"};function Qt(n){const s=n.indexOf(":");return s>=0?{type:n.slice(0,s),name:n.slice(s+1)}:{type:"",name:n}}function Gs(n){const s=new Map,i=(e,r,l)=>{let a=s.get(e);return a||(a={key:e,type:r,name:l,children:[]},s.set(e,a)),a};for(const e of n)if(e.parentKey){const r=Qt(e.parentKey);i(e.parentKey,r.type,r.name).children.push(e)}else{const r=i(e.itemKey,e.itemType,e.itemName||Qt(e.itemKey).name);r.type=e.itemType,r.name=e.itemName||r.name,r.self=e}return[...s.values()].sort((e,r)=>Ve(e.type)-Ve(r.type)||e.name.localeCompare(r.name))}function Xs(n,s,i,e){const{fetchJson:r}=E.useImaginariumApi();return Q.useQuery({queryKey:["imaginarium","release-push-preview",n,s],queryFn:()=>r(`${i}/${n}/push-preview`,{method:"POST",body:JSON.stringify({destConfigIds:s})}),enabled:e,staleTime:1/0,gcTime:0})}function Ys({summary:n}){return t.jsxs("span",{className:"text-xs",children:[t.jsxs("span",{className:We.create,children:[n.create," create"]})," · ",t.jsxs("span",{className:We.update,children:[n.update," update"]})," · ",t.jsxs("span",{className:We.remove,children:[n.remove," remove"]})]})}function Vt({action:n}){return t.jsx("span",{className:`font-mono text-xs uppercase ${We[n]??""}`,children:n})}function Zs(){return t.jsx("span",{className:"font-mono text-xs uppercase text-muted-foreground",children:"no_update"})}function ei({preview:n,loading:s,error:i,onSelectItem:e}){if(s)return t.jsxs("p",{className:"mt-1 inline-flex items-center gap-1 text-xs text-muted-foreground",children:[t.jsx(M.Loader2,{className:"h-3 w-3 animate-spin"})," Computing changes…"]});if(n!=null&&n.error)return t.jsxs("p",{className:"mt-1 text-xs text-destructive",children:["Couldn’t compute changes: ",n.error]});if(i&&!n)return t.jsx("p",{className:"mt-1 text-xs text-destructive",children:"Couldn’t compute changes for this target."});if(!n||!n.summary)return null;if(n.summary.total===0)return t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"No changes — already up to date."});const r=Gs(n.items??[]);return t.jsxs("div",{className:"mt-1",children:[t.jsx(Ys,{summary:n.summary}),t.jsx("div",{className:"mt-2 max-h-[55vh] space-y-3 overflow-auto border-t pt-2",children:r.map(l=>t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-baseline gap-2",children:[l.self?t.jsx(Vt,{action:l.self.action}):t.jsx(Zs,{}),l.self&&e?t.jsx("button",{type:"button",className:"text-sm font-medium hover:underline",onClick:()=>e(l.self),children:l.name}):t.jsx("span",{className:"text-sm font-medium",children:l.name}),t.jsx("span",{className:"text-xs text-muted-foreground",children:l.type})]}),l.children.length>0?t.jsx("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-3",children:l.children.map((a,o)=>t.jsxs("li",{className:"text-xs",children:[t.jsx(Vt,{action:a.action})," ",e?t.jsx("button",{type:"button",className:"hover:underline",onClick:()=>e(a),children:a.itemName||a.itemKey}):t.jsx("span",{children:a.itemName||a.itemKey}),a.itemType!=="attribute"?t.jsxs("span",{className:"text-muted-foreground",children:[" (",a.itemType,")"]}):null]},`${a.itemKey}-${o}`))}):null]},l.key))})]})}function jn({releaseId:n,destConfigId:s,name:i,apiPath:e="/releases",onSelectItem:r,headerRight:l,footer:a,defaultOpen:o=!1}){var f,p,N,v;const[d,u]=I.useState(o),c=I.useMemo(()=>[s],[s]),m=Xs(n,c,e,d),x=((p=(f=m.data)==null?void 0:f.previews)==null?void 0:p.find(g=>g.destConfigId===s))??((v=(N=m.data)==null?void 0:N.previews)==null?void 0:v[0]);return t.jsxs("div",{className:"rounded border",children:[t.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-1 text-sm font-medium",onClick:()=>u(g=>!g),children:[d?t.jsx(M.ChevronDown,{className:"h-4 w-4 shrink-0"}):t.jsx(M.ChevronRight,{className:"h-4 w-4 shrink-0"}),t.jsx("span",{className:"truncate",children:i})]}),l]}),d?t.jsxs("div",{className:"border-t px-3 py-2",children:[t.jsx(ei,{preview:x,loading:m.isFetching,error:m.isError,onSelectItem:r}),a]}):null]})}function ti({state:n}){switch(n.status){case"pushing":return t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-muted-foreground",children:[t.jsx(M.Loader2,{className:"h-4 w-4 animate-spin"}),"Pushing…"]});case"success":return t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-emerald-600",children:[t.jsx(M.Check,{className:"h-4 w-4"}),"Success"]});case"partial":return t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-amber-600",children:[t.jsx(M.AlertTriangle,{className:"h-4 w-4"}),"Partial — ",n.failed??0," failed"]});case"failed":return t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-destructive",title:n.error,children:[t.jsx(M.X,{className:"h-4 w-4"}),"Failed"]});default:return t.jsxs("span",{className:"inline-flex items-center gap-1 text-sm text-muted-foreground",children:[t.jsx(M.Circle,{className:"h-3 w-3"}),"Pending"]})}}function Nn({open:n,onOpenChange:s,releaseId:i,targetConfigIds:e,targetNames:r,apiPath:l="/releases",onComplete:a,dependencyWarnings:o=[]}){const{toast:d}=E.useToast(),{fetchJson:u}=E.useImaginariumApi(),c=Q.useQueryClient(),[m,x]=I.useState(!1),[f,p]=I.useState({}),[N,v]=I.useState(!1),g=y=>(r==null?void 0:r[y])??y,T=(y,A)=>p(q=>({...q,[y]:A})),S=async()=>{x(!0),v(!1),p(Object.fromEntries(e.map(q=>[q,{status:"idle"}])));let y=0,A=0;for(const q of e){T(q,{status:"pushing"});try{const h=await u(`${l}/${i}/push`,{method:"POST",body:JSON.stringify({destConfigId:q})}),j=(h.results??[]).filter(k=>!k.ok);h.status==="success"?(y+=1,T(q,{status:"success"})):h.status==="partial"?(A+=1,T(q,{status:"partial",failed:j.length,failures:j})):(A+=1,T(q,{status:"failed",failures:j}))}catch(h){A+=1;const j=h instanceof Error?h.message:String(h);T(q,{status:"failed",error:j})}}c.invalidateQueries({queryKey:["imaginarium","releases"]}),c.invalidateQueries({queryKey:["imaginarium","release",i]}),c.invalidateQueries({queryKey:["imaginarium","release-items",i]}),c.invalidateQueries({queryKey:["imaginarium","release-pushes",i]}),c.invalidateQueries({queryKey:["imaginarium","release-push-preview",i]}),d(A===0?{title:"Push complete",description:`Pushed to ${y} target${y===1?"":"s"}.`}:{title:"Push finished with errors",description:`${A} target${A===1?"":"s"} did not fully succeed.`,variant:"destructive"}),x(!1),v(!0),a==null||a()},D=y=>{m||(y||(p({}),v(!1)),s(y))};return t.jsx(L.Dialog,{open:n,onOpenChange:D,children:t.jsxs(L.DialogContent,{className:"max-w-2xl",children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:"Push release"}),t.jsx(L.DialogDescription,{children:"Pushes the included items to each target cluster, one at a time. Each target re-compares against the latest origin before applying."})]}),o.length>0?t.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:[t.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[t.jsx(M.AlertTriangle,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),o.length," item",o.length===1?"":"s"," reference excluded dependencies"]}),t.jsx("ul",{className:"list-disc space-y-0.5 pl-8",children:o.map(y=>t.jsxs("li",{children:[y.itemName," → ",y.missing.join(", ")]},y.itemName))}),t.jsx("p",{className:"pl-8 text-amber-600",children:"Push may fail for these items. You can proceed anyway."})]}):null,t.jsx("div",{className:"max-h-[60vh] space-y-2 overflow-y-auto py-2",children:e.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"This release has no targets."}):e.map(y=>{const A=f[y]??{status:"idle"},q=A.failures??[];return t.jsx(jn,{releaseId:i,destConfigId:y,name:g(y),apiPath:l,headerRight:t.jsx(ti,{state:A}),footer:q.length>0?t.jsx("ul",{className:"mt-2 max-h-48 space-y-1 overflow-auto border-t pt-2 text-xs",children:q.map((h,j)=>t.jsxs("li",{className:"text-destructive",children:[t.jsxs("span",{className:"font-mono",children:[h.action?`${h.action} `:"",h.itemKey??"item"]}),h.error?t.jsxs("span",{className:"text-muted-foreground",children:[" — ",h.error]}):null]},`${h.itemKey??"item"}-${j}`))}):null},y)})}),t.jsxs(L.DialogFooter,{children:[t.jsx(E.Button,{variant:"outline",onClick:()=>D(!1),disabled:m,children:"Close"}),t.jsxs(E.Button,{variant:"destructive",onClick:S,disabled:m||N||e.length===0,children:[t.jsx(M.Send,{className:"w-4 h-4 mr-2"}),m?"Pushing…":"Confirm push"]})]})]})})}function vt({item:n,onClose:s}){const[i,e]=I.useState("side-by-side"),r=I.useMemo(()=>{var l,a;try{const o=JSON.stringify(((l=n==null?void 0:n.diff)==null?void 0:l.target)??null,null,2),d=JSON.stringify(((a=n==null?void 0:n.diff)==null?void 0:a.origin)??null,null,2),u=Je("data.json",o,d,"Target (current)","Origin (incoming)");return Qe(u,{drawFileList:!1,matching:"lines",outputFormat:i})}catch{return null}},[n,i]);return n?t.jsxs("div",{className:"flex h-full min-w-0 flex-col rounded-md border bg-background",children:[t.jsxs("div",{className:"flex items-center justify-between border-b p-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"truncate font-medium",children:n.itemName}),t.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:n.itemType})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${i==="side-by-side"?"bg-muted":"text-muted-foreground"}`,title:"Side by side",onClick:()=>e("side-by-side"),children:t.jsx(M.Columns2,{size:14})}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:`h-7 w-7 ${i==="line-by-line"?"bg-muted":"text-muted-foreground"}`,title:"Line by line",onClick:()=>e("line-by-line"),children:t.jsx(M.AlignJustify,{size:14})}),t.jsx(E.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",title:"Close",onClick:s,children:t.jsx(M.X,{})})]})]}),r?t.jsx("div",{className:"diff2html-panel min-h-0 flex-1 overflow-auto p-3",dangerouslySetInnerHTML:{__html:r}}):t.jsx("div",{className:"flex flex-1 items-center justify-center p-3 text-xs text-muted-foreground",children:"Unable to render diff."})]}):null}function ni(n){return{itemName:n.itemName,itemType:n.itemType,diff:{origin:n.origin,target:n.target}}}function si({open:n,onOpenChange:s,releaseId:i,targetConfigIds:e,targetNames:r,apiPath:l="/releases",dependencyWarnings:a=[]}){const[o,d]=I.useState(null),u=m=>(r==null?void 0:r[m])??m,c=m=>{m||d(null),s(m)};return t.jsx(L.Dialog,{open:n,onOpenChange:c,children:t.jsxs(L.DialogContent,{className:"max-w-4xl",children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:"Changes to push"}),t.jsx(L.DialogDescription,{children:"Expand a target to compute and see exactly what it would receive, from a dry run of the push. Nothing is applied."})]}),!o&&a.length>0?t.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:[t.jsxs("div",{className:"flex items-center gap-2 font-medium",children:[t.jsx(M.AlertTriangle,{className:"h-4 w-4 shrink-0 text-amber-600 dark:text-amber-400"}),a.length," item",a.length===1?"":"s"," reference excluded dependencies"]}),t.jsx("ul",{className:"list-disc space-y-0.5 pl-8",children:a.map(m=>t.jsxs("li",{children:[m.itemName," → ",m.missing.join(", ")]},m.itemName))}),t.jsx("p",{className:"pl-8 text-amber-600",children:"Push may fail for these items until this is resolved."})]}):null,t.jsx("div",{className:o?"hidden":"min-w-0 max-h-[70vh] space-y-2 overflow-y-auto py-2",children:e.length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"This release has no targets."}):e.map(m=>t.jsx(jn,{releaseId:i,destConfigId:m,name:u(m),apiPath:l,onSelectItem:d},m))}),o?t.jsxs("div",{className:"min-w-0 space-y-2",children:[t.jsxs(E.Button,{variant:"ghost",size:"sm",onClick:()=>d(null),children:[t.jsx(M.ArrowLeft,{})," Back to changes"]}),t.jsx("div",{className:"h-[60vh] min-w-0",children:t.jsx(vt,{item:ni(o),onClose:()=>d(null)})})]}):null,t.jsx(L.DialogFooter,{children:t.jsx(E.Button,{variant:"outline",onClick:()=>c(!1),children:"Close"})})]})})}function ii({source:n,action:s,affected:i,onUndo:e,onIgnore:r,onConfirm:l}){const a=s==="exclude",o=i.length;return t.jsx(L.Dialog,{open:!!n,onOpenChange:d=>{d||r()},children:t.jsxs(L.DialogContent,{children:[t.jsxs(L.DialogHeader,{children:[t.jsxs(L.DialogTitle,{children:[t.jsx(M.AlertTriangle,{className:"inline w-4 h-4 mr-2 text-amber-600"}),a?"Exclude dependent items too?":"Include dependencies too?"]}),t.jsx(L.DialogDescription,{children:a?t.jsxs(t.Fragment,{children:[o," item",o===1?"":"s"," ",o===1?"depends":"depend",' on "',n==null?void 0:n.itemName,'" and would fail to push if left included.']}):t.jsxs(t.Fragment,{children:['"',n==null?void 0:n.itemName,'" depends on ',o," item",o===1?"":"s"," still excluded — the push will fail unless ",o===1?"it is":"they are"," included too."]})})]}),t.jsx("div",{className:"max-h-64 overflow-y-auto rounded-md border border-input p-2 text-sm",children:i.map(d=>t.jsxs("div",{className:"flex items-center gap-2 py-1",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:d.itemType}),t.jsx("span",{children:d.itemName})]},d.itemKey))}),t.jsxs(L.DialogFooter,{className:"flex-col sm:flex-col sm:items-start sm:space-x-0 gap-4",children:[t.jsx(E.Button,{variant:"ghost",onClick:r,title:a?"Leave these items included — they'll show their own warning until this one is included again":"Leave this item included — it will keep showing a warning until the excluded items are included too",className:"self-start px-0 text-red-600 hover:bg-transparent hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:a?"Ignore warning, leave them included":"Ignore warning, leave them excluded"}),t.jsxs("div",{className:"flex w-full flex-wrap justify-end gap-2",children:[t.jsx(E.Button,{variant:"outline",onClick:e,children:a?"Undo exclusion":"Undo inclusion"}),t.jsx(E.Button,{onClick:l,children:a?o===1?"Yes, exclude this one too":`Yes, exclude these ${o} too`:o===1?"Yes, include this one too":`Yes, include these ${o} too`})]})]})]})})}function ri(n){var s;return(((s=n.diff)==null?void 0:s.versions)??[]).filter(i=>!i.existsOnTarget)}function ai({item:n,disabled:s,onChange:i}){var r;const e=((r=n.diff)==null?void 0:r.versions)??[];return t.jsxs("select",{value:n.selectedVersion??"",disabled:s,onClick:l=>l.stopPropagation(),onChange:l=>i(l.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:[t.jsx("option",{value:"",disabled:!0,children:"Select a version"}),e.map(l=>{const a=String(l.version),o=l.existsOnTarget?`v${l.version} — already on target`:`v${l.version}${l.isPublished?" (published)":""}`;return t.jsx("option",{value:a,disabled:l.existsOnTarget,children:o},a)})]})}const li={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",value:"bg-orange-100 text-orange-800 dark:bg-orange-500/15 dark:text-orange-300",project:"bg-fuchsia-50 text-fuchsia-800 dark:bg-fuchsia-500/15 dark:text-fuchsia-300"};function Se({type:n}){const s=n==="enumValue"?"value":n,i=li[s]??"bg-muted text-muted-foreground";return t.jsx("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-semibold ${i}`,children:s})}function dt({checked:n,onChange:s,disabled:i=!1}){return t.jsxs("label",{className:`relative inline-block h-[18px] w-8 shrink-0 ${i?"cursor-not-allowed opacity-40":"cursor-pointer"}`,children:[t.jsx("input",{type:"checkbox",className:"peer sr-only",checked:n,disabled:i,onChange:e=>s(e.target.checked)}),t.jsx("span",{className:"absolute inset-0 rounded-full bg-input transition-colors peer-checked:bg-primary"}),t.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"})]})}const oi=/\b([A-Z]{2,}-\d+)\b/g;function di(n){const s=[];let i=0;for(const e of n.matchAll(oi))e.index>i&&s.push(n.slice(i,e.index)),s.push(t.jsx("a",{href:`https://leverege.atlassian.net/browse/${e[1]}`,target:"_blank",rel:"noreferrer",className:"text-primary underline underline-offset-2",onClick:r=>r.stopPropagation(),children:e[1]},e.index)),i=e.index+e[0].length;return i<n.length&&s.push(n.slice(i)),s.length>0?t.jsx(t.Fragment,{children:s}):n}function wn(n){const s=new Map;for(const e of n){const r=s.get(e.destConfigId);(!r||e.createdAt>r.createdAt)&&s.set(e.destConfigId,e)}const i=new Map;for(const e of s.values())for(const r of e.results??[]){if(!r.itemKey)continue;let l=i.get(r.itemKey);l||(l=new Map,i.set(r.itemKey,l)),l.set(e.destConfigId,{ok:r.ok,error:r.error})}return i}function Cn(n,s,i){var e;return(e=n.get(s))==null?void 0:e.get(i)}function ci(n,s){return n.filter(i=>!(s.type!=="all"&&i.itemType!==s.type||s.included==="enabled"&&(!i.included||i.ignored)||s.included==="disabled"&&i.included&&!i.ignored))}function Tn(n){const s={};for(const i of n)s[i.itemType]=(s[i.itemType]??0)+1;return s}function ui(n){const s=n.indexOf(":"),i=s>=0?n.slice(0,s):n,e=s>=0?n.slice(s+1):n;return{id:"",releaseId:"",itemKey:n,itemType:i,itemName:e,parentKey:null,selectedVersion:null,status:"updated",included:!0,carriedOver:!1,ignored:!1,diff:null,createdAt:"",updatedAt:""}}function kn(n){var l;const s=new Set(n.filter(a=>!a.parentKey).map(a=>a.itemKey)),i=[],e=new Map;for(const a of n){if(a.parentKey)continue;const o={item:a,children:[]};i.push(o),e.set(a.itemKey,o)}const r=new Map;for(const a of n){if(!a.parentKey)continue;if(s.has(a.parentKey)){(l=e.get(a.parentKey))==null||l.children.push(a);continue}let o=r.get(a.parentKey);o||(o={item:ui(a.parentKey),children:[],synthetic:!0},r.set(a.parentKey,o),i.push(o)),o.children.push(a)}for(const a of i)a.children.sort((o,d)=>o.itemName.localeCompare(d.itemName));return i}function mi(n){const s=n.indexOf(":"),i=s>=0?n.slice(0,s):n,e=s>=0?n.slice(s+1):n;return{itemKey:n,itemType:i,itemName:e,parentKey:null,cells:{}}}function Sn(n){var l;const s=new Set(n.filter(a=>!a.parentKey).map(a=>a.itemKey)),i=[],e=new Map;for(const a of n){if(a.parentKey)continue;const o={row:a,children:[]};i.push(o),e.set(a.itemKey,o)}const r=new Map;for(const a of n){if(!a.parentKey)continue;if(s.has(a.parentKey)){(l=e.get(a.parentKey))==null||l.children.push(a);continue}let o=r.get(a.parentKey);o||(o={row:mi(a.parentKey),children:[],synthetic:!0},r.set(a.parentKey,o),i.push(o)),o.children.push(a)}return i}function En(n){let s=0;for(const i of n.children)i.included&&!i.ignored&&(s+=1);return{included:s,total:n.children.length}}function Pn(n){var a,o,d,u;const s=[],i=new Map,e=new Map;for(const c of n){if(e.set(c.itemKey,c.parentKey),c.status!=="new"&&c.status!=="skip")continue;const m=(a=c.diff)==null?void 0:a.origin,x=m==null?void 0:m.id;if(typeof x=="string"&&x&&s.push({token:x,depKey:c.itemKey}),c.itemType==="enum"){const f=m==null?void 0:m.type;typeof f=="string"&&f&&s.push({token:f,depKey:c.itemKey})}if(c.itemType==="attribute"&&((o=c.parentKey)!=null&&o.startsWith("blueprint:"))){const f=c.parentKey.slice(10);let p=i.get(f);p||(p=new Map,i.set(f,p)),p.set(c.itemName,c.itemKey)}}const r=fi(s),l=new Map;for(const c of n){const m=JSON.stringify(((d=c.diff)==null?void 0:d.origin)??null),x=hi(r,m);c.itemType==="rule"&&i.size>0&&ct((u=c.diff)==null?void 0:u.origin,i,x),x.delete(c.itemKey);for(const f of x)e.get(f)===c.itemKey&&x.delete(f);l.set(c.itemKey,x)}return l}function ct(n,s,i){var a;if(Array.isArray(n)){for(const o of n)ct(o,s,i);return}if(n===null||typeof n!="object")return;const e=n,r=e.valueKey,l=(a=e.metadata)==null?void 0:a.blueprint;if(typeof r=="string"&&r&&typeof l=="string"&&l){const o=s.get(l);if(o){const d=r.startsWith("data/")?r.slice(5):r,u=d.slice(d.lastIndexOf("/")+1),c=o.get(d)??o.get(u);c&&i.add(c)}}for(const o of Object.keys(e))ct(e[o],s,i)}function fi(n){const s={children:new Map,fail:null,output:new Set};for(const{token:e,depKey:r}of n){let l=s;for(const a of e){let o=l.children.get(a);o||(o={children:new Map,fail:null,output:new Set},l.children.set(a,o)),l=o}l.output.add(r)}const i=[];for(const e of s.children.values())e.fail=s,i.push(e);for(;i.length>0;){const e=i.shift();for(const[r,l]of e.children){let a=e.fail;for(;a&&!a.children.has(r);)a=a.fail;l.fail=a?a.children.get(r):s;for(const o of l.fail.output)l.output.add(o);i.push(l)}}return s}function hi(n,s){const i=new Set;let e=n;for(const r of s){for(;e!==n&&!e.children.has(r);)e=e.fail;e=e.children.get(r)??n;for(const l of e.output)i.add(l)}return i}function pi(n){const s=new Map,i=e=>{let r=s.get(e);return r||(r=new Set,s.set(e,r)),r};for(const[e,r]of n){i(e);for(const l of r)i(l).add(e)}return s}function gi(n,s){const i=new Set([n]),e=[n],r=new Set;for(;e.length>0;){const l=e.shift();for(const a of s.get(l)??[])i.has(a)||(i.add(a),r.add(a),e.push(a))}return r}function Ce(n,s,i){const e=s.get(n.itemKey);if(!e||e.size===0)return[];const r=[];for(const l of e){const a=i.get(l);a&&(a.status!=="new"&&a.status!=="skip"||a.status==="new"&&a.included&&!a.ignored||r.push(a))}return r}function xi(n){return n.tags+n.metadataKeys+n.i18nPaths+n.permissions}function bi(n){const s=[];return n.tags>0&&s.push(`${n.tags} tag${n.tags===1?"":"s"}`),n.metadataKeys>0&&s.push(`${n.metadataKeys} metadata key${n.metadataKeys===1?"":"s"}`),n.i18nPaths>0&&s.push(`${n.i18nPaths} translation${n.i18nPaths===1?"":"s"}`),n.permissions>0&&s.push(`${n.permissions} permission${n.permissions===1?"":"s"}`),s.length===0?"":`${s.join(", ")} excluded from push`}function He(n){if(n==null||typeof n!="object"||Array.isArray(n))return[];const s=n;return Array.isArray(s.values)?s.values.filter(i=>i!=null&&typeof i=="object"&&!Array.isArray(i)&&typeof i.value=="string"):[]}function yi(n){if(n.diff==null)return[];const s=He(n.diff.origin),i=He(n.diff.target),e=n.diff.byTarget??null,r=new Set(s.map(a=>a.value));if(e)for(const a of Object.values(e))for(const o of He(a))r.add(o.value);else for(const a of i)r.add(a.value);const l=[];for(const a of r){const o=s.find(p=>p.value===a)??null,d=i.find(p=>p.value===a)??null,u=e?Object.fromEntries(Object.entries(e).map(([p,N])=>[p,He(N).find(v=>v.value===a)??null])):null,c=o!=null,m=u?Object.values(u):[d],x=m.some(p=>p!=null);let f;if(!c)f="removed";else if(!x)f="new";else{const p=JSON.stringify(o);f=m.every(v=>v!=null&&JSON.stringify(v)===p)?"skip":"updated"}f!=="skip"&&l.push({id:"",releaseId:n.releaseId,itemKey:`${n.itemKey}::${a}`,itemType:"value",itemName:a,parentKey:n.itemKey,selectedVersion:null,status:f,included:!0,carriedOver:!1,ignored:!1,diff:{origin:o,target:d,byTarget:u},createdAt:n.createdAt,updatedAt:n.updatedAt})}return l}const vi=[{value:"all",label:"All"},{value:"enabled",label:"Enabled"},{value:"disabled",label:"Disabled"}];function tt(n,s){return s==="all"?!0:s==="enabled"?n.included&&!n.ignored:!n.included||n.ignored}function Gt({status:n,count:s}){const i=n==="new"?"bg-green-50 text-green-700 border-green-200 dark:bg-green-900/20 dark:text-green-300 dark:border-green-800":n==="updated"?"bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-900/20 dark:text-blue-300 dark:border-blue-800":n==="removed"?"bg-red-50 text-red-700 border-red-200 dark:bg-red-900/20 dark:text-red-300 dark:border-red-800":"bg-muted text-muted-foreground border-border";return t.jsxs("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium border ${i}`,children:[n,s!==void 0?` (${s})`:""]})}function Xt({item:n,targetConfigIds:s}){const i=Vs(n,s);return i?t.jsx("div",{className:"flex flex-wrap gap-1",children:i.map(({status:e,count:r})=>t.jsx(Gt,{status:e,count:r},e))}):t.jsx(Gt,{status:n.status})}function ue(n){if(Array.isArray(n))return n.filter(s=>typeof s=="string");if(typeof n=="string"&&n.length>0)try{const s=JSON.parse(n);return Array.isArray(s)?s.filter(i=>typeof i=="string"):[]}catch{return[]}return[]}function Yt({item:n}){const s={tags:ue(n.excludedTags).length,metadataKeys:ue(n.excludedMetadataKeys).length,i18nPaths:ue(n.excludedI18nPaths).length,permissions:ue(n.excludedPermissions).length},i=xi(s);return i<=0?null:t.jsxs("span",{title:bi(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:[i," manual override",i===1?"":"s"]})}function Zt({item:n,targetConfigIds:s,results:i,pushedDests:e,displayName:r}){const l=n.included&&!n.ignored,a=s.filter(o=>e.has(o)).map(o=>({id:o,result:Cn(i,n.itemKey,o)})).filter(o=>o.result!=null||l);return a.length===0?null:t.jsx("div",{className:"flex flex-wrap justify-end gap-1",children:a.map(({id:o,result:d})=>{const u=d?d.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",c=d?d.ok?"✓":"✗":"=",m=d?d.ok?void 0:d.error:"No change — already in sync";return t.jsxs("span",{title:m,className:`inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px] font-semibold ${u}`,children:[r(o)," ",c]},o)})})}function Dn({releaseId:n,onBack:s}){var Ct,Tt,kt;const i=Ge.Config.get("Release","apiPath","/releases"),{toast:e}=E.useToast(),{fetchJson:r}=E.useImaginariumApi(),{configs:l}=Ee.useSystemConfigs(),a=Q.useQueryClient(),[o,d]=I.useState("all"),[u,c]=I.useState("all"),[m,x]=I.useState(null),[f,p]=I.useState(!1),[N,v]=I.useState(!1),[g,T]=I.useState(()=>new Set),[S,D]=I.useState(!1),[y,A]=I.useState(null),q=b=>T(H=>{const P=new Set(H);return P.has(b)?P.delete(b):P.add(b),P}),h=["imaginarium","release",n],j=["imaginarium","release-items",n],k=["imaginarium","release-pushes",n],B=["imaginarium","release-push-preview",n],$=()=>{a.invalidateQueries({queryKey:j}),a.invalidateQueries({queryKey:B})},{data:w,isLoading:_}=Q.useQuery({queryKey:h,queryFn:()=>r(`${i}/${n}`)}),{data:F,isLoading:Z}=Q.useQuery({queryKey:j,queryFn:async()=>{const b=await r(`${i}/${n}/items`);return Array.isArray(b)?b:(b==null?void 0:b.items)??[]}}),{data:ee}=Q.useQuery({queryKey:k,queryFn:async()=>{const b=await r(`${i}/${n}/pushes`);return Array.isArray(b)?b:(b==null?void 0:b.items)??[]}}),V=I.useMemo(()=>wn(ee??[]),[ee]),X=I.useMemo(()=>new Set((ee??[]).map(b=>b.destConfigId)),[ee]),z=(ee??[]).length>0,C=I.useMemo(()=>(w==null?void 0:w.targetConfigIds)??[],[w]),R=I.useMemo(()=>{const b=new Map;return l.forEach(H=>b.set(String(H.id),H.displayName)),b},[l]),O=b=>R.get(b)??b,U=I.useMemo(()=>kn(F??[]),[F]),ne=I.useMemo(()=>U.map(b=>b.item),[U]),Y=I.useMemo(()=>Pn(F??[]),[w==null?void 0:w.snapshotAt,F==null]),te=I.useMemo(()=>pi(Y),[Y]),ae=I.useMemo(()=>new Map((F??[]).map(b=>[b.itemKey,b])),[F]),le=b=>{var P;let H;if(b.parentKey){const J=(P=ae.get(b.parentKey))==null?void 0:P.itemName,G=b.parentKey.indexOf(":");H=J??(G>=0?b.parentKey.slice(G+1):void 0)}return`${H?H+" ":""}${b.itemType} "${b.itemName}"`},oe=I.useMemo(()=>{var H,P;const b=new Map;for(const J of F??[]){const G=(P=(H=J.diff)==null?void 0:H.origin)==null?void 0:P.id;typeof G=="string"&&G&&b.set(G,J.itemName)}return b},[F]),de=I.useMemo(()=>(F??[]).filter(b=>b.included&&!b.ignored).map(b=>({itemName:b.itemName,missing:Ce(b,Y,ae).map(le)})).filter(b=>b.missing.length>0),[F,Y,ae]),fe=I.useMemo(()=>Tn(ne),[ne]),Pe=I.useMemo(()=>Object.keys(fe).sort(ot),[fe]),jt=I.useMemo(()=>U.filter(b=>o==="all"||b.item.itemType===o).map(b=>{let H;if(b.item.itemType==="enum"){const P=b.children.length===0?yi(b.item):b.children;H=u==="all"||tt(b.item,u)?P:[]}else H=u==="all"?b.children:b.children.filter(P=>tt(P,u));return{node:b,renderChildren:H}}).filter(({node:b,renderChildren:H})=>u==="all"||tt(b.item,u)||H.length>0).sort((b,H)=>{const P=ot(b.node.item.itemType,H.node.item.itemType);return P!==0?P:b.node.item.itemName.localeCompare(H.node.item.itemName)}),[U,o,u]),De=Q.useMutation({mutationFn:()=>r(`${i}/${n}/refresh`,{method:"POST"}),onSuccess:()=>{$(),e({title:"Snapshot refreshed",description:"Items re-computed from origin."})},onError:b=>{e({title:"Error",description:b.message,variant:"destructive"})}}),Oe=Q.useMutation({mutationFn:({itemId:b,included:H})=>r(`${i}/${n}/items/${b}`,{method:"PATCH",body:JSON.stringify({included:H})}),onSuccess:()=>{$(),D(!0)},onError:b=>{e({title:"Error",description:b.message,variant:"destructive"})}}),Nt=(b,H)=>{if(Oe.mutate({itemId:b.id,included:H}),H){const J=Ce(b,Y,ae);J.length>0&&A({source:b,affected:J,action:"include"});return}const P=[...gi(b.itemKey,te)].map(J=>ae.get(J)).filter(J=>!!J&&J.included&&!J.ignored);P.length>0&&A({source:b,affected:P,action:"exclude"})},wt=Q.useMutation({mutationFn:({itemId:b,selectedVersion:H})=>r(`${i}/${n}/items/${b}`,{method:"PATCH",body:JSON.stringify({selectedVersion:H})}),onSuccess:()=>{$()},onError:b=>{e({title:"Error",description:b.message,variant:"destructive"})}}),Fe=b=>({mutationFn:({itemId:H,value:P})=>r(`${i}/${n}/items/${H}`,{method:"PATCH",body:JSON.stringify({[b]:P})}),onMutate:async({itemId:H,value:P})=>{await a.cancelQueries({queryKey:j});const J=a.getQueryData(j);return a.setQueryData(j,G=>(G??[]).map(ve=>ve.id===H?{...ve,[b]:P}:ve)),{prev:J}},onError:(H,P,J)=>{J!=null&&J.prev&&a.setQueryData(j,J.prev),e({title:"Error",description:H.message,variant:"destructive"})},onSettled:()=>{$()}}),$n=Q.useMutation(Fe("excludedTags")),Ln=Q.useMutation(Fe("excludedMetadataKeys")),Rn=Q.useMutation(Fe("excludedI18nPaths")),Fn=Q.useMutation(Fe("excludedPermissions")),me=(w==null?void 0:w.status)==="pushed",K=m?ae.get(m.itemKey)??m:null;return _?t.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"}):w?t.jsxs("div",{className:"space-y-4",children:[me&&t.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."}),t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[t.jsxs(E.Button,{variant:"ghost",size:"sm",onClick:s,children:[t.jsx(M.ArrowLeft,{}),"Back"]}),t.jsx("h3",{className:"text-lg font-semibold",children:di(w.name)}),t.jsx(mt,{status:w.status})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[!me&&t.jsx(dn,{releaseId:n,apiPath:i,onReset:$}),t.jsxs(E.Button,{variant:"outline",size:"sm",onClick:()=>De.mutate(),disabled:me||De.isPending,children:[t.jsx(M.RefreshCw,{}),De.isPending?"Refreshing…":"Refresh"]}),t.jsxs(E.Button,{variant:S&&!me?"default":"outline",size:"sm",onClick:()=>{v(!0),D(!1)},disabled:(w.targetConfigIds??[]).length===0,children:[t.jsx(M.ListChecks,{}),"Preview changes"]}),me?t.jsx(E.Button,{size:"sm",disabled:!0,children:"Pushed ✓"}):t.jsx(E.Button,{size:"sm",onClick:()=>p(!0),disabled:(w.targetConfigIds??[]).length===0||S,title:S?"Preview changes before pushing":void 0,children:"Push"})]})]}),t.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm text-muted-foreground",children:[t.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:O(w.originConfigId)}),t.jsx("span",{children:"→"}),(w.targetConfigIds??[]).map(b=>t.jsx("span",{className:"inline-flex items-center rounded bg-muted px-1.5 py-0.5 text-xs",children:O(b)},b)),t.jsxs("span",{className:"ml-2",children:["Snapshot: ",w.snapshotAt?new Date(w.snapshotAt).toLocaleString():"—"]}),t.jsxs("span",{children:["Pushed: ",w.pushedAt?new Date(w.pushedAt).toLocaleString():"—"]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[t.jsxs(E.Button,{variant:o==="all"?"secondary":"ghost",size:"sm",onClick:()=>d("all"),children:["All types (",ne.length,")"]}),Pe.map(b=>t.jsxs(E.Button,{variant:o===b?"secondary":"ghost",size:"sm",onClick:()=>d(b),children:[b," (",fe[b],")"]},b))]}),t.jsx("div",{className:"flex flex-wrap items-center gap-1",children:vi.map(b=>t.jsx(E.Button,{variant:u===b.value?"secondary":"outline",size:"sm",onClick:()=>c(b.value),children:b.label},b.value))})]}),t.jsxs("div",{className:"flex gap-4",children:[t.jsx("div",{className:"min-w-0 flex-1",children:Z?t.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading items…"}):jt.length===0?t.jsx(E.Card,{children:t.jsx(E.CardContent,{className:"py-12 text-center text-muted-foreground",children:ne.length===0?"No items in this release yet.":"No items match the current filters."})}):t.jsx(E.Card,{children:t.jsx(E.CardContent,{className:"p-0",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b text-left text-muted-foreground",children:[t.jsx("th",{className:"p-3 font-medium w-10",children:"Inc."}),t.jsx("th",{className:"p-3 font-medium",children:"Type"}),t.jsx("th",{className:"p-3 font-medium",children:"Origin Name"}),t.jsx("th",{className:"p-3 font-medium",children:"Status"}),t.jsx("th",{className:"p-3 font-medium"})]})}),t.jsx("tbody",{children:jt.map(({node:b,renderChildren:H})=>{var Ot;const P=b.item,J=H.length>0,G=g.has(P.itemKey)||u!=="all",ve=g.has(P.itemKey),be=En(b),St=((Ot=P.diff)==null?void 0:Ot.versions)??[],Ie=P.itemType==="rule"&&St.length>0,Et=St.some(W=>W.isPublished),Bn=Ie?ri(P):[],Pt=Ie&&!Et,Dt=Ie&&Et&&Bn.length===0,Be=Pt||Dt,Kn=Ie&&!Be&&P.selectedVersion==null;return t.jsxs(I.Fragment,{children:[b.synthetic?t.jsxs("tr",{className:"border-b last:border-0 cursor-pointer hover:bg-muted/50",onClick:()=>q(P.itemKey),children:[t.jsx("td",{className:"p-3"}),t.jsx("td",{className:"p-3",children:t.jsx(Se,{type:P.itemType})}),t.jsx("td",{className:"p-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:W=>{W.stopPropagation(),q(P.itemKey)},"aria-label":ve?"Collapse":"Expand",children:ve?t.jsx(M.ChevronDown,{size:14}):t.jsx(M.ChevronRight,{size:14})}),t.jsx("span",{className:"font-medium",children:P.itemName}),t.jsxs("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs ${be.included<be.total?"bg-amber-100 text-amber-700 font-medium dark:bg-amber-500/15 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:[be.included,"/",be.total," changes included"]})]})}),t.jsx("td",{className:"p-3"}),t.jsx("td",{className:"p-3"})]}):t.jsxs("tr",{className:`border-b last:border-0 cursor-pointer hover:bg-muted/50 ${(m==null?void 0:m.id)===P.id?"bg-muted/50":""} ${Be?"opacity-60":""}`,onClick:()=>x(P),children:[t.jsx("td",{className:"p-3",onClick:W=>W.stopPropagation(),children:t.jsx(dt,{checked:P.included,disabled:P.ignored||Oe.isPending||me||Be,onChange:W=>Nt(P,W)})}),t.jsx("td",{className:"p-3",children:t.jsx(Se,{type:P.itemType})}),t.jsx("td",{className:"p-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[J?t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:W=>{W.stopPropagation(),q(P.itemKey)},"aria-label":ve?"Collapse":"Expand",children:ve?t.jsx(M.ChevronDown,{size:14}):t.jsx(M.ChevronRight,{size:14})}):null,t.jsx("span",{className:"font-medium",children:P.itemName}),(()=>{if(!P.included||P.ignored)return null;const W=Ce(P,Y,ae);return W.length===0?null:t.jsx("span",{title:`Depends on excluded: ${W.map(ye=>ye.itemName).join(", ")}`,children:t.jsx(M.AlertTriangle,{size:14,className:"shrink-0 text-amber-600"})})})(),t.jsx(Yt,{item:P}),J&&be.total>0?t.jsxs("span",{className:`inline-flex items-center rounded px-1.5 py-0.5 text-xs ${be.included<be.total?"bg-amber-100 text-amber-700 font-medium dark:bg-amber-500/15 dark:text-amber-300":"bg-muted text-muted-foreground"}`,children:[be.included,"/",be.total," changes included"]}):null,P.carriedOver?t.jsx(on,{originName:O(w.originConfigId)}):null,P.ignored?t.jsx(nt,{}):null,Ie&&!Be?t.jsx("span",{onClick:W=>W.stopPropagation(),children:t.jsx(ai,{item:P,disabled:me||wt.isPending,onChange:W=>wt.mutate({itemId:P.id,selectedVersion:W})})}):null,Pt?t.jsx("span",{className:"text-xs text-muted-foreground",children:"Rules without a published version cannot be pushed"}):null,Dt?t.jsx("span",{className:"text-xs text-muted-foreground",children:"Nothing to push — all versions exist on target"}):null,Kn?t.jsx("span",{className:"text-xs text-amber-600",children:"Pushable version not selected"}):null]})}),t.jsx("td",{className:"p-3",children:t.jsx(Xt,{item:P,targetConfigIds:C})}),t.jsx("td",{className:"p-3 text-right",onClick:W=>W.stopPropagation(),children:t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[z?t.jsx(Zt,{item:P,targetConfigIds:C,results:V,pushedDests:X,displayName:O}):null,!P.ignored&&!me&&t.jsx(st,{createPayload:{originConfigId:w.originConfigId,itemKey:P.itemKey,itemType:P.itemType,itemName:P.itemName},hasAttributes:J,onChange:()=>{a.setQueryData(j,W=>(W??[]).map(ye=>ye.id===P.id?{...ye,ignored:!0,included:!1}:ye)),De.mutate()}})]})})]}),J&&G?H.map(W=>{const ye=W.itemType==="value";return t.jsxs("tr",{className:`border-b last:border-0 cursor-pointer hover:bg-muted/50 ${(m==null?void 0:m.itemKey)===W.itemKey?"bg-muted/50":""}`,onClick:()=>x(W),children:[t.jsx("td",{className:"p-3 pl-8",onClick:he=>he.stopPropagation(),children:ye?null:t.jsx(dt,{checked:W.included,disabled:W.ignored||Oe.isPending||me,onChange:he=>Nt(W,he)})}),t.jsx("td",{className:"p-3 pl-8",children:t.jsx(Se,{type:W.itemType})}),t.jsx("td",{className:"p-3",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"font-medium",children:W.itemName}),(()=>{if(!W.included||W.ignored)return null;const he=Ce(W,Y,ae);return he.length===0?null:t.jsx("span",{title:`Depends on excluded: ${he.map(Me=>Me.itemName).join(", ")}`,children:t.jsx(M.AlertTriangle,{size:14,className:"shrink-0 text-amber-600"})})})(),t.jsx(Yt,{item:W}),W.ignored?t.jsx(nt,{}):null]})}),t.jsx("td",{className:"p-3",children:t.jsx(Xt,{item:W,targetConfigIds:C})}),t.jsx("td",{className:"p-3 text-right",onClick:he=>he.stopPropagation(),children:t.jsxs("div",{className:"flex items-center justify-end gap-2",children:[z?t.jsx(Zt,{item:W,targetConfigIds:C,results:V,pushedDests:X,displayName:O}):null,!ye&&!W.ignored&&!me&&t.jsx(st,{createPayload:{originConfigId:w.originConfigId,itemKey:W.itemKey,itemType:W.itemType,itemName:W.itemName},onChange:()=>{a.setQueryData(j,he=>(he??[]).map(Me=>Me.id===W.id?{...Me,ignored:!0,included:!1}:Me)),De.mutate()}})]})})]},ye?W.itemKey:W.id)}):null]},b.synthetic?P.itemKey:P.id)})})]})})})}),m?t.jsx("div",{className:"w-[28rem] shrink-0 self-start sticky top-4 max-h-[calc(100vh-2rem)] overflow-auto",children:t.jsx(vn,{item:K,targets:(w.targetConfigIds??[]).map(b=>({id:b,name:O(b)})),onClose:()=>x(null),unmetDependencyNames:K&&K.included&&!K.ignored?Ce(K,Y,ae).map(le):[],tags:Array.isArray((Tt=(Ct=K==null?void 0:K.diff)==null?void 0:Ct.origin)==null?void 0:Tt.tags)?((kt=K==null?void 0:K.diff)==null?void 0:kt.origin).tags??[]:[],excludedTags:ue(K==null?void 0:K.excludedTags),metadataKeys:(()=>{var H,P;const b=(P=(H=K==null?void 0:K.diff)==null?void 0:H.origin)==null?void 0:P.metadata;return b!=null&&typeof b=="object"&&!Array.isArray(b)?Object.keys(b):[]})(),excludedMetadataKeys:ue(K==null?void 0:K.excludedMetadataKeys),i18nPaths:(()=>{var P,J;const b=(J=(P=K==null?void 0:K.diff)==null?void 0:P.origin)==null?void 0:J.i18n;if(!Array.isArray(b))return[];const H=b.map(G=>G==null?void 0:G.path).filter(G=>typeof G=="string");return Array.from(new Set(H))})(),excludedI18nPaths:ue(K==null?void 0:K.excludedI18nPaths),permissionKeys:(()=>{var P,J;if((K==null?void 0:K.itemType)!=="role")return[];const b=(J=(P=K==null?void 0:K.diff)==null?void 0:P.origin)==null?void 0:J.permissions;if(!Array.isArray(b))return[];const H=b.map(G=>`${(G==null?void 0:G.module)??""}/${(G==null?void 0:G.name)??(G==null?void 0:G.id)??""}`).filter(G=>G!=="/");return Array.from(new Set(H))})(),excludedPermissions:ue(K==null?void 0:K.excludedPermissions),formatPermissionLabel:b=>b.split(/([/.])/).map(H=>{var P,J;return((J=(P=K==null?void 0:K.diff)==null?void 0:P.nameMap)==null?void 0:J[H])??oe.get(H)??H}).join(""),replacementMaps:w.replacementMaps??void 0,editable:!!(K!=null&&K.id)&&!me,onToggleTag:(b,H)=>{if(!K||!K.id)return;const P=ue(K.excludedTags),J=H?P.filter(G=>G!==b):Array.from(new Set([...P,b]));$n.mutate({itemId:K.id,value:J})},onToggleMetadataKey:(b,H)=>{if(!K||!K.id)return;const P=ue(K.excludedMetadataKeys),J=H?P.filter(G=>G!==b):Array.from(new Set([...P,b]));Ln.mutate({itemId:K.id,value:J})},onToggleI18nPath:(b,H)=>{if(!K||!K.id)return;const P=ue(K.excludedI18nPaths),J=H?P.filter(G=>G!==b):Array.from(new Set([...P,b]));Rn.mutate({itemId:K.id,value:J})},onTogglePermission:(b,H)=>{if(!K||!K.id)return;const P=ue(K.excludedPermissions),J=H?P.filter(G=>G!==b):Array.from(new Set([...P,b]));Fn.mutate({itemId:K.id,value:J})}})}):null]}),t.jsx(Nn,{open:f,onOpenChange:p,releaseId:n,apiPath:i,targetConfigIds:C,targetNames:Object.fromEntries((w.targetConfigIds??[]).map(b=>[b,O(b)])),dependencyWarnings:de}),t.jsx(si,{open:N,onOpenChange:v,releaseId:n,apiPath:i,targetConfigIds:C,targetNames:Object.fromEntries((w.targetConfigIds??[]).map(b=>[b,O(b)])),dependencyWarnings:de}),t.jsx(ii,{source:(y==null?void 0:y.source)??null,action:(y==null?void 0:y.action)??"exclude",affected:(y==null?void 0:y.affected)??[],onUndo:()=>{y&&Oe.mutate({itemId:y.source.id,included:y.source.included}),A(null)},onIgnore:()=>A(null),onConfirm:()=>{for(const b of(y==null?void 0:y.affected)??[])Oe.mutate({itemId:b.id,included:(y==null?void 0:y.action)==="include"});A(null)}})]}):t.jsxs("div",{className:"space-y-4",children:[t.jsxs(E.Button,{variant:"ghost",size:"sm",onClick:s,children:[t.jsx(M.ArrowLeft,{}),"Back"]}),t.jsx("p",{className:"text-muted-foreground",children:"Release not found."})]})}function ut({value:n,onChange:s,configs:i,label:e}){const r=`cluster-select-${e.toLowerCase().replace(/\s+/g,"-")}`;return t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:r,children:e}),t.jsxs("select",{id:r,value:n,onChange:l=>s(l.target.value),className:"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm",children:[t.jsx("option",{value:"",children:"Select cluster…"}),i.map(l=>t.jsx("option",{value:l.id,children:l.displayName},l.id))]})]})}const en={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 tn({state:n,onClick:s,active:i}){const e=en[n]??en.match,r=n!=="match"&&n!=="skip"&&!!s;return t.jsx("button",{type:"button",onClick:r?s:void 0,disabled:!r,title:e.label,className:E.cn("w-full text-center text-sm py-1 rounded",e.className,r&&"hover:bg-muted cursor-pointer",!r&&"cursor-default",i&&"bg-muted ring-1 ring-ring"),children:e.symbol})}function ji({stats:n,destConfigIds:s}){return t.jsx("div",{className:"flex gap-6 text-xs text-muted-foreground py-2 px-1",children:s.map(i=>{const e=n[i];if(!e)return null;const r=e.match+e.diff+e.missing+e.extra;return t.jsxs("span",{children:[t.jsxs("span",{className:"font-mono font-medium",children:[e.match,"/",r]})," match",e.diff>0&&t.jsxs("span",{className:"text-destructive ml-2",children:[e.diff," diff"]}),e.missing>0&&t.jsxs("span",{className:"text-destructive ml-2",children:[e.missing," missing"]}),e.extra>0&&t.jsxs("span",{className:"text-amber-600 ml-2",children:[e.extra," extra"]})]},i)})})}function nn(n){return Object.values(n.cells).some(s=>s==="diff"||s==="missing"||s==="extra")}function On({originConfigId:n,destConfigIds:s,apiPath:i="/release-status"}){const{toast:e}=E.useToast(),{fetchJson:r}=E.useImaginariumApi(),{configs:l}=Ee.useSystemConfigs(),a=Q.useQueryClient(),[o,d]=I.useState("issues"),[u,c]=I.useState(!1),[m,x]=I.useState(null),[f,p]=I.useState(new Set),[N,v]=I.useState(()=>new Set),g=z=>v(C=>{const R=new Set(C);return R.has(z)?R.delete(z):R.add(z),R}),T=I.useMemo(()=>{const z=new Map;return l.forEach(C=>z.set(C.id,C.displayName)),z},[l]),S=z=>T.get(z)??z,D=s.filter(z=>!f.has(z)),y=new URLSearchParams;y.set("originConfigId",n),D.forEach(z=>y.append("destConfigIds[]",z));const A=["imaginarium","release-status",n,D],{data:q,isLoading:h,isFetching:j,isError:k}=Q.useQuery({queryKey:A,queryFn:()=>r(`${i}?${y.toString()}`),enabled:D.length>0}),B=Q.useMutation({mutationFn:()=>r(`${i}/refresh`,{method:"POST",body:JSON.stringify({originConfigId:n,destConfigIds:D})}),onSuccess:()=>{a.invalidateQueries({queryKey:A}),e({title:"Cache cleared",description:"Refreshing comparison data…"})},onError:z=>{e({title:"Error",description:z.message,variant:"destructive"})}}),{data:$,isLoading:w,isError:_}=Q.useQuery({queryKey:["imaginarium","release-status-diff",n,m==null?void 0:m.destConfigId,m==null?void 0:m.itemKey],queryFn:()=>r(`${i}/diff?originConfigId=${encodeURIComponent(n)}&destConfigId=${encodeURIComponent(m.destConfigId)}&itemKey=${encodeURIComponent(m.itemKey)}`),enabled:!!m}),F=z=>{p(C=>{const R=new Set(C);return R.has(z)?R.delete(z):R.add(z),R})},Z=(z,C)=>{x(R=>(R==null?void 0:R.itemKey)===z&&R.destConfigId===C?null:{itemKey:z,destConfigId:C})},ee=(q==null?void 0:q.rows)??[],V=(q==null?void 0:q.stats)??{},X=I.useMemo(()=>Sn(ee).map(C=>{const R=o==="issues"?C.children.filter(nn):C.children;return{node:C,renderChildren:R}}).filter(({node:C,renderChildren:R})=>o==="all"||nn(C.row)||R.length>0).sort((C,R)=>{const O=ot(C.node.row.itemType,R.node.row.itemType);return O!==0?O:C.node.row.itemName.localeCompare(R.node.row.itemName)}),[ee,o]);return t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex rounded-md border text-sm overflow-hidden",children:[t.jsx("button",{className:E.cn("px-3 py-1.5",o==="issues"?"bg-muted font-medium":"hover:bg-muted/50"),onClick:()=>d("issues"),children:"Issues only"}),t.jsx("button",{className:E.cn("px-3 py-1.5 border-l",o==="all"?"bg-muted font-medium":"hover:bg-muted/50"),onClick:()=>d("all"),children:"All"})]}),t.jsxs(E.Button,{variant:"ghost",size:"sm",onClick:()=>c(z=>!z),children:[t.jsx(M.BarChart2,{}),"Stats"]}),t.jsxs(E.Button,{variant:"ghost",size:"sm",onClick:()=>B.mutate(),disabled:B.isPending||j,children:[t.jsx(M.RefreshCw,{className:E.cn((B.isPending||j)&&"animate-spin")}),"Refresh"]}),[...f].map(z=>t.jsxs("button",{onClick:()=>F(z),className:"text-xs border rounded px-2 py-1 text-muted-foreground hover:bg-muted",children:["+ ",S(z)]},z))]}),u&&q&&t.jsx(ji,{stats:V,destConfigIds:D}),h&&t.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"}),k&&t.jsx("div",{className:"text-center text-destructive py-8",children:"Failed to load comparison data."}),!h&&!k&&t.jsxs("div",{className:"flex gap-4",children:[t.jsx("div",{className:"min-w-0 flex-1 rounded-md border overflow-auto max-h-[70vh]",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"sticky top-0 z-10 bg-muted px-4 py-2 text-left font-medium min-w-[200px]",children:"Item"}),D.map(z=>t.jsx("th",{className:"sticky top-0 z-10 bg-muted px-2 py-2 text-center font-medium min-w-[80px]",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx("span",{className:"truncate max-w-[120px]",title:S(z),children:S(z)}),t.jsx("button",{className:"text-muted-foreground hover:text-foreground",onClick:()=>F(z),title:"Hide column",children:"×"})]})},z))]})}),t.jsx("tbody",{children:X.length===0?t.jsx("tr",{children:t.jsx("td",{colSpan:D.length+1,className:"text-center text-muted-foreground py-8",children:o==="issues"?"No issues found — all clusters in sync.":"No items."})}):X.map(({node:z,renderChildren:C})=>{const R=z.row,O=C.length>0,U=N.has(R.itemKey)||o==="issues",ne=N.has(R.itemKey);return t.jsxs(I.Fragment,{children:[t.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[t.jsx("td",{className:"px-4 py-1.5",children:t.jsxs("div",{className:"flex items-center gap-2",children:[O?t.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground",onClick:()=>g(R.itemKey),"aria-label":ne?"Collapse":"Expand",children:ne?t.jsx(M.ChevronDown,{size:14}):t.jsx(M.ChevronRight,{size:14})}):null,t.jsx("span",{className:"inline-flex align-middle",children:t.jsx(Se,{type:R.itemType})}),t.jsx("span",{className:"font-medium",children:R.itemName})]})}),D.map(Y=>t.jsx("td",{className:"px-2 py-1",children:t.jsx(tn,{state:R.cells[Y]??"match",active:(m==null?void 0:m.itemKey)===R.itemKey&&m.destConfigId===Y,onClick:()=>Z(R.itemKey,Y)})},Y))]}),O&&U?C.map(Y=>t.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[t.jsx("td",{className:"px-4 py-1.5 pl-8",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"inline-flex align-middle",children:t.jsx(Se,{type:Y.itemType})}),t.jsx("span",{className:"font-medium",children:Y.itemName})]})}),D.map(te=>t.jsx("td",{className:"px-2 py-1",children:t.jsx(tn,{state:Y.cells[te]??"match",active:(m==null?void 0:m.itemKey)===Y.itemKey&&m.destConfigId===te,onClick:()=>Z(Y.itemKey,te)})},te))]},Y.itemKey)):null]},R.itemKey)})})]})}),m?t.jsx("div",{className:"w-[28rem] shrink-0 self-start sticky top-4 max-h-[calc(100vh-2rem)] overflow-auto",children:w?t.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…"}):_||!$?t.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."}):t.jsx(vt,{item:{itemName:$.itemName,itemType:$.itemType,diff:{origin:$.origin,target:$.target}},onClose:()=>x(null)})}):null]})]})}const sn=n=>({name:"",description:"",values:Object.fromEntries(n.map(s=>[s,""]))});function In({configIds:n,clusterNames:s={},apiPath:i="/release-translations"}){const{toast:e}=E.useToast(),{fetchJson:r}=E.useImaginariumApi(),l=Q.useQueryClient(),[a,o]=I.useState(!1),[d,u]=I.useState(null),[c,m]=I.useState(sn(n)),[x,f]=I.useState(()=>new Set),p=w=>{f(_=>{const F=new Set(_);return F.has(w)?F.delete(w):F.add(w),F})},N=["imaginarium","release-translations"],{data:v,isLoading:g}=Q.useQuery({queryKey:N,queryFn:async()=>{const w=await r(i);return(w==null?void 0:w.items)??[]}}),T=Q.useMutation({mutationFn:async w=>{const _=await r(i,{method:"POST",body:JSON.stringify({name:w.name.trim(),description:w.description.trim()||null})});await y(_.id,w.values)},onSuccess:()=>{l.invalidateQueries({queryKey:N}),e({title:"Translation created"}),h()},onError:w=>e({title:"Error",description:w.message,variant:"destructive"})}),S=Q.useMutation({mutationFn:async w=>{await r(`${i}/${d.id}`,{method:"PATCH",body:JSON.stringify({name:w.name.trim(),description:w.description.trim()||null})}),await y(d.id,w.values)},onSuccess:()=>{l.invalidateQueries({queryKey:N}),e({title:"Translation updated"}),h()},onError:w=>e({title:"Error",description:w.message,variant:"destructive"})}),D=Q.useMutation({mutationFn:w=>r(`${i}/${w}`,{method:"DELETE"}),onSuccess:()=>{l.invalidateQueries({queryKey:N}),e({title:"Translation deleted"})},onError:w=>e({title:"Error",description:w.message,variant:"destructive"})});async function y(w,_){var Z;const F=(d==null?void 0:d.values)??[];for(const ee of n){const V=(Z=_[ee])==null?void 0:Z.trim(),X=F.find(C=>C.configId===ee),z=`${i}/${w}/values`;X&&V?await r(`${z}/${X.id}`,{method:"PATCH",body:JSON.stringify({value:V})}):X&&!V?await r(`${z}/${X.id}`,{method:"DELETE"}):!X&&V&&await r(z,{method:"POST",body:JSON.stringify({translationId:w,configId:ee,value:V})})}}const A=()=>{u(null),m(sn(n)),o(!0)},q=w=>{u(w);const _=w.values??[],F=Object.fromEntries(n.map(Z=>{var ee;return[Z,((ee=_.find(V=>V.configId===Z))==null?void 0:ee.value)??""]}));m({name:w.name,description:w.description??"",values:F}),o(!0)},h=()=>{o(!1),u(null)},j=()=>{d?S.mutate(c):T.mutate(c)},k=T.isPending||S.isPending,B=!!c.name.trim();if(g)return t.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"});const $=[...v??[]].sort((w,_)=>w.name.localeCompare(_.name,void 0,{sensitivity:"base"}));return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:$.length===0?"No translation rules yet.":`${$.length} translation rule${$.length===1?"":"s"}.`}),t.jsxs(E.Button,{size:"sm",onClick:A,children:[t.jsx(M.Plus,{}),"Add translation"]})]}),$.length>0&&t.jsx("div",{className:"rounded-md border divide-y text-sm",children:$.map(w=>{const _=x.has(w.id),F=w.values??[],Z=V=>{var X;return((X=F.find(z=>z.configId===V))==null?void 0:X.value)??""},ee=n.filter(V=>Z(V)).length;return t.jsxs("div",{children:[t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 hover:bg-muted/25",children:[t.jsxs("button",{type:"button",onClick:()=>p(w.id),"aria-expanded":_,className:"flex flex-1 min-w-0 items-center gap-3 text-left",children:[_?t.jsx(M.ChevronDown,{className:"size-4 shrink-0 text-muted-foreground"}):t.jsx(M.ChevronRight,{className:"size-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"font-medium",children:w.name}),w.description&&t.jsx("div",{className:"truncate text-xs text-muted-foreground",children:w.description})]}),t.jsxs("div",{className:"shrink-0 whitespace-nowrap text-xs text-muted-foreground",children:[ee," of ",n.length," set"]})]}),t.jsxs("div",{className:"flex shrink-0 gap-1",children:[t.jsx(E.Button,{variant:"ghost",size:"icon",onClick:()=>q(w),children:t.jsx(M.Pencil,{})}),t.jsx(E.Button,{variant:"ghost",size:"icon",onClick:()=>{window.confirm(`Delete translation "${w.name}"?`)&&D.mutate(w.id)},children:t.jsx(M.Trash2,{})})]})]}),_&&t.jsx("div",{className:"space-y-1 px-4 pb-3 pl-11",children:n.map(V=>t.jsxs("div",{className:"grid grid-cols-[10rem_1fr] gap-2 text-xs",children:[t.jsx("span",{className:"text-muted-foreground",children:s[V]??V}),t.jsx("span",{className:"break-all font-mono",children:Z(V)||t.jsx("span",{className:"text-muted-foreground",children:"—"})})]},V))})]},w.id)})}),t.jsx(L.Dialog,{open:a,onOpenChange:o,children:t.jsxs(L.DialogContent,{className:"max-w-lg",children:[t.jsxs(L.DialogHeader,{children:[t.jsx(L.DialogTitle,{children:d?`Edit ${d.name}`:"New Translation Rule"}),t.jsx(L.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."})]}),t.jsxs("div",{className:"space-y-4 py-2",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"tr-name",children:"Name"}),t.jsx(L.Input,{id:"tr-name",value:c.name,onChange:w=>m({...c,name:w.target.value}),placeholder:"key (ex. molten-url)"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(L.Label,{htmlFor:"tr-desc",children:"Description (optional)"}),t.jsx(L.Input,{id:"tr-desc",value:c.description,onChange:w=>m({...c,description:w.target.value}),placeholder:"Explain what this value represents"})]}),t.jsxs("div",{className:"space-y-3 pt-1",children:[t.jsx("p",{className:"text-sm font-medium",children:"Values per cluster"}),n.map(w=>t.jsxs("div",{className:"space-y-1",children:[t.jsx(L.Label,{htmlFor:`tr-val-${w}`,className:"text-xs text-muted-foreground",children:s[w]??w}),t.jsx(L.Input,{id:`tr-val-${w}`,value:c.values[w]??"",onChange:_=>m({...c,values:{...c.values,[w]:_.target.value}}),placeholder:"Leave blank to remove",className:"font-mono text-xs"})]},w))]})]}),t.jsxs(L.DialogFooter,{children:[t.jsxs(E.Button,{variant:"outline",onClick:h,children:[t.jsx(M.X,{}),"Cancel"]}),t.jsxs(E.Button,{onClick:j,disabled:!B||k,children:[t.jsx(M.Save,{}),k?"Saving…":"Save"]})]})]})})]})}function Mn({originConfigId:n,apiPath:s="/release-ignores"}){const{toast:i}=E.useToast(),{fetchJson:e}=E.useImaginariumApi(),r=Q.useQueryClient(),l=["imaginarium","release-ignores",n],{data:a,isLoading:o}=Q.useQuery({queryKey:l,queryFn:async()=>{const x=await e(`${s}?where[originConfigId]=${encodeURIComponent(n)}`);return(x==null?void 0:x.items)??[]}}),d=Q.useMutation({mutationFn:x=>e(`${s}/${x}`,{method:"DELETE"}),onSuccess:()=>{r.invalidateQueries({queryKey:l}),i({title:"Item removed from ignore list"})},onError:x=>{i({title:"Error",description:x.message,variant:"destructive"})}}),u=Q.useMutation({mutationFn:()=>e(`${s}?originConfigId=${encodeURIComponent(n)}`,{method:"DELETE"}),onSuccess:()=>{r.invalidateQueries({queryKey:l}),i({title:"All ignore rules cleared"})},onError:x=>{i({title:"Error",description:x.message,variant:"destructive"})}}),c=()=>{window.confirm("Remove all ignore rules for this cluster? Items will appear normally in future snapshots.")&&u.mutate()};if(o)return t.jsx("div",{className:"text-center text-muted-foreground py-8",children:"Loading…"});const m=a??[];return t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("p",{className:"text-sm text-muted-foreground",children:m.length===0?"No items are permanently ignored.":`${m.length} item${m.length===1?"":"s"} permanently ignored for this cluster.`}),m.length>0&&t.jsxs(E.Button,{variant:"outline",size:"sm",onClick:c,disabled:u.isPending,children:[t.jsx(M.Ban,{}),u.isPending?"Clearing…":"Clear all"]})]}),m.length>0&&t.jsx("div",{className:"rounded-md border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{children:t.jsxs("tr",{className:"border-b bg-muted/50",children:[t.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Type"}),t.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Name"}),t.jsx("th",{className:"px-4 py-2 text-left font-medium",children:"Reason"}),t.jsx("th",{className:"px-4 py-2 text-right font-medium"})]})}),t.jsx("tbody",{children:m.map(x=>t.jsxs("tr",{className:"border-b last:border-0 hover:bg-muted/25",children:[t.jsx("td",{className:"px-4 py-2 text-muted-foreground font-mono text-xs",children:x.itemType}),t.jsx("td",{className:"px-4 py-2 font-medium",children:x.itemName}),t.jsx("td",{className:"px-4 py-2 text-muted-foreground",children:x.reason??t.jsx("span",{className:"italic text-xs",children:"—"})}),t.jsx("td",{className:"px-4 py-2 text-right",children:t.jsx(E.Button,{variant:"ghost",size:"icon",title:"Remove from ignore list",onClick:()=>d.mutate(x.id),disabled:d.isPending,children:t.jsx(M.Trash2,{})})})]},x.id))})]})})]})}function Ni(n,s){return[...n].sort((i,e)=>(s[i]??i).localeCompare(s[e]??e,void 0,{sensitivity:"base"}))}const rn=["dev","stg","prd"];function wi(n){const s=(n.tags??[]).map(e=>e.toLowerCase()),i=rn.findIndex(e=>s.includes(e));return i===-1?rn.length:i}function Ci(n){const s=Object.fromEntries(n.map(r=>[r.id,r.displayName])),i=new Map;for(const r of n){const l=wi(r);i.has(l)||i.set(l,[]),i.get(l).push(r.id)}return[...i.keys()].sort((r,l)=>r-l).flatMap(r=>Ni(i.get(r),s))}const Ti=[{id:"releases",label:"Releases"},{id:"status",label:"Status"},{id:"translations",label:"Translations"},{id:"ignored",label:"Ignored"}];function ki(){const n=window.location.hash;return n.startsWith("#release-")?n.slice(9):null}function An(){var m;const[n,s]=I.useState("releases"),[i,e]=I.useState(ki);I.useEffect(()=>{i?history.replaceState(null,"",`${window.location.pathname}${window.location.search}#release-${i}`):history.replaceState(null,"",window.location.pathname+window.location.search)},[i]);const{configs:r}=Ee.useSystemConfigs(),[l,a]=I.useState("");I.useEffect(()=>{!l&&r.length>0&&a(r[0].id)},[l,r]);const o=I.useMemo(()=>{const x={};return r.forEach(f=>{x[f.id]=f.displayName}),x},[r]),d=l||((m=r[0])==null?void 0:m.id)||"",u=I.useMemo(()=>Ci(r),[r]),c=u.filter(x=>x!==d);return t.jsxs("div",{className:"space-y-6",children:[t.jsxs("div",{children:[t.jsx("h2",{className:"text-2xl font-semibold",children:"imp"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage releases across clusters"})]}),t.jsx("div",{className:"flex items-center gap-1 border-b pb-2",children:Ti.map(({id:x,label:f})=>t.jsx(E.Button,{variant:n===x?"secondary":"ghost",size:"sm",onClick:()=>s(x),children:f},x))}),n==="releases"&&(i==null?t.jsx(ln,{onOpen:e}):t.jsx(Dn,{releaseId:i,onBack:()=>e(null)})),n==="status"&&(r.length===0?t.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"max-w-xs",children:t.jsx(ut,{label:"Reference",value:d,onChange:a,configs:r})}),d?t.jsx(On,{originConfigId:d,destConfigIds:c}):t.jsx("div",{className:"text-muted-foreground",children:"Select a reference cluster."})]})),n==="translations"&&(r.length===0?t.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):t.jsx(In,{configIds:u,clusterNames:o})),n==="ignored"&&(r.length===0?t.jsx("div",{className:"text-muted-foreground",children:"No clusters configured."}):t.jsxs("div",{className:"space-y-4",children:[t.jsx("div",{className:"max-w-xs",children:t.jsx(ut,{label:"Cluster",value:d,onChange:a,configs:r})}),d?t.jsx(Mn,{originConfigId:d}):t.jsx("div",{className:"text-muted-foreground",children:"Select a cluster."})]}))]})}const Si={id:"imaginarium.ui.ImpPage",path:"/imp",element:An},Ei={id:"imaginarium.ui.ImpNavItem",path:"/imp",label:"imp",icon:M.Bot,sort:150},Pi={install(n){n.addPlugin(It.PageType,Si),n.addPlugin(It.NavItemType,Ei),L.PageDoc.register(n,zn)}};exports.ClusterSelect=ut;exports.CreateReleaseModal=an;exports.DiffPanel=vt;exports.EntityTag=Se;exports.IgnoreButton=st;exports.IgnoredPill=nt;exports.IgnoredTab=Mn;exports.PreviouslySkippedBadge=on;exports.PushDialog=Nn;exports.ReleaseDetail=Dn;exports.ReleaseDiffPanel=vn;exports.ReleaseList=ln;exports.ReleaseSetup=Pi;exports.ReleaseStatusBadge=mt;exports.ReleaseView=An;exports.ResetExclusionsButton=dn;exports.StatusMatrix=On;exports.Toggle=dt;exports.TranslationsTab=In;exports.buildItemTree=kn;exports.buildPushResultMap=wn;exports.computeDependsOn=Pn;exports.filterItems=ci;exports.groupStatusRows=Sn;exports.includedChildCounts=En;exports.pushResultFor=Cn;exports.typeCounts=Tn;exports.unmetDependencies=Ce;
|
|
229
|
+
//# sourceMappingURL=PluginSetup-C6utOEKL.cjs.map
|