import { jsxs as c, jsx as e, Fragment as F } from "react/jsx-runtime";
import { o as le, an as X, I as v, S as h, B as x, ao as C, ap as J, aq as Q, n as E, ar as P, p as re, q as de, as as T, W as ue, L as Z, a8 as me, t as fe } from "./index-C62tPk5p.js";
import { useState as w } from "react";
import { S as t, A as ve } from "./AppCard-CQEg94Y3.js";
import { u as he } from "./useIsAppEnabled-DnQeiNdg.js";
const pe = ({
  fieldRules: _,
  updateFieldRules: L
}) => {
  const { t: S } = le(), A = [
    { label: S("salesforce_rr_skip_field_rule_ignore"), value: X.IGNORE },
    { label: S("salesforce_rr_skip_field_rule_must_include"), value: X.MUST_INCLUDE }
  ], [s, r] = w({
    field: "",
    value: "",
    action: X.IGNORE
  }), [i, R] = w(null), [u, N] = w(null), O = (m) => {
    const k = _[m];
    R(m), N({ field: k.field, value: k.value, action: k.action });
  }, H = () => {
    R(null), N(null);
  }, j = () => {
    if (i === null || !u || !u.field.trim() || !u.value.trim()) return;
    const m = [..._];
    m[i] = {
      field: u.field.trim(),
      value: u.value.trim(),
      action: u.action
    }, L(m), H();
  };
  return /* @__PURE__ */ c(t.SubSection, { children: [
    /* @__PURE__ */ e(
      t.SubSectionHeader,
      {
        icon: "filter",
        title: S("salesforce_rr_skip_field_rules"),
        labelFor: "rr-skip-field-rules",
        children: /* @__PURE__ */ e(F, {})
      }
    ),
    /* @__PURE__ */ c(t.SubSectionContent, { children: [
      /* @__PURE__ */ c("div", { className: "text-subtle flex gap-3 px-3 py-[6px] text-sm font-medium", children: [
        /* @__PURE__ */ e("div", { className: "flex-1", children: S("field_name") }),
        /* @__PURE__ */ e("div", { className: "flex-1", children: S("value") }),
        /* @__PURE__ */ e("div", { className: "w-32", children: S("action") }),
        /* @__PURE__ */ e("div", { className: "w-20" })
      ] }),
      /* @__PURE__ */ c(t.SubSectionNested, { children: [
        _.map((m, k) => {
          const W = i === k;
          return /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ e("div", { className: "flex-1", children: W ? /* @__PURE__ */ e(
              v,
              {
                value: (u == null ? void 0 : u.field) || "",
                onChange: (p) => N((b) => b ? { ...b, field: p.target.value } : null),
                size: "sm",
                className: "w-full"
              }
            ) : /* @__PURE__ */ e(v, { value: m.field, readOnly: !0, size: "sm", className: "w-full" }) }),
            /* @__PURE__ */ e("div", { className: "flex-1", children: W ? /* @__PURE__ */ e(
              v,
              {
                value: (u == null ? void 0 : u.value) || "",
                onChange: (p) => N((b) => b ? { ...b, value: p.target.value } : null),
                size: "sm",
                className: "w-full"
              }
            ) : /* @__PURE__ */ e(v, { value: m.value, readOnly: !0, size: "sm", className: "w-full" }) }),
            /* @__PURE__ */ e("div", { className: "w-32", children: W ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: A,
                value: A.find((p) => p.value === (u == null ? void 0 : u.action)),
                onChange: (p) => {
                  p && N((b) => b ? { ...b, action: p.value } : null);
                }
              }
            ) : /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: A,
                value: A.find((p) => p.value === m.action),
                isDisabled: !0
              }
            ) }),
            /* @__PURE__ */ e("div", { className: "flex w-20 justify-center gap-1", children: W ? /* @__PURE__ */ c(F, { children: [
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "check",
                  variant: "icon",
                  color: "primary",
                  onClick: () => j()
                }
              ),
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "x",
                  variant: "icon",
                  color: "secondary",
                  onClick: () => H()
                }
              )
            ] }) : /* @__PURE__ */ c(F, { children: [
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "pencil",
                  variant: "icon",
                  color: "minimal",
                  onClick: () => O(k)
                }
              ),
              /* @__PURE__ */ e(
                x,
                {
                  StartIcon: "x",
                  variant: "icon",
                  size: "sm",
                  color: "minimal",
                  onClick: () => {
                    L(_.filter((p, b) => b !== k));
                  }
                }
              )
            ] }) })
          ] }, `${m.field}-${k}`);
        }),
        /* @__PURE__ */ c("div", { className: "mt-2 flex gap-2", children: [
          /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
            v,
            {
              size: "sm",
              className: "w-full",
              placeholder: S("salesforce_field_name_placeholder"),
              value: s.field,
              onChange: (m) => r({ ...s, field: m.target.value })
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
            v,
            {
              size: "sm",
              className: "w-full",
              placeholder: S("value"),
              value: s.value,
              onChange: (m) => r({ ...s, value: m.target.value })
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "w-32", children: /* @__PURE__ */ e(
            h,
            {
              size: "sm",
              className: "w-full",
              options: A,
              value: A.find((m) => m.value === s.action),
              onChange: (m) => {
                m && r({ ...s, action: m.value });
              }
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "w-20" })
        ] })
      ] }),
      /* @__PURE__ */ e(
        x,
        {
          className: "text-subtle mt-2 w-fit",
          StartIcon: "plus",
          color: "minimal",
          size: "sm",
          disabled: !(s.field && s.value),
          onClick: () => {
            L([
              ..._,
              {
                field: s.field.trim(),
                value: s.value.trim(),
                action: s.action
              }
            ]), r({ field: "", value: "", action: X.IGNORE });
          },
          children: S("add_new_rule")
        }
      )
    ] })
  ] });
};
var ee = /* @__PURE__ */ ((_) => (_.ON_BOOKING = "on_booking", _.ON_CANCEL = "on_cancel", _))(ee || {});
const te = ({
  bookingAction: _,
  optionLabel: L,
  optionEnabled: S,
  optionSwitchOnChange: A,
  writeToObjectData: s,
  updateWriteToObjectData: r
}) => {
  const { t: i } = le(), R = [
    { label: i("text"), value: C.TEXT },
    { label: i("date"), value: C.DATE },
    { label: i("phone").charAt(0).toUpperCase() + i("phone").slice(1), value: C.PHONE },
    { label: i("checkbox"), value: C.CHECKBOX },
    { label: i("picklist"), value: C.PICKLIST },
    { label: i("custom"), value: C.CUSTOM }
  ], u = [
    { label: i("only_if_field_is_empty"), value: J.FIELD_EMPTY },
    ..._ === "on_cancel" ? [{ label: i("salesforce_on_every_cancellation"), value: J.EVERY_BOOKING }] : [{ label: i("on_every_booking"), value: J.EVERY_BOOKING }]
  ], N = [
    { label: i("true"), value: !0 },
    { label: i("false"), value: !1 }
  ], O = [
    ..._ === "on_cancel" ? [{ label: i("booking_cancel_date"), value: Q.BOOKING_CANCEL_DATE }] : [],
    { label: i("booking_start_date"), value: Q.BOOKING_START_DATE },
    { label: i("booking_created_date"), value: Q.BOOKING_CREATED_DATE }
  ], [H, j] = w(R[0]), [m, k] = w(O[0]), [W, p] = w(
    N[0]
  ), [b, y] = w(u[0]), [D, G] = w({}), [K, z] = w(
    {}
  ), [f, B] = w({
    field: "",
    fieldType: H.value,
    value: "",
    whenToWrite: b.value
  }), V = (l) => {
    Object.keys(D).forEach((d) => {
      D[d] && d !== l && U(d);
    }), G((d) => ({ ...d, [l]: !0 })), z((d) => ({
      ...d,
      [l]: {
        field: l,
        fieldType: s[l].fieldType,
        value: s[l].value,
        whenToWrite: s[l].whenToWrite
      }
    }));
  }, U = (l) => {
    G((d) => ({ ...d, [l]: !1 })), z((d) => {
      const o = { ...d };
      return delete o[l], o;
    });
  }, $ = (l) => {
    const d = K[l];
    if (!d) return;
    if (!d.field.trim()) {
      P("Field name cannot be empty", "error");
      return;
    }
    if (d.field !== l && Object.keys(s).includes(d.field.trim())) {
      P("Field already exists", "error");
      return;
    }
    const o = { ...s };
    d.field !== l && delete o[l], o[d.field.trim()] = {
      fieldType: d.fieldType,
      value: d.value,
      whenToWrite: d.whenToWrite
    }, r(o), U(l);
  };
  return /* @__PURE__ */ c(F, { children: [
    /* @__PURE__ */ e(t.SubSectionHeader, { icon: "star", labelFor: "write-to-object-settings", title: L, children: /* @__PURE__ */ e(
      E,
      {
        checked: S,
        onCheckedChange: A,
        id: "write-to-object-settings",
        size: "sm"
      }
    ) }),
    S ? /* @__PURE__ */ c(t.SubSectionContent, { children: [
      /* @__PURE__ */ c("div", { className: "text-subtle flex gap-3 px-3 py-[6px] text-sm font-medium", children: [
        /* @__PURE__ */ e("div", { className: "flex-1", children: i("field_name") }),
        /* @__PURE__ */ e("div", { className: "flex-1", children: i("field_type") }),
        /* @__PURE__ */ e("div", { className: "flex-1", children: i("value") }),
        /* @__PURE__ */ e("div", { className: "flex-1", children: i("when_to_write") }),
        /* @__PURE__ */ e("div", { className: "w-20" })
      ] }),
      /* @__PURE__ */ c(t.SubSectionNested, { children: [
        Object.keys(s).map((l) => {
          const d = D[l], o = K[l];
          return /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ e("div", { className: "flex-1", children: d ? /* @__PURE__ */ e(
              v,
              {
                value: (o == null ? void 0 : o.field) || l,
                onChange: (n) => z((g) => ({
                  ...g,
                  [l]: { ...o, field: n.target.value }
                })),
                size: "sm",
                className: "w-full"
              }
            ) : /* @__PURE__ */ e(v, { value: l, readOnly: !0, size: "sm", className: "w-full" }) }),
            /* @__PURE__ */ e("div", { className: "flex-1", children: d ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: R,
                value: R.find((n) => n.value === (o == null ? void 0 : o.fieldType)),
                onChange: (n) => {
                  n && z((g) => ({
                    ...g,
                    [l]: {
                      ...o,
                      fieldType: n.value,
                      ...n.value === C.DATE && {
                        value: O[0].value
                      },
                      ...n.value === C.CHECKBOX && {
                        value: N[0].value
                      }
                    }
                  }));
                }
              }
            ) : /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                value: R.find(
                  (n) => n.value === s[l].fieldType
                ),
                isDisabled: !0
              }
            ) }),
            /* @__PURE__ */ e("div", { className: "flex-1", children: d ? (o == null ? void 0 : o.fieldType) === C.DATE ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: O,
                value: O.find((n) => n.value === o.value),
                onChange: (n) => {
                  n && z((g) => ({
                    ...g,
                    [l]: { ...o, value: n.value }
                  }));
                }
              }
            ) : (o == null ? void 0 : o.fieldType) === C.CHECKBOX ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: N,
                value: N.find((n) => n.value === o.value),
                onChange: (n) => {
                  n && z((g) => ({
                    ...g,
                    [l]: { ...o, value: n.value }
                  }));
                }
              }
            ) : /* @__PURE__ */ e(
              v,
              {
                value: (o == null ? void 0 : o.value) || "",
                onChange: (n) => z((g) => ({
                  ...g,
                  [l]: { ...o, value: n.target.value }
                })),
                size: "sm",
                className: "w-full"
              }
            ) : s[l].fieldType === C.DATE ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                value: O.find(
                  (n) => n.value === s[l].value
                ),
                isDisabled: !0
              }
            ) : s[l].fieldType === C.CHECKBOX ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                value: N.find(
                  (n) => n.value === s[l].value
                ),
                isDisabled: !0
              }
            ) : /* @__PURE__ */ e(
              v,
              {
                value: s[l].value,
                readOnly: !0,
                size: "sm",
                className: "w-full"
              }
            ) }),
            /* @__PURE__ */ e("div", { className: "flex-1", children: d ? /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                options: u,
                value: u.find(
                  (n) => n.value === (o == null ? void 0 : o.whenToWrite)
                ),
                onChange: (n) => {
                  n && z((g) => ({
                    ...g,
                    [l]: { ...o, whenToWrite: n.value }
                  }));
                }
              }
            ) : /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                className: "w-full",
                value: u.find(
                  (n) => n.value === s[l].whenToWrite
                ),
                isDisabled: !0
              }
            ) }),
            /* @__PURE__ */ e("div", { className: "flex w-20 justify-center gap-1", children: d ? /* @__PURE__ */ c(F, { children: [
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "check",
                  variant: "icon",
                  color: "primary",
                  onClick: () => $(l)
                }
              ),
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "x",
                  variant: "icon",
                  color: "secondary",
                  onClick: () => U(l)
                }
              )
            ] }) : /* @__PURE__ */ c(F, { children: [
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "pencil",
                  variant: "icon",
                  color: "minimal",
                  onClick: () => V(l)
                }
              ),
              /* @__PURE__ */ e(
                x,
                {
                  size: "sm",
                  StartIcon: "x",
                  variant: "icon",
                  color: "minimal",
                  onClick: () => {
                    const n = { ...s };
                    delete n[l], r(n);
                  }
                }
              )
            ] }) })
          ] }, l);
        }),
        /* @__PURE__ */ c("div", { className: "flex gap-2", children: [
          /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
            v,
            {
              size: "sm",
              className: "w-full",
              value: f.field,
              onChange: (l) => B({
                ...f,
                field: l.target.value
              })
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
            h,
            {
              size: "sm",
              className: "w-full",
              options: R,
              value: H,
              onChange: (l) => {
                l && (j(l), B({
                  ...f,
                  fieldType: l.value,
                  ...l.value === C.DATE && { value: m.value },
                  ...l.value === C.CHECKBOX && {
                    value: W.value
                  }
                }));
              }
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "flex-1", children: f.fieldType === C.DATE ? /* @__PURE__ */ e(
            h,
            {
              size: "sm",
              className: "w-full",
              options: O,
              value: m,
              onChange: (l) => {
                l && (k(l), B({
                  ...f,
                  value: l.value
                }));
              }
            }
          ) : f.fieldType === C.CHECKBOX ? /* @__PURE__ */ e(
            h,
            {
              size: "sm",
              className: "w-full",
              options: N,
              value: W,
              onChange: (l) => {
                l && (p(l), B({
                  ...f,
                  value: l.value
                }));
              }
            }
          ) : /* @__PURE__ */ e(
            v,
            {
              size: "sm",
              className: "w-full",
              value: f.value,
              onChange: (l) => B({
                ...f,
                value: l.target.value
              })
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
            h,
            {
              size: "sm",
              className: "w-full",
              options: u,
              value: b,
              onChange: (l) => {
                l && (y(l), B({
                  ...f,
                  whenToWrite: l.value
                }));
              }
            }
          ) }),
          /* @__PURE__ */ e("div", { className: "w-20" })
        ] })
      ] }),
      /* @__PURE__ */ e(
        x,
        {
          className: "text-subtle mt-2 w-fit",
          StartIcon: "plus",
          color: "minimal",
          size: "sm",
          disabled: !(f.field && f.fieldType && f.value !== "" && f.whenToWrite),
          onClick: () => {
            if (Object.keys(s).includes(f.field.trim())) {
              P("Field already exists", "error");
              return;
            }
            r({
              ...s,
              [f.field.trim()]: {
                fieldType: f.fieldType,
                value: f.value,
                whenToWrite: f.whenToWrite
              }
            }), B({
              field: "",
              fieldType: R[0].value,
              value: "",
              whenToWrite: u[0].value
            });
          },
          children: i("add_new_field")
        }
      )
    ] }) : null
  ] });
}, _e = function({ app: L, eventType: S, onAppInstallSuccess: A }) {
  var ie;
  const s = re.usePathname(), { getAppData: r, setAppData: i, disabled: R } = de(), { enabled: u, updateEnabled: N } = he(L), O = r("roundRobinLeadSkip"), H = r("roundRobinSkipCheckRecordOn") ?? T.CONTACT, j = r("ifFreeEmailDomainSkipOwnerCheck") ?? !1, m = r("skipContactCreation"), k = r("createLeadIfAccountNull"), W = r("createNewContactUnderAccount"), p = r("createEventOn") ?? T.CONTACT, b = r("onBookingWriteToEventObject") ?? !1, y = r("onBookingWriteToEventObjectMap") ?? {}, D = r("createEventOnLeadCheckForContact") ?? !1, G = r("onBookingChangeRecordOwner") ?? !1, K = r("onBookingChangeRecordOwnerName") ?? [], z = r("sendNoShowAttendeeData") ?? !1, f = r("sendNoShowAttendeeDataField") ?? "", B = r("onBookingWriteToRecord") ?? !1, V = r("onBookingWriteToRecordFields") ?? {}, U = r("ignoreGuests") ?? !1, $ = r("roundRobinSkipFallbackToLeadOwner") ?? !1, l = r("onCancelWriteToEventRecord") ?? !1, d = r("onCancelWriteToEventRecordFields") ?? {}, o = r("rrSkipFieldRules") ?? [], { t: n } = le(), g = [
    { label: n("contact"), value: T.CONTACT },
    { label: n("salesforce_lead"), value: T.LEAD },
    { label: n("salesforce_contact_under_account"), value: T.ACCOUNT }
  ], [M, oe] = w(
    g.find((a) => a.value === p) ?? g[0]
  ), Y = [
    { label: n("contact"), value: T.CONTACT },
    { label: n("salesforce_lead"), value: T.LEAD },
    { label: n("account"), value: T.ACCOUNT }
  ], [ne, ce] = w(
    Y.find((a) => a.value === H) ?? Y[0]
  ), [I, q] = w({
    field: "",
    value: ""
  }), ae = () => /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
    t.SubSectionHeader,
    {
      icon: "at-sign",
      title: n("salesforce_create_new_contact_under_account"),
      labelFor: "create-new-contact-under-account",
      children: /* @__PURE__ */ e(
        E,
        {
          size: "sm",
          labelOnLeading: !0,
          checked: W,
          onCheckedChange: (a) => {
            i("createNewContactUnderAccount", a);
          }
        }
      )
    }
  ) });
  return /* @__PURE__ */ e(
    ve,
    {
      onAppInstallSuccess: A,
      returnTo: `${ue}${s}?tabName=apps`,
      app: L,
      teamId: ((ie = S.team) == null ? void 0 : ie.id) || void 0,
      switchOnClick: (a) => {
        N(a);
      },
      switchChecked: u,
      hideSettingsIcon: !0,
      children: /* @__PURE__ */ c(t.Content, { children: [
        /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
          t.SubSectionHeader,
          {
            icon: "zap",
            title: n("salesforce_add_attendees_as"),
            justify: "start",
            labelFor: "add-attendees-as",
            children: /* @__PURE__ */ e(
              h,
              {
                size: "sm",
                id: "add-attendees-as",
                className: "w-[200px]",
                options: g,
                value: M,
                onChange: (a) => {
                  a && (oe(a), i("createEventOn", a.value));
                }
              }
            )
          }
        ) }),
        /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
          t.SubSectionHeader,
          {
            icon: "user-plus",
            title: n("salesforce_ignore_guests"),
            labelFor: "ignore-guests",
            children: /* @__PURE__ */ e(
              E,
              {
                size: "sm",
                labelOnLeading: !0,
                checked: U,
                onCheckedChange: (a) => {
                  i("ignoreGuests", a);
                }
              }
            )
          }
        ) }),
        M.value === T.CONTACT ? /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
          t.SubSectionHeader,
          {
            icon: "user-plus",
            title: n("skip_contact_creation", { appName: "Salesforce" }),
            labelFor: "skip-contact-creation",
            children: /* @__PURE__ */ e(
              E,
              {
                size: "sm",
                labelOnLeading: !0,
                checked: m,
                onCheckedChange: (a) => {
                  i("skipContactCreation", a);
                }
              }
            )
          }
        ) }) : null,
        M.value === T.LEAD ? /* @__PURE__ */ c(F, { children: [
          /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
            t.SubSectionHeader,
            {
              icon: "user-plus",
              title: n("salesforce_create_event_on_contact"),
              labelFor: "create-event-on-contact",
              children: /* @__PURE__ */ e(
                E,
                {
                  size: "sm",
                  labelOnLeading: !0,
                  checked: D,
                  onCheckedChange: (a) => {
                    i("createEventOnLeadCheckForContact", a);
                  }
                }
              )
            }
          ) }),
          /* @__PURE__ */ e(ae, {})
        ] }) : null,
        M.value === T.ACCOUNT ? /* @__PURE__ */ c(F, { children: [
          /* @__PURE__ */ e(ae, {}),
          /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
            t.SubSectionHeader,
            {
              icon: "user-plus",
              title: n("salesforce_if_account_does_not_exist"),
              labelFor: "create-lead-if-account-null",
              children: /* @__PURE__ */ e(
                E,
                {
                  size: "sm",
                  labelOnLeading: !0,
                  checked: k,
                  onCheckedChange: (a) => {
                    i("createLeadIfAccountNull", a);
                  }
                }
              )
            }
          ) })
        ] }) : null,
        /* @__PURE__ */ c(t.SubSection, { children: [
          /* @__PURE__ */ e(t.SubSectionHeader, { icon: "badge-check", title: n("on_booking_write_to_event_object"), children: /* @__PURE__ */ e(
            E,
            {
              size: "sm",
              labelOnLeading: !0,
              checked: b,
              onCheckedChange: (a) => {
                i("onBookingWriteToEventObject", a);
              }
            }
          ) }),
          b ? /* @__PURE__ */ c(t.SubSectionContent, { children: [
            /* @__PURE__ */ c("div", { className: "text-subtle flex gap-3 px-3 py-[6px] text-sm font-medium", children: [
              /* @__PURE__ */ e("div", { className: "flex-1", children: n("field_name") }),
              /* @__PURE__ */ e("div", { className: "flex-1", children: n("value") }),
              /* @__PURE__ */ e("div", { className: "w-10" })
            ] }),
            /* @__PURE__ */ c(t.SubSectionNested, { children: [
              Object.keys(y).map((a) => /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
                /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(v, { value: a, readOnly: !0, size: "sm", className: "w-full" }) }),
                /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
                  v,
                  {
                    value: y[a],
                    readOnly: !0,
                    size: "sm",
                    className: "w-full"
                  }
                ) }),
                /* @__PURE__ */ e("div", { className: "flex w-10 justify-center", children: /* @__PURE__ */ e(
                  x,
                  {
                    StartIcon: "x",
                    variant: "icon",
                    size: "sm",
                    color: "minimal",
                    onClick: () => {
                      const se = y;
                      delete y[a], i("onBookingWriteToEventObjectMap", se);
                    }
                  }
                ) })
              ] }, a)),
              /* @__PURE__ */ c("div", { className: "mt-2 flex gap-4", children: [
                /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
                  v,
                  {
                    size: "sm",
                    className: "w-full",
                    value: I.field,
                    onChange: (a) => q({
                      ...I,
                      field: a.target.value
                    })
                  }
                ) }),
                /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(
                  v,
                  {
                    size: "sm",
                    className: "w-full",
                    value: I.value,
                    onChange: (a) => q({
                      ...I,
                      value: a.target.value
                    })
                  }
                ) }),
                /* @__PURE__ */ e("div", { className: "w-10" })
              ] })
            ] }),
            /* @__PURE__ */ e(
              x,
              {
                className: "text-subtle mt-2 w-fit",
                size: "sm",
                color: "secondary",
                disabled: !(I.field && I.value),
                onClick: () => {
                  if (Object.keys(y).includes(
                    I.field.trim()
                  )) {
                    P("Field already exists", "error");
                    return;
                  }
                  i("onBookingWriteToEventObjectMap", {
                    ...y,
                    [I.field.trim()]: I.value.trim()
                  }), q({ field: "", value: "" });
                },
                children: n("add_new_field")
              }
            )
          ] }) : null
        ] }),
        /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
          te,
          {
            bookingAction: ee.ON_BOOKING,
            optionLabel: n("salesforce_on_booking_write_to_record", { record: p }),
            optionEnabled: B,
            writeToObjectData: V,
            optionSwitchOnChange: (a) => {
              i("onBookingWriteToRecord", a);
            },
            updateWriteToObjectData: (a) => i("onBookingWriteToRecordFields", a)
          }
        ) }),
        /* @__PURE__ */ c(t.SubSection, { children: [
          /* @__PURE__ */ e(
            t.SubSectionHeader,
            {
              icon: "user-plus",
              title: n("salesforce_change_record_owner_on_booking"),
              labelFor: "change-record-owner-on-booking",
              children: /* @__PURE__ */ e(
                E,
                {
                  size: "sm",
                  labelOnLeading: !0,
                  checked: G,
                  onCheckedChange: (a) => {
                    i("onBookingChangeRecordOwner", a);
                  }
                }
              )
            }
          ),
          G ? /* @__PURE__ */ e(t.SubSectionContent, { classNames: { container: "p-3" }, children: /* @__PURE__ */ c("div", { children: [
            /* @__PURE__ */ e(
              Z,
              {
                htmlFor: "on-booking-change-record-owner-name",
                className: "text-subtle text-sm font-medium",
                children: n("salesforce_owner_name_to_change")
              }
            ),
            /* @__PURE__ */ e(
              v,
              {
                id: "on-booking-change-record-owner-name",
                size: "sm",
                value: K,
                onChange: (a) => i("onBookingChangeRecordOwnerName", a.target.value)
              }
            )
          ] }) }) : null
        ] }),
        S.schedulingType === me.ROUND_ROBIN ? /* @__PURE__ */ c(F, { children: [
          /* @__PURE__ */ c(t.SubSection, { children: [
            /* @__PURE__ */ e(
              t.SubSectionHeader,
              {
                icon: "users",
                title: n("salesforce_book_directly_with_attendee_owner"),
                labelFor: "book-directly-with-attendee-owner",
                children: /* @__PURE__ */ e(
                  E,
                  {
                    size: "sm",
                    id: "book-directly-witha-attendee-owner",
                    checked: O,
                    onCheckedChange: (a) => {
                      i("roundRobinLeadSkip", a), a && i("enabled", a);
                    }
                  }
                )
              }
            ),
            O ? /* @__PURE__ */ e(t.SubSectionContent, { classNames: { container: "p-3" }, children: /* @__PURE__ */ c("div", { children: [
              /* @__PURE__ */ e(
                Z,
                {
                  htmlFor: "round-robin-skip-check-record-on",
                  className: "text-subtle text-sm font-medium",
                  children: n("salesforce_check_owner_of")
                }
              ),
              /* @__PURE__ */ e(
                h,
                {
                  size: "sm",
                  className: "w-60",
                  options: Y,
                  value: ne,
                  onChange: (a) => {
                    a && (ce(a), i("roundRobinSkipCheckRecordOn", a.value));
                  }
                }
              )
            ] }) }) : null
          ] }),
          /* @__PURE__ */ e(F, { children: O ? /* @__PURE__ */ c(F, { children: [
            ne.value === T.CONTACT ? /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
              t.SubSectionHeader,
              {
                icon: "users",
                title: n("salesforce_round_robin_skip_fallback_to_lead_owner"),
                labelFor: "round-robin-skip-fallback-to-lead-owner",
                children: /* @__PURE__ */ e(
                  E,
                  {
                    id: "round-robin-skip-fallback-to-lead-owner",
                    size: "sm",
                    checked: $,
                    onCheckedChange: (a) => {
                      i("roundRobinSkipFallbackToLeadOwner", a);
                    }
                  }
                )
              }
            ) }) : null,
            /* @__PURE__ */ c(t.SubSection, { children: [
              /* @__PURE__ */ e(
                t.SubSectionHeader,
                {
                  icon: "users",
                  title: n("salesforce_if_free_email_domain_skip_owner_check"),
                  labelFor: "if-free-email-domain-skip-owner-check",
                  children: /* @__PURE__ */ e(
                    E,
                    {
                      id: "if-free-email-domain-skip-owner-check",
                      size: "sm",
                      checked: j,
                      onCheckedChange: (a) => {
                        i("ifFreeEmailDomainSkipOwnerCheck", a);
                      }
                    }
                  )
                }
              ),
              /* @__PURE__ */ e(fe, { severity: "info", title: n("skip_rr_description") })
            ] }),
            /* @__PURE__ */ e(
              pe,
              {
                fieldRules: o,
                updateFieldRules: (a) => i("rrSkipFieldRules", a)
              }
            )
          ] }) : null })
        ] }) : null,
        /* @__PURE__ */ e(t.SubSection, { children: /* @__PURE__ */ e(
          te,
          {
            bookingAction: ee.ON_CANCEL,
            optionLabel: n("salesforce_on_cancel_write_to_event"),
            optionEnabled: l,
            writeToObjectData: d,
            optionSwitchOnChange: (a) => {
              i("onCancelWriteToEventRecord", a);
            },
            updateWriteToObjectData: (a) => i("onCancelWriteToEventRecordFields", a)
          }
        ) }),
        /* @__PURE__ */ c(t.SubSection, { children: [
          /* @__PURE__ */ e(
            t.SubSectionHeader,
            {
              icon: "calendar",
              title: "Send no show attendee data to event object",
              labelFor: "send-no-show-attendee-data",
              children: /* @__PURE__ */ e(
                E,
                {
                  id: "send-no-show-attendee-data",
                  size: "sm",
                  checked: z,
                  onCheckedChange: (a) => {
                    i("sendNoShowAttendeeData", a);
                  }
                }
              )
            }
          ),
          z ? /* @__PURE__ */ c(t.SubSectionContent, { classNames: { container: "p-3" }, children: [
            /* @__PURE__ */ e(
              Z,
              {
                htmlFor: "send-no-show-attendee-data-field-name",
                className: "text-subtle text-sm font-medium",
                children: "Field name to check (must be checkbox data type)"
              }
            ),
            /* @__PURE__ */ e(
              v,
              {
                id: "send-no-show-attendee-data-field-name",
                size: "sm",
                value: f,
                onChange: (a) => i("sendNoShowAttendeeDataField", a.target.value)
              }
            )
          ] }) : null
        ] })
      ] })
    }
  );
};
export {
  _e as default
};
