// #region Imports
// #endregion
// #region Array Manipulation
/**
 * Move an item within an array.
 *
 * @param array - Array to modify.
 * @param fromIndex - Source index.
 * @param toIndex - Target index.
 * @returns Modified array (same reference).
 *
 * @public
 */
export function moveItemInArray(array, fromIndex, toIndex) {
    const item = array[fromIndex];
    array.splice(fromIndex, 1);
    array.splice(toIndex, 0, item);
    return array;
}
/**
 * Transfer an item from one array to another.
 *
 * @param sourceArray - Source array.
 * @param targetArray - Target array.
 * @param sourceIndex - Index in source array.
 * @param targetIndex - Index in target array.
 *
 * @public
 */
export function transferArrayItem(sourceArray, targetArray, sourceIndex, targetIndex) {
    const item = sourceArray[sourceIndex];
    sourceArray.splice(sourceIndex, 1);
    targetArray.splice(targetIndex, 0, item);
}
/**
 * Copy an item from one array to another.
 *
 * @param sourceArray - Source array.
 * @param targetArray - Target array.
 * @param sourceIndex - Index in source array.
 * @param targetIndex - Index in target array.
 *
 * @public
 */
export function copyArrayItem(sourceArray, targetArray, sourceIndex, targetIndex) {
    const item = sourceArray[sourceIndex];
    targetArray.splice(targetIndex, 0, item);
}
// #endregion
// #region Immutable Variants
/**
 * Move an item within an array (immutable).
 *
 * @param array - Original array.
 * @param fromIndex - Source index.
 * @param toIndex - Target index.
 * @returns New array with item moved.
 *
 * @public
 */
export function moveItemInArrayImmutable(array, fromIndex, toIndex) {
    const newArray = [...array];
    return moveItemInArray(newArray, fromIndex, toIndex);
}
/**
 * Transfer an item from one array to another (immutable).
 *
 * @param sourceArray - Source array.
 * @param targetArray - Target array.
 * @param sourceIndex - Index in source array.
 * @param targetIndex - Index in target array.
 * @returns Object with new source and target arrays.
 *
 * @public
 */
export function transferArrayItemImmutable(sourceArray, targetArray, sourceIndex, targetIndex) {
    const newSource = [...sourceArray];
    const newTarget = [...targetArray];
    transferArrayItem(newSource, newTarget, sourceIndex, targetIndex);
    return { from: newSource,
        to: newTarget };
}
// #endregion
//# sourceMappingURL=ArrayUtils.js.map