const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/common-DlXhUo7M.js","assets/index-BFZJiDOW.js","assets/client-DWauEnMw.js","assets/index-Ck6G7Wfb.css"])))=>i.map(i=>d[i]);
import{S as e,l as t,m as n,p as r,t as i}from"./client-DWauEnMw.js";import{t as a}from"./index-BFZJiDOW.js";var o=a(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]);async function s(t,n){let[{default:r},a]=await Promise.all([e(()=>import(`./common-DlXhUo7M.js`),__vite__mapDeps([0,1,2,3])),i().fsRead(t)]),o=await a.text();return{raw:o,html:r.getLanguage(n)===void 0?c(o):r.highlight(o,{language:n,ignoreIllegals:!0}).value}}function c(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`)}function l({file:e,language:i}){let[a,c]=t({status:`loading`}),[l,u]=t(!1);r(()=>{let t=!1;return c({status:`loading`}),s(e.path,i).then(({raw:e,html:n})=>{t||c({status:`ready`,raw:e,html:n})}).catch(e=>{t||c({status:`error`,error:e instanceof Error?e.message:String(e)})}),()=>{t=!0}},[e.path,i]);let d=async()=>{if(a.raw)try{await navigator.clipboard.writeText(a.raw),u(!0),window.setTimeout(()=>u(!1),1400)}catch{}};if(a.status===`loading`)return n(`p`,{style:`color:var(--muted);font-size:13px;padding:16px`,children:`Loading…`});if(a.status===`error`)return n(`p`,{role:`alert`,style:`color:var(--err);font-size:13px;padding:16px`,children:[`Couldn't render code: `,a.error]});let f=(a.raw??``).split(`
`).length,p=Array.from({length:f},(e,t)=>t+1).join(`
`);return n(`div`,{class:`code-preview`,style:`display:flex;flex-direction:column;height:100%;background:var(--paper)`,children:[n(`div`,{style:`display:flex;align-items:center;justify-content:space-between;padding:8px 14px;border-bottom:1px solid var(--rule);background:var(--ice);flex-shrink:0`,children:[n(`span`,{class:`eyebrow`,style:`font-family:var(--f-mono);font-size:11px;letter-spacing:.06em;color:var(--muted);text-transform:uppercase`,children:i}),n(`button`,{type:`button`,onClick:()=>void d(),"aria-label":l?`Copied`:`Copy to clipboard`,title:l?`Copied`:`Copy`,style:`display:inline-flex;align-items:center;gap:6px;padding:4px 10px;background:transparent;border:1px solid var(--rule);border-radius:var(--r-xs);color:var(--graphite);font-family:var(--f-sans);font-size:11.5px;cursor:pointer`,children:[n(o,{size:11,"aria-hidden":`true`}),l?`Copied`:`Copy`]})]}),n(`div`,{style:`flex:1;display:flex;overflow:auto;font-family:var(--f-mono);font-size:12.5px;line-height:1.5`,children:[n(`pre`,{"aria-hidden":`true`,style:`flex-shrink:0;margin:0;padding:14px 10px 14px 14px;color:var(--muted);text-align:right;user-select:none;background:var(--ice);border-right:1px solid var(--rule);white-space:pre`,children:p}),n(`pre`,{class:`hljs`,style:`flex:1;margin:0;padding:14px;color:var(--ink);background:var(--paper);overflow-x:auto;white-space:pre`,children:n(`code`,{dangerouslySetInnerHTML:{__html:a.html??``}})})]})]})}export{l as CodePreview};
//# sourceMappingURL=CodePreview-BoboFjiC.js.map