"use client";
'use strict';

var chunk3T2WGL47_js = require('../../chunk-3T2WGL47.js');
var chunkFAGDZEKM_js = require('../../chunk-FAGDZEKM.js');

// 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 = undefined[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}`;
}

Object.defineProperty(exports, "adaptWorkflowGraphToUi", {
  enumerable: true,
  get: function () { return chunk3T2WGL47_js.adaptWorkflowGraphToUi; }
});
Object.defineProperty(exports, "formatDurationMs", {
  enumerable: true,
  get: function () { return chunk3T2WGL47_js.formatDurationMs; }
});
Object.defineProperty(exports, "buildLambdaApiUrl", {
  enumerable: true,
  get: function () { return chunkFAGDZEKM_js.buildLambdaApiUrl; }
});
Object.defineProperty(exports, "getLambdaApiBase", {
  enumerable: true,
  get: function () { return chunkFAGDZEKM_js.getLambdaApiBase; }
});
exports.TOOL_CATEGORY_VALUES = TOOL_CATEGORY_VALUES;
exports.buildHostedAuthUrl = buildHostedAuthUrl;
exports.getAuthAppUrl = getAuthAppUrl;
exports.parseToolCategory = parseToolCategory;
exports.tryParseJson = tryParseJson;
exports.tryParseJsonArray = tryParseJsonArray;
exports.tryParseJsonObject = tryParseJsonObject;
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index.js.map