@privy-io/react-auth
Version:
React client for the Privy Auth API
3 lines (2 loc) • 3.1 kB
JavaScript
import{jsx as e,jsxs as r,Fragment as o}from"react/jsx-runtime";import t from"qrcode";import l from"react";import{styled as i}from"styled-components";import{u as n}from"./context-Bycd1SKV.mjs";import{a2 as c,a3 as a}from"./useActiveWallet-Bsy5GTCV.mjs";const g=()=>/*#__PURE__*/e("svg",{width:"200",height:"200",viewBox:"-77 -77 200 200",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px"},children:/*#__PURE__*/e("rect",{width:"50",height:"50",fill:"black",rx:10,ry:10})});let h=(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},m=(e,r)=>{let o=t.create(e,{errorCorrectionLevel:r}).modules,l=a(Array.from(o.data),o.size);return l=h(l,0,0,7,7),l=h(l,l.length-7,0,7,7),h(l,0,l.length-7,7,7)},d=({x:r,y:t,cellSize:l,bgColor:i,fgColor:n})=>
/*#__PURE__*/e(o,{children:[0,1,2].map((o=>/*#__PURE__*/e("circle",{r:l*(7-2*o)/2,cx:r+7*l/2,cy:t+7*l/2,fill:o%2!=0?i:n},`finder-${r}-${t}-${o}`)))}),s=({cellSize:r,matrixSize:t,bgColor:l,fgColor:i})=>/*#__PURE__*/e(o,{children:[[0,0],[(t-7)*r,0],[0,(t-7)*r]].map((([o,t])=>/*#__PURE__*/e(d,{x:o,y:t,cellSize:r,bgColor:l,fgColor:i},`finder-${o}-${t}`)))}),p=({matrix:r,cellSize:t,color:i})=>/*#__PURE__*/e(o,{children:r.map(((r,o)=>r.map(((r,n)=>r?/*#__PURE__*/e("rect",{height:t-.4,width:t-.4,x:o*t+.1*t,y:n*t+.1*t,rx:.5*t,ry:.5*t,fill:i},`cell-${o}-${n}`):/*#__PURE__*/e(l.Fragment,{},`circle-${o}-${n}`)))))}),f=({cellSize:t,matrixSize:l,element:i,sizePercentage:n,bgColor:c})=>{if(!i)/*#__PURE__*/return e(o,{});let a=l*(n||.14),g=Math.floor(l/2-a/2),h=Math.floor(l/2+a/2);(h-g)%2!=l%2&&(h+=1);let m=(h-g)*t,d=m-.2*m,s=g*t;/*#__PURE__*/return r(o,{children:[/*#__PURE__*/e("rect",{x:g*t,y:g*t,width:m,height:m,fill:c}),/*#__PURE__*/e(i,{x:s+.1*m,y:s+.1*m,height:d,width:d})]})},u=o=>{let t=o.outputSize,l=m(o.url,o.errorCorrectionLevel),i=t/l.length,n=c(2*i,{min:.025*t,max:.036*t});/*#__PURE__*/return r("svg",{height:o.outputSize,width:o.outputSize,viewBox:`0 0 ${o.outputSize} ${o.outputSize}`,style:{height:"100%",width:"100%",padding:`${n}px`},children:[/*#__PURE__*/e(p,{matrix:l,cellSize:i,color:o.fgColor}),/*#__PURE__*/e(s,{cellSize:i,matrixSize:l.length,fgColor:o.fgColor,bgColor:o.bgColor}),/*#__PURE__*/e(f,{cellSize:i,element:o.logo?.element,bgColor:o.bgColor,matrixSize:l.length})]})},C=/*#__PURE__*/i.div.attrs({className:"ph-no-capture"}).withConfig({displayName:"QrContainer",componentId:"sc-597e27f3-0"})(["display:flex;justify-content:center;align-items:center;height:",";width:",";margin:auto;background-color:",";&&{border-width:2px;border-color:",";border-radius:var(--privy-border-radius-md);}"],(e=>`${e.$size}px`),(e=>`${e.$size}px`),(e=>e.$bgColor),(e=>e.$borderColor));const x=r=>{let{appearance:o}=n(),t=r.bgColor||"#FFFFFF",l=r.fgColor||"#000000",i=r.size||160,c="dark"===o.palette.colorScheme?t:l;/*#__PURE__*/return e(C,{$size:i,$bgColor:t,$fgColor:l,$borderColor:c,children:/*#__PURE__*/e(u,{url:r.url,logo:{element:r.squareLogoElement??g},outputSize:i,bgColor:t,fgColor:l,errorCorrectionLevel:r.errorCorrectionLevel||"Q"})})};export{x as Q};