import{P as e,S as t,U as n,ct as r,j as i,tt as a}from"./auth-DetOXv90.js";import{G as o,K as s,M as c,N as l,r as u,t as d}from"./light-BN35I8ot.js";function f(e){return{borderRadius:e.borderRadius}}var p={name:`QrCode`,common:d,self:f},m;(function(e){class t{static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,o=40,s=-1,c=!0){if(!(t.MIN_VERSION<=a&&a<=o&&o<=t.MAX_VERSION)||s<-1||s>7)throw RangeError(`Invalid value`);let l,u;for(l=a;;l++){let n=t.getNumDataCodewords(l,r)*8,a=i.getTotalBits(e,l);if(a<=n){u=a;break}if(l>=o)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])c&&u<=t.getNumDataCodewords(l,e)*8&&(r=e);let d=[];for(let t of e){n(t.mode.modeBits,4,d),n(t.numChars,t.mode.numCharCountBits(l),d);for(let e of t.getData())d.push(e)}let f=t.getNumDataCodewords(l,r)*8;n(0,Math.min(4,f-d.length),d),n(0,(8-d.length%8)%8,d);for(let e=236;d.lengthp[t>>>3]|=e<<7-(t&7)),new t(l,r,p,s)}constructor(e,n,r,i){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],et.MAX_VERSION)throw RangeError(`Version value out of range`);if(i<-1||i>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let a=[];for(let e=0;e=0&&e=0&&t>>9)*1335;let i=(t<<10|n)^21522;for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(i,e));this.setFunctionModule(8,7,r(i,6)),this.setFunctionModule(8,8,r(i,7)),this.setFunctionModule(7,8,r(i,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(i,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(i,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(i,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;a>=0&&a=0&&o{(e!==c-a||n>=s)&&d.push(t[e])});return d}drawCodewords(e){if(e.length!==Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t===6&&(t=5);for(let i=0;i>>3],7-(n&7)),n++)}}}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;ne+ +!!t,n);let r=this.size*this.size,i=Math.ceil(Math.abs(n*20-r*10)/r)-1;return e+=i*t.PENALTY_N4,e}getAlignmentPatternPositions(){if(this.version===1)return[];{let e=Math.floor(this.version/7)+2,t=this.version===32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.lengtht.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n}finderPenaltyCountPatterns(e){let t=e[1],n=t>0&&e[2]===t&&e[3]===t*3&&e[4]===t&&e[5]===t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]===0&&(e+=this.size),t.pop(),t.unshift(e)}}t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}class i{static makeBytes(e){let t=[];for(let r of e)n(r,8,t);return new i(i.Mode.BYTE,e.length,t)}static makeNumeric(e){if(!i.isNumeric(e))throw RangeError(`String contains non-numeric characters`);let t=[];for(let r=0;r=1<({"--n-border-radius":s.value.self.borderRadius})),f=o?c(`qr-code`,void 0,d,e):void 0,m=r(),v=t(()=>{let t=_[e.errorCorrectionLevel];return h.QrCode.encodeText(e.value??`-`,t)});n(()=>{let t=r(0),n=null;a(()=>{e.type!==`svg`&&(t.value,b(v.value,e.size,e.color,e.backgroundColor,n?{icon:n,iconBorderRadius:e.iconBorderRadius,iconSize:e.iconSize,iconBackgroundColor:e.iconBackgroundColor}:null))}),a(()=>{if(e.type===`svg`)return;let{iconSrc:r}=e;if(r){let e=!1,i=new Image;return i.src=r,i.onload=()=>{e||(n=i,t.value++)},()=>{e=!0}}})});function b(e,t,n,r,i){let a=m.value;if(!a)return;let o=t*y,s=o/e.size;a.width=o,a.height=o;let c=a.getContext(`2d`);if(c){c.clearRect(0,0,a.width,a.height);for(let t=0;t=1?o:o*u,f=u<=1?o:o/u,p=s+(o-d)/2,m=l+(o-f)/2;c.drawImage(e,p,m,d,f)}}}function x(e,t=0){let n=[];return e.forEach((e,r)=>{let i=null;e.forEach((a,o)=>{if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function S(t,n,r){let i=t.getModules(),a=i.length,o=i,s=``,c=``,l=``,u=``;if(r){let{iconSrc:e,iconSize:t}=r,o=Math.floor(n*.1),s=a/n,c=(t||o)*s,l=(t||o)*s,d=i.length/2-l/2,f=i.length/2-c/2;u+=``}return s+=c,s+=l,s+=u,{innerHtml:s,numCells:a}}let C=t(()=>S(v.value,e.size,e.iconSrc?{iconSrc:e.iconSrc,iconBorderRadius:e.iconBorderRadius,iconSize:e.iconSize,iconBackgroundColor:e.iconBackgroundColor}:null));return{canvasRef:m,mergedClsPrefix:i,cssVars:o?void 0:d,themeClass:f?.themeClass,svgInfo:C}},render(){let{mergedClsPrefix:t,backgroundColor:n,padding:r,cssVars:i,themeClass:a,size:o,type:s}=this;return e(`div`,{class:[`${t}-qr-code`,a],style:Object.assign({padding:typeof r==`number`?`${r}px`:r,backgroundColor:n,width:`${o}px`,height:`${o}px`},i)},s===`canvas`?e(`canvas`,{ref:`canvasRef`,style:{width:`${o}px`,height:`${o}px`}}):e(`svg`,{height:o,width:o,viewBox:`0 0 ${this.svgInfo.numCells} ${this.svgInfo.numCells}`,role:`img`,innerHTML:this.svgInfo.innerHtml}))}});export{b as t};