{"version":3,"file":"UpdatePrompt.cjs","names":[],"sources":["../../../src/components/UpdatePrompt/UpdatePrompt.tsx"],"sourcesContent":["import type { HTMLAttributes, ReactNode } from \"react\";\nimport { RefreshCw, X } from \"lucide-react\";\nimport { cn } from \"@/utils/cn\";\nimport styles from \"./UpdatePrompt.module.css\";\n\nexport type UpdatePromptPosition = \"top\" | \"bottom\";\n\nexport interface UpdatePromptProps extends Omit<HTMLAttributes<HTMLDivElement>, \"children\"> {\n    /** Whether the prompt is visible. Feed from `useServiceWorkerUpdate().updateAvailable`. */\n    open: boolean;\n    /** Called when the user confirms the update. Wire to `applyUpdate`. */\n    onUpdate: () => void;\n    /** Called when the user dismisses the prompt. Omit to hide the dismiss button. */\n    onDismiss?: () => void;\n    /** Body message. */\n    message?: ReactNode;\n    /** Confirm button label. Default `\"Atualizar\"`. */\n    actionLabel?: string;\n    /** Where to pin the fixed toast. Default `\"bottom\"`. */\n    position?: UpdatePromptPosition;\n}\n\n/**\n * Fixed toast prompting the user to activate a freshly installed service\n * worker. Presentational — pair with {@link useServiceWorkerUpdate}, feeding\n * `updateAvailable` to `open` and `applyUpdate` to `onUpdate`.\n *\n * Renders nothing while `open` is `false`.\n *\n * @example\n * const { updateAvailable, applyUpdate } = useServiceWorkerUpdate({ url: \"/sw.js\" });\n * <UpdatePrompt open={updateAvailable} onUpdate={applyUpdate} />\n */\nexport function UpdatePrompt({\n    open,\n    onUpdate,\n    onDismiss,\n    message = \"Uma nova versão está disponível.\",\n    actionLabel = \"Atualizar\",\n    position = \"bottom\",\n    className,\n    ...props\n}: UpdatePromptProps) {\n    if (!open) return null;\n    return (\n        <div\n            className={cn(styles.prompt, styles[position], className)}\n            role=\"alert\"\n            aria-live=\"assertive\"\n            {...props}\n        >\n            <RefreshCw className={styles.icon} size={18} aria-hidden=\"true\" />\n            <span className={styles.message}>{message}</span>\n            <button type=\"button\" className={styles.action} onClick={onUpdate}>\n                {actionLabel}\n            </button>\n            {onDismiss && (\n                <button\n                    type=\"button\"\n                    className={styles.dismiss}\n                    aria-label=\"Dispensar\"\n                    onClick={onDismiss}\n                >\n                    <X size={16} aria-hidden=\"true\" />\n                </button>\n            )}\n        </div>\n    );\n}\n"],"mappings":"0IAiCA,SAAgB,EAAa,CACzB,OACA,WACA,YACA,UAAU,mCACV,cAAc,YACd,WAAW,SACX,YACA,GAAG,GACe,CAElB,OADK,GAED,EAAA,EAAA,KAAA,CAAC,MAAD,CACI,UAAW,EAAA,GAAG,EAAA,QAAO,OAAQ,EAAA,QAAO,GAAW,CAAS,EACxD,KAAK,QACL,YAAU,YACV,GAAI,EAJR,SAAA,EAMI,EAAA,EAAA,IAAA,CAAC,EAAA,UAAD,CAAW,UAAW,EAAA,QAAO,KAAM,KAAM,GAAI,cAAY,MAAQ,CAAA,GACjE,EAAA,EAAA,IAAA,CAAC,OAAD,CAAM,UAAW,EAAA,QAAO,QAAU,SAAA,CAAc,CAAA,GAChD,EAAA,EAAA,IAAA,CAAC,SAAD,CAAQ,KAAK,SAAS,UAAW,EAAA,QAAO,OAAQ,QAAS,EACpD,SAAA,CACG,CAAA,EACP,IACG,EAAA,EAAA,IAAA,CAAC,SAAD,CACI,KAAK,SACL,UAAW,EAAA,QAAO,QAClB,aAAW,YACX,QAAS,EAET,UAAA,EAAA,EAAA,IAAA,CAAC,EAAA,EAAD,CAAG,KAAM,GAAI,cAAY,MAAQ,CAAA,CAC7B,CAAA,CAEX,IAvBS,IAyBtB"}