{"version":3,"file":"replace-path.mjs","names":[],"sources":["../../src/paths/replace-path.ts"],"sourcesContent":["import { getPath } from './get-path';\nimport { setPath } from './set-path';\n\nexport function replacePath<T>(path: unknown, item: unknown, index: number, values: T) {\n  const currentValue = getPath(path, values);\n\n  if (!Array.isArray(currentValue)) {\n    return values;\n  }\n\n  if (currentValue.length <= index) {\n    return values;\n  }\n\n  const cloned = [...currentValue];\n  cloned[index] = item;\n\n  return setPath(path, cloned, values);\n}\n"],"mappings":";;;;AAGA,SAAgB,YAAe,MAAe,MAAe,OAAe,QAAW;CACrF,MAAM,eAAe,QAAQ,MAAM,MAAM;CAEzC,IAAI,CAAC,MAAM,QAAQ,YAAY,GAC7B,OAAO;CAGT,IAAI,aAAa,UAAU,OACzB,OAAO;CAGT,MAAM,SAAS,CAAC,GAAG,YAAY;CAC/B,OAAO,SAAS;CAEhB,OAAO,QAAQ,MAAM,QAAQ,MAAM;AACrC"}