@ht-rnd/merge-conflict-viewer 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -221,7 +221,7 @@ The variables are optional. If your CSS does not define one (you copied the file
221
221
 
222
222
  ### Tailwind v3.4 and v4
223
223
 
224
- The same file works with both. It only uses utilities that exist in both (typed arbitrary values such as `bg-[color:var(--_merge-modified)]`, `size-*`, no v4-only syntax) and computes the colour classes per cell in JavaScript, so there are no variant-order surprises. The registry test installs the component into a fresh Tailwind v3.4 project and a fresh v4 project, type-checks them and builds the CSS.
224
+ The same file works with both. It only uses utilities that exist in both (typed arbitrary values such as `bg-[color:var(--mcv-modified)]`, `size-*`, no v4-only syntax) and computes the colour classes per cell in JavaScript, so there are no variant-order surprises. The registry test installs the component into a fresh Tailwind v3.4 project and a fresh v4 project, type-checks them and builds the CSS.
225
225
 
226
226
  Tailwind v3 projects keep their theme in `tailwind.config.js`; the `--merge-*` variables are plain CSS variables referenced through arbitrary values, so nothing needs to be added to the config.
227
227
 
@@ -463,7 +463,7 @@ Takes the [options](#options) above. Returns everything `useMergeConflicts` retu
463
463
  |---|---|
464
464
  | `items` | Everything shown, in order: rows (`current`, `result` and `incoming` lines) and folds of unchanged lines |
465
465
  | `labels`, `stacked`, `statusState`, `statusText` | Resolved texts, whether the panes are stacked, and the banner state (`"empty" \| "pending" \| "resolved"`) |
466
- | `collapsed`, `toggleCollapsed` | Whether unchanged runs are folded |
466
+ | `collapsed`, `toggleCollapsed` | Whether unchanged runs are folded. `collapsed` turns `false` when the user opens a run by hand, and `toggleCollapsed` then folds them all again before it switches folding off |
467
467
  | `activeId`, `goToChange(dir)`, `goToNextUnresolved()` | Navigation between changes |
468
468
  | `editable`, `editingId`, `startEdit(id)`, `cancelEdit()`, `editorText(id)`, `commitEdit(id, text)` | Editing; `commitEdit` returns the parser's message when the text is not valid JSON |
469
469
  | `getRootProps()`, `getScrollProps()`, `getGridProps()`, `getHeaderProps(pane)`, `getCellProps(row, pane, column)`, `getFoldProps(fold, pane)` | Prop getters to spread on your elements |
package/dist/lib/main.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qe=require("react/jsx-runtime"),y=require("react"),et=3;function we(e,t,s){const r=[],n=(c,i)=>{for(let h=c;h<i;h++)r.push({type:"row",row:e[h]})};let o=0;for(;o<e.length;){if(e[o].blockId!==null){r.push({type:"row",row:e[o]}),o++;continue}let c=o;for(;c<e.length&&e[c].blockId===null;)c++;const i=o===0?1:t,h=c===e.length?1:t,u=c-o-i-h,d=`${e[o-1]?.blockId??"start"}>${e[c]?.blockId??"end"}`;u<et||s.has(d)?n(o,c):(n(o,o+i),r.push({type:"fold",key:d,hidden:u}),n(c-h,c)),o=c}return r}function Ne(e,t){if(t===null)return[e,"",""];const s=e.endsWith(",")?",":"",r=s?e.slice(0,-1):e,n=t.endsWith(",")?t.slice(0,-1):t;let o=0;const c=Math.min(r.length,n.length);for(;o<c&&r[o]===n[o];)o++;let i=r.length,h=n.length;for(;i>o&&h>o&&r[i-1]===n[h-1];)i--,h--;return[r.slice(0,o),r.slice(o,i),r.slice(i)+s]}function Ce(e,t){if(t==null)return[{text:e,changed:!1}];const[s,r,n]=Ne(e,t);if(!r)return[{text:e,changed:!1}];const o=[];return s&&o.push({text:s,changed:!1}),o.push({text:r,changed:!0}),n&&o.push({text:n,changed:!1}),o}function B(e,t,s){return e===1?t:s}const Ae={current:"Current",result:"Result",incoming:"Incoming",applyAllCurrent:"Apply all from current",applyAllIncoming:"Apply all from incoming",previousChange:"Previous change",nextChange:"Next change",hideUnchanged:"Hide unchanged lines",undo:"Undo",redo:"Redo",summary:({total:e})=>e===0?"No differences":`${e} ${B(e,"change","changes")}`,noChanges:"No differences. Nothing to merge.",unresolved:({unresolved:e,total:t})=>`${e} of ${t} ${B(t,"change","changes")} still ${B(e,"needs","need")} a decision.`,allResolved:({total:e})=>`All ${e} ${B(e,"change","changes")} resolved. Safe to merge.`,nextUnresolved:"Next unresolved",unchangedLines:e=>`${e} unchanged ${B(e,"line","lines")}`,showUnchanged:e=>`Show ${e} unchanged ${B(e,"line","lines")}`,acceptCurrent:e=>`Accept current ${e}`,acceptIncoming:e=>`Accept incoming ${e}`,removeChange:e=>`Remove ${e} from result`,editChange:e=>`Edit ${e} in result`,revertEdit:e=>`Revert edit of ${e}`,editorTitle:e=>`Edit ${e} (JSON value)`,editorInput:e=>`JSON value of ${e}`,apply:"Apply",cancel:"Cancel"};function Ie(e){const t={...Ae};for(const[s,r]of Object.entries(e??{}))r!==void 0&&(t[s]=r);return t}const Le=" ",tt=["id","@id","key","name","code","uuid","slug"];function ue(e){return typeof e=="object"&&e!==null&&"custom"in e}function F(e,t){return Object.hasOwn(e,t)}function _(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function j(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((s,r)=>j(s,t[r]));if(_(e)&&_(t)){const s=Object.keys(e),r=Object.keys(t);return s.length===r.length&&s.every(n=>F(t,n)&&j(e[n],t[n]))}return!1}function ce(e){return Array.isArray(e)?`[${e.map(ce).join(",")}]`:_(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${ce(e[t])}`).join(",")}}`:JSON.stringify(e)??"null"}function ie(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}const nt=/^[A-Za-z_$][\w$]*$/;function ot(e,t){return nt.test(t)?e?`${e}.${t}`:t:`${e}[${JSON.stringify(t)}]`}function st(e,t){const s=[...t],r=new Set(t);let n=-1;for(const o of e){if(r.has(o)){n=s.indexOf(o);continue}n+=1,s.splice(n,0,o),r.add(o)}return s}function Re(e,t){const s=e.length,r=t.length,n=r+1,o=new Uint32Array((s+1)*n);for(let u=s-1;u>=0;u--)for(let d=r-1;d>=0;d--)o[u*n+d]=e[u]===t[d]?o[(u+1)*n+d+1]+1:Math.max(o[(u+1)*n+d],o[u*n+d+1]);const c=[];let i=0,h=0;for(;i<s&&h<r;)e[i]===t[h]?(c.push([i,h]),i++,h++):o[(i+1)*n+h]>=o[i*n+h+1]?i++:h++;return c}function rt(e,t){return tt.find(s=>[e,t].every(r=>{const n=new Set;return r.every(o=>{if(!_(o)||!F(o,s))return!1;const c=o[s];return typeof c!="string"&&typeof c!="number"||n.has(c)?!1:(n.add(c),!0)})}))}function ee(e,t,s,r,n,o){const c={type:"conflict",id:JSON.stringify(s),key:t,label:r,path:s,kind:e==="left"?"left-only":"right-only",hasLeft:e==="left",hasRight:e==="right",left:e==="left"?n:void 0,right:e==="right"?n:void 0};return o.push(c),c}function Ee(e,t,s,r,n,o){if(j(r,n))return{type:"equal",key:e,value:r};if(_(r)&&_(n))return{type:"container",key:e,container:"object",children:xe(r,n,t,s,o)};if(Array.isArray(r)&&Array.isArray(n))return{type:"container",key:e,container:"array",children:lt(r,n,t,s,o)};const c={type:"conflict",id:JSON.stringify(t),key:e,label:s,path:t,kind:"modified",hasLeft:!0,hasRight:!0,left:r,right:n};return o.push(c),c}function xe(e,t,s,r,n){const o=[];for(const c of st(Object.keys(e),Object.keys(t))){const i=F(e,c),h=F(t,c),u=[...s,c],d=ot(r,c);i&&h?o.push(Ee(c,u,d,e[c],t[c],n)):i?o.push(ee("left",c,u,d,e[c],n)):o.push(ee("right",c,u,d,t[c],n))}return o}function lt(e,t,s,r,n){const o=rt(e,t),c=(S,a)=>S.map(O=>a?`${typeof O[a]}:${O[a]}`:ce(O));let i=Re(c(e,o),c(t,o)),h=o!==void 0;h&&i.length===0&&(h=!1,i=Re(c(e,void 0),c(t,void 0)));const u=[];let d=0,$=0;const k=S=>`${r}[${S}]`,M=()=>[...s,u.length],A=(S,a)=>{u.push(Ee(null,M(),k(a),e[S],t[a],n))},w=(S,a)=>{const O=h?0:Math.min(S-d,a-$);for(let v=0;v<O;v++)A(d+v,$+v);for(let v=d+O;v<S;v++)u.push(ee("left",null,M(),k(v),e[v],n));for(let v=$+O;v<a;v++)u.push(ee("right",null,M(),k(v),t[v],n));d=S,$=a};for(const[S,a]of i)w(S,a),A(S,a),d=S+1,$=a+1;return w(e.length,t.length),u}function Me(e,t){const s=[];return{children:xe(e,t,[],"",s),conflicts:s}}function Z(e,t){const s=t??"right";return ue(s)?{present:!0,value:s.custom,side:null,custom:!0}:s==="left"&&e.hasLeft?{present:!0,value:e.left,side:"left"}:s==="right"&&e.hasRight?{present:!0,value:e.right,side:"right"}:{present:!1,side:null}}function ct(e,t){const s=Z(e,t);return s.custom?"custom":s.side??"deleted"}function Y(e,t){const s={};for(const r of e.conflicts)s[r.id]=t;return s}function Te(e,t,s){const r={},n=[];for(const o of e){let c;if(o.type==="equal")c=ie(o.value);else if(o.type==="container")c=Te(o.children,t,o.container);else{const i=Z(o,t[o.id]);if(!i.present)continue;c=ie(i.value)}s==="array"?n.push(c):o.key!==null&&(r[o.key]=c)}return s==="array"?n:r}function ae(e,t){return Te(e.children,t,"object")}const Oe=Symbol("unknown");function $e(e){return e.hasLeft&&e.hasRight?"deleted":e.hasLeft?"right":"left"}function je(e,t,s,r){for(const n of e){if(n.type==="equal")continue;if(n.type==="container"){const i=s==="object"&&n.key!==null&&_(t)&&F(t,n.key)?t[n.key]:Oe;je(n.children,i,n.container,r);continue}if(t===Oe){r[n.id]="right";continue}let o=!1,c=!1;if(s==="object"){if(n.key===null||!_(t)||!F(t,n.key)){r[n.id]=$e(n);continue}const i=t[n.key];if(o=n.hasLeft&&j(i,n.left),c=n.hasRight&&j(i,n.right),!o&&!c){r[n.id]={custom:ie(i)};continue}}else{const i=Array.isArray(t)?t:[];if(o=n.hasLeft&&i.some(h=>j(h,n.left)),c=n.hasRight&&i.some(h=>j(h,n.right)),!o&&!c){r[n.id]=$e(n);continue}}r[n.id]=o&&!c?"left":"right"}}function Pe(e,t){let s=0,r=0;for(const o of e.conflicts)F(t,o.id)&&(s++,ue(t[o.id])&&r++);const n=e.conflicts.length;return{total:n,resolved:s,unresolved:n-s,edited:r,allResolved:s===n}}function Ke(e,t){if(!t)return Y(e,"right");for(const r of["left","right"]){const n=Y(e,r);if(j(t,ae(e,n)))return n}const s=Y(e,"right");return je(e.children,t,"object",s),s}function H(e,t,s,r){const n=Le.repeat(s),o=(JSON.stringify(t,null,2)??"null").split(`
2
- `),c=o.length-1,i=e===null?"":`${JSON.stringify(e)}: `;return o.map((h,u)=>{const d=u===0?`${i}${h}`:h;return`${n}${d}${u===c&&r?",":""}`})}function De(e,t){const s=[],r=[],n=(u,d,$,k=null)=>{s.push({index:s.length,blockId:k,blockRow:0,blockSize:1,left:u,right:d,result:$,leftNo:null,rightNo:null,resultNo:null})},o=(u,d)=>{const $=u.map(a=>a.type!=="conflict"||a.hasLeft),k=u.map(a=>a.type!=="conflict"||a.hasRight),M=u.map(a=>a.type!=="conflict"||Z(a,t[a.id]).present),A=$.lastIndexOf(!0),w=k.lastIndexOf(!0),S=M.lastIndexOf(!0);u.forEach((a,O)=>{const v=O!==A,N=O!==w,C=O!==S;if(a.type==="equal"){const g=H(a.key,a.value,d,v),b=H(a.key,a.value,d,N),D=H(a.key,a.value,d,C);g.forEach((J,E)=>{n(J,b[E],D[E])});return}if(a.type==="container"){const g=Le.repeat(d),b=a.key===null?"":`${JSON.stringify(a.key)}: `,[D,J]=a.container==="array"?["[","]"]:["{","}"],E=`${g}${b}${D}`;n(E,E,E),o(a.children,d+1),n(`${g}${J}${v?",":""}`,`${g}${J}${N?",":""}`,`${g}${J}${C?",":""}`);return}const z=a.hasLeft?H(a.key,a.left,d,v):[],T=a.hasRight?H(a.key,a.right,d,N):[],I=Z(a,t[a.id]),P=I.present?H(a.key,I.value,d,C):[],K=Math.max(z.length,T.length,P.length),W=s.length;for(let g=0;g<K;g++)n(z[g]??null,T[g]??null,P[g]??null,a.id);r.push({id:a.id,entry:a,kind:a.kind,start:W,size:K,selection:ct(a,t[a.id])})})};n("{","{","{"),o(e.children,1),n("}","}","}");for(const u of r)for(let d=0;d<u.size;d++)s[u.start+d].blockRow=d,s[u.start+d].blockSize=u.size;let c=0,i=0,h=0;for(const u of s)u.leftNo=u.left===null?null:++c,u.rightNo=u.right===null?null:++i,u.resultNo=u.result===null?null:++h;return{rows:s,blocks:r}}const _e=y.createContext(null);function it({viewer:e,children:t}){return Qe.jsx(_e.Provider,{value:e,children:t})}function ut(){const e=y.useContext(_e);if(!e)throw new Error("useMergeViewerContext must be used inside a MergeViewerProvider");return e}const at="minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax(0, 1fr)",dt="3.5ch 3.5rem minmax(0, 1fr)",ft={current:{code:"1",actions:"2",number:"3",header:"1 / 4",fold:"1 / 4"},result:{number:"4",code:"5",header:"4 / 6",fold:"4 / 6"},incoming:{number:"6",actions:"7",code:"8",header:"6 / 9",fold:"6 / 9"}},ht={current:{number:"1",actions:"2",code:"3",header:"1 / -1",fold:"1 / -1"},incoming:{number:"1",actions:"2",code:"3",header:"1 / -1",fold:"1 / -1"},result:{number:"1",code:"2 / 4",header:"1 / -1",fold:"1 / -1"}},gt={current:0,incoming:1,result:2};function Q(e,t,s,r,n){const c=(e==="stacked"?ht:ft)[t][s]??"auto";if(e==="horizontal")return{gridRow:s==="header"?1:r+2,gridColumn:c};const i=gt[t]*(n+1);return{gridRow:s==="header"?i+1:i+r+2,gridColumn:c}}function ze(e){return e==="stacked"?dt:at}const pt=100;function Je({currentJson:e,incomingJson:t,initialMergedJson:s,startUnresolved:r,decisions:n,onDecisionsChange:o}){const c=y.useMemo(()=>JSON.stringify(e),[e]),i=y.useMemo(()=>JSON.stringify(t),[t]),h=y.useMemo(()=>s===void 0?void 0:JSON.stringify(s),[s]),u=y.useMemo(()=>Me(e,t),[c,i]),d=y.useMemo(()=>Ke(u,s),[u,h]),$=r??s===void 0,k=()=>$?{}:d,[M,A]=y.useState(k),w=y.useRef({past:[],future:[]}),[,S]=y.useState(0),[a,O]=y.useState(u);a!==u&&(O(u),A(k()),w.current={past:[],future:[]});const v=n!==void 0,N=v?n:M,C=y.useRef(N);C.current=N;const z=y.useRef(o);z.current=o;const T=g=>{C.current=g,v||A(g),z.current?.(g),S(b=>b+1)},I=g=>{if(j(g,C.current))return;const b=w.current;b.past.push(C.current),b.past.length>pt&&b.past.shift(),b.future=[],T(g)},P=y.useMemo(()=>({...d,...N}),[d,N]),K=y.useMemo(()=>ae(u,P),[u,P]),W=y.useMemo(()=>Pe(u,N),[u,N]);return{tree:u,decisions:N,selection:P,merged:K,status:W,isResolved:g=>Object.hasOwn(N,g),choose:(g,b)=>I({...C.current,[g]:b}),revert:g=>{const b={...C.current},D=k();Object.hasOwn(D,g)?b[g]=D[g]:delete b[g],I(b)},applyAll:g=>I(Y(u,g)),reset:()=>I(k()),undo:()=>{const g=w.current,b=g.past.pop();b&&(g.future.push(C.current),T(b))},redo:()=>{const g=w.current,b=g.future.pop();b&&(g.past.push(C.current),T(b))},canUndo:w.current.past.length>0,canRedo:w.current.future.length>0}}const yt=900,mt=3,vt=typeof window>"u"?y.useEffect:y.useLayoutEffect,le=e=>e?"":void 0;function bt({onMergeChange:e,editable:t=!1,labels:s,layout:r="responsive",stackBelow:n=yt,collapseUnchanged:o=!1,...c}){const i=y.useMemo(()=>Ie(s),[s]),h=Je(c),{tree:u,selection:d,merged:$,status:k,isResolved:M}=h,A=y.useMemo(()=>De(u,d),[u,d]),w=y.useMemo(()=>{const l=new Map;for(const f of A.blocks)l.set(f.id,f);return l},[A]),S=y.useRef(e);S.current=e,y.useEffect(()=>{S.current?.($,k)},[$,k]);const[a,O]=y.useState(null),[v,N]=y.useState(null),[C,z]=y.useState(!1);vt(()=>{if(r!=="responsive"||!v||typeof ResizeObserver>"u")return;const l=new ResizeObserver(([f])=>{z(f.contentRect.width<n)});return l.observe(v),()=>l.disconnect()},[r,v,n]);const T=r==="vertical"||r==="responsive"&&C,I=T?"stacked":"horizontal",P=typeof o=="number"?o:mt,[K,W]=y.useState(o!==!1),[g,b]=y.useState(()=>new Set),D=y.useMemo(()=>K?we(A.rows,P,g):A.rows.map(l=>({type:"row",row:l})),[K,A,P,g]),J=l=>{b(f=>new Set(f).add(l))},[E,te]=y.useState(null),[de,ne]=y.useState(null),V=y.useMemo(()=>u.conflicts.map(l=>l.id),[u]),Ue=l=>{const f=Array.from(a?.querySelectorAll("[data-merge-block]")??[]).filter(L=>L.dataset.mergeBlock===l),p=f.find(L=>getComputedStyle(L).display!=="none")??f[0],R=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;p?.scrollIntoView?.({block:"center",behavior:R?"auto":"smooth"})},fe=l=>{te(l),Ue(l)},he=(l,f)=>{if(l.length===0)return null;const p=E===null?-1:V.indexOf(E);if(f==="next")return l.find(L=>V.indexOf(L)>p)??l[0];const R=p===-1?V.length:p;return[...l].reverse().find(L=>V.indexOf(L)<R)??l[l.length-1]},Fe=()=>{const l=he(V.filter(f=>!M(f)),"next");return l===null?!1:(fe(l),!0)},Ve=l=>{const f=he(V,l);f!==null&&fe(f)},G=(l,f)=>{h.choose(l,f),te(l)},ge=l=>{const f=w.get(l);if(!f)return"null";const p=Z(f.entry,d[l]),R=p.present?p.value:f.entry.hasRight?f.entry.right:f.entry.left;return JSON.stringify(R,null,2)??"null"},pe=l=>{te(l),ne(l)},qe=()=>ne(null),Be=(l,f)=>{let p;try{p=JSON.parse(f)}catch(R){return R instanceof Error?R.message:"Invalid JSON"}return G(l,{custom:p}),ne(null),null},oe=(l,f,p,R,L)=>{const m=f.blockId?w.get(f.blockId):void 0,re=!!m&&f.blockRow===0,Ye=!!m&&f.blockRow===f.blockSize-1,X=m?M(m.id):!0,x=m?.entry,Ze=l==="current"?m?.selection==="left":l==="incoming"?m?.selection==="right":!0;let q="unchanged";m&&(p===null?q="filler":l==="result"&&!X?q="pending":l==="result"&&m.selection==="custom"?q="edited":X&&!Ze?q="rejected":q="changed");const U={};if(m&&x&&re){const be=()=>({label:i.removeChange(x.label),pressed:X&&m.selection==="deleted",run:()=>G(m.id,"deleted")}),ke=(Se,Xe)=>({label:Xe,pressed:X&&m.selection===Se,run:()=>G(m.id,Se)});l==="current"&&x.hasLeft?(U.remove=be(),U.accept=ke("left",i.acceptCurrent(x.label))):l==="incoming"&&x.hasRight?(U.accept=ke("right",i.acceptIncoming(x.label)),U.remove=be()):l==="result"&&t&&(m.selection==="custom"&&(U.revert={label:i.revertEdit(x.label),pressed:!1,run:()=>h.revert(m.id)}),U.edit={label:i.editChange(x.label),pressed:!1,run:()=>pe(m.id)})}const Ge=l==="result"&&t&&re&&m!==void 0&&de===m.id;return{pane:l,text:p,segments:p===null?[]:Ce(p,l!=="result"&&m?.kind==="modified"?L:void 0),lineNo:R,state:q,kind:m?.kind??null,blockId:m?.id??null,blockStart:re,blockEnd:Ye,active:!!m&&E===m?.id,actions:U,editor:Ge&&m&&x?{title:i.editorTitle(x.label),inputLabel:i.editorInput(x.label),initialText:ge(m.id)}:void 0}},ye=D.map((l,f)=>{if(l.type==="fold")return{type:"fold",key:`fold-${l.key}`,index:f,hidden:l.hidden,label:i.unchangedLines(l.hidden),showLabel:i.showUnchanged(l.hidden),expand:()=>J(l.key)};const{row:p}=l;return{type:"row",key:`row-${p.index}`,index:f,row:p,current:oe("current",p,p.left,p.leftNo,p.right),result:oe("result",p,p.result,p.resultNo,null),incoming:oe("incoming",p,p.right,p.rightNo,p.left)}}),me=k.total,ve=me===0?"empty":k.allResolved?"resolved":"pending",He=me===0?i.noChanges:k.allResolved?i.allResolved(k):i.unresolved(k),We=l=>{const f=l.target;if(!(l.ctrlKey||l.metaKey)||f.closest("textarea, input"))return;const p=l.key.toLowerCase();p==="z"&&!l.shiftKey?(l.preventDefault(),h.undo()):(p==="z"&&l.shiftKey||p==="y")&&(l.preventDefault(),h.redo())},se=ye.length;return{...h,choose:G,items:ye,labels:i,stacked:T,statusState:ve,statusText:He,collapsed:K,toggleCollapsed:()=>W(l=>!l),activeId:E,goToChange:Ve,goToNextUnresolved:Fe,editable:t,editingId:de,startEdit:pe,cancelEdit:qe,editorText:ge,commitEdit:Be,getRootProps:()=>({ref:O,onKeyDown:We,"data-merge-status":ve}),getScrollProps:()=>({ref:N}),getGridProps:()=>({style:{display:"grid",gridTemplateColumns:ze(I)},"data-layout":I}),getHeaderProps:l=>({style:{...Q(I,l,"header",0,se)},"data-pane":l,"data-column":"header"}),getCellProps:(l,f,p)=>{const R=l[f],L={...Q(I,f,p,l.index,se)};return T&&R.state==="filler"&&(L.display="none"),{style:L,"data-pane":f,"data-column":p,"data-state":R.state,"data-kind":R.kind??void 0,"data-block-start":le(R.blockStart),"data-block-end":le(R.blockEnd),"data-active":le(R.active),"data-merge-block":p==="code"&&R.blockStart?R.blockId??void 0:void 0}},getFoldProps:(l,f)=>({type:"button",style:{...Q(I,f,"fold",l.index,se)},tabIndex:f==="current"?0:-1,"aria-hidden":f==="current"?void 0:!0,"aria-label":l.showLabel,"data-pane":f,"data-column":"fold",onClick:l.expand})}}exports.MergeViewerProvider=it;exports.buildMergeLayout=De;exports.buildMergeTree=Me;exports.buildMergedJson=ae;exports.deepEqual=j;exports.defaultLabels=Ae;exports.foldRows=we;exports.getMergeStatus=Pe;exports.gridTemplateColumns=ze;exports.initialSelection=Ke;exports.inlineSegments=Ce;exports.isCustomChoice=ue;exports.placeCell=Q;exports.resolveLabels=Ie;exports.selectAll=Y;exports.splitInlineEdit=Ne;exports.useMergeConflicts=Je;exports.useMergeViewer=bt;exports.useMergeViewerContext=ut;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const nt=require("react/jsx-runtime"),y=require("react"),ot=3;function ie(e,t,s){const r=[],n=(c,i)=>{for(let h=c;h<i;h++)r.push({type:"row",row:e[h]})};let o=0;for(;o<e.length;){if(e[o].blockId!==null){r.push({type:"row",row:e[o]}),o++;continue}let c=o;for(;c<e.length&&e[c].blockId===null;)c++;const i=o===0?1:t,h=c===e.length?1:t,u=c-o-i-h,f=`${e[o-1]?.blockId??"start"}>${e[c]?.blockId??"end"}`;u<ot||s.has(f)?n(o,c):(n(o,o+i),r.push({type:"fold",key:f,hidden:u}),n(c-h,c)),o=c}return r}function Ce(e,t){if(t===null)return[e,"",""];const s=e.endsWith(",")?",":"",r=s?e.slice(0,-1):e,n=t.endsWith(",")?t.slice(0,-1):t;let o=0;const c=Math.min(r.length,n.length);for(;o<c&&r[o]===n[o];)o++;let i=r.length,h=n.length;for(;i>o&&h>o&&r[i-1]===n[h-1];)i--,h--;return[r.slice(0,o),r.slice(o,i),r.slice(i)+s]}function Ae(e,t){if(t==null)return[{text:e,changed:!1}];const[s,r,n]=Ce(e,t);if(!r)return[{text:e,changed:!1}];const o=[];return s&&o.push({text:s,changed:!1}),o.push({text:r,changed:!0}),n&&o.push({text:n,changed:!1}),o}function B(e,t,s){return e===1?t:s}const Ie={current:"Current",result:"Result",incoming:"Incoming",applyAllCurrent:"Apply all from current",applyAllIncoming:"Apply all from incoming",previousChange:"Previous change",nextChange:"Next change",hideUnchanged:"Hide unchanged lines",undo:"Undo",redo:"Redo",summary:({total:e})=>e===0?"No differences":`${e} ${B(e,"change","changes")}`,noChanges:"No differences. Nothing to merge.",unresolved:({unresolved:e,total:t})=>`${e} of ${t} ${B(t,"change","changes")} still ${B(e,"needs","need")} a decision.`,allResolved:({total:e})=>`All ${e} ${B(e,"change","changes")} resolved. Safe to merge.`,nextUnresolved:"Next unresolved",unchangedLines:e=>`${e} unchanged ${B(e,"line","lines")}`,showUnchanged:e=>`Show ${e} unchanged ${B(e,"line","lines")}`,acceptCurrent:e=>`Accept current ${e}`,acceptIncoming:e=>`Accept incoming ${e}`,removeChange:e=>`Remove ${e} from result`,editChange:e=>`Edit ${e} in result`,revertEdit:e=>`Revert edit of ${e}`,editorTitle:e=>`Edit ${e} (JSON value)`,editorInput:e=>`JSON value of ${e}`,apply:"Apply",cancel:"Cancel"};function Le(e){const t={...Ie};for(const[s,r]of Object.entries(e??{}))r!==void 0&&(t[s]=r);return t}const Ee=" ",st=["id","@id","key","name","code","uuid","slug"];function de(e){return typeof e=="object"&&e!==null&&"custom"in e}function U(e,t){return Object.hasOwn(e,t)}function z(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function P(e,t){if(e===t)return!0;if(Array.isArray(e)||Array.isArray(t))return Array.isArray(e)&&Array.isArray(t)&&e.length===t.length&&e.every((s,r)=>P(s,t[r]));if(z(e)&&z(t)){const s=Object.keys(e),r=Object.keys(t);return s.length===r.length&&s.every(n=>U(t,n)&&P(e[n],t[n]))}return!1}function ue(e){return Array.isArray(e)?`[${e.map(ue).join(",")}]`:z(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${ue(e[t])}`).join(",")}}`:JSON.stringify(e)??"null"}function ae(e){return e===void 0?e:JSON.parse(JSON.stringify(e))}const rt=/^[A-Za-z_$][\w$]*$/;function lt(e,t){return rt.test(t)?e?`${e}.${t}`:t:`${e}[${JSON.stringify(t)}]`}function ct(e,t){const s=[...t],r=new Set(t);let n=-1;for(const o of e){if(r.has(o)){n=s.indexOf(o);continue}n+=1,s.splice(n,0,o),r.add(o)}return s}function we(e,t){const s=e.length,r=t.length,n=r+1,o=new Uint32Array((s+1)*n);for(let u=s-1;u>=0;u--)for(let f=r-1;f>=0;f--)o[u*n+f]=e[u]===t[f]?o[(u+1)*n+f+1]+1:Math.max(o[(u+1)*n+f],o[u*n+f+1]);const c=[];let i=0,h=0;for(;i<s&&h<r;)e[i]===t[h]?(c.push([i,h]),i++,h++):o[(i+1)*n+h]>=o[i*n+h+1]?i++:h++;return c}function it(e,t){return st.find(s=>[e,t].every(r=>{const n=new Set;return r.every(o=>{if(!z(o)||!U(o,s))return!1;const c=o[s];return typeof c!="string"&&typeof c!="number"||n.has(c)?!1:(n.add(c),!0)})}))}function te(e,t,s,r,n,o){const c={type:"conflict",id:JSON.stringify(s),key:t,label:r,path:s,kind:e==="left"?"left-only":"right-only",hasLeft:e==="left",hasRight:e==="right",left:e==="left"?n:void 0,right:e==="right"?n:void 0};return o.push(c),c}function xe(e,t,s,r,n,o){if(P(r,n))return{type:"equal",key:e,value:r};if(z(r)&&z(n))return{type:"container",key:e,container:"object",children:Me(r,n,t,s,o)};if(Array.isArray(r)&&Array.isArray(n))return{type:"container",key:e,container:"array",children:ut(r,n,t,s,o)};const c={type:"conflict",id:JSON.stringify(t),key:e,label:s,path:t,kind:"modified",hasLeft:!0,hasRight:!0,left:r,right:n};return o.push(c),c}function Me(e,t,s,r,n){const o=[];for(const c of ct(Object.keys(e),Object.keys(t))){const i=U(e,c),h=U(t,c),u=[...s,c],f=lt(r,c);i&&h?o.push(xe(c,u,f,e[c],t[c],n)):i?o.push(te("left",c,u,f,e[c],n)):o.push(te("right",c,u,f,t[c],n))}return o}function ut(e,t,s,r,n){const o=it(e,t),c=(S,a)=>S.map(w=>a?`${typeof w[a]}:${w[a]}`:ue(w));let i=we(c(e,o),c(t,o)),h=o!==void 0;h&&i.length===0&&(h=!1,i=we(c(e,void 0),c(t,void 0)));const u=[];let f=0,$=0;const k=S=>`${r}[${S}]`,M=()=>[...s,u.length],R=(S,a)=>{u.push(xe(null,M(),k(a),e[S],t[a],n))},N=(S,a)=>{const w=h?0:Math.min(S-f,a-$);for(let v=0;v<w;v++)R(f+v,$+v);for(let v=f+w;v<S;v++)u.push(te("left",null,M(),k(v),e[v],n));for(let v=$+w;v<a;v++)u.push(te("right",null,M(),k(v),t[v],n));f=S,$=a};for(const[S,a]of i)N(S,a),R(S,a),f=S+1,$=a+1;return N(e.length,t.length),u}function Te(e,t){const s=[];return{children:Me(e,t,[],"",s),conflicts:s}}function Z(e,t){const s=t??"right";return de(s)?{present:!0,value:s.custom,side:null,custom:!0}:s==="left"&&e.hasLeft?{present:!0,value:e.left,side:"left"}:s==="right"&&e.hasRight?{present:!0,value:e.right,side:"right"}:{present:!1,side:null}}function at(e,t){const s=Z(e,t);return s.custom?"custom":s.side??"deleted"}function Y(e,t){const s={};for(const r of e.conflicts)s[r.id]=t;return s}function je(e,t,s){const r={},n=[];for(const o of e){let c;if(o.type==="equal")c=ae(o.value);else if(o.type==="container")c=je(o.children,t,o.container);else{const i=Z(o,t[o.id]);if(!i.present)continue;c=ae(i.value)}s==="array"?n.push(c):o.key!==null&&(r[o.key]=c)}return s==="array"?n:r}function fe(e,t){return je(e.children,t,"object")}const $e=Symbol("unknown");function Ne(e){return e.hasLeft&&e.hasRight?"deleted":e.hasLeft?"right":"left"}function Pe(e,t,s,r){for(const n of e){if(n.type==="equal")continue;if(n.type==="container"){const i=s==="object"&&n.key!==null&&z(t)&&U(t,n.key)?t[n.key]:$e;Pe(n.children,i,n.container,r);continue}if(t===$e){r[n.id]="right";continue}let o=!1,c=!1;if(s==="object"){if(n.key===null||!z(t)||!U(t,n.key)){r[n.id]=Ne(n);continue}const i=t[n.key];if(o=n.hasLeft&&P(i,n.left),c=n.hasRight&&P(i,n.right),!o&&!c){r[n.id]={custom:ae(i)};continue}}else{const i=Array.isArray(t)?t:[];if(o=n.hasLeft&&i.some(h=>P(h,n.left)),c=n.hasRight&&i.some(h=>P(h,n.right)),!o&&!c){r[n.id]=Ne(n);continue}}r[n.id]=o&&!c?"left":"right"}}function Ke(e,t){let s=0,r=0;for(const o of e.conflicts)U(t,o.id)&&(s++,de(t[o.id])&&r++);const n=e.conflicts.length;return{total:n,resolved:s,unresolved:n-s,edited:r,allResolved:s===n}}function De(e,t){if(!t)return Y(e,"right");for(const r of["left","right"]){const n=Y(e,r);if(P(t,fe(e,n)))return n}const s=Y(e,"right");return Pe(e.children,t,"object",s),s}function H(e,t,s,r){const n=Ee.repeat(s),o=(JSON.stringify(t,null,2)??"null").split(`
2
+ `),c=o.length-1,i=e===null?"":`${JSON.stringify(e)}: `;return o.map((h,u)=>{const f=u===0?`${i}${h}`:h;return`${n}${f}${u===c&&r?",":""}`})}function _e(e,t){const s=[],r=[],n=(u,f,$,k=null)=>{s.push({index:s.length,blockId:k,blockRow:0,blockSize:1,left:u,right:f,result:$,leftNo:null,rightNo:null,resultNo:null})},o=(u,f)=>{const $=u.map(a=>a.type!=="conflict"||a.hasLeft),k=u.map(a=>a.type!=="conflict"||a.hasRight),M=u.map(a=>a.type!=="conflict"||Z(a,t[a.id]).present),R=$.lastIndexOf(!0),N=k.lastIndexOf(!0),S=M.lastIndexOf(!0);u.forEach((a,w)=>{const v=w!==R,C=w!==N,A=w!==S;if(a.type==="equal"){const g=H(a.key,a.value,f,v),b=H(a.key,a.value,f,C),j=H(a.key,a.value,f,A);g.forEach((_,D)=>{n(_,b[D],j[D])});return}if(a.type==="container"){const g=Ee.repeat(f),b=a.key===null?"":`${JSON.stringify(a.key)}: `,[j,_]=a.container==="array"?["[","]"]:["{","}"],D=`${g}${b}${j}`;n(D,D,D),o(a.children,f+1),n(`${g}${_}${v?",":""}`,`${g}${_}${C?",":""}`,`${g}${_}${A?",":""}`);return}const F=a.hasLeft?H(a.key,a.left,f,v):[],T=a.hasRight?H(a.key,a.right,f,C):[],I=Z(a,t[a.id]),E=I.present?H(a.key,I.value,f,A):[],K=Math.max(F.length,T.length,E.length),W=s.length;for(let g=0;g<K;g++)n(F[g]??null,T[g]??null,E[g]??null,a.id);r.push({id:a.id,entry:a,kind:a.kind,start:W,size:K,selection:at(a,t[a.id])})})};n("{","{","{"),o(e.children,1),n("}","}","}");for(const u of r)for(let f=0;f<u.size;f++)s[u.start+f].blockRow=f,s[u.start+f].blockSize=u.size;let c=0,i=0,h=0;for(const u of s)u.leftNo=u.left===null?null:++c,u.rightNo=u.right===null?null:++i,u.resultNo=u.result===null?null:++h;return{rows:s,blocks:r}}const ze=y.createContext(null);function dt({viewer:e,children:t}){return nt.jsx(ze.Provider,{value:e,children:t})}function ft(){const e=y.useContext(ze);if(!e)throw new Error("useMergeViewerContext must be used inside a MergeViewerProvider");return e}const ht="minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax(0, 1fr)",gt="3.5ch 3.5rem minmax(0, 1fr)",pt={current:{code:"1",actions:"2",number:"3",header:"1 / 4",fold:"1 / 4"},result:{number:"4",code:"5",header:"4 / 6",fold:"4 / 6"},incoming:{number:"6",actions:"7",code:"8",header:"6 / 9",fold:"6 / 9"}},yt={current:{number:"1",actions:"2",code:"3",header:"1 / -1",fold:"1 / -1"},incoming:{number:"1",actions:"2",code:"3",header:"1 / -1",fold:"1 / -1"},result:{number:"1",code:"2 / 4",header:"1 / -1",fold:"1 / -1"}},mt={current:0,incoming:1,result:2};function ee(e,t,s,r,n){const c=(e==="stacked"?yt:pt)[t][s]??"auto";if(e==="horizontal")return{gridRow:s==="header"?1:r+2,gridColumn:c};const i=mt[t]*(n+1);return{gridRow:s==="header"?i+1:i+r+2,gridColumn:c}}function Fe(e){return e==="stacked"?gt:ht}const vt=100;function Je({currentJson:e,incomingJson:t,initialMergedJson:s,startUnresolved:r,decisions:n,onDecisionsChange:o}){const c=y.useMemo(()=>JSON.stringify(e),[e]),i=y.useMemo(()=>JSON.stringify(t),[t]),h=y.useMemo(()=>s===void 0?void 0:JSON.stringify(s),[s]),u=y.useMemo(()=>Te(e,t),[c,i]),f=y.useMemo(()=>De(u,s),[u,h]),$=r??s===void 0,k=()=>$?{}:f,[M,R]=y.useState(k),N=y.useRef({past:[],future:[]}),[,S]=y.useState(0),[a,w]=y.useState(u);a!==u&&(w(u),R(k()),N.current={past:[],future:[]});const v=n!==void 0,C=v?n:M,A=y.useRef(C);A.current=C;const F=y.useRef(o);F.current=o;const T=g=>{A.current=g,v||R(g),F.current?.(g),S(b=>b+1)},I=g=>{if(P(g,A.current))return;const b=N.current;b.past.push(A.current),b.past.length>vt&&b.past.shift(),b.future=[],T(g)},E=y.useMemo(()=>({...f,...C}),[f,C]),K=y.useMemo(()=>fe(u,E),[u,E]),W=y.useMemo(()=>Ke(u,C),[u,C]);return{tree:u,decisions:C,selection:E,merged:K,status:W,isResolved:g=>Object.hasOwn(C,g),choose:(g,b)=>I({...A.current,[g]:b}),revert:g=>{const b={...A.current},j=k();Object.hasOwn(j,g)?b[g]=j[g]:delete b[g],I(b)},applyAll:g=>I(Y(u,g)),reset:()=>I(k()),undo:()=>{const g=N.current,b=g.past.pop();b&&(g.future.push(A.current),T(b))},redo:()=>{const g=N.current,b=g.future.pop();b&&(g.past.push(A.current),T(b))},canUndo:N.current.past.length>0,canRedo:N.current.future.length>0}}const bt=900,kt=3,St=typeof window>"u"?y.useEffect:y.useLayoutEffect,ce=e=>e?"":void 0;function Ot({onMergeChange:e,editable:t=!1,labels:s,layout:r="responsive",stackBelow:n=bt,collapseUnchanged:o=!1,...c}){const i=y.useMemo(()=>Le(s),[s]),h=Je(c),{tree:u,selection:f,merged:$,status:k,isResolved:M}=h,R=y.useMemo(()=>_e(u,f),[u,f]),N=y.useMemo(()=>{const l=new Map;for(const d of R.blocks)l.set(d.id,d);return l},[R]),S=y.useRef(e);S.current=e,y.useEffect(()=>{S.current?.($,k)},[$,k]);const[a,w]=y.useState(null),[v,C]=y.useState(null),[A,F]=y.useState(!1);St(()=>{if(r!=="responsive"||!v||typeof ResizeObserver>"u")return;const l=new ResizeObserver(([d])=>{F(d.contentRect.width<n)});return l.observe(v),()=>l.disconnect()},[r,v,n]);const T=r==="vertical"||r==="responsive"&&A,I=T?"stacked":"horizontal",E=typeof o=="number"?o:kt,[K,W]=y.useState(o!==!1),[g,b]=y.useState(()=>new Set),j=y.useMemo(()=>K?ie(R.rows,E,g):R.rows.map(l=>({type:"row",row:l})),[K,R,E,g]),_=l=>l.filter(d=>d.type==="fold").length,D=y.useMemo(()=>K&&_(j)===_(ie(R.rows,E,new Set)),[K,j,R,E]),Ue=()=>{b(new Set),W(!D)},Ve=l=>{b(d=>new Set(d).add(l))},[G,ne]=y.useState(null),[he,oe]=y.useState(null),V=y.useMemo(()=>u.conflicts.map(l=>l.id),[u]),qe=l=>{const d=Array.from(a?.querySelectorAll("[data-merge-block]")??[]).filter(L=>L.dataset.mergeBlock===l),p=d.find(L=>getComputedStyle(L).display!=="none")??d[0],O=window.matchMedia?.("(prefers-reduced-motion: reduce)").matches??!1;p?.scrollIntoView?.({block:"center",behavior:O?"auto":"smooth"})},ge=l=>{ne(l),qe(l)},pe=(l,d)=>{if(l.length===0)return null;const p=G===null?-1:V.indexOf(G);if(d==="next")return l.find(L=>V.indexOf(L)>p)??l[0];const O=p===-1?V.length:p;return[...l].reverse().find(L=>V.indexOf(L)<O)??l[l.length-1]},Be=()=>{const l=pe(V.filter(d=>!M(d)),"next");return l===null?!1:(ge(l),!0)},He=l=>{const d=pe(V,l);d!==null&&ge(d)},X=(l,d)=>{h.choose(l,d),ne(l)},ye=l=>{const d=N.get(l);if(!d)return"null";const p=Z(d.entry,f[l]),O=p.present?p.value:d.entry.hasRight?d.entry.right:d.entry.left;return JSON.stringify(O,null,2)??"null"},me=l=>{ne(l),oe(l)},We=()=>oe(null),Ye=(l,d)=>{let p;try{p=JSON.parse(d)}catch(O){return O instanceof Error?O.message:"Invalid JSON"}return X(l,{custom:p}),oe(null),null},se=(l,d,p,O,L)=>{const m=d.blockId?N.get(d.blockId):void 0,le=!!m&&d.blockRow===0,Xe=!!m&&d.blockRow===d.blockSize-1,Q=m?M(m.id):!0,x=m?.entry,Qe=l==="current"?m?.selection==="left":l==="incoming"?m?.selection==="right":!0;let q="unchanged";m&&(p===null?q="filler":l==="result"&&!Q?q="pending":l==="result"&&m.selection==="custom"?q="edited":Q&&!Qe?q="rejected":q="changed");const J={};if(m&&x&&le){const Se=()=>({label:i.removeChange(x.label),pressed:Q&&m.selection==="deleted",run:()=>X(m.id,"deleted")}),Oe=(Re,tt)=>({label:tt,pressed:Q&&m.selection===Re,run:()=>X(m.id,Re)});l==="current"&&x.hasLeft?(J.remove=Se(),J.accept=Oe("left",i.acceptCurrent(x.label))):l==="incoming"&&x.hasRight?(J.accept=Oe("right",i.acceptIncoming(x.label)),J.remove=Se()):l==="result"&&t&&(m.selection==="custom"&&(J.revert={label:i.revertEdit(x.label),pressed:!1,run:()=>h.revert(m.id)}),J.edit={label:i.editChange(x.label),pressed:!1,run:()=>me(m.id)})}const et=l==="result"&&t&&le&&m!==void 0&&he===m.id;return{pane:l,text:p,segments:p===null?[]:Ae(p,l!=="result"&&m?.kind==="modified"?L:void 0),lineNo:O,state:q,kind:m?.kind??null,blockId:m?.id??null,blockStart:le,blockEnd:Xe,active:!!m&&G===m?.id,actions:J,editor:et&&m&&x?{title:i.editorTitle(x.label),inputLabel:i.editorInput(x.label),initialText:ye(m.id)}:void 0}},ve=j.map((l,d)=>{if(l.type==="fold")return{type:"fold",key:`fold-${l.key}`,index:d,hidden:l.hidden,label:i.unchangedLines(l.hidden),showLabel:i.showUnchanged(l.hidden),expand:()=>Ve(l.key)};const{row:p}=l;return{type:"row",key:`row-${p.index}`,index:d,row:p,current:se("current",p,p.left,p.leftNo,p.right),result:se("result",p,p.result,p.resultNo,null),incoming:se("incoming",p,p.right,p.rightNo,p.left)}}),be=k.total,ke=be===0?"empty":k.allResolved?"resolved":"pending",Ze=be===0?i.noChanges:k.allResolved?i.allResolved(k):i.unresolved(k),Ge=l=>{const d=l.target;if(!(l.ctrlKey||l.metaKey)||d.closest("textarea, input"))return;const p=l.key.toLowerCase();p==="z"&&!l.shiftKey?(l.preventDefault(),h.undo()):(p==="z"&&l.shiftKey||p==="y")&&(l.preventDefault(),h.redo())},re=ve.length;return{...h,choose:X,items:ve,labels:i,stacked:T,statusState:ke,statusText:Ze,collapsed:D,toggleCollapsed:Ue,activeId:G,goToChange:He,goToNextUnresolved:Be,editable:t,editingId:he,startEdit:me,cancelEdit:We,editorText:ye,commitEdit:Ye,getRootProps:()=>({ref:w,onKeyDown:Ge,"data-merge-status":ke}),getScrollProps:()=>({ref:C}),getGridProps:()=>({style:{display:"grid",gridTemplateColumns:Fe(I)},"data-layout":I}),getHeaderProps:l=>({style:{...ee(I,l,"header",0,re)},"data-pane":l,"data-column":"header"}),getCellProps:(l,d,p)=>{const O=l[d],L={...ee(I,d,p,l.index,re)};return T&&O.state==="filler"&&(L.display="none"),{style:L,"data-pane":d,"data-column":p,"data-state":O.state,"data-kind":O.kind??void 0,"data-block-start":ce(O.blockStart),"data-block-end":ce(O.blockEnd),"data-active":ce(O.active),"data-merge-block":p==="code"&&O.blockStart?O.blockId??void 0:void 0}},getFoldProps:(l,d)=>({type:"button",style:{...ee(I,d,"fold",l.index,re)},tabIndex:d==="current"?0:-1,"aria-hidden":d==="current"?void 0:!0,"aria-label":l.showLabel,"data-pane":d,"data-column":"fold",onClick:l.expand})}}exports.MergeViewerProvider=dt;exports.buildMergeLayout=_e;exports.buildMergeTree=Te;exports.buildMergedJson=fe;exports.deepEqual=P;exports.defaultLabels=Ie;exports.foldRows=ie;exports.getMergeStatus=Ke;exports.gridTemplateColumns=Fe;exports.initialSelection=De;exports.inlineSegments=Ae;exports.isCustomChoice=de;exports.placeCell=ee;exports.resolveLabels=Le;exports.selectAll=Y;exports.splitInlineEdit=Ce;exports.useMergeConflicts=Je;exports.useMergeViewer=Ot;exports.useMergeViewerContext=ft;
@@ -1,7 +1,7 @@
1
- import { jsx as Ve } from "react/jsx-runtime";
2
- import { useContext as qe, createContext as He, useMemo as L, useState as M, useRef as Q, useEffect as Ne, useLayoutEffect as We } from "react";
3
- const Ye = 3;
4
- function Ze(e, t, r) {
1
+ import { jsx as Ye } from "react/jsx-runtime";
2
+ import { useContext as Ze, createContext as Ge, useMemo as I, useState as K, useRef as ee, useEffect as Ae, useLayoutEffect as Xe } from "react";
3
+ const Qe = 3;
4
+ function $e(e, t, r) {
5
5
  const s = [], n = (c, i) => {
6
6
  for (let h = c; h < i; h++)
7
7
  s.push({ type: "row", row: e[h] });
@@ -15,12 +15,12 @@ function Ze(e, t, r) {
15
15
  let c = o;
16
16
  for (; c < e.length && e[c].blockId === null; )
17
17
  c++;
18
- const i = o === 0 ? 1 : t, h = c === e.length ? 1 : t, u = c - o - i - h, d = `${e[o - 1]?.blockId ?? "start"}>${e[c]?.blockId ?? "end"}`;
19
- u < Ye || r.has(d) ? n(o, c) : (n(o, o + i), s.push({ type: "fold", key: d, hidden: u }), n(c - h, c)), o = c;
18
+ const i = o === 0 ? 1 : t, h = c === e.length ? 1 : t, u = c - o - i - h, f = `${e[o - 1]?.blockId ?? "start"}>${e[c]?.blockId ?? "end"}`;
19
+ u < Qe || r.has(f) ? n(o, c) : (n(o, o + i), s.push({ type: "fold", key: f, hidden: u }), n(c - h, c)), o = c;
20
20
  }
21
21
  return s;
22
22
  }
23
- function Ge(e, t) {
23
+ function et(e, t) {
24
24
  if (t === null)
25
25
  return [e, "", ""];
26
26
  const r = e.endsWith(",") ? "," : "", s = r ? e.slice(0, -1) : e, n = t.endsWith(",") ? t.slice(0, -1) : t;
@@ -33,10 +33,10 @@ function Ge(e, t) {
33
33
  i--, h--;
34
34
  return [s.slice(0, o), s.slice(o, i), s.slice(i) + r];
35
35
  }
36
- function Xe(e, t) {
36
+ function tt(e, t) {
37
37
  if (t == null)
38
38
  return [{ text: e, changed: !1 }];
39
- const [r, s, n] = Ge(e, t);
39
+ const [r, s, n] = et(e, t);
40
40
  if (!s)
41
41
  return [{ text: e, changed: !1 }];
42
42
  const o = [];
@@ -45,7 +45,7 @@ function Xe(e, t) {
45
45
  function H(e, t, r) {
46
46
  return e === 1 ? t : r;
47
47
  }
48
- const Qe = {
48
+ const nt = {
49
49
  current: "Current",
50
50
  result: "Result",
51
51
  incoming: "Incoming",
@@ -77,44 +77,44 @@ const Qe = {
77
77
  apply: "Apply",
78
78
  cancel: "Cancel"
79
79
  };
80
- function et(e) {
81
- const t = { ...Qe };
80
+ function ot(e) {
81
+ const t = { ...nt };
82
82
  for (const [r, s] of Object.entries(e ?? {}))
83
83
  s !== void 0 && (t[r] = s);
84
84
  return t;
85
85
  }
86
- const we = " ", tt = ["id", "@id", "key", "name", "code", "uuid", "slug"];
87
- function Ae(e) {
86
+ const Ie = " ", rt = ["id", "@id", "key", "name", "code", "uuid", "slug"];
87
+ function Le(e) {
88
88
  return typeof e == "object" && e !== null && "custom" in e;
89
89
  }
90
90
  function B(e, t) {
91
91
  return Object.hasOwn(e, t);
92
92
  }
93
- function z(e) {
93
+ function F(e) {
94
94
  return typeof e == "object" && e !== null && !Array.isArray(e);
95
95
  }
96
- function D(e, t) {
96
+ function _(e, t) {
97
97
  if (e === t)
98
98
  return !0;
99
99
  if (Array.isArray(e) || Array.isArray(t))
100
- return Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((r, s) => D(r, t[s]));
101
- if (z(e) && z(t)) {
100
+ return Array.isArray(e) && Array.isArray(t) && e.length === t.length && e.every((r, s) => _(r, t[s]));
101
+ if (F(e) && F(t)) {
102
102
  const r = Object.keys(e), s = Object.keys(t);
103
- return r.length === s.length && r.every((n) => B(t, n) && D(e[n], t[n]));
103
+ return r.length === s.length && r.every((n) => B(t, n) && _(e[n], t[n]));
104
104
  }
105
105
  return !1;
106
106
  }
107
- function ue(e) {
108
- return Array.isArray(e) ? `[${e.map(ue).join(",")}]` : z(e) ? `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${ue(e[t])}`).join(",")}}` : JSON.stringify(e) ?? "null";
109
- }
110
107
  function ae(e) {
108
+ return Array.isArray(e) ? `[${e.map(ae).join(",")}]` : F(e) ? `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${ae(e[t])}`).join(",")}}` : JSON.stringify(e) ?? "null";
109
+ }
110
+ function de(e) {
111
111
  return e === void 0 ? e : JSON.parse(JSON.stringify(e));
112
112
  }
113
- const nt = /^[A-Za-z_$][\w$]*$/;
114
- function ot(e, t) {
115
- return nt.test(t) ? e ? `${e}.${t}` : t : `${e}[${JSON.stringify(t)}]`;
113
+ const st = /^[A-Za-z_$][\w$]*$/;
114
+ function lt(e, t) {
115
+ return st.test(t) ? e ? `${e}.${t}` : t : `${e}[${JSON.stringify(t)}]`;
116
116
  }
117
- function rt(e, t) {
117
+ function ct(e, t) {
118
118
  const r = [...t], s = new Set(t);
119
119
  let n = -1;
120
120
  for (const o of e) {
@@ -126,23 +126,23 @@ function rt(e, t) {
126
126
  }
127
127
  return r;
128
128
  }
129
- function Oe(e, t) {
129
+ function Re(e, t) {
130
130
  const r = e.length, s = t.length, n = s + 1, o = new Uint32Array((r + 1) * n);
131
131
  for (let u = r - 1; u >= 0; u--)
132
- for (let d = s - 1; d >= 0; d--)
133
- o[u * n + d] = e[u] === t[d] ? o[(u + 1) * n + d + 1] + 1 : Math.max(o[(u + 1) * n + d], o[u * n + d + 1]);
132
+ for (let f = s - 1; f >= 0; f--)
133
+ o[u * n + f] = e[u] === t[f] ? o[(u + 1) * n + f + 1] + 1 : Math.max(o[(u + 1) * n + f], o[u * n + f + 1]);
134
134
  const c = [];
135
135
  let i = 0, h = 0;
136
136
  for (; i < r && h < s; )
137
137
  e[i] === t[h] ? (c.push([i, h]), i++, h++) : o[(i + 1) * n + h] >= o[i * n + h + 1] ? i++ : h++;
138
138
  return c;
139
139
  }
140
- function st(e, t) {
141
- return tt.find(
140
+ function it(e, t) {
141
+ return rt.find(
142
142
  (r) => [e, t].every((s) => {
143
143
  const n = /* @__PURE__ */ new Set();
144
144
  return s.every((o) => {
145
- if (!z(o) || !B(o, r))
145
+ if (!F(o) || !B(o, r))
146
146
  return !1;
147
147
  const c = o[r];
148
148
  return typeof c != "string" && typeof c != "number" || n.has(c) ? !1 : (n.add(c), !0);
@@ -150,7 +150,7 @@ function st(e, t) {
150
150
  })
151
151
  );
152
152
  }
153
- function te(e, t, r, s, n, o) {
153
+ function ne(e, t, r, s, n, o) {
154
154
  const c = {
155
155
  type: "conflict",
156
156
  id: JSON.stringify(r),
@@ -165,22 +165,22 @@ function te(e, t, r, s, n, o) {
165
165
  };
166
166
  return o.push(c), c;
167
167
  }
168
- function Ie(e, t, r, s, n, o) {
169
- if (D(s, n))
168
+ function Ce(e, t, r, s, n, o) {
169
+ if (_(s, n))
170
170
  return { type: "equal", key: e, value: s };
171
- if (z(s) && z(n))
171
+ if (F(s) && F(n))
172
172
  return {
173
173
  type: "container",
174
174
  key: e,
175
175
  container: "object",
176
- children: Le(s, n, t, r, o)
176
+ children: Ee(s, n, t, r, o)
177
177
  };
178
178
  if (Array.isArray(s) && Array.isArray(n))
179
179
  return {
180
180
  type: "container",
181
181
  key: e,
182
182
  container: "array",
183
- children: lt(s, n, t, r, o)
183
+ children: ut(s, n, t, r, o)
184
184
  };
185
185
  const c = {
186
186
  type: "conflict",
@@ -196,27 +196,27 @@ function Ie(e, t, r, s, n, o) {
196
196
  };
197
197
  return o.push(c), c;
198
198
  }
199
- function Le(e, t, r, s, n) {
199
+ function Ee(e, t, r, s, n) {
200
200
  const o = [];
201
- for (const c of rt(Object.keys(e), Object.keys(t))) {
202
- const i = B(e, c), h = B(t, c), u = [...r, c], d = ot(s, c);
201
+ for (const c of ct(Object.keys(e), Object.keys(t))) {
202
+ const i = B(e, c), h = B(t, c), u = [...r, c], f = lt(s, c);
203
203
  i && h ? o.push(
204
- Ie(
204
+ Ce(
205
205
  c,
206
206
  u,
207
- d,
207
+ f,
208
208
  e[c],
209
209
  t[c],
210
210
  n
211
211
  )
212
212
  ) : i ? o.push(
213
- te("left", c, u, d, e[c], n)
213
+ ne("left", c, u, f, e[c], n)
214
214
  ) : o.push(
215
- te(
215
+ ne(
216
216
  "right",
217
217
  c,
218
218
  u,
219
- d,
219
+ f,
220
220
  t[c],
221
221
  n
222
222
  )
@@ -224,28 +224,28 @@ function Le(e, t, r, s, n) {
224
224
  }
225
225
  return o;
226
226
  }
227
- function lt(e, t, r, s, n) {
228
- const o = st(e, t), c = (k, a) => k.map(
229
- (O) => a ? `${typeof O[a]}:${O[a]}` : ue(O)
227
+ function ut(e, t, r, s, n) {
228
+ const o = it(e, t), c = (k, a) => k.map(
229
+ ($) => a ? `${typeof $[a]}:${$[a]}` : ae($)
230
230
  );
231
- let i = Oe(
231
+ let i = Re(
232
232
  c(e, o),
233
233
  c(t, o)
234
234
  ), h = o !== void 0;
235
- h && i.length === 0 && (h = !1, i = Oe(c(e, void 0), c(t, void 0)));
235
+ h && i.length === 0 && (h = !1, i = Re(c(e, void 0), c(t, void 0)));
236
236
  const u = [];
237
- let d = 0, S = 0;
238
- const b = (k) => `${s}[${k}]`, T = () => [...r, u.length], A = (k, a) => {
237
+ let f = 0, R = 0;
238
+ const b = (k) => `${s}[${k}]`, T = () => [...r, u.length], S = (k, a) => {
239
239
  u.push(
240
- Ie(null, T(), b(a), e[k], t[a], n)
240
+ Ce(null, T(), b(a), e[k], t[a], n)
241
241
  );
242
- }, R = (k, a) => {
243
- const O = h ? 0 : Math.min(k - d, a - S);
244
- for (let m = 0; m < O; m++)
245
- A(d + m, S + m);
246
- for (let m = d + O; m < k; m++)
242
+ }, w = (k, a) => {
243
+ const $ = h ? 0 : Math.min(k - f, a - R);
244
+ for (let m = 0; m < $; m++)
245
+ S(f + m, R + m);
246
+ for (let m = f + $; m < k; m++)
247
247
  u.push(
248
- te(
248
+ ne(
249
249
  "left",
250
250
  null,
251
251
  T(),
@@ -254,9 +254,9 @@ function lt(e, t, r, s, n) {
254
254
  n
255
255
  )
256
256
  );
257
- for (let m = S + O; m < a; m++)
257
+ for (let m = R + $; m < a; m++)
258
258
  u.push(
259
- te(
259
+ ne(
260
260
  "right",
261
261
  null,
262
262
  T(),
@@ -265,93 +265,93 @@ function lt(e, t, r, s, n) {
265
265
  n
266
266
  )
267
267
  );
268
- d = k, S = a;
268
+ f = k, R = a;
269
269
  };
270
270
  for (const [k, a] of i)
271
- R(k, a), A(k, a), d = k + 1, S = a + 1;
272
- return R(e.length, t.length), u;
271
+ w(k, a), S(k, a), f = k + 1, R = a + 1;
272
+ return w(e.length, t.length), u;
273
273
  }
274
- function ct(e, t) {
274
+ function at(e, t) {
275
275
  const r = [];
276
- return { children: Le(e, t, [], "", r), conflicts: r };
276
+ return { children: Ee(e, t, [], "", r), conflicts: r };
277
277
  }
278
278
  function Z(e, t) {
279
279
  const r = t ?? "right";
280
- return Ae(r) ? { present: !0, value: r.custom, side: null, custom: !0 } : r === "left" && e.hasLeft ? { present: !0, value: e.left, side: "left" } : r === "right" && e.hasRight ? { present: !0, value: e.right, side: "right" } : { present: !1, side: null };
280
+ return Le(r) ? { present: !0, value: r.custom, side: null, custom: !0 } : r === "left" && e.hasLeft ? { present: !0, value: e.left, side: "left" } : r === "right" && e.hasRight ? { present: !0, value: e.right, side: "right" } : { present: !1, side: null };
281
281
  }
282
- function it(e, t) {
282
+ function dt(e, t) {
283
283
  const r = Z(e, t);
284
284
  return r.custom ? "custom" : r.side ?? "deleted";
285
285
  }
286
- function ee(e, t) {
286
+ function te(e, t) {
287
287
  const r = {};
288
288
  for (const s of e.conflicts)
289
289
  r[s.id] = t;
290
290
  return r;
291
291
  }
292
- function Ce(e, t, r) {
292
+ function xe(e, t, r) {
293
293
  const s = {}, n = [];
294
294
  for (const o of e) {
295
295
  let c;
296
296
  if (o.type === "equal")
297
- c = ae(o.value);
297
+ c = de(o.value);
298
298
  else if (o.type === "container")
299
- c = Ce(o.children, t, o.container);
299
+ c = xe(o.children, t, o.container);
300
300
  else {
301
301
  const i = Z(o, t[o.id]);
302
302
  if (!i.present)
303
303
  continue;
304
- c = ae(i.value);
304
+ c = de(i.value);
305
305
  }
306
306
  r === "array" ? n.push(c) : o.key !== null && (s[o.key] = c);
307
307
  }
308
308
  return r === "array" ? n : s;
309
309
  }
310
- function Ee(e, t) {
311
- return Ce(e.children, t, "object");
310
+ function Te(e, t) {
311
+ return xe(e.children, t, "object");
312
312
  }
313
- const Se = /* @__PURE__ */ Symbol("unknown");
314
- function Re(e) {
313
+ const we = /* @__PURE__ */ Symbol("unknown");
314
+ function Ne(e) {
315
315
  return e.hasLeft && e.hasRight ? "deleted" : e.hasLeft ? "right" : "left";
316
316
  }
317
- function xe(e, t, r, s) {
317
+ function je(e, t, r, s) {
318
318
  for (const n of e) {
319
319
  if (n.type === "equal")
320
320
  continue;
321
321
  if (n.type === "container") {
322
- const i = r === "object" && n.key !== null && z(t) && B(t, n.key) ? t[n.key] : Se;
323
- xe(n.children, i, n.container, s);
322
+ const i = r === "object" && n.key !== null && F(t) && B(t, n.key) ? t[n.key] : we;
323
+ je(n.children, i, n.container, s);
324
324
  continue;
325
325
  }
326
- if (t === Se) {
326
+ if (t === we) {
327
327
  s[n.id] = "right";
328
328
  continue;
329
329
  }
330
330
  let o = !1, c = !1;
331
331
  if (r === "object") {
332
- if (n.key === null || !z(t) || !B(t, n.key)) {
333
- s[n.id] = Re(n);
332
+ if (n.key === null || !F(t) || !B(t, n.key)) {
333
+ s[n.id] = Ne(n);
334
334
  continue;
335
335
  }
336
336
  const i = t[n.key];
337
- if (o = n.hasLeft && D(i, n.left), c = n.hasRight && D(i, n.right), !o && !c) {
338
- s[n.id] = { custom: ae(i) };
337
+ if (o = n.hasLeft && _(i, n.left), c = n.hasRight && _(i, n.right), !o && !c) {
338
+ s[n.id] = { custom: de(i) };
339
339
  continue;
340
340
  }
341
341
  } else {
342
342
  const i = Array.isArray(t) ? t : [];
343
- if (o = n.hasLeft && i.some((h) => D(h, n.left)), c = n.hasRight && i.some((h) => D(h, n.right)), !o && !c) {
344
- s[n.id] = Re(n);
343
+ if (o = n.hasLeft && i.some((h) => _(h, n.left)), c = n.hasRight && i.some((h) => _(h, n.right)), !o && !c) {
344
+ s[n.id] = Ne(n);
345
345
  continue;
346
346
  }
347
347
  }
348
348
  s[n.id] = o && !c ? "left" : "right";
349
349
  }
350
350
  }
351
- function ut(e, t) {
351
+ function ft(e, t) {
352
352
  let r = 0, s = 0;
353
353
  for (const o of e.conflicts)
354
- B(t, o.id) && (r++, Ae(t[o.id]) && s++);
354
+ B(t, o.id) && (r++, Le(t[o.id]) && s++);
355
355
  const n = e.conflicts.length;
356
356
  return {
357
357
  total: n,
@@ -361,99 +361,99 @@ function ut(e, t) {
361
361
  allResolved: r === n
362
362
  };
363
363
  }
364
- function at(e, t) {
364
+ function ht(e, t) {
365
365
  if (!t)
366
- return ee(e, "right");
366
+ return te(e, "right");
367
367
  for (const s of ["left", "right"]) {
368
- const n = ee(e, s);
369
- if (D(t, Ee(e, n)))
368
+ const n = te(e, s);
369
+ if (_(t, Te(e, n)))
370
370
  return n;
371
371
  }
372
- const r = ee(e, "right");
373
- return xe(e.children, t, "object", r), r;
372
+ const r = te(e, "right");
373
+ return je(e.children, t, "object", r), r;
374
374
  }
375
375
  function W(e, t, r, s) {
376
- const n = we.repeat(r), o = (JSON.stringify(t, null, 2) ?? "null").split(`
376
+ const n = Ie.repeat(r), o = (JSON.stringify(t, null, 2) ?? "null").split(`
377
377
  `), c = o.length - 1, i = e === null ? "" : `${JSON.stringify(e)}: `;
378
378
  return o.map((h, u) => {
379
- const d = u === 0 ? `${i}${h}` : h;
380
- return `${n}${d}${u === c && s ? "," : ""}`;
379
+ const f = u === 0 ? `${i}${h}` : h;
380
+ return `${n}${f}${u === c && s ? "," : ""}`;
381
381
  });
382
382
  }
383
- function dt(e, t) {
384
- const r = [], s = [], n = (u, d, S, b = null) => {
383
+ function gt(e, t) {
384
+ const r = [], s = [], n = (u, f, R, b = null) => {
385
385
  r.push({
386
386
  index: r.length,
387
387
  blockId: b,
388
388
  blockRow: 0,
389
389
  blockSize: 1,
390
390
  left: u,
391
- right: d,
392
- result: S,
391
+ right: f,
392
+ result: R,
393
393
  leftNo: null,
394
394
  rightNo: null,
395
395
  resultNo: null
396
396
  });
397
- }, o = (u, d) => {
398
- const S = u.map((a) => a.type !== "conflict" || a.hasLeft), b = u.map((a) => a.type !== "conflict" || a.hasRight), T = u.map(
397
+ }, o = (u, f) => {
398
+ const R = u.map((a) => a.type !== "conflict" || a.hasLeft), b = u.map((a) => a.type !== "conflict" || a.hasRight), T = u.map(
399
399
  (a) => a.type !== "conflict" || Z(a, t[a.id]).present
400
- ), A = S.lastIndexOf(!0), R = b.lastIndexOf(!0), k = T.lastIndexOf(!0);
401
- u.forEach((a, O) => {
402
- const m = O !== A, N = O !== R, w = O !== k;
400
+ ), S = R.lastIndexOf(!0), w = b.lastIndexOf(!0), k = T.lastIndexOf(!0);
401
+ u.forEach((a, $) => {
402
+ const m = $ !== S, N = $ !== w, A = $ !== k;
403
403
  if (a.type === "equal") {
404
- const g = W(a.key, a.value, d, m), v = W(a.key, a.value, d, N), _ = W(a.key, a.value, d, w);
405
- g.forEach((F, E) => {
406
- n(F, v[E], _[E]);
404
+ const g = W(a.key, a.value, f, m), v = W(a.key, a.value, f, N), M = W(a.key, a.value, f, A);
405
+ g.forEach((z, P) => {
406
+ n(z, v[P], M[P]);
407
407
  });
408
408
  return;
409
409
  }
410
410
  if (a.type === "container") {
411
- const g = we.repeat(d), v = a.key === null ? "" : `${JSON.stringify(a.key)}: `, [_, F] = a.container === "array" ? ["[", "]"] : ["{", "}"], E = `${g}${v}${_}`;
412
- n(E, E, E), o(a.children, d + 1), n(
413
- `${g}${F}${m ? "," : ""}`,
414
- `${g}${F}${N ? "," : ""}`,
415
- `${g}${F}${w ? "," : ""}`
411
+ const g = Ie.repeat(f), v = a.key === null ? "" : `${JSON.stringify(a.key)}: `, [M, z] = a.container === "array" ? ["[", "]"] : ["{", "}"], P = `${g}${v}${M}`;
412
+ n(P, P, P), o(a.children, f + 1), n(
413
+ `${g}${z}${m ? "," : ""}`,
414
+ `${g}${z}${N ? "," : ""}`,
415
+ `${g}${z}${A ? "," : ""}`
416
416
  );
417
417
  return;
418
418
  }
419
- const U = a.hasLeft ? W(a.key, a.left, d, m) : [], j = a.hasRight ? W(a.key, a.right, d, N) : [], I = Z(a, t[a.id]), K = I.present ? W(a.key, I.value, d, w) : [], P = Math.max(U.length, j.length, K.length), Y = r.length;
420
- for (let g = 0; g < P; g++)
421
- n(U[g] ?? null, j[g] ?? null, K[g] ?? null, a.id);
419
+ const U = a.hasLeft ? W(a.key, a.left, f, m) : [], j = a.hasRight ? W(a.key, a.right, f, N) : [], L = Z(a, t[a.id]), E = L.present ? W(a.key, L.value, f, A) : [], D = Math.max(U.length, j.length, E.length), Y = r.length;
420
+ for (let g = 0; g < D; g++)
421
+ n(U[g] ?? null, j[g] ?? null, E[g] ?? null, a.id);
422
422
  s.push({
423
423
  id: a.id,
424
424
  entry: a,
425
425
  kind: a.kind,
426
426
  start: Y,
427
- size: P,
428
- selection: it(a, t[a.id])
427
+ size: D,
428
+ selection: dt(a, t[a.id])
429
429
  });
430
430
  });
431
431
  };
432
432
  n("{", "{", "{"), o(e.children, 1), n("}", "}", "}");
433
433
  for (const u of s)
434
- for (let d = 0; d < u.size; d++)
435
- r[u.start + d].blockRow = d, r[u.start + d].blockSize = u.size;
434
+ for (let f = 0; f < u.size; f++)
435
+ r[u.start + f].blockRow = f, r[u.start + f].blockSize = u.size;
436
436
  let c = 0, i = 0, h = 0;
437
437
  for (const u of r)
438
438
  u.leftNo = u.left === null ? null : ++c, u.rightNo = u.right === null ? null : ++i, u.resultNo = u.result === null ? null : ++h;
439
439
  return { rows: r, blocks: s };
440
440
  }
441
- const Te = He(null);
442
- function Nt({
441
+ const Me = Ge(null);
442
+ function It({
443
443
  viewer: e,
444
444
  children: t
445
445
  }) {
446
- return /* @__PURE__ */ Ve(Te.Provider, { value: e, children: t });
446
+ return /* @__PURE__ */ Ye(Me.Provider, { value: e, children: t });
447
447
  }
448
- function wt() {
449
- const e = qe(Te);
448
+ function Lt() {
449
+ const e = Ze(Me);
450
450
  if (!e)
451
451
  throw new Error(
452
452
  "useMergeViewerContext must be used inside a MergeViewerProvider"
453
453
  );
454
454
  return e;
455
455
  }
456
- const ft = "minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax(0, 1fr)", ht = "3.5ch 3.5rem minmax(0, 1fr)", gt = {
456
+ const pt = "minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax(0, 1fr)", yt = "3.5ch 3.5rem minmax(0, 1fr)", mt = {
457
457
  current: {
458
458
  code: "1",
459
459
  actions: "2",
@@ -474,7 +474,7 @@ const ft = "minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax
474
474
  header: "6 / 9",
475
475
  fold: "6 / 9"
476
476
  }
477
- }, pt = {
477
+ }, vt = {
478
478
  current: {
479
479
  number: "1",
480
480
  actions: "2",
@@ -496,26 +496,26 @@ const ft = "minmax(0, 1fr) 3.5rem 3.5ch 3.5ch minmax(0, 1fr) 3.5ch 3.5rem minmax
496
496
  header: "1 / -1",
497
497
  fold: "1 / -1"
498
498
  }
499
- }, yt = {
499
+ }, bt = {
500
500
  current: 0,
501
501
  incoming: 1,
502
502
  result: 2
503
503
  };
504
- function ce(e, t, r, s, n) {
505
- const c = (e === "stacked" ? pt : gt)[t][r] ?? "auto";
504
+ function ie(e, t, r, s, n) {
505
+ const c = (e === "stacked" ? vt : mt)[t][r] ?? "auto";
506
506
  if (e === "horizontal")
507
507
  return { gridRow: r === "header" ? 1 : s + 2, gridColumn: c };
508
- const i = yt[t] * (n + 1);
508
+ const i = bt[t] * (n + 1);
509
509
  return {
510
510
  gridRow: r === "header" ? i + 1 : i + s + 2,
511
511
  gridColumn: c
512
512
  };
513
513
  }
514
- function mt(e) {
515
- return e === "stacked" ? ht : ft;
514
+ function kt(e) {
515
+ return e === "stacked" ? yt : pt;
516
516
  }
517
- const vt = 100;
518
- function bt({
517
+ const Ot = 100;
518
+ function St({
519
519
  currentJson: e,
520
520
  incomingJson: t,
521
521
  initialMergedJson: r,
@@ -523,309 +523,314 @@ function bt({
523
523
  decisions: n,
524
524
  onDecisionsChange: o
525
525
  }) {
526
- const c = L(() => JSON.stringify(e), [e]), i = L(
526
+ const c = I(() => JSON.stringify(e), [e]), i = I(
527
527
  () => JSON.stringify(t),
528
528
  [t]
529
- ), h = L(
529
+ ), h = I(
530
530
  () => r === void 0 ? void 0 : JSON.stringify(r),
531
531
  [r]
532
- ), u = L(
533
- () => ct(e, t),
532
+ ), u = I(
533
+ () => at(e, t),
534
534
  [c, i]
535
- ), d = L(
536
- () => at(u, r),
535
+ ), f = I(
536
+ () => ht(u, r),
537
537
  [u, h]
538
- ), S = s ?? r === void 0, b = () => S ? {} : d, [T, A] = M(b), R = Q({ past: [], future: [] }), [, k] = M(0), [a, O] = M(u);
539
- a !== u && (O(u), A(b()), R.current = { past: [], future: [] });
540
- const m = n !== void 0, N = m ? n : T, w = Q(N);
541
- w.current = N;
542
- const U = Q(o);
538
+ ), R = s ?? r === void 0, b = () => R ? {} : f, [T, S] = K(b), w = ee({ past: [], future: [] }), [, k] = K(0), [a, $] = K(u);
539
+ a !== u && ($(u), S(b()), w.current = { past: [], future: [] });
540
+ const m = n !== void 0, N = m ? n : T, A = ee(N);
541
+ A.current = N;
542
+ const U = ee(o);
543
543
  U.current = o;
544
544
  const j = (g) => {
545
- w.current = g, m || A(g), U.current?.(g), k((v) => v + 1);
546
- }, I = (g) => {
547
- if (D(g, w.current))
545
+ A.current = g, m || S(g), U.current?.(g), k((v) => v + 1);
546
+ }, L = (g) => {
547
+ if (_(g, A.current))
548
548
  return;
549
- const v = R.current;
550
- v.past.push(w.current), v.past.length > vt && v.past.shift(), v.future = [], j(g);
551
- }, K = L(
552
- () => ({ ...d, ...N }),
553
- [d, N]
554
- ), P = L(
555
- () => Ee(u, K),
556
- [u, K]
557
- ), Y = L(
558
- () => ut(u, N),
549
+ const v = w.current;
550
+ v.past.push(A.current), v.past.length > Ot && v.past.shift(), v.future = [], j(g);
551
+ }, E = I(
552
+ () => ({ ...f, ...N }),
553
+ [f, N]
554
+ ), D = I(
555
+ () => Te(u, E),
556
+ [u, E]
557
+ ), Y = I(
558
+ () => ft(u, N),
559
559
  [u, N]
560
560
  );
561
561
  return {
562
562
  tree: u,
563
563
  decisions: N,
564
- selection: K,
565
- merged: P,
564
+ selection: E,
565
+ merged: D,
566
566
  status: Y,
567
567
  isResolved: (g) => Object.hasOwn(N, g),
568
- choose: (g, v) => I({ ...w.current, [g]: v }),
568
+ choose: (g, v) => L({ ...A.current, [g]: v }),
569
569
  revert: (g) => {
570
- const v = { ...w.current }, _ = b();
571
- Object.hasOwn(_, g) ? v[g] = _[g] : delete v[g], I(v);
570
+ const v = { ...A.current }, M = b();
571
+ Object.hasOwn(M, g) ? v[g] = M[g] : delete v[g], L(v);
572
572
  },
573
- applyAll: (g) => I(ee(u, g)),
574
- reset: () => I(b()),
573
+ applyAll: (g) => L(te(u, g)),
574
+ reset: () => L(b()),
575
575
  undo: () => {
576
- const g = R.current, v = g.past.pop();
577
- v && (g.future.push(w.current), j(v));
576
+ const g = w.current, v = g.past.pop();
577
+ v && (g.future.push(A.current), j(v));
578
578
  },
579
579
  redo: () => {
580
- const g = R.current, v = g.future.pop();
581
- v && (g.past.push(w.current), j(v));
580
+ const g = w.current, v = g.future.pop();
581
+ v && (g.past.push(A.current), j(v));
582
582
  },
583
- canUndo: R.current.past.length > 0,
584
- canRedo: R.current.future.length > 0
583
+ canUndo: w.current.past.length > 0,
584
+ canRedo: w.current.future.length > 0
585
585
  };
586
586
  }
587
- const kt = 900, $t = 3, Ot = typeof window > "u" ? Ne : We, ie = (e) => e ? "" : void 0;
588
- function At({
587
+ const $t = 900, Rt = 3, wt = typeof window > "u" ? Ae : Xe, ue = (e) => e ? "" : void 0;
588
+ function Ct({
589
589
  onMergeChange: e,
590
590
  editable: t = !1,
591
591
  labels: r,
592
592
  layout: s = "responsive",
593
- stackBelow: n = kt,
593
+ stackBelow: n = $t,
594
594
  collapseUnchanged: o = !1,
595
595
  ...c
596
596
  }) {
597
- const i = L(() => et(r), [r]), h = bt(c), { tree: u, selection: d, merged: S, status: b, isResolved: T } = h, A = L(
598
- () => dt(u, d),
599
- [u, d]
600
- ), R = L(() => {
597
+ const i = I(() => ot(r), [r]), h = St(c), { tree: u, selection: f, merged: R, status: b, isResolved: T } = h, S = I(
598
+ () => gt(u, f),
599
+ [u, f]
600
+ ), w = I(() => {
601
601
  const l = /* @__PURE__ */ new Map();
602
- for (const f of A.blocks)
603
- l.set(f.id, f);
602
+ for (const d of S.blocks)
603
+ l.set(d.id, d);
604
604
  return l;
605
- }, [A]), k = Q(e);
606
- k.current = e, Ne(() => {
607
- k.current?.(S, b);
608
- }, [S, b]);
609
- const [a, O] = M(null), [m, N] = M(null), [w, U] = M(!1);
610
- Ot(() => {
605
+ }, [S]), k = ee(e);
606
+ k.current = e, Ae(() => {
607
+ k.current?.(R, b);
608
+ }, [R, b]);
609
+ const [a, $] = K(null), [m, N] = K(null), [A, U] = K(!1);
610
+ wt(() => {
611
611
  if (s !== "responsive" || !m || typeof ResizeObserver > "u")
612
612
  return;
613
- const l = new ResizeObserver(([f]) => {
614
- U(f.contentRect.width < n);
613
+ const l = new ResizeObserver(([d]) => {
614
+ U(d.contentRect.width < n);
615
615
  });
616
616
  return l.observe(m), () => l.disconnect();
617
617
  }, [s, m, n]);
618
- const j = s === "vertical" || s === "responsive" && w, I = j ? "stacked" : "horizontal", K = typeof o == "number" ? o : $t, [P, Y] = M(o !== !1), [g, v] = M(
618
+ const j = s === "vertical" || s === "responsive" && A, L = j ? "stacked" : "horizontal", E = typeof o == "number" ? o : Rt, [D, Y] = K(o !== !1), [g, v] = K(
619
619
  () => /* @__PURE__ */ new Set()
620
- ), _ = L(
621
- () => P ? Ze(A.rows, K, g) : A.rows.map((l) => ({ type: "row", row: l })),
622
- [P, A, K, g]
623
- ), F = (l) => {
624
- v((f) => new Set(f).add(l));
625
- }, [E, ne] = M(null), [de, oe] = M(null), V = L(() => u.conflicts.map((l) => l.id), [u]), je = (l) => {
626
- const f = Array.from(
620
+ ), M = I(
621
+ () => D ? $e(S.rows, E, g) : S.rows.map((l) => ({ type: "row", row: l })),
622
+ [D, S, E, g]
623
+ ), z = (l) => l.filter((d) => d.type === "fold").length, P = I(
624
+ () => D && z(M) === z($e(S.rows, E, /* @__PURE__ */ new Set())),
625
+ [D, M, S, E]
626
+ ), Ke = () => {
627
+ v(/* @__PURE__ */ new Set()), Y(!P);
628
+ }, De = (l) => {
629
+ v((d) => new Set(d).add(l));
630
+ }, [G, oe] = K(null), [fe, re] = K(null), V = I(() => u.conflicts.map((l) => l.id), [u]), Pe = (l) => {
631
+ const d = Array.from(
627
632
  a?.querySelectorAll("[data-merge-block]") ?? []
628
- ).filter((C) => C.dataset.mergeBlock === l), p = f.find((C) => getComputedStyle(C).display !== "none") ?? f[0], $ = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
633
+ ).filter((C) => C.dataset.mergeBlock === l), p = d.find((C) => getComputedStyle(C).display !== "none") ?? d[0], O = window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ?? !1;
629
634
  p?.scrollIntoView?.({
630
635
  block: "center",
631
- behavior: $ ? "auto" : "smooth"
636
+ behavior: O ? "auto" : "smooth"
632
637
  });
633
- }, fe = (l) => {
634
- ne(l), je(l);
635
- }, he = (l, f) => {
638
+ }, he = (l) => {
639
+ oe(l), Pe(l);
640
+ }, ge = (l, d) => {
636
641
  if (l.length === 0)
637
642
  return null;
638
- const p = E === null ? -1 : V.indexOf(E);
639
- if (f === "next")
643
+ const p = G === null ? -1 : V.indexOf(G);
644
+ if (d === "next")
640
645
  return l.find((C) => V.indexOf(C) > p) ?? l[0];
641
- const $ = p === -1 ? V.length : p;
642
- return [...l].reverse().find((C) => V.indexOf(C) < $) ?? l[l.length - 1];
643
- }, Me = () => {
644
- const l = he(
645
- V.filter((f) => !T(f)),
646
+ const O = p === -1 ? V.length : p;
647
+ return [...l].reverse().find((C) => V.indexOf(C) < O) ?? l[l.length - 1];
648
+ }, _e = () => {
649
+ const l = ge(
650
+ V.filter((d) => !T(d)),
646
651
  "next"
647
652
  );
648
- return l === null ? !1 : (fe(l), !0);
649
- }, Ke = (l) => {
650
- const f = he(V, l);
651
- f !== null && fe(f);
652
- }, G = (l, f) => {
653
- h.choose(l, f), ne(l);
654
- }, ge = (l) => {
655
- const f = R.get(l);
656
- if (!f)
657
- return "null";
658
- const p = Z(f.entry, d[l]), $ = p.present ? p.value : f.entry.hasRight ? f.entry.right : f.entry.left;
659
- return JSON.stringify($, null, 2) ?? "null";
653
+ return l === null ? !1 : (he(l), !0);
654
+ }, ze = (l) => {
655
+ const d = ge(V, l);
656
+ d !== null && he(d);
657
+ }, X = (l, d) => {
658
+ h.choose(l, d), oe(l);
660
659
  }, pe = (l) => {
661
- ne(l), oe(l);
662
- }, De = () => oe(null), Pe = (l, f) => {
660
+ const d = w.get(l);
661
+ if (!d)
662
+ return "null";
663
+ const p = Z(d.entry, f[l]), O = p.present ? p.value : d.entry.hasRight ? d.entry.right : d.entry.left;
664
+ return JSON.stringify(O, null, 2) ?? "null";
665
+ }, ye = (l) => {
666
+ oe(l), re(l);
667
+ }, Fe = () => re(null), Ue = (l, d) => {
663
668
  let p;
664
669
  try {
665
- p = JSON.parse(f);
666
- } catch ($) {
667
- return $ instanceof Error ? $.message : "Invalid JSON";
670
+ p = JSON.parse(d);
671
+ } catch (O) {
672
+ return O instanceof Error ? O.message : "Invalid JSON";
668
673
  }
669
- return G(l, { custom: p }), oe(null), null;
670
- }, re = (l, f, p, $, C) => {
671
- const y = f.blockId ? R.get(f.blockId) : void 0, le = !!y && f.blockRow === 0, Ue = !!y && f.blockRow === f.blockSize - 1, X = y ? T(y.id) : !0, x = y?.entry, Fe = l === "current" ? y?.selection === "left" : l === "incoming" ? y?.selection === "right" : !0;
674
+ return X(l, { custom: p }), re(null), null;
675
+ }, se = (l, d, p, O, C) => {
676
+ const y = d.blockId ? w.get(d.blockId) : void 0, ce = !!y && d.blockRow === 0, Ve = !!y && d.blockRow === d.blockSize - 1, Q = y ? T(y.id) : !0, x = y?.entry, qe = l === "current" ? y?.selection === "left" : l === "incoming" ? y?.selection === "right" : !0;
672
677
  let q = "unchanged";
673
- y && (p === null ? q = "filler" : l === "result" && !X ? q = "pending" : l === "result" && y.selection === "custom" ? q = "edited" : X && !Fe ? q = "rejected" : q = "changed");
678
+ y && (p === null ? q = "filler" : l === "result" && !Q ? q = "pending" : l === "result" && y.selection === "custom" ? q = "edited" : Q && !qe ? q = "rejected" : q = "changed");
674
679
  const J = {};
675
- if (y && x && le) {
676
- const be = () => ({
680
+ if (y && x && ce) {
681
+ const ke = () => ({
677
682
  label: i.removeChange(x.label),
678
- pressed: X && y.selection === "deleted",
679
- run: () => G(y.id, "deleted")
680
- }), ke = ($e, Be) => ({
681
- label: Be,
682
- pressed: X && y.selection === $e,
683
- run: () => G(y.id, $e)
683
+ pressed: Q && y.selection === "deleted",
684
+ run: () => X(y.id, "deleted")
685
+ }), Oe = (Se, We) => ({
686
+ label: We,
687
+ pressed: Q && y.selection === Se,
688
+ run: () => X(y.id, Se)
684
689
  });
685
- l === "current" && x.hasLeft ? (J.remove = be(), J.accept = ke("left", i.acceptCurrent(x.label))) : l === "incoming" && x.hasRight ? (J.accept = ke("right", i.acceptIncoming(x.label)), J.remove = be()) : l === "result" && t && (y.selection === "custom" && (J.revert = {
690
+ l === "current" && x.hasLeft ? (J.remove = ke(), J.accept = Oe("left", i.acceptCurrent(x.label))) : l === "incoming" && x.hasRight ? (J.accept = Oe("right", i.acceptIncoming(x.label)), J.remove = ke()) : l === "result" && t && (y.selection === "custom" && (J.revert = {
686
691
  label: i.revertEdit(x.label),
687
692
  pressed: !1,
688
693
  run: () => h.revert(y.id)
689
694
  }), J.edit = {
690
695
  label: i.editChange(x.label),
691
696
  pressed: !1,
692
- run: () => pe(y.id)
697
+ run: () => ye(y.id)
693
698
  });
694
699
  }
695
- const Je = l === "result" && t && le && y !== void 0 && de === y.id;
700
+ const He = l === "result" && t && ce && y !== void 0 && fe === y.id;
696
701
  return {
697
702
  pane: l,
698
703
  text: p,
699
- segments: p === null ? [] : Xe(
704
+ segments: p === null ? [] : tt(
700
705
  p,
701
706
  l !== "result" && y?.kind === "modified" ? C : void 0
702
707
  ),
703
- lineNo: $,
708
+ lineNo: O,
704
709
  state: q,
705
710
  kind: y?.kind ?? null,
706
711
  blockId: y?.id ?? null,
707
- blockStart: le,
708
- blockEnd: Ue,
709
- active: !!y && E === y?.id,
712
+ blockStart: ce,
713
+ blockEnd: Ve,
714
+ active: !!y && G === y?.id,
710
715
  actions: J,
711
- editor: Je && y && x ? {
716
+ editor: He && y && x ? {
712
717
  title: i.editorTitle(x.label),
713
718
  inputLabel: i.editorInput(x.label),
714
- initialText: ge(y.id)
719
+ initialText: pe(y.id)
715
720
  } : void 0
716
721
  };
717
- }, ye = _.map((l, f) => {
722
+ }, me = M.map((l, d) => {
718
723
  if (l.type === "fold")
719
724
  return {
720
725
  type: "fold",
721
726
  key: `fold-${l.key}`,
722
- index: f,
727
+ index: d,
723
728
  hidden: l.hidden,
724
729
  label: i.unchangedLines(l.hidden),
725
730
  showLabel: i.showUnchanged(l.hidden),
726
- expand: () => F(l.key)
731
+ expand: () => De(l.key)
727
732
  };
728
733
  const { row: p } = l;
729
734
  return {
730
735
  type: "row",
731
736
  key: `row-${p.index}`,
732
- index: f,
737
+ index: d,
733
738
  row: p,
734
- current: re("current", p, p.left, p.leftNo, p.right),
735
- result: re("result", p, p.result, p.resultNo, null),
736
- incoming: re("incoming", p, p.right, p.rightNo, p.left)
739
+ current: se("current", p, p.left, p.leftNo, p.right),
740
+ result: se("result", p, p.result, p.resultNo, null),
741
+ incoming: se("incoming", p, p.right, p.rightNo, p.left)
737
742
  };
738
- }), me = b.total, ve = me === 0 ? "empty" : b.allResolved ? "resolved" : "pending", _e = me === 0 ? i.noChanges : b.allResolved ? i.allResolved(b) : i.unresolved(b), ze = (l) => {
739
- const f = l.target;
740
- if (!(l.ctrlKey || l.metaKey) || f.closest("textarea, input"))
743
+ }), ve = b.total, be = ve === 0 ? "empty" : b.allResolved ? "resolved" : "pending", Je = ve === 0 ? i.noChanges : b.allResolved ? i.allResolved(b) : i.unresolved(b), Be = (l) => {
744
+ const d = l.target;
745
+ if (!(l.ctrlKey || l.metaKey) || d.closest("textarea, input"))
741
746
  return;
742
747
  const p = l.key.toLowerCase();
743
748
  p === "z" && !l.shiftKey ? (l.preventDefault(), h.undo()) : (p === "z" && l.shiftKey || p === "y") && (l.preventDefault(), h.redo());
744
- }, se = ye.length;
749
+ }, le = me.length;
745
750
  return {
746
751
  ...h,
747
- choose: G,
748
- items: ye,
752
+ choose: X,
753
+ items: me,
749
754
  labels: i,
750
755
  stacked: j,
751
- statusState: ve,
752
- statusText: _e,
756
+ statusState: be,
757
+ statusText: Je,
753
758
  collapsed: P,
754
- toggleCollapsed: () => Y((l) => !l),
755
- activeId: E,
756
- goToChange: Ke,
757
- goToNextUnresolved: Me,
759
+ toggleCollapsed: Ke,
760
+ activeId: G,
761
+ goToChange: ze,
762
+ goToNextUnresolved: _e,
758
763
  editable: t,
759
- editingId: de,
760
- startEdit: pe,
761
- cancelEdit: De,
762
- editorText: ge,
763
- commitEdit: Pe,
764
+ editingId: fe,
765
+ startEdit: ye,
766
+ cancelEdit: Fe,
767
+ editorText: pe,
768
+ commitEdit: Ue,
764
769
  getRootProps: () => ({
765
- ref: O,
766
- onKeyDown: ze,
767
- "data-merge-status": ve
770
+ ref: $,
771
+ onKeyDown: Be,
772
+ "data-merge-status": be
768
773
  }),
769
774
  getScrollProps: () => ({ ref: N }),
770
775
  getGridProps: () => ({
771
776
  style: {
772
777
  display: "grid",
773
- gridTemplateColumns: mt(I)
778
+ gridTemplateColumns: kt(L)
774
779
  },
775
- "data-layout": I
780
+ "data-layout": L
776
781
  }),
777
782
  getHeaderProps: (l) => ({
778
- style: { ...ce(I, l, "header", 0, se) },
783
+ style: { ...ie(L, l, "header", 0, le) },
779
784
  "data-pane": l,
780
785
  "data-column": "header"
781
786
  }),
782
- getCellProps: (l, f, p) => {
783
- const $ = l[f], C = {
784
- ...ce(I, f, p, l.index, se)
787
+ getCellProps: (l, d, p) => {
788
+ const O = l[d], C = {
789
+ ...ie(L, d, p, l.index, le)
785
790
  };
786
- return j && $.state === "filler" && (C.display = "none"), {
791
+ return j && O.state === "filler" && (C.display = "none"), {
787
792
  style: C,
788
- "data-pane": f,
793
+ "data-pane": d,
789
794
  "data-column": p,
790
- "data-state": $.state,
791
- "data-kind": $.kind ?? void 0,
792
- "data-block-start": ie($.blockStart),
793
- "data-block-end": ie($.blockEnd),
794
- "data-active": ie($.active),
795
- "data-merge-block": p === "code" && $.blockStart ? $.blockId ?? void 0 : void 0
795
+ "data-state": O.state,
796
+ "data-kind": O.kind ?? void 0,
797
+ "data-block-start": ue(O.blockStart),
798
+ "data-block-end": ue(O.blockEnd),
799
+ "data-active": ue(O.active),
800
+ "data-merge-block": p === "code" && O.blockStart ? O.blockId ?? void 0 : void 0
796
801
  };
797
802
  },
798
- getFoldProps: (l, f) => ({
803
+ getFoldProps: (l, d) => ({
799
804
  type: "button",
800
- style: { ...ce(I, f, "fold", l.index, se) },
805
+ style: { ...ie(L, d, "fold", l.index, le) },
801
806
  // Only one of the three panes needs to be reachable and announced.
802
- tabIndex: f === "current" ? 0 : -1,
803
- "aria-hidden": f === "current" ? void 0 : !0,
807
+ tabIndex: d === "current" ? 0 : -1,
808
+ "aria-hidden": d === "current" ? void 0 : !0,
804
809
  "aria-label": l.showLabel,
805
- "data-pane": f,
810
+ "data-pane": d,
806
811
  "data-column": "fold",
807
812
  onClick: l.expand
808
813
  })
809
814
  };
810
815
  }
811
816
  export {
812
- Nt as MergeViewerProvider,
813
- dt as buildMergeLayout,
814
- ct as buildMergeTree,
815
- Ee as buildMergedJson,
816
- D as deepEqual,
817
- Qe as defaultLabels,
818
- Ze as foldRows,
819
- ut as getMergeStatus,
820
- mt as gridTemplateColumns,
821
- at as initialSelection,
822
- Xe as inlineSegments,
823
- Ae as isCustomChoice,
824
- ce as placeCell,
825
- et as resolveLabels,
826
- ee as selectAll,
827
- Ge as splitInlineEdit,
828
- bt as useMergeConflicts,
829
- At as useMergeViewer,
830
- wt as useMergeViewerContext
817
+ It as MergeViewerProvider,
818
+ gt as buildMergeLayout,
819
+ at as buildMergeTree,
820
+ Te as buildMergedJson,
821
+ _ as deepEqual,
822
+ nt as defaultLabels,
823
+ $e as foldRows,
824
+ ft as getMergeStatus,
825
+ kt as gridTemplateColumns,
826
+ ht as initialSelection,
827
+ tt as inlineSegments,
828
+ Le as isCustomChoice,
829
+ ie as placeCell,
830
+ ot as resolveLabels,
831
+ te as selectAll,
832
+ et as splitInlineEdit,
833
+ St as useMergeConflicts,
834
+ Ct as useMergeViewer,
835
+ Lt as useMergeViewerContext
831
836
  };
@@ -243,8 +243,15 @@ export declare interface MergeViewer extends MergeConflictsState {
243
243
  statusState: MergeViewerStatusState;
244
244
  /** The banner text matching `statusState`. */
245
245
  statusText: string;
246
- /** Whether long runs of unchanged lines are folded. */
246
+ /**
247
+ * Whether long runs of unchanged lines are folded. `false` as soon as one
248
+ * of them was opened by hand, so a "hide" button reads as not pressed.
249
+ */
247
250
  collapsed: boolean;
251
+ /**
252
+ * Hides every unchanged run when some are showing (including ones opened by
253
+ * hand), otherwise switches folding off again.
254
+ */
248
255
  toggleCollapsed: () => void;
249
256
  activeId: string | null;
250
257
  /** Scrolls to the next or previous change and marks it active. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ht-rnd/merge-conflict-viewer",
3
3
  "private": false,
4
- "version": "1.0.0",
4
+ "version": "1.0.2",
5
5
  "type": "module",
6
6
  "description": "Headless merge conflict viewer for JSON (React hooks and merge model), with a shadcn/ui registry component",
7
7
  "author": "ht-rnd",