"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactBinding = require("@contember/react-binding");
const RoutingParameter = require("../RoutingParameter.cjs");
const parseLinkTarget = (to, env) => {
  if (typeof to !== "string") {
    return to;
  }
  const parsedTarget = reactBinding.QueryLanguage.desugarTaggedMap(to, env);
  return {
    pageName: parsedTarget.name,
    parameters: Object.fromEntries(parsedTarget.entries.map((it) => {
      switch (it.value.type) {
        case "literal":
          return [it.key, typeof it.value.value === "number" ? String(it.value.value) : it.value.value ?? void 0];
        case "variable":
          return [it.key, new RoutingParameter.RoutingParameter(it.value.value)];
      }
    }))
  };
};
exports.parseLinkTarget = parseLinkTarget;
//# sourceMappingURL=LinkLanguage.cjs.map
