import{r as e,j as t,c as o}from"./vendor-react-Co0R0q1H.js";import{q as n,r as s}from"./index-nE6cslhy.js";const a={standard:"w-3 h-3",compact:"w-2.5 h-2.5",responsive:"w-2.5 h-2.5 sm:w-3 sm:h-3"};function r({children:r,copyValue:c,copy:i=!1,size:l="standard",className:p,title:d,color:u,truncate:m}){const[x,h]=e.useState(!1),[y,w]=e.useState(!1),f=e.useRef(null),v=c??("string"==typeof r?r:""),b=a[l],g=(()=>{if(!m||"string"!=typeof r)return r;const e=r,[t,o]=!0===m?[6,4]:m;return e.length<=t+o+3?e:`${e.slice(0,t)}…${e.slice(-o)}`})(),j=e.useCallback(e=>{i&&(e.preventDefault(),e.stopPropagation(),f.current&&clearTimeout(f.current),function(e){var t;if("undefined"!=typeof window&&(window.isSecureContext||"https:"===window.location.protocol||"localhost"===window.location.hostname)&&(null==(t=navigator.clipboard)?void 0:t.writeText))return navigator.clipboard.writeText(e).catch(()=>{}),!0;try{const{scrollX:t,scrollY:o}=window,n=document.createElement("textarea");n.value=e,n.style.cssText="position:fixed;left:-9999px;top:-9999px;opacity:0;pointer-events:none",n.setAttribute("readonly",""),document.body.appendChild(n),n.focus({preventScroll:!0}),n.select(),n.setSelectionRange(0,e.length);const s=document.execCommand("copy");return document.body.removeChild(n),window.scrollTo(t,o),s}catch(o){return!1}}(v),h(!0),f.current=setTimeout(()=>h(!1),2e3))},[i,v]),C="compact"===l?"data-box-compact":"responsive"===l?"data-box-responsive":"",N=i?d||`Click to copy: ${v}`:d;return i?t.jsxs("button",{type:"button",onClick:j,onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),className:o("data-box interactive",C,"cursor-pointer select-none gap-1","hover-bg",u,p),title:N,"aria-label":`Copy ${v}`,children:[t.jsx("span",{className:o("transition-colors duration-200",x?"text-sys-green":""),children:g}),t.jsx("span",{className:o("flex items-center justify-center","compact"===l?"w-3 h-3":"w-3.5 h-3.5"),children:x?t.jsx(n,{className:o("text-sys-green",b)}):t.jsx(s,{className:o("transition-opacity duration-200",y?"opacity-70":"opacity-40",b)})})]}):t.jsx("span",{className:o("data-box",C,u,p),title:N,children:g})}export{r as D};
