"use strict";var A=Object.create;var d=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var F=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var b=(t,e)=>{for(var r in e)d(t,r,{get:e[r],enumerable:!0})},m=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of R(e))!v.call(t,o)&&o!==r&&d(t,o,{get:()=>e[o],enumerable:!(n=P(e,o))||n.enumerable});return t};var h=(t,e,r)=>(r=t!=null?A(F(t)):{},m(e||!t||!t.__esModule?d(r,"default",{value:t,enumerable:!0}):r,t)),N=t=>m(d({},"__esModule",{value:!0}),t);var j={};b(j,{BuiltInStrategies:()=>T,mergeObject:()=>M,statusToString:()=>$});module.exports=N(j);var k=(t,{rules:e,matcher:r})=>{var g,c,f;let n=(g=e.exact[t])!=null?g:[],o=(f=e.exactFields[(c=t.split(".").pop())!=null?c:""])!=null?f:[],i=Object.entries(e.patterns).filter(([s])=>r.isMatch(t,[s])).flatMap(([,s])=>s),u=[...n.flatMap(s=>s.strategies),...o.flatMap(s=>s.strategies),...i.flatMap(s=>s.strategies),...e.default],l=u.filter(s=>s.important),y=u.filter(s=>!s.important);return[...l,...y].map(s=>s.name)};var _=h(require("fs/promises")),O=h(require("path")),S=Symbol("MERGE_DROP");var a=0,p=1,w=2,C=3;var $=t=>{switch(t){case a:return"OK";case p:return"CONTINUE";case w:return"FAIL";case C:return"SKIP";default:return`UNKNOWN(${t})`}},x=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),T={ours:({ours:t})=>({status:a,value:t}),theirs:({theirs:t})=>({status:a,value:t}),base:({base:t})=>({status:a,value:t}),drop:t=>({status:a,value:S}),skip:({path:t})=>({status:C,reason:`Skip strategy applied at ${t}`}),"non-empty":({ours:t,theirs:e,base:r})=>t!=null&&t!==""?{status:a,value:t}:e!=null&&e!==""?{status:a,value:e}:r!=null&&r!==""?{status:a,value:r}:{status:p},update:({ours:t,theirs:e})=>t!==void 0?{status:a,value:e}:{status:a,value:S},merge:async t=>{let{ours:e,theirs:r,base:n,path:o,filePath:i,ctx:u,conflicts:l}=t;if(x(e)&&x(r)){let y=new Set([...Object.keys(e),...Object.keys(r)]),g={};for(let c of y)g[c]=await M({ours:e[c],theirs:r[c],base:x(n)?n[c]:void 0,path:o?`${o}.${c}`:c,filePath:i,ctx:u,conflicts:l});return{status:a,value:g}}return{status:p,reason:"Unmergeable type"}},concat:({ours:t,theirs:e,path:r})=>Array.isArray(t)&&Array.isArray(e)?{status:a,value:[...t,...e]}:{status:p,reason:`Cannot concat at ${r}`},unique:({ours:t,theirs:e,path:r})=>Array.isArray(t)&&Array.isArray(e)?{status:a,value:[...new Set([...t,...e])]}:{status:p,reason:`Cannot concat at ${r}`}},M=async({ours:t,theirs:e,base:r,path:n,filePath:o,ctx:i,conflicts:u})=>{var y;if(t===e)return t;i._strategyCache||(i._strategyCache=new Map);let l=i._strategyCache.get(n);l||(l=k(n,i.config),i._strategyCache.set(n,l));for(let g of l){let c=(y=T[g])!=null?y:i.strategies[g];if(!c)continue;let f=await c({ours:t,theirs:e,base:r,path:n,filePath:o,ctx:i,conflicts:u});switch(f.status){case a:return f.value;case p:continue;case C:u.push({path:n,reason:f.reason});return;case w:throw u.push({path:n,reason:f.reason}),new Error(`Merge failed at ${n}: ${f.reason}`)}}u.push({path:n,reason:`All strategies failed (tried: ${l.join(", ")||"none"})`,...i.config.debug?{ours:t,theirs:e,base:r}:{}})};0&&(module.exports={BuiltInStrategies,mergeObject,statusToString});
