{"version":3,"sources":["jsdelivr-header.js","/npm/@radix-ui/react-context@1.1.3/src/index.ts","/npm/@radix-ui/react-context@1.1.3/src/create-context.tsx"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,svBCNA,cAAA,GAAA,SAAA,cAAA,CAAA,cAAA,IAAA,eAAA,mBAAA,IAAA,qBAAA,OAAA,QAAA,aAAA,eCAA,IAAA,MAAuB,QAAA,QAAA,UAcZ,mBAAA,QAAA,qBAZX,SAAS,eACP,EACA,GAEA,MAAM,EAAgB,MAAA,cAA4C,GAClE,EAAQ,YAAc,EAAoB,UAE1C,MAAM,EAAwE,IAC5E,MAAM,SAAE,KAAa,GAAY,EAG3B,EAAc,MAAA,SAAQ,IAAM,GAAS,OAAO,OAAO,IACzD,OAAO,EAAA,mBAAA,KAAC,EAAQ,SAAR,CAAiB,QAAe,YAAS,EAanD,OAVA,EAAS,YAAc,EAAoB,WAUpC,CAAC,EARR,SAAoB,GAClB,MAAM,EAAgB,MAAA,WAAW,GACjC,GAAI,EAAS,OAAO,EACpB,QAAuB,IAAnB,EAA8B,OAAO,EAEzC,MAAM,IAAI,MAAM,KAAK,6BAAwC,MAC/D,EAGF,CAaA,SAAS,mBAAmB,EAAmB,EAAwC,IACrF,IAAI,EAAyB,GA4C7B,MAAM,EAA2B,KAC/B,MAAM,EAAgB,EAAgB,KAAK,GAC5B,MAAA,cAAc,KAE7B,OAAO,SAAkB,GACvB,MAAM,EAAW,IAAQ,IAAc,EACvC,OAAa,MAAA,SACX,MAAS,CAAC,UAAU,KAAc,IAAK,EAAO,CAAC,GAAY,MAC3D,CAAC,EAAO,GAEZ,GAIF,OADA,EAAY,UAAY,EACjB,CApDP,SACE,EACA,GAEA,MAAM,EAAoB,MAAA,cAA4C,GACtE,EAAY,YAAc,EAAoB,UAC9C,MAAM,EAAQ,EAAgB,OAC9B,EAAkB,IAAI,EAAiB,GAEvC,MAAM,EAED,IACH,MAAM,MAAE,EAAA,SAAO,KAAa,GAAY,EAClC,EAAU,IAAQ,KAAa,IAAU,EAGzC,EAAc,MAAA,SAAQ,IAAM,GAAS,OAAO,OAAO,IACzD,OAAO,EAAA,mBAAA,KAAC,EAAQ,SAAR,CAAiB,QAAe,YAAS,EAcnD,OAXA,EAAS,YAAc,EAAoB,WAWpC,CAAC,EATR,SAAoB,EAAsB,GACxC,MAAM,EAAU,IAAQ,KAAa,IAAU,EACzC,EAAgB,MAAA,WAAW,GACjC,GAAI,EAAS,OAAO,EACpB,QAAuB,IAAnB,EAA8B,OAAO,EAEzC,MAAM,IAAI,MAAM,KAAK,6BAAwC,MAC/D,EAGF,EAoBuB,qBAAqB,KAAgB,GAC9D,CAMA,SAAS,wBAAwB,GAC/B,MAAM,EAAY,EAAO,GACzB,GAAsB,IAAlB,EAAO,OAAc,OAAO,EAEhC,MAAM,EAA2B,KAC/B,MAAM,EAAa,EAAO,KAAK,KAC7B,SAAU,IACV,UAAW,EAAY,cAGzB,OAAO,SAA2B,GAChC,MAAM,EAAa,EAAW,QAAO,CAAC,GAAc,WAAU,gBAMrD,IAAK,KAFO,EAAS,GACI,UAAU,QAEzC,CAAC,GAEJ,OAAa,MAAA,SAAQ,MAAS,CAAC,UAAU,EAAU,aAAc,KAAe,CAAC,GACnF,GAIF,OADA,EAAY,UAAY,EAAU,UAC3B,CACT","file":"/npm/@radix-ui/react-context@1.1.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@radix-ui/react-context@1.1.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","export { createContext, createContextScope } from './create-context';\nexport type { CreateScope, Scope } from './create-context';\n","import * as React from 'react';\n\nfunction createContext<ContextValueType extends object | null>(\n  rootComponentName: string,\n  defaultContext?: ContextValueType,\n) {\n  const Context = React.createContext<ContextValueType | undefined>(defaultContext);\n  Context.displayName = rootComponentName + 'Context';\n\n  const Provider: React.FC<ContextValueType & { children: React.ReactNode }> = (props) => {\n    const { children, ...context } = props;\n    // Only re-memoize when prop values change\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n    const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n    return <Context.Provider value={value}>{children}</Context.Provider>;\n  };\n\n  Provider.displayName = rootComponentName + 'Provider';\n\n  function useContext(consumerName: string) {\n    const context = React.useContext(Context);\n    if (context) return context;\n    if (defaultContext !== undefined) return defaultContext;\n    // if a defaultContext wasn't specified, it's a required context.\n    throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n  }\n\n  return [Provider, useContext] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * createContextScope\n * -----------------------------------------------------------------------------------------------*/\n\ntype Scope<C = any> = { [scopeName: string]: React.Context<C>[] } | undefined;\ntype ScopeHook = (scope: Scope) => { [__scopeProp: string]: Scope };\ninterface CreateScope {\n  scopeName: string;\n  (): ScopeHook;\n}\n\nfunction createContextScope(scopeName: string, createContextScopeDeps: CreateScope[] = []) {\n  let defaultContexts: any[] = [];\n\n  /* -----------------------------------------------------------------------------------------------\n   * createContext\n   * ---------------------------------------------------------------------------------------------*/\n\n  function createContext<ContextValueType extends object | null>(\n    rootComponentName: string,\n    defaultContext?: ContextValueType,\n  ) {\n    const BaseContext = React.createContext<ContextValueType | undefined>(defaultContext);\n    BaseContext.displayName = rootComponentName + 'Context';\n    const index = defaultContexts.length;\n    defaultContexts = [...defaultContexts, defaultContext];\n\n    const Provider: React.FC<\n      ContextValueType & { scope: Scope<ContextValueType>; children: React.ReactNode }\n    > = (props) => {\n      const { scope, children, ...context } = props;\n      const Context = scope?.[scopeName]?.[index] || BaseContext;\n      // Only re-memoize when prop values change\n      // eslint-disable-next-line react-hooks/exhaustive-deps\n      const value = React.useMemo(() => context, Object.values(context)) as ContextValueType;\n      return <Context.Provider value={value}>{children}</Context.Provider>;\n    };\n\n    Provider.displayName = rootComponentName + 'Provider';\n\n    function useContext(consumerName: string, scope: Scope<ContextValueType | undefined>) {\n      const Context = scope?.[scopeName]?.[index] || BaseContext;\n      const context = React.useContext(Context);\n      if (context) return context;\n      if (defaultContext !== undefined) return defaultContext;\n      // if a defaultContext wasn't specified, it's a required context.\n      throw new Error(`\\`${consumerName}\\` must be used within \\`${rootComponentName}\\``);\n    }\n\n    return [Provider, useContext] as const;\n  }\n\n  /* -----------------------------------------------------------------------------------------------\n   * createScope\n   * ---------------------------------------------------------------------------------------------*/\n\n  const createScope: CreateScope = () => {\n    const scopeContexts = defaultContexts.map((defaultContext) => {\n      return React.createContext(defaultContext);\n    });\n    return function useScope(scope: Scope) {\n      const contexts = scope?.[scopeName] || scopeContexts;\n      return React.useMemo(\n        () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),\n        [scope, contexts],\n      );\n    };\n  };\n\n  createScope.scopeName = scopeName;\n  return [createContext, composeContextScopes(createScope, ...createContextScopeDeps)] as const;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * composeContextScopes\n * -----------------------------------------------------------------------------------------------*/\n\nfunction composeContextScopes(...scopes: [CreateScope, ...CreateScope[]]): CreateScope {\n  const baseScope = scopes[0];\n  if (scopes.length === 1) return baseScope;\n\n  const createScope: CreateScope = () => {\n    const scopeHooks = scopes.map((createScope) => ({\n      useScope: createScope(),\n      scopeName: createScope.scopeName,\n    }));\n\n    return function useComposedScopes(overrideScopes) {\n      const nextScopes = scopeHooks.reduce((nextScopes, { useScope, scopeName }) => {\n        // We are calling a hook inside a callback which React warns against to avoid inconsistent\n        // renders, however, scoping doesn't have render side effects so we ignore the rule.\n        // eslint-disable-next-line react-hooks/rules-of-hooks\n        const scopeProps = useScope(overrideScopes);\n        const currentScope = scopeProps[`__scope${scopeName}`];\n        return { ...nextScopes, ...currentScope };\n      }, {});\n\n      return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);\n    };\n  };\n\n  createScope.scopeName = baseScope.scopeName;\n  return createScope;\n}\n\n/* -----------------------------------------------------------------------------------------------*/\n\nexport { createContext, createContextScope };\nexport type { CreateScope, Scope };\n"]}