{"version":3,"names":["dynamic","omit","Show","mergeRootProps","resolveClassStyle","useButton","useToastRootContext","ToastAction","props","ctx","disabled","Boolean","nativeButton","actionProps","toast","computedChildren","ap","children","shouldRender","button","native","userClassStyle","type","userHtmlProps","internalProps","ref","data-type","merged","Tag","as"],"sources":["toast-action.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { omit, Show } from \"solid-js\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type {\n\tBaseUIComponentProps,\n\tNativeButtonProps,\n} from \"../../internals/types\";\nimport { useButton } from \"../../internals/use-button/use-button\";\nimport { useToastRootContext } from \"../root/toast-root-context\";\n\nexport interface ToastActionState {\n\ttype: string | undefined;\n}\n\nexport interface ToastActionProps\n\textends NativeButtonProps,\n\t\tBaseUIComponentProps<\"button\", ToastActionState> {\n\t/** Tag/component to render. Defaults to `\"button\"`. */\n\tas?: ValidComponent;\n}\n\n/**\n * Optional action button inside the toast.\n */\nexport function ToastAction(props: ToastActionProps): JSX.Element {\n\tconst ctx = useToastRootContext();\n\n\tconst disabled = (): boolean => Boolean(props.disabled);\n\tconst nativeButton = (): boolean => props.nativeButton ?? true;\n\n\tconst actionProps = (): Record<string, unknown> =>\n\t\t(ctx.toast().actionProps ?? {}) as Record<string, unknown>;\n\n\tconst computedChildren = (): JSX.Element | undefined => {\n\t\tconst ap = actionProps();\n\t\treturn (ap.children as JSX.Element | undefined) ?? props.children;\n\t};\n\n\tconst shouldRender = (): boolean => Boolean(computedChildren());\n\n\tconst button = useButton({\n\t\tdisabled,\n\t\tnative: nativeButton,\n\t});\n\tconst userClassStyle = resolveClassStyle(props, () => ({\n\t\ttype: ctx.toast().type,\n\t}));\n\n\tconst userHtmlProps = omit(\n\t\tprops,\n\t\t\"as\",\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t\t\"nativeButton\",\n\t\t\"children\",\n\t) as Record<string, unknown>;\n\n\tconst internalProps = {\n\t\tref: button.ref,\n\t\tget \"data-type\"() {\n\t\t\treturn ctx.toast().type;\n\t\t},\n\t};\n\n\tconst merged = mergeRootProps(\n\t\tmergeRootProps(\n\t\t\tmergeRootProps(\n\t\t\t\tmergeRootProps(internalProps, button.props as Record<string, unknown>),\n\t\t\t\tactionProps() as Record<string, unknown>,\n\t\t\t),\n\t\t\tuserClassStyle,\n\t\t),\n\t\tuserHtmlProps,\n\t);\n\n\tconst Tag = dynamic(() => props.as ?? \"button\");\n\treturn (\n\t\t<Show when={shouldRender()}>\n\t\t\t<Tag {...merged}>{computedChildren()}</Tag>\n\t\t</Show>\n\t);\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,IAAI,EAAEC,IAAI,QAAQ,UAAU;AACrC,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,iBAAiB,QAAQ,qCAAqC;AAKvE,SAASC,SAAS,QAAQ,uCAAuC;AACjE,SAASC,mBAAmB,QAAQ,4BAA4B;AAahE;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,KAAuB,EAAe;EACjE,MAAMC,GAAG,GAAGH,mBAAmB,CAAC,CAAC;EAEjC,MAAMI,QAAQ,GAAGA,CAAA,KAAeC,OAAO,CAACH,KAAK,CAACE,QAAQ,CAAC;EACvD,MAAME,YAAY,GAAGA,CAAA,KAAeJ,KAAK,CAACI,YAAY,IAAI,IAAI;EAE9D,MAAMC,WAAW,GAAGA,CAAA,KAClBJ,GAAG,CAACK,KAAK,CAAC,CAAC,CAACD,WAAW,IAAI,CAAC,CAA6B;EAE3D,MAAME,gBAAgB,GAAGA,CAAA,KAA+B;IACvD,MAAMC,EAAE,GAAGH,WAAW,CAAC,CAAC;IACxB,OAAQG,EAAE,CAACC,QAAQ,IAAgCT,KAAK,CAACS,QAAQ;EAClE,CAAC;EAED,MAAMC,YAAY,GAAGA,CAAA,KAAeP,OAAO,CA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