import { jsxs as o, jsx as c } from "react/jsx-runtime";
import { useState as m, useEffect as v } from "react";
import { R as p, S as h } from "./index-ykl8OQ78.js";
const S = ({}) => {
  const [n, u] = m(), [f, r] = m(), { data: e } = p.viewer.appBasecamp3.projects.useQuery(), d = p.viewer.appBasecamp3.projectMutation.useMutation();
  return v(
    function() {
      var a, i, l;
      r({
        value: e == null ? void 0 : e.projects.currentProject,
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        label: (i = (a = e == null ? void 0 : e.projects) == null ? void 0 : a.find((s) => s.id === (e == null ? void 0 : e.currentProject))) == null ? void 0 : i.name
      }), u(
        // eslint-disable-next-line @typescript-eslint/no-explicit-any
        (l = e == null ? void 0 : e.projects) == null ? void 0 : l.map((s) => ({
          value: s.id,
          label: s.name
        }))
      );
    },
    [e]
  ), /* @__PURE__ */ o("div", { className: "mt-2 text-sm", children: [
    /* @__PURE__ */ o("div", { className: "flex gap-3", children: [
      /* @__PURE__ */ c("div", { className: "items-center", children: /* @__PURE__ */ c("p", { className: "py-2", children: "Link a Basecamp project to this event:" }) }),
      /* @__PURE__ */ c(
        h,
        {
          placeholder: "Select project",
          options: n,
          isLoading: !n,
          className: "md:min-w-[120px]",
          onChange: (t) => {
            t && (d.mutate({ projectId: t == null ? void 0 : t.value.toString() }), r(t));
          },
          value: f
        }
      )
    ] }),
    /* @__PURE__ */ o("div", { className: "mt-2", children: [
      "Please note that as of now you can only link ",
      /* @__PURE__ */ c("span", { className: "italic", children: "one" }),
      " of your projects to cal.com"
    ] })
  ] });
};
export {
  S as default
};
