import { DataSourceUtils as l } from "../../datasource/utils/utils.mjs";
import { EventUtils as p } from "../utils/utils.mjs";
const S = (g, w) => {
  const { pageAction: e } = g, d = l.getVariableData(), s = l.replaceStringVariables(e.parameter, d), r = s ? p.urlParamToJson(s) : null;
  let a = e.target;
  if (!a && e.pageId && (window.location.href.includes("/sharing") && (window.location.href.includes("/#") ? a = `/#/proto/${e.pageId}/sharing` : a = `/proto/${e.pageId}/sharing`), window.location.href.includes("/release") && (window.location.href.includes("/#") ? a = `/#/release/${e.pageId}` : a = `/release/${e.pageId}`)), !a)
    return;
  const t = new URL(a, window.location.origin);
  if (r) {
    const n = t.toString().indexOf("/#/");
    if (n !== -1) {
      const o = t.toString().substring(0, n), i = t.toString().substring(n), c = new URLSearchParams();
      Object.entries(r).forEach(([f, h]) => {
        c.append(f, h);
      }), window.location.href = `${o}${i}?${c.toString()}`;
    } else
      Object.entries(r).forEach(([o, i]) => {
        t.searchParams.append(o, i);
      }), window.location.href = t.toString();
  } else
    window.location.href = t.toString();
};
export {
  S as executePageAction
};
