import { r as registerInstance, h as h$1, c as Host } from './index-38ad4957.js';
import { o as m, f as useEffect, n as h } from './dom-context-hooks.module-50442785.js';
import { G, e as Q, E as Ee, P as Pe } from './index.module-b23fdad8.js';

async function useGraphQLClientProvider({ domain }) {
  const token = G();
  const appDomain = domain;
  const tenantAlias = Q();
  // Memoization is shared. One client per domain, tenant and token (or null)
  const managedIdentityClient = Ee(appDomain, tenantAlias, token);
  const [, setGraphQLClient] = m(Pe, managedIdentityClient);
  useEffect(() => {
    setGraphQLClient(managedIdentityClient);
  }, [managedIdentityClient]);
}

const GraphQLClientProvider = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.ignored = true;
    h(this);
  }
  disconnectedCallback() { }
  render() {
     useGraphQLClientProvider(this);
    return (h$1(Host, { style: { display: "contents" } }, h$1("slot", null)));
  }
};

export { GraphQLClientProvider as sqm_graphql_client_provider };
