import{r as l,j as o,d as t,K as d}from"./index-C6X1YceK.js";const m=({value:a,children:e,tooltipMessage:p,onCopyButtonClick:n})=>{const[s,r]=l.useState(!1),c=async()=>{try{await navigator.clipboard.writeText(a),r(!0),n?.(),setTimeout(()=>{r(!1)},2e3)}catch(i){console.error(i)}};return navigator.clipboard===void 0?o.jsx(o.Fragment,{children:e}):o.jsxs("div",{className:"copy-to-clipboard-container",children:[o.jsx("div",{className:"u-truncate",children:e}),o.jsx(t.Button,{appearance:"base",type:"button",hasIcon:!0,dense:!0,className:"u-no-margin--bottom copy-to-clipboard-button","aria-label":s?"Copied to clipboard":"Copy to clipboard",onClick:c,children:s?o.jsx(t.Icon,{className:"copy-to-clipboard-button-wrapper",name:"task-outstanding"}):o.jsx(t.Tooltip,{message:p??"Copy",position:"top-center",className:"copy-to-clipboard-button-wrapper",zIndex:999,children:o.jsx(t.Icon,{name:"copy-to-clipboard"})})})]})},b=({code:a,className:e,appearance:p=t.CodeSnippetBlockAppearance.LINUX_PROMPT,title:n,tooltipMessage:s,onCopyButtonClick:r})=>o.jsx(t.CodeSnippet,{className:d("code-snippet-with-copy-button-wrapper",e),blocks:[{appearance:p,title:n,code:o.jsxs("div",{className:"command-wrapper",children:[o.jsx("span",{className:"command u-truncate",title:a,children:a}),o.jsx(m,{value:a,tooltipMessage:s,onCopyButtonClick:r})]})}]});export{b as C};
