@thepayulink/checkout 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -337,4 +337,4 @@ var Z=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var fe=Object
|
|
|
337
337
|
</div>
|
|
338
338
|
<div id="pl-status" class="pl-pendrow"><span class="pl-mini-spin"></span> Waiting for payment\u2026</div>`}function J(f,p){if(f==="contact")p.querySelector("#pl-continue").onclick=()=>{let k=p.querySelector("#pl-name").value.trim(),M=p.querySelector("#pl-mobile").value.replace(/\D/g,""),I=p.querySelector("#pl-email").value.trim(),H=p.querySelector("#pl-cerr");if(k.length<2)return H.textContent="Please enter your name";if(M.length!==10)return H.textContent="Enter a valid 10-digit mobile number";r.customer={name:k,mobile:M,email:I},C("options")};else if(f==="options"){p.querySelectorAll(".pl-navitem").forEach(M=>M.onclick=()=>{M.dataset.m!=="upi"&&T("Coming soon \u2014 please pay via UPI / QR for now")});let k=p.querySelector("#pl-verify");k&&(k.onclick=()=>{let M=(p.querySelector("#pl-vpa").value||"").trim();if(!/^[\w.\-]{2,}@[a-zA-Z]{2,}$/.test(M))return p.querySelector("#pl-vpa").focus(),T("Enter a valid UPI ID, e.g. name@okhdfcbank");let I=r.order&&(r.order.upi_intent_url||r.order.payment_link);I&&/Android|iPhone|iPad|Mobile/i.test(navigator.userAgent)?location.href=I:T("Scan the QR with your phone\u2019s UPI app to complete the payment.")}),B(),R(!0)}}let z=!1;async function R(f){if(f||C("options"),r.order){G();return}if(!z){z=!0;try{r.customer||(r.customer={name:o.prefill.name||"Customer",mobile:(o.prefill.contact||"").replace(/\D/g,""),email:o.prefill.email||""}),r.order=await o.createOrder(r.customer),G(),d()}catch(p){let k=t.querySelector("#pl-qr");if(k){k.innerHTML=`<div class="pl-qrerr"><span>${L(p.message||"Could not start payment")}</span><button class="pl-retry" id="pl-retry">Try again</button></div>`;let M=k.querySelector("#pl-retry");M&&(M.onclick=()=>{z=!1,k.innerHTML='<div class="pl-qrloading"></div>',R(!0)})}}finally{z=!1}}}function G(){let f=r.order;if(!f)return;l(f);let p=t.querySelector("#pl-qr");p&&(f.qr_data_url?p.innerHTML=`<img src="${f.qr_data_url}" alt="UPI QR">`:p.innerHTML='<div class="pl-qrerr"><span>QR unavailable \u2014 use a UPI app below</span></div>');let k=f.upi_intent_url||f.payment_link||"#",M=t.querySelector("#pl-applist");M&&M.querySelectorAll(".pl-uapp").forEach(I=>{I.setAttribute("href",k),I.setAttribute("target","_blank"),I.setAttribute("rel","noopener")}),B()}function l(f){f&&f.expires_at&&f.server_now?r.expiryMs=Date.now()+Math.max(0,f.expires_at-f.server_now):r.expiryMs||(r.expiryMs=Date.now()+5*60*1e3)}function u(){if(r.done)return;let f=t.querySelector("#pl-qr");f&&(f.innerHTML='<div class="pl-qrerr"><span>QR code expired</span><button class="pl-retry" id="pl-regen">Generate new QR</button></div>');let p=t.querySelector("#pl-regen");p&&(p.onclick=n);let k=t.querySelector("#pl-timer");k&&(k.textContent="Expired");let M=t.querySelector(".pl-validrow");M&&M.classList.add("pl-expired")}function n(){if(r.stop){try{r.stop()}catch{}r.stop=null}r.order=null,r.expiryMs=null,z=!1;let f=t.querySelector(".pl-validrow");f&&f.classList.remove("pl-expired");let p=t.querySelector("#pl-qr");p&&(p.innerHTML='<div class="pl-qrloading"></div>'),R(!0)}function d(){!r.order||r.stop||(r.stop=o.watchOrder(r.order.merchant_order_no,f=>{!f||typeof f.status!="number"||(f.status===0?(r.utr=f.utr||r.utr,v()):f.status===3?(clearInterval(r.timer),r.expiryMs=Date.now(),u(),s("failed","QR expired \u2014 generate a new one")):[1,4].includes(f.status)?s("failed","Payment "+(f.status_label||"failed").toLowerCase()):f.status===6&&s("pending","Processing payment\u2026"))}))}function s(f,p){let k=t.querySelector("#pl-status");k&&(k.className=f==="failed"?"pl-pendrow pl-fail":"pl-pendrow",k.innerHTML=(f==="pending"?'<span class="pl-mini-spin"></span> ':"")+L(p))}function v(){r.done||(r.done=!0,clearInterval(r.timer),C("success"),o.onSuccess&&o.onSuccess({merchant_order_no:r.order.merchant_order_no,utr:r.utr,amount:o.amount}),r.utr||w())}async function w(){for(let f=0;f<10&&!r.utr;f++){await new Promise(p=>setTimeout(p,4e3));try{let p=await fetch(`${g}/api/order/${r.order.merchant_order_no}`).then(k=>k.json());if(p.utr){r.utr=p.utr;let k=t.querySelector("#pl-pid");k&&r.screen==="success"&&k.insertAdjacentHTML("afterend",`<div class="pl-pid pl-utr">UTR ${L(p.utr)}</div>`);break}}catch{}}}function B(){clearInterval(r.timer);let f=()=>{let p=t.querySelector("#pl-timer");if(!p)return;if(!r.expiryMs){p.textContent="Valid 5:00";return}let k=Math.max(0,Math.round((r.expiryMs-Date.now())/1e3));p.textContent=k>0?"Valid "+me(k):"Expired",k<=0&&(clearInterval(r.timer),u())};f(),r.timer=setInterval(f,1e3)}function T(f){let p=document.getElementById("pl-toast");p||(p=document.createElement("div"),p.id="pl-toast",document.body.appendChild(p)),p.textContent=f,p.classList.add("pl-show"),clearTimeout(p._t),p._t=setTimeout(()=>p.classList.remove("pl-show"),2600)}return C("loader"),setTimeout(()=>{let f=o.prefill||{};f.name&&(f.contact||"").replace(/\D/g,"").length===10?(r.customer={name:f.name,mobile:f.contact.replace(/\D/g,""),email:f.email||""},C("options")):C("contact");let p=t.querySelector("#pl-splash");p&&(p.classList.add("pl-splash-hide"),setTimeout(()=>p.remove(),450))},1600),{close:y}}var Q=function(o,g){let a=o,r=F[g],t=null,e=0,h=null,m=[],b={},x=function(l,u){e=a*4+17,t=function(n){let d=new Array(n);for(let s=0;s<n;s+=1){d[s]=new Array(n);for(let v=0;v<n;v+=1)d[s][v]=null}return d}(e),y(0,0),y(e-7,0),y(0,e-7),A(),C(),E(l,u),a>=7&&P(l),h==null&&(h=z(a,r,m)),S(h,u)},y=function(l,u){for(let n=-1;n<=7;n+=1)if(!(l+n<=-1||e<=l+n))for(let d=-1;d<=7;d+=1)u+d<=-1||e<=u+d||(0<=n&&n<=6&&(d==0||d==6)||0<=d&&d<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=d&&d<=4?t[l+n][u+d]=!0:t[l+n][u+d]=!1)},_=function(){let l=0,u=0;for(let n=0;n<8;n+=1){x(!0,n);let d=N.getLostPoint(b);(n==0||l>d)&&(l=d,u=n)}return u},C=function(){for(let l=8;l<e-8;l+=1)t[l][6]==null&&(t[l][6]=l%2==0);for(let l=8;l<e-8;l+=1)t[6][l]==null&&(t[6][l]=l%2==0)},A=function(){let l=N.getPatternPosition(a);for(let u=0;u<l.length;u+=1)for(let n=0;n<l.length;n+=1){let d=l[u],s=l[n];if(t[d][s]==null)for(let v=-2;v<=2;v+=1)for(let w=-2;w<=2;w+=1)v==-2||v==2||w==-2||w==2||v==0&&w==0?t[d+v][s+w]=!0:t[d+v][s+w]=!1}},P=function(l){let u=N.getBCHTypeNumber(a);for(let n=0;n<18;n+=1){let d=!l&&(u>>n&1)==1;t[Math.floor(n/3)][n%3+e-8-3]=d}for(let n=0;n<18;n+=1){let d=!l&&(u>>n&1)==1;t[n%3+e-8-3][Math.floor(n/3)]=d}},E=function(l,u){let n=r<<3|u,d=N.getBCHTypeInfo(n);for(let s=0;s<15;s+=1){let v=!l&&(d>>s&1)==1;s<6?t[s][8]=v:s<8?t[s+1][8]=v:t[e-15+s][8]=v}for(let s=0;s<15;s+=1){let v=!l&&(d>>s&1)==1;s<8?t[8][e-s-1]=v:s<9?t[8][15-s-1+1]=v:t[8][15-s-1]=v}t[e-8][8]=!l},S=function(l,u){let n=-1,d=e-1,s=7,v=0,w=N.getMaskFunction(u);for(let B=e-1;B>0;B-=2)for(B==6&&(B-=1);;){for(let T=0;T<2;T+=1)if(t[d][B-T]==null){let f=!1;v<l.length&&(f=(l[v]>>>s&1)==1),w(d,B-T)&&(f=!f),t[d][B-T]=f,s-=1,s==-1&&(v+=1,s=7)}if(d+=n,d<0||e<=d){d-=n,n=-n;break}}},J=function(l,u){let n=0,d=0,s=0,v=new Array(u.length),w=new Array(u.length);for(let p=0;p<u.length;p+=1){let k=u[p].dataCount,M=u[p].totalCount-k;d=Math.max(d,k),s=Math.max(s,M),v[p]=new Array(k);for(let $=0;$<v[p].length;$+=1)v[p][$]=255&l.getBuffer()[$+n];n+=k;let I=N.getErrorCorrectPolynomial(M),K=V(v[p],I.getLength()-1).mod(I);w[p]=new Array(I.getLength()-1);for(let $=0;$<w[p].length;$+=1){let X=$+K.getLength()-w[p].length;w[p][$]=X>=0?K.getAt(X):0}}let B=0;for(let p=0;p<u.length;p+=1)B+=u[p].totalCount;let T=new Array(B),f=0;for(let p=0;p<d;p+=1)for(let k=0;k<u.length;k+=1)p<v[k].length&&(T[f]=v[k][p],f+=1);for(let p=0;p<s;p+=1)for(let k=0;k<u.length;k+=1)p<w[k].length&&(T[f]=w[k][p],f+=1);return T},z=function(l,u,n){let d=ne.getRSBlocks(l,u),s=oe();for(let w=0;w<n.length;w+=1){let B=n[w];s.put(B.getMode(),4),s.put(B.getLength(),N.getLengthInBits(B.getMode(),l)),B.write(s)}let v=0;for(let w=0;w<d.length;w+=1)v+=d[w].dataCount;if(s.getLengthInBits()>v*8)throw"code length overflow. ("+s.getLengthInBits()+">"+v*8+")";for(s.getLengthInBits()+4<=v*8&&s.put(0,4);s.getLengthInBits()%8!=0;)s.putBit(!1);for(;!(s.getLengthInBits()>=v*8||(s.put(236,8),s.getLengthInBits()>=v*8));)s.put(17,8);return J(s,d)};b.addData=function(l,u){u=u||"Byte";let n=null;switch(u){case"Numeric":n=we(l);break;case"Alphanumeric":n=ke(l);break;case"Byte":n=_e(l);break;case"Kanji":n=Me(l);break;default:throw"mode:"+u}m.push(n),h=null},b.isDark=function(l,u){if(l<0||e<=l||u<0||e<=u)throw l+","+u;return t[l][u]},b.getModuleCount=function(){return e},b.make=function(){if(a<1){let l=1;for(;l<40;l++){let u=ne.getRSBlocks(l,r),n=oe();for(let s=0;s<m.length;s++){let v=m[s];n.put(v.getMode(),4),n.put(v.getLength(),N.getLengthInBits(v.getMode(),l)),v.write(n)}let d=0;for(let s=0;s<u.length;s++)d+=u[s].dataCount;if(n.getLengthInBits()<=d*8)break}a=l}x(!1,_())},b.createTableTag=function(l,u){l=l||2,u=typeof u=="undefined"?l*4:u;let n="";n+='<table style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: "+u+"px;",n+='">',n+="<tbody>";for(let d=0;d<b.getModuleCount();d+=1){n+="<tr>";for(let s=0;s<b.getModuleCount();s+=1)n+='<td style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: 0px;",n+=" width: "+l+"px;",n+=" height: "+l+"px;",n+=" background-color: ",n+=b.isDark(d,s)?"#000000":"#ffffff",n+=";",n+='"/>';n+="</tr>"}return n+="</tbody>",n+="</table>",n},b.createSvgTag=function(l,u,n,d){let s={};typeof arguments[0]=="object"&&(s=arguments[0],l=s.cellSize,u=s.margin,n=s.alt,d=s.title),l=l||2,u=typeof u=="undefined"?l*4:u,n=typeof n=="string"?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||"qrcode-description":null,d=typeof d=="string"?{text:d}:d||{},d.text=d.text||null,d.id=d.text?d.id||"qrcode-title":null;let v=b.getModuleCount()*l+u*2,w,B,T,f,p="",k;for(k="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=s.scalable?"":' width="'+v+'px" height="'+v+'px"',p+=' viewBox="0 0 '+v+" "+v+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=d.text||n.text?' role="img" aria-labelledby="'+R([d.id,n.id].join(" ").trim())+'"':"",p+=">",p+=d.text?'<title id="'+R(d.id)+'">'+R(d.text)+"</title>":"",p+=n.text?'<description id="'+R(n.id)+'">'+R(n.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<path d="',T=0;T<b.getModuleCount();T+=1)for(f=T*l+u,w=0;w<b.getModuleCount();w+=1)b.isDark(T,w)&&(B=w*l+u,p+="M"+B+","+f+k);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},b.createDataURL=function(l,u){l=l||2,u=typeof u=="undefined"?l*4:u;let n=b.getModuleCount()*l+u*2,d=u,s=n-u;return Te(n,n,function(v,w){if(d<=v&&v<s&&d<=w&&w<s){let B=Math.floor((v-d)/l),T=Math.floor((w-d)/l);return b.isDark(T,B)?0:1}else return 1})},b.createImgTag=function(l,u,n){l=l||2,u=typeof u=="undefined"?l*4:u;let d=b.getModuleCount()*l+u*2,s="";return s+="<img",s+=' src="',s+=b.createDataURL(l,u),s+='"',s+=' width="',s+=d,s+='"',s+=' height="',s+=d,s+='"',n&&(s+=' alt="',s+=R(n),s+='"'),s+="/>",s};let R=function(l){let u="";for(let n=0;n<l.length;n+=1){let d=l.charAt(n);switch(d){case"<":u+="<";break;case">":u+=">";break;case"&":u+="&";break;case'"':u+=""";break;default:u+=d;break}}return u},G=function(l){l=typeof l=="undefined"?1*2:l;let n=b.getModuleCount()*1+l*2,d=l,s=n-l,v,w,B,T,f,p={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},k={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},M="";for(v=0;v<n;v+=2){for(B=Math.floor((v-d)/1),T=Math.floor((v+1-d)/1),w=0;w<n;w+=1)f="\u2588",d<=w&&w<s&&d<=v&&v<s&&b.isDark(B,Math.floor((w-d)/1))&&(f=" "),d<=w&&w<s&&d<=v+1&&v+1<s&&b.isDark(T,Math.floor((w-d)/1))?f+=" ":f+="\u2588",M+=l<1&&v+1>=s?k[f]:p[f];M+=`
|
|
339
339
|
`}return n%2&&l>0?M.substring(0,M.length-n-1)+Array(n+1).join("\u2580"):M.substring(0,M.length-1)};return b.createASCII=function(l,u){if(l=l||1,l<2)return G(u);l-=1,u=typeof u=="undefined"?l*2:u;let n=b.getModuleCount()*l+u*2,d=u,s=n-u,v,w,B,T,f=Array(l+1).join("\u2588\u2588"),p=Array(l+1).join(" "),k="",M="";for(v=0;v<n;v+=1){for(B=Math.floor((v-d)/l),M="",w=0;w<n;w+=1)T=1,d<=w&&w<s&&d<=v&&v<s&&b.isDark(B,Math.floor((w-d)/l))&&(T=0),M+=T?f:p;for(B=0;B<l;B+=1)k+=M+`
|
|
340
|
-
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,u){u=u||2;let n=b.getModuleCount();for(let d=0;d<n;d++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(d,s)?"black":"white",l.fillRect(s*u,d*u,u,u)},b};Q.stringToBytes=function(o){let g=[];for(let c=0;c<o.length;c+=1){let i=o.charCodeAt(c);g.push(i&255)}return g};Q.createStringToBytes=function(o,g){let c=function(){let a=Be(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),y=String.fromCharCode(h<<8|m),_=b<<8|x;e[y]=_,t+=1}if(t!=g)throw t+" != "+g;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=c[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},F={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],g=1335,c=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(g)>=0;)e^=g<<r(e)-r(g);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(c)>=0;)e^=c<<r(e)-r(c);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=V([1],0);for(let h=0;h<t;h+=1)e=e.multiply(V([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1){let _=0,C=t.isDark(x,y);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)y+P<0||e<=y+P||A==0&&P==0||C==t.isDark(x+A,y+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let y=0;y<e-1;y+=1){let _=0;t.isDark(x,y)&&(_+=1),t.isDark(x+1,y)&&(_+=1),t.isDark(x,y+1)&&(_+=1),t.isDark(x+1,y+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(x,y)&&!t.isDark(x,y+1)&&t.isDark(x,y+2)&&t.isDark(x,y+3)&&t.isDark(x,y+4)&&!t.isDark(x,y+5)&&t.isDark(x,y+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(y,x)&&!t.isDark(y+1,x)&&t.isDark(y+2,x)&&t.isDark(y+3,x)&&t.isDark(y+4,x)&&!t.isDark(y+5,x)&&t.isDark(y+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1)t.isDark(y,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),g=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)g[o[i]]=i;let c={};return c.glog=function(i){if(i<1)throw"glog("+i+")";return g[i]},c.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},c}(),V=function(o,g){if(typeof o.length=="undefined")throw o.length+"/"+g;let c=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+g);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return c[a]},i.getLength=function(){return c.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return V(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return V(t,0).mod(a)},i},ne=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],g=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},c={},i=function(a,r){switch(r){case F.L:return o[(a-1)*4+0];case F.M:return o[(a-1)*4+1];case F.Q:return o[(a-1)*4+2];case F.H:return o[(a-1)*4+3];default:return}};return c.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],y=t[m*3+2];for(let _=0;_<b;_+=1)h.push(g(x,y))}return h},c}(),oe=function(){let o=[],g=0,c={};return c.getBuffer=function(){return o},c.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},c.put=function(i,a){for(let r=0;r<a;r+=1)c.putBit((i>>>a-r-1&1)==1)},c.getLengthInBits=function(){return g},c.putBit=function(i){let a=Math.floor(g/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>g%8),g+=1},c},we=function(o){let g=D.MODE_NUMBER,c=o,i={};i.getMode=function(){return g},i.getLength=function(t){return c.length},i.write=function(t){let e=c,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ke=function(o){let g=D.MODE_ALPHA_NUM,c=o,i={};i.getMode=function(){return g},i.getLength=function(r){return c.length},i.write=function(r){let t=c,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},_e=function(o){let g=D.MODE_8BIT_BYTE,c=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return g},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},Me=function(o){let g=D.MODE_KANJI,c=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return g},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},le=function(){let o=[],g={};return g.writeByte=function(c){o.push(c&255)},g.writeShort=function(c){g.writeByte(c),g.writeByte(c>>>8)},g.writeBytes=function(c,i,a){i=i||0,a=a||c.length;for(let r=0;r<a;r+=1)g.writeByte(c[r+i])},g.writeString=function(c){for(let i=0;i<c.length;i+=1)g.writeByte(c.charCodeAt(i))},g.toByteArray=function(){return o},g.toString=function(){let c="";c+="[";for(let i=0;i<o.length;i+=1)i>0&&(c+=","),c+=o[i];return c+="]",c},g},Ce=function(){let o=0,g=0,c=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,g+=8,c+=1;g>=6;)r(o>>>g-6),g-=6},a.flush=function(){if(g>0&&(r(o<<6-g),o=0,g=0),c%3!=0){let e=3-c%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},Be=function(o){let g=o,c=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(c>=g.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=g.charAt(c);if(c+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},Ae=function(o,g){let c=o,i=g,a=new Array(o*g),r={};r.setPixel=function(m,b,x){a[b*c+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(c),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(c),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let y=0;for(;x.length-y>255;)m.writeByte(255),m.writeBytes(x,y,255),y+=255;m.writeByte(x.length-y),m.writeBytes(x,y,x.length-y),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,y=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|y)),A-=8-x,C>>>=8-x,y=0,x=0;y=C<<x|y,x=x+A},_.flush=function(){x>0&&b.writeByte(y)},_},e=function(m){let b=1<<m,x=(1<<m)+1,y=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=le(),A=t(C);A.write(b,y);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),y),_.size()<4095&&(_.size()==1<<y&&(y+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),y),A.write(x,y),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(y){if(x.contains(y))throw"dup key:"+y;m[y]=b,b+=1},x.size=function(){return b},x.indexOf=function(y){return m[y]},x.contains=function(y){return typeof m[y]!="undefined"},x};return r},Te=function(o,g,c){let i=Ae(o,g);for(let e=0;e<g;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,c(h,e));let a=le();i.write(a);let r=Ce(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},ie=Q,$e=Q.stringToBytes;var ae={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function Ee(o){if(!o)return null;try{let g=ie(0,"M");return g.addData(String(o)),g.make(),g.createDataURL(6,2)}catch{return null}}var Y=class o{constructor(g={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let c=g.key||g.keyId||g.key_id;if(!c)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(c)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),g.keySecret||g.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ae,g,{key:c})}open(g={}){let c=Object.assign({},this.options,g),i=String(c.apiBase||"").replace(/\/$/,""),a=String(c.assetBase||`${i}/assets`).replace(/\/$/,""),r=c.order_id||c.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=y=>{typeof c.onError=="function"?c.onError(y):console.error("PayuLink:",y.message||y)},e=null,h=null,m=async y=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:c.key,order_id:r,customer:y?{name:y.name,contact:y.mobile||y.contact,email:y.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:Ee(C.upi_intent_url),expires_at:C.expires_at,server_now:Math.floor(Date.now()/1e3)}},b=(y,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,c.pollMs||ae.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var y;(y=this._inner)==null||y.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(c.key)}`).then(async y=>{var C;let _=await y.json().catch(()=>({}));if(!y.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=re(Object.assign({},{apiBase:i,assetBase:a,name:c.name||_.merchant_name,logo:c.logo||`${a}/payulink-logo.png`,brandColor:c.brandColor,note:c.note,prefill:c.prefill||{},amount:_.amount/100,description:c.description||c.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof c.handler=="function"&&c.handler(A),typeof c.onSuccess=="function"&&c.onSuccess(A)},onDismiss:()=>{typeof c.onDismiss=="function"&&c.onDismiss()},onError:t}))}).catch(t),x}static open(g={}){return new o(g).open(g)}};typeof window!="undefined"&&(window.PayuLink=Y,window.PayulinkCheckout=Y);
|
|
340
|
+
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,u){u=u||2;let n=b.getModuleCount();for(let d=0;d<n;d++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(d,s)?"black":"white",l.fillRect(s*u,d*u,u,u)},b};Q.stringToBytes=function(o){let g=[];for(let c=0;c<o.length;c+=1){let i=o.charCodeAt(c);g.push(i&255)}return g};Q.createStringToBytes=function(o,g){let c=function(){let a=Be(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),y=String.fromCharCode(h<<8|m),_=b<<8|x;e[y]=_,t+=1}if(t!=g)throw t+" != "+g;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=c[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},F={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],g=1335,c=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(g)>=0;)e^=g<<r(e)-r(g);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(c)>=0;)e^=c<<r(e)-r(c);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=V([1],0);for(let h=0;h<t;h+=1)e=e.multiply(V([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1){let _=0,C=t.isDark(x,y);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)y+P<0||e<=y+P||A==0&&P==0||C==t.isDark(x+A,y+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let y=0;y<e-1;y+=1){let _=0;t.isDark(x,y)&&(_+=1),t.isDark(x+1,y)&&(_+=1),t.isDark(x,y+1)&&(_+=1),t.isDark(x+1,y+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(x,y)&&!t.isDark(x,y+1)&&t.isDark(x,y+2)&&t.isDark(x,y+3)&&t.isDark(x,y+4)&&!t.isDark(x,y+5)&&t.isDark(x,y+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(y,x)&&!t.isDark(y+1,x)&&t.isDark(y+2,x)&&t.isDark(y+3,x)&&t.isDark(y+4,x)&&!t.isDark(y+5,x)&&t.isDark(y+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1)t.isDark(y,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),g=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)g[o[i]]=i;let c={};return c.glog=function(i){if(i<1)throw"glog("+i+")";return g[i]},c.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},c}(),V=function(o,g){if(typeof o.length=="undefined")throw o.length+"/"+g;let c=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+g);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return c[a]},i.getLength=function(){return c.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return V(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return V(t,0).mod(a)},i},ne=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],g=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},c={},i=function(a,r){switch(r){case F.L:return o[(a-1)*4+0];case F.M:return o[(a-1)*4+1];case F.Q:return o[(a-1)*4+2];case F.H:return o[(a-1)*4+3];default:return}};return c.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],y=t[m*3+2];for(let _=0;_<b;_+=1)h.push(g(x,y))}return h},c}(),oe=function(){let o=[],g=0,c={};return c.getBuffer=function(){return o},c.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},c.put=function(i,a){for(let r=0;r<a;r+=1)c.putBit((i>>>a-r-1&1)==1)},c.getLengthInBits=function(){return g},c.putBit=function(i){let a=Math.floor(g/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>g%8),g+=1},c},we=function(o){let g=D.MODE_NUMBER,c=o,i={};i.getMode=function(){return g},i.getLength=function(t){return c.length},i.write=function(t){let e=c,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ke=function(o){let g=D.MODE_ALPHA_NUM,c=o,i={};i.getMode=function(){return g},i.getLength=function(r){return c.length},i.write=function(r){let t=c,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},_e=function(o){let g=D.MODE_8BIT_BYTE,c=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return g},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},Me=function(o){let g=D.MODE_KANJI,c=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return g},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},le=function(){let o=[],g={};return g.writeByte=function(c){o.push(c&255)},g.writeShort=function(c){g.writeByte(c),g.writeByte(c>>>8)},g.writeBytes=function(c,i,a){i=i||0,a=a||c.length;for(let r=0;r<a;r+=1)g.writeByte(c[r+i])},g.writeString=function(c){for(let i=0;i<c.length;i+=1)g.writeByte(c.charCodeAt(i))},g.toByteArray=function(){return o},g.toString=function(){let c="";c+="[";for(let i=0;i<o.length;i+=1)i>0&&(c+=","),c+=o[i];return c+="]",c},g},Ce=function(){let o=0,g=0,c=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,g+=8,c+=1;g>=6;)r(o>>>g-6),g-=6},a.flush=function(){if(g>0&&(r(o<<6-g),o=0,g=0),c%3!=0){let e=3-c%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},Be=function(o){let g=o,c=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(c>=g.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=g.charAt(c);if(c+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},Ae=function(o,g){let c=o,i=g,a=new Array(o*g),r={};r.setPixel=function(m,b,x){a[b*c+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(c),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(c),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let y=0;for(;x.length-y>255;)m.writeByte(255),m.writeBytes(x,y,255),y+=255;m.writeByte(x.length-y),m.writeBytes(x,y,x.length-y),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,y=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|y)),A-=8-x,C>>>=8-x,y=0,x=0;y=C<<x|y,x=x+A},_.flush=function(){x>0&&b.writeByte(y)},_},e=function(m){let b=1<<m,x=(1<<m)+1,y=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=le(),A=t(C);A.write(b,y);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),y),_.size()<4095&&(_.size()==1<<y&&(y+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),y),A.write(x,y),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(y){if(x.contains(y))throw"dup key:"+y;m[y]=b,b+=1},x.size=function(){return b},x.indexOf=function(y){return m[y]},x.contains=function(y){return typeof m[y]!="undefined"},x};return r},Te=function(o,g,c){let i=Ae(o,g);for(let e=0;e<g;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,c(h,e));let a=le();i.write(a);let r=Ce(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},ie=Q,$e=Q.stringToBytes;var ae={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function Ee(o){if(!o)return null;try{let g=ie(0,"M");return g.addData(String(o)),g.make(),g.createDataURL(6,2)}catch{return null}}var Y=class o{constructor(g={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let c=g.key||g.keyId||g.key_id;if(!c)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(c)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),g.keySecret||g.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ae,g,{key:c})}open(g={}){let c=Object.assign({},this.options,g),i=String(c.apiBase||"").replace(/\/$/,""),a=String(c.assetBase||`${i}/assets`).replace(/\/$/,""),r=c.order_id||c.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=y=>{typeof c.onError=="function"?c.onError(y):console.error("PayuLink:",y.message||y)},e=null,h=null,m=async y=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:c.key,order_id:r,customer:y?{name:y.name,contact:y.mobile||y.contact,email:y.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:Ee(C.upi_intent_url),expires_at:C.expires_at?C.expires_at*1e3:null,server_now:Date.now()}},b=(y,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,c.pollMs||ae.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var y;(y=this._inner)==null||y.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(c.key)}`).then(async y=>{var C;let _=await y.json().catch(()=>({}));if(!y.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=re(Object.assign({},{apiBase:i,assetBase:a,name:c.name||_.merchant_name,logo:c.logo||`${a}/payulink-logo.png`,brandColor:c.brandColor,note:c.note,prefill:c.prefill||{},amount:_.amount/100,description:c.description||c.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof c.handler=="function"&&c.handler(A),typeof c.onSuccess=="function"&&c.onSuccess(A)},onDismiss:()=>{typeof c.onDismiss=="function"&&c.onDismiss()},onError:t}))}).catch(t),x}static open(g={}){return new o(g).open(g)}};typeof window!="undefined"&&(window.PayuLink=Y,window.PayulinkCheckout=Y);
|
|
@@ -337,4 +337,4 @@ var ce=`
|
|
|
337
337
|
</div>
|
|
338
338
|
<div id="pl-status" class="pl-pendrow"><span class="pl-mini-spin"></span> Waiting for payment\u2026</div>`}function J(d,p){if(d==="contact")p.querySelector("#pl-continue").onclick=()=>{let k=p.querySelector("#pl-name").value.trim(),M=p.querySelector("#pl-mobile").value.replace(/\D/g,""),I=p.querySelector("#pl-email").value.trim(),H=p.querySelector("#pl-cerr");if(k.length<2)return H.textContent="Please enter your name";if(M.length!==10)return H.textContent="Enter a valid 10-digit mobile number";r.customer={name:k,mobile:M,email:I},C("options")};else if(d==="options"){p.querySelectorAll(".pl-navitem").forEach(M=>M.onclick=()=>{M.dataset.m!=="upi"&&T("Coming soon \u2014 please pay via UPI / QR for now")});let k=p.querySelector("#pl-verify");k&&(k.onclick=()=>{let M=(p.querySelector("#pl-vpa").value||"").trim();if(!/^[\w.\-]{2,}@[a-zA-Z]{2,}$/.test(M))return p.querySelector("#pl-vpa").focus(),T("Enter a valid UPI ID, e.g. name@okhdfcbank");let I=r.order&&(r.order.upi_intent_url||r.order.payment_link);I&&/Android|iPhone|iPad|Mobile/i.test(navigator.userAgent)?location.href=I:T("Scan the QR with your phone\u2019s UPI app to complete the payment.")}),B(),R(!0)}}let z=!1;async function R(d){if(d||C("options"),r.order){G();return}if(!z){z=!0;try{r.customer||(r.customer={name:o.prefill.name||"Customer",mobile:(o.prefill.contact||"").replace(/\D/g,""),email:o.prefill.email||""}),r.order=await o.createOrder(r.customer),G(),c()}catch(p){let k=t.querySelector("#pl-qr");if(k){k.innerHTML=`<div class="pl-qrerr"><span>${L(p.message||"Could not start payment")}</span><button class="pl-retry" id="pl-retry">Try again</button></div>`;let M=k.querySelector("#pl-retry");M&&(M.onclick=()=>{z=!1,k.innerHTML='<div class="pl-qrloading"></div>',R(!0)})}}finally{z=!1}}}function G(){let d=r.order;if(!d)return;l(d);let p=t.querySelector("#pl-qr");p&&(d.qr_data_url?p.innerHTML=`<img src="${d.qr_data_url}" alt="UPI QR">`:p.innerHTML='<div class="pl-qrerr"><span>QR unavailable \u2014 use a UPI app below</span></div>');let k=d.upi_intent_url||d.payment_link||"#",M=t.querySelector("#pl-applist");M&&M.querySelectorAll(".pl-uapp").forEach(I=>{I.setAttribute("href",k),I.setAttribute("target","_blank"),I.setAttribute("rel","noopener")}),B()}function l(d){d&&d.expires_at&&d.server_now?r.expiryMs=Date.now()+Math.max(0,d.expires_at-d.server_now):r.expiryMs||(r.expiryMs=Date.now()+5*60*1e3)}function f(){if(r.done)return;let d=t.querySelector("#pl-qr");d&&(d.innerHTML='<div class="pl-qrerr"><span>QR code expired</span><button class="pl-retry" id="pl-regen">Generate new QR</button></div>');let p=t.querySelector("#pl-regen");p&&(p.onclick=n);let k=t.querySelector("#pl-timer");k&&(k.textContent="Expired");let M=t.querySelector(".pl-validrow");M&&M.classList.add("pl-expired")}function n(){if(r.stop){try{r.stop()}catch{}r.stop=null}r.order=null,r.expiryMs=null,z=!1;let d=t.querySelector(".pl-validrow");d&&d.classList.remove("pl-expired");let p=t.querySelector("#pl-qr");p&&(p.innerHTML='<div class="pl-qrloading"></div>'),R(!0)}function c(){!r.order||r.stop||(r.stop=o.watchOrder(r.order.merchant_order_no,d=>{!d||typeof d.status!="number"||(d.status===0?(r.utr=d.utr||r.utr,v()):d.status===3?(clearInterval(r.timer),r.expiryMs=Date.now(),f(),s("failed","QR expired \u2014 generate a new one")):[1,4].includes(d.status)?s("failed","Payment "+(d.status_label||"failed").toLowerCase()):d.status===6&&s("pending","Processing payment\u2026"))}))}function s(d,p){let k=t.querySelector("#pl-status");k&&(k.className=d==="failed"?"pl-pendrow pl-fail":"pl-pendrow",k.innerHTML=(d==="pending"?'<span class="pl-mini-spin"></span> ':"")+L(p))}function v(){r.done||(r.done=!0,clearInterval(r.timer),C("success"),o.onSuccess&&o.onSuccess({merchant_order_no:r.order.merchant_order_no,utr:r.utr,amount:o.amount}),r.utr||w())}async function w(){for(let d=0;d<10&&!r.utr;d++){await new Promise(p=>setTimeout(p,4e3));try{let p=await fetch(`${y}/api/order/${r.order.merchant_order_no}`).then(k=>k.json());if(p.utr){r.utr=p.utr;let k=t.querySelector("#pl-pid");k&&r.screen==="success"&&k.insertAdjacentHTML("afterend",`<div class="pl-pid pl-utr">UTR ${L(p.utr)}</div>`);break}}catch{}}}function B(){clearInterval(r.timer);let d=()=>{let p=t.querySelector("#pl-timer");if(!p)return;if(!r.expiryMs){p.textContent="Valid 5:00";return}let k=Math.max(0,Math.round((r.expiryMs-Date.now())/1e3));p.textContent=k>0?"Valid "+fe(k):"Expired",k<=0&&(clearInterval(r.timer),f())};d(),r.timer=setInterval(d,1e3)}function T(d){let p=document.getElementById("pl-toast");p||(p=document.createElement("div"),p.id="pl-toast",document.body.appendChild(p)),p.textContent=d,p.classList.add("pl-show"),clearTimeout(p._t),p._t=setTimeout(()=>p.classList.remove("pl-show"),2600)}return C("loader"),setTimeout(()=>{let d=o.prefill||{};d.name&&(d.contact||"").replace(/\D/g,"").length===10?(r.customer={name:d.name,mobile:d.contact.replace(/\D/g,""),email:d.email||""},C("options")):C("contact");let p=t.querySelector("#pl-splash");p&&(p.classList.add("pl-splash-hide"),setTimeout(()=>p.remove(),450))},1600),{close:g}}var Q=function(o,y){let a=o,r=Y[y],t=null,e=0,h=null,m=[],b={},x=function(l,f){e=a*4+17,t=function(n){let c=new Array(n);for(let s=0;s<n;s+=1){c[s]=new Array(n);for(let v=0;v<n;v+=1)c[s][v]=null}return c}(e),g(0,0),g(e-7,0),g(0,e-7),A(),C(),E(l,f),a>=7&&P(l),h==null&&(h=z(a,r,m)),S(h,f)},g=function(l,f){for(let n=-1;n<=7;n+=1)if(!(l+n<=-1||e<=l+n))for(let c=-1;c<=7;c+=1)f+c<=-1||e<=f+c||(0<=n&&n<=6&&(c==0||c==6)||0<=c&&c<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=c&&c<=4?t[l+n][f+c]=!0:t[l+n][f+c]=!1)},_=function(){let l=0,f=0;for(let n=0;n<8;n+=1){x(!0,n);let c=N.getLostPoint(b);(n==0||l>c)&&(l=c,f=n)}return f},C=function(){for(let l=8;l<e-8;l+=1)t[l][6]==null&&(t[l][6]=l%2==0);for(let l=8;l<e-8;l+=1)t[6][l]==null&&(t[6][l]=l%2==0)},A=function(){let l=N.getPatternPosition(a);for(let f=0;f<l.length;f+=1)for(let n=0;n<l.length;n+=1){let c=l[f],s=l[n];if(t[c][s]==null)for(let v=-2;v<=2;v+=1)for(let w=-2;w<=2;w+=1)v==-2||v==2||w==-2||w==2||v==0&&w==0?t[c+v][s+w]=!0:t[c+v][s+w]=!1}},P=function(l){let f=N.getBCHTypeNumber(a);for(let n=0;n<18;n+=1){let c=!l&&(f>>n&1)==1;t[Math.floor(n/3)][n%3+e-8-3]=c}for(let n=0;n<18;n+=1){let c=!l&&(f>>n&1)==1;t[n%3+e-8-3][Math.floor(n/3)]=c}},E=function(l,f){let n=r<<3|f,c=N.getBCHTypeInfo(n);for(let s=0;s<15;s+=1){let v=!l&&(c>>s&1)==1;s<6?t[s][8]=v:s<8?t[s+1][8]=v:t[e-15+s][8]=v}for(let s=0;s<15;s+=1){let v=!l&&(c>>s&1)==1;s<8?t[8][e-s-1]=v:s<9?t[8][15-s-1+1]=v:t[8][15-s-1]=v}t[e-8][8]=!l},S=function(l,f){let n=-1,c=e-1,s=7,v=0,w=N.getMaskFunction(f);for(let B=e-1;B>0;B-=2)for(B==6&&(B-=1);;){for(let T=0;T<2;T+=1)if(t[c][B-T]==null){let d=!1;v<l.length&&(d=(l[v]>>>s&1)==1),w(c,B-T)&&(d=!d),t[c][B-T]=d,s-=1,s==-1&&(v+=1,s=7)}if(c+=n,c<0||e<=c){c-=n,n=-n;break}}},J=function(l,f){let n=0,c=0,s=0,v=new Array(f.length),w=new Array(f.length);for(let p=0;p<f.length;p+=1){let k=f[p].dataCount,M=f[p].totalCount-k;c=Math.max(c,k),s=Math.max(s,M),v[p]=new Array(k);for(let $=0;$<v[p].length;$+=1)v[p][$]=255&l.getBuffer()[$+n];n+=k;let I=N.getErrorCorrectPolynomial(M),K=F(v[p],I.getLength()-1).mod(I);w[p]=new Array(I.getLength()-1);for(let $=0;$<w[p].length;$+=1){let X=$+K.getLength()-w[p].length;w[p][$]=X>=0?K.getAt(X):0}}let B=0;for(let p=0;p<f.length;p+=1)B+=f[p].totalCount;let T=new Array(B),d=0;for(let p=0;p<c;p+=1)for(let k=0;k<f.length;k+=1)p<v[k].length&&(T[d]=v[k][p],d+=1);for(let p=0;p<s;p+=1)for(let k=0;k<f.length;k+=1)p<w[k].length&&(T[d]=w[k][p],d+=1);return T},z=function(l,f,n){let c=re.getRSBlocks(l,f),s=ne();for(let w=0;w<n.length;w+=1){let B=n[w];s.put(B.getMode(),4),s.put(B.getLength(),N.getLengthInBits(B.getMode(),l)),B.write(s)}let v=0;for(let w=0;w<c.length;w+=1)v+=c[w].dataCount;if(s.getLengthInBits()>v*8)throw"code length overflow. ("+s.getLengthInBits()+">"+v*8+")";for(s.getLengthInBits()+4<=v*8&&s.put(0,4);s.getLengthInBits()%8!=0;)s.putBit(!1);for(;!(s.getLengthInBits()>=v*8||(s.put(236,8),s.getLengthInBits()>=v*8));)s.put(17,8);return J(s,c)};b.addData=function(l,f){f=f||"Byte";let n=null;switch(f){case"Numeric":n=he(l);break;case"Alphanumeric":n=ge(l);break;case"Byte":n=ye(l);break;case"Kanji":n=xe(l);break;default:throw"mode:"+f}m.push(n),h=null},b.isDark=function(l,f){if(l<0||e<=l||f<0||e<=f)throw l+","+f;return t[l][f]},b.getModuleCount=function(){return e},b.make=function(){if(a<1){let l=1;for(;l<40;l++){let f=re.getRSBlocks(l,r),n=ne();for(let s=0;s<m.length;s++){let v=m[s];n.put(v.getMode(),4),n.put(v.getLength(),N.getLengthInBits(v.getMode(),l)),v.write(n)}let c=0;for(let s=0;s<f.length;s++)c+=f[s].dataCount;if(n.getLengthInBits()<=c*8)break}a=l}x(!1,_())},b.createTableTag=function(l,f){l=l||2,f=typeof f=="undefined"?l*4:f;let n="";n+='<table style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: "+f+"px;",n+='">',n+="<tbody>";for(let c=0;c<b.getModuleCount();c+=1){n+="<tr>";for(let s=0;s<b.getModuleCount();s+=1)n+='<td style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: 0px;",n+=" width: "+l+"px;",n+=" height: "+l+"px;",n+=" background-color: ",n+=b.isDark(c,s)?"#000000":"#ffffff",n+=";",n+='"/>';n+="</tr>"}return n+="</tbody>",n+="</table>",n},b.createSvgTag=function(l,f,n,c){let s={};typeof arguments[0]=="object"&&(s=arguments[0],l=s.cellSize,f=s.margin,n=s.alt,c=s.title),l=l||2,f=typeof f=="undefined"?l*4:f,n=typeof n=="string"?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||"qrcode-description":null,c=typeof c=="string"?{text:c}:c||{},c.text=c.text||null,c.id=c.text?c.id||"qrcode-title":null;let v=b.getModuleCount()*l+f*2,w,B,T,d,p="",k;for(k="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=s.scalable?"":' width="'+v+'px" height="'+v+'px"',p+=' viewBox="0 0 '+v+" "+v+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=c.text||n.text?' role="img" aria-labelledby="'+R([c.id,n.id].join(" ").trim())+'"':"",p+=">",p+=c.text?'<title id="'+R(c.id)+'">'+R(c.text)+"</title>":"",p+=n.text?'<description id="'+R(n.id)+'">'+R(n.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<path d="',T=0;T<b.getModuleCount();T+=1)for(d=T*l+f,w=0;w<b.getModuleCount();w+=1)b.isDark(T,w)&&(B=w*l+f,p+="M"+B+","+d+k);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},b.createDataURL=function(l,f){l=l||2,f=typeof f=="undefined"?l*4:f;let n=b.getModuleCount()*l+f*2,c=f,s=n-f;return we(n,n,function(v,w){if(c<=v&&v<s&&c<=w&&w<s){let B=Math.floor((v-c)/l),T=Math.floor((w-c)/l);return b.isDark(T,B)?0:1}else return 1})},b.createImgTag=function(l,f,n){l=l||2,f=typeof f=="undefined"?l*4:f;let c=b.getModuleCount()*l+f*2,s="";return s+="<img",s+=' src="',s+=b.createDataURL(l,f),s+='"',s+=' width="',s+=c,s+='"',s+=' height="',s+=c,s+='"',n&&(s+=' alt="',s+=R(n),s+='"'),s+="/>",s};let R=function(l){let f="";for(let n=0;n<l.length;n+=1){let c=l.charAt(n);switch(c){case"<":f+="<";break;case">":f+=">";break;case"&":f+="&";break;case'"':f+=""";break;default:f+=c;break}}return f},G=function(l){l=typeof l=="undefined"?1*2:l;let n=b.getModuleCount()*1+l*2,c=l,s=n-l,v,w,B,T,d,p={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},k={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},M="";for(v=0;v<n;v+=2){for(B=Math.floor((v-c)/1),T=Math.floor((v+1-c)/1),w=0;w<n;w+=1)d="\u2588",c<=w&&w<s&&c<=v&&v<s&&b.isDark(B,Math.floor((w-c)/1))&&(d=" "),c<=w&&w<s&&c<=v+1&&v+1<s&&b.isDark(T,Math.floor((w-c)/1))?d+=" ":d+="\u2588",M+=l<1&&v+1>=s?k[d]:p[d];M+=`
|
|
339
339
|
`}return n%2&&l>0?M.substring(0,M.length-n-1)+Array(n+1).join("\u2580"):M.substring(0,M.length-1)};return b.createASCII=function(l,f){if(l=l||1,l<2)return G(f);l-=1,f=typeof f=="undefined"?l*2:f;let n=b.getModuleCount()*l+f*2,c=f,s=n-f,v,w,B,T,d=Array(l+1).join("\u2588\u2588"),p=Array(l+1).join(" "),k="",M="";for(v=0;v<n;v+=1){for(B=Math.floor((v-c)/l),M="",w=0;w<n;w+=1)T=1,c<=w&&w<s&&c<=v&&v<s&&b.isDark(B,Math.floor((w-c)/l))&&(T=0),M+=T?d:p;for(B=0;B<l;B+=1)k+=M+`
|
|
340
|
-
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,f){f=f||2;let n=b.getModuleCount();for(let c=0;c<n;c++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(c,s)?"black":"white",l.fillRect(s*f,c*f,f,f)},b};Q.stringToBytes=function(o){let y=[];for(let u=0;u<o.length;u+=1){let i=o.charCodeAt(u);y.push(i&255)}return y};Q.createStringToBytes=function(o,y){let u=function(){let a=me(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),g=String.fromCharCode(h<<8|m),_=b<<8|x;e[g]=_,t+=1}if(t!=y)throw t+" != "+y;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=u[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Y={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],y=1335,u=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(y)>=0;)e^=y<<r(e)-r(y);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(u)>=0;)e^=u<<r(e)-r(u);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=F([1],0);for(let h=0;h<t;h+=1)e=e.multiply(F([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let g=0;g<e;g+=1){let _=0,C=t.isDark(x,g);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)g+P<0||e<=g+P||A==0&&P==0||C==t.isDark(x+A,g+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let g=0;g<e-1;g+=1){let _=0;t.isDark(x,g)&&(_+=1),t.isDark(x+1,g)&&(_+=1),t.isDark(x,g+1)&&(_+=1),t.isDark(x+1,g+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let g=0;g<e-6;g+=1)t.isDark(x,g)&&!t.isDark(x,g+1)&&t.isDark(x,g+2)&&t.isDark(x,g+3)&&t.isDark(x,g+4)&&!t.isDark(x,g+5)&&t.isDark(x,g+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let g=0;g<e-6;g+=1)t.isDark(g,x)&&!t.isDark(g+1,x)&&t.isDark(g+2,x)&&t.isDark(g+3,x)&&t.isDark(g+4,x)&&!t.isDark(g+5,x)&&t.isDark(g+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let g=0;g<e;g+=1)t.isDark(g,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),y=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)y[o[i]]=i;let u={};return u.glog=function(i){if(i<1)throw"glog("+i+")";return y[i]},u.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},u}(),F=function(o,y){if(typeof o.length=="undefined")throw o.length+"/"+y;let u=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+y);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return u[a]},i.getLength=function(){return u.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return F(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return F(t,0).mod(a)},i},re=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],y=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},u={},i=function(a,r){switch(r){case Y.L:return o[(a-1)*4+0];case Y.M:return o[(a-1)*4+1];case Y.Q:return o[(a-1)*4+2];case Y.H:return o[(a-1)*4+3];default:return}};return u.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],g=t[m*3+2];for(let _=0;_<b;_+=1)h.push(y(x,g))}return h},u}(),ne=function(){let o=[],y=0,u={};return u.getBuffer=function(){return o},u.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},u.put=function(i,a){for(let r=0;r<a;r+=1)u.putBit((i>>>a-r-1&1)==1)},u.getLengthInBits=function(){return y},u.putBit=function(i){let a=Math.floor(y/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>y%8),y+=1},u},he=function(o){let y=D.MODE_NUMBER,u=o,i={};i.getMode=function(){return y},i.getLength=function(t){return u.length},i.write=function(t){let e=u,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ge=function(o){let y=D.MODE_ALPHA_NUM,u=o,i={};i.getMode=function(){return y},i.getLength=function(r){return u.length},i.write=function(r){let t=u,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},ye=function(o){let y=D.MODE_8BIT_BYTE,u=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return y},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},xe=function(o){let y=D.MODE_KANJI,u=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return y},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},oe=function(){let o=[],y={};return y.writeByte=function(u){o.push(u&255)},y.writeShort=function(u){y.writeByte(u),y.writeByte(u>>>8)},y.writeBytes=function(u,i,a){i=i||0,a=a||u.length;for(let r=0;r<a;r+=1)y.writeByte(u[r+i])},y.writeString=function(u){for(let i=0;i<u.length;i+=1)y.writeByte(u.charCodeAt(i))},y.toByteArray=function(){return o},y.toString=function(){let u="";u+="[";for(let i=0;i<o.length;i+=1)i>0&&(u+=","),u+=o[i];return u+="]",u},y},ve=function(){let o=0,y=0,u=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,y+=8,u+=1;y>=6;)r(o>>>y-6),y-=6},a.flush=function(){if(y>0&&(r(o<<6-y),o=0,y=0),u%3!=0){let e=3-u%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},me=function(o){let y=o,u=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(u>=y.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=y.charAt(u);if(u+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},be=function(o,y){let u=o,i=y,a=new Array(o*y),r={};r.setPixel=function(m,b,x){a[b*u+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(u),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(u),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let g=0;for(;x.length-g>255;)m.writeByte(255),m.writeBytes(x,g,255),g+=255;m.writeByte(x.length-g),m.writeBytes(x,g,x.length-g),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,g=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|g)),A-=8-x,C>>>=8-x,g=0,x=0;g=C<<x|g,x=x+A},_.flush=function(){x>0&&b.writeByte(g)},_},e=function(m){let b=1<<m,x=(1<<m)+1,g=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=oe(),A=t(C);A.write(b,g);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),g),_.size()<4095&&(_.size()==1<<g&&(g+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),g),A.write(x,g),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(g){if(x.contains(g))throw"dup key:"+g;m[g]=b,b+=1},x.size=function(){return b},x.indexOf=function(g){return m[g]},x.contains=function(g){return typeof m[g]!="undefined"},x};return r},we=function(o,y,u){let i=be(o,y);for(let e=0;e<y;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,u(h,e));let a=oe();i.write(a);let r=ve(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},le=Q,Be=Q.stringToBytes;var ie={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function ke(o){if(!o)return null;try{let y=le(0,"M");return y.addData(String(o)),y.make(),y.createDataURL(6,2)}catch{return null}}var V=class o{constructor(y={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let u=y.key||y.keyId||y.key_id;if(!u)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(u)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),y.keySecret||y.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ie,y,{key:u})}open(y={}){let u=Object.assign({},this.options,y),i=String(u.apiBase||"").replace(/\/$/,""),a=String(u.assetBase||`${i}/assets`).replace(/\/$/,""),r=u.order_id||u.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=g=>{typeof u.onError=="function"?u.onError(g):console.error("PayuLink:",g.message||g)},e=null,h=null,m=async g=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:u.key,order_id:r,customer:g?{name:g.name,contact:g.mobile||g.contact,email:g.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:ke(C.upi_intent_url),expires_at:C.expires_at,server_now:Math.floor(Date.now()/1e3)}},b=(g,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,u.pollMs||ie.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var g;(g=this._inner)==null||g.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(u.key)}`).then(async g=>{var C;let _=await g.json().catch(()=>({}));if(!g.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=te(Object.assign({},{apiBase:i,assetBase:a,name:u.name||_.merchant_name,logo:u.logo||`${a}/payulink-logo.png`,brandColor:u.brandColor,note:u.note,prefill:u.prefill||{},amount:_.amount/100,description:u.description||u.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof u.handler=="function"&&u.handler(A),typeof u.onSuccess=="function"&&u.onSuccess(A)},onDismiss:()=>{typeof u.onDismiss=="function"&&u.onDismiss()},onError:t}))}).catch(t),x}static open(y={}){return new o(y).open(y)}};typeof window!="undefined"&&(window.PayuLink=V,window.PayulinkCheckout=V);export{V as default};
|
|
340
|
+
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,f){f=f||2;let n=b.getModuleCount();for(let c=0;c<n;c++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(c,s)?"black":"white",l.fillRect(s*f,c*f,f,f)},b};Q.stringToBytes=function(o){let y=[];for(let u=0;u<o.length;u+=1){let i=o.charCodeAt(u);y.push(i&255)}return y};Q.createStringToBytes=function(o,y){let u=function(){let a=me(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),g=String.fromCharCode(h<<8|m),_=b<<8|x;e[g]=_,t+=1}if(t!=y)throw t+" != "+y;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=u[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},Y={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],y=1335,u=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(y)>=0;)e^=y<<r(e)-r(y);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(u)>=0;)e^=u<<r(e)-r(u);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=F([1],0);for(let h=0;h<t;h+=1)e=e.multiply(F([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let g=0;g<e;g+=1){let _=0,C=t.isDark(x,g);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)g+P<0||e<=g+P||A==0&&P==0||C==t.isDark(x+A,g+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let g=0;g<e-1;g+=1){let _=0;t.isDark(x,g)&&(_+=1),t.isDark(x+1,g)&&(_+=1),t.isDark(x,g+1)&&(_+=1),t.isDark(x+1,g+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let g=0;g<e-6;g+=1)t.isDark(x,g)&&!t.isDark(x,g+1)&&t.isDark(x,g+2)&&t.isDark(x,g+3)&&t.isDark(x,g+4)&&!t.isDark(x,g+5)&&t.isDark(x,g+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let g=0;g<e-6;g+=1)t.isDark(g,x)&&!t.isDark(g+1,x)&&t.isDark(g+2,x)&&t.isDark(g+3,x)&&t.isDark(g+4,x)&&!t.isDark(g+5,x)&&t.isDark(g+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let g=0;g<e;g+=1)t.isDark(g,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),y=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)y[o[i]]=i;let u={};return u.glog=function(i){if(i<1)throw"glog("+i+")";return y[i]},u.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},u}(),F=function(o,y){if(typeof o.length=="undefined")throw o.length+"/"+y;let u=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+y);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return u[a]},i.getLength=function(){return u.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return F(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return F(t,0).mod(a)},i},re=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],y=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},u={},i=function(a,r){switch(r){case Y.L:return o[(a-1)*4+0];case Y.M:return o[(a-1)*4+1];case Y.Q:return o[(a-1)*4+2];case Y.H:return o[(a-1)*4+3];default:return}};return u.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],g=t[m*3+2];for(let _=0;_<b;_+=1)h.push(y(x,g))}return h},u}(),ne=function(){let o=[],y=0,u={};return u.getBuffer=function(){return o},u.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},u.put=function(i,a){for(let r=0;r<a;r+=1)u.putBit((i>>>a-r-1&1)==1)},u.getLengthInBits=function(){return y},u.putBit=function(i){let a=Math.floor(y/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>y%8),y+=1},u},he=function(o){let y=D.MODE_NUMBER,u=o,i={};i.getMode=function(){return y},i.getLength=function(t){return u.length},i.write=function(t){let e=u,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ge=function(o){let y=D.MODE_ALPHA_NUM,u=o,i={};i.getMode=function(){return y},i.getLength=function(r){return u.length},i.write=function(r){let t=u,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},ye=function(o){let y=D.MODE_8BIT_BYTE,u=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return y},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},xe=function(o){let y=D.MODE_KANJI,u=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return y},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},oe=function(){let o=[],y={};return y.writeByte=function(u){o.push(u&255)},y.writeShort=function(u){y.writeByte(u),y.writeByte(u>>>8)},y.writeBytes=function(u,i,a){i=i||0,a=a||u.length;for(let r=0;r<a;r+=1)y.writeByte(u[r+i])},y.writeString=function(u){for(let i=0;i<u.length;i+=1)y.writeByte(u.charCodeAt(i))},y.toByteArray=function(){return o},y.toString=function(){let u="";u+="[";for(let i=0;i<o.length;i+=1)i>0&&(u+=","),u+=o[i];return u+="]",u},y},ve=function(){let o=0,y=0,u=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,y+=8,u+=1;y>=6;)r(o>>>y-6),y-=6},a.flush=function(){if(y>0&&(r(o<<6-y),o=0,y=0),u%3!=0){let e=3-u%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},me=function(o){let y=o,u=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(u>=y.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=y.charAt(u);if(u+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},be=function(o,y){let u=o,i=y,a=new Array(o*y),r={};r.setPixel=function(m,b,x){a[b*u+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(u),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(u),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let g=0;for(;x.length-g>255;)m.writeByte(255),m.writeBytes(x,g,255),g+=255;m.writeByte(x.length-g),m.writeBytes(x,g,x.length-g),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,g=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|g)),A-=8-x,C>>>=8-x,g=0,x=0;g=C<<x|g,x=x+A},_.flush=function(){x>0&&b.writeByte(g)},_},e=function(m){let b=1<<m,x=(1<<m)+1,g=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=oe(),A=t(C);A.write(b,g);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),g),_.size()<4095&&(_.size()==1<<g&&(g+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),g),A.write(x,g),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(g){if(x.contains(g))throw"dup key:"+g;m[g]=b,b+=1},x.size=function(){return b},x.indexOf=function(g){return m[g]},x.contains=function(g){return typeof m[g]!="undefined"},x};return r},we=function(o,y,u){let i=be(o,y);for(let e=0;e<y;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,u(h,e));let a=oe();i.write(a);let r=ve(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},le=Q,Be=Q.stringToBytes;var ie={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function ke(o){if(!o)return null;try{let y=le(0,"M");return y.addData(String(o)),y.make(),y.createDataURL(6,2)}catch{return null}}var V=class o{constructor(y={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let u=y.key||y.keyId||y.key_id;if(!u)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(u)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),y.keySecret||y.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ie,y,{key:u})}open(y={}){let u=Object.assign({},this.options,y),i=String(u.apiBase||"").replace(/\/$/,""),a=String(u.assetBase||`${i}/assets`).replace(/\/$/,""),r=u.order_id||u.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=g=>{typeof u.onError=="function"?u.onError(g):console.error("PayuLink:",g.message||g)},e=null,h=null,m=async g=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:u.key,order_id:r,customer:g?{name:g.name,contact:g.mobile||g.contact,email:g.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:ke(C.upi_intent_url),expires_at:C.expires_at?C.expires_at*1e3:null,server_now:Date.now()}},b=(g,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,u.pollMs||ie.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var g;(g=this._inner)==null||g.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(u.key)}`).then(async g=>{var C;let _=await g.json().catch(()=>({}));if(!g.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=te(Object.assign({},{apiBase:i,assetBase:a,name:u.name||_.merchant_name,logo:u.logo||`${a}/payulink-logo.png`,brandColor:u.brandColor,note:u.note,prefill:u.prefill||{},amount:_.amount/100,description:u.description||u.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof u.handler=="function"&&u.handler(A),typeof u.onSuccess=="function"&&u.onSuccess(A)},onDismiss:()=>{typeof u.onDismiss=="function"&&u.onDismiss()},onError:t}))}).catch(t),x}static open(y={}){return new o(y).open(y)}};typeof window!="undefined"&&(window.PayuLink=V,window.PayulinkCheckout=V);export{V as default};
|
|
@@ -337,5 +337,5 @@ var PayulinkCheckoutNS=(()=>{var Z=Object.defineProperty;var de=Object.getOwnPro
|
|
|
337
337
|
</div>
|
|
338
338
|
<div id="pl-status" class="pl-pendrow"><span class="pl-mini-spin"></span> Waiting for payment\u2026</div>`}function J(f,p){if(f==="contact")p.querySelector("#pl-continue").onclick=()=>{let k=p.querySelector("#pl-name").value.trim(),M=p.querySelector("#pl-mobile").value.replace(/\D/g,""),I=p.querySelector("#pl-email").value.trim(),H=p.querySelector("#pl-cerr");if(k.length<2)return H.textContent="Please enter your name";if(M.length!==10)return H.textContent="Enter a valid 10-digit mobile number";r.customer={name:k,mobile:M,email:I},C("options")};else if(f==="options"){p.querySelectorAll(".pl-navitem").forEach(M=>M.onclick=()=>{M.dataset.m!=="upi"&&T("Coming soon \u2014 please pay via UPI / QR for now")});let k=p.querySelector("#pl-verify");k&&(k.onclick=()=>{let M=(p.querySelector("#pl-vpa").value||"").trim();if(!/^[\w.\-]{2,}@[a-zA-Z]{2,}$/.test(M))return p.querySelector("#pl-vpa").focus(),T("Enter a valid UPI ID, e.g. name@okhdfcbank");let I=r.order&&(r.order.upi_intent_url||r.order.payment_link);I&&/Android|iPhone|iPad|Mobile/i.test(navigator.userAgent)?location.href=I:T("Scan the QR with your phone\u2019s UPI app to complete the payment.")}),B(),R(!0)}}let z=!1;async function R(f){if(f||C("options"),r.order){G();return}if(!z){z=!0;try{r.customer||(r.customer={name:o.prefill.name||"Customer",mobile:(o.prefill.contact||"").replace(/\D/g,""),email:o.prefill.email||""}),r.order=await o.createOrder(r.customer),G(),d()}catch(p){let k=t.querySelector("#pl-qr");if(k){k.innerHTML=`<div class="pl-qrerr"><span>${L(p.message||"Could not start payment")}</span><button class="pl-retry" id="pl-retry">Try again</button></div>`;let M=k.querySelector("#pl-retry");M&&(M.onclick=()=>{z=!1,k.innerHTML='<div class="pl-qrloading"></div>',R(!0)})}}finally{z=!1}}}function G(){let f=r.order;if(!f)return;l(f);let p=t.querySelector("#pl-qr");p&&(f.qr_data_url?p.innerHTML=`<img src="${f.qr_data_url}" alt="UPI QR">`:p.innerHTML='<div class="pl-qrerr"><span>QR unavailable \u2014 use a UPI app below</span></div>');let k=f.upi_intent_url||f.payment_link||"#",M=t.querySelector("#pl-applist");M&&M.querySelectorAll(".pl-uapp").forEach(I=>{I.setAttribute("href",k),I.setAttribute("target","_blank"),I.setAttribute("rel","noopener")}),B()}function l(f){f&&f.expires_at&&f.server_now?r.expiryMs=Date.now()+Math.max(0,f.expires_at-f.server_now):r.expiryMs||(r.expiryMs=Date.now()+5*60*1e3)}function u(){if(r.done)return;let f=t.querySelector("#pl-qr");f&&(f.innerHTML='<div class="pl-qrerr"><span>QR code expired</span><button class="pl-retry" id="pl-regen">Generate new QR</button></div>');let p=t.querySelector("#pl-regen");p&&(p.onclick=n);let k=t.querySelector("#pl-timer");k&&(k.textContent="Expired");let M=t.querySelector(".pl-validrow");M&&M.classList.add("pl-expired")}function n(){if(r.stop){try{r.stop()}catch{}r.stop=null}r.order=null,r.expiryMs=null,z=!1;let f=t.querySelector(".pl-validrow");f&&f.classList.remove("pl-expired");let p=t.querySelector("#pl-qr");p&&(p.innerHTML='<div class="pl-qrloading"></div>'),R(!0)}function d(){!r.order||r.stop||(r.stop=o.watchOrder(r.order.merchant_order_no,f=>{!f||typeof f.status!="number"||(f.status===0?(r.utr=f.utr||r.utr,v()):f.status===3?(clearInterval(r.timer),r.expiryMs=Date.now(),u(),s("failed","QR expired \u2014 generate a new one")):[1,4].includes(f.status)?s("failed","Payment "+(f.status_label||"failed").toLowerCase()):f.status===6&&s("pending","Processing payment\u2026"))}))}function s(f,p){let k=t.querySelector("#pl-status");k&&(k.className=f==="failed"?"pl-pendrow pl-fail":"pl-pendrow",k.innerHTML=(f==="pending"?'<span class="pl-mini-spin"></span> ':"")+L(p))}function v(){r.done||(r.done=!0,clearInterval(r.timer),C("success"),o.onSuccess&&o.onSuccess({merchant_order_no:r.order.merchant_order_no,utr:r.utr,amount:o.amount}),r.utr||w())}async function w(){for(let f=0;f<10&&!r.utr;f++){await new Promise(p=>setTimeout(p,4e3));try{let p=await fetch(`${g}/api/order/${r.order.merchant_order_no}`).then(k=>k.json());if(p.utr){r.utr=p.utr;let k=t.querySelector("#pl-pid");k&&r.screen==="success"&&k.insertAdjacentHTML("afterend",`<div class="pl-pid pl-utr">UTR ${L(p.utr)}</div>`);break}}catch{}}}function B(){clearInterval(r.timer);let f=()=>{let p=t.querySelector("#pl-timer");if(!p)return;if(!r.expiryMs){p.textContent="Valid 5:00";return}let k=Math.max(0,Math.round((r.expiryMs-Date.now())/1e3));p.textContent=k>0?"Valid "+me(k):"Expired",k<=0&&(clearInterval(r.timer),u())};f(),r.timer=setInterval(f,1e3)}function T(f){let p=document.getElementById("pl-toast");p||(p=document.createElement("div"),p.id="pl-toast",document.body.appendChild(p)),p.textContent=f,p.classList.add("pl-show"),clearTimeout(p._t),p._t=setTimeout(()=>p.classList.remove("pl-show"),2600)}return C("loader"),setTimeout(()=>{let f=o.prefill||{};f.name&&(f.contact||"").replace(/\D/g,"").length===10?(r.customer={name:f.name,mobile:f.contact.replace(/\D/g,""),email:f.email||""},C("options")):C("contact");let p=t.querySelector("#pl-splash");p&&(p.classList.add("pl-splash-hide"),setTimeout(()=>p.remove(),450))},1600),{close:y}}var Q=function(o,g){let a=o,r=F[g],t=null,e=0,h=null,m=[],b={},x=function(l,u){e=a*4+17,t=function(n){let d=new Array(n);for(let s=0;s<n;s+=1){d[s]=new Array(n);for(let v=0;v<n;v+=1)d[s][v]=null}return d}(e),y(0,0),y(e-7,0),y(0,e-7),A(),C(),E(l,u),a>=7&&P(l),h==null&&(h=z(a,r,m)),S(h,u)},y=function(l,u){for(let n=-1;n<=7;n+=1)if(!(l+n<=-1||e<=l+n))for(let d=-1;d<=7;d+=1)u+d<=-1||e<=u+d||(0<=n&&n<=6&&(d==0||d==6)||0<=d&&d<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=d&&d<=4?t[l+n][u+d]=!0:t[l+n][u+d]=!1)},_=function(){let l=0,u=0;for(let n=0;n<8;n+=1){x(!0,n);let d=N.getLostPoint(b);(n==0||l>d)&&(l=d,u=n)}return u},C=function(){for(let l=8;l<e-8;l+=1)t[l][6]==null&&(t[l][6]=l%2==0);for(let l=8;l<e-8;l+=1)t[6][l]==null&&(t[6][l]=l%2==0)},A=function(){let l=N.getPatternPosition(a);for(let u=0;u<l.length;u+=1)for(let n=0;n<l.length;n+=1){let d=l[u],s=l[n];if(t[d][s]==null)for(let v=-2;v<=2;v+=1)for(let w=-2;w<=2;w+=1)v==-2||v==2||w==-2||w==2||v==0&&w==0?t[d+v][s+w]=!0:t[d+v][s+w]=!1}},P=function(l){let u=N.getBCHTypeNumber(a);for(let n=0;n<18;n+=1){let d=!l&&(u>>n&1)==1;t[Math.floor(n/3)][n%3+e-8-3]=d}for(let n=0;n<18;n+=1){let d=!l&&(u>>n&1)==1;t[n%3+e-8-3][Math.floor(n/3)]=d}},E=function(l,u){let n=r<<3|u,d=N.getBCHTypeInfo(n);for(let s=0;s<15;s+=1){let v=!l&&(d>>s&1)==1;s<6?t[s][8]=v:s<8?t[s+1][8]=v:t[e-15+s][8]=v}for(let s=0;s<15;s+=1){let v=!l&&(d>>s&1)==1;s<8?t[8][e-s-1]=v:s<9?t[8][15-s-1+1]=v:t[8][15-s-1]=v}t[e-8][8]=!l},S=function(l,u){let n=-1,d=e-1,s=7,v=0,w=N.getMaskFunction(u);for(let B=e-1;B>0;B-=2)for(B==6&&(B-=1);;){for(let T=0;T<2;T+=1)if(t[d][B-T]==null){let f=!1;v<l.length&&(f=(l[v]>>>s&1)==1),w(d,B-T)&&(f=!f),t[d][B-T]=f,s-=1,s==-1&&(v+=1,s=7)}if(d+=n,d<0||e<=d){d-=n,n=-n;break}}},J=function(l,u){let n=0,d=0,s=0,v=new Array(u.length),w=new Array(u.length);for(let p=0;p<u.length;p+=1){let k=u[p].dataCount,M=u[p].totalCount-k;d=Math.max(d,k),s=Math.max(s,M),v[p]=new Array(k);for(let $=0;$<v[p].length;$+=1)v[p][$]=255&l.getBuffer()[$+n];n+=k;let I=N.getErrorCorrectPolynomial(M),K=V(v[p],I.getLength()-1).mod(I);w[p]=new Array(I.getLength()-1);for(let $=0;$<w[p].length;$+=1){let X=$+K.getLength()-w[p].length;w[p][$]=X>=0?K.getAt(X):0}}let B=0;for(let p=0;p<u.length;p+=1)B+=u[p].totalCount;let T=new Array(B),f=0;for(let p=0;p<d;p+=1)for(let k=0;k<u.length;k+=1)p<v[k].length&&(T[f]=v[k][p],f+=1);for(let p=0;p<s;p+=1)for(let k=0;k<u.length;k+=1)p<w[k].length&&(T[f]=w[k][p],f+=1);return T},z=function(l,u,n){let d=ne.getRSBlocks(l,u),s=oe();for(let w=0;w<n.length;w+=1){let B=n[w];s.put(B.getMode(),4),s.put(B.getLength(),N.getLengthInBits(B.getMode(),l)),B.write(s)}let v=0;for(let w=0;w<d.length;w+=1)v+=d[w].dataCount;if(s.getLengthInBits()>v*8)throw"code length overflow. ("+s.getLengthInBits()+">"+v*8+")";for(s.getLengthInBits()+4<=v*8&&s.put(0,4);s.getLengthInBits()%8!=0;)s.putBit(!1);for(;!(s.getLengthInBits()>=v*8||(s.put(236,8),s.getLengthInBits()>=v*8));)s.put(17,8);return J(s,d)};b.addData=function(l,u){u=u||"Byte";let n=null;switch(u){case"Numeric":n=we(l);break;case"Alphanumeric":n=ke(l);break;case"Byte":n=_e(l);break;case"Kanji":n=Me(l);break;default:throw"mode:"+u}m.push(n),h=null},b.isDark=function(l,u){if(l<0||e<=l||u<0||e<=u)throw l+","+u;return t[l][u]},b.getModuleCount=function(){return e},b.make=function(){if(a<1){let l=1;for(;l<40;l++){let u=ne.getRSBlocks(l,r),n=oe();for(let s=0;s<m.length;s++){let v=m[s];n.put(v.getMode(),4),n.put(v.getLength(),N.getLengthInBits(v.getMode(),l)),v.write(n)}let d=0;for(let s=0;s<u.length;s++)d+=u[s].dataCount;if(n.getLengthInBits()<=d*8)break}a=l}x(!1,_())},b.createTableTag=function(l,u){l=l||2,u=typeof u=="undefined"?l*4:u;let n="";n+='<table style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: "+u+"px;",n+='">',n+="<tbody>";for(let d=0;d<b.getModuleCount();d+=1){n+="<tr>";for(let s=0;s<b.getModuleCount();s+=1)n+='<td style="',n+=" border-width: 0px; border-style: none;",n+=" border-collapse: collapse;",n+=" padding: 0px; margin: 0px;",n+=" width: "+l+"px;",n+=" height: "+l+"px;",n+=" background-color: ",n+=b.isDark(d,s)?"#000000":"#ffffff",n+=";",n+='"/>';n+="</tr>"}return n+="</tbody>",n+="</table>",n},b.createSvgTag=function(l,u,n,d){let s={};typeof arguments[0]=="object"&&(s=arguments[0],l=s.cellSize,u=s.margin,n=s.alt,d=s.title),l=l||2,u=typeof u=="undefined"?l*4:u,n=typeof n=="string"?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||"qrcode-description":null,d=typeof d=="string"?{text:d}:d||{},d.text=d.text||null,d.id=d.text?d.id||"qrcode-title":null;let v=b.getModuleCount()*l+u*2,w,B,T,f,p="",k;for(k="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",p+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',p+=s.scalable?"":' width="'+v+'px" height="'+v+'px"',p+=' viewBox="0 0 '+v+" "+v+'" ',p+=' preserveAspectRatio="xMinYMin meet"',p+=d.text||n.text?' role="img" aria-labelledby="'+R([d.id,n.id].join(" ").trim())+'"':"",p+=">",p+=d.text?'<title id="'+R(d.id)+'">'+R(d.text)+"</title>":"",p+=n.text?'<description id="'+R(n.id)+'">'+R(n.text)+"</description>":"",p+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',p+='<path d="',T=0;T<b.getModuleCount();T+=1)for(f=T*l+u,w=0;w<b.getModuleCount();w+=1)b.isDark(T,w)&&(B=w*l+u,p+="M"+B+","+f+k);return p+='" stroke="transparent" fill="black"/>',p+="</svg>",p},b.createDataURL=function(l,u){l=l||2,u=typeof u=="undefined"?l*4:u;let n=b.getModuleCount()*l+u*2,d=u,s=n-u;return Te(n,n,function(v,w){if(d<=v&&v<s&&d<=w&&w<s){let B=Math.floor((v-d)/l),T=Math.floor((w-d)/l);return b.isDark(T,B)?0:1}else return 1})},b.createImgTag=function(l,u,n){l=l||2,u=typeof u=="undefined"?l*4:u;let d=b.getModuleCount()*l+u*2,s="";return s+="<img",s+=' src="',s+=b.createDataURL(l,u),s+='"',s+=' width="',s+=d,s+='"',s+=' height="',s+=d,s+='"',n&&(s+=' alt="',s+=R(n),s+='"'),s+="/>",s};let R=function(l){let u="";for(let n=0;n<l.length;n+=1){let d=l.charAt(n);switch(d){case"<":u+="<";break;case">":u+=">";break;case"&":u+="&";break;case'"':u+=""";break;default:u+=d;break}}return u},G=function(l){l=typeof l=="undefined"?1*2:l;let n=b.getModuleCount()*1+l*2,d=l,s=n-l,v,w,B,T,f,p={"\u2588\u2588":"\u2588","\u2588 ":"\u2580"," \u2588":"\u2584"," ":" "},k={"\u2588\u2588":"\u2580","\u2588 ":"\u2580"," \u2588":" "," ":" "},M="";for(v=0;v<n;v+=2){for(B=Math.floor((v-d)/1),T=Math.floor((v+1-d)/1),w=0;w<n;w+=1)f="\u2588",d<=w&&w<s&&d<=v&&v<s&&b.isDark(B,Math.floor((w-d)/1))&&(f=" "),d<=w&&w<s&&d<=v+1&&v+1<s&&b.isDark(T,Math.floor((w-d)/1))?f+=" ":f+="\u2588",M+=l<1&&v+1>=s?k[f]:p[f];M+=`
|
|
339
339
|
`}return n%2&&l>0?M.substring(0,M.length-n-1)+Array(n+1).join("\u2580"):M.substring(0,M.length-1)};return b.createASCII=function(l,u){if(l=l||1,l<2)return G(u);l-=1,u=typeof u=="undefined"?l*2:u;let n=b.getModuleCount()*l+u*2,d=u,s=n-u,v,w,B,T,f=Array(l+1).join("\u2588\u2588"),p=Array(l+1).join(" "),k="",M="";for(v=0;v<n;v+=1){for(B=Math.floor((v-d)/l),M="",w=0;w<n;w+=1)T=1,d<=w&&w<s&&d<=v&&v<s&&b.isDark(B,Math.floor((w-d)/l))&&(T=0),M+=T?f:p;for(B=0;B<l;B+=1)k+=M+`
|
|
340
|
-
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,u){u=u||2;let n=b.getModuleCount();for(let d=0;d<n;d++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(d,s)?"black":"white",l.fillRect(s*u,d*u,u,u)},b};Q.stringToBytes=function(o){let g=[];for(let c=0;c<o.length;c+=1){let i=o.charCodeAt(c);g.push(i&255)}return g};Q.createStringToBytes=function(o,g){let c=function(){let a=Be(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),y=String.fromCharCode(h<<8|m),_=b<<8|x;e[y]=_,t+=1}if(t!=g)throw t+" != "+g;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=c[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},F={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],g=1335,c=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(g)>=0;)e^=g<<r(e)-r(g);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(c)>=0;)e^=c<<r(e)-r(c);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=V([1],0);for(let h=0;h<t;h+=1)e=e.multiply(V([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1){let _=0,C=t.isDark(x,y);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)y+P<0||e<=y+P||A==0&&P==0||C==t.isDark(x+A,y+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let y=0;y<e-1;y+=1){let _=0;t.isDark(x,y)&&(_+=1),t.isDark(x+1,y)&&(_+=1),t.isDark(x,y+1)&&(_+=1),t.isDark(x+1,y+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(x,y)&&!t.isDark(x,y+1)&&t.isDark(x,y+2)&&t.isDark(x,y+3)&&t.isDark(x,y+4)&&!t.isDark(x,y+5)&&t.isDark(x,y+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(y,x)&&!t.isDark(y+1,x)&&t.isDark(y+2,x)&&t.isDark(y+3,x)&&t.isDark(y+4,x)&&!t.isDark(y+5,x)&&t.isDark(y+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1)t.isDark(y,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),g=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)g[o[i]]=i;let c={};return c.glog=function(i){if(i<1)throw"glog("+i+")";return g[i]},c.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},c}(),V=function(o,g){if(typeof o.length=="undefined")throw o.length+"/"+g;let c=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+g);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return c[a]},i.getLength=function(){return c.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return V(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return V(t,0).mod(a)},i},ne=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],g=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},c={},i=function(a,r){switch(r){case F.L:return o[(a-1)*4+0];case F.M:return o[(a-1)*4+1];case F.Q:return o[(a-1)*4+2];case F.H:return o[(a-1)*4+3];default:return}};return c.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],y=t[m*3+2];for(let _=0;_<b;_+=1)h.push(g(x,y))}return h},c}(),oe=function(){let o=[],g=0,c={};return c.getBuffer=function(){return o},c.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},c.put=function(i,a){for(let r=0;r<a;r+=1)c.putBit((i>>>a-r-1&1)==1)},c.getLengthInBits=function(){return g},c.putBit=function(i){let a=Math.floor(g/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>g%8),g+=1},c},we=function(o){let g=D.MODE_NUMBER,c=o,i={};i.getMode=function(){return g},i.getLength=function(t){return c.length},i.write=function(t){let e=c,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ke=function(o){let g=D.MODE_ALPHA_NUM,c=o,i={};i.getMode=function(){return g},i.getLength=function(r){return c.length},i.write=function(r){let t=c,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},_e=function(o){let g=D.MODE_8BIT_BYTE,c=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return g},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},Me=function(o){let g=D.MODE_KANJI,c=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return g},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},le=function(){let o=[],g={};return g.writeByte=function(c){o.push(c&255)},g.writeShort=function(c){g.writeByte(c),g.writeByte(c>>>8)},g.writeBytes=function(c,i,a){i=i||0,a=a||c.length;for(let r=0;r<a;r+=1)g.writeByte(c[r+i])},g.writeString=function(c){for(let i=0;i<c.length;i+=1)g.writeByte(c.charCodeAt(i))},g.toByteArray=function(){return o},g.toString=function(){let c="";c+="[";for(let i=0;i<o.length;i+=1)i>0&&(c+=","),c+=o[i];return c+="]",c},g},Ce=function(){let o=0,g=0,c=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,g+=8,c+=1;g>=6;)r(o>>>g-6),g-=6},a.flush=function(){if(g>0&&(r(o<<6-g),o=0,g=0),c%3!=0){let e=3-c%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},Be=function(o){let g=o,c=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(c>=g.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=g.charAt(c);if(c+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},Ae=function(o,g){let c=o,i=g,a=new Array(o*g),r={};r.setPixel=function(m,b,x){a[b*c+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(c),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(c),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let y=0;for(;x.length-y>255;)m.writeByte(255),m.writeBytes(x,y,255),y+=255;m.writeByte(x.length-y),m.writeBytes(x,y,x.length-y),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,y=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|y)),A-=8-x,C>>>=8-x,y=0,x=0;y=C<<x|y,x=x+A},_.flush=function(){x>0&&b.writeByte(y)},_},e=function(m){let b=1<<m,x=(1<<m)+1,y=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=le(),A=t(C);A.write(b,y);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),y),_.size()<4095&&(_.size()==1<<y&&(y+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),y),A.write(x,y),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(y){if(x.contains(y))throw"dup key:"+y;m[y]=b,b+=1},x.size=function(){return b},x.indexOf=function(y){return m[y]},x.contains=function(y){return typeof m[y]!="undefined"},x};return r},Te=function(o,g,c){let i=Ae(o,g);for(let e=0;e<g;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,c(h,e));let a=le();i.write(a);let r=Ce(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},ie=Q,$e=Q.stringToBytes;var ae={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function Ee(o){if(!o)return null;try{let g=ie(0,"M");return g.addData(String(o)),g.make(),g.createDataURL(6,2)}catch{return null}}var Y=class o{constructor(g={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let c=g.key||g.keyId||g.key_id;if(!c)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(c)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),g.keySecret||g.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ae,g,{key:c})}open(g={}){let c=Object.assign({},this.options,g),i=String(c.apiBase||"").replace(/\/$/,""),a=String(c.assetBase||`${i}/assets`).replace(/\/$/,""),r=c.order_id||c.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=y=>{typeof c.onError=="function"?c.onError(y):console.error("PayuLink:",y.message||y)},e=null,h=null,m=async y=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:c.key,order_id:r,customer:y?{name:y.name,contact:y.mobile||y.contact,email:y.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:Ee(C.upi_intent_url),expires_at:C.expires_at,server_now:Math.floor(Date.now()/1e3)}},b=(y,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,c.pollMs||ae.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var y;(y=this._inner)==null||y.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(c.key)}`).then(async y=>{var C;let _=await y.json().catch(()=>({}));if(!y.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=re(Object.assign({},{apiBase:i,assetBase:a,name:c.name||_.merchant_name,logo:c.logo||`${a}/payulink-logo.png`,brandColor:c.brandColor,note:c.note,prefill:c.prefill||{},amount:_.amount/100,description:c.description||c.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof c.handler=="function"&&c.handler(A),typeof c.onSuccess=="function"&&c.onSuccess(A)},onDismiss:()=>{typeof c.onDismiss=="function"&&c.onDismiss()},onError:t}))}).catch(t),x}static open(g={}){return new o(g).open(g)}};typeof window!="undefined"&&(window.PayuLink=Y,window.PayulinkCheckout=Y);return ye(Pe);})();
|
|
340
|
+
`}return k.substring(0,k.length-1)},b.renderTo2dContext=function(l,u){u=u||2;let n=b.getModuleCount();for(let d=0;d<n;d++)for(let s=0;s<n;s++)l.fillStyle=b.isDark(d,s)?"black":"white",l.fillRect(s*u,d*u,u,u)},b};Q.stringToBytes=function(o){let g=[];for(let c=0;c<o.length;c+=1){let i=o.charCodeAt(c);g.push(i&255)}return g};Q.createStringToBytes=function(o,g){let c=function(){let a=Be(o),r=function(){let h=a.read();if(h==-1)throw"eof";return h},t=0,e={};for(;;){let h=a.read();if(h==-1)break;let m=r(),b=r(),x=r(),y=String.fromCharCode(h<<8|m),_=b<<8|x;e[y]=_,t+=1}if(t!=g)throw t+" != "+g;return e}(),i=63;return function(a){let r=[];for(let t=0;t<a.length;t+=1){let e=a.charCodeAt(t);if(e<128)r.push(e);else{let h=c[a.charAt(t)];typeof h=="number"?(h&255)==h?r.push(h):(r.push(h>>>8),r.push(h&255)):r.push(i)}}return r}};var D={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},F={L:1,M:0,Q:3,H:2},q={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},N=function(){let o=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],g=1335,c=7973,i=21522,a={},r=function(t){let e=0;for(;t!=0;)e+=1,t>>>=1;return e};return a.getBCHTypeInfo=function(t){let e=t<<10;for(;r(e)-r(g)>=0;)e^=g<<r(e)-r(g);return(t<<10|e)^i},a.getBCHTypeNumber=function(t){let e=t<<12;for(;r(e)-r(c)>=0;)e^=c<<r(e)-r(c);return t<<12|e},a.getPatternPosition=function(t){return o[t-1]},a.getMaskFunction=function(t){switch(t){case q.PATTERN000:return function(e,h){return(e+h)%2==0};case q.PATTERN001:return function(e,h){return e%2==0};case q.PATTERN010:return function(e,h){return h%3==0};case q.PATTERN011:return function(e,h){return(e+h)%3==0};case q.PATTERN100:return function(e,h){return(Math.floor(e/2)+Math.floor(h/3))%2==0};case q.PATTERN101:return function(e,h){return e*h%2+e*h%3==0};case q.PATTERN110:return function(e,h){return(e*h%2+e*h%3)%2==0};case q.PATTERN111:return function(e,h){return(e*h%3+(e+h)%2)%2==0};default:throw"bad maskPattern:"+t}},a.getErrorCorrectPolynomial=function(t){let e=V([1],0);for(let h=0;h<t;h+=1)e=e.multiply(V([1,j.gexp(h)],0));return e},a.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case D.MODE_NUMBER:return 10;case D.MODE_ALPHA_NUM:return 9;case D.MODE_8BIT_BYTE:return 8;case D.MODE_KANJI:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case D.MODE_NUMBER:return 12;case D.MODE_ALPHA_NUM:return 11;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 10;default:throw"mode:"+t}else if(e<41)switch(t){case D.MODE_NUMBER:return 14;case D.MODE_ALPHA_NUM:return 13;case D.MODE_8BIT_BYTE:return 16;case D.MODE_KANJI:return 12;default:throw"mode:"+t}else throw"type:"+e},a.getLostPoint=function(t){let e=t.getModuleCount(),h=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1){let _=0,C=t.isDark(x,y);for(let A=-1;A<=1;A+=1)if(!(x+A<0||e<=x+A))for(let P=-1;P<=1;P+=1)y+P<0||e<=y+P||A==0&&P==0||C==t.isDark(x+A,y+P)&&(_+=1);_>5&&(h+=3+_-5)}for(let x=0;x<e-1;x+=1)for(let y=0;y<e-1;y+=1){let _=0;t.isDark(x,y)&&(_+=1),t.isDark(x+1,y)&&(_+=1),t.isDark(x,y+1)&&(_+=1),t.isDark(x+1,y+1)&&(_+=1),(_==0||_==4)&&(h+=3)}for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(x,y)&&!t.isDark(x,y+1)&&t.isDark(x,y+2)&&t.isDark(x,y+3)&&t.isDark(x,y+4)&&!t.isDark(x,y+5)&&t.isDark(x,y+6)&&(h+=40);for(let x=0;x<e;x+=1)for(let y=0;y<e-6;y+=1)t.isDark(y,x)&&!t.isDark(y+1,x)&&t.isDark(y+2,x)&&t.isDark(y+3,x)&&t.isDark(y+4,x)&&!t.isDark(y+5,x)&&t.isDark(y+6,x)&&(h+=40);let m=0;for(let x=0;x<e;x+=1)for(let y=0;y<e;y+=1)t.isDark(y,x)&&(m+=1);let b=Math.abs(100*m/e/e-50)/5;return h+=b*10,h},a}(),j=function(){let o=new Array(256),g=new Array(256);for(let i=0;i<8;i+=1)o[i]=1<<i;for(let i=8;i<256;i+=1)o[i]=o[i-4]^o[i-5]^o[i-6]^o[i-8];for(let i=0;i<255;i+=1)g[o[i]]=i;let c={};return c.glog=function(i){if(i<1)throw"glog("+i+")";return g[i]},c.gexp=function(i){for(;i<0;)i+=255;for(;i>=256;)i-=255;return o[i]},c}(),V=function(o,g){if(typeof o.length=="undefined")throw o.length+"/"+g;let c=function(){let a=0;for(;a<o.length&&o[a]==0;)a+=1;let r=new Array(o.length-a+g);for(let t=0;t<o.length-a;t+=1)r[t]=o[t+a];return r}(),i={};return i.getAt=function(a){return c[a]},i.getLength=function(){return c.length},i.multiply=function(a){let r=new Array(i.getLength()+a.getLength()-1);for(let t=0;t<i.getLength();t+=1)for(let e=0;e<a.getLength();e+=1)r[t+e]^=j.gexp(j.glog(i.getAt(t))+j.glog(a.getAt(e)));return V(r,0)},i.mod=function(a){if(i.getLength()-a.getLength()<0)return i;let r=j.glog(i.getAt(0))-j.glog(a.getAt(0)),t=new Array(i.getLength());for(let e=0;e<i.getLength();e+=1)t[e]=i.getAt(e);for(let e=0;e<a.getLength();e+=1)t[e]^=j.gexp(j.glog(a.getAt(e))+r);return V(t,0).mod(a)},i},ne=function(){let o=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],g=function(a,r){let t={};return t.totalCount=a,t.dataCount=r,t},c={},i=function(a,r){switch(r){case F.L:return o[(a-1)*4+0];case F.M:return o[(a-1)*4+1];case F.Q:return o[(a-1)*4+2];case F.H:return o[(a-1)*4+3];default:return}};return c.getRSBlocks=function(a,r){let t=i(a,r);if(typeof t=="undefined")throw"bad rs block @ typeNumber:"+a+"/errorCorrectionLevel:"+r;let e=t.length/3,h=[];for(let m=0;m<e;m+=1){let b=t[m*3+0],x=t[m*3+1],y=t[m*3+2];for(let _=0;_<b;_+=1)h.push(g(x,y))}return h},c}(),oe=function(){let o=[],g=0,c={};return c.getBuffer=function(){return o},c.getAt=function(i){let a=Math.floor(i/8);return(o[a]>>>7-i%8&1)==1},c.put=function(i,a){for(let r=0;r<a;r+=1)c.putBit((i>>>a-r-1&1)==1)},c.getLengthInBits=function(){return g},c.putBit=function(i){let a=Math.floor(g/8);o.length<=a&&o.push(0),i&&(o[a]|=128>>>g%8),g+=1},c},we=function(o){let g=D.MODE_NUMBER,c=o,i={};i.getMode=function(){return g},i.getLength=function(t){return c.length},i.write=function(t){let e=c,h=0;for(;h+2<e.length;)t.put(a(e.substring(h,h+3)),10),h+=3;h<e.length&&(e.length-h==1?t.put(a(e.substring(h,h+1)),4):e.length-h==2&&t.put(a(e.substring(h,h+2)),7))};let a=function(t){let e=0;for(let h=0;h<t.length;h+=1)e=e*10+r(t.charAt(h));return e},r=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw"illegal char :"+t};return i},ke=function(o){let g=D.MODE_ALPHA_NUM,c=o,i={};i.getMode=function(){return g},i.getLength=function(r){return c.length},i.write=function(r){let t=c,e=0;for(;e+1<t.length;)r.put(a(t.charAt(e))*45+a(t.charAt(e+1)),11),e+=2;e<t.length&&r.put(a(t.charAt(e)),6)};let a=function(r){if("0"<=r&&r<="9")return r.charCodeAt(0)-48;if("A"<=r&&r<="Z")return r.charCodeAt(0)-65+10;switch(r){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+r}};return i},_e=function(o){let g=D.MODE_8BIT_BYTE,c=o,i=Q.stringToBytes(o),a={};return a.getMode=function(){return g},a.getLength=function(r){return i.length},a.write=function(r){for(let t=0;t<i.length;t+=1)r.put(i[t],8)},a},Me=function(o){let g=D.MODE_KANJI,c=o,i=Q.stringToBytes;(function(t,e){let h=i(t);if(h.length!=2||(h[0]<<8|h[1])!=e)throw"sjis not supported."})("\u53CB",38726);let a=i(o),r={};return r.getMode=function(){return g},r.getLength=function(t){return~~(a.length/2)},r.write=function(t){let e=a,h=0;for(;h+1<e.length;){let m=(255&e[h])<<8|255&e[h+1];if(33088<=m&&m<=40956)m-=33088;else if(57408<=m&&m<=60351)m-=49472;else throw"illegal char at "+(h+1)+"/"+m;m=(m>>>8&255)*192+(m&255),t.put(m,13),h+=2}if(h<e.length)throw"illegal char at "+(h+1)},r},le=function(){let o=[],g={};return g.writeByte=function(c){o.push(c&255)},g.writeShort=function(c){g.writeByte(c),g.writeByte(c>>>8)},g.writeBytes=function(c,i,a){i=i||0,a=a||c.length;for(let r=0;r<a;r+=1)g.writeByte(c[r+i])},g.writeString=function(c){for(let i=0;i<c.length;i+=1)g.writeByte(c.charCodeAt(i))},g.toByteArray=function(){return o},g.toString=function(){let c="";c+="[";for(let i=0;i<o.length;i+=1)i>0&&(c+=","),c+=o[i];return c+="]",c},g},Ce=function(){let o=0,g=0,c=0,i="",a={},r=function(e){i+=String.fromCharCode(t(e&63))},t=function(e){if(e<0)throw"n:"+e;if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47;throw"n:"+e};return a.writeByte=function(e){for(o=o<<8|e&255,g+=8,c+=1;g>=6;)r(o>>>g-6),g-=6},a.flush=function(){if(g>0&&(r(o<<6-g),o=0,g=0),c%3!=0){let e=3-c%3;for(let h=0;h<e;h+=1)i+="="}},a.toString=function(){return i},a},Be=function(o){let g=o,c=0,i=0,a=0,r={};r.read=function(){for(;a<8;){if(c>=g.length){if(a==0)return-1;throw"unexpected end of file./"+a}let h=g.charAt(c);if(c+=1,h=="=")return a=0,-1;if(h.match(/^\s$/))continue;i=i<<6|t(h.charCodeAt(0)),a+=6}let e=i>>>a-8&255;return a-=8,e};let t=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw"c:"+e};return r},Ae=function(o,g){let c=o,i=g,a=new Array(o*g),r={};r.setPixel=function(m,b,x){a[b*c+m]=x},r.write=function(m){m.writeString("GIF87a"),m.writeShort(c),m.writeShort(i),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(c),m.writeShort(i),m.writeByte(0);let b=2,x=e(b);m.writeByte(b);let y=0;for(;x.length-y>255;)m.writeByte(255),m.writeBytes(x,y,255),y+=255;m.writeByte(x.length-y),m.writeBytes(x,y,x.length-y),m.writeByte(0),m.writeString(";")};let t=function(m){let b=m,x=0,y=0,_={};return _.write=function(C,A){if(C>>>A)throw"length over";for(;x+A>=8;)b.writeByte(255&(C<<x|y)),A-=8-x,C>>>=8-x,y=0,x=0;y=C<<x|y,x=x+A},_.flush=function(){x>0&&b.writeByte(y)},_},e=function(m){let b=1<<m,x=(1<<m)+1,y=m+1,_=h();for(let S=0;S<b;S+=1)_.add(String.fromCharCode(S));_.add(String.fromCharCode(b)),_.add(String.fromCharCode(x));let C=le(),A=t(C);A.write(b,y);let P=0,E=String.fromCharCode(a[P]);for(P+=1;P<a.length;){let S=String.fromCharCode(a[P]);P+=1,_.contains(E+S)?E=E+S:(A.write(_.indexOf(E),y),_.size()<4095&&(_.size()==1<<y&&(y+=1),_.add(E+S)),E=S)}return A.write(_.indexOf(E),y),A.write(x,y),A.flush(),C.toByteArray()},h=function(){let m={},b=0,x={};return x.add=function(y){if(x.contains(y))throw"dup key:"+y;m[y]=b,b+=1},x.size=function(){return b},x.indexOf=function(y){return m[y]},x.contains=function(y){return typeof m[y]!="undefined"},x};return r},Te=function(o,g,c){let i=Ae(o,g);for(let e=0;e<g;e+=1)for(let h=0;h<o;h+=1)i.setPixel(h,e,c(h,e));let a=le();i.write(a);let r=Ce(),t=a.toByteArray();for(let e=0;e<t.length;e+=1)r.writeByte(t[e]);return r.flush(),"data:image/gif;base64,"+r},ie=Q,$e=Q.stringToBytes;var ae={apiBase:"https://payulink.io/api",assetBase:"https://assetcdn.payulink.io/checkout/v1/assets",name:null,logo:null,brandColor:null,pollMs:2500};function Ee(o){if(!o)return null;try{let g=ie(0,"M");return g.addData(String(o)),g.make(),g.createDataURL(6,2)}catch{return null}}var Y=class o{constructor(g={}){if(typeof window=="undefined"||typeof document=="undefined")throw new Error("PayuLink checkout runs in the browser only. On React Native use @thepayulink/checkout-react-native; on a server use @thepayulink/server.");let c=g.key||g.keyId||g.key_id;if(!c)throw new Error("PayuLink: `key` (your publishable pl_live_\u2026 / pl_test_\u2026 key) is required");if(/^pl_(live|test)_/.test(c)||console.warn("PayuLink: `key` should look like pl_live_\u2026 or pl_test_\u2026"),g.keySecret||g.key_secret)throw new Error("PayuLink: never pass a key_secret to the browser SDK. It belongs on your server only.");this.options=Object.assign({},ae,g,{key:c})}open(g={}){let c=Object.assign({},this.options,g),i=String(c.apiBase||"").replace(/\/$/,""),a=String(c.assetBase||`${i}/assets`).replace(/\/$/,""),r=c.order_id||c.orderId;if(!r)throw new Error("PayuLink: `order_id` is required. Create it on your server with POST /v1/orders.");let t=y=>{typeof c.onError=="function"?c.onError(y):console.error("PayuLink:",y.message||y)},e=null,h=null,m=async y=>{var A;let _=await fetch(`${i}/v1/checkout/session`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({key_id:c.key,order_id:r,customer:y?{name:y.name,contact:y.mobile||y.contact,email:y.email}:void 0})}),C=await _.json().catch(()=>({}));if(!_.ok)throw new Error(((A=C==null?void 0:C.error)==null?void 0:A.description)||`Could not start payment (HTTP ${_.status})`);return e=C,{merchant_order_no:C.order_id,amount:C.amount/100,upi_intent_url:C.upi_intent_url,payment_link:C.payment_link,qr_data_url:Ee(C.upi_intent_url),expires_at:C.expires_at?C.expires_at*1e3:null,server_now:Date.now()}},b=(y,_)=>{let C=async()=>{if(e!=null&&e.session_token)try{let E=await(await fetch(`${i}/v1/checkout/session/${encodeURIComponent(e.session_token)}`)).json().catch(()=>({}));E.status==="paid"&&E.payulink_signature&&(h={payulink_order_id:E.payulink_order_id,payulink_payment_id:E.payulink_payment_id,payulink_signature:E.payulink_signature,utr:E.utr||null,amount:E.amount}),_({status:E.status==="paid"?0:E.status==="failed"?1:E.status==="expired"?3:2,status_label:String(E.status||"pending").toUpperCase(),utr:E.utr||null})}catch{}},A=setInterval(C,c.pollMs||ae.pollMs);return C(),()=>clearInterval(A)},x={_inner:null,close(){var y;(y=this._inner)==null||y.close()}};return fetch(`${i}/v1/checkout/order/${encodeURIComponent(r)}?key_id=${encodeURIComponent(c.key)}`).then(async y=>{var C;let _=await y.json().catch(()=>({}));if(!y.ok)throw new Error(((C=_==null?void 0:_.error)==null?void 0:C.description)||"Unknown or expired order");x._inner=re(Object.assign({},{apiBase:i,assetBase:a,name:c.name||_.merchant_name,logo:c.logo||`${a}/payulink-logo.png`,brandColor:c.brandColor,note:c.note,prefill:c.prefill||{},amount:_.amount/100,description:c.description||c.item||_.merchant_name,createOrder:m,watchOrder:b,onSuccess:()=>{let A=h||{payulink_order_id:(e==null?void 0:e.order_id)||r,payulink_payment_id:null,payulink_signature:null};typeof c.handler=="function"&&c.handler(A),typeof c.onSuccess=="function"&&c.onSuccess(A)},onDismiss:()=>{typeof c.onDismiss=="function"&&c.onDismiss()},onError:t}))}).catch(t),x}static open(g={}){return new o(g).open(g)}};typeof window!="undefined"&&(window.PayuLink=Y,window.PayulinkCheckout=Y);return ye(Pe);})();
|
|
341
341
|
window.PayulinkCheckout=PayulinkCheckoutNS.default||PayulinkCheckoutNS;
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -117,9 +117,13 @@ export default class PayuLink {
|
|
|
117
117
|
upi_intent_url: s.upi_intent_url,
|
|
118
118
|
payment_link: s.payment_link,
|
|
119
119
|
qr_data_url: toQrDataUrl(s.upi_intent_url),
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
// UNITS: modal.js does `Date.now() + (expires_at - server_now)`, and
|
|
121
|
+
// Date.now() is MILLISECONDS — so the delta must be ms too, not just
|
|
122
|
+
// "the same unit as each other". /v1 returns expires_at in epoch
|
|
123
|
+
// SECONDS, so convert. Passing seconds made a 30-min TTL expire in
|
|
124
|
+
// 1800ms (~2s) — the QR looked dead on arrival.
|
|
125
|
+
expires_at: s.expires_at ? s.expires_at * 1000 : null,
|
|
126
|
+
server_now: Date.now(),
|
|
123
127
|
};
|
|
124
128
|
};
|
|
125
129
|
|