{
  "version": 3,
  "sources": ["../../src/notice/index.tsx"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { RawHTML, useEffect, renderToString } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { close } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { VisuallyHidden } from '../visually-hidden';\nimport { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nconst noop = () => {};\n\n/**\n * Custom hook which announces the message with the given politeness, if a\n * valid message is provided.\n */\nfunction useSpokenMessage(message, politeness) {\n  const spokenMessage = typeof message === 'string' ? message : renderToString(message);\n  useEffect(() => {\n    if (spokenMessage) {\n      speak(spokenMessage, politeness);\n    }\n  }, [spokenMessage, politeness]);\n}\nfunction getDefaultPoliteness(status) {\n  switch (status) {\n    case 'success':\n    case 'warning':\n    case 'info':\n      return 'polite';\n    // The default will also catch the 'error' status.\n    default:\n      return 'assertive';\n  }\n}\nfunction getStatusLabel(status) {\n  switch (status) {\n    case 'warning':\n      return __('Warning notice');\n    case 'info':\n      return __('Information notice');\n    case 'error':\n      return __('Error notice');\n    // The default will also catch the 'success' status.\n    default:\n      return __('Notice');\n  }\n}\n\n/**\n * `Notice` is a component used to communicate feedback to the user.\n *\n *```jsx\n * import { Notice } from `@wordpress/components`;\n *\n * const MyNotice = () => (\n *   <Notice status=\"error\">An unknown error occurred.</Notice>\n * );\n * ```\n */\nfunction Notice({\n  className,\n  status = 'info',\n  children,\n  spokenMessage = children,\n  onRemove = noop,\n  isDismissible = true,\n  actions = [],\n  politeness = getDefaultPoliteness(status),\n  __unstableHTML,\n  // onDismiss is a callback executed when the notice is dismissed.\n  // It is distinct from onRemove, which _looks_ like a callback but is\n  // actually the function to call to remove the notice from the UI.\n  onDismiss = noop\n}) {\n  useSpokenMessage(spokenMessage, politeness);\n  const classes = clsx(className, 'components-notice', 'is-' + status, {\n    'is-dismissible': isDismissible\n  });\n  if (__unstableHTML && typeof children === 'string') {\n    children = /*#__PURE__*/_jsx(RawHTML, {\n      children: children\n    });\n  }\n  const onDismissNotice = () => {\n    onDismiss();\n    onRemove();\n  };\n  return /*#__PURE__*/_jsxs(\"div\", {\n    className: classes,\n    children: [/*#__PURE__*/_jsx(VisuallyHidden, {\n      children: getStatusLabel(status)\n    }), /*#__PURE__*/_jsxs(\"div\", {\n      className: \"components-notice__content\",\n      children: [children, actions.length > 0 && /*#__PURE__*/_jsx(\"div\", {\n        className: \"components-notice__actions\",\n        children: actions.map(({\n          className: buttonCustomClasses,\n          label,\n          isPrimary,\n          variant,\n          noDefaultClasses = false,\n          onClick,\n          url,\n          disabled\n        }, index) => {\n          let computedVariant = variant;\n          if (variant !== 'primary' && !noDefaultClasses) {\n            computedVariant = !url ? 'secondary' : 'link';\n          }\n          if (typeof computedVariant === 'undefined' && isPrimary) {\n            computedVariant = 'primary';\n          }\n          return /*#__PURE__*/_jsx(Button, {\n            __next40pxDefaultSize: true,\n            href: url,\n            variant: computedVariant,\n            onClick: onClick,\n            disabled: disabled,\n            accessibleWhenDisabled: true,\n            className: clsx('components-notice__action', buttonCustomClasses),\n            children: label\n          }, index);\n        })\n      })]\n    }), isDismissible && /*#__PURE__*/_jsx(Button, {\n      size: \"small\",\n      className: \"components-notice__dismiss\",\n      icon: close,\n      label: __('Close'),\n      onClick: onDismissNotice\n    })]\n  });\n}\nexport default Notice;"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAiB;AAKjB,kBAAmB;AACnB,qBAAmD;AACnD,kBAAsB;AACtB,mBAAsB;AAKtB,oBAAmB;AACnB,6BAA+B;AAC/B,yBAA2C;AAC3C,IAAM,OAAO,MAAM;AAAC;AAMpB,SAAS,iBAAiB,SAAS,YAAY;AAC7C,QAAM,gBAAgB,OAAO,YAAY,WAAW,cAAU,+BAAe,OAAO;AACp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