import { getResolvedRef as s } from "@scalar/workspace-store/helpers/get-resolved-ref";
const f = (e, t) => "content" in t ? o(e, Object.keys(t.content ?? {})[0] ?? "") : "schema" in t ? y(e, t.schema) : e, o = (e, t) => {
  if (typeof e == "string" && t.includes("json"))
    try {
      return JSON.parse(e);
    } catch {
    }
  return e;
}, c = /* @__PURE__ */ new Set(["array", "object", "boolean", "number", "integer", "null"]), y = (e, t) => {
  const r = s(t);
  if (typeof e == "string" && r && "type" in r) {
    const n = Array.isArray(r.type) ? r.type[0] : r.type;
    if (n && c.has(n))
      try {
        return JSON.parse(e);
      } catch {
        if (n === "array")
          return e.split(/,\s?/).filter((i) => i !== "");
      }
  }
  return e;
};
export {
  f as deSerializeParameter
};
