// @bun
import {
  init_setup,
  isChromeExtensionInstalled
} from "./chunk-z6q9bvc0.js";
import"./chunk-rmn1bnbd.js";
import {
  Select,
  init_AppState,
  init_select,
  useAppState
} from "./chunk-4vz571bb.js";
import"./chunk-14p6wvsq.js";
import"./chunk-8hseq8b1.js";
import"./chunk-ddtxq6k5.js";
import"./chunk-28jd8qjx.js";
import"./chunk-djt39ze3.js";
import"./chunk-ptxteaeh.js";
import"./chunk-wd53a7m4.js";
import"./chunk-hms8ge0k.js";
import"./chunk-whpphypt.js";
import"./chunk-pht800m5.js";
import"./chunk-pjkqh1kq.js";
import"./chunk-9a9g5hbj.js";
import"./chunk-9hn8e6h1.js";
import"./chunk-rgyzsbs3.js";
import"./chunk-qn6me9n1.js";
import"./chunk-qd3r2s2n.js";
import"./chunk-djzd7tef.js";
import"./chunk-gyhnpbkx.js";
import"./chunk-71sdcaq6.js";
import"./chunk-60gf7p5s.js";
import {
  CLAUDE_IN_CHROME_MCP_SERVER_NAME,
  init_common,
  openInChrome
} from "./chunk-sj3d0nqx.js";
import"./chunk-9pk9rk2w.js";
import"./chunk-javpza6a.js";
import"./chunk-6v7bre98.js";
import"./chunk-24kv69g3.js";
import"./chunk-fcqebw9m.js";
import"./chunk-dnfd3c9s.js";
import"./chunk-15ezj4ww.js";
import"./chunk-1h284c6e.js";
import"./chunk-582g9yce.js";
import"./chunk-y3ztgztb.js";
import"./chunk-4spgkgr3.js";
import"./chunk-n8kbhswc.js";
import"./chunk-60fkafk2.js";
import"./chunk-fgbkrbk3.js";
import"./chunk-ssw61jfd.js";
import"./chunk-093ej2sf.js";
import"./chunk-7tfdhkpy.js";
import"./chunk-nde5ym6a.js";
import"./chunk-k8wq4qsj.js";
import"./chunk-g7d3xx1p.js";
import"./chunk-3wrx2943.js";
import"./chunk-7p9kkh0f.js";
import"./chunk-qp8cgz66.js";
import {
  init_browser,
  openBrowser
} from "./chunk-1mg610h2.js";
import"./chunk-93hc149s.js";
import"./chunk-935nrvdb.js";
import"./chunk-8zz4z1q3.js";
import"./chunk-nnat9jw5.js";
import"./chunk-hqxp6b72.js";
import"./chunk-4jzkqgf1.js";
import"./chunk-33rd41ng.js";
import"./chunk-f257kqw9.js";
import"./chunk-w5hnghah.js";
import"./chunk-36twraxy.js";
import"./chunk-1bkvnj0y.js";
import"./chunk-akdpcc5p.js";
import {
  getGlobalConfig,
  init_auth,
  init_config1 as init_config,
  isClaudeAISubscriber,
  saveGlobalConfig
} from "./chunk-7rrkrej7.js";
import"./chunk-6r0bxrh6.js";
import"./chunk-d6500tvx.js";
import"./chunk-jg4bw4hp.js";
import"./chunk-epvbnq43.js";
import"./chunk-tn2sx7j6.js";
import"./chunk-6tzyv21c.js";
import"./chunk-8kf8h7xf.js";
import"./chunk-bgan4cpf.js";
import"./chunk-jmv7k0jn.js";
import"./chunk-ch4pgvwq.js";
import"./chunk-99jc4tcw.js";
import"./chunk-fghczfqt.js";
import"./chunk-vwenx8ke.js";
import {
  env,
  init_env
} from "./chunk-f86mwfyd.js";
import"./chunk-v4ypszbb.js";
import"./chunk-bk6ck5c2.js";
import"./chunk-ym6j0wv1.js";
import"./chunk-hjmatcgt.js";
import"./chunk-6mdh70q0.js";
import"./chunk-ch92ycde.js";
import"./chunk-e4dsy4g1.js";
import"./chunk-326zehp8.js";
import"./chunk-kc67kt75.js";
import"./chunk-40t1d75v.js";
import"./chunk-nt5dmk8q.js";
import"./chunk-e3abfxpy.js";
import"./chunk-q44zc68f.js";
import"./chunk-fejeqe61.js";
import"./chunk-0gp4q8aq.js";
import"./chunk-hn4w9pkj.js";
import {
  Dialog,
  ThemedBox_default,
  ThemedText,
  init_src,
  require_react
} from "./chunk-0r6npc3t.js";
import {
  require_jsx_runtime
} from "./chunk-gxyx8b8w.js";
import"./chunk-j1mep9ck.js";
import"./chunk-6x35ffpx.js";
import"./chunk-1zbwhcbt.js";
import"./chunk-t0450ma3.js";
import"./chunk-0cqw3y8h.js";
import"./chunk-k1sw7km0.js";
import"./chunk-e3j7m7k2.js";
import"./chunk-sc9ycxra.js";
import"./chunk-hhta0nge.js";
import"./chunk-8wsj9fff.js";
import"./chunk-m28vg9w4.js";
import"./chunk-f8prtxs3.js";
import"./chunk-41a6f2kv.js";
import"./chunk-c1yc761e.js";
import"./chunk-c5g9shkw.js";
import"./chunk-byd20vdq.js";
import"./chunk-kb3758f7.js";
import"./chunk-3j8w0rq8.js";
import"./chunk-tj0dzck2.js";
import"./chunk-aeysytks.js";
import"./chunk-ns1htxgd.js";
import"./chunk-ztqzmfx1.js";
import {
  init_envUtils,
  isRunningOnHomespace
} from "./chunk-6k1rsk85.js";
import"./chunk-nxzx0ey9.js";
import"./chunk-yes1my80.js";
import"./chunk-pecy49yr.js";
import"./chunk-azbab59e.js";
import"./chunk-3nk9q8dr.js";
import {
  __esm,
  __toESM
} from "./chunk-hhsxm2yr.js";

