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,yCAAK;gCACJ,SAAS,IAAM,CAAA,GAAA,YAAI,EAAE,SAAS;gCAC9B,SAAQ;gCACR,WAAU;gCACV,WAAW,oBAAoB;0CAC9B;;4BAGJ,sCACC,gBAAC,CAAA,GAAA,yCAAK;gCACJ,SAAS,IAAM,CAAA,GAAA,YAAI,EAAE,SAAS;gCAC9B,SAAQ;gCACR,YAAY;gCACZ,WAAU;gCACV,WAAW,oBAAoB;0CAC9B;;0CAGL,gBAAC,CAAA,GAAA,yCAAK;gCACJ,SAAS;gCACT,YAAY;gCACZ,WAAW,oBAAoB;gCAC/B,SAAS,IAAM,CAAA,GAAA,YAAI,EAAE,SAAS;0CAC7B;;;;;;;AAOf","sources":["packages/@react-spectrum/s2/src/AlertDialog.tsx"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport AlertTriangle from '../s2wf-icons/S2_Icon_AlertTriangle_20_N.svg';\nimport {Button} from './Button';\nimport {ButtonGroup} from './ButtonGroup';\nimport {CenterBaseline} from './CenterBaseline';\nimport {chain} from '@react-aria/utils';\nimport {Content, Heading} from './Content';\nimport {Dialog} from './Dialog';\nimport {DOMProps, DOMRef} from '@react-types/shared';\nimport {forwardRef, ReactNode} from 'react';\nimport {IconContext} from './Icon';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport NoticeSquare from '../s2wf-icons/S2_Icon_AlertDiamond_20_N.svg';\nimport {Provider} from 'react-aria-components';\nimport {style} from '../style' with {type: 'macro'};\nimport {UnsafeStyles} from './style-utils' with {type: 'macro'};\nimport {useLocalizedStringFormatter} from '@react-aria/i18n';\n\nexport interface AlertDialogProps extends DOMProps, UnsafeStyles {\n  /** The [visual style](https://spectrum.adobe.com/page/alert-dialog/#Options) of the AlertDialog.  */\n  variant?: 'confirmation' | 'information' | 'destructive' | 'error' | 'warning',\n  /** The title of the AlertDialog. */\n  title: string,\n  /** The contents of the AlertDialog. */\n  children: ReactNode,\n  /** The label to display within the cancel button. */\n  cancelLabel?: string,\n  /** The label to display within the confirm button. */\n  primaryActionLabel: string,\n  /** The label to display within the secondary button. */\n  secondaryActionLabel?: string,\n  /** Whether the primary button is disabled. */\n  isPrimaryActionDisabled?: boolean,\n  /** Whether the secondary button is disabled. */\n  isSecondaryActionDisabled?: boolean,\n  /** Handler that is called when the cancel button is pressed. */\n  onCancel?: () => void,\n  /** Handler that is called when the primary button is pressed. */\n  onPrimaryAction?: () => void,\n  /** Handler that is called when the secondary button is pressed. */\n  onSecondaryAction?: () => void,\n  /** Button to focus by default when the dialog opens. */\n  autoFocusButton?: 'cancel' | 'primary' | 'secondary',\n  /**\n   * The size of the Dialog.\n   *\n   * @default 'M'\n   */\n    size?: 'S' | 'M' | 'L'\n}\n\nconst icon = style({\n  marginEnd: 8,\n  '--iconPrimary': {\n    type: 'fill',\n    value: {\n      variant: {\n        error: 'negative',\n        warning: 'notice'\n      }\n    }\n  }\n});\n\n/**\n * AlertDialogs are a specific type of Dialog. They display important information that users need to acknowledge.\n */\nexport const AlertDialog = forwardRef(function AlertDialog(props: AlertDialogProps, ref: DOMRef) {\n  let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/s2');\n  let {\n    autoFocusButton,\n    cancelLabel,\n    secondaryActionLabel,\n    primaryActionLabel,\n    isSecondaryActionDisabled,\n    isPrimaryActionDisabled,\n    onCancel = () => {},\n    onPrimaryAction = () => {},\n    onSecondaryAction = () => {},\n    title,\n    children,\n    variant = 'confirmation'\n  } = props;\n\n  let buttonVariant = 'primary';\n  if (variant === 'confirmation') {\n    buttonVariant = 'accent';\n  } else if (variant === 'destructive') {\n    buttonVariant = 'negative';\n  }\n\n  return (\n    <Dialog\n      role=\"alertdialog\"\n      ref={ref}\n      size={props.size}\n      UNSAFE_style={props.UNSAFE_style}\n      UNSAFE_className={(props.UNSAFE_className || '')}>\n      {({close}) => (\n        <>\n          <Provider\n            values={[\n              [IconContext, {styles: icon({variant})}]\n            ]}>\n            <Heading slot=\"title\">\n              <CenterBaseline>\n                {variant === 'error' && <AlertTriangle aria-label={stringFormatter.format('dialog.alert')} />}\n                {variant === 'warning' && <NoticeSquare aria-label={stringFormatter.format('dialog.alert')} />}\n                {title}\n              </CenterBaseline>\n            </Heading>\n          </Provider>\n          <Content>{children}</Content>\n          <ButtonGroup>\n            {cancelLabel &&\n              <Button\n                onPress={() => chain(close(), onCancel())}\n                variant=\"secondary\"\n                fillStyle=\"outline\"\n                autoFocus={autoFocusButton === 'cancel'}>\n                {cancelLabel}\n              </Button>\n            }\n            {secondaryActionLabel &&\n              <Button\n                onPress={() => chain(close(), onSecondaryAction())}\n                variant=\"secondary\"\n                isDisabled={isSecondaryActionDisabled}\n                fillStyle=\"outline\"\n                autoFocus={autoFocusButton === 'secondary'}>\n                {secondaryActionLabel}\n              </Button>\n            }\n            <Button\n              variant={buttonVariant as 'primary' | 'accent' | 'negative'}\n              isDisabled={isPrimaryActionDisabled}\n              autoFocus={autoFocusButton === 'primary'}\n              onPress={() => chain(close(), onPrimaryAction())}>\n              {primaryActionLabel}\n            </Button>\n          </ButtonGroup>\n        </>\n      )}\n    </Dialog>\n  );\n});\n"],"names":[],"version":3,"file":"AlertDialog.mjs.map"}