"use strict";var e=require("react/jsx-runtime"),r=require("qrcode"),o=require("react"),t=require("styled-components"),l=require("./context-rs-ygOK2.js"),i=require("./wallet-connect-BuohfvHK.js");function n(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=/*#__PURE__*/n(r),a=/*#__PURE__*/n(o);const g=r=>/*#__PURE__*/e.jsx("svg",{viewBox:"0 0 50 50",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:/*#__PURE__*/e.jsx("rect",{width:"50",height:"50",fill:"black",rx:10,ry:10})});let s=(e,r,o,t,l)=>{for(let i=r;i<r+t;i++)for(let r=o;r<o+l;r++){let o=e?.[r];o&&o[i]&&(o[i]=0)}return e},d=({x:r,y:o,cellSize:t,bgColor:l,fgColor:i})=>
/*#__PURE__*/e.jsx(e.Fragment,{children:[0,1,2].map((n=>/*#__PURE__*/e.jsx("circle",{r:t*(7-2*n)/2,cx:r+7*t/2,cy:o+7*t/2,fill:n%2!=0?l:i},`finder-${r}-${o}-${n}`)))}),x=({cellSize:r,matrixSize:o,bgColor:t,fgColor:l})=>/*#__PURE__*/e.jsx(e.Fragment,{children:[[0,0],[(o-7)*r,0],[0,(o-7)*r]].map((([o,i])=>/*#__PURE__*/e.jsx(d,{x:o,y:i,cellSize:r,bgColor:t,fgColor:l},`finder-${o}-${i}`)))}),u=({matrix:r,cellSize:o,color:t})=>/*#__PURE__*/e.jsx(e.Fragment,{children:r.map(((r,l)=>r.map(((r,i)=>r?/*#__PURE__*/e.jsx("rect",{height:o-.4,width:o-.4,x:l*o+.1*o,y:i*o+.1*o,rx:.5*o,ry:.5*o,fill:t},`cell-${l}-${i}`):/*#__PURE__*/e.jsx(a.default.Fragment,{},`circle-${l}-${i}`)))))}),h=({cellSize:r,matrixSize:o,element:t,sizePercentage:l,bgColor:i})=>{if(!t)/*#__PURE__*/return e.jsx(e.Fragment,{});let n=o*(l||.14),c=Math.floor(o/2-n/2),a=Math.floor(o/2+n/2);(a-c)%2!=o%2&&(a+=1);let g=(a-c)*r,s=g-.2*g,d=c*r;/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx("rect",{x:c*r,y:c*r,width:g,height:g,fill:i}),/*#__PURE__*/e.jsx(t,{x:d+.1*g,y:d+.1*g,height:s,width:s})]})},m=r=>{let o=r.outputSize,t=((e,r)=>{let o=c.default.create(e,{errorCorrectionLevel:r}).modules,t=i.convert1dTo2dArray(Array.from(o.data),o.size);return t=s(t,0,0,7,7),t=s(t,t.length-7,0,7,7),s(t,0,t.length-7,7,7)})(r.url,r.errorCorrectionLevel),l=o/t.length,n=i.clamp(2*l,{min:.025*o,max:.036*o});/*#__PURE__*/return e.jsxs("svg",{height:r.outputSize,width:r.outputSize,viewBox:`0 0 ${r.outputSize} ${r.outputSize}`,style:{height:"100%",width:"100%",padding:`${n}px`},children:[/*#__PURE__*/e.jsx(u,{matrix:t,cellSize:l,color:r.fgColor}),/*#__PURE__*/e.jsx(x,{cellSize:l,matrixSize:t.length,fgColor:r.fgColor,bgColor:r.bgColor}),/*#__PURE__*/e.jsx(h,{cellSize:l,element:r.logo?.element,bgColor:r.bgColor,matrixSize:t.length})]})},f=t.styled.div.attrs({className:"ph-no-capture"})`
  display: flex;
  justify-content: center;
  align-items: center;
  height: ${e=>`${e.$size}px`};
  width: ${e=>`${e.$size}px`};
  margin: auto;
  background-color: ${e=>e.$bgColor};

  && {
    border-width: 2px;
    border-color: ${e=>e.$borderColor};
    border-radius: var(--privy-border-radius-md);
  }
`;exports.QrCode=r=>{let{appearance:o}=l.useAppConfig(),t=r.bgColor||"#FFFFFF",i=r.fgColor||"#000000",n=r.size||160,c="dark"===o.palette.colorScheme?t:i;/*#__PURE__*/return e.jsx(f,{$size:n,$bgColor:t,$fgColor:i,$borderColor:c,children:/*#__PURE__*/e.jsx(m,{url:r.url,logo:r.hideLogo?void 0:{element:r.squareLogoElement??g},outputSize:n,bgColor:t,fgColor:i,errorCorrectionLevel:r.errorCorrectionLevel||"Q"})})};
//# sourceMappingURL=QrCode-ErbyIBDF.js.map
