import { jsxs as n, Fragment as c, jsx as r } from "react/jsx-runtime";
import { useState as d } from "react";
import { useLoadFrmType as f } from "./hooks/useLoadFiles.js";
import { u as p } from "./useQuery-n4ls1rLk.js";
import t from "./components/AlertDialog/index.js";
import l from "./components/Buttons/index.js";
import { BasicFormProvider as v } from "./components/FormProvider.js";
import s from "./composables/FormInputs.js";
import { formClient as x } from "./config/index.js";
const D = () => {
  const [a, i] = d(!1), { configFrm: o } = f(), m = p(), u = async (e) => {
    await x.put("frmtype", {
      id: "42404B79-6BA6-EE11-B9E7-C87F5406F554",
      name: "formulario test",
      description: "este es un formulario",
      jsx: e.jsx,
      functions: e.functions || "5971536A-6BA6-EE11-B9E7-C87F5406F554"
    }), m.invalidateQueries({ queryKey: ["frmtype"] }), i(!1);
  };
  return o ? /* @__PURE__ */ n(c, { children: [
    /* @__PURE__ */ r("div", { className: "_flex", children: /* @__PURE__ */ r(l.Button, { onClick: () => i(!a), children: "Editar Formulario" }) }),
    /* @__PURE__ */ r(t.AlertDialog, { open: a, children: /* @__PURE__ */ n(t.AlertDialogContent, { variant: { variant: "govco" }, children: [
      /* @__PURE__ */ r(t.AlertDialogHeader, { variants: { variant: "govco" }, closeModal: () => i(!1), children: "Editar formulario" }),
      /* @__PURE__ */ n(
        v,
        {
          className: "_px-2",
          submit: (e) => u(e),
          defaultValue: { jsx: o == null ? void 0 : o.jsx, functions: o == null ? void 0 : o.functions },
          children: [
            /* @__PURE__ */ r(
              s.InputFormCntx,
              {
                currentId: "functions",
                label: "GUID de los esquemas (validación, formulas, etc.)",
                placeholder: "ej: 5971536A-6BA6-EE11-B9E7-C87F5406F554"
              }
            ),
            /* @__PURE__ */ r(s.TextAreaFormCntx, { currentId: "jsx", inputProps: { rows: 15, style: { resize: "none" } }, label: "Plantilla del formulario" }),
            /* @__PURE__ */ r(t.AlertDialogFooter, { variants: { variant: "govco" }, children: /* @__PURE__ */ r(l.FormButton, { children: "Editar" }) })
          ]
        }
      )
    ] }) })
  ] }) : "loading...";
};
export {
  D as ConfigForm
};
