import{u as _,r as x,j as e}from"./index-BIVkyPD7.js";const N="_container_uv8oc_2",j="_header_uv8oc_10",v="_modeBtn_uv8oc_18",g="_modeBtnActive_uv8oc_33",w="_unifiedView_uv8oc_40",L="_diffLine_uv8oc_46",b="_lineNum_uv8oc_55",C="_lineContent_uv8oc_64",S="_lineAdded_uv8oc_68",V="_lineRemoved_uv8oc_73",B="_lineContext_uv8oc_78",$="_sideBySide_uv8oc_83",A="_sidePane_uv8oc_90",P="_sideLabel_uv8oc_100",R="_sideContent_uv8oc_112",D="_empty_uv8oc_117",s={container:N,header:j,modeBtn:v,modeBtnActive:g,unifiedView:w,diffLine:L,lineNum:b,lineContent:C,lineAdded:S,lineRemoved:V,lineContext:B,sideBySide:$,sidePane:A,sideLabel:P,sideContent:R,empty:D};function k(n,i){const l=n.split(`
`),d=i.split(`
`),a=[],f=Math.max(l.length,d.length);let t=0,r=0;for(;(t<l.length||r<d.length)&&(t<l.length&&r<d.length?l[t]===d[r]?(a.push({type:"context",content:l[t],lineNum:r+1}),t++,r++):(a.push({type:"removed",content:l[t],lineNum:t+1}),t++,t<l.length&&l[t]===d[r]?(a.push({type:"added",content:d[r],lineNum:r+1}),r++):r<d.length&&(a.push({type:"added",content:d[r],lineNum:r+1}),r++)):t<l.length?(a.push({type:"removed",content:l[t],lineNum:t+1}),t++):r<d.length&&(a.push({type:"added",content:d[r],lineNum:r+1}),r++),!(a.length>f*3)););return a}function O({before:n,after:i}){const{t:l}=_(),[d,a]=x.useState("unified"),f=typeof n=="string"?n:n!=null?JSON.stringify(n,null,2):"",t=typeof i=="string"?i:i!=null?JSON.stringify(i,null,2):"",r=x.useMemo(()=>k(f,t),[f,t]);if(!f&&!t)return e.jsx("div",{className:s.container,children:e.jsx("div",{className:s.empty,children:l("changelog.diff.empty","No diff available")})});if(!f&&t){const c=t.split(`
`);return e.jsx("div",{className:s.container,children:e.jsx("div",{className:s.unifiedView,children:c.map((u,m)=>e.jsxs("div",{className:`${s.diffLine} ${s.lineAdded}`,children:[e.jsx("span",{className:s.lineNum,children:m+1}),e.jsxs("span",{className:s.lineContent,children:["+ ",u]})]},m))})})}return e.jsxs("div",{className:s.container,children:[e.jsxs("div",{className:s.header,children:[e.jsx("button",{className:`${s.modeBtn} ${d==="unified"?s.modeBtnActive:""}`,onClick:()=>a("unified"),children:l("changelog.diff.unified","Unified")}),e.jsx("button",{className:`${s.modeBtn} ${d==="side-by-side"?s.modeBtnActive:""}`,onClick:()=>a("side-by-side"),children:l("changelog.diff.sideBySide","Side by Side")})]}),d==="unified"?e.jsx("div",{className:s.unifiedView,children:r.map((c,u)=>e.jsxs("div",{className:`${s.diffLine} ${c.type==="added"?s.lineAdded:c.type==="removed"?s.lineRemoved:s.lineContext}`,children:[e.jsx("span",{className:s.lineNum,children:c.lineNum??""}),e.jsxs("span",{className:s.lineContent,children:[c.type==="added"?"+ ":c.type==="removed"?"- ":"  ",c.content]})]},u))}):e.jsxs("div",{className:s.sideBySide,children:[e.jsxs("div",{className:s.sidePane,children:[e.jsx("div",{className:s.sideLabel,children:l("changelog.diff.before","Before")}),e.jsx("div",{className:s.sideContent,children:f.split(`
`).map((c,u)=>e.jsxs("div",{className:`${s.diffLine} ${s.lineContext}`,children:[e.jsx("span",{className:s.lineNum,children:u+1}),e.jsx("span",{className:s.lineContent,children:c})]},u))})]}),e.jsxs("div",{className:s.sidePane,children:[e.jsx("div",{className:s.sideLabel,children:l("changelog.diff.after","After")}),e.jsx("div",{className:s.sideContent,children:t.split(`
`).map((c,u)=>e.jsxs("div",{className:`${s.diffLine} ${s.lineContext}`,children:[e.jsx("span",{className:s.lineNum,children:u+1}),e.jsx("span",{className:s.lineContent,children:c})]},u))})]})]})]})}const z="_container_1d335_2",J="_propertyList_1d335_11",K="_propertyRow_1d335_18",F="_propertyKey_1d335_26",E="_oldValue_1d335_33",G="_arrow_1d335_39",I="_newValue_1d335_44",o={container:z,propertyList:J,propertyRow:K,propertyKey:F,oldValue:E,arrow:G,newValue:I};function h(n){return typeof n=="object"&&n!==null}function M(n){return h(n)&&n.type==="props"}function U(n){return h(n)&&n.type==="value"}function p(n){return n==null?"nil":typeof n=="string"?`"${n}"`:typeof n=="object"?JSON.stringify(n):String(n)}function W({before:n,after:i}){if(M(i)){const a=Object.entries(i.changedProperties??{});return a.length===0?null:e.jsx("div",{className:o.propertyList,children:a.map(([f,t])=>e.jsxs("div",{className:o.propertyRow,children:[e.jsx("span",{className:o.propertyKey,children:f}),e.jsx("span",{className:o.oldValue,children:p(t.before)}),e.jsx("span",{className:o.arrow,children:"→"}),e.jsx("span",{className:o.newValue,children:p(t.after)})]},f))})}if(U(i)&&i.valueDiff)return e.jsxs("div",{className:o.container,children:[e.jsx("span",{className:o.oldValue,children:p(i.valueDiff.before)}),e.jsx("span",{className:o.arrow,children:"→"}),e.jsx("span",{className:o.newValue,children:p(i.valueDiff.after)})]});const l=n!=null,d=i!=null;return!l&&!d?null:l?d?e.jsxs("div",{className:o.container,children:[e.jsx("span",{className:o.oldValue,children:p(n)}),e.jsx("span",{className:o.arrow,children:"→"}),e.jsx("span",{className:o.newValue,children:p(i)})]}):e.jsx("div",{className:o.container,children:e.jsx("span",{className:o.oldValue,children:p(n)})}):e.jsx("div",{className:o.container,children:e.jsx("span",{className:o.newValue,children:p(i)})})}function q(n){return typeof n=="object"&&n!==null}function H(n){return q(n)&&n.type==="script"}function y(n){return n==null?"new":`${n} lines`}function T({change:n}){if(n.category==="script"){if(typeof n.before=="string"||typeof n.after=="string")return e.jsx(O,{before:n.before,after:n.after});if(H(n.after)){const i=n.after.scriptMeta;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",fontFamily:"var(--font-code)",fontSize:"11px",padding:"4px 0"},children:[e.jsx("span",{style:{color:"var(--text-secondary)"},children:y(i==null?void 0:i.beforeLines)}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:"10px"},children:"→"}),e.jsx("span",{style:{color:"var(--text-primary)",fontWeight:500},children:y(i==null?void 0:i.afterLines)})]})}}return n.category==="property"?e.jsx(W,{before:n.before,after:n.after}):n.details?e.jsx("pre",{style:{fontFamily:"var(--font-code)",fontSize:"11px",color:"var(--text-secondary)",margin:0,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(n.details,null,2)}):e.jsx("div",{style:{fontFamily:"var(--font-code)",fontSize:"11px",color:"var(--text-muted)"},children:n.target})}export{T as G};
