btcdonate
Version:
A standalone React component for BTC donations.
158 lines (150 loc) • 33.9 kB
JavaScript
(function($,w){typeof exports=="object"&&typeof module<"u"?w(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],w):($=typeof globalThis<"u"?globalThis:$||self,w($.BtcDonate={},$.React))})(this,function($,w){"use strict";var K={exports:{}},Z={};/**
* @license React
* react-jsx-runtime.production.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var ae;function ye(){if(ae)return Z;ae=1;var u=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function i(c,h,f){var y=null;if(f!==void 0&&(y=""+f),h.key!==void 0&&(y=""+h.key),"key"in h){f={};for(var v in h)v!=="key"&&(f[v]=h[v])}else f=h;return h=f.ref,{$$typeof:u,type:c,key:y,ref:h!==void 0?h:null,props:f}}return Z.Fragment=l,Z.jsx=i,Z.jsxs=i,Z}var q={};/**
* @license React
* react-jsx-runtime.development.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/var le;function Re(){return le||(le=1,process.env.NODE_ENV!=="production"&&function(){function u(s){if(s==null)return null;if(typeof s=="function")return s.$$typeof===Q?null:s.displayName||s.name||null;if(typeof s=="string")return s;switch(s){case m:return"Fragment";case k:return"Profiler";case p:return"StrictMode";case P:return"Suspense";case L:return"SuspenseList";case U:return"Activity"}if(typeof s=="object")switch(typeof s.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),s.$$typeof){case a:return"Portal";case g:return(s.displayName||"Context")+".Provider";case S:return(s._context.displayName||"Context")+".Consumer";case A:var E=s.render;return s=s.displayName,s||(s=E.displayName||E.name||"",s=s!==""?"ForwardRef("+s+")":"ForwardRef"),s;case W:return E=s.displayName||null,E!==null?E:u(s.type)||"Memo";case F:E=s._payload,s=s._init;try{return u(s(E))}catch{}}return null}function l(s){return""+s}function i(s){try{l(s);var E=!1}catch{E=!0}if(E){E=console;var R=E.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&s[Symbol.toStringTag]||s.constructor.name||"Object";return R.call(E,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),l(s)}}function c(s){if(s===m)return"<>";if(typeof s=="object"&&s!==null&&s.$$typeof===F)return"<...>";try{var E=u(s);return E?"<"+E+">":"<...>"}catch{return"<...>"}}function h(){var s=O.A;return s===null?null:s.getOwner()}function f(){return Error("react-stack-top-frame")}function y(s){if(V.call(s,"key")){var E=Object.getOwnPropertyDescriptor(s,"key").get;if(E&&E.isReactWarning)return!1}return s.key!==void 0}function v(s,E){function R(){I||(I=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",E))}R.isReactWarning=!0,Object.defineProperty(s,"key",{get:R,configurable:!0})}function e(){var s=u(this.type);return x[s]||(x[s]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),s=this.props.ref,s!==void 0?s:null}function r(s,E,R,T,z,D,ne,se){return R=D.ref,s={$$typeof:d,type:s,key:E,props:D,_owner:z},(R!==void 0?R:null)!==null?Object.defineProperty(s,"ref",{enumerable:!1,get:e}):Object.defineProperty(s,"ref",{enumerable:!1,value:null}),s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(s,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(s,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.defineProperty(s,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:se}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s}function t(s,E,R,T,z,D,ne,se){var _=E.children;if(_!==void 0)if(T)if(G(_)){for(T=0;T<_.length;T++)o(_[T]);Object.freeze&&Object.freeze(_)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else o(_);if(V.call(E,"key")){_=u(s);var J=Object.keys(E).filter(function(Fe){return Fe!=="key"});T=0<J.length?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}",X[_+T]||(J=0<J.length?"{"+J.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
let props = %s;
<%s {...props} />
React keys must be passed directly to JSX without using spread:
let props = %s;
<%s key={someKey} {...props} />`,T,_,J,_),X[_+T]=!0)}if(_=null,R!==void 0&&(i(R),_=""+R),y(E)&&(i(E.key),_=""+E.key),"key"in E){R={};for(var ie in E)ie!=="key"&&(R[ie]=E[ie])}else R=E;return _&&v(R,typeof s=="function"?s.displayName||s.name||"Unknown":s),r(s,_,D,z,h(),R,ne,se)}function o(s){typeof s=="object"&&s!==null&&s.$$typeof===d&&s._store&&(s._store.validated=1)}var n=w,d=Symbol.for("react.transitional.element"),a=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),p=Symbol.for("react.strict_mode"),k=Symbol.for("react.profiler"),S=Symbol.for("react.consumer"),g=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),P=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),W=Symbol.for("react.memo"),F=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),Q=Symbol.for("react.client.reference"),O=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,G=Array.isArray,j=console.createTask?console.createTask:function(){return null};n={react_stack_bottom_frame:function(s){return s()}};var I,x={},N=n.react_stack_bottom_frame.bind(n,f)(),B=j(c(f)),X={};q.Fragment=m,q.jsx=function(s,E,R,T,z){var D=1e4>O.recentlyCreatedOwnerStacks++;return t(s,E,R,!1,T,z,D?Error("react-stack-top-frame"):N,D?j(c(s)):B)},q.jsxs=function(s,E,R,T,z){var D=1e4>O.recentlyCreatedOwnerStacks++;return t(s,E,R,!0,T,z,D?Error("react-stack-top-frame"):N,D?j(c(s)):B)}}()),q}var ce;function Ae(){return ce||(ce=1,process.env.NODE_ENV==="production"?K.exports=ye():K.exports=Re()),K.exports}var C=Ae(),Se=Object.defineProperty,ee=Object.getOwnPropertySymbols,ue=Object.prototype.hasOwnProperty,de=Object.prototype.propertyIsEnumerable,fe=(u,l,i)=>l in u?Se(u,l,{enumerable:!0,configurable:!0,writable:!0,value:i}):u[l]=i,te=(u,l)=>{for(var i in l||(l={}))ue.call(l,i)&&fe(u,i,l[i]);if(ee)for(var i of ee(l))de.call(l,i)&&fe(u,i,l[i]);return u},re=(u,l)=>{var i={};for(var c in u)ue.call(u,c)&&l.indexOf(c)<0&&(i[c]=u[c]);if(u!=null&&ee)for(var c of ee(u))l.indexOf(c)<0&&de.call(u,c)&&(i[c]=u[c]);return i};/**
* @license QR Code generator library (TypeScript)
* Copyright (c) Project Nayuki.
* SPDX-License-Identifier: MIT
*/var Y;(u=>{const l=class b{constructor(e,r,t,o){if(this.version=e,this.errorCorrectionLevel=r,this.modules=[],this.isFunction=[],e<b.MIN_VERSION||e>b.MAX_VERSION)throw new RangeError("Version value out of range");if(o<-1||o>7)throw new RangeError("Mask value out of range");this.size=e*4+17;let n=[];for(let a=0;a<this.size;a++)n.push(!1);for(let a=0;a<this.size;a++)this.modules.push(n.slice()),this.isFunction.push(n.slice());this.drawFunctionPatterns();const d=this.addEccAndInterleave(t);if(this.drawCodewords(d),o==-1){let a=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const p=this.getPenaltyScore();p<a&&(o=m,a=p),this.applyMask(m)}}h(0<=o&&o<=7),this.mask=o,this.applyMask(o),this.drawFormatBits(o),this.isFunction=[]}static encodeText(e,r){const t=u.QrSegment.makeSegments(e);return b.encodeSegments(t,r)}static encodeBinary(e,r){const t=u.QrSegment.makeBytes(e);return b.encodeSegments([t],r)}static encodeSegments(e,r,t=1,o=40,n=-1,d=!0){if(!(b.MIN_VERSION<=t&&t<=o&&o<=b.MAX_VERSION)||n<-1||n>7)throw new RangeError("Invalid value");let a,m;for(a=t;;a++){const g=b.getNumDataCodewords(a,r)*8,A=y.getTotalBits(e,a);if(A<=g){m=A;break}if(a>=o)throw new RangeError("Data too long")}for(const g of[b.Ecc.MEDIUM,b.Ecc.QUARTILE,b.Ecc.HIGH])d&&m<=b.getNumDataCodewords(a,g)*8&&(r=g);let p=[];for(const g of e){i(g.mode.modeBits,4,p),i(g.numChars,g.mode.numCharCountBits(a),p);for(const A of g.getData())p.push(A)}h(p.length==m);const k=b.getNumDataCodewords(a,r)*8;h(p.length<=k),i(0,Math.min(4,k-p.length),p),i(0,(8-p.length%8)%8,p),h(p.length%8==0);for(let g=236;p.length<k;g^=253)i(g,8,p);let S=[];for(;S.length*8<p.length;)S.push(0);return p.forEach((g,A)=>S[A>>>3]|=g<<7-(A&7)),new b(a,r,S,n)}getModule(e,r){return 0<=e&&e<this.size&&0<=r&&r<this.size&&this.modules[r][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let t=0;t<this.size;t++)this.setFunctionModule(6,t,t%2==0),this.setFunctionModule(t,6,t%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const e=this.getAlignmentPatternPositions(),r=e.length;for(let t=0;t<r;t++)for(let o=0;o<r;o++)t==0&&o==0||t==0&&o==r-1||t==r-1&&o==0||this.drawAlignmentPattern(e[t],e[o]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){const r=this.errorCorrectionLevel.formatBits<<3|e;let t=r;for(let n=0;n<10;n++)t=t<<1^(t>>>9)*1335;const o=(r<<10|t)^21522;h(o>>>15==0);for(let n=0;n<=5;n++)this.setFunctionModule(8,n,c(o,n));this.setFunctionModule(8,7,c(o,6)),this.setFunctionModule(8,8,c(o,7)),this.setFunctionModule(7,8,c(o,8));for(let n=9;n<15;n++)this.setFunctionModule(14-n,8,c(o,n));for(let n=0;n<8;n++)this.setFunctionModule(this.size-1-n,8,c(o,n));for(let n=8;n<15;n++)this.setFunctionModule(8,this.size-15+n,c(o,n));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;const r=this.version<<12|e;h(r>>>18==0);for(let t=0;t<18;t++){const o=c(r,t),n=this.size-11+t%3,d=Math.floor(t/3);this.setFunctionModule(n,d,o),this.setFunctionModule(d,n,o)}}drawFinderPattern(e,r){for(let t=-4;t<=4;t++)for(let o=-4;o<=4;o++){const n=Math.max(Math.abs(o),Math.abs(t)),d=e+o,a=r+t;0<=d&&d<this.size&&0<=a&&a<this.size&&this.setFunctionModule(d,a,n!=2&&n!=4)}}drawAlignmentPattern(e,r){for(let t=-2;t<=2;t++)for(let o=-2;o<=2;o++)this.setFunctionModule(e+o,r+t,Math.max(Math.abs(o),Math.abs(t))!=1)}setFunctionModule(e,r,t){this.modules[r][e]=t,this.isFunction[r][e]=!0}addEccAndInterleave(e){const r=this.version,t=this.errorCorrectionLevel;if(e.length!=b.getNumDataCodewords(r,t))throw new RangeError("Invalid argument");const o=b.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][r],n=b.ECC_CODEWORDS_PER_BLOCK[t.ordinal][r],d=Math.floor(b.getNumRawDataModules(r)/8),a=o-d%o,m=Math.floor(d/o);let p=[];const k=b.reedSolomonComputeDivisor(n);for(let g=0,A=0;g<o;g++){let P=e.slice(A,A+m-n+(g<a?0:1));A+=P.length;const L=b.reedSolomonComputeRemainder(P,k);g<a&&P.push(0),p.push(P.concat(L))}let S=[];for(let g=0;g<p[0].length;g++)p.forEach((A,P)=>{(g!=m-n||P>=a)&&S.push(A[g])});return h(S.length==d),S}drawCodewords(e){if(e.length!=Math.floor(b.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let r=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let o=0;o<this.size;o++)for(let n=0;n<2;n++){const d=t-n,m=(t+1&2)==0?this.size-1-o:o;!this.isFunction[m][d]&&r<e.length*8&&(this.modules[m][d]=c(e[r>>>3],7-(r&7)),r++)}}h(r==e.length*8)}applyMask(e){if(e<0||e>7)throw new RangeError("Mask value out of range");for(let r=0;r<this.size;r++)for(let t=0;t<this.size;t++){let o;switch(e){case 0:o=(t+r)%2==0;break;case 1:o=r%2==0;break;case 2:o=t%3==0;break;case 3:o=(t+r)%3==0;break;case 4:o=(Math.floor(t/3)+Math.floor(r/2))%2==0;break;case 5:o=t*r%2+t*r%3==0;break;case 6:o=(t*r%2+t*r%3)%2==0;break;case 7:o=((t+r)%2+t*r%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[r][t]&&o&&(this.modules[r][t]=!this.modules[r][t])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let d=!1,a=0,m=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[n][p]==d?(a++,a==5?e+=b.PENALTY_N1:a>5&&e++):(this.finderPenaltyAddHistory(a,m),d||(e+=this.finderPenaltyCountPatterns(m)*b.PENALTY_N3),d=this.modules[n][p],a=1);e+=this.finderPenaltyTerminateAndCount(d,a,m)*b.PENALTY_N3}for(let n=0;n<this.size;n++){let d=!1,a=0,m=[0,0,0,0,0,0,0];for(let p=0;p<this.size;p++)this.modules[p][n]==d?(a++,a==5?e+=b.PENALTY_N1:a>5&&e++):(this.finderPenaltyAddHistory(a,m),d||(e+=this.finderPenaltyCountPatterns(m)*b.PENALTY_N3),d=this.modules[p][n],a=1);e+=this.finderPenaltyTerminateAndCount(d,a,m)*b.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let d=0;d<this.size-1;d++){const a=this.modules[n][d];a==this.modules[n][d+1]&&a==this.modules[n+1][d]&&a==this.modules[n+1][d+1]&&(e+=b.PENALTY_N2)}let r=0;for(const n of this.modules)r=n.reduce((d,a)=>d+(a?1:0),r);const t=this.size*this.size,o=Math.ceil(Math.abs(r*20-t*10)/t)-1;return h(0<=o&&o<=9),e+=o*b.PENALTY_N4,h(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{const e=Math.floor(this.version/7)+2,r=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2;let t=[6];for(let o=this.size-7;t.length<e;o-=r)t.splice(1,0,o);return t}}static getNumRawDataModules(e){if(e<b.MIN_VERSION||e>b.MAX_VERSION)throw new RangeError("Version number out of range");let r=(16*e+128)*e+64;if(e>=2){const t=Math.floor(e/7)+2;r-=(25*t-10)*t-55,e>=7&&(r-=36)}return h(208<=r&&r<=29648),r}static getNumDataCodewords(e,r){return Math.floor(b.getNumRawDataModules(e)/8)-b.ECC_CODEWORDS_PER_BLOCK[r.ordinal][e]*b.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw new RangeError("Degree out of range");let r=[];for(let o=0;o<e-1;o++)r.push(0);r.push(1);let t=1;for(let o=0;o<e;o++){for(let n=0;n<r.length;n++)r[n]=b.reedSolomonMultiply(r[n],t),n+1<r.length&&(r[n]^=r[n+1]);t=b.reedSolomonMultiply(t,2)}return r}static reedSolomonComputeRemainder(e,r){let t=r.map(o=>0);for(const o of e){const n=o^t.shift();t.push(0),r.forEach((d,a)=>t[a]^=b.reedSolomonMultiply(d,n))}return t}static reedSolomonMultiply(e,r){if(e>>>8||r>>>8)throw new RangeError("Byte out of range");let t=0;for(let o=7;o>=0;o--)t=t<<1^(t>>>7)*285,t^=(r>>>o&1)*e;return h(t>>>8==0),t}finderPenaltyCountPatterns(e){const r=e[1];h(r<=this.size*3);const t=r>0&&e[2]==r&&e[3]==r*3&&e[4]==r&&e[5]==r;return(t&&e[0]>=r*4&&e[6]>=r?1:0)+(t&&e[6]>=r*4&&e[0]>=r?1:0)}finderPenaltyTerminateAndCount(e,r,t){return e&&(this.finderPenaltyAddHistory(r,t),r=0),r+=this.size,this.finderPenaltyAddHistory(r,t),this.finderPenaltyCountPatterns(t)}finderPenaltyAddHistory(e,r){r[0]==0&&(e+=this.size),r.pop(),r.unshift(e)}};l.MIN_VERSION=1,l.MAX_VERSION=40,l.PENALTY_N1=3,l.PENALTY_N2=3,l.PENALTY_N3=40,l.PENALTY_N4=10,l.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],l.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],u.QrCode=l;function i(v,e,r){if(e<0||e>31||v>>>e)throw new RangeError("Value out of range");for(let t=e-1;t>=0;t--)r.push(v>>>t&1)}function c(v,e){return(v>>>e&1)!=0}function h(v){if(!v)throw new Error("Assertion error")}const f=class M{constructor(e,r,t){if(this.mode=e,this.numChars=r,this.bitData=t,r<0)throw new RangeError("Invalid argument");this.bitData=t.slice()}static makeBytes(e){let r=[];for(const t of e)i(t,8,r);return new M(M.Mode.BYTE,e.length,r)}static makeNumeric(e){if(!M.isNumeric(e))throw new RangeError("String contains non-numeric characters");let r=[];for(let t=0;t<e.length;){const o=Math.min(e.length-t,3);i(parseInt(e.substring(t,t+o),10),o*3+1,r),t+=o}return new M(M.Mode.NUMERIC,e.length,r)}static makeAlphanumeric(e){if(!M.isAlphanumeric(e))throw new RangeError("String contains unencodable characters in alphanumeric mode");let r=[],t;for(t=0;t+2<=e.length;t+=2){let o=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t))*45;o+=M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t+1)),i(o,11,r)}return t<e.length&&i(M.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)),6,r),new M(M.Mode.ALPHANUMERIC,e.length,r)}static makeSegments(e){return e==""?[]:M.isNumeric(e)?[M.makeNumeric(e)]:M.isAlphanumeric(e)?[M.makeAlphanumeric(e)]:[M.makeBytes(M.toUtf8ByteArray(e))]}static makeEci(e){let r=[];if(e<0)throw new RangeError("ECI assignment value out of range");if(e<128)i(e,8,r);else if(e<16384)i(2,2,r),i(e,14,r);else if(e<1e6)i(6,3,r),i(e,21,r);else throw new RangeError("ECI assignment value out of range");return new M(M.Mode.ECI,0,r)}static isNumeric(e){return M.NUMERIC_REGEX.test(e)}static isAlphanumeric(e){return M.ALPHANUMERIC_REGEX.test(e)}getData(){return this.bitData.slice()}static getTotalBits(e,r){let t=0;for(const o of e){const n=o.mode.numCharCountBits(r);if(o.numChars>=1<<n)return 1/0;t+=4+n+o.bitData.length}return t}static toUtf8ByteArray(e){e=encodeURI(e);let r=[];for(let t=0;t<e.length;t++)e.charAt(t)!="%"?r.push(e.charCodeAt(t)):(r.push(parseInt(e.substring(t+1,t+3),16)),t+=2);return r}};f.NUMERIC_REGEX=/^[0-9]*$/,f.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,f.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let y=f;u.QrSegment=f})(Y||(Y={})),(u=>{(l=>{const i=class{constructor(h,f){this.ordinal=h,this.formatBits=f}};i.LOW=new i(0,1),i.MEDIUM=new i(1,0),i.QUARTILE=new i(2,3),i.HIGH=new i(3,2),l.Ecc=i})(u.QrCode||(u.QrCode={}))})(Y||(Y={})),(u=>{(l=>{const i=class{constructor(h,f){this.modeBits=h,this.numBitsCharCount=f}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}};i.NUMERIC=new i(1,[10,12,14]),i.ALPHANUMERIC=new i(2,[9,11,13]),i.BYTE=new i(4,[8,16,16]),i.KANJI=new i(8,[8,10,12]),i.ECI=new i(7,[0,0,0]),l.Mode=i})(u.QrSegment||(u.QrSegment={}))})(Y||(Y={}));var H=Y;/**
* @license qrcode.react
* Copyright (c) Paul O'Shannessy
* SPDX-License-Identifier: ISC
*/var Me={L:H.QrCode.Ecc.LOW,M:H.QrCode.Ecc.MEDIUM,Q:H.QrCode.Ecc.QUARTILE,H:H.QrCode.Ecc.HIGH},he=128,pe="L",me="#FFFFFF",ge="#000000",Ee=!1,we=1,Ne=4,Pe=0,Te=.1;function be(u,l=0){const i=[];return u.forEach(function(c,h){let f=null;c.forEach(function(y,v){if(!y&&f!==null){i.push(`M${f+l} ${h+l}h${v-f}v1H${f+l}z`),f=null;return}if(v===c.length-1){if(!y)return;f===null?i.push(`M${v+l},${h+l} h1v1H${v+l}z`):i.push(`M${f+l},${h+l} h${v+1-f}v1H${f+l}z`);return}y&&f===null&&(f=v)})}),i.join("")}function Ce(u,l){return u.slice().map((i,c)=>c<l.y||c>=l.y+l.h?i:i.map((h,f)=>f<l.x||f>=l.x+l.w?h:!1))}function Oe(u,l,i,c){if(c==null)return null;const h=u.length+i*2,f=Math.floor(l*Te),y=h/l,v=(c.width||f)*y,e=(c.height||f)*y,r=c.x==null?u.length/2-v/2:c.x*y,t=c.y==null?u.length/2-e/2:c.y*y,o=c.opacity==null?1:c.opacity;let n=null;if(c.excavate){let a=Math.floor(r),m=Math.floor(t),p=Math.ceil(v+r-a),k=Math.ceil(e+t-m);n={x:a,y:m,w:p,h:k}}const d=c.crossOrigin;return{x:r,y:t,h:e,w:v,excavation:n,opacity:o,crossOrigin:d}}function ke(u,l){return l!=null?Math.max(Math.floor(l),0):u?Ne:Pe}function xe({value:u,level:l,minVersion:i,includeMargin:c,marginSize:h,imageSettings:f,size:y,boostLevel:v}){let e=w.useMemo(()=>{const a=(Array.isArray(u)?u:[u]).reduce((m,p)=>(m.push(...H.QrSegment.makeSegments(p)),m),[]);return H.QrCode.encodeSegments(a,Me[l],i,void 0,void 0,v)},[u,l,i,v]);const{cells:r,margin:t,numCells:o,calculatedImageSettings:n}=w.useMemo(()=>{let d=e.getModules();const a=ke(c,h),m=d.length+a*2,p=Oe(d,y,a,f);return{cells:d,margin:a,numCells:m,calculatedImageSettings:p}},[e,y,f,c,h]);return{qrcode:e,margin:t,cells:r,numCells:o,calculatedImageSettings:n}}var _e=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),ve=w.forwardRef(function(l,i){const c=l,{value:h,size:f=he,level:y=pe,bgColor:v=me,fgColor:e=ge,includeMargin:r=Ee,minVersion:t=we,boostLevel:o,marginSize:n,imageSettings:d}=c,m=re(c,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:p}=m,k=re(m,["style"]),S=d?.src,g=w.useRef(null),A=w.useRef(null),P=w.useCallback(j=>{g.current=j,typeof i=="function"?i(j):i&&(i.current=j)},[i]),[L,W]=w.useState(!1),{margin:F,cells:U,numCells:Q,calculatedImageSettings:O}=xe({value:h,level:y,minVersion:t,boostLevel:o,includeMargin:r,marginSize:n,imageSettings:d,size:f});w.useEffect(()=>{if(g.current!=null){const j=g.current,I=j.getContext("2d");if(!I)return;let x=U;const N=A.current,B=O!=null&&N!==null&&N.complete&&N.naturalHeight!==0&&N.naturalWidth!==0;B&&O.excavation!=null&&(x=Ce(U,O.excavation));const X=window.devicePixelRatio||1;j.height=j.width=f*X;const s=f/Q*X;I.scale(s,s),I.fillStyle=v,I.fillRect(0,0,Q,Q),I.fillStyle=e,_e?I.fill(new Path2D(be(x,F))):U.forEach(function(E,R){E.forEach(function(T,z){T&&I.fillRect(z+F,R+F,1,1)})}),O&&(I.globalAlpha=O.opacity),B&&I.drawImage(N,O.x+F,O.y+F,O.w,O.h)}}),w.useEffect(()=>{W(!1)},[S]);const V=te({height:f,width:f},p);let G=null;return S!=null&&(G=w.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{W(!0)},ref:A,crossOrigin:O?.crossOrigin})),w.createElement(w.Fragment,null,w.createElement("canvas",te({style:V,height:f,width:f,ref:P,role:"img"},k)),G)});ve.displayName="QRCodeCanvas";var Ie=w.forwardRef(function(l,i){const c=l,{value:h,size:f=he,level:y=pe,bgColor:v=me,fgColor:e=ge,includeMargin:r=Ee,minVersion:t=we,boostLevel:o,title:n,marginSize:d,imageSettings:a}=c,m=re(c,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:p,cells:k,numCells:S,calculatedImageSettings:g}=xe({value:h,level:y,minVersion:t,boostLevel:o,includeMargin:r,marginSize:d,imageSettings:a,size:f});let A=k,P=null;a!=null&&g!=null&&(g.excavation!=null&&(A=Ce(k,g.excavation)),P=w.createElement("image",{href:a.src,height:g.h,width:g.w,x:g.x+p,y:g.y+p,preserveAspectRatio:"none",opacity:g.opacity,crossOrigin:g.crossOrigin}));const L=be(A,p);return w.createElement("svg",te({height:f,width:f,viewBox:`0 0 ${S} ${S}`,ref:i,role:"img"},m),!!n&&w.createElement("title",null,n),w.createElement("path",{fill:v,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),w.createElement("path",{fill:e,d:L,shapeRendering:"crispEdges"}),P)});Ie.displayName="QRCodeSVG";const oe=u=>{switch(u){case"usd":return"$";case"eur":return"€";case"gbp":return"£";case"jpy":case"cny":return"¥";case"aed":return"د.إ";case"zar":return"R";case"brl":return"R$";default:return"$"}},je=()=>{const[u,l]=w.useState(!1),[i,c]=w.useState("複製"),h=w.useCallback(f=>{navigator.clipboard.writeText(f).then(()=>{l(!0),c("已複製!"),setTimeout(()=>{l(!1),c("複製")},2e3)},y=>{console.error("無法複製到剪貼簿",y),c("複製失敗"),setTimeout(()=>c("複製"),2e3)})},[]);return[u,h,i]},Le=({address:u="bc1qx6xswq65n5x864vwj77lrtn0xn2rmlh3ypfkk8",title:l="Donate",description:i="Use this QR code or address below",currency:c="usd",presets:h=[50,100,200],showButton:f=!0,buttonText:y="Support Bitcoin.org",onClose:v})=>{const[e,r]=w.useState(!1),[t,o]=w.useState(""),[n,d]=w.useState(""),[a,m]=w.useState(112776),[p,k]=w.useState(""),[S,g,A]=je(),[P,L]=w.useState(null),[W,F]=w.useState(oe(c.toLowerCase()));w.useEffect(()=>{(async()=>{try{const N=c.toLowerCase();F(oe(N));const B=await fetch(`https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=${N}`);if(!B.ok)throw new Error(`HTTP error! Status: ${B.status}`);const s=(await B.json()).bitcoin?.[N];s?m(s):console.warn(`Could not find rate for currency: ${N}`)}catch(N){console.error("Error fetching Bitcoin rate:",N),m(112776),c="usd";const B=c.toLowerCase();F(oe(B))}})()},[c]),w.useEffect(()=>{if(P==="usd"){const x=parseFloat(t);if(isNaN(x))d("");else{const N=(x/a).toFixed(8);d(N)}}},[t,a,P]),w.useEffect(()=>{if(P==="btc"){const x=parseFloat(n);if(isNaN(x))o("");else{const N=(x*a).toFixed(2);o(N)}}},[n,a,P]);const U=`bitcoin:${u}?amount=${parseFloat(n)}${p?`&message=${encodeURIComponent(p)}`:""}`,Q=()=>{r(!1),v?.()},O=x=>{o(x.target.value),L("usd")},V=x=>{d(x.target.value),L("btc")},G=x=>{o(x.toString()),L("usd")},j=()=>C.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[C.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"}),C.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]}),I=()=>C.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:C.jsx("polyline",{points:"20 6 9 17 4 12"})});return C.jsxs(C.Fragment,{children:[f&&C.jsx("button",{onClick:()=>r(!0),style:{padding:"12px 24px",backgroundColor:"#2a2a2a",color:"white",borderRadius:"8px",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.1)",transition:"all 0.2s",border:"none",cursor:"pointer",fontSize:"1rem",fontWeight:"bold"},onMouseOver:x=>x.currentTarget.style.backgroundColor="#4a4a4a",onMouseOut:x=>x.currentTarget.style.backgroundColor="#2a2a2a",children:y}),e&&C.jsxs("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",overflowY:"auto",padding:"1rem"},children:[C.jsx("style",{children:`
@keyframes fadeInZoom {
0% {
opacity: 0;
transform: scale(0.5);
}
100% {
opacity: 1;
transform: scale(1);
}
}
.donate-modal {
background-color: white;
width: 100%;
width: 770px;
max-width: 770px;
margin: 0;
padding: 1.5rem;
height: 755px;
padding: 20px 90px;
border-radius: 1rem;
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
position: relative;
color: "#646464";
animation: fadeInZoom 0.3s ease-out;
transform-origin: top;
}
.donate-modal input::placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
opacity: 1; /* 瀏覽器可能會預設降低 opacity,這會強制它為 1 */
}
.donate-modal input::-webkit-input-placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
}
.donate-modal input::-moz-placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
}
.donate-modal textarea::placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
opacity: 1; /* 瀏覽器可能會預設降低 opacity,這會強制它為 1 */
}
.donate-modal textarea::-webkit-input-placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
}
.donate-modal textarea::-moz-placeholder {
color: #555; /* 選擇你想要的顏色,這裡使用較深的灰色 */
}
.focus-effect:focus {
border-width: 2px; /* 變粗 */
border-color: #555; /* 顏色變深 */
}
.copy-btn{
padding:0
}
.donate-presets {
display: flex;
gap: 0.5rem;
justify-content: center;
justify-content: space-between;
margin-bottom: 2rem;
}
.donate-inputs {
display: flex;
gap: 1rem;
}
.donate-input-wrapper {
position: relative;
flex: 1;
}
.donate-input-wrapper input {
width: 100%;
border: 1px solid #d1d5db;
padding: 15px 15px 15px 20px;
border-radius: 6px;
border-radius: 1px;
line-height: 1.25rem;
outline: none;
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
}
.donate-input-wrapper input:focus {
border-radius: 4px;
}
.donate-input-wrapper span {
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
color: #6b7280;
font-size: 0.875rem;
}
@media handheld, only screen and ( max-width: 60em ), only screen and ( max-device-width: 60em ){
.donate-modal {
padding: 20px 38px;
width: 620px;
height: 700px;
}
}
@media (max-width: 640px) {
.donate-modal {
padding: 1rem;
border-radius: 0.5rem;
}
.donate-presets {
flex-wrap: wrap;
}
.donate-presets button {
flex: auto;
width: auto;
}
.donate-inputs {
flex-direction: column;
flex-direction: row;
}
.donate-input-wrapper {
flex: auto;
}
.focus-effect:focus {
border-color: #F7931A; /* 顏色變深 */
}
}
`}),C.jsxs("div",{className:"donate-modal",children:[C.jsx("div",{onClick:Q,style:{position:"absolute",top:"1rem",right:"1rem",fontSize:"2rem",lineHeight:.5,height:"32px",width:"32px",padding:"0.5rem",color:"#6b7280",border:"none",background:"transparent",cursor:"pointer"},onMouseOver:x=>x.currentTarget.style.color="#4a4a4a",onMouseOut:x=>x.currentTarget.style.color="#6b7280",children:"×"}),C.jsx("h2",{style:{fontSize:"1.5rem",textAlign:"center",color:"#FF7E00",fontWeight:"normal",marginBottom:"20px",lineHeight:"65px"},children:l}),C.jsx("p",{style:{textAlign:"center",fontSize:"20px",lineHeight:"34px",color:"#6b7280",marginBottom:"1rem"},children:i}),C.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"0.75rem"},children:C.jsx(ve,{value:U,size:160,level:"L"})}),C.jsxs("div",{style:{textAlign:"center",position:"relative",marginBottom:"1.5rem"},children:[C.jsx("p",{style:{color:"#3498db",fontSize:"0.875rem",wordBreak:"break-all",paddingRight:"35px",paddingLeft:"35px",fontWeight:"bold",margin:"27px 0 25px"},children:C.jsx("a",{style:{color:"#3498db",fontSize:"0.875rem",wordBreak:"break-all",fontWeight:"bold"},href:U,target:"_blank",children:u})}),C.jsx("button",{onClick:()=>g(u),title:"複製比特幣地址","aria-label":"複製比特幣地址","data-status":A,style:{position:"absolute",right:"0",top:"50%",transform:"translateY(-50%)",backgroundColor:"transparent",border:"none",cursor:"pointer",color:"#6b7280",padding:"0.25rem"},children:S?C.jsx(I,{}):C.jsx(j,{})})]}),C.jsx("div",{className:"donate-presets",children:h.map(x=>C.jsxs("button",{onClick:()=>G(x),style:{flex:1,padding:"8px 0",borderRadius:"1px",transition:"all 0.15s",border:"none",cursor:"pointer",backgroundColor:"#F7931A",maxWidth:"170px",color:"white",height:"65px"},children:[W," ",x,C.jsx("br",{}),C.jsxs("span",{style:{fontSize:"0.75rem",display:"block",color:"white"},children:["(",(x/a).toFixed(6)," BTC)"]})]},x))}),C.jsxs("div",{className:"donate-inputs",children:[C.jsx("div",{className:"donate-input-wrapper",children:C.jsx("input",{type:"text",placeholder:"Custom amount(BTC)",value:n,onChange:V,onBlur:()=>L(null),className:"focus-effect"})}),C.jsx("div",{className:"donate-input-wrapper",children:C.jsx("input",{type:"text",placeholder:`Custom amount(${c.toUpperCase()})`,value:t,onChange:O,onBlur:()=>L(null),className:"focus-effect"})})]}),C.jsx("textarea",{className:"focus-effect",style:{width:"100%",border:"1px solid #d1d5db",padding:" 15px 15px 15px 20px",borderRadius:"1px",margin:" 30px 0 10px",lineHeight:"1.25rem",boxShadow:"inset 0 1px 2px rgba(0, 0, 0, 0.075)"},placeholder:"Optional description (for your wallet or contact info)",value:p,onChange:x=>k(x.target.value),rows:2,name:"note",id:"note"}),C.jsxs("div",{style:{textAlign:"center",marginTop:"auto"},children:[C.jsx("span",{style:{color:"#4b5563",fontSize:"0.75rem",lineHeight:"1rem"},children:"Current Rate:"}),C.jsxs("span",{style:{marginLeft:"0.5rem",fontSize:"0.875rem",lineHeight:"1.25rem"},children:["1 BTC ≈ ",a.toLocaleString()," ",c.toUpperCase()]})]})]})]})]})};$.BitcoinDonate=Le,Object.defineProperty($,Symbol.toStringTag,{value:"Module"})});