{
  "version": 3,
  "sources": ["../../src/clipboard-button/index.tsx"],
  "sourcesContent": ["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { useRef, useEffect } from '@wordpress/element';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport deprecated from '@wordpress/deprecated';\n\n/**\n * Internal dependencies\n */\nimport Button from '../button';\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nconst TIMEOUT = 4000;\nexport default function ClipboardButton({\n  className,\n  children,\n  onCopy,\n  onFinishCopy,\n  text,\n  ...buttonProps\n}) {\n  deprecated('wp.components.ClipboardButton', {\n    since: '5.8',\n    alternative: 'wp.compose.useCopyToClipboard'\n  });\n  const timeoutIdRef = useRef(undefined);\n  const ref = useCopyToClipboard(text, () => {\n    onCopy();\n    if (timeoutIdRef.current) {\n      clearTimeout(timeoutIdRef.current);\n    }\n    if (onFinishCopy) {\n      timeoutIdRef.current = setTimeout(() => onFinishCopy(), TIMEOUT);\n    }\n  });\n  useEffect(() => {\n    return () => {\n      if (timeoutIdRef.current) {\n        clearTimeout(timeoutIdRef.current);\n      }\n    };\n  }, []);\n  const classes = clsx('components-clipboard-button', className);\n\n  // Workaround for inconsistent behavior in Safari, where <textarea> is not\n  // the document.activeElement at the moment when the copy event fires.\n  // This causes documentHasSelection() in the copy-handler component to\n  // mistakenly override the ClipboardButton, and copy a serialized string\n  // of the current block instead.\n  const focusOnCopyEventTarget = event => {\n    // @ts-expect-error: Should be currentTarget, but not changing because this component is deprecated.\n    event.target.focus();\n  };\n  return (\n    /*#__PURE__*/\n    // Disable reasons: the parent component takes care of the __next40pxDefaultSize prop.\n    // eslint-disable-next-line @wordpress/components-no-missing-40px-size-prop\n    _jsx(Button, {\n      ...buttonProps,\n      className: classes,\n      ref: ref,\n      onCopy: focusOnCopyEventTarget,\n      children: children\n    })\n  );\n}"],
  "mappings": ";AAGA,OAAO,UAAU;AAKjB,SAAS,QAAQ,iBAAiB;AAClC,SAAS,0BAA0B;AACnC,OAAO,gBAAgB;AAKvB,OAAO,YAAY;AACnB,SAAS,OAAO,YAAY;AAC5B,IAAM,UAAU;AACD,SAAR,gBAAiC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,GAAG;AACD,aAAW,iCAAiC;AAAA,IAC1C,OAAO;AAAA,IACP,aAAa;AAAA,EACf,CAAC;AACD,QAAM,eAAe,OAAO,MAAS;AACrC,QAAM,MAAM,mBAAmB,MAAM,MAAM;AACzC,WAAO;AACP,QAAI,aAAa,SAAS;AACxB,mBAAa,aAAa,OAAO;AAAA,IACnC;AACA,QAAI,cAAc;AAChB,mBAAa,UAAU,WAAW,MAAM,aAAa,GAAG,OAAO;AAAA,IACjE;AAAA,EACF,CAAC;AACD,YAAU,MAAM;AACd,WAAO,MAAM;AACX,UAAI,aAAa,SAAS;AACxB,qBAAa,aAAa,OAAO;AAAA,MACnC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,CAAC;AACL,QAAM,UAAU,KAAK,+BAA+B,SAAS;AAO7D,QAAM,yBAAyB,WAAS;AAEtC,UAAM,OAAO,MAAM;AAAA,EACrB;AACA;AAAA;AAAA;AAAA,IAIE,qBAAK,QAAQ;AAAA,MACX,GAAG;AAAA,MACH,WAAW;AAAA,MACX;AAAA,MACA,QAAQ;AAAA,MACR;AAAA,IACF,CAAC;AAAA;AAEL;",
  "names": []
}
