{"version":3,"file":"move-pill.cjs","names":[],"sources":["../../../../src/components/Combobox/use-pills-reorder/move-pill.ts"],"sourcesContent":["export type PillReorderPosition = 'before' | 'after';\n\nexport function movePill<T>(\n  value: T[],\n  from: number,\n  to: number,\n  position: PillReorderPosition\n): T[] {\n  if (from === to) {\n    return value;\n  }\n\n  if (position === 'before' && to === from + 1) {\n    return value;\n  }\n\n  if (position === 'after' && to === from - 1) {\n    return value;\n  }\n\n  const result = value.slice();\n  const [item] = result.splice(from, 1);\n\n  let targetIndex = from < to ? to - 1 : to;\n  if (position === 'after') {\n    targetIndex += 1;\n  }\n\n  result.splice(targetIndex, 0, item);\n  return result;\n}\n"],"mappings":";;AAEA,SAAgB,SACd,OACA,MACA,IACA,UACK;CACL,IAAI,SAAS,IACX,OAAO;CAGT,IAAI,aAAa,YAAY,OAAO,OAAO,GACzC,OAAO;CAGT,IAAI,aAAa,WAAW,OAAO,OAAO,GACxC,OAAO;CAGT,MAAM,SAAS,MAAM,MAAM;CAC3B,MAAM,CAAC,QAAQ,OAAO,OAAO,MAAM,CAAC;CAEpC,IAAI,cAAc,OAAO,KAAK,KAAK,IAAI;CACvC,IAAI,aAAa,SACf,eAAe;CAGjB,OAAO,OAAO,aAAa,GAAG,IAAI;CAClC,OAAO;AACT"}