import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  createHttpClient,
  useAuth
} from "./chunk-HWT3LUJJ.js";
import {
  require_react
} from "./chunk-TODKQSCF.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-http-client-react/src/httpClientProvider.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var HttpClientContext = (0, import_react.createContext)(null);
var HttpClientProvider = ({
  children,
  headers
}) => {
  return /* @__PURE__ */ import_react.default.createElement(HttpClientContext.Provider, { value: { headers } }, children);
};

// ../cli-http-client-react/src/buildHttpClientHeaders.ts
init_esm_shims();
var buildHttpClientHeaders = ({
  flow,
  command,
  cliVersion
}) => {
  const buildWixBiGatewayHeader = (flow2, command2, cliVersion2) => [
    `environment=CLI-${flow2}`,
    `package-version=${cliVersion2}`,
    `package-name=${command2}`
  ].join(",");
  return {
    "x-wix-bi-gateway": buildWixBiGatewayHeader(flow, command, cliVersion)
  };
};

// ../cli-http-client-react/src/index.ts
init_esm_shims();

// ../cli-http-client-react/src/useHttpClient.ts
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);
function useHttpClient({
  type,
  siteId
}) {
  const context = (0, import_react2.useContext)(HttpClientContext);
  const { getAccessToken: getAppToken, getRequestHeaders: createAuthHeaders } = useAuth();
  return (0, import_react2.useMemo)(
    () => createHttpClient({
      type,
      getAppToken: () => getAppToken({ siteId }),
      createHeaders: () => ({
        ...createAuthHeaders?.({ siteId }),
        ...context?.headers
      })
    }),
    [type, getAppToken, createAuthHeaders, context, siteId]
  );
}

export {
  HttpClientProvider,
  useHttpClient,
  buildHttpClientHeaders
};
//# sourceMappingURL=chunk-WFQIXGJV.js.map