{"version":3,"names":["dynamic","createEffect","createSignal","omit","Show","untrack","mergeRootProps","resolveClassStyle","useAvatarRootContext","AvatarFallback","props","context","delayPassed","setDelayPassed","delay","undefined","ownedWrite","timeoutId","window","setTimeout","clearTimeout","shouldShow","imageLoadingStatus","userStyling","userHtmlProps","styledUserProps","merged","Tag","as"],"sources":["avatar-fallback.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { createEffect, createSignal, omit, Show, untrack } from \"solid-js\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport { useAvatarRootContext } from \"../avatar-root-context\";\nimport type { AvatarRootState } from \"../root/avatar-root\";\n\nexport interface AvatarFallbackState extends AvatarRootState {}\n\nexport interface AvatarFallbackProps\n\textends BaseUIComponentProps<\"span\", AvatarFallbackState> {\n\t/** Tag/component to render. Defaults to `\"span\"`. */\n\tas?: ValidComponent;\n\t/**\n\t * How long to wait before showing the fallback. Specified in milliseconds.\n\t *\n\t * When `delay` is `undefined`, the fallback is eligible immediately. When\n\t * it is a number, the fallback stays hidden for that many milliseconds\n\t * after mount, giving the image a chance to load first.\n\t */\n\tdelay?: number | undefined;\n}\n\n/**\n * Rendered when the image fails to load or when no image is provided.\n * Renders a `<span>` element.\n */\nexport function AvatarFallback(props: AvatarFallbackProps): JSX.Element {\n\tconst context = useAvatarRootContext();\n\n\t// `delayPassed` starts true when `delay` is undefined (fallback is eligible\n\t// immediately) and is flipped by the timer below once the delay elapses.\n\t// Internal plumbing — `ownedWrite` lets the split-effect's apply half (owned\n\t// scope) flip it without tripping SIGNAL_WRITE_IN_OWNED_SCOPE.\n\t// Initial value is a snapshot — the split effect below tracks\n\t// `props.delay` independently and re-flips this signal on changes, so\n\t// the seed read can be untracked to silence `[STRICT_READ_UNTRACKED]`.\n\tconst [delayPassed, setDelayPassed] = createSignal(\n\t\tuntrack(() => props.delay === undefined),\n\t\t{\n\t\t\townedWrite: true,\n\t\t},\n\t);\n\n\t// Split effect: the compute half tracks `props.delay`; the apply half\n\t// installs / clears the timer. When `delay` changes, Solid cleans up the\n\t// previous apply run (clearing the stale timer) and re-runs with the new\n\t// value — matching Base UI React, which keys its effect on `delay`.\n\t// `onSettled` wouldn't give restart-on-change semantics; a split\n\t// `createEffect` does.\n\tcreateEffect(\n\t\t() => props.delay,\n\t\t(delay) => {\n\t\t\tif (delay === undefined) {\n\t\t\t\tsetDelayPassed(true);\n\t\t\t\treturn undefined;\n\t\t\t}\n\t\t\tsetDelayPassed(false);\n\t\t\tconst timeoutId = window.setTimeout(() => {\n\t\t\t\tsetDelayPassed(true);\n\t\t\t}, delay);\n\t\t\treturn () => {\n\t\t\t\twindow.clearTimeout(timeoutId);\n\t\t\t};\n\t\t},\n\t);\n\n\t// Visible when the image is not yet loaded (idle/loading/error) AND the\n\t// configured delay has passed. Use a memo-ish accessor — Solid tracks\n\t// both reads inside `<Show when>`'s compute naturally.\n\tconst shouldShow = (): boolean =>\n\t\tcontext.imageLoadingStatus() !== \"loaded\" && delayPassed();\n\n\tconst userStyling = resolveClassStyle(props, () => ({\n\t\timageLoadingStatus: context.imageLoadingStatus(),\n\t}));\n\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t\t\"as\",\n\t\t\"delay\",\n\t) as Record<string, unknown>;\n\tconst styledUserProps = mergeRootProps(userStyling, userHtmlProps);\n\n\tconst merged = mergeRootProps({}, styledUserProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"span\");\n\treturn (\n\t\t<Show when={shouldShow()}>\n\t\t\t<Tag {...merged} />\n\t\t</Show>\n\t);\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,YAAY,EAAEC,YAAY,EAAEC,IAAI,EAAEC,IAAI,EAAEC,OAAO,QAAQ,UAAU;AA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