((o) => {
  "undefined" != typeof wpcf7 &&
    null !== wpcf7 &&
    ((wpcf7 = o.extend({ cached: 0, inputs: [] }, wpcf7)),
    o(function () {
      (wpcf7.supportHtml5 = (() => {
        var a = {},
          i = document.createElement("input");
        return (
          (a.placeholder = "placeholder" in i),
          o.each(
            ["email", "url", "tel", "number", "range", "date"],
            function (t, e) {
              i.setAttribute("type", e), (a[e] = "text" !== i.type);
            },
          ),
          a
        );
      })()),
        o("div.wpcf7 > form").each(function () {
          var t = o(this);
          wpcf7.initForm(t), wpcf7.cached && wpcf7.refill(t);
        });
    }),
    (wpcf7.getId = function (t) {
      return parseInt(o('input[name="_wpcf7"]', t).val(), 10);
    }),
    (wpcf7.initForm = function (t) {
      var e = o(t);
      wpcf7.setStatus(e, "init"),
        e.submit(function (t) {
          wpcf7.supportHtml5.placeholder ||
            o("[placeholder].placeheld", e).each(function (t, e) {
              o(e).val("").removeClass("placeheld");
            }),
            "function" == typeof window.FormData &&
              (wpcf7.submit(e), t.preventDefault());
        }),
        o(".wpcf7-submit", e).after('<span class="ajax-loader"></span>'),
        wpcf7.toggleSubmit(e),
        e.on("click", ".wpcf7-acceptance", function () {
          wpcf7.toggleSubmit(e);
        }),
        o(".wpcf7-exclusive-checkbox", e).on(
          "click",
          "input:checkbox",
          function () {
            var t = o(this).attr("name");
            e.find('input:checkbox[name="' + t + '"]')
              .not(this)
              .prop("checked", !1);
          },
        ),
        o(".wpcf7-list-item.has-free-text", e).each(function () {
          var t = o(":input.wpcf7-free-text", this),
            e = o(this).closest(".wpcf7-form-control");
          o(":checkbox, :radio", this).is(":checked")
            ? t.prop("disabled", !1)
            : t.prop("disabled", !0),
            e.on("change", ":checkbox, :radio", function () {
              o(".has-free-text", e).find(":checkbox, :radio").is(":checked")
                ? t.prop("disabled", !1).focus()
                : t.prop("disabled", !0);
            });
        }),
        wpcf7.supportHtml5.placeholder ||
          o("[placeholder]", e).each(function () {
            o(this).val(o(this).attr("placeholder")),
              o(this).addClass("placeheld"),
              o(this).focus(function () {
                o(this).hasClass("placeheld") &&
                  o(this).val("").removeClass("placeheld");
              }),
              o(this).blur(function () {
                "" === o(this).val() &&
                  (o(this).val(o(this).attr("placeholder")),
                  o(this).addClass("placeheld"));
              });
          }),
        wpcf7.jqueryUi &&
          !wpcf7.supportHtml5.date &&
          e.find('input.wpcf7-date[type="date"]').each(function () {
            o(this).datepicker({
              dateFormat: "yy-mm-dd",
              minDate: new Date(o(this).attr("min")),
              maxDate: new Date(o(this).attr("max")),
            });
          }),
        wpcf7.jqueryUi &&
          !wpcf7.supportHtml5.number &&
          e.find('input.wpcf7-number[type="number"]').each(function () {
            o(this).spinner({
              min: o(this).attr("min"),
              max: o(this).attr("max"),
              step: o(this).attr("step"),
            });
          }),
        wpcf7.resetCounter(e),
        e.on("change", ".wpcf7-validates-as-url", function () {
          var t = o.trim(o(this).val());
          t &&
            !t.match(/^[a-z][a-z0-9.+-]*:/i) &&
            -1 !== t.indexOf(".") &&
            (t = "http://" + (t = t.replace(/^\/+/, ""))),
            o(this).val(t);
        });
    }),
    (wpcf7.submit = function (t) {
      var c, s;
      "function" == typeof window.FormData &&
        ((c = o(t)),
        o(".ajax-loader", c).addClass("is-active"),
        wpcf7.clearResponse(c),
        (t = new FormData(c.get(0))),
        (s = {
          id: c.closest("div.wpcf7").attr("id"),
          status: "init",
          inputs: [],
          formData: t,
        }),
        o.each(c.serializeArray(), function (t, e) {
          "_wpcf7" == e.name
            ? (s.contactFormId = e.value)
            : "_wpcf7_version" == e.name
              ? (s.pluginVersion = e.value)
              : "_wpcf7_locale" == e.name
                ? (s.contactFormLocale = e.value)
                : "_wpcf7_unit_tag" == e.name
                  ? (s.unitTag = e.value)
                  : "_wpcf7_container_post" == e.name
                    ? (s.containerPostId = e.value)
                    : e.name.match(/^_/) || s.inputs.push(e);
        }),
        wpcf7.triggerEvent(c.closest("div.wpcf7"), "beforesubmit", s),
        o
          .ajax({
            type: "POST",
            url: wpcf7.apiSettings.getRoute(
              "/contact-forms/" + wpcf7.getId(c) + "/feedback",
            ),
            data: t,
            dataType: "json",
            processData: !1,
            contentType: !1,
          })
          .done(function (t, e, a) {
            var n = t,
              i = c;
            switch (
              ((s.id = o(n.into).attr("id")),
              (s.status = n.status),
              (s.apiResponse = n).status)
            ) {
              case "init":
                wpcf7.setStatus(i, "init");
                break;
              case "validation_failed":
                o.each(n.invalid_fields, function (t, e) {
                  o(e.into, i).each(function () {
                    wpcf7.notValidTip(this, e.message),
                      o(".wpcf7-form-control", this).addClass(
                        "wpcf7-not-valid",
                      ),
                      o(".wpcf7-form-control", this).attr(
                        "aria-describedby",
                        e.error_id,
                      ),
                      o("[aria-invalid]", this).attr("aria-invalid", "true");
                  });
                }),
                  wpcf7.setStatus(i, "invalid"),
                  wpcf7.triggerEvent(n.into, "invalid", s);
                break;
              case "acceptance_missing":
                wpcf7.setStatus(i, "unaccepted"),
                  wpcf7.triggerEvent(n.into, "unaccepted", s);
                break;
              case "spam":
                wpcf7.setStatus(i, "spam"),
                  wpcf7.triggerEvent(n.into, "spam", s);
                break;
              case "aborted":
                wpcf7.setStatus(i, "aborted"),
                  wpcf7.triggerEvent(n.into, "aborted", s);
                break;
              case "mail_sent":
                wpcf7.setStatus(i, "sent"),
                  wpcf7.triggerEvent(n.into, "mailsent", s);
                break;
              case "mail_failed":
                wpcf7.setStatus(i, "failed"),
                  wpcf7.triggerEvent(n.into, "mailfailed", s);
                break;
              default:
                wpcf7.setStatus(
                  i,
                  "custom-" + n.status.replace(/[^0-9a-z]+/i, "-"),
                );
            }
            wpcf7.refill(i, n),
              wpcf7.triggerEvent(n.into, "submit", s),
              "mail_sent" == n.status &&
                (i.each(function () {
                  this.reset();
                }),
                wpcf7.toggleSubmit(i),
                wpcf7.resetCounter(i)),
              wpcf7.supportHtml5.placeholder ||
                i.find("[placeholder].placeheld").each(function (t, e) {
                  o(e).val(o(e).attr("placeholder"));
                }),
              o(".wpcf7-response-output", i)
                .html("")
                .append(n.message)
                .slideDown("fast"),
              o(".screen-reader-response", i.closest(".wpcf7")).each(
                function () {
                  var i = o(this);
                  o('[role="status"]', i).html(n.message),
                    n.invalid_fields &&
                      o.each(n.invalid_fields, function (t, e) {
                        var a;
                        (a = e.idref
                          ? o("<li></li>").append(
                              o("<a></a>")
                                .attr("href", "#" + e.idref)
                                .append(e.message),
                            )
                          : o("<li></li>").append(e.message)).attr(
                          "id",
                          e.error_id,
                        ),
                          o("ul", i).append(a);
                      });
                },
              ),
              n.posted_data_hash &&
                i
                  .find('input[name="_wpcf7_posted_data_hash"]')
                  .first()
                  .val(n.posted_data_hash),
              o(".ajax-loader", c).removeClass("is-active");
          })
          .fail(function (t, e, a) {
            a = o('<div class="ajax-error"></div>').text(a.message);
            c.after(a);
          }));
    }),
    (wpcf7.triggerEvent = function (t, e, a) {
      e = new CustomEvent("wpcf7" + e, { bubbles: !0, detail: a });
      o(t).get(0).dispatchEvent(e);
    }),
    (wpcf7.setStatus = function (t, e) {
      var t = o(t),
        a = t.attr("data-status");
      t.data("status", e),
        t.addClass(e),
        t.attr("data-status", e),
        a && a !== e && t.removeClass(a);
    }),
    (wpcf7.toggleSubmit = function (t, e) {
      var t = o(t),
        a = o("input:submit", t);
      void 0 !== e
        ? a.prop("disabled", !e)
        : t.hasClass("wpcf7-acceptance-as-validation") ||
          (a.prop("disabled", !1),
          o(".wpcf7-acceptance", t).each(function () {
            var t = o(this),
              e = o("input:checkbox", t);
            if (
              !t.hasClass("optional") &&
              ((t.hasClass("invert") && e.is(":checked")) ||
                (!t.hasClass("invert") && !e.is(":checked")))
            )
              return a.prop("disabled", !0), !1;
          }));
    }),
    (wpcf7.resetCounter = function (t) {
      var p = o(t);
      o(".wpcf7-character-count", p).each(function () {
        function t(t) {
          var t = o(t).val().length,
            e = i ? n - t : t;
          a.attr("data-current-value", e),
            a.text(e),
            c && c < t ? a.addClass("too-long") : a.removeClass("too-long"),
            s && t < s ? a.addClass("too-short") : a.removeClass("too-short");
        }
        var a = o(this),
          e = a.attr("data-target-name"),
          i = a.hasClass("down"),
          n = parseInt(a.attr("data-starting-value"), 10),
          c = parseInt(a.attr("data-maximum-value"), 10),
          s = parseInt(a.attr("data-minimum-value"), 10);
        o(':input[name="' + e + '"]', p).each(function () {
          t(this),
            o(this).keyup(function () {
              t(this);
            });
        });
      });
    }),
    (wpcf7.notValidTip = function (t, e) {
      var a,
        i = o(t);
      o(".wpcf7-not-valid-tip", i).remove(),
        o("<span></span>")
          .attr({ class: "wpcf7-not-valid-tip", "aria-hidden": "true" })
          .text(e)
          .appendTo(i),
        i.is(".use-floating-validation-tip *") &&
          ((a = function (t) {
            o(t)
              .not(":hidden")
              .animate({ opacity: 0 }, "fast", function () {
                o(this).css({ "z-index": -100 });
              });
          }),
          i.on("mouseover", ".wpcf7-not-valid-tip", function () {
            a(this);
          }),
          i.on("focus", ":input", function () {
            a(o(".wpcf7-not-valid-tip", i));
          }));
    }),
    (wpcf7.refill = function (t, e) {
      function i(a, t) {
        o.each(t, function (t, e) {
          a.find(':input[name="' + t + '"]').val(""),
            a.find("img.wpcf7-captcha-" + t).attr("src", e);
          e = /([0-9]+)\.(png|gif|jpeg)$/.exec(e);
          a.find(
            'input:hidden[name="_wpcf7_captcha_challenge_' + t + '"]',
          ).attr("value", e[1]);
        });
      }
      function n(a, t) {
        o.each(t, function (t, e) {
          a.find(':input[name="' + t + '"]').val(""),
            a
              .find(':input[name="' + t + '"]')
              .siblings("span.wpcf7-quiz-label")
              .text(e[0]),
            a
              .find('input:hidden[name="_wpcf7_quiz_answer_' + t + '"]')
              .attr("value", e[1]);
        });
      }
      var c = o(t);
      void 0 === e
        ? o
            .ajax({
              type: "GET",
              url: wpcf7.apiSettings.getRoute(
                "/contact-forms/" + wpcf7.getId(c) + "/refill",
              ),
              beforeSend: function (t) {
                var e = c.find(':input[name="_wpnonce"]').val();
                e && t.setRequestHeader("X-WP-Nonce", e);
              },
              dataType: "json",
            })
            .done(function (t, e, a) {
              t.captcha && i(c, t.captcha), t.quiz && n(c, t.quiz);
            })
        : (e.captcha && i(c, e.captcha), e.quiz && n(c, e.quiz));
    }),
    (wpcf7.clearResponse = function (t) {
      t = o(t);
      t.siblings(".screen-reader-response").each(function () {
        o('[role="status"]', this).html(""), o("ul", this).html("");
      }),
        o(".wpcf7-not-valid-tip", t).remove(),
        o("[aria-invalid]", t).attr("aria-invalid", "false"),
        o(".wpcf7-form-control", t).removeClass("wpcf7-not-valid"),
        o(".wpcf7-response-output", t).hide().empty();
    }),
    (wpcf7.apiSettings.getRoute = function (t) {
      return wpcf7.apiSettings.root.replace(
        wpcf7.apiSettings.namespace,
        wpcf7.apiSettings.namespace + t,
      );
    }));
})(jQuery),
  (() => {
    function t(t, e) {
      e = e || { bubbles: !1, cancelable: !1, detail: void 0 };
      var a = document.createEvent("CustomEvent");
      return a.initCustomEvent(t, e.bubbles, e.cancelable, e.detail), a;
    }
    "function" != typeof window.CustomEvent &&
      ((t.prototype = window.Event.prototype), (window.CustomEvent = t));
  })();
