"use client";
export { adaptWorkflowGraphToUi, formatDurationMs } from '../../chunk-UQXVCVAN.mjs';
export { buildLambdaApiUrl, getLambdaApiBase } from '../../chunk-3AY5HIQ6.mjs';

// src/platform/utils/json-parse.ts
function tryParseJson(value) {
  const raw = typeof value === "string" ? value.trim() : "";
  if (!raw) return void 0;
  try {
    return JSON.parse(raw);
  } catch {
    return void 0;
  }
}
function tryParseJsonObject(value) {
  const parsed = tryParseJson(value);
  if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
    return parsed;
  }
  return void 0;
}
function tryParseJsonArray(value) {
  const parsed = tryParseJson(value);
  if (Array.isArray(parsed)) {
    return parsed;
  }
  return void 0;
}

// src/platform/utils/tool-category.ts
var TOOL_CATEGORY_VALUES = [
  "search",
  "code",
  "file",
  "web",
  "math",
  "custom"
];
var TOOL_CATEGORY_SET = new Set(TOOL_CATEGORY_VALUES);
function parseToolCategory(value) {
  const str = typeof value === "string" ? value.trim() : "";
  return TOOL_CATEGORY_SET.has(str) ? str : void 0;
}

// src/platform/utils/auth-app.ts
function requireEnv(name) {
  const rawValue = import.meta.env[name];
  if (typeof rawValue !== "string") {
    throw new Error(`Missing required environment variable: ${name}`);
  }
  const value = rawValue.trim();
  if (!value) {
    throw new Error(`Missing required environment variable: ${name}`);
  }
  return value.replace(/\/+$/, "");
}
function getAuthAppUrl() {
  return requireEnv("VITE_AUTH_APP_URL");
}
function buildHostedAuthUrl(path, search = "") {
  const authAppUrl = getAuthAppUrl();
  const normalizedPath = path.startsWith("/") ? path : `/${path}`;
  const normalizedSearch = search.startsWith("?") ? search : search ? `?${search}` : "";
  return `${authAppUrl}${normalizedPath}${normalizedSearch}`;
}

export { TOOL_CATEGORY_VALUES, buildHostedAuthUrl, getAuthAppUrl, parseToolCategory, tryParseJson, tryParseJsonArray, tryParseJsonObject };
//# sourceMappingURL=index.mjs.map
//# sourceMappingURL=index.mjs.map