@tamagui/core 1.0.1-rc.11 → 1.0.1-rc.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/createComponent.tsx"],
4
- "sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n isClient,\n isRSC,\n isServer,\n isWeb,\n useIsomorphicLayoutEffect,\n} from '@tamagui/constants'\nimport {\n composeEventHandlers,\n stylePropsView,\n validPseudoKeys,\n validStyles,\n} from '@tamagui/helpers'\nimport { useResponderEvents } from '@tamagui/react-native-use-responder-events'\nimport React, {\n Children,\n Fragment,\n RefObject,\n createElement,\n forwardRef,\n memo,\n startTransition,\n useCallback,\n useContext,\n useEffect,\n useRef,\n} from 'react'\n\nimport { onConfiguredOnce } from './config'\nimport { stackDefaultStyles } from './constants/constants'\nimport { FontLanguageContext } from './contexts/FontLanguageContext'\nimport { TextAncestorContext } from './contexts/TextAncestorContext'\nimport { didGetVariableValue, setDidGetVariableValue } from './createVariable'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getRect } from './helpers/getRect'\nimport { useSplitStyles } from './helpers/getSplitStyles'\nimport { getAllSelectors } from './helpers/insertStyleRule'\nimport { mergeProps } from './helpers/mergeProps'\nimport { proxyThemeVariables } from './helpers/proxyThemeVariables'\nimport { useShallowSetState } from './helpers/useShallowSetState'\nimport { measureLayout, useElementLayout } from './hooks/useElementLayout'\nimport { setMediaShouldUpdate, useMedia } from './hooks/useMedia'\nimport { useServerRef, useServerState } from './hooks/useServerHooks'\nimport { getThemeIsNewTheme, getThemeManager, useTheme } from './hooks/useTheme'\nimport {\n DebugProp,\n SpaceDirection,\n SpaceTokens,\n SpacerProps,\n StaticConfig,\n StaticConfigParsed,\n StylableComponent,\n TamaguiComponent,\n TamaguiComponentState,\n TamaguiConfig,\n TamaguiElement,\n TamaguiInternalConfig,\n UseAnimationHook,\n UseAnimationProps,\n} from './types'\nimport { usePressability } from './vendor/Pressability'\nimport { Slot, mergeEvent } from './views/Slot'\nimport { wrapThemeManagerContext } from './views/Theme'\n\n// let t\n// import { timer } from '@tamagui/timer'\n// if (true || process.env.ANALYZE) {\n// t = require().timer()\n// setTimeout(() => {\n// const out = t.print()\n// if (isClient) {\n// alert(out)\n// }\n// }, 2000)\n// }\n\n// this appears to fix expo / babel not picking this up sometimes? really odd\nprocess.env.TAMAGUI_TARGET\n\n/**\n * All things that need one-time setup after createTamagui is called\n */\nlet defaultComponentState: TamaguiComponentState | null = null\nlet defaultComponentStateMounted: TamaguiComponentState | null = null\nlet tamaguiConfig: TamaguiInternalConfig\nlet AnimatedText: any\nlet AnimatedView: any\nlet initialTheme: any\n\nexport const mouseUps = new Set<Function>()\nif (typeof document !== 'undefined') {\n const cancelTouches = () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n }\n addEventListener('mouseup', cancelTouches)\n addEventListener('touchend', cancelTouches)\n addEventListener('touchcancel', cancelTouches)\n}\n\n// mutates\nfunction mergeShorthands(\n { defaultProps }: StaticConfigParsed,\n { shorthands }: TamaguiConfig\n) {\n // they are defined in correct order already { ...parent, ...child }\n for (const key of Object.keys(defaultProps)) {\n defaultProps[shorthands[key] || key] = defaultProps[key]\n }\n}\n\n/**\n * Only on native do we need the actual underlying View/Text\n * On the web we avoid react-native altogether in core.\n */\nlet BaseText: any\nlet BaseView: any\nif (process.env.TAMAGUI_TARGET === 'native') {\n const native = require('react-native')\n BaseText = native.Text || native.default.Text\n BaseView = native.View || native.default.View\n}\n\nexport function createComponent<\n ComponentPropTypes extends Object = {},\n Ref = TamaguiElement,\n BaseProps = never\n>(\n configIn: Partial<StaticConfig> | StaticConfigParsed,\n ParentComponent?: StylableComponent\n) {\n const staticConfig = (() => {\n const next = extendStaticConfig(configIn, ParentComponent)\n if ('parsed' in next) {\n return next\n } else {\n return parseStaticConfig(next)\n }\n })()\n\n const defaultComponentClassName = `is_${staticConfig.componentName}`\n let tamaguiDefaultProps: any\n let defaultTag: string | undefined\n\n // see onConfiguredOnce below which attaches a name then to this component\n const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {\n // test only\n if (process.env.NODE_ENV === 'test') {\n if (propsIn['data-test-renders']) {\n propsIn['data-test-renders']['current'] ??= 0\n propsIn['data-test-renders']['current'] += 1\n }\n }\n // const time = t.start({ quiet: true })\n\n // React inserts default props after your props for some reason...\n // order important so we do loops, you can't just spread because JS does weird things\n let props: any\n if (tamaguiDefaultProps && !propsIn.asChild) {\n props = mergeProps(tamaguiDefaultProps, propsIn)[0]\n } else {\n props = propsIn\n }\n\n const debugProp = props['debug'] as DebugProp\n const { Component, isText, isZStack } = staticConfig\n const componentName = props.componentName || staticConfig.componentName\n const componentClassName = props.asChild\n ? ''\n : props.componentName\n ? `is_${props.componentName}`\n : defaultComponentClassName\n\n /**\n * Component state for tracking animations, pseudos\n */\n const animationsConfig = tamaguiConfig.animations\n const useAnimations = animationsConfig?.useAnimations as UseAnimationHook | undefined\n const avoidClassesWhileAnimating = animationsConfig.isReactNative\n const hasEnterStyle = !!props.enterStyle\n const needsMount = Boolean(\n (isWeb ? isClient : true) && (hasEnterStyle || props.animation)\n )\n const states = useServerState<TamaguiComponentState>(\n needsMount ? defaultComponentState! : defaultComponentStateMounted!\n )\n\n const state = propsIn.forceStyle\n ? { ...states[0], [propsIn.forceStyle]: true }\n : states[0]\n const setState = states[1]\n const setStateShallow = useShallowSetState(setState, debugProp, componentName)\n\n // conditional but if ever true stays true\n // [animated, inversed]\n const stateRef = useRef(\n undefined as any as {\n hasAnimated?: boolean\n hasThemeInversed?: boolean\n hasProvidedThemeManager?: boolean\n themeShouldReset?: boolean\n }\n )\n stateRef.current ??= {}\n\n const isAnimated = (() => {\n const next = !!(useAnimations && props.animation)\n if (next && !stateRef.current.hasAnimated) {\n stateRef.current.hasAnimated = true\n }\n return next || stateRef.current.hasAnimated\n })()\n\n const usePresence = tamaguiConfig.animations?.usePresence\n const presence = !isRSC && isAnimated ? usePresence() : null\n\n // set enter/exit variants onto our new props object\n if (isAnimated && presence) {\n const presenceState = presence[2]\n if (presenceState) {\n if (state.unmounted && presenceState.enterVariant) {\n props[presenceState.enterVariant] = true\n }\n if (!presenceState.isPresent && presenceState.exitVariant) {\n props[presenceState.exitVariant] = true\n }\n }\n }\n\n const isReactNative = Boolean(\n staticConfig.isReactNative || (isAnimated && tamaguiConfig.animations.isReactNative)\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (debugProp) {\n const name = `${\n componentName ||\n Component?.displayName ||\n Component?.name ||\n '[Unnamed Component]'\n }`\n const type = isReactNative ? '(rnw)' : ''\n const dataIs = propsIn['data-is'] || ''\n const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type}`\n // eslint-disable-next-line no-console\n console.group(`%c ${banner}`, 'background: yellow;')\n if (!isServer) {\n // eslint-disable-next-line no-console\n console.log('state', state)\n }\n }\n }\n\n const shouldAvoidClasses =\n !isWeb ||\n !!(props.animation && avoidClassesWhileAnimating) ||\n !staticConfig.acceptsClassName\n const shouldForcePseudo = !!propsIn.forceStyle\n const noClassNames = shouldAvoidClasses || shouldForcePseudo\n\n const theme = useTheme({\n name: props.theme,\n componentName,\n reset: props.reset,\n inverse: props.themeInverse,\n // @ts-expect-error internal use only\n disable: props['data-themeable'],\n debug: props.debug,\n })\n const themeManager = getThemeManager(theme)\n const themeIsNew = getThemeIsNewTheme(theme)\n\n const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)\n const languageContext = isRSC ? null : useContext(FontLanguageContext)\n const isDisabled = props.disabled ?? props.accessibilityState?.disabled\n\n const isTaggable = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb\n ? isTaggable\n ? props.tag || defaultTag || Component\n : Component\n : Component\n\n const BaseTextComponent = BaseText || element || 'span'\n const BaseViewComponent = BaseView || element || (hasTextAncestor ? 'span' : 'div')\n let elementType = isText\n ? (isAnimated ? AnimatedText : null) || BaseTextComponent\n : (isAnimated ? AnimatedView : null) || BaseViewComponent\n\n elementType = Component || elementType\n const isStringElement = typeof elementType === 'string'\n\n const isExiting = presence?.[0] === false\n\n const mediaState = useMedia(\n // @ts-ignore, we just pass a stable object so we can get it later with\n // should match to the one used in `setMediaShouldUpdate` below\n stateRef\n )\n\n setDidGetVariableValue(false)\n\n const splitStyles = useSplitStyles(\n props,\n staticConfig,\n theme,\n {\n ...state,\n mediaState,\n noClassNames,\n dynamicStylesInline: noClassNames,\n hasTextAncestor,\n resolveVariablesAs: 'auto',\n isExiting,\n },\n null,\n languageContext || undefined,\n elementType,\n debugProp\n )\n\n // only listen for changes if we are using raw theme values or media space, or dynamic media (native)\n const shouldListenForMediaChanges =\n didGetVariableValue() ||\n splitStyles.hasMedia === 'space' ||\n (noClassNames === true && splitStyles.hasMedia)\n\n if (shouldListenForMediaChanges) {\n setMediaShouldUpdate(stateRef, shouldListenForMediaChanges)\n }\n\n const hostRef = useServerRef<TamaguiElement>(null)\n\n // animation setup\n const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating\n\n if (process.env.NODE_ENV === 'development') {\n if (!process.env.TAMAGUI_TARGET) {\n // eslint-disable-next-line no-console\n console.error(\n `No process.env.TAMAGUI_TARGET set, please set it to \"native\" or \"web\".`\n )\n }\n\n if (debugProp) {\n // eslint-disable-next-line no-console\n console.groupCollapsed('props')\n // eslint-disable-next-line no-console\n console.log(\n 'props in',\n propsIn,\n 'mapped to',\n props,\n 'in order',\n Object.keys(props)\n )\n // eslint-disable-next-line no-console\n console.log('splitStyles', splitStyles)\n // eslint-disable-next-line no-console\n console.log('shouldListenForMediaChanges', shouldListenForMediaChanges)\n // eslint-disable-next-line no-console\n console.log('className', Object.values(splitStyles.classNames))\n if (isClient) {\n // eslint-disable-next-line no-console\n console.log('ref', hostRef, '(click to view)')\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n if (debugProp === 'break') {\n }\n }\n }\n\n const {\n viewProps: viewPropsIn,\n pseudos,\n medias,\n style: splitStylesStyle,\n classNames,\n space,\n } = splitStyles\n\n const propsWithAnimation = props as UseAnimationProps\n\n // once you set animation prop don't remove it, you can set to undefined/false\n // reason is animations are heavy - no way around it, and must be run inline here (\uD83D\uDE45 loading as a sub-component)\n let animationStyles: any\n if (!isRSC && isAnimated && useAnimations) {\n const animations = useAnimations({\n props: propsWithAnimation,\n style: splitStylesStyle,\n presence,\n state,\n pseudos,\n onDidAnimate: props.onDidAnimate,\n hostRef,\n staticConfig,\n })\n if (animations) {\n animationStyles = animations.style\n }\n }\n\n const {\n hitSlop,\n asChild,\n children,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n themeShallow,\n spaceDirection: _spaceDirection,\n disabled: disabledProp,\n onMouseUp,\n onMouseDown,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n separator,\n // ignore from here on out\n forceStyle: _forceStyle,\n // @ts-ignore for next/link compat etc\n onClick,\n theme: _themeProp,\n // @ts-ignore\n defaultVariants,\n\n ...nonTamaguiProps\n } = viewPropsIn\n\n const disabled =\n (props.accessibilityState != null && props.accessibilityState.disabled === true) ||\n props.accessibilityDisabled\n\n // these can ultimately be for DOM, react-native-web views, or animated views\n // so the type is pretty loose\n let viewProps: Record<string, any>\n\n // if react-native-web view just pass all props down\n if (process.env.TAMAGUI_TARGET === 'web' && !isReactNative) {\n // otherwise replicate react-native-web functionality\n const {\n // event props\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n\n // android\n collapsable,\n focusable,\n\n // deprecated,\n accessible,\n accessibilityDisabled,\n\n onLayout,\n\n ...webProps\n } = nonTamaguiProps\n\n viewProps = webProps\n\n if (!isRSC) {\n usePlatformMethods(hostRef as RefObject<Element>)\n\n useElementLayout(hostRef as RefObject<Element>, onLayout as any)\n\n useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n } as any)\n }\n\n if (props.href !== undefined && hrefAttrs !== undefined) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? `_${target}` : target\n }\n }\n\n // FOCUS\n // \"focusable\" indicates that an element may be a keyboard tab-stop.\n const _focusable = focusable !== undefined ? focusable : accessible\n const role = viewProps.role\n if (_focusable === false) {\n viewProps.tabIndex = '-1'\n }\n if (\n // These native elements are focusable by default\n elementType === 'a' ||\n elementType === 'button' ||\n elementType === 'input' ||\n elementType === 'select' ||\n elementType === 'textarea'\n ) {\n if (_focusable === false || accessibilityDisabled === true) {\n viewProps.tabIndex = '-1'\n }\n } else if (\n // These roles are made focusable by default\n role === 'button' ||\n role === 'checkbox' ||\n role === 'link' ||\n role === 'radio' ||\n role === 'textbox' ||\n role === 'switch'\n ) {\n if (_focusable !== false) {\n viewProps.tabIndex = '0'\n }\n }\n // Everything else must explicitly set the prop\n if (_focusable === true) {\n viewProps.tabIndex = '0'\n }\n } else {\n viewProps = nonTamaguiProps\n }\n\n viewProps.ref = useComposedRefs(hostRef as any, forwardedRef)\n\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n // allow newlines because why not its annoying with mdx\n if (typeof item === 'string' && item !== '\\n') {\n // eslint-disable-next-line no-console\n console.error(\n `Unexpected text node: ${item}. A text node cannot be a child of a <View>.`\n )\n }\n })\n }\n\n const unPress = useCallback(() => {\n setStateShallow({\n press: false,\n pressIn: false,\n })\n }, [setStateShallow])\n\n if (isWeb) {\n useEffect(() => {\n return () => {\n mouseUps.delete(unPress)\n }\n }, [])\n }\n\n const shouldSetMounted = needsMount && state.unmounted\n useEffect(() => {\n if (!shouldSetMounted) return\n setStateShallow({\n unmounted: false,\n })\n }, [shouldSetMounted])\n\n let styles: Record<string, any>[]\n\n if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {\n styles = {\n ...(animationStyles ?? splitStylesStyle),\n ...medias,\n }\n } else {\n styles = [animationStyles ?? splitStylesStyle, medias]\n\n // ugly but for now...\n if (shouldForcePseudo) {\n const next = {}\n styles.forEach((style) => Object.assign(next, style))\n // @ts-ignore\n Object.assign(splitStyles.style, next)\n }\n }\n\n let fontFamily = isText\n ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily\n : null\n if (fontFamily && fontFamily[0] === '$') {\n fontFamily = fontFamily.slice(1)\n }\n const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''\n\n const classList = [\n hasEnterStyle && ((state.unmounted && needsMount) || !isClient)\n ? 't_will-mount'\n : '',\n componentName ? componentClassName : '',\n fontFamilyClassName,\n themeIsNew ? theme.className : '',\n classNames ? Object.values(classNames).join(' ') : '',\n ]\n\n const className = classList.join(' ')\n\n if (process.env.TAMAGUI_TARGET === 'web') {\n const style = animationStyles ?? splitStyles.style\n\n if (isAnimatedReactNativeWeb) {\n viewProps.style = style\n } else if (isReactNative) {\n const rnwStyle = { $$css: true }\n for (const name of className.split(' ')) {\n rnwStyle[name] = name\n }\n viewProps.style = [rnwStyle, ...(Array.isArray(style) ? style : [style])]\n if (process.env.NODE_ENV === 'development') {\n // turn debug data- props into dataSet in dev mode\n Object.keys(viewProps).forEach((key) => {\n if (key.startsWith('data-')) {\n viewProps.dataSet ??= {}\n viewProps.dataSet[key.replace('data-', '')] = viewProps[key]\n delete viewProps[key]\n }\n })\n }\n } else {\n viewProps.className = className\n viewProps.style = style\n }\n }\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n // swap out the right family based on weight/style\n if (splitStyles.fontFamily) {\n const faceInfo = tamaguiConfig.fontsParsed[splitStyles.fontFamily]?.face\n if (faceInfo) {\n const [weight, style] = (() => {\n let weight: string | undefined\n let style: string | undefined\n for (let i = styles.length; i >= 0; i--) {\n weight ??= styles[i]?.fontWeight\n style ??= styles[i]?.fontStyle\n }\n return [weight || '400', style || 'normal'] as const\n })()\n const overrideFace = faceInfo[weight]?.[style]?.val\n if (overrideFace) {\n for (const style of styles) {\n if (style?.fontFamily) {\n style.fontFamily = overrideFace\n style.fontWeight = undefined\n style.fontStyle = undefined\n }\n }\n }\n }\n }\n\n // assign styles\n viewProps.style = styles\n }\n\n const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle\n const attachPress = !!(\n runtimePressStyle ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle\n const isHoverable =\n isWeb &&\n !!(runtimeHoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n const handlesPressEvents = !(isWeb || asChild)\n\n // check presence rather than value to prevent reparenting bugs\n // allows for onPress={x ? function : undefined} without re-ordering dom\n const shouldAttach = asChild\n ? false\n : Boolean(\n attachPress ||\n isHoverable ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n )\n\n const events =\n shouldAttach && !isRSC && !isDisabled\n ? {\n onPressOut: attachPress\n ? (e) => {\n unPress()\n onPressOut?.(e)\n onMouseUp?.(e)\n }\n : undefined,\n ...(isHoverable && {\n onMouseEnter: isHoverable\n ? (e) => {\n const next: Partial<typeof state> = {}\n if (isHoverable) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (isHoverable || state.pressIn) {\n setStateShallow(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave: isHoverable\n ? (e) => {\n const next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (isHoverable) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n setStateShallow(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onPressIn: attachPress\n ? (e) => {\n setStateShallow({\n press: true,\n pressIn: true,\n hover: false,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n if (isWeb) {\n mouseUps.add(unPress)\n }\n }\n : undefined,\n onPress: attachPress\n ? (e) => {\n unPress()\n // @ts-ignore\n onClick?.(e)\n onPress?.(e)\n }\n : undefined,\n\n // replicating TouchableWithoutFeedback\n ...(!isWeb && {\n cancelable: !props.rejectResponderTermination,\n disabled: isDisabled,\n hitSlop: props.hitSlop,\n delayLongPress: props.delayLongPress,\n delayPressIn: props.delayPressIn,\n delayPressOut: props.delayPressOut,\n focusable: viewProps.focusable ?? true,\n minPressDuration: 0,\n }),\n }\n : null\n\n const themeShouldReset = Boolean(themeShallow && themeManager && themeIsNew)\n const shouldProvideThemeManager = themeShouldReset || (themeManager && themeIsNew)\n\n // memoize to avoid re-parenting\n if (shouldProvideThemeManager) {\n stateRef.current.hasProvidedThemeManager = true\n }\n if (themeShouldReset) {\n stateRef.current.themeShouldReset = true\n }\n\n const childEls =\n !children || asChild\n ? children\n : wrapThemeManagerContext(\n spacedChildren({\n separator,\n children,\n space,\n direction: props.spaceDirection || 'both',\n isZStack,\n }),\n // only set context if changed theme\n stateRef.current.hasProvidedThemeManager ? themeManager : undefined,\n stateRef.current.themeShouldReset\n )\n\n let content: any\n\n if (asChild) {\n elementType = Slot\n viewProps = {\n ...viewProps,\n onPress,\n onPressIn,\n onPressOut,\n }\n }\n\n // EVENTS native\n if (process.env.TAMAGUI_TARGET === 'native') {\n // add focus events\n const attachFocus = !!pseudos.focusStyle\n if (attachFocus) {\n viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {\n setStateShallow({ focus: true })\n })\n viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {\n setStateShallow({ focus: false })\n })\n }\n\n // use Pressability to get smooth unPress when you press + hold + move out\n // only ever create once, use .configure() to update later\n const pressability = usePressability(events ? { ...events, hitSlop } : {})\n if (attachPress && events) {\n for (const key in pressability) {\n const og = props[key]\n const val = pressability[key]\n viewProps[key] =\n og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val\n }\n }\n }\n\n content = createElement(elementType, viewProps, childEls)\n\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (events || isAnimatedReactNativeWeb) {\n content = (\n <span\n className={`${isAnimatedReactNativeWeb ? className : ''} _dsp_contents`}\n {...(events && {\n onMouseEnter: events.onMouseEnter,\n onMouseLeave: events.onMouseLeave,\n onClick: events.onPress,\n onMouseDown: events.onPressIn,\n onMouseUp: events.onPressOut,\n onTouchStart: events.onPressIn,\n onTouchEnd: events.onPressOut,\n })}\n >\n {content}\n </span>\n )\n }\n }\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG !== 'tamagui') {\n if (debugProp) {\n const element = typeof elementType === 'string' ? elementType : 'Component'\n // eslint-disable-next-line no-console\n console.groupCollapsed(`render <${element} /> with props`, viewProps)\n for (const key in viewProps) {\n // eslint-disable-next-line no-console\n console.log(key, viewProps[key])\n }\n // eslint-disable-next-line no-console\n console.log('children', content)\n // eslint-disable-next-line no-console\n console.groupEnd()\n if (typeof window !== 'undefined') {\n // eslint-disable-next-line no-console\n console.log({\n state,\n shouldProvideThemeManager,\n isAnimated,\n isAnimatedReactNativeWeb,\n tamaguiDefaultProps,\n viewProps,\n splitStyles,\n animationStyles,\n handlesPressEvents,\n isStringElement,\n classNamesIn: props.className?.split(' '),\n classNamesOut: viewProps.className?.split(' '),\n events,\n shouldAttach,\n styles,\n pseudos,\n content,\n childEls,\n shouldAvoidClasses,\n avoidClasses: avoidClassesWhileAnimating,\n animation: props.animation,\n style: splitStylesStyle,\n ...(typeof window !== 'undefined'\n ? {\n theme,\n themeClassName: theme.className,\n staticConfig,\n tamaguiConfig,\n events,\n shouldAvoidClasses,\n shouldForcePseudo,\n classNames: Object.fromEntries(\n Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])\n ),\n }\n : null),\n })\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n\n return content\n })\n\n if (staticConfig.componentName) {\n component.displayName = staticConfig.componentName\n }\n\n onConfiguredOnce((conf) => {\n // one time only setup\n if (!tamaguiConfig) {\n tamaguiConfig = conf\n if (!defaultComponentState) {\n defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n focus: false,\n unmounted: true,\n }\n defaultComponentStateMounted = {\n ...defaultComponentState,\n unmounted: false,\n }\n }\n\n if (tamaguiConfig.animations) {\n AnimatedText = tamaguiConfig.animations.Text\n AnimatedView = tamaguiConfig.animations.View\n }\n\n if (!initialTheme) {\n const next = conf.themes[Object.keys(conf.themes)[0]]\n initialTheme = proxyThemeVariables(next)\n if (process.env.NODE_ENV === 'development') {\n if (!initialTheme) {\n // eslint-disable-next-line no-console\n console.log('Warning: Missing theme')\n }\n }\n }\n }\n\n // per-component setup\n // do this to make sure shorthands don't duplicate with.. longhands\n mergeShorthands(staticConfig, tamaguiConfig)\n\n let defaultPropsIn = staticConfig.defaultProps || {}\n\n // because we run createTamagui after styled() defs, have to do some work here\n // gather defaults props one time and merge downwards\n // find last unprocessed and process\n const parentNames = [...(staticConfig.parentNames || []), staticConfig.componentName]\n\n if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {\n defaultPropsIn = mergeConfigDefaultProps(\n staticConfig.componentName,\n defaultPropsIn,\n tamaguiConfig.defaultProps,\n parentNames,\n tamaguiConfig\n )\n }\n\n const debug = defaultPropsIn['debug']\n\n // remove all classNames\n const [ourProps, ourClassNames] = mergeProps(defaultPropsIn, {})\n\n if (ourProps.tag) {\n defaultTag = ourProps.tag\n }\n\n const noClassNames = !staticConfig.acceptsClassName\n const { name, variants, defaultVariants, ...restProps } = ourProps\n\n // must preserve prop order\n // leave out className because we handle that already with initialSplitStyles.classNames\n // otherwise it confuses variant functions getting className props\n const [defaults, defaultsClassnames] = mergeProps(component.defaultProps as any, {\n ...defaultVariants,\n ...restProps,\n })\n\n // split - keep variables on props to be processed using theme values at runtime (native)\n if (!isWeb) {\n for (const key in staticConfig.defaultProps) {\n const val = staticConfig.defaultProps[key]\n if (validPseudoKeys[key]) continue\n defaults[key] = val\n }\n }\n\n // set to global\n tamaguiDefaultProps = defaults\n\n // add debug logs\n if (process.env.NODE_ENV === 'development' && debug) {\n if (process.env.IS_STATIC !== 'is_static') {\n // eslint-disable-next-line no-console\n console.log(`\uD83D\uDC1B [${staticConfig.componentName || 'Component'}]`, {\n staticConfig,\n tamaguiDefaultProps,\n defaults,\n defaultPropsIn,\n defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),\n defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [\n k,\n defaultPropsIn[k],\n ]),\n ourProps,\n ourClassNames,\n defaultsClassnames,\n defaultTag,\n noClassNames,\n })\n }\n }\n })\n\n let res: TamaguiComponent<ComponentPropTypes, Ref, BaseProps> = component as any\n\n if (configIn.memo) {\n res = memo(res) as any\n }\n\n res.staticConfig = {\n validStyles: staticConfig.validStyles || stylePropsView,\n ...staticConfig,\n }\n\n // res.extractable HoC\n res.extractable = (Component: any, conf?: Partial<StaticConfig>) => {\n Component.staticConfig = extendStaticConfig(\n {\n Component,\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\n },\n res\n )\n return Component\n }\n\n return res\n}\n\n// for elements to avoid spacing\nexport const Unspaced = (props: { children?: any }) => {\n return props.children\n}\nUnspaced['isUnspaced'] = true\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<SpacerProps>({\n acceptsClassName: true,\n memo: true,\n componentName: 'Spacer',\n validStyles,\n\n defaultProps: {\n ...stackDefaultStyles,\n // avoid nesting issues\n tag: 'span',\n size: true,\n },\n\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n size = size === true ? '$true' : size\n const sizePx = tokens.space[size] ?? size\n return {\n width: sizePx,\n height: sizePx,\n minWidth: sizePx,\n minHeight: sizePx,\n }\n },\n },\n\n flex: {\n true: {\n flexGrow: 1,\n },\n },\n\n direction: {\n horizontal: {\n height: 0,\n minHeight: 0,\n },\n vertical: {\n width: 0,\n minWidth: 0,\n },\n both: {},\n },\n } as const,\n})\n\nexport type SpacedChildrenProps = {\n isZStack?: boolean\n children?: React.ReactNode\n space?: SpaceTokens | number | null\n spaceFlex?: boolean | number\n direction?: SpaceDirection\n separator?: React.ReactNode\n}\n\nexport function spacedChildren({\n isZStack,\n children,\n space,\n direction,\n spaceFlex,\n separator,\n}: SpacedChildrenProps) {\n const hasSpace = !!(space || spaceFlex)\n const hasSeparator = !(separator === undefined || separator === null)\n if (!(hasSpace || hasSeparator || isZStack)) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len <= 1 && !isZStack) {\n if (len === 1) {\n // forward space! only when one component doesn't make sense to forward space to all children\n const [onlyChild] = childrenList\n if (React.isValidElement(onlyChild) && onlyChild.type?.['shouldForwardSpace']) {\n return React.cloneElement(onlyChild, {\n space,\n spaceFlex,\n separator,\n } as any)\n }\n }\n return childrenList\n }\n const final: React.ReactNode[] = []\n for (const [index, child] of childrenList.entries()) {\n const isEmpty =\n child === null ||\n child === undefined ||\n (Array.isArray(child) && child.length === 0)\n // push them all, but wrap some in Fragment\n if (isEmpty || !child || (child['key'] && !isZStack)) {\n final.push(child)\n } else {\n final.push(\n <Fragment key={index}>\n {isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}\n </Fragment>\n )\n }\n\n // first child unspaced avoid insert space\n if (isUnspaced(child) && index === 0) continue\n // no spacing on ZStack\n if (isZStack) continue\n\n const next = childrenList[index + 1]\n\n if (next && !isUnspaced(next)) {\n if (separator) {\n if (hasSpace) {\n final.push(\n createSpacer({\n key: `_${index}_00tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n final.push(\n React.isValidElement(separator)\n ? React.cloneElement(separator, { key: `sep_${index}` })\n : separator\n )\n if (hasSpace) {\n final.push(\n createSpacer({\n key: `_${index}01tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n } else {\n final.push(\n createSpacer({\n key: `_${index}02tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n }\n }\n\n return final\n}\n\ntype CreateSpacerProps = SpacedChildrenProps & { key: string }\n\nfunction createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {\n return (\n // @ts-ignore this one blew up but the types seem better\n <Spacer\n key={key}\n size={space}\n direction={direction}\n {...(typeof spaceFlex !== 'undefined' && {\n flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,\n })}\n />\n )\n}\n\nfunction isUnspaced(child: React.ReactNode) {\n // console.log('unspaced?', child, getMedia())\n return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']\n}\n\nconst DefaultProps = new Map()\n\nfunction mergeConfigDefaultProps(\n name: string,\n props: Record<string, any>,\n configDefaults: Record<string, Object>,\n parentNames: (string | undefined)[],\n conf: TamaguiInternalConfig\n) {\n const len = parentNames.length\n let prev\n\n for (let i = 0; i < len; i++) {\n const n = parentNames[i]\n if (!n) continue\n if (DefaultProps.has(n)) {\n prev = DefaultProps.get(n)\n continue\n }\n const props = configDefaults[n]\n if (!props) {\n if (prev) {\n DefaultProps.set(n, prev)\n }\n continue\n }\n prev = mergeProps(prev || {}, props, false, conf.inverseShorthands)[0]\n DefaultProps.set(n, prev)\n }\n\n // overwrite the user defined defaults on top of internal defined defaults\n const ourDefaultsMerged = DefaultProps.get(name)\n if (ourDefaultsMerged) {\n return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0]\n }\n return props\n}\n\n// react native compat (web only)\nfunction usePlatformMethods(hostRef: RefObject<Element>) {\n useIsomorphicLayoutEffect(() => {\n const node = hostRef.current\n if (!node) return\n // @ts-ignore\n node.measure = (callback) => measureLayout(node, null, callback)\n // @ts-ignore\n node.measureLayout = (relativeToNode, success) =>\n measureLayout(node as HTMLElement, relativeToNode, success)\n // @ts-ignore\n node.measureInWindow = (callback) => {\n if (!node) return\n setTimeout(() => {\n const { height, left, top, width } = getRect(node as HTMLElement)!\n callback(left, top, width, height)\n }, 0)\n }\n }, [hostRef])\n}\n\nconst AbsoluteFill: any = createComponent({\n componentName: 'AbsoluteFill',\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n pointerEvents: 'box-none',\n },\n})\n\nconst dontComposePressabilityKeys = {\n onClick: true,\n}\n"],
5
- "mappings": "AA62BU;AA72BV,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AACjC,SAAS,0BAA0B;AACnC,SAAS,2BAA2B;AACpC,SAAS,2BAA2B;AACpC,SAAS,qBAAqB,8BAA8B;AAC5D,SAAS,oBAAoB,yBAAyB;AACtD,SAAS,eAAe;AACxB,SAAS,sBAAsB;AAC/B,S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AM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;AAEA,MAAM,eAAoB,gBAAgB;AAAA,EACxC,eAAe;AAAA,EACf,cAAc;AAAA,IACZ,GAAG;AAAA,IACH,eAAe;AAAA,IACf,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,eAAe;AAAA,EACjB;AACF,CAAC;AAED,MAAM,8BAA8B;AAAA,EAClC,SAAS;AACX;",
4
+ "sourcesContent": ["import { useComposedRefs } from '@tamagui/compose-refs'\nimport {\n isClient,\n isRSC,\n isServer,\n isWeb,\n useIsomorphicLayoutEffect,\n} from '@tamagui/constants'\nimport {\n composeEventHandlers,\n stylePropsView,\n validPseudoKeys,\n validStyles,\n} from '@tamagui/helpers'\nimport { useResponderEvents } from '@tamagui/react-native-use-responder-events'\nimport React, {\n Children,\n Fragment,\n RefObject,\n createElement,\n forwardRef,\n memo,\n useCallback,\n useContext,\n useEffect,\n useRef,\n} from 'react'\n\nimport { onConfiguredOnce } from './config'\nimport { stackDefaultStyles } from './constants/constants'\nimport { FontLanguageContext } from './contexts/FontLanguageContext'\nimport { TextAncestorContext } from './contexts/TextAncestorContext'\nimport { didGetVariableValue, setDidGetVariableValue } from './createVariable'\nimport { extendStaticConfig, parseStaticConfig } from './helpers/extendStaticConfig'\nimport { getRect } from './helpers/getRect'\nimport { useSplitStyles } from './helpers/getSplitStyles'\nimport { getAllSelectors } from './helpers/insertStyleRule'\nimport { mergeProps } from './helpers/mergeProps'\nimport { proxyThemeVariables } from './helpers/proxyThemeVariables'\nimport { useShallowSetState } from './helpers/useShallowSetState'\nimport { measureLayout, useElementLayout } from './hooks/useElementLayout'\nimport { setMediaShouldUpdate, useMedia } from './hooks/useMedia'\nimport { useServerRef, useServerState } from './hooks/useServerHooks'\nimport { getThemeIsNewTheme, getThemeManager, useTheme } from './hooks/useTheme'\nimport {\n DebugProp,\n SpaceDirection,\n SpaceTokens,\n SpacerProps,\n StaticConfig,\n StaticConfigParsed,\n StylableComponent,\n TamaguiComponent,\n TamaguiComponentState,\n TamaguiConfig,\n TamaguiElement,\n TamaguiInternalConfig,\n UseAnimationHook,\n UseAnimationProps,\n} from './types'\nimport { usePressability } from './vendor/Pressability'\nimport { Slot, mergeEvent } from './views/Slot'\nimport { wrapThemeManagerContext } from './views/Theme'\n\n// let t\n// import { timer } from '@tamagui/timer'\n// if (true || process.env.ANALYZE) {\n// t = require().timer()\n// setTimeout(() => {\n// const out = t.print()\n// if (isClient) {\n// alert(out)\n// }\n// }, 2000)\n// }\n\n// this appears to fix expo / babel not picking this up sometimes? really odd\nprocess.env.TAMAGUI_TARGET\n\n/**\n * All things that need one-time setup after createTamagui is called\n */\nlet defaultComponentState: TamaguiComponentState | null = null\nlet defaultComponentStateMounted: TamaguiComponentState | null = null\nlet tamaguiConfig: TamaguiInternalConfig\nlet AnimatedText: any\nlet AnimatedView: any\nlet initialTheme: any\n\nexport const mouseUps = new Set<Function>()\nif (typeof document !== 'undefined') {\n const cancelTouches = () => {\n mouseUps.forEach((x) => x())\n mouseUps.clear()\n }\n addEventListener('mouseup', cancelTouches)\n addEventListener('touchend', cancelTouches)\n addEventListener('touchcancel', cancelTouches)\n}\n\n// mutates\nfunction mergeShorthands(\n { defaultProps }: StaticConfigParsed,\n { shorthands }: TamaguiConfig\n) {\n // they are defined in correct order already { ...parent, ...child }\n for (const key of Object.keys(defaultProps)) {\n defaultProps[shorthands[key] || key] = defaultProps[key]\n }\n}\n\n/**\n * Only on native do we need the actual underlying View/Text\n * On the web we avoid react-native altogether in core.\n */\nlet BaseText: any\nlet BaseView: any\nif (process.env.TAMAGUI_TARGET === 'native') {\n const native = require('react-native')\n BaseText = native.Text || native.default.Text\n BaseView = native.View || native.default.View\n}\n\nexport function createComponent<\n ComponentPropTypes extends Object = {},\n Ref = TamaguiElement,\n BaseProps = never\n>(\n configIn: Partial<StaticConfig> | StaticConfigParsed,\n ParentComponent?: StylableComponent\n) {\n const staticConfig = (() => {\n const next = extendStaticConfig(configIn, ParentComponent)\n if ('parsed' in next) {\n return next\n } else {\n return parseStaticConfig(next)\n }\n })()\n\n const defaultComponentClassName = `is_${staticConfig.componentName}`\n let tamaguiDefaultProps: any\n let defaultTag: string | undefined\n\n // see onConfiguredOnce below which attaches a name then to this component\n const component = forwardRef<Ref, ComponentPropTypes>((propsIn: any, forwardedRef) => {\n // test only\n if (process.env.NODE_ENV === 'test') {\n if (propsIn['data-test-renders']) {\n propsIn['data-test-renders']['current'] ??= 0\n propsIn['data-test-renders']['current'] += 1\n }\n }\n // const time = t.start({ quiet: true })\n\n // React inserts default props after your props for some reason...\n // order important so we do loops, you can't just spread because JS does weird things\n let props: any\n if (tamaguiDefaultProps && !propsIn.asChild) {\n props = mergeProps(tamaguiDefaultProps, propsIn)[0]\n } else {\n props = propsIn\n }\n\n const debugProp = props['debug'] as DebugProp\n const { Component, isText, isZStack } = staticConfig\n const componentName = props.componentName || staticConfig.componentName\n const componentClassName = props.asChild\n ? ''\n : props.componentName\n ? `is_${props.componentName}`\n : defaultComponentClassName\n\n /**\n * Component state for tracking animations, pseudos\n */\n const animationsConfig = tamaguiConfig.animations\n const useAnimations = animationsConfig?.useAnimations as UseAnimationHook | undefined\n const avoidClassesWhileAnimating = animationsConfig.isReactNative\n const hasEnterStyle = !!props.enterStyle\n const needsMount = Boolean(\n (isWeb ? isClient : true) && (hasEnterStyle || props.animation)\n )\n const states = useServerState<TamaguiComponentState>(\n needsMount ? defaultComponentState! : defaultComponentStateMounted!\n )\n\n const state = propsIn.forceStyle\n ? { ...states[0], [propsIn.forceStyle]: true }\n : states[0]\n const setState = states[1]\n const setStateShallow = useShallowSetState(setState, debugProp, componentName)\n\n // conditional but if ever true stays true\n // [animated, inversed]\n const stateRef = useRef(\n undefined as any as {\n hasAnimated?: boolean\n hasThemeInversed?: boolean\n hasProvidedThemeManager?: boolean\n themeShouldReset?: boolean\n }\n )\n stateRef.current ??= {}\n\n const isAnimated = (() => {\n const next = !!(useAnimations && props.animation)\n if (next && !stateRef.current.hasAnimated) {\n stateRef.current.hasAnimated = true\n }\n return next || stateRef.current.hasAnimated\n })()\n\n const usePresence = tamaguiConfig.animations?.usePresence\n const presence = !isRSC && isAnimated ? usePresence() : null\n\n // set enter/exit variants onto our new props object\n if (isAnimated && presence) {\n const presenceState = presence[2]\n if (presenceState) {\n if (state.unmounted && presenceState.enterVariant) {\n props[presenceState.enterVariant] = true\n }\n if (!presenceState.isPresent && presenceState.exitVariant) {\n props[presenceState.exitVariant] = true\n }\n }\n }\n\n const isReactNative = Boolean(\n staticConfig.isReactNative || (isAnimated && tamaguiConfig.animations.isReactNative)\n )\n\n if (process.env.NODE_ENV === 'development') {\n if (debugProp) {\n const name = `${\n componentName ||\n Component?.displayName ||\n Component?.name ||\n '[Unnamed Component]'\n }`\n const type = isReactNative ? '(rnw)' : ''\n const dataIs = propsIn['data-is'] || ''\n const banner = `${name}${dataIs ? ` ${dataIs}` : ''} ${type}`\n // eslint-disable-next-line no-console\n console.group(`%c ${banner}`, 'background: yellow;')\n if (!isServer) {\n // eslint-disable-next-line no-console\n console.log('state', state)\n }\n }\n }\n\n const shouldAvoidClasses =\n !isWeb ||\n !!(props.animation && avoidClassesWhileAnimating) ||\n !staticConfig.acceptsClassName\n const shouldForcePseudo = !!propsIn.forceStyle\n const noClassNames = shouldAvoidClasses || shouldForcePseudo\n\n const theme = useTheme({\n name: props.theme,\n componentName,\n reset: props.reset,\n inverse: props.themeInverse,\n // @ts-expect-error internal use only\n disable: props['data-themeable'],\n debug: props.debug,\n })\n const themeManager = getThemeManager(theme)\n const themeIsNew = getThemeIsNewTheme(theme)\n\n const hasTextAncestor = !!(isWeb && isText ? useContext(TextAncestorContext) : false)\n const languageContext = isRSC ? null : useContext(FontLanguageContext)\n const isDisabled = props.disabled ?? props.accessibilityState?.disabled\n\n const isTaggable = !Component || typeof Component === 'string'\n // default to tag, fallback to component (when both strings)\n const element = isWeb\n ? isTaggable\n ? props.tag || defaultTag || Component\n : Component\n : Component\n\n const BaseTextComponent = BaseText || element || 'span'\n const BaseViewComponent = BaseView || element || (hasTextAncestor ? 'span' : 'div')\n let elementType = isText\n ? (isAnimated ? AnimatedText : null) || BaseTextComponent\n : (isAnimated ? AnimatedView : null) || BaseViewComponent\n\n elementType = Component || elementType\n const isStringElement = typeof elementType === 'string'\n\n const isExiting = presence?.[0] === false\n\n const mediaState = useMedia(\n // @ts-ignore, we just pass a stable object so we can get it later with\n // should match to the one used in `setMediaShouldUpdate` below\n stateRef\n )\n\n setDidGetVariableValue(false)\n\n const splitStyles = useSplitStyles(\n props,\n staticConfig,\n theme,\n {\n ...state,\n mediaState,\n noClassNames,\n dynamicStylesInline: noClassNames,\n hasTextAncestor,\n resolveVariablesAs: 'auto',\n isExiting,\n },\n null,\n languageContext || undefined,\n elementType,\n debugProp\n )\n\n // only listen for changes if we are using raw theme values or media space, or dynamic media (native)\n const shouldListenForMediaChanges =\n didGetVariableValue() ||\n splitStyles.hasMedia === 'space' ||\n (noClassNames === true && splitStyles.hasMedia)\n\n if (shouldListenForMediaChanges) {\n setMediaShouldUpdate(stateRef, shouldListenForMediaChanges)\n }\n\n const hostRef = useServerRef<TamaguiElement>(null)\n\n // animation setup\n const isAnimatedReactNativeWeb = isAnimated && avoidClassesWhileAnimating\n\n if (process.env.NODE_ENV === 'development') {\n if (!process.env.TAMAGUI_TARGET) {\n // eslint-disable-next-line no-console\n console.error(\n `No process.env.TAMAGUI_TARGET set, please set it to \"native\" or \"web\".`\n )\n }\n\n if (debugProp) {\n // eslint-disable-next-line no-console\n console.groupCollapsed('props')\n // eslint-disable-next-line no-console\n console.log(\n 'props in',\n propsIn,\n 'mapped to',\n props,\n 'in order',\n Object.keys(props)\n )\n // eslint-disable-next-line no-console\n console.log('splitStyles', splitStyles)\n // eslint-disable-next-line no-console\n console.log('shouldListenForMediaChanges', shouldListenForMediaChanges)\n // eslint-disable-next-line no-console\n console.log('className', Object.values(splitStyles.classNames))\n if (isClient) {\n // eslint-disable-next-line no-console\n console.log('ref', hostRef, '(click to view)')\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n if (debugProp === 'break') {\n }\n }\n }\n\n const {\n viewProps: viewPropsIn,\n pseudos,\n medias,\n style: splitStylesStyle,\n classNames,\n space,\n } = splitStyles\n\n const propsWithAnimation = props as UseAnimationProps\n\n // once you set animation prop don't remove it, you can set to undefined/false\n // reason is animations are heavy - no way around it, and must be run inline here (\uD83D\uDE45 loading as a sub-component)\n let animationStyles: any\n if (!isRSC && isAnimated && useAnimations) {\n const animations = useAnimations({\n props: propsWithAnimation,\n style: splitStylesStyle,\n presence,\n state,\n pseudos,\n onDidAnimate: props.onDidAnimate,\n hostRef,\n staticConfig,\n })\n if (animations) {\n animationStyles = animations.style\n }\n }\n\n const {\n hitSlop,\n asChild,\n children,\n onPress,\n onPressIn,\n onPressOut,\n onHoverIn,\n onHoverOut,\n themeShallow,\n spaceDirection: _spaceDirection,\n disabled: disabledProp,\n onMouseUp,\n onMouseDown,\n onMouseEnter,\n onMouseLeave,\n hrefAttrs,\n separator,\n // ignore from here on out\n forceStyle: _forceStyle,\n // @ts-ignore for next/link compat etc\n onClick,\n theme: _themeProp,\n // @ts-ignore\n defaultVariants,\n\n ...nonTamaguiProps\n } = viewPropsIn\n\n const disabled =\n (props.accessibilityState != null && props.accessibilityState.disabled === true) ||\n props.accessibilityDisabled\n\n // these can ultimately be for DOM, react-native-web views, or animated views\n // so the type is pretty loose\n let viewProps: Record<string, any>\n\n // if react-native-web view just pass all props down\n if (process.env.TAMAGUI_TARGET === 'web' && !isReactNative) {\n // otherwise replicate react-native-web functionality\n const {\n // event props\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n\n // android\n collapsable,\n focusable,\n\n // deprecated,\n accessible,\n accessibilityDisabled,\n\n onLayout,\n\n ...webProps\n } = nonTamaguiProps\n\n viewProps = webProps\n\n if (!isRSC) {\n usePlatformMethods(hostRef as RefObject<Element>)\n\n useElementLayout(hostRef as RefObject<Element>, onLayout as any)\n\n useResponderEvents(hostRef, {\n onMoveShouldSetResponder,\n onMoveShouldSetResponderCapture,\n onResponderEnd,\n onResponderGrant,\n onResponderMove,\n onResponderReject,\n onResponderRelease,\n onResponderStart,\n onResponderTerminate,\n onResponderTerminationRequest,\n onScrollShouldSetResponder,\n onScrollShouldSetResponderCapture,\n onSelectionChangeShouldSetResponder,\n onSelectionChangeShouldSetResponderCapture,\n onStartShouldSetResponder,\n onStartShouldSetResponderCapture,\n } as any)\n }\n\n if (props.href !== undefined && hrefAttrs !== undefined) {\n const { download, rel, target } = hrefAttrs\n if (download != null) {\n viewProps.download = download\n }\n if (rel != null) {\n viewProps.rel = rel\n }\n if (typeof target === 'string') {\n viewProps.target = target.charAt(0) !== '_' ? `_${target}` : target\n }\n }\n\n // FOCUS\n // \"focusable\" indicates that an element may be a keyboard tab-stop.\n const _focusable = focusable !== undefined ? focusable : accessible\n const role = viewProps.role\n if (_focusable === false) {\n viewProps.tabIndex = '-1'\n }\n if (\n // These native elements are focusable by default\n elementType === 'a' ||\n elementType === 'button' ||\n elementType === 'input' ||\n elementType === 'select' ||\n elementType === 'textarea'\n ) {\n if (_focusable === false || accessibilityDisabled === true) {\n viewProps.tabIndex = '-1'\n }\n } else if (\n // These roles are made focusable by default\n role === 'button' ||\n role === 'checkbox' ||\n role === 'link' ||\n role === 'radio' ||\n role === 'textbox' ||\n role === 'switch'\n ) {\n if (_focusable !== false) {\n viewProps.tabIndex = '0'\n }\n }\n // Everything else must explicitly set the prop\n if (_focusable === true) {\n viewProps.tabIndex = '0'\n }\n } else {\n viewProps = nonTamaguiProps\n }\n\n viewProps.ref = useComposedRefs(hostRef as any, forwardedRef)\n\n if (process.env.NODE_ENV === 'development' && !isText && isWeb) {\n Children.toArray(props.children).forEach((item) => {\n // allow newlines because why not its annoying with mdx\n if (typeof item === 'string' && item !== '\\n') {\n // eslint-disable-next-line no-console\n console.error(\n `Unexpected text node: ${item}. A text node cannot be a child of a <View>.`\n )\n }\n })\n }\n\n const unPress = useCallback(() => {\n setStateShallow({\n press: false,\n pressIn: false,\n })\n }, [setStateShallow])\n\n if (isWeb) {\n useEffect(() => {\n return () => {\n mouseUps.delete(unPress)\n }\n }, [])\n }\n\n const shouldSetMounted = needsMount && state.unmounted\n useEffect(() => {\n if (!shouldSetMounted) return\n setStateShallow({\n unmounted: false,\n })\n }, [shouldSetMounted])\n\n let styles: Record<string, any>[]\n\n if (isStringElement && shouldAvoidClasses && !shouldForcePseudo) {\n styles = {\n ...(animationStyles ?? splitStylesStyle),\n ...medias,\n }\n } else {\n styles = [animationStyles ?? splitStylesStyle, medias]\n\n // ugly but for now...\n if (shouldForcePseudo) {\n const next = {}\n styles.forEach((style) => Object.assign(next, style))\n // @ts-ignore\n Object.assign(splitStyles.style, next)\n }\n }\n\n let fontFamily = isText\n ? splitStyles.fontFamily || staticConfig.defaultProps.fontFamily\n : null\n if (fontFamily && fontFamily[0] === '$') {\n fontFamily = fontFamily.slice(1)\n }\n const fontFamilyClassName = fontFamily ? `font_${fontFamily}` : ''\n\n const classList = [\n hasEnterStyle && ((state.unmounted && needsMount) || !isClient)\n ? 't_will-mount'\n : '',\n componentName ? componentClassName : '',\n fontFamilyClassName,\n themeIsNew ? theme.className : '',\n classNames ? Object.values(classNames).join(' ') : '',\n ]\n\n const className = classList.join(' ')\n\n if (process.env.TAMAGUI_TARGET === 'web') {\n const style = animationStyles ?? splitStyles.style\n\n if (isAnimatedReactNativeWeb) {\n viewProps.style = style\n } else if (isReactNative) {\n const rnwStyle = { $$css: true }\n for (const name of className.split(' ')) {\n rnwStyle[name] = name\n }\n viewProps.style = [rnwStyle, ...(Array.isArray(style) ? style : [style])]\n if (process.env.NODE_ENV === 'development') {\n // turn debug data- props into dataSet in dev mode\n Object.keys(viewProps).forEach((key) => {\n if (key.startsWith('data-')) {\n viewProps.dataSet ??= {}\n viewProps.dataSet[key.replace('data-', '')] = viewProps[key]\n delete viewProps[key]\n }\n })\n }\n } else {\n viewProps.className = className\n viewProps.style = style\n }\n }\n\n if (process.env.TAMAGUI_TARGET === 'native') {\n // swap out the right family based on weight/style\n if (splitStyles.fontFamily) {\n const faceInfo = tamaguiConfig.fontsParsed[splitStyles.fontFamily]?.face\n if (faceInfo) {\n const [weight, style] = (() => {\n let weight: string | undefined\n let style: string | undefined\n for (let i = styles.length; i >= 0; i--) {\n weight ??= styles[i]?.fontWeight\n style ??= styles[i]?.fontStyle\n }\n return [weight || '400', style || 'normal'] as const\n })()\n const overrideFace = faceInfo[weight]?.[style]?.val\n if (overrideFace) {\n for (const style of styles) {\n if (style?.fontFamily) {\n style.fontFamily = overrideFace\n style.fontWeight = undefined\n style.fontStyle = undefined\n }\n }\n }\n }\n }\n\n // assign styles\n viewProps.style = styles\n }\n\n const runtimePressStyle = !disabled && noClassNames && pseudos?.pressStyle\n const attachPress = !!(\n runtimePressStyle ||\n onPress ||\n onPressOut ||\n onPressIn ||\n onClick\n )\n const runtimeHoverStyle = !disabled && noClassNames && pseudos?.hoverStyle\n const isHoverable =\n isWeb &&\n !!(runtimeHoverStyle || onHoverIn || onHoverOut || onMouseEnter || onMouseLeave)\n\n const handlesPressEvents = !(isWeb || asChild)\n\n // check presence rather than value to prevent reparenting bugs\n // allows for onPress={x ? function : undefined} without re-ordering dom\n const shouldAttach = asChild\n ? false\n : Boolean(\n attachPress ||\n isHoverable ||\n 'pressStyle' in props ||\n 'onPress' in props ||\n 'onPressIn' in props ||\n 'onPressOut' in props ||\n (isWeb &&\n ('hoverStyle' in props ||\n 'onHoverIn' in props ||\n 'onHoverOut' in props ||\n 'onMouseEnter' in props ||\n 'onMouseLeave' in props))\n )\n\n const events =\n shouldAttach && !isRSC && !isDisabled\n ? {\n onPressOut: attachPress\n ? (e) => {\n unPress()\n onPressOut?.(e)\n onMouseUp?.(e)\n }\n : undefined,\n ...(isHoverable && {\n onMouseEnter: isHoverable\n ? (e) => {\n const next: Partial<typeof state> = {}\n if (isHoverable) {\n next.hover = true\n }\n if (state.pressIn) {\n next.press = true\n }\n if (isHoverable || state.pressIn) {\n setStateShallow(next)\n }\n onHoverIn?.(e)\n onMouseEnter?.(e)\n }\n : undefined,\n onMouseLeave: isHoverable\n ? (e) => {\n const next: Partial<typeof state> = {}\n mouseUps.add(unPress)\n if (isHoverable) {\n next.hover = false\n }\n if (state.pressIn) {\n next.press = false\n next.pressIn = false\n }\n if (Object.keys(next).length) {\n setStateShallow(next)\n }\n onHoverOut?.(e)\n onMouseLeave?.(e)\n }\n : undefined,\n }),\n onPressIn: attachPress\n ? (e) => {\n setStateShallow({\n press: true,\n pressIn: true,\n hover: false,\n })\n onPressIn?.(e)\n onMouseDown?.(e)\n if (isWeb) {\n mouseUps.add(unPress)\n }\n }\n : undefined,\n onPress: attachPress\n ? (e) => {\n unPress()\n // @ts-ignore\n onClick?.(e)\n onPress?.(e)\n }\n : undefined,\n\n // replicating TouchableWithoutFeedback\n ...(!isWeb && {\n cancelable: !props.rejectResponderTermination,\n disabled: isDisabled,\n hitSlop: props.hitSlop,\n delayLongPress: props.delayLongPress,\n delayPressIn: props.delayPressIn,\n delayPressOut: props.delayPressOut,\n focusable: viewProps.focusable ?? true,\n minPressDuration: 0,\n }),\n }\n : null\n\n const themeShouldReset = Boolean(themeShallow && themeManager && themeIsNew)\n const shouldProvideThemeManager = themeShouldReset || (themeManager && themeIsNew)\n\n // memoize to avoid re-parenting\n if (shouldProvideThemeManager) {\n stateRef.current.hasProvidedThemeManager = true\n }\n if (themeShouldReset) {\n stateRef.current.themeShouldReset = true\n }\n\n const childEls =\n !children || asChild\n ? children\n : wrapThemeManagerContext(\n spacedChildren({\n separator,\n children,\n space,\n direction: props.spaceDirection || 'both',\n isZStack,\n }),\n // only set context if changed theme\n stateRef.current.hasProvidedThemeManager ? themeManager : undefined,\n stateRef.current.themeShouldReset\n )\n\n let content: any\n\n if (asChild) {\n elementType = Slot\n viewProps = {\n ...viewProps,\n onPress,\n onPressIn,\n onPressOut,\n }\n }\n\n // EVENTS native\n if (process.env.TAMAGUI_TARGET === 'native') {\n // add focus events\n const attachFocus = !!pseudos.focusStyle\n if (attachFocus) {\n viewProps.onFocus = mergeEvent(viewProps.onFocus, () => {\n setStateShallow({ focus: true })\n })\n viewProps.onBlur = mergeEvent(viewProps.onBlur, () => {\n setStateShallow({ focus: false })\n })\n }\n\n // use Pressability to get smooth unPress when you press + hold + move out\n // only ever create once, use .configure() to update later\n const pressability = usePressability(events ? { ...events, hitSlop } : {})\n if (attachPress && events) {\n for (const key in pressability) {\n const og = props[key]\n const val = pressability[key]\n viewProps[key] =\n og && !dontComposePressabilityKeys[key] ? composeEventHandlers(og, val) : val\n }\n }\n }\n\n content = createElement(elementType, viewProps, childEls)\n\n if (process.env.TAMAGUI_TARGET === 'web') {\n if (events || isAnimatedReactNativeWeb) {\n content = (\n <span\n className={`${isAnimatedReactNativeWeb ? className : ''} _dsp_contents`}\n {...(events && {\n onMouseEnter: events.onMouseEnter,\n onMouseLeave: events.onMouseLeave,\n onClick: events.onPress,\n onMouseDown: events.onPressIn,\n onMouseUp: events.onPressOut,\n onTouchStart: events.onPressIn,\n onTouchEnd: events.onPressOut,\n })}\n >\n {content}\n </span>\n )\n }\n }\n\n if (process.env.NODE_ENV === 'development' && process.env.DEBUG !== 'tamagui') {\n if (debugProp) {\n const element = typeof elementType === 'string' ? elementType : 'Component'\n // eslint-disable-next-line no-console\n console.groupCollapsed(`render <${element} /> with props`, viewProps)\n for (const key in viewProps) {\n // eslint-disable-next-line no-console\n console.log(key, viewProps[key])\n }\n // eslint-disable-next-line no-console\n console.log('children', content)\n // eslint-disable-next-line no-console\n console.groupEnd()\n if (typeof window !== 'undefined') {\n // eslint-disable-next-line no-console\n console.log({\n state,\n shouldProvideThemeManager,\n isAnimated,\n isAnimatedReactNativeWeb,\n tamaguiDefaultProps,\n viewProps,\n splitStyles,\n animationStyles,\n handlesPressEvents,\n isStringElement,\n classNamesIn: props.className?.split(' '),\n classNamesOut: viewProps.className?.split(' '),\n events,\n shouldAttach,\n styles,\n pseudos,\n content,\n childEls,\n shouldAvoidClasses,\n avoidClasses: avoidClassesWhileAnimating,\n animation: props.animation,\n style: splitStylesStyle,\n ...(typeof window !== 'undefined'\n ? {\n theme,\n themeClassName: theme.className,\n staticConfig,\n tamaguiConfig,\n events,\n shouldAvoidClasses,\n shouldForcePseudo,\n classNames: Object.fromEntries(\n Object.entries(classNames).map(([k, v]) => [v, getAllSelectors()[v]])\n ),\n }\n : null),\n })\n }\n // eslint-disable-next-line no-console\n console.groupEnd()\n }\n }\n\n return content\n })\n\n if (staticConfig.componentName) {\n component.displayName = staticConfig.componentName\n }\n\n onConfiguredOnce((conf) => {\n // one time only setup\n if (!tamaguiConfig) {\n tamaguiConfig = conf\n if (!defaultComponentState) {\n defaultComponentState = {\n hover: false,\n press: false,\n pressIn: false,\n focus: false,\n unmounted: true,\n }\n defaultComponentStateMounted = {\n ...defaultComponentState,\n unmounted: false,\n }\n }\n\n if (tamaguiConfig.animations) {\n AnimatedText = tamaguiConfig.animations.Text\n AnimatedView = tamaguiConfig.animations.View\n }\n\n if (!initialTheme) {\n const next = conf.themes[Object.keys(conf.themes)[0]]\n initialTheme = proxyThemeVariables(next)\n if (process.env.NODE_ENV === 'development') {\n if (!initialTheme) {\n // eslint-disable-next-line no-console\n console.log('Warning: Missing theme')\n }\n }\n }\n }\n\n // per-component setup\n // do this to make sure shorthands don't duplicate with.. longhands\n mergeShorthands(staticConfig, tamaguiConfig)\n\n let defaultPropsIn = staticConfig.defaultProps || {}\n\n // because we run createTamagui after styled() defs, have to do some work here\n // gather defaults props one time and merge downwards\n // find last unprocessed and process\n const parentNames = [...(staticConfig.parentNames || []), staticConfig.componentName]\n\n if (tamaguiConfig.defaultProps && parentNames && staticConfig.componentName) {\n defaultPropsIn = mergeConfigDefaultProps(\n staticConfig.componentName,\n defaultPropsIn,\n tamaguiConfig.defaultProps,\n parentNames,\n tamaguiConfig\n )\n }\n\n const debug = defaultPropsIn['debug']\n\n // remove all classNames\n const [ourProps, ourClassNames] = mergeProps(defaultPropsIn, {})\n\n if (ourProps.tag) {\n defaultTag = ourProps.tag\n }\n\n const noClassNames = !staticConfig.acceptsClassName\n const { name, variants, defaultVariants, ...restProps } = ourProps\n\n // must preserve prop order\n // leave out className because we handle that already with initialSplitStyles.classNames\n // otherwise it confuses variant functions getting className props\n const [defaults, defaultsClassnames] = mergeProps(component.defaultProps as any, {\n ...defaultVariants,\n ...restProps,\n })\n\n // split - keep variables on props to be processed using theme values at runtime (native)\n if (!isWeb) {\n for (const key in staticConfig.defaultProps) {\n const val = staticConfig.defaultProps[key]\n if (validPseudoKeys[key]) continue\n defaults[key] = val\n }\n }\n\n // set to global\n tamaguiDefaultProps = defaults\n\n // add debug logs\n if (process.env.NODE_ENV === 'development' && debug) {\n if (process.env.IS_STATIC !== 'is_static') {\n // eslint-disable-next-line no-console\n console.log(`\uD83D\uDC1B [${staticConfig.componentName || 'Component'}]`, {\n staticConfig,\n tamaguiDefaultProps,\n defaults,\n defaultPropsIn,\n defaultPropsKeyOrder: Object.keys(staticConfig.defaultProps),\n defaultPropsInKeyOrder: Object.keys(defaultPropsIn).map((k) => [\n k,\n defaultPropsIn[k],\n ]),\n ourProps,\n ourClassNames,\n defaultsClassnames,\n defaultTag,\n noClassNames,\n })\n }\n }\n })\n\n let res: TamaguiComponent<ComponentPropTypes, Ref, BaseProps> = component as any\n\n if (configIn.memo) {\n res = memo(res) as any\n }\n\n res.staticConfig = {\n validStyles: staticConfig.validStyles || stylePropsView,\n ...staticConfig,\n }\n\n // res.extractable HoC\n res.extractable = (Component: any, conf?: Partial<StaticConfig>) => {\n Component.staticConfig = extendStaticConfig(\n {\n Component,\n ...conf,\n neverFlatten: true,\n defaultProps: {\n ...Component.defaultProps,\n ...conf?.defaultProps,\n },\n },\n res\n )\n return Component\n }\n\n return res\n}\n\n// for elements to avoid spacing\nexport const Unspaced = (props: { children?: any }) => {\n return props.children\n}\nUnspaced['isUnspaced'] = true\n\n// dont used styled() here to avoid circular deps\n// keep inline to avoid circular deps\n\nexport const Spacer = createComponent<SpacerProps>({\n acceptsClassName: true,\n memo: true,\n componentName: 'Spacer',\n validStyles,\n\n defaultProps: {\n ...stackDefaultStyles,\n // avoid nesting issues\n tag: 'span',\n size: true,\n },\n\n variants: {\n size: {\n '...size': (size, { tokens }) => {\n size = size === true ? '$true' : size\n const sizePx = tokens.space[size] ?? size\n return {\n width: sizePx,\n height: sizePx,\n minWidth: sizePx,\n minHeight: sizePx,\n }\n },\n },\n\n flex: {\n true: {\n flexGrow: 1,\n },\n },\n\n direction: {\n horizontal: {\n height: 0,\n minHeight: 0,\n },\n vertical: {\n width: 0,\n minWidth: 0,\n },\n both: {},\n },\n } as const,\n})\n\nexport type SpacedChildrenProps = {\n isZStack?: boolean\n children?: React.ReactNode\n space?: SpaceTokens | number | null\n spaceFlex?: boolean | number\n direction?: SpaceDirection\n separator?: React.ReactNode\n}\n\nexport function spacedChildren({\n isZStack,\n children,\n space,\n direction,\n spaceFlex,\n separator,\n}: SpacedChildrenProps) {\n const hasSpace = !!(space || spaceFlex)\n const hasSeparator = !(separator === undefined || separator === null)\n if (!(hasSpace || hasSeparator || isZStack)) {\n return children\n }\n const childrenList = Children.toArray(children)\n const len = childrenList.length\n if (len <= 1 && !isZStack) {\n if (len === 1) {\n // forward space! only when one component doesn't make sense to forward space to all children\n const [onlyChild] = childrenList\n if (React.isValidElement(onlyChild) && onlyChild.type?.['shouldForwardSpace']) {\n return React.cloneElement(onlyChild, {\n space,\n spaceFlex,\n separator,\n } as any)\n }\n }\n return childrenList\n }\n const final: React.ReactNode[] = []\n for (const [index, child] of childrenList.entries()) {\n const isEmpty =\n child === null ||\n child === undefined ||\n (Array.isArray(child) && child.length === 0)\n // push them all, but wrap some in Fragment\n if (isEmpty || !child || (child['key'] && !isZStack)) {\n final.push(child)\n } else {\n final.push(\n <Fragment key={index}>\n {isZStack ? <AbsoluteFill>{child}</AbsoluteFill> : child}\n </Fragment>\n )\n }\n\n // first child unspaced avoid insert space\n if (isUnspaced(child) && index === 0) continue\n // no spacing on ZStack\n if (isZStack) continue\n\n const next = childrenList[index + 1]\n\n if (next && !isUnspaced(next)) {\n if (separator) {\n if (hasSpace) {\n final.push(\n createSpacer({\n key: `_${index}_00tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n final.push(\n React.isValidElement(separator)\n ? React.cloneElement(separator, { key: `sep_${index}` })\n : separator\n )\n if (hasSpace) {\n final.push(\n createSpacer({\n key: `_${index}01tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n } else {\n final.push(\n createSpacer({\n key: `_${index}02tmgui`,\n direction,\n space,\n spaceFlex,\n })\n )\n }\n }\n }\n\n return final\n}\n\ntype CreateSpacerProps = SpacedChildrenProps & { key: string }\n\nfunction createSpacer({ key, direction, space, spaceFlex }: CreateSpacerProps) {\n return (\n // @ts-ignore this one blew up but the types seem better\n <Spacer\n key={key}\n size={space}\n direction={direction}\n {...(typeof spaceFlex !== 'undefined' && {\n flex: spaceFlex === true ? 1 : spaceFlex === false ? 0 : spaceFlex,\n })}\n />\n )\n}\n\nfunction isUnspaced(child: React.ReactNode) {\n // console.log('unspaced?', child, getMedia())\n return child?.['type']?.['isVisuallyHidden'] || child?.['type']?.['isUnspaced']\n}\n\nconst DefaultProps = new Map()\n\nfunction mergeConfigDefaultProps(\n name: string,\n props: Record<string, any>,\n configDefaults: Record<string, Object>,\n parentNames: (string | undefined)[],\n conf: TamaguiInternalConfig\n) {\n const len = parentNames.length\n let prev\n\n for (let i = 0; i < len; i++) {\n const n = parentNames[i]\n if (!n) continue\n if (DefaultProps.has(n)) {\n prev = DefaultProps.get(n)\n continue\n }\n const props = configDefaults[n]\n if (!props) {\n if (prev) {\n DefaultProps.set(n, prev)\n }\n continue\n }\n prev = mergeProps(prev || {}, props, false, conf.inverseShorthands)[0]\n DefaultProps.set(n, prev)\n }\n\n // overwrite the user defined defaults on top of internal defined defaults\n const ourDefaultsMerged = DefaultProps.get(name)\n if (ourDefaultsMerged) {\n return mergeProps(props, ourDefaultsMerged, false, conf.inverseShorthands)[0]\n }\n return props\n}\n\n// react native compat (web only)\nfunction usePlatformMethods(hostRef: RefObject<Element>) {\n useIsomorphicLayoutEffect(() => {\n const node = hostRef.current\n if (!node) return\n // @ts-ignore\n node.measure = (callback) => measureLayout(node, null, callback)\n // @ts-ignore\n node.measureLayout = (relativeToNode, success) =>\n measureLayout(node as HTMLElement, relativeToNode, success)\n // @ts-ignore\n node.measureInWindow = (callback) => {\n if (!node) return\n setTimeout(() => {\n const { height, left, top, width } = getRect(node as HTMLElement)!\n callback(left, top, width, height)\n }, 0)\n }\n }, [hostRef])\n}\n\nconst AbsoluteFill: any = createComponent({\n componentName: 'AbsoluteFill',\n defaultProps: {\n ...stackDefaultStyles,\n flexDirection: 'column',\n position: 'absolute',\n top: 0,\n right: 0,\n bottom: 0,\n left: 0,\n pointerEvents: 'box-none',\n },\n})\n\nconst dontComposePressabilityKeys = {\n onClick: true,\n}\n"],
5
+ "mappings": "AA42BU;AA52BV,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,0BAA0B;AACnC,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,wBAAwB;AACjC,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gB,OAAO;AAE5D,SAAK,kBAAkB,CAAC,aAAa;AACnC,UAAI,CAAC;AAAM;AACX,iBAAW,MAAM;AACf,cAAM,EAAE,QAAQ,MAAM,KAAK,MAAM,IAAI,QAAQ,IAAmB;AAChE,iBAAS,MAAM,KAAK,OAAO,MAAM;AAAA,MACnC,GAAG,CAAC;AAAA,IACN;AAAA,EACF,GAAG,CAAC,OAAO,CAAC;AACd;AAEA,MAAM,eAAoB,gBAAgB;AAAA,EACxC,eAAe;AAAA,EACf,cAAc;AAAA,IACZ,GAAG;AAAA,IACH,eAAe;AAAA,IACf,UAAU;AAAA,IACV,KAAK;AAAA,IACL,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,eAAe;AAAA,EACjB;AACF,CAAC;AAED,MAAM,8BAA8B;AAAA,EAClC,SAAS;AACX;",
6
6
  "names": ["_a", "_b", "weight", "style", "element", "props"]
