export function createSessionSnapshotSummary(snapshot, fallbackLabel = null) {
  const metadata = snapshot?.metadata ?? {};
  const files = snapshot?.payload?.files ?? {};
  return {
    snapshotLabel: fallbackLabel ?? metadata.snapshotLabel ?? null,
    workflow: metadata.workflow ?? null,
    defaultGcodeOpfsPath: metadata.defaultGcodeOpfsPath ?? null,
    iniOpfsPath: files.ini ?? null,
    parameterOpfsPath: files.parameters ?? null,
    toolTableOpfsPath: files.toolTable ?? null,
    gcodeOpfsPath: files.gcode ?? null,
  };
}

export function sessionSnapshotSummaryLogLines(summary) {
  return [
    `Snapshot: ${summary.snapshotLabel ?? "-"}`,
    `Workflow: ${summary.workflow ?? "-"}`,
    `Default G-code: ${summary.defaultGcodeOpfsPath ?? "-"}`,
  ];
}

export function sessionSnapshotMetadataLogLines(summary) {
  return [
    `Workflow: ${summary.workflow ?? "-"}`,
    `Default G-code: ${summary.defaultGcodeOpfsPath ?? "-"}`,
  ];
}
