import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{t}from"./clipboard-DMTjLsXj.js";import{Ff as n,Gy as r,Hy as i,Ly as a,Vy as o,bf as s,jg as c,m_ as l,rv as u,sr as d,xf as f}from"./index-DDwwBb9e.js";import{t as p}from"./copy-to-clipboard-CMC1JDMT.js";var m=e(r()),h=i(),g=o`
  0% { background-position-x: 0%; }
  100% { background-position-x: 200%; }
`;function _({command:e,maskedCommand:r,lang:i,showPrompt:o=!1,copyLabel:_=`Command`,animateRainbow:v}){let y=v??o,b=!!r,[x,S]=(0,m.useState)(!b),[C,w]=(0,m.useState)(!1),T=(0,m.useRef)(null),E=(0,m.useRef)(null),[D,O]=(0,m.useState)(!1),k=(0,m.useRef)(null);(0,m.useEffect)(()=>{let t=!1;O(!1);async function n(){let[n,a]=await Promise.all([d({code:e,lang:i}),r?d({code:r,lang:i}):Promise.resolve(null)]);t||(E.current=n,T.current=a,O(!0))}return n(),()=>{t=!0}},[e,r,i]),(0,m.useEffect)(()=>()=>{k.current!==null&&clearTimeout(k.current)},[]);let A=(0,m.useMemo)(()=>D?!b||x?E.current:T.current:null,[D,b,x]);return(0,h.jsxs)(a,{"data-testid":`shiki-command-box`,position:`relative`,width:`full`,borderRadius:`xl`,border:`1px solid`,borderColor:`border.subtle`,bg:`bg.panel/70`,boxShadow:`xs`,overflow:`hidden`,transition:`all 0.17s ease`,_hover:{borderColor:`orange.emphasized`,boxShadow:`md`},children:[(0,h.jsxs)(l,{paddingX:3,paddingY:1.5,borderBottomWidth:`1px`,borderColor:`border.subtle`,bg:`bg.subtle`,children:[(0,h.jsx)(c,{}),b&&(0,h.jsx)(u,{"aria-label":x?`Hide secret values`:`Show secret values`,size:`xs`,variant:`ghost`,onClick:()=>S(e=>!e),children:x?(0,h.jsx)(f,{size:14}):(0,h.jsx)(s,{size:14})}),(0,h.jsx)(u,{"aria-label":`Copy ${_.toLowerCase()}`,"data-state":C?`copied`:`idle`,size:`xs`,variant:`ghost`,colorPalette:C?`green`:`gray`,onClick:()=>{p({text:e,successMessage:`${_} copied to clipboard`}).then(e=>{e&&(w(!0),k.current!==null&&clearTimeout(k.current),k.current=setTimeout(()=>w(!1),1e3))})},children:C?(0,h.jsx)(n,{size:14}):(0,h.jsx)(t,{size:14})})]}),(0,h.jsxs)(l,{align:`start`,paddingX:3,paddingY:2,gap:0,overflow:`hidden`,children:[o&&(0,h.jsx)(a,{as:`span`,"aria-hidden":`true`,flexShrink:0,fontFamily:`mono`,fontSize:`xs`,color:`fg.muted`,lineHeight:`1.6`,paddingRight:2,userSelect:`none`,children:`>_`}),(0,h.jsx)(a,{flex:1,overflowX:`auto`,"data-shiki-box":!0,"data-rainbow":y?`on`:`off`,css:{"& pre":{margin:`0 !important`,padding:`0 !important`,background:`transparent !important`,fontFamily:`'Geist Mono', 'IBM Plex Mono', 'Source Code Pro', Menlo, monospace`,fontSize:`12.5px`,lineHeight:`1.6`,whiteSpace:`pre`,overflowWrap:`normal !important`,wordWrap:`normal !important`,width:`max-content`,minWidth:`100%`},"& code":{fontFamily:`inherit`,fontSize:`inherit`,background:`transparent !important`},...y&&{color:`transparent`,backgroundImage:`linear-gradient(90deg, #0143cb 0%, #2b6ff4 24%, #d23401 47%, #ff651f 66%, #fba000 83%, #0143cb 100%)`,backgroundClip:`text`,WebkitBackgroundClip:`text`,WebkitTextFillColor:`transparent`,backgroundSize:`200% 100%`,animation:`${g} 3s linear infinite`,"& pre, & code, & span":{color:`inherit !important`,WebkitTextFillColor:`inherit`},"@media (prefers-reduced-motion: reduce)":{animation:`none`}}},children:A?(0,h.jsx)(a,{display:`contents`,dangerouslySetInnerHTML:{__html:A}}):(0,h.jsx)(a,{as:`pre`,fontFamily:`mono`,fontSize:`xs`,margin:0,padding:0,color:`fg`,children:b&&!x&&r?r:e})})]})]})}export{_ as ShikiCommandBox};
//# sourceMappingURL=ShikiCommandBox-BFDhHa2x.js.map