import { expose, groupTracksPerScheme, transfer } from "@scripts/common";
import { CONNECTIONS } from "./constants";
import type { Track } from "@applets/core/types";

////////////////////////////////////////////
// ACTIONS
////////////////////////////////////////////
const actions = expose({
  groupTracks,
});

export type Actions = typeof actions;

// Actions

function groupTracks(tracks: Track[]) {
  const grouped = groupTracksPerScheme(
    tracks,
    Object.fromEntries(
      Object.entries(CONNECTIONS).map(([k, _v]) => {
        return [k, []];
      }),
    ),
  );

  return transfer(grouped);
}
