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