"use client" /** * Forked from https://github.com/emotion-js/emotion/blob/main/packages/styled/src/base.js * but optimized for Chakra UI. All credits to the original authors. * * This also serves a bridge to React 19's style tag hoisting features. */ import emotionIsPropValid from "@emotion/is-prop-valid" import { ThemeContext, withEmotionCache } from "@emotion/react" import { serializeStyles } from "@emotion/serialize" //@ts-ignore import { useInsertionEffectAlwaysWithSyncFallback } from "@emotion/use-insertion-effect-with-fallbacks" import { getRegisteredStyles, insertStyles, registerStyles, } from "@emotion/utils" import * as React from "react" import { mergeProps } from "../merge-props" import { mergeRefs } from "../merge-refs" import { compact, cx, getElementRef, interopDefault, uniq } from "../utils" import type { JsxFactory, StyledFactoryFn } from "./factory.types" import { useChakraContext } from "./provider" import { isHtmlProp, useResolvedProps } from "./use-resolved-props" const isPropValid = interopDefault(emotionIsPropValid) const testOmitPropsOnStringTag = isPropValid const testOmitPropsOnComponent = (key: string) => key !== "theme" const composeShouldForwardProps = (tag: any, options: any, isReal: boolean) => { let shouldForwardProp if (options) { const optionsShouldForwardProp = options.shouldForwardProp shouldForwardProp = tag.__emotion_forwardProp && optionsShouldForwardProp ? (propName: string) => tag.__emotion_forwardProp(propName) && optionsShouldForwardProp(propName) : optionsShouldForwardProp } if (typeof shouldForwardProp !== "function" && isReal) { shouldForwardProp = tag.__emotion_forwardProp } return shouldForwardProp } let isBrowser = typeof document !== "undefined" const Insertion = ({ cache, serialized, isStringTag }: any) => { registerStyles(cache, serialized, isStringTag) const rules = useInsertionEffectAlwaysWithSyncFallback(() => insertStyles(cache, serialized, isStringTag), ) if (!isBrowser && rules !== undefined) { let serializedNames = serialized.name let next = serialized.next while (next !== undefined) { serializedNames = cx(serializedNames, next.name) next = next.next } return (