7
7
  }
@@ -62,9 +62,9 @@ class ThemeManager {
62
62
  }
63
63
  getStateShouldChange(nextState, state = this.state) {
64
64
  if (!(nextState == null ? void 0 : nextState.theme) || nextState.theme === (state == null ? void 0 : state.theme)) {
65
- return null;
65
+ return false;
66
66
  }
67
- return nextState;
67
+ return true;
68
68
  }
69
69
  getState(props = this.props, parentManager = this.parentManager) {
70
70
  return getState(props, parentManager) || (process.env.TAMAGUI_TARGET === "native" ? (parentManager == null ? void 0 : parentManager.state) || null : null);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/helpers/ThemeManager.tsx"],
4
- "sourcesContent": ["import { getThemes } from '../config'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'\nimport { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { ThemeParsed, ThemeProps } from '../types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n reset?: boolean\n}\n\nexport type ThemeManagerState = {\n name: string\n theme?: ThemeParsed | null\n className?: string\n parentName?: string\n}\n\nconst emptyState: ThemeManagerState = { name: '' }\n\nexport function hasNoThemeUpdatingProps(props: ThemeProps) {\n return !(props.name || props.componentName || props.inverse || props.reset)\n}\n\nexport class ThemeManager {\n themeListeners = new Set<ThemeListener>()\n parentManager: ThemeManager | null = null\n state: ThemeManagerState = emptyState\n\n constructor(\n public props: ThemeProps = {},\n parentManager?: ThemeManager | 'root' | null | undefined\n ) {\n if (parentManager === 'root') {\n this.updateState(props, false)\n return\n }\n if (!parentManager) {\n throw new Error('Must set up root first')\n }\n // no change no props\n if (hasNoThemeUpdatingProps(props)) {\n return parentManager\n }\n if (parentManager) {\n this.parentManager = parentManager\n }\n const updatedState = this.getStateIfChanged(props)\n if (updatedState) {\n this.state = updatedState\n return\n }\n return parentManager || this\n }\n\n updateState(\n props: ThemeProps & { forceTheme?: ThemeParsed } = this.props || {},\n notify = true\n ) {\n const shouldFlush = (() => {\n if (props.forceTheme) {\n this.state.theme = props.forceTheme\n this.state.name = props.name || ''\n return true\n }\n const nextState = this.getStateIfChanged(props)\n if (nextState) {\n this.state = nextState\n return true\n }\n })()\n if (shouldFlush) {\n // reset any derived state\n this.#allKeys = null\n notify && this.notify()\n return this.state\n }\n }\n\n getStateIfChanged(\n props = this.props,\n state: ThemeManagerState | null = this.state,\n parentManager = this.parentManager\n ) {\n const _ = this.getState(props, parentManager)\n // is removing\n if (state && state !== emptyState && !_) {\n return parentManager?.state\n }\n if (this.getStateShouldChange(_, state)) {\n return _\n }\n }\n\n getStateShouldChange(\n nextState: ThemeManagerState | null,\n state: ThemeManagerState | null = this.state\n ) {\n if (!nextState?.theme || nextState.theme === state?.theme) {\n return null\n }\n return nextState\n }\n\n getState(props = this.props, parentManager = this.parentManager) {\n return (\n getState(props, parentManager) ||\n (process.env.TAMAGUI_TARGET === 'native' ? parentManager?.state || null : null)\n )\n }\n\n #allKeys: Set<string> | null = null\n get allKeys() {\n this.#allKeys ??= new Set([\n ...(this.parentManager?.allKeys || []),\n ...Object.keys(this.state.theme || {}),\n ])\n return this.#allKeys\n }\n\n // gets value going up to parents\n getValue(key: string, state?: ThemeManagerState) {\n let theme = (state || this.state).theme\n let manager = this as ThemeManager | null\n while (theme && manager) {\n if (key in theme) {\n return theme[key]\n }\n manager = manager.parentManager\n theme = manager?.state.theme\n }\n }\n\n notify() {\n this.themeListeners.forEach((cb) => cb(this.state.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n}\n\nfunction getNextThemeClassName(name: string, isInverting = false) {\n const next = `${THEME_CLASSNAME_PREFIX}${name}`\n if (isInverting) {\n return next\n }\n return next.replace('light_', '').replace('dark_', '')\n}\n\nconst cache = new WeakMap<ThemeProps, [ThemeManager, ThemeManagerState | null]>()\n\nfunction getState(\n props: ThemeProps,\n parentManager?: ThemeManager | null\n): ThemeManagerState | null {\n const cached = cache.get(props)\n if (cached && cached[0] === parentManager) {\n return cached[1]\n }\n\n const themes = getThemes()\n\n if (props.name && props.reset) {\n throw new Error('Cannot reset + set new name')\n }\n if (props.reset && !parentManager?.parentManager) {\n throw new Error('Cannot reset no grandparent exists')\n }\n\n let result: ThemeManagerState | null = null\n\n const nextName = props.reset\n ? parentManager?.parentManager?.state?.name || ''\n : props.name || ''\n const { componentName } = props\n const parentName = parentManager?.state?.name || ''\n\n // components look for most specific, fallback upwards\n const base = parentName.split(THEME_NAME_SEPARATOR)\n const lastSegment = base[base.length - 1]\n const isParentAComponentTheme =\n parentName && lastSegment[0].toUpperCase() === lastSegment[0]\n if (isParentAComponentTheme) {\n base.pop() // always remove componentName they can't nest\n }\n const parentBaseTheme = isParentAComponentTheme\n ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)\n : parentName\n const max = base.length\n const min =\n componentName && !nextName\n ? max // component name only don't search upwards\n : 0\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')\n [\n // eslint-disable-next-line no-console\n console.groupCollapsed('ThemeManager.getState()', props, {\n parentName,\n parentBaseTheme,\n base,\n min,\n max,\n isParentAComponentTheme,\n }),\n // eslint-disable-next-line no-console\n console.trace(),\n // eslint-disable-next-line no-console\n console.groupEnd(),\n ]\n\n for (let i = max; i >= min; i--) {\n let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)\n if (props.inverse) {\n prefix = inverseThemeName(prefix)\n }\n const potentials: string[] = []\n if (prefix && prefix !== parentBaseTheme) {\n potentials.push(prefix)\n }\n if (nextName) {\n potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName)\n }\n if (i === 1) {\n const lastSegment = potentials.findIndex((x) => !x.includes('_'))\n if (lastSegment > 0) {\n potentials.splice(lastSegment, 0, nextName) // last try prefer our new name to parent\n }\n }\n if (componentName) {\n // components only look for component themes\n if (nextName) {\n potentials.push(\n `${prefix.slice(\n 0,\n prefix.indexOf(THEME_NAME_SEPARATOR)\n )}_${nextName}_${componentName}`\n )\n }\n potentials.push(`${prefix}_${componentName}`)\n if (nextName) {\n potentials.unshift(`${prefix}_${nextName}_${componentName}`)\n }\n }\n\n const found = potentials.find((t) => t in themes)\n\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')\n console.log('getState found', found, 'from', potentials, 'parentName', parentName)\n\n if (found) {\n // optimization return null if not changed\n if (found === parentName) {\n break\n }\n result = {\n name: found,\n theme: getThemeUnwrapped(themes[found]),\n className: getNextThemeClassName(found, props.inverse),\n parentName,\n }\n break\n }\n }\n\n if (parentManager) {\n cache.set(props, [parentManager, result])\n }\n\n return result\n}\n\nconst inverseThemeName = (themeName: string) => {\n return themeName.startsWith('light')\n ? themeName.replace(/^light/, 'dark')\n : themeName.replace(/^dark/, 'light')\n}\n"],
4
+ "sourcesContent": ["import { getThemes } from '../config'\nimport { THEME_CLASSNAME_PREFIX, THEME_NAME_SEPARATOR } from '../constants/constants'\nimport { getThemeUnwrapped } from '../hooks/getThemeUnwrapped'\nimport { ThemeParsed, ThemeProps } from '../types'\n\ntype ThemeListener = (name: string | null, themeManager: ThemeManager) => void\n\nexport type SetActiveThemeProps = {\n className?: string\n parentManager?: ThemeManager | null\n name?: string | null\n theme?: any\n reset?: boolean\n}\n\nexport type ThemeManagerState = {\n name: string\n theme?: ThemeParsed | null\n className?: string\n parentName?: string\n}\n\nconst emptyState: ThemeManagerState = { name: '' }\n\nexport function hasNoThemeUpdatingProps(props: ThemeProps) {\n return !(props.name || props.componentName || props.inverse || props.reset)\n}\n\nexport class ThemeManager {\n themeListeners = new Set<ThemeListener>()\n parentManager: ThemeManager | null = null\n state: ThemeManagerState = emptyState\n\n constructor(\n public props: ThemeProps = {},\n parentManager?: ThemeManager | 'root' | null | undefined\n ) {\n if (parentManager === 'root') {\n this.updateState(props, false)\n return\n }\n if (!parentManager) {\n throw new Error('Must set up root first')\n }\n // no change no props\n if (hasNoThemeUpdatingProps(props)) {\n return parentManager\n }\n if (parentManager) {\n this.parentManager = parentManager\n }\n const updatedState = this.getStateIfChanged(props)\n if (updatedState) {\n this.state = updatedState\n return\n }\n return parentManager || this\n }\n\n updateState(\n props: ThemeProps & { forceTheme?: ThemeParsed } = this.props || {},\n notify = true\n ) {\n const shouldFlush = (() => {\n if (props.forceTheme) {\n this.state.theme = props.forceTheme\n this.state.name = props.name || ''\n return true\n }\n const nextState = this.getStateIfChanged(props)\n if (nextState) {\n this.state = nextState\n return true\n }\n })()\n if (shouldFlush) {\n // reset any derived state\n this.#allKeys = null\n notify && this.notify()\n return this.state\n }\n }\n\n getStateIfChanged(\n props = this.props,\n state: ThemeManagerState | null = this.state,\n parentManager = this.parentManager\n ) {\n const _ = this.getState(props, parentManager)\n // is removing\n if (state && state !== emptyState && !_) {\n return parentManager?.state\n }\n if (this.getStateShouldChange(_, state)) {\n return _\n }\n }\n\n getStateShouldChange(\n nextState: ThemeManagerState | null,\n state: ThemeManagerState | null = this.state\n ) {\n if (!nextState?.theme || nextState.theme === state?.theme) {\n return false\n }\n return true\n }\n\n getState(props = this.props, parentManager = this.parentManager) {\n return (\n getState(props, parentManager) ||\n (process.env.TAMAGUI_TARGET === 'native' ? parentManager?.state || null : null)\n )\n }\n\n #allKeys: Set<string> | null = null\n get allKeys() {\n this.#allKeys ??= new Set([\n ...(this.parentManager?.allKeys || []),\n ...Object.keys(this.state.theme || {}),\n ])\n return this.#allKeys\n }\n\n // gets value going up to parents\n getValue(key: string, state?: ThemeManagerState) {\n let theme = (state || this.state).theme\n let manager = this as ThemeManager | null\n while (theme && manager) {\n if (key in theme) {\n return theme[key]\n }\n manager = manager.parentManager\n theme = manager?.state.theme\n }\n }\n\n notify() {\n this.themeListeners.forEach((cb) => cb(this.state.name, this))\n }\n\n onChangeTheme(cb: ThemeListener) {\n this.themeListeners.add(cb)\n return () => {\n this.themeListeners.delete(cb)\n }\n }\n}\n\nfunction getNextThemeClassName(name: string, isInverting = false) {\n const next = `${THEME_CLASSNAME_PREFIX}${name}`\n if (isInverting) {\n return next\n }\n return next.replace('light_', '').replace('dark_', '')\n}\n\nconst cache = new WeakMap<ThemeProps, [ThemeManager, ThemeManagerState | null]>()\n\nfunction getState(\n props: ThemeProps,\n parentManager?: ThemeManager | null\n): ThemeManagerState | null {\n const cached = cache.get(props)\n if (cached && cached[0] === parentManager) {\n return cached[1]\n }\n\n const themes = getThemes()\n\n if (props.name && props.reset) {\n throw new Error('Cannot reset + set new name')\n }\n if (props.reset && !parentManager?.parentManager) {\n throw new Error('Cannot reset no grandparent exists')\n }\n\n let result: ThemeManagerState | null = null\n\n const nextName = props.reset\n ? parentManager?.parentManager?.state?.name || ''\n : props.name || ''\n const { componentName } = props\n const parentName = parentManager?.state?.name || ''\n\n // components look for most specific, fallback upwards\n const base = parentName.split(THEME_NAME_SEPARATOR)\n const lastSegment = base[base.length - 1]\n const isParentAComponentTheme =\n parentName && lastSegment[0].toUpperCase() === lastSegment[0]\n if (isParentAComponentTheme) {\n base.pop() // always remove componentName they can't nest\n }\n const parentBaseTheme = isParentAComponentTheme\n ? base.slice(0, base.length).join(THEME_NAME_SEPARATOR)\n : parentName\n const max = base.length\n const min =\n componentName && !nextName\n ? max // component name only don't search upwards\n : 0\n\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')\n [\n // eslint-disable-next-line no-console\n console.groupCollapsed('ThemeManager.getState()', props, {\n parentName,\n parentBaseTheme,\n base,\n min,\n max,\n isParentAComponentTheme,\n }),\n // eslint-disable-next-line no-console\n console.trace(),\n // eslint-disable-next-line no-console\n console.groupEnd(),\n ]\n\n for (let i = max; i >= min; i--) {\n let prefix = base.slice(0, i).join(THEME_NAME_SEPARATOR)\n if (props.inverse) {\n prefix = inverseThemeName(prefix)\n }\n const potentials: string[] = []\n if (prefix && prefix !== parentBaseTheme) {\n potentials.push(prefix)\n }\n if (nextName) {\n potentials.unshift(prefix ? `${prefix}_${nextName}` : nextName)\n }\n if (i === 1) {\n const lastSegment = potentials.findIndex((x) => !x.includes('_'))\n if (lastSegment > 0) {\n potentials.splice(lastSegment, 0, nextName) // last try prefer our new name to parent\n }\n }\n if (componentName) {\n // components only look for component themes\n if (nextName) {\n potentials.push(\n `${prefix.slice(\n 0,\n prefix.indexOf(THEME_NAME_SEPARATOR)\n )}_${nextName}_${componentName}`\n )\n }\n potentials.push(`${prefix}_${componentName}`)\n if (nextName) {\n potentials.unshift(`${prefix}_${nextName}_${componentName}`)\n }\n }\n\n const found = potentials.find((t) => t in themes)\n\n // eslint-disable-next-line no-console\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')\n console.log('getState found', found, 'from', potentials, 'parentName', parentName)\n\n if (found) {\n // optimization return null if not changed\n if (found === parentName) {\n break\n }\n result = {\n name: found,\n theme: getThemeUnwrapped(themes[found]),\n className: getNextThemeClassName(found, props.inverse),\n parentName,\n }\n break\n }\n }\n\n if (parentManager) {\n cache.set(props, [parentManager, result])\n }\n\n return result\n}\n\nconst inverseThemeName = (themeName: string) => {\n return themeName.startsWith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AAsB,OAAO,MAAM,OAAO;AAAA,QACrD;AAAA,MACF;AACA;AAAA,IACF;AAAA,EACF;AAEA,MAAI,eAAe;AACjB,UAAM,IAAI,OAAO,CAAC,eAAe,MAAM,CAAC;AAAA,EAC1C;AAEA,SAAO;AACT;AAEA,MAAM,mBAAmB,CAAC,cAAsB;AAC9C,SAAO,UAAU,WAAW,OAAO,IAC/B,UAAU,QAAQ,UAAU,MAAM,IAClC,UAAU,QAAQ,SAAS,OAAO;AACxC;",
6
6
  "names": ["lastSegment"]
7
7
  }
@@ -1,4 +1,9 @@
1
- import { isClient, isRSC, isServer, isWeb } from "@tamagui/constants";
1
+ import {
2
+ isClient,
3
+ isRSC,
4
+ isServer,
5
+ isWeb
6
+ } from "@tamagui/constants";
2
7
  import { useContext, useEffect, useMemo, useState } from "react";
3
8
  import { getConfig } from "../config";
4
9
  import { isDevTools } from "../constants/isDevTools";
@@ -9,6 +14,7 @@ import {
9
14
  } from "../helpers/ThemeManager";
10
15
  import { ThemeManagerContext } from "../helpers/ThemeManagerContext";
11
16
  import { GetThemeUnwrapped } from "./getThemeUnwrapped";
17
+ import { useServerRef } from "./useServerHooks";
12
18
  const emptyProps = { name: null };
13
19
  function getDefaultThemeProxied() {
14
20
  const config = getConfig();
@@ -23,7 +29,17 @@ const useTheme = (props = emptyProps) => {
23
29
  if (isRSC) {
24
30
  return getDefaultThemeProxied();
25
31
  }
26
- const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(props);
32
+ const state = useServerRef();
33
+ if (isClient && !state.current) {
34
+ state.current = {
35
+ keys: /* @__PURE__ */ new Set()
36
+ };
37
+ }
38
+ const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(
39
+ props,
40
+ false,
41
+ isClient ? () => state.current.keys.size === 0 : void 0
42
+ );
27
43
  if (process.env.NODE_ENV === "development") {
28
44
  if (isWeb && isNewTheme && className === ((_a = themeManager == null ? void 0 : themeManager.parentManager) == null ? void 0 : _a.state.className)) {
29
45
  console.error("Should always change, duplicating ThemeMananger bug", themeManager);
@@ -49,7 +65,8 @@ const useTheme = (props = emptyProps) => {
49
65
  theme,
50
66
  name,
51
67
  className,
52
- themeManager
68
+ themeManager,
69
+ state
53
70
  });
54
71
  }, [theme, isNewTheme, name, className, themeManager]);
55
72
  };
@@ -58,7 +75,8 @@ function getThemeProxied({
58
75
  name,
59
76
  className,
60
77
  themeManager,
61
- isNewTheme
78
+ isNewTheme,
79
+ state
62
80
  }) {
63
81
  return createProxy(theme, {
64
82
  has(_, key) {
@@ -88,7 +106,20 @@ function getThemeProxied({
88
106
  if (!themeManager) {
89
107
  return theme[key];
90
108
  }
91
- return themeManager.getValue(key);
109
+ const val = themeManager.getValue(key);
110
+ if (val && state) {
111
+ if (isClient) {
112
+ return new Proxy(val, {
113
+ get(_2, subkey) {
114
+ if (subkey === "val") {
115
+ state.current.keys.add(key);
116
+ }
117
+ return Reflect.get(val, subkey);
118
+ }
119
+ });
120
+ }
121
+ }
122
+ return val;
92
123
  }
93
124
  });
94
125
  }
@@ -97,7 +128,7 @@ const GetIsNewTheme = Symbol();
97
128
  const getThemeManager = (theme) => theme == null ? void 0 : theme[GetThemeManager];
98
129
  const getThemeIsNewTheme = (theme) => theme == null ? void 0 : theme[GetIsNewTheme];
99
130
  const activeThemeManagers = /* @__PURE__ */ new Set();
100
- const useChangeThemeEffect = (props, root = false) => {
131
+ const useChangeThemeEffect = (props, root = false, disableUpdate) => {
101
132
  if (isRSC) {
102
133
  return {
103
134
  ...createState().state,
@@ -152,12 +183,7 @@ const useChangeThemeEffect = (props, root = false) => {
152
183
  if (!parentManager)
153
184
  throw "impossible";
154
185
  if (process.env.NODE_ENV === "development" && props.debug === "verbose")
155
- console.log(
156
- "useTheme hasNoThemeUpdatingProps",
157
- parentManager.state.name,
158
- "isInversingOnMount",
159
- isInversingOnMount
160
- );
186
+ console.log("useTheme hasNoThemeUpdatingProps", parentManager.state.name, "isInversingOnMount", isInversingOnMount);
161
187
  return {
162
188
  ...parentManager.state,
163
189
  className: isInversingOnMount ? "" : parentManager.state.className,
@@ -175,24 +201,7 @@ const useChangeThemeEffect = (props, root = false) => {
175
201
  const _ = new ThemeManager(props, root ? "root" : parentManager);
176
202
  const isNewTheme2 = _ !== parentManager;
177
203
  if (process.env.NODE_ENV === "development" && debug)
178
- [
179
- console.groupCollapsed("useTheme create() isNewTheme", isNewTheme2),
180
- console.log(
181
- "parent.state.name",
182
- parentManager == null ? void 0 : parentManager.state.name,
183
- "\n",
184
- "props",
185
- props,
186
- "\n",
187
- isClient ? parentManager : "",
188
- "getState",
189
- isNewTheme2 && isClient ? _.getState(props) : "",
190
- "\n",
191
- "state",
192
- isClient ? { ..._.state } : ""
193
- ),
194
- console.groupEnd()
195
- ];
204
+ [console.groupCollapsed("useTheme create() isNewTheme", isNewTheme2), console.log("parent.state.name", parentManager == null ? void 0 : parentManager.state.name, "\n", "props", props, "\n", isClient ? parentManager : "", "getState", isNewTheme2 && isClient ? _.getState(props) : "", "\n", "state", isClient ? { ..._.state } : ""), console.groupEnd()];
196
205
  const mounted2 = !props.inverse ? true : root || (prev == null ? void 0 : prev.mounted);
197
206
  return {
198
207
  isNewTheme: isNewTheme2,
@@ -202,6 +211,9 @@ const useChangeThemeEffect = (props, root = false) => {
202
211
  };
203
212
  }
204
213
  function updateState() {
214
+ if (disableUpdate == null ? void 0 : disableUpdate()) {
215
+ return;
216
+ }
205
217
  const next = themeManager.getState(props, parentManager);
206
218
  const shouldChange = themeManager.getStateShouldChange(
207
219
  next,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/hooks/useTheme.tsx"],
4
- "sourcesContent": ["/* eslint-disable no-console */\nimport { isClient, isRSC, isServer, isWeb } from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport {\n ThemeManager,\n ThemeManagerState,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\n\nexport type ChangedThemeResponse = {\n themeManager: ThemeManager | null\n name: string\n isNewTheme?: boolean\n theme?: ThemeParsed | null\n className?: string\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n if (isRSC) {\n return getDefaultThemeProxied()\n }\n\n const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(props)\n\n if (process.env.NODE_ENV === 'development') {\n // ensure we aren't creating too many ThemeManagers\n if (\n isWeb &&\n isNewTheme &&\n className === themeManager?.parentManager?.state.className\n ) {\n console.error('Should always change, duplicating ThemeMananger bug', themeManager)\n }\n if (props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n }\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return getDefaultThemeProxied()\n }\n\n return useMemo(() => {\n return getThemeProxied({\n isNewTheme,\n theme,\n name,\n className,\n themeManager,\n })\n }, [theme, isNewTheme, name, className, themeManager])\n}\n\nfunction getThemeProxied({\n theme,\n name,\n className,\n themeManager,\n isNewTheme,\n}: {\n theme: any\n name: string\n className?: string\n themeManager?: ThemeManager | null\n isNewTheme?: boolean\n}) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n } else if (key === GetThemeManager) {\n return themeManager\n } else if (key === GetIsNewTheme) {\n return isNewTheme\n } else if (key === 'name') {\n return name\n } else if (key === 'className') {\n return className\n } else if (\n !name ||\n key === '__proto__' ||\n typeof key === 'symbol' ||\n key === '$typeof'\n ) {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') key = key.slice(1)\n if (!themeManager) {\n return theme[key]\n }\n return themeManager.getValue(key)\n },\n })\n}\n\nconst GetThemeManager = Symbol()\nconst GetIsNewTheme = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined =>\n theme?.[GetThemeManager]\nexport const getThemeIsNewTheme = (theme: any): ThemeManager | undefined =>\n theme?.[GetIsNewTheme]\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n ...createState().state,\n themeManager: null,\n }\n }\n const parentManager = useContext(ThemeManagerContext)\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n if (disable) {\n if (!parentManager) throw new Error('Disable topmost')\n return {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }\n }\n\n type State = {\n isNewTheme: boolean\n state: ThemeManagerState\n themeManager: ThemeManager\n mounted?: boolean\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { isNewTheme, state, themeManager, mounted } = themeState\n\n if (!isServer) {\n useEffect(() => {\n if (disable) return\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n activeThemeManagers.add(themeManager)\n const disposeChangeListener = parentManager?.onChangeTheme(() => {\n if (!(isNewTheme || isWeb)) {\n setThemeState({\n ...themeState,\n state: { ...themeManager.state },\n isNewTheme: false,\n })\n } else {\n updateState()\n }\n })\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeChangeListener?.()\n }\n }, [disable, state, isNewTheme, debug])\n }\n\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = hasNoThemeUpdatingProps(props) || isInversingOnMount\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose')\n console.log(\n 'useTheme hasNoThemeUpdatingProps',\n parentManager.state.name,\n 'isInversingOnMount',\n isInversingOnMount\n )\n return {\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n isNewTheme: false,\n }\n }\n\n // run inline in render\n updateState()\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State) {\n const _ = new ThemeManager(props, root ? 'root' : parentManager)\n const isNewTheme = _ !== parentManager\n if (process.env.NODE_ENV === 'development' && debug)\n [\n console.groupCollapsed('useTheme create() isNewTheme', isNewTheme),\n console.log(\n 'parent.state.name',\n parentManager?.state.name,\n '\\n',\n 'props',\n props,\n '\\n',\n isClient ? parentManager : '',\n 'getState',\n isNewTheme && isClient ? _.getState(props) : '',\n '\\n',\n 'state',\n isClient ? { ..._.state } : ''\n ),\n console.groupEnd(),\n ]\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n return {\n // ThemeManager returns parentManager if no change\n isNewTheme,\n state: { ..._.state },\n themeManager: _,\n mounted,\n }\n }\n\n function updateState() {\n const next = themeManager.getState(props, parentManager)\n const shouldChange = themeManager.getStateShouldChange(\n next,\n isNewTheme ? state : null\n )\n if (shouldChange) {\n setThemeState(createState)\n } else {\n if (!next && parentManager?.state.name !== state.name) {\n // were changing back to parent state\n setThemeState(createState)\n }\n }\n }\n}\n"],
5
- "mappings": "AACA,SAAS,UAAU,OAAO,UAAU,aAAa;AACjD,SAAS,YAAY,WAA4B,SAAS,gBAAgB;AAE1E,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;A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AAAA,EACF;AAGA,cAAY;AAEZ,SAAO;AAAA,IACL,GAAG;AAAA,IACH;AAAA,IACA;AAAA,EACF;AAEA,WAAS,YAAY,MAAc;AACjC,UAAM,IAAI,IAAI,aAAa,OAAO,OAAO,SAAS,aAAa;AAC/D,UAAMA,cAAa,MAAM;AACzB,QAAI,QAAQ,IAAI,aAAa,iBAAiB;AAC5C;AAAA,QACE,QAAQ,eAAe,gCAAgCA,WAAU;AAAA,QACjE,QAAQ;AAAA,UACN;AAAA,UACA,+CAAe,MAAM;AAAA,UACrB;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA,WAAW,gBAAgB;AAAA,UAC3B;AAAA,UACAA,eAAc,WAAW,EAAE,SAAS,KAAK,IAAI;AAAA,UAC7C;AAAA,UACA;AAAA,UACA,WAAW,EAAE,GAAG,EAAE,MAAM,IAAI;AAAA,QAC9B;AAAA,QACA,QAAQ,SAAS;AAAA,MACnB;AAEF,UAAMC,WAAU,CAAC,MAAM,UAAU,OAAO,SAAQ,6BAAM;AACtD,WAAO;AAAA,MAEL,YAAAD;AAAA,MACA,OAAO,EAAE,GAAG,EAAE,MAAM;AAAA,MACpB,cAAc;AAAA,MACd,SAAAC;AAAA,IACF;AAAA,EACF;AAEA,WAAS,cAAc;AACrB,UAAM,OAAO,aAAa,SAAS,OAAO,aAAa;AACvD,UAAM,eAAe,aAAa;AAAA,MAChC;AAAA,MACA,aAAa,QAAQ;AAAA,IACvB;AACA,QAAI,cAAc;AAChB,oBAAc,WAAW;AAAA,IAC3B,OAAO;AACL,UAAI,CAAC,SAAQ,+CAAe,MAAM,UAAS,MAAM,MAAM;AAErD,sBAAc,WAAW;AAAA,MAC3B;AAAA,IACF;AAAA,EACF;AACF;",
6
- "names": ["isNewTheme", "mounted"]
4
+ "sourcesContent": ["/* eslint-disable no-console */\nimport {\n isClient,\n isRSC,\n isServer,\n isWeb,\n useIsomorphicLayoutEffect,\n} from '@tamagui/constants'\nimport { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport { getConfig } from '../config'\nimport { isDevTools } from '../constants/isDevTools'\nimport { createProxy } from '../helpers/createProxy'\nimport {\n ThemeManager,\n ThemeManagerState,\n hasNoThemeUpdatingProps,\n} from '../helpers/ThemeManager'\nimport { ThemeManagerContext } from '../helpers/ThemeManagerContext'\nimport { ThemeParsed, ThemeProps } from '../types'\nimport { GetThemeUnwrapped } from './getThemeUnwrapped'\nimport { useServerRef } from './useServerHooks'\n\nexport type ChangedThemeResponse = {\n themeManager: ThemeManager | null\n name: string\n isNewTheme?: boolean\n theme?: ThemeParsed | null\n className?: string\n}\n\nconst emptyProps = { name: null }\n\nfunction getDefaultThemeProxied() {\n const config = getConfig()\n const name = Object.keys(config.themes)[0]\n return getThemeProxied({\n theme: config.themes[name],\n name,\n })\n}\n\ninterface UseThemeState {\n keys: Set<string>\n}\n\nexport const useTheme = (props: ThemeProps = emptyProps): ThemeParsed => {\n if (isRSC) {\n return getDefaultThemeProxied()\n }\n\n const state = useServerRef() as React.MutableRefObject<UseThemeState>\n if (isClient && !state.current) {\n state.current = {\n keys: new Set(),\n }\n }\n\n const { name, theme, themeManager, className, isNewTheme } = useChangeThemeEffect(\n props,\n false,\n isClient ? () => state.current.keys.size === 0 : undefined\n )\n\n if (process.env.NODE_ENV === 'development') {\n // ensure we aren't creating too many ThemeManagers\n if (\n isWeb &&\n isNewTheme &&\n className === themeManager?.parentManager?.state.className\n ) {\n console.error('Should always change, duplicating ThemeMananger bug', themeManager)\n }\n if (props.debug === 'verbose') {\n console.groupCollapsed(' \uD83D\uDD39 useTheme =>', name)\n const logs = { ...props, name, className, ...(isDevTools && { theme }) }\n for (const key in logs) {\n console.log(' ', key, logs[key])\n }\n console.groupEnd()\n }\n }\n\n if (!theme) {\n if (process.env.NODE_ENV === 'development') {\n console.warn('No theme found', name, props, themeManager)\n }\n return getDefaultThemeProxied()\n }\n\n return useMemo(() => {\n return getThemeProxied({\n isNewTheme,\n theme,\n name,\n className,\n themeManager,\n state,\n })\n }, [theme, isNewTheme, name, className, themeManager])\n}\n\nfunction getThemeProxied({\n theme,\n name,\n className,\n themeManager,\n isNewTheme,\n state,\n}: {\n theme: any\n name: string\n className?: string\n themeManager?: ThemeManager | null\n isNewTheme?: boolean\n state?: React.RefObject<UseThemeState>\n}) {\n return createProxy(theme, {\n has(_, key) {\n if (typeof key === 'string') {\n if (key[0] === '$') key = key.slice(1)\n return themeManager?.allKeys.has(key)\n }\n return Reflect.has(theme, key)\n },\n get(_, key) {\n if (key === GetThemeUnwrapped) {\n return theme\n } else if (key === GetThemeManager) {\n return themeManager\n } else if (key === GetIsNewTheme) {\n return isNewTheme\n } else if (key === 'name') {\n return name\n } else if (key === 'className') {\n return className\n } else if (\n !name ||\n key === '__proto__' ||\n typeof key === 'symbol' ||\n key === '$typeof'\n ) {\n return Reflect.get(_, key)\n }\n // auto convert variables to plain\n if (key[0] === '$') key = key.slice(1)\n if (!themeManager) {\n return theme[key]\n }\n const val = themeManager.getValue(key)\n if (val && state) {\n if (isClient) {\n return new Proxy(val as any, {\n get(_, subkey) {\n if (subkey === 'val') {\n state.current!.keys.add(key as any)\n }\n return Reflect.get(val, subkey)\n },\n })\n }\n }\n return val\n },\n })\n}\n\nconst GetThemeManager = Symbol()\nconst GetIsNewTheme = Symbol()\n\nexport const getThemeManager = (theme: any): ThemeManager | undefined =>\n theme?.[GetThemeManager]\nexport const getThemeIsNewTheme = (theme: any): ThemeManager | undefined =>\n theme?.[GetIsNewTheme]\n\nexport const activeThemeManagers = new Set<ThemeManager>()\n\nexport const useChangeThemeEffect = (\n props: ThemeProps,\n root = false,\n disableUpdate?: () => boolean\n): ChangedThemeResponse => {\n if (isRSC) {\n // we need context working for this to work well\n return {\n ...createState().state,\n themeManager: null,\n }\n }\n const parentManager = useContext(ThemeManagerContext)\n\n const {\n debug,\n // @ts-expect-error internal use only\n disable,\n } = props\n\n if (disable) {\n if (!parentManager) throw new Error('Disable topmost')\n return {\n ...parentManager.state,\n isNewTheme: false,\n themeManager: parentManager,\n }\n }\n\n type State = {\n isNewTheme: boolean\n state: ThemeManagerState\n themeManager: ThemeManager\n mounted?: boolean\n }\n\n const [themeState, setThemeState] = useState<State>(createState)\n const { isNewTheme, state, themeManager, mounted } = themeState\n\n if (!isServer) {\n useEffect(() => {\n if (disable) return\n // SSR safe inverse (because server can't know prefers scheme)\n // could be done through fancy selectors like how we do prefers-media\n // but may be a bit of explosion of selectors\n if (props.inverse && !mounted) {\n setThemeState({ ...themeState, mounted: true })\n return\n }\n activeThemeManagers.add(themeManager)\n const disposeChangeListener = parentManager?.onChangeTheme(() => {\n if (!(isNewTheme || isWeb)) {\n setThemeState({\n ...themeState,\n state: { ...themeManager.state },\n isNewTheme: false,\n })\n } else {\n updateState()\n }\n })\n return () => {\n activeThemeManagers.delete(themeManager)\n disposeChangeListener?.()\n }\n }, [disable, state, isNewTheme, debug])\n }\n\n const isInversingOnMount = Boolean(!themeState.mounted && props.inverse)\n const shouldReturnParentState = hasNoThemeUpdatingProps(props) || isInversingOnMount\n\n if (shouldReturnParentState) {\n if (!parentManager) throw 'impossible'\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && props.debug === 'verbose') console.log('useTheme hasNoThemeUpdatingProps', parentManager.state.name, 'isInversingOnMount', isInversingOnMount)\n return {\n ...parentManager.state,\n className: isInversingOnMount ? '' : parentManager.state.className,\n themeManager: parentManager,\n isNewTheme: false,\n }\n }\n\n // run inline in render\n updateState()\n\n return {\n ...state,\n isNewTheme,\n themeManager,\n }\n\n function createState(prev?: State) {\n // returns previous theme manager if no change\n const _ = new ThemeManager(props, root ? 'root' : parentManager)\n const isNewTheme = _ !== parentManager\n // prettier-ignore\n if (process.env.NODE_ENV === 'development' && debug) [console.groupCollapsed('useTheme create() isNewTheme', isNewTheme),console.log('parent.state.name', parentManager?.state.name, '\\n', 'props', props, '\\n', isClient ? parentManager : '', 'getState', isNewTheme && isClient ? _.getState(props) : '', '\\n', 'state', isClient ? { ..._.state } : ''),console.groupEnd()]\n // only inverse relies on this for ssr\n const mounted = !props.inverse ? true : root || prev?.mounted\n return {\n // ThemeManager returns parentManager if no change\n isNewTheme,\n state: { ..._.state },\n themeManager: _,\n mounted,\n }\n }\n\n function updateState() {\n if (disableUpdate?.()) {\n return\n }\n const next = themeManager.getState(props, parentManager)\n const shouldChange = themeManager.getStateShouldChange(\n next,\n isNewTheme ? state : null\n )\n if (shouldChange) {\n setThemeState(createState)\n } else {\n if (!next && parentManager?.state.name !== state.name) {\n // were changing back to parent state\n setThemeState(createState)\n }\n }\n }\n}\n"],
5
+ "mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,YAAY,WAA4B,SAAiB,gBAAgB;AAElF,SAAS,iBAAiB;AAC1B,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,2BAA2B;AAEpC,SAAS,yBAAyB;AAClC,SAAS,oBAAoB;AAU7B,MAAM,aAAa,EAAE,MAAM,KAAK;AAEhC,SAAS,yBAAyB;AAChC,QAAM,SAAS,UAAU;AACzB,QAAM,OAAO,OAAO,KAAK,OAAO,MAAM,EAAE;AACxC,SAAO,gBAAgB;AAAA,IACrB,OAAO,OAAO,OAAO;AAAA,IACrB;AAAA,EACF,CAAC;AACH;AAMO,MAAM,WAAW,CAAC,QAAoB,eAA4B;AA9CzE;AA+CE,MAAI,OAAO;AACT,WAAO,uBAAuB;AAAA,EAChC;AAEA,QAAM,QAAQ,aAAa;AAC3B,MAAI,YAAY,CAAC,MAAM,SAAS;AAC9B,UAAM,UAAU;AAAA,MACd,MAAM,oBAAI,IAAI;AAAA,IAChB;AAAA,EACF;AAEA,QAAM,EAAE,MAAM,OAAO,cAAc,WAAW,WAAW,IAAI;AAAA,IAC3D;AAAA,IACA;AAAA,IACA,WAAW,MAAM,MAAM,QAAQ,KAAK,SAAS,IAAI;AAAA,EACnD;AAE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