// src/commands/chrome/chrome.tsx
function ClaudeInChromeMenu({
  onDone,
  isExtensionInstalled: installed,
  configEnabled,
  isClaudeAISubscriber: isClaudeAISubscriber2,
  isWSL
}) {
  const mcpClients = useAppState((s) => s.mcp.clients);
  const [selectKey, setSelectKey] = import_react.useState(0);
  const [enabledByDefault, setEnabledByDefault] = import_react.useState(configEnabled ?? false);
  const [showInstallHint, setShowInstallHint] = import_react.useState(false);
  const [isExtensionInstalled, setIsExtensionInstalled] = import_react.useState(installed);
  const isHomespace = process.env.USER_TYPE === "ant" && isRunningOnHomespace();
  const chromeClient = mcpClients.find((c) => c.name === CLAUDE_IN_CHROME_MCP_SERVER_NAME);
  const isConnected = chromeClient?.type === "connected";
  function openUrl(url) {
    if (isHomespace) {
      openBrowser(url);
    } else {
      openInChrome(url);
    }
  }
  function handleAction(action) {
    switch (action) {
      case "install-extension":
        setSelectKey((k) => k + 1);
        setShowInstallHint(true);
        openUrl(CHROME_EXTENSION_URL);
        break;
      case "reconnect":
        setSelectKey((k) => k + 1);
        isChromeExtensionInstalled().then((installed2) => {
          setIsExtensionInstalled(installed2);
          if (installed2) {
            setShowInstallHint(false);
          }
        });
        openUrl(CHROME_RECONNECT_URL);
        break;
      case "manage-permissions":
        setSelectKey((k) => k + 1);
        openUrl(CHROME_PERMISSIONS_URL);
        break;
      case "toggle-default": {
        const newValue = !enabledByDefault;
        saveGlobalConfig((current) => ({
          ...current,
          claudeInChromeDefaultEnabled: newValue
        }));
        setEnabledByDefault(newValue);
        break;
      }
    }
  }
  const options = [];
  const requiresExtensionSuffix = isExtensionInstalled ? "" : " (requires extension)";
  if (!isExtensionInstalled && !isHomespace) {
    options.push({
      label: "Install Chrome extension",
      value: "install-extension"
    });
  }
  options.push({
    label: /* @__PURE__ */ jsx_runtime.jsxs(jsx_runtime.Fragment, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          children: "Manage permissions"
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: requiresExtensionSuffix
        })
      ]
    }),
    value: "manage-permissions"
  }, {
    label: /* @__PURE__ */ jsx_runtime.jsxs(jsx_runtime.Fragment, {
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          children: "Reconnect extension"
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: requiresExtensionSuffix
        })
      ]
    }),
    value: "reconnect"
  }, {
    label: `Enabled by default: ${enabledByDefault ? "Yes" : "No"}`,
    value: "toggle-default"
  });
  const isDisabled = isWSL || process.env.USER_TYPE !== "ant" && !isClaudeAISubscriber2;
  return /* @__PURE__ */ jsx_runtime.jsx(Dialog, {
    title: "Claude in Chrome (Beta)",
    onCancel: () => onDone(),
    color: "chromeYellow",
    children: /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
      flexDirection: "column",
      gap: 1,
      children: [
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          children: "Claude in Chrome works with the Chrome extension to let you control your browser directly from Chris Code. Navigate websites, fill forms, capture screenshots, record GIFs, and debug with console logs and network requests."
        }),
        isWSL && /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "error",
          children: "Claude in Chrome is not supported in WSL at this time."
        }),
        process.env.USER_TYPE !== "ant" && !isClaudeAISubscriber2 && /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          color: "error",
          children: "Claude in Chrome requires a claude.ai subscription."
        }),
        !isDisabled && /* @__PURE__ */ jsx_runtime.jsxs(jsx_runtime.Fragment, {
          children: [
            !isHomespace && /* @__PURE__ */ jsx_runtime.jsxs(ThemedBox_default, {
              flexDirection: "column",
              children: [
                /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
                  children: [
                    "Status: ",
                    isConnected ? /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                      color: "success",
                      children: "Enabled"
                    }) : /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                      color: "inactive",
                      children: "Disabled"
                    })
                  ]
                }),
                /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
                  children: [
                    "Extension:",
                    " ",
                    isExtensionInstalled ? /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                      color: "success",
                      children: "Installed"
                    }) : /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                      color: "warning",
                      children: "Not detected"
                    })
                  ]
                })
              ]
            }),
            /* @__PURE__ */ jsx_runtime.jsx(Select, {
              options,
              onChange: handleAction,
              hideIndexes: true
            }, selectKey),
            showInstallHint && /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
              color: "warning",
              children: [
                "Once installed, select ",
                '"Reconnect extension"',
                " to connect."
              ]
            }),
            /* @__PURE__ */ jsx_runtime.jsxs(ThemedText, {
              children: [
                /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                  dimColor: true,
                  children: "Usage: "
                }),
                /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                  children: "claude --chrome"
                }),
                /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                  dimColor: true,
                  children: " or "
                }),
                /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
                  children: "claude --no-chrome"
                })
              ]
            }),
            /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
              dimColor: true,
              children: "Site-level permissions are inherited from the Chrome extension. Manage permissions in the Chrome extension settings to control which sites Claude can browse, click, and type on."
            })
          ]
        }),
        /* @__PURE__ */ jsx_runtime.jsx(ThemedText, {
          dimColor: true,
          children: "Learn more: https://code.claude.com/docs/en/chrome"
        })
      ]
    })
  });
}
var import_react, jsx_runtime, CHROME_EXTENSION_URL = "https://claude.ai/chrome", CHROME_PERMISSIONS_URL = "https://clau.de/chrome/permissions", CHROME_RECONNECT_URL = "https://clau.de/chrome/reconnect", call = async function(onDone) {
  const isExtensionInstalled = await isChromeExtensionInstalled();
  const config = getGlobalConfig();
  const isSubscriber = isClaudeAISubscriber();
  const isWSL = env.isWslEnvironment();
  return /* @__PURE__ */ jsx_runtime.jsx(ClaudeInChromeMenu, {
    onDone,
    isExtensionInstalled,
    configEnabled: config.claudeInChromeDefaultEnabled,
    isClaudeAISubscriber: isSubscriber,
    isWSL
  });
};
var init_chrome = __esm(() => {
  init_select();
  init_src();
  init_src();
  init_AppState();
  init_auth();
  init_browser();
  init_common();
  init_setup();
  init_config();
  init_env();
  init_envUtils();
  import_react = __toESM(require_react(), 1);
  jsx_runtime = __toESM(require_jsx_runtime(), 1);
});
init_chrome();

export {
  call
};

//# debugId=AC89198539B68CA764756E2164756E21
//# sourceMappingURL=chunk-rykyvnx5.js.map
