import { defineComponent as h, computed as R, createBlock as s, openBlock as r, unref as n, withCtx as o, createVNode as m, createElementVNode as d, createCommentVNode as g, withModifiers as x, createTextVNode as u, toDisplayString as c } from "vue";
import { ScalarTooltip as b, ScalarButton as y } from "@scalar/components";
import P from "./RequestTable.vue.js";
import C from "../../../components/layout/CollapsibleSection.vue.js";
const A = { class: "text-c-2 request-meta-buttons flex whitespace-nowrap opacity-0 group-hover/params:opacity-100 has-[:focus-visible]:opacity-100" }, B = { class: "sr-only" }, V = /* @__PURE__ */ h({
  __name: "RequestParams",
  props: {
    rows: {},
    exampleKey: {},
    title: {},
    label: {},
    invalidParams: {},
    globalRoute: {},
    showAddRowPlaceholder: { type: Boolean, default: !0 },
    environment: {},
    eventBus: {}
  },
  emits: ["upsert", "delete", "deleteAll"],
  setup(e, { emit: f }) {
    const a = f, v = R(() => e.rows.length > 1), w = (i, t) => {
      const { value: l, ...p } = t;
      l instanceof File || a("upsert", i, { ...p, value: l ?? "" });
    };
    return (i, t) => (r(), s(n(C), {
      class: "group/params",
      itemCount: e.rows.length
    }, {
      title: o(() => [
        u(c(e.title), 1)
      ]),
      actions: o(() => [
        d("div", A, [
          v.value ? (r(), s(n(b), {
            key: 0,
            content: "Clear optional parameters",
            placement: "left"
          }, {
            default: o(() => [
              m(n(y), {
                class: "pr-0.75 pl-1 transition-none",
                size: "sm",
                variant: "ghost",
                onClick: t[0] || (t[0] = x((l) => a("deleteAll"), ["stop"]))
              }, {
                default: o(() => [
                  t[3] || (t[3] = u(" Clear ", -1)),
                  d("span", B, "All " + c(e.title), 1)
                ]),
                _: 1
              })
            ]),
            _: 1
          })) : g("", !0)
        ])
      ]),
      default: o(() => [
        m(P, {
          class: "flex-1",
          columns: ["32px", "", ""],
          data: e.rows,
          environment: e.environment,
          exampleKey: e.exampleKey,
          globalRoute: e.globalRoute,
          invalidParams: e.invalidParams,
          label: e.label,
          showAddRowPlaceholder: e.showAddRowPlaceholder,
          onDeleteRow: t[1] || (t[1] = (l) => a("delete", { index: l })),
          onNavigate: t[2] || (t[2] = (l) => e.eventBus.emit("ui:navigate", l)),
          onUpsertRow: w
        }, null, 8, ["data", "environment", "exampleKey", "globalRoute", "invalidParams", "label", "showAddRowPlaceholder"])
      ]),
      _: 1
    }, 8, ["itemCount"]));
  }
});
export {
  V as default
};
