"use client";
'use strict';

// src/platform/utils/workflow-graph-adapter.ts
function assertEntityConfig(node) {
  if (node.type !== "entity") return node;
  const config = node.data.config;
  if (!config || config.type !== "entity") {
    throw new Error(`Entity node ${node.id} is missing entity config`);
  }
  const entityConfig = config;
  if (!entityConfig.entityMasterId || entityConfig.entityMasterId.trim().length === 0) {
    throw new Error(`Entity node ${node.id} is missing required entityMasterId`);
  }
  return node;
}
function adaptWorkflowGraphToUi(graph) {
  const nodes = graph.nodes.map((node) => assertEntityConfig(node));
  return {
    nodes,
    edges: graph.edges,
    viewport: graph.viewport
  };
}

// src/platform/utils/format-duration.ts
function formatDurationMs(ms) {
  if (ms === null || ms === void 0 || Number.isNaN(ms)) return "\u2014";
  if (ms < 0) return "\u2014";
  if (ms < 1e3) return `${Math.round(ms)}ms`;
  const totalSeconds = ms / 1e3;
  if (totalSeconds < 60) return `${totalSeconds.toFixed(totalSeconds < 10 ? 2 : 1)}s`;
  const minutes = Math.floor(totalSeconds / 60);
  const seconds = Math.round(totalSeconds - minutes * 60);
  if (minutes < 60) return seconds === 0 ? `${minutes}m` : `${minutes}m ${seconds}s`;
  const hours = Math.floor(minutes / 60);
  const remainingMinutes = minutes - hours * 60;
  return remainingMinutes === 0 ? `${hours}h` : `${hours}h ${remainingMinutes}m`;
}

exports.adaptWorkflowGraphToUi = adaptWorkflowGraphToUi;
exports.formatDurationMs = formatDurationMs;
//# sourceMappingURL=chunk-3T2WGL47.js.map
//# sourceMappingURL=chunk-3T2WGL47.js.map