coinley-checkout 0.2.9 → 0.3.0

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.
@@ -0,0 +1,41 @@
1
+ (function(P,y){typeof exports=="object"&&typeof module!="undefined"?y(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],y):(P=typeof globalThis!="undefined"?globalThis:P||self,y(P.CoinleyCheckout={},P.React))})(this,function(P,y){"use strict";var Fr=Object.defineProperty,Ur=Object.defineProperties;var _r=Object.getOwnPropertyDescriptors;var Ot=Object.getOwnPropertySymbols;var Wr=Object.prototype.hasOwnProperty,Br=Object.prototype.propertyIsEnumerable;var Lt=(P,y,K)=>y in P?Fr(P,y,{enumerable:!0,configurable:!0,writable:!0,value:K}):P[y]=K,de=(P,y)=>{for(var K in y||(y={}))Wr.call(y,K)&&Lt(P,K,y[K]);if(Ot)for(var K of Ot(y))Br.call(y,K)&&Lt(P,K,y[K]);return P},Dt=(P,y)=>Ur(P,_r(y));var H=(P,y,K)=>new Promise((Y,Oe)=>{var Ae=se=>{try{Se(K.next(se))}catch(pe){Oe(pe)}},Le=se=>{try{Se(K.throw(se))}catch(pe){Oe(pe)}},Se=se=>se.done?Y(se.value):Promise.resolve(se.value).then(Ae,Le);Se((K=K.apply(P,y)).next())});const K="";let Y={apiKey:null,apiSecret:null,apiUrl:"http://localhost:9000",merchantWalletAddresses:{}};const Oe=i=>{Y=de(de({},Y),i),console.log("API initialized with:",{apiUrl:Y.apiUrl,apiKey:Y.apiKey?`${Y.apiKey.substring(0,6)}...`:null,hasWalletAddresses:Object.keys(Y.merchantWalletAddresses||{}).length>0})},Ae=()=>({"Content-Type":"application/json","x-api-key":Y.apiKey,"x-api-secret":Y.apiSecret}),Le=i=>H(this,null,function*(){try{console.log("Creating payment with data:",i),console.log("API URL:",`${Y.apiUrl}/api/payments/create`);const o=Dt(de({},i),{merchantWalletAddresses:de(de({},Y.merchantWalletAddresses),i.merchantWalletAddresses)}),s=yield fetch(`${Y.apiUrl}/api/payments/create`,{method:"POST",headers:Ae(),body:JSON.stringify(o)});if(console.log("Create payment response status:",s.status),!s.ok){const h=yield s.json();throw console.error("Error creating payment:",h),new Error(h.error||`Failed to create payment: ${s.status}`)}const f=yield s.json();return console.log("Create payment response data:",f),f}catch(o){throw console.error("Create payment error:",o),o}}),Se=i=>H(this,null,function*(){try{console.log("Getting payment:",i);const o=yield fetch(`${Y.apiUrl}/api/payments/${i}`,{method:"GET",headers:Ae()});if(!o.ok){const f=yield o.json();throw console.error("Error getting payment:",f),new Error(f.error||`Failed to get payment: ${o.status}`)}const s=yield o.json();return console.log("Get payment response:",s),s}catch(o){throw console.error("Get payment error:",o),o}}),se=i=>H(this,null,function*(){try{console.log("Processing payment with data:",i),console.log("API URL:",`${Y.apiUrl}/api/payments/process`);const o=yield fetch(`${Y.apiUrl}/api/payments/process`,{method:"POST",headers:Ae(),body:JSON.stringify(i)});if(console.log("Process payment response status:",o.status),!o.ok){const f=yield o.json();throw console.error("Error processing payment:",f),new Error(f.error||`Failed to process payment: ${o.status}`)}const s=yield o.json();return console.log("Process payment response data:",s),s}catch(o){throw console.error("Process payment error:",o),o}}),pe=()=>typeof window!="undefined"&&typeof window.ethereum!="undefined",It=()=>H(this,null,function*(){if(!pe())throw new Error("MetaMask is not installed");try{return yield window.ethereum.request({method:"eth_requestAccounts"})}catch(i){throw console.error("Error connecting to wallet:",i),i}});var _e={exports:{}},je={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.min.js
4
+ *
5
+ * Copyright (c) Facebook, Inc. and its affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var Xe;function Ft(){if(Xe)return je;Xe=1;var i=y,o=Symbol.for("react.element"),s=Symbol.for("react.fragment"),f=Object.prototype.hasOwnProperty,h=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,m={key:!0,ref:!0,__self:!0,__source:!0};function T(x,t,n){var r,l={},c=null,w=null;n!==void 0&&(c=""+n),t.key!==void 0&&(c=""+t.key),t.ref!==void 0&&(w=t.ref);for(r in t)f.call(t,r)&&!m.hasOwnProperty(r)&&(l[r]=t[r]);if(x&&x.defaultProps)for(r in t=x.defaultProps,t)l[r]===void 0&&(l[r]=t[r]);return{$$typeof:o,type:x,key:c,ref:w,props:l,_owner:h.current}}return je.Fragment=s,je.jsx=T,je.jsxs=T,je}var Re={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var Ze;function Ut(){return Ze||(Ze=1,process.env.NODE_ENV!=="production"&&function(){var i=y,o=Symbol.for("react.element"),s=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),h=Symbol.for("react.strict_mode"),m=Symbol.for("react.profiler"),T=Symbol.for("react.provider"),x=Symbol.for("react.context"),t=Symbol.for("react.forward_ref"),n=Symbol.for("react.suspense"),r=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),c=Symbol.for("react.lazy"),w=Symbol.for("react.offscreen"),u=Symbol.iterator,p="@@iterator";function v(e){if(e===null||typeof e!="object")return null;var d=u&&e[u]||e[p];return typeof d=="function"?d:null}var A=i.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function N(e){{for(var d=arguments.length,g=new Array(d>1?d-1:0),b=1;b<d;b++)g[b-1]=arguments[b];E("error",e,g)}}function E(e,d,g){{var b=A.ReactDebugCurrentFrame,O=b.getStackAddendum();O!==""&&(d+="%s",g=g.concat([O]));var I=g.map(function(k){return String(k)});I.unshift("Warning: "+d),Function.prototype.apply.call(console[e],console,I)}}var F=!1,U=!1,ee=!1,ie=!1,C=!1,L;L=Symbol.for("react.module.reference");function le(e){return!!(typeof e=="string"||typeof e=="function"||e===f||e===m||C||e===h||e===n||e===r||ie||e===w||F||U||ee||typeof e=="object"&&e!==null&&(e.$$typeof===c||e.$$typeof===l||e.$$typeof===T||e.$$typeof===x||e.$$typeof===t||e.$$typeof===L||e.getModuleId!==void 0))}function q(e,d,g){var b=e.displayName;if(b)return b;var O=d.displayName||d.name||"";return O!==""?g+"("+O+")":g}function X(e){return e.displayName||"Context"}function $(e){if(e==null)return null;if(typeof e.tag=="number"&&N("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case s:return"Portal";case m:return"Profiler";case h:return"StrictMode";case n:return"Suspense";case r:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case x:var d=e;return X(d)+".Consumer";case T:var g=e;return X(g._context)+".Provider";case t:return q(e,e.render,"ForwardRef");case l:var b=e.displayName||null;return b!==null?b:$(e.type)||"Memo";case c:{var O=e,I=O._payload,k=O._init;try{return $(k(I))}catch(R){return null}}}return null}var V=Object.assign,_=0,oe,ae,he,ce,te,ye,me;function ve(){}ve.__reactDisabledLog=!0;function B(){{if(_===0){oe=console.log,ae=console.info,he=console.warn,ce=console.error,te=console.group,ye=console.groupCollapsed,me=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ve,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}_++}}function Ve(){{if(_--,_===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:V({},e,{value:oe}),info:V({},e,{value:ae}),warn:V({},e,{value:he}),error:V({},e,{value:ce}),group:V({},e,{value:te}),groupCollapsed:V({},e,{value:ye}),groupEnd:V({},e,{value:me})})}_<0&&N("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var xe=A.ReactCurrentDispatcher,ke;function Ee(e,d,g){{if(ke===void 0)try{throw Error()}catch(O){var b=O.stack.trim().match(/\n( *(at )?)/);ke=b&&b[1]||""}return`
18
+ `+ke+e}}var Me=!1,be;{var Ge=typeof WeakMap=="function"?WeakMap:Map;be=new Ge}function D(e,d){if(!e||Me)return"";{var g=be.get(e);if(g!==void 0)return g}var b;Me=!0;var O=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var I;I=xe.current,xe.current=null,B();try{if(d){var k=function(){throw Error()};if(Object.defineProperty(k.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(k,[])}catch(Z){b=Z}Reflect.construct(e,[],k)}else{try{k.call()}catch(Z){b=Z}e.call(k.prototype)}}else{try{throw Error()}catch(Z){b=Z}e()}}catch(Z){if(Z&&b&&typeof Z.stack=="string"){for(var R=Z.stack.split(`
19
+ `),J=b.stack.split(`
20
+ `),z=R.length-1,Q=J.length-1;z>=1&&Q>=0&&R[z]!==J[Q];)Q--;for(;z>=1&&Q>=0;z--,Q--)if(R[z]!==J[Q]){if(z!==1||Q!==1)do if(z--,Q--,Q<0||R[z]!==J[Q]){var ne=`
21
+ `+R[z].replace(" at new "," at ");return e.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",e.displayName)),typeof e=="function"&&be.set(e,ne),ne}while(z>=1&&Q>=0);break}}}finally{Me=!1,xe.current=I,Ve(),Error.prepareStackTrace=O}var Ce=e?e.displayName||e.name:"",ge=Ce?Ee(Ce):"";return typeof e=="function"&&be.set(e,ge),ge}function G(e,d,g){return D(e,!1)}function re(e){var d=e.prototype;return!!(d&&d.isReactComponent)}function Ne(e,d,g){if(e==null)return"";if(typeof e=="function")return D(e,re(e));if(typeof e=="string")return Ee(e);switch(e){case n:return Ee("Suspense");case r:return Ee("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case t:return G(e.render);case l:return Ne(e.type,d,g);case c:{var b=e,O=b._payload,I=b._init;try{return Ne(I(O),d,g)}catch(k){}}}return""}var ue=Object.prototype.hasOwnProperty,xt={},Et=A.ReactDebugCurrentFrame;function Ue(e){if(e){var d=e._owner,g=Ne(e.type,e._source,d?d.type:null);Et.setExtraStackFrame(g)}else Et.setExtraStackFrame(null)}function gr(e,d,g,b,O){{var I=Function.call.bind(ue);for(var k in e)if(I(e,k)){var R=void 0;try{if(typeof e[k]!="function"){var J=Error((b||"React class")+": "+g+" type `"+k+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[k]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}R=e[k](d,k,b,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(z){R=z}R&&!(R instanceof Error)&&(Ue(O),N("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",b||"React class",g,k,typeof R),Ue(null)),R instanceof Error&&!(R.message in xt)&&(xt[R.message]=!0,Ue(O),N("Failed %s type: %s",g,R.message),Ue(null))}}}var pr=Array.isArray;function He(e){return pr(e)}function wr(e){{var d=typeof Symbol=="function"&&Symbol.toStringTag,g=d&&e[Symbol.toStringTag]||e.constructor.name||"Object";return g}}function yr(e){try{return bt(e),!1}catch(d){return!0}}function bt(e){return""+e}function Nt(e){if(yr(e))return N("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",wr(e)),bt(e)}var Pe=A.ReactCurrentOwner,vr={key:!0,ref:!0,__self:!0,__source:!0},Tt,Ct,Ke;Ke={};function xr(e){if(ue.call(e,"ref")){var d=Object.getOwnPropertyDescriptor(e,"ref").get;if(d&&d.isReactWarning)return!1}return e.ref!==void 0}function Er(e){if(ue.call(e,"key")){var d=Object.getOwnPropertyDescriptor(e,"key").get;if(d&&d.isReactWarning)return!1}return e.key!==void 0}function br(e,d){if(typeof e.ref=="string"&&Pe.current&&d&&Pe.current.stateNode!==d){var g=$(Pe.current.type);Ke[g]||(N('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',$(Pe.current.type),e.ref),Ke[g]=!0)}}function Nr(e,d){{var g=function(){Tt||(Tt=!0,N("%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://reactjs.org/link/special-props)",d))};g.isReactWarning=!0,Object.defineProperty(e,"key",{get:g,configurable:!0})}}function Tr(e,d){{var g=function(){Ct||(Ct=!0,N("%s: `ref` 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://reactjs.org/link/special-props)",d))};g.isReactWarning=!0,Object.defineProperty(e,"ref",{get:g,configurable:!0})}}var Cr=function(e,d,g,b,O,I,k){var R={$$typeof:o,type:e,key:d,ref:g,props:k,_owner:I};return R._store={},Object.defineProperty(R._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(R,"_self",{configurable:!1,enumerable:!1,writable:!1,value:b}),Object.defineProperty(R,"_source",{configurable:!1,enumerable:!1,writable:!1,value:O}),Object.freeze&&(Object.freeze(R.props),Object.freeze(R)),R};function Ar(e,d,g,b,O){{var I,k={},R=null,J=null;g!==void 0&&(Nt(g),R=""+g),Er(d)&&(Nt(d.key),R=""+d.key),xr(d)&&(J=d.ref,br(d,O));for(I in d)ue.call(d,I)&&!vr.hasOwnProperty(I)&&(k[I]=d[I]);if(e&&e.defaultProps){var z=e.defaultProps;for(I in z)k[I]===void 0&&(k[I]=z[I])}if(R||J){var Q=typeof e=="function"?e.displayName||e.name||"Unknown":e;R&&Nr(k,Q),J&&Tr(k,Q)}return Cr(e,R,J,O,b,Pe.current,k)}}var Ye=A.ReactCurrentOwner,At=A.ReactDebugCurrentFrame;function Te(e){if(e){var d=e._owner,g=Ne(e.type,e._source,d?d.type:null);At.setExtraStackFrame(g)}else At.setExtraStackFrame(null)}var qe;qe=!1;function $e(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function St(){{if(Ye.current){var e=$(Ye.current.type);if(e)return`
22
+
23
+ Check the render method of \``+e+"`."}return""}}function Sr(e){{if(e!==void 0){var d=e.fileName.replace(/^.*[\\\/]/,""),g=e.lineNumber;return`
24
+
25
+ Check your code at `+d+":"+g+"."}return""}}var jt={};function jr(e){{var d=St();if(!d){var g=typeof e=="string"?e:e.displayName||e.name;g&&(d=`
26
+
27
+ Check the top-level render call using <`+g+">.")}return d}}function Rt(e,d){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var g=jr(d);if(jt[g])return;jt[g]=!0;var b="";e&&e._owner&&e._owner!==Ye.current&&(b=" It was passed a child from "+$(e._owner.type)+"."),Te(e),N('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,b),Te(null)}}function kt(e,d){{if(typeof e!="object")return;if(He(e))for(var g=0;g<e.length;g++){var b=e[g];$e(b)&&Rt(b,d)}else if($e(e))e._store&&(e._store.validated=!0);else if(e){var O=v(e);if(typeof O=="function"&&O!==e.entries)for(var I=O.call(e),k;!(k=I.next()).done;)$e(k.value)&&Rt(k.value,d)}}}function Rr(e){{var d=e.type;if(d==null||typeof d=="string")return;var g;if(typeof d=="function")g=d.propTypes;else if(typeof d=="object"&&(d.$$typeof===t||d.$$typeof===l))g=d.propTypes;else return;if(g){var b=$(d);gr(g,e.props,"prop",b,e)}else if(d.PropTypes!==void 0&&!qe){qe=!0;var O=$(d);N("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",O||"Unknown")}typeof d.getDefaultProps=="function"&&!d.getDefaultProps.isReactClassApproved&&N("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kr(e){{for(var d=Object.keys(e.props),g=0;g<d.length;g++){var b=d[g];if(b!=="children"&&b!=="key"){Te(e),N("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",b),Te(null);break}}e.ref!==null&&(Te(e),N("Invalid attribute `ref` supplied to `React.Fragment`."),Te(null))}}var Mt={};function Pt(e,d,g,b,O,I){{var k=le(e);if(!k){var R="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(R+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var J=Sr(O);J?R+=J:R+=St();var z;e===null?z="null":He(e)?z="array":e!==void 0&&e.$$typeof===o?(z="<"+($(e.type)||"Unknown")+" />",R=" Did you accidentally export a JSX literal instead of a component?"):z=typeof e,N("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",z,R)}var Q=Ar(e,d,g,O,I);if(Q==null)return Q;if(k){var ne=d.children;if(ne!==void 0)if(b)if(He(ne)){for(var Ce=0;Ce<ne.length;Ce++)kt(ne[Ce],e);Object.freeze&&Object.freeze(ne)}else N("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 kt(ne,e)}if(ue.call(d,"key")){var ge=$(e),Z=Object.keys(d).filter(function(Ir){return Ir!=="key"}),Je=Z.length>0?"{key: someKey, "+Z.join(": ..., ")+": ...}":"{key: someKey}";if(!Mt[ge+Je]){var Dr=Z.length>0?"{"+Z.join(": ..., ")+": ...}":"{}";N(`A props object containing a "key" prop is being spread into JSX:
28
+ let props = %s;
29
+ <%s {...props} />
30
+ React keys must be passed directly to JSX without using spread:
31
+ let props = %s;
32
+ <%s key={someKey} {...props} />`,Je,ge,Dr,ge),Mt[ge+Je]=!0}}return e===f?kr(Q):Rr(Q),Q}}function Mr(e,d,g){return Pt(e,d,g,!0)}function Pr(e,d,g){return Pt(e,d,g,!1)}var Or=Pr,Lr=Mr;Re.Fragment=f,Re.jsx=Or,Re.jsxs=Lr}()),Re}process.env.NODE_ENV==="production"?_e.exports=Ft():_e.exports=Ut();var a=_e.exports;const et=y.createContext(),_t=()=>y.useContext(et),Wt=({initialTheme:i="light",children:o})=>{const[s,f]=y.useState(i),h=()=>{f(m=>m==="light"?"dark":"light")};return y.useEffect(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(s)},[s]),a.jsx(et.Provider,{value:{theme:s,setTheme:f,toggleTheme:h},children:o})},tt=y.createContext(),Bt=()=>y.useContext(tt),zt=({apiKey:i,apiSecret:o,apiUrl:s="http://localhost:9000",merchantWalletAddress:f=null,merchantSolWalletAddress:h=null,debug:m=!1,children:T})=>{const[x,t]=y.useState(!1),[n,r]=y.useState(null),[l,c]=y.useState(null);y.useEffect(()=>{if(!i||!o){r("API key and secret are required");return}try{Oe({apiKey:i,apiSecret:o,apiUrl:s,merchantWalletAddress:f,merchantSolWalletAddress:h}),t(!0),m&&console.log("Coinley SDK initialized with:",{apiKey:i,apiUrl:s,merchantWalletAddress:f?`${f.substring(0,6)}...${f.substring(f.length-4)}`:"Not provided",merchantSolWalletAddress:h?`${h.substring(0,6)}...${h.substring(h.length-4)}`:"Not provided"})}catch(p){r(p.message),m&&console.error("Coinley SDK initialization error:",p)}},[i,o,s,f,h,m]);const u={apiKey:i,apiSecret:o,apiUrl:s,merchantWalletAddress:f,merchantSolWalletAddress:h,isInitialized:x,error:n,debug:m,paymentData:l,storePaymentData:p=>(c(p),p)};return a.jsx(tt.Provider,{value:u,children:T})};var Qt=Object.defineProperty,De=Object.getOwnPropertySymbols,rt=Object.prototype.hasOwnProperty,nt=Object.prototype.propertyIsEnumerable,st=(i,o,s)=>o in i?Qt(i,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[o]=s,We=(i,o)=>{for(var s in o||(o={}))rt.call(o,s)&&st(i,s,o[s]);if(De)for(var s of De(o))nt.call(o,s)&&st(i,s,o[s]);return i},Be=(i,o)=>{var s={};for(var f in i)rt.call(i,f)&&o.indexOf(f)<0&&(s[f]=i[f]);if(i!=null&&De)for(var f of De(i))o.indexOf(f)<0&&nt.call(i,f)&&(s[f]=i[f]);return s};/**
33
+ * @license QR Code generator library (TypeScript)
34
+ * Copyright (c) Project Nayuki.
35
+ * SPDX-License-Identifier: MIT
36
+ */var fe;(i=>{const o=class j{constructor(t,n,r,l){if(this.version=t,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],t<j.MIN_VERSION||t>j.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=t*4+17;let c=[];for(let u=0;u<this.size;u++)c.push(!1);for(let u=0;u<this.size;u++)this.modules.push(c.slice()),this.isFunction.push(c.slice());this.drawFunctionPatterns();const w=this.addEccAndInterleave(r);if(this.drawCodewords(w),l==-1){let u=1e9;for(let p=0;p<8;p++){this.applyMask(p),this.drawFormatBits(p);const v=this.getPenaltyScore();v<u&&(l=p,u=v),this.applyMask(p)}}h(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(t,n){const r=i.QrSegment.makeSegments(t);return j.encodeSegments(r,n)}static encodeBinary(t,n){const r=i.QrSegment.makeBytes(t);return j.encodeSegments([r],n)}static encodeSegments(t,n,r=1,l=40,c=-1,w=!0){if(!(j.MIN_VERSION<=r&&r<=l&&l<=j.MAX_VERSION)||c<-1||c>7)throw new RangeError("Invalid value");let u,p;for(u=r;;u++){const E=j.getNumDataCodewords(u,n)*8,F=T.getTotalBits(t,u);if(F<=E){p=F;break}if(u>=l)throw new RangeError("Data too long")}for(const E of[j.Ecc.MEDIUM,j.Ecc.QUARTILE,j.Ecc.HIGH])w&&p<=j.getNumDataCodewords(u,E)*8&&(n=E);let v=[];for(const E of t){s(E.mode.modeBits,4,v),s(E.numChars,E.mode.numCharCountBits(u),v);for(const F of E.getData())v.push(F)}h(v.length==p);const A=j.getNumDataCodewords(u,n)*8;h(v.length<=A),s(0,Math.min(4,A-v.length),v),s(0,(8-v.length%8)%8,v),h(v.length%8==0);for(let E=236;v.length<A;E^=253)s(E,8,v);let N=[];for(;N.length*8<v.length;)N.push(0);return v.forEach((E,F)=>N[F>>>3]|=E<<7-(F&7)),new j(u,n,N,c)}getModule(t,n){return 0<=t&&t<this.size&&0<=n&&n<this.size&&this.modules[n][t]}getModules(){return this.modules}drawFunctionPatterns(){for(let r=0;r<this.size;r++)this.setFunctionModule(6,r,r%2==0),this.setFunctionModule(r,6,r%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const t=this.getAlignmentPatternPositions(),n=t.length;for(let r=0;r<n;r++)for(let l=0;l<n;l++)r==0&&l==0||r==0&&l==n-1||r==n-1&&l==0||this.drawAlignmentPattern(t[r],t[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(t){const n=this.errorCorrectionLevel.formatBits<<3|t;let r=n;for(let c=0;c<10;c++)r=r<<1^(r>>>9)*1335;const l=(n<<10|r)^21522;h(l>>>15==0);for(let c=0;c<=5;c++)this.setFunctionModule(8,c,f(l,c));this.setFunctionModule(8,7,f(l,6)),this.setFunctionModule(8,8,f(l,7)),this.setFunctionModule(7,8,f(l,8));for(let c=9;c<15;c++)this.setFunctionModule(14-c,8,f(l,c));for(let c=0;c<8;c++)this.setFunctionModule(this.size-1-c,8,f(l,c));for(let c=8;c<15;c++)this.setFunctionModule(8,this.size-15+c,f(l,c));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let t=this.version;for(let r=0;r<12;r++)t=t<<1^(t>>>11)*7973;const n=this.version<<12|t;h(n>>>18==0);for(let r=0;r<18;r++){const l=f(n,r),c=this.size-11+r%3,w=Math.floor(r/3);this.setFunctionModule(c,w,l),this.setFunctionModule(w,c,l)}}drawFinderPattern(t,n){for(let r=-4;r<=4;r++)for(let l=-4;l<=4;l++){const c=Math.max(Math.abs(l),Math.abs(r)),w=t+l,u=n+r;0<=w&&w<this.size&&0<=u&&u<this.size&&this.setFunctionModule(w,u,c!=2&&c!=4)}}drawAlignmentPattern(t,n){for(let r=-2;r<=2;r++)for(let l=-2;l<=2;l++)this.setFunctionModule(t+l,n+r,Math.max(Math.abs(l),Math.abs(r))!=1)}setFunctionModule(t,n,r){this.modules[n][t]=r,this.isFunction[n][t]=!0}addEccAndInterleave(t){const n=this.version,r=this.errorCorrectionLevel;if(t.length!=j.getNumDataCodewords(n,r))throw new RangeError("Invalid argument");const l=j.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],c=j.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],w=Math.floor(j.getNumRawDataModules(n)/8),u=l-w%l,p=Math.floor(w/l);let v=[];const A=j.reedSolomonComputeDivisor(c);for(let E=0,F=0;E<l;E++){let U=t.slice(F,F+p-c+(E<u?0:1));F+=U.length;const ee=j.reedSolomonComputeRemainder(U,A);E<u&&U.push(0),v.push(U.concat(ee))}let N=[];for(let E=0;E<v[0].length;E++)v.forEach((F,U)=>{(E!=p-c||U>=u)&&N.push(F[E])});return h(N.length==w),N}drawCodewords(t){if(t.length!=Math.floor(j.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let n=0;for(let r=this.size-1;r>=1;r-=2){r==6&&(r=5);for(let l=0;l<this.size;l++)for(let c=0;c<2;c++){const w=r-c,p=(r+1&2)==0?this.size-1-l:l;!this.isFunction[p][w]&&n<t.length*8&&(this.modules[p][w]=f(t[n>>>3],7-(n&7)),n++)}}h(n==t.length*8)}applyMask(t){if(t<0||t>7)throw new RangeError("Mask value out of range");for(let n=0;n<this.size;n++)for(let r=0;r<this.size;r++){let l;switch(t){case 0:l=(r+n)%2==0;break;case 1:l=n%2==0;break;case 2:l=r%3==0;break;case 3:l=(r+n)%3==0;break;case 4:l=(Math.floor(r/3)+Math.floor(n/2))%2==0;break;case 5:l=r*n%2+r*n%3==0;break;case 6:l=(r*n%2+r*n%3)%2==0;break;case 7:l=((r+n)%2+r*n%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[n][r]&&l&&(this.modules[n][r]=!this.modules[n][r])}}getPenaltyScore(){let t=0;for(let c=0;c<this.size;c++){let w=!1,u=0,p=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[c][v]==w?(u++,u==5?t+=j.PENALTY_N1:u>5&&t++):(this.finderPenaltyAddHistory(u,p),w||(t+=this.finderPenaltyCountPatterns(p)*j.PENALTY_N3),w=this.modules[c][v],u=1);t+=this.finderPenaltyTerminateAndCount(w,u,p)*j.PENALTY_N3}for(let c=0;c<this.size;c++){let w=!1,u=0,p=[0,0,0,0,0,0,0];for(let v=0;v<this.size;v++)this.modules[v][c]==w?(u++,u==5?t+=j.PENALTY_N1:u>5&&t++):(this.finderPenaltyAddHistory(u,p),w||(t+=this.finderPenaltyCountPatterns(p)*j.PENALTY_N3),w=this.modules[v][c],u=1);t+=this.finderPenaltyTerminateAndCount(w,u,p)*j.PENALTY_N3}for(let c=0;c<this.size-1;c++)for(let w=0;w<this.size-1;w++){const u=this.modules[c][w];u==this.modules[c][w+1]&&u==this.modules[c+1][w]&&u==this.modules[c+1][w+1]&&(t+=j.PENALTY_N2)}let n=0;for(const c of this.modules)n=c.reduce((w,u)=>w+(u?1:0),n);const r=this.size*this.size,l=Math.ceil(Math.abs(n*20-r*10)/r)-1;return h(0<=l&&l<=9),t+=l*j.PENALTY_N4,h(0<=t&&t<=2568888),t}getAlignmentPatternPositions(){if(this.version==1)return[];{const t=Math.floor(this.version/7)+2,n=this.version==32?26:Math.ceil((this.version*4+4)/(t*2-2))*2;let r=[6];for(let l=this.size-7;r.length<t;l-=n)r.splice(1,0,l);return r}}static getNumRawDataModules(t){if(t<j.MIN_VERSION||t>j.MAX_VERSION)throw new RangeError("Version number out of range");let n=(16*t+128)*t+64;if(t>=2){const r=Math.floor(t/7)+2;n-=(25*r-10)*r-55,t>=7&&(n-=36)}return h(208<=n&&n<=29648),n}static getNumDataCodewords(t,n){return Math.floor(j.getNumRawDataModules(t)/8)-j.ECC_CODEWORDS_PER_BLOCK[n.ordinal][t]*j.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][t]}static reedSolomonComputeDivisor(t){if(t<1||t>255)throw new RangeError("Degree out of range");let n=[];for(let l=0;l<t-1;l++)n.push(0);n.push(1);let r=1;for(let l=0;l<t;l++){for(let c=0;c<n.length;c++)n[c]=j.reedSolomonMultiply(n[c],r),c+1<n.length&&(n[c]^=n[c+1]);r=j.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(t,n){let r=n.map(l=>0);for(const l of t){const c=l^r.shift();r.push(0),n.forEach((w,u)=>r[u]^=j.reedSolomonMultiply(w,c))}return r}static reedSolomonMultiply(t,n){if(t>>>8||n>>>8)throw new RangeError("Byte out of range");let r=0;for(let l=7;l>=0;l--)r=r<<1^(r>>>7)*285,r^=(n>>>l&1)*t;return h(r>>>8==0),r}finderPenaltyCountPatterns(t){const n=t[1];h(n<=this.size*3);const r=n>0&&t[2]==n&&t[3]==n*3&&t[4]==n&&t[5]==n;return(r&&t[0]>=n*4&&t[6]>=n?1:0)+(r&&t[6]>=n*4&&t[0]>=n?1:0)}finderPenaltyTerminateAndCount(t,n,r){return t&&(this.finderPenaltyAddHistory(n,r),n=0),n+=this.size,this.finderPenaltyAddHistory(n,r),this.finderPenaltyCountPatterns(r)}finderPenaltyAddHistory(t,n){n[0]==0&&(t+=this.size),n.pop(),n.unshift(t)}};o.MIN_VERSION=1,o.MAX_VERSION=40,o.PENALTY_N1=3,o.PENALTY_N2=3,o.PENALTY_N3=40,o.PENALTY_N4=10,o.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]],o.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]],i.QrCode=o;function s(x,t,n){if(t<0||t>31||x>>>t)throw new RangeError("Value out of range");for(let r=t-1;r>=0;r--)n.push(x>>>r&1)}function f(x,t){return(x>>>t&1)!=0}function h(x){if(!x)throw new Error("Assertion error")}const m=class W{constructor(t,n,r){if(this.mode=t,this.numChars=n,this.bitData=r,n<0)throw new RangeError("Invalid argument");this.bitData=r.slice()}static makeBytes(t){let n=[];for(const r of t)s(r,8,n);return new W(W.Mode.BYTE,t.length,n)}static makeNumeric(t){if(!W.isNumeric(t))throw new RangeError("String contains non-numeric characters");let n=[];for(let r=0;r<t.length;){const l=Math.min(t.length-r,3);s(parseInt(t.substring(r,r+l),10),l*3+1,n),r+=l}return new W(W.Mode.NUMERIC,t.length,n)}static makeAlphanumeric(t){if(!W.isAlphanumeric(t))throw new RangeError("String contains unencodable characters in alphanumeric mode");let n=[],r;for(r=0;r+2<=t.length;r+=2){let l=W.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r))*45;l+=W.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r+1)),s(l,11,n)}return r<t.length&&s(W.ALPHANUMERIC_CHARSET.indexOf(t.charAt(r)),6,n),new W(W.Mode.ALPHANUMERIC,t.length,n)}static makeSegments(t){return t==""?[]:W.isNumeric(t)?[W.makeNumeric(t)]:W.isAlphanumeric(t)?[W.makeAlphanumeric(t)]:[W.makeBytes(W.toUtf8ByteArray(t))]}static makeEci(t){let n=[];if(t<0)throw new RangeError("ECI assignment value out of range");if(t<128)s(t,8,n);else if(t<16384)s(2,2,n),s(t,14,n);else if(t<1e6)s(6,3,n),s(t,21,n);else throw new RangeError("ECI assignment value out of range");return new W(W.Mode.ECI,0,n)}static isNumeric(t){return W.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return W.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(t,n){let r=0;for(const l of t){const c=l.mode.numCharCountBits(n);if(l.numChars>=1<<c)return 1/0;r+=4+c+l.bitData.length}return r}static toUtf8ByteArray(t){t=encodeURI(t);let n=[];for(let r=0;r<t.length;r++)t.charAt(r)!="%"?n.push(t.charCodeAt(r)):(n.push(parseInt(t.substring(r+1,r+3),16)),r+=2);return n}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let T=m;i.QrSegment=m})(fe||(fe={})),(i=>{(o=>{const s=class{constructor(h,m){this.ordinal=h,this.formatBits=m}};s.LOW=new s(0,1),s.MEDIUM=new s(1,0),s.QUARTILE=new s(2,3),s.HIGH=new s(3,2),o.Ecc=s})(i.QrCode||(i.QrCode={}))})(fe||(fe={})),(i=>{(o=>{const s=class{constructor(h,m){this.modeBits=h,this.numBitsCharCount=m}numCharCountBits(h){return this.numBitsCharCount[Math.floor((h+7)/17)]}};s.NUMERIC=new s(1,[10,12,14]),s.ALPHANUMERIC=new s(2,[9,11,13]),s.BYTE=new s(4,[8,16,16]),s.KANJI=new s(8,[8,10,12]),s.ECI=new s(7,[0,0,0]),o.Mode=s})(i.QrSegment||(i.QrSegment={}))})(fe||(fe={}));var we=fe;/**
37
+ * @license qrcode.react
38
+ * Copyright (c) Paul O'Shannessy
39
+ * SPDX-License-Identifier: ISC
40
+ */var Vt={L:we.QrCode.Ecc.LOW,M:we.QrCode.Ecc.MEDIUM,Q:we.QrCode.Ecc.QUARTILE,H:we.QrCode.Ecc.HIGH},at=128,ot="L",it="#FFFFFF",lt="#000000",ct=!1,ut=1,Gt=4,Ht=0,Kt=.1;function dt(i,o=0){const s=[];return i.forEach(function(f,h){let m=null;f.forEach(function(T,x){if(!T&&m!==null){s.push(`M${m+o} ${h+o}h${x-m}v1H${m+o}z`),m=null;return}if(x===f.length-1){if(!T)return;m===null?s.push(`M${x+o},${h+o} h1v1H${x+o}z`):s.push(`M${m+o},${h+o} h${x+1-m}v1H${m+o}z`);return}T&&m===null&&(m=x)})}),s.join("")}function ft(i,o){return i.slice().map((s,f)=>f<o.y||f>=o.y+o.h?s:s.map((h,m)=>m<o.x||m>=o.x+o.w?h:!1))}function Yt(i,o,s,f){if(f==null)return null;const h=i.length+s*2,m=Math.floor(o*Kt),T=h/o,x=(f.width||m)*T,t=(f.height||m)*T,n=f.x==null?i.length/2-x/2:f.x*T,r=f.y==null?i.length/2-t/2:f.y*T,l=f.opacity==null?1:f.opacity;let c=null;if(f.excavate){let u=Math.floor(n),p=Math.floor(r),v=Math.ceil(x+n-u),A=Math.ceil(t+r-p);c={x:u,y:p,w:v,h:A}}const w=f.crossOrigin;return{x:n,y:r,h:t,w:x,excavation:c,opacity:l,crossOrigin:w}}function qt(i,o){return o!=null?Math.max(Math.floor(o),0):i?Gt:Ht}function ht({value:i,level:o,minVersion:s,includeMargin:f,marginSize:h,imageSettings:m,size:T,boostLevel:x}){let t=y.useMemo(()=>{const u=(Array.isArray(i)?i:[i]).reduce((p,v)=>(p.push(...we.QrSegment.makeSegments(v)),p),[]);return we.QrCode.encodeSegments(u,Vt[o],s,void 0,void 0,x)},[i,o,s,x]);const{cells:n,margin:r,numCells:l,calculatedImageSettings:c}=y.useMemo(()=>{let w=t.getModules();const u=qt(f,h),p=w.length+u*2,v=Yt(w,T,u,m);return{cells:w,margin:u,numCells:p,calculatedImageSettings:v}},[t,T,m,f,h]);return{qrcode:t,margin:r,cells:n,numCells:l,calculatedImageSettings:c}}var $t=function(){try{new Path2D().addPath(new Path2D)}catch(i){return!1}return!0}(),Jt=y.forwardRef(function(o,s){const f=o,{value:h,size:m=at,level:T=ot,bgColor:x=it,fgColor:t=lt,includeMargin:n=ct,minVersion:r=ut,boostLevel:l,marginSize:c,imageSettings:w}=f,p=Be(f,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:v}=p,A=Be(p,["style"]),N=w==null?void 0:w.src,E=y.useRef(null),F=y.useRef(null),U=y.useCallback(V=>{E.current=V,typeof s=="function"?s(V):s&&(s.current=V)},[s]),[ee,ie]=y.useState(!1),{margin:C,cells:L,numCells:le,calculatedImageSettings:q}=ht({value:h,level:T,minVersion:r,boostLevel:l,includeMargin:n,marginSize:c,imageSettings:w,size:m});y.useEffect(()=>{if(E.current!=null){const V=E.current,_=V.getContext("2d");if(!_)return;let oe=L;const ae=F.current,he=q!=null&&ae!==null&&ae.complete&&ae.naturalHeight!==0&&ae.naturalWidth!==0;he&&q.excavation!=null&&(oe=ft(L,q.excavation));const ce=window.devicePixelRatio||1;V.height=V.width=m*ce;const te=m/le*ce;_.scale(te,te),_.fillStyle=x,_.fillRect(0,0,le,le),_.fillStyle=t,$t?_.fill(new Path2D(dt(oe,C))):L.forEach(function(ye,me){ye.forEach(function(ve,B){ve&&_.fillRect(B+C,me+C,1,1)})}),q&&(_.globalAlpha=q.opacity),he&&_.drawImage(ae,q.x+C,q.y+C,q.w,q.h)}}),y.useEffect(()=>{ie(!1)},[N]);const X=We({height:m,width:m},v);let $=null;return N!=null&&($=y.createElement("img",{src:N,key:N,style:{display:"none"},onLoad:()=>{ie(!0)},ref:F,crossOrigin:q==null?void 0:q.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",We({style:X,height:m,width:m,ref:U,role:"img"},A)),$)});Jt.displayName="QRCodeCanvas";var mt=y.forwardRef(function(o,s){const f=o,{value:h,size:m=at,level:T=ot,bgColor:x=it,fgColor:t=lt,includeMargin:n=ct,minVersion:r=ut,boostLevel:l,title:c,marginSize:w,imageSettings:u}=f,p=Be(f,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:v,cells:A,numCells:N,calculatedImageSettings:E}=ht({value:h,level:T,minVersion:r,boostLevel:l,includeMargin:n,marginSize:w,imageSettings:u,size:m});let F=A,U=null;u!=null&&E!=null&&(E.excavation!=null&&(F=ft(A,E.excavation)),U=y.createElement("image",{href:u.src,height:E.h,width:E.w,x:E.x+v,y:E.y+v,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const ee=dt(F,v);return y.createElement("svg",We({height:m,width:m,viewBox:`0 0 ${N} ${N}`,ref:s,role:"img"},p),!!c&&y.createElement("title",null,c),y.createElement("path",{fill:x,d:`M0,0 h${N}v${N}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:t,d:ee,shapeRendering:"crispEdges"}),U)});mt.displayName="QRCodeSVG";const Xt=({walletAddress:i,amount:o,currency:s,theme:f="light",size:h=200})=>{const[m,T]=y.useState(""),[x,t]=y.useState(null);y.useEffect(()=>{if(!i){t("No wallet address provided");return}try{let c;s==="SOL"||s==="USDC_SOL"?c=`solana:${i}?amount=${o}&spl-token=USDC`:s==="USDT"||s==="USDC"?c=`ethereum:${n(s)}/transfer?address=${i}&uint256=${r(o,s)}`:c=`ethereum:${i}@1?value=${l(o)}`,T(c),t(null)}catch(c){console.error("Error generating QR code:",c),t("Error generating payment QR code")}},[i,o,s]);const n=c=>({USDT:"0xdAC17F958D2ee523a2206206994597C13D831ec7",USDC:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",BNB:"0xB8c77482e45F1F44dE1745F52C74426C631bDD52"})[c]||"",r=(c,w)=>{const u=w==="USDT"||w==="USDC"?6:18;return Math.floor(parseFloat(c)*Math.pow(10,u)).toString()},l=c=>Math.floor(parseFloat(c)*1e18).toString();return a.jsxs("div",{className:"flex flex-col items-center",children:[x?a.jsx("div",{className:"p-4 rounded-lg bg-red-100 mb-3 text-red-700",children:x}):a.jsx("div",{className:"p-4 rounded-lg bg-white mb-3",children:m&&a.jsx(mt,{value:m,size:h,bgColor:f==="dark"?"#374151":"#FFFFFF",fgColor:f==="dark"?"#FFFFFF":"#000000",level:"H",includeMargin:!0})}),a.jsxs("div",{className:"text-center text-sm text-gray-700",children:[a.jsx("p",{className:"font-semibold text-gray-800",children:"Pay with QR Code"}),"Scan with your wallet app to pay"]}),a.jsx("div",{className:"mt-3 w-full"}),a.jsx("div",{className:"mt-4 w-full",children:a.jsxs("div",{className:"p-3 rounded bg-gray-100",children:[a.jsx("h4",{className:"text-sm font-medium mb-2 text-gray-800",children:"Payment Instructions"}),a.jsxs("ol",{className:"text-xs space-y-2 text-gray-600",children:[a.jsx("li",{children:"1. Open your crypto wallet app (MetaMask, Trust Wallet, etc.)"}),a.jsx("li",{children:"2. Scan the QR code above"}),a.jsxs("li",{children:["3. Confirm the payment amount (",o," ",s,")"]}),a.jsx("li",{children:'4. Click "Pay Now" button below after sending the payment'})]})]})})]})},Ie=({status:i,message:o,theme:s="light"})=>{const f=()=>{switch(i){case"processing":return a.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20"});case"success":return a.jsx("div",{className:"rounded-full h-12 w-12 bg-green-100 flex items-center justify-center",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-green-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})});case"error":return a.jsx("div",{className:"rounded-full h-12 w-12 bg-red-100 flex items-center justify-center",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-8 w-8 text-red-500",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})});default:return null}},h=()=>{switch(i){case"processing":return"Processing Payment";case"success":return"Payment Successful";case"error":return"Payment Failed";default:return"Unknown Status"}},m=()=>{switch(i){case"processing":return s==="dark"?"text-blue-300":"text-blue-600";case"success":return s==="dark"?"text-green-300":"text-green-600";case"error":return s==="dark"?"text-red-300":"text-red-600";default:return s==="dark"?"text-gray-300":"text-gray-600"}};return a.jsxs("div",{className:"flex flex-col items-center justify-center py-6",children:[a.jsx("div",{className:"mb-4",children:f()}),a.jsx("h3",{className:`text-xl font-bold mb-2 ${s==="dark"?"text-white":"text-gray-900"}`,children:h()}),a.jsx("p",{className:`text-center ${m()}`,children:o}),i==="processing"&&a.jsx("div",{className:`mt-4 text-xs ${s==="dark"?"text-gray-400":"text-gray-500"}`,children:"This may take a few moments. Please do not close this window."}),i==="success"&&a.jsx("div",{className:`mt-4 p-2 rounded ${s==="dark"?"bg-gray-700":"bg-gray-100"}`,children:a.jsx("p",{className:`text-xs ${s==="dark"?"text-gray-300":"text-gray-600"}`,children:"Your payment has been successfully processed. You will receive a confirmation shortly."})})]})},M={ETHEREUM:"ethereum",BSC:"bsc",TRON:"tron",ALGORAND:"algorand"},S={METAMASK:"metamask",TRONLINK:"tronlink",TRUST_WALLET:"trust_wallet",LUTE:"lute"},ze={[M.ETHEREUM]:{chainId:"0x1",chainName:"Ethereum Mainnet",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:["https://mainnet.infura.io/v3/"],blockExplorerUrls:["https://etherscan.io/"],supportedWallets:[S.METAMASK,S.TRUST_WALLET]},[M.BSC]:{chainId:"0x38",chainName:"BNB Smart Chain",nativeCurrency:{name:"BNB",symbol:"BNB",decimals:18},rpcUrls:["https://bsc-dataseed.binance.org/"],blockExplorerUrls:["https://bscscan.com/"],supportedWallets:[S.METAMASK,S.TRUST_WALLET]},[M.TRON]:{fullHost:"https://api.trongrid.io",explorerUrl:"https://tronscan.org",supportedWallets:[S.TRONLINK]},[M.ALGORAND]:{network:"mainnet",explorerUrl:"https://algoexplorer.io",supportedWallets:[S.LUTE]}},Zt={USDT:{[M.ETHEREUM]:{address:"0xdAC17F958D2ee523a2206206994597C13D831ec7",decimals:6},[M.BSC]:{address:"0x55d398326f99059fF775485246999027B3197955",decimals:18},[M.TRON]:{address:"TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",decimals:6}},USDC:{[M.ETHEREUM]:{address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",decimals:6},[M.BSC]:{address:"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d",decimals:18},[M.TRON]:{address:"TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8",decimals:6}},ALGO:{[M.ALGORAND]:{address:"native",decimals:6}}};let Fe=null;const er=()=>H(this,null,function*(){if(Fe)return Fe;try{const i=yield import("web3");return Fe=i.default||i,Fe}catch(i){throw console.error("Failed to import Web3:",i),new Error("Web3 is required for EVM transactions. Please install web3 package.")}}),Qe=()=>{const i={[S.METAMASK]:!1,[S.TRUST_WALLET]:!1,[S.TRONLINK]:!1,[S.LUTE]:!1};return typeof window!="undefined"&&(i[S.METAMASK]=!!(window.ethereum&&window.ethereum.isMetaMask),i[S.TRONLINK]=!!(window.tronWeb&&window.tronWeb.ready),i[S.TRUST_WALLET]=!!(window.ethereum&&window.ethereum.isTrust),i[S.LUTE]=!!(window.algorand&&window.algorand.isLute)),i},gt=i=>{const o=ze[i];if(!o)return[];const s=Qe();return o.supportedWallets.filter(f=>s[f])},tr=(i,o)=>H(this,null,function*(){switch(i){case S.METAMASK:return yield rr(o);case S.TRONLINK:return yield nr();case S.TRUST_WALLET:return yield sr(o);case S.LUTE:return yield ar();default:throw new Error(`Unsupported wallet type: ${i}`)}}),rr=i=>H(this,null,function*(){if(!window.ethereum||!window.ethereum.isMetaMask)throw new Error("MetaMask is not installed");try{const o=yield window.ethereum.request({method:"eth_requestAccounts"}),s=ze[i];return s&&s.chainId&&(yield pt(s)),{address:o[0],network:i,walletType:S.METAMASK}}catch(o){throw new Error(`Failed to connect MetaMask: ${o.message}`)}}),nr=()=>H(this,null,function*(){if(!window.tronWeb)throw new Error("TronLink is not installed");let i=0;for(;!window.tronWeb.ready&&i<10;)yield new Promise(s=>setTimeout(s,1e3)),i++;if(!window.tronWeb.ready)throw new Error("Please unlock your TronLink wallet");const o=window.tronWeb.defaultAddress.base58;if(!o)throw new Error("No account found in TronLink");return{address:o,network:M.TRON,walletType:S.TRONLINK}}),sr=i=>H(this,null,function*(){if(!window.ethereum||!window.ethereum.isTrust)throw new Error("Trust Wallet is not installed");try{const o=yield window.ethereum.request({method:"eth_requestAccounts"}),s=ze[i];return s&&s.chainId&&(yield pt(s)),{address:o[0],network:i,walletType:S.TRUST_WALLET}}catch(o){throw new Error(`Failed to connect Trust Wallet: ${o.message}`)}}),ar=()=>H(this,null,function*(){if(!window.algorand||!window.algorand.isLute)throw new Error("Lute wallet is not installed");try{return{address:(yield window.algorand.connect())[0],network:M.ALGORAND,walletType:S.LUTE}}catch(i){throw new Error(`Failed to connect Lute wallet: ${i.message}`)}}),pt=i=>H(this,null,function*(){try{yield window.ethereum.request({method:"wallet_switchEthereumChain",params:[{chainId:i.chainId}]})}catch(o){if(o.code===4902)yield window.ethereum.request({method:"wallet_addEthereumChain",params:[i]});else throw o}}),or=(i,o)=>H(this,null,function*(){const{walletType:s,network:f,address:h}=i,{to:m,amount:T,tokenAddress:x,tokenDecimals:t}=o;switch(s){case S.METAMASK:case S.TRUST_WALLET:return yield ir(h,m,T,x,t);case S.TRONLINK:return yield lr(m,T,x,t);case S.LUTE:return yield cr(h,m,T);default:throw new Error(`Unsupported wallet type: ${s}`)}}),ir=(i,o,s,f,h)=>H(this,null,function*(){const m=yield er();if(!window.ethereum)throw new Error("No Ethereum provider found");const T=new m(window.ethereum),x=T.utils.toBN(Math.floor(parseFloat(s)*Math.pow(10,h||18)));if(f&&f!=="native"){const t=[{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"}];return(yield new T.eth.Contract(t,f).methods.transfer(o,x).send({from:i})).transactionHash}else return(yield T.eth.sendTransaction({from:i,to:o,value:x})).transactionHash}),lr=(i,o,s,f)=>H(this,null,function*(){if(!window.tronWeb||!window.tronWeb.ready)throw new Error("TronLink is not ready");const h=Math.floor(parseFloat(o)*Math.pow(10,f||6));return s&&s!=="native"?yield(yield window.tronWeb.contract().at(s)).transfer(i,h).send({feeLimit:1e8,callValue:0}):(yield window.tronWeb.trx.sendTransaction(i,h)).txid}),cr=(i,o,s)=>H(this,null,function*(){if(!window.algorand)throw new Error("Lute wallet is not available");const f=Math.floor(parseFloat(s)*1e6),h={from:i,to:o,amount:f,type:"pay"},m=yield window.algorand.signTransaction(h);return(yield window.algorand.sendTransaction(m)).txId}),ur=i=>({[S.METAMASK]:"https://metamask.io/",[S.TRONLINK]:"https://www.tronlink.org/",[S.TRUST_WALLET]:"https://trustwallet.com/",[S.LUTE]:"https://lute.app/"})[i]||"",wt=({onSelect:i,selected:o,theme:s="light",supportedNetworks:f=[]})=>{const[h,m]=y.useState({}),[T,x]=y.useState(M.ETHEREUM);y.useEffect(()=>{m(Qe())},[]);const t=[{id:"USDT",name:"USDT",description:"Tether USD",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSj0euZAOXsLTJFQxgiKzlX7z8xbfBk-7kmJA&s",networks:[M.ETHEREUM,M.BSC,M.TRON]},{id:"USDC",name:"USDC",description:"USD Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ43MuDqq54iD1ZCRL_uthAPkfwSSL-J5qI_Q&s",networks:[M.ETHEREUM,M.BSC,M.TRON]},{id:"BNB",name:"BNB",description:"Binance Coin",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRHSjyW2sSnBhwztCwVW97i1BtV40g7heMMxg&s",networks:[M.BSC]},{id:"ETH",name:"ETH",description:"Ethereum",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTcyJyRKN0dRJWVZqoLzYgkRHdJsxKGq8nHUw&s",networks:[M.ETHEREUM]},{id:"TRX",name:"TRX",description:"Tron",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKLpLNsGRHbZfCUXAjZLPSp_YFZvX5dMnAoA&s",networks:[M.TRON]},{id:"ALGO",name:"ALGO",description:"Algorand",logo:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR0Yx1Vp8qPQI5XZoJuKfQS8bj_FNiMZGCHqA&s",networks:[M.ALGORAND]}],n=t.filter(u=>f.length===0?!0:u.networks.some(p=>f.includes(p))),r=u=>{const p=t.find(v=>v.id===u);return p?p.networks:[]},l=u=>({[M.ETHEREUM]:"Ethereum",[M.BSC]:"BSC",[M.TRON]:"Tron",[M.ALGORAND]:"Algorand"})[u]||u,c=u=>gt(u).length>0,w=(u,p)=>{var v;x(p),i({currency:u,network:p,tokenConfig:(v=Zt[u])==null?void 0:v[p]})};return a.jsxs("div",{children:[a.jsx("h3",{className:`text-lg font-medium mb-3 ${s==="dark"?"text-white":"text-gray-800"}`,children:"Select Payment Method"}),a.jsx("div",{className:"space-y-3",children:n.map(u=>{const p=r(u.id),v=(o==null?void 0:o.currency)===u.id;return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:`flex items-center p-3 rounded-lg border-2 transition-colors ${v?s==="dark"?"bg-blue-900/30 border-[#7042D2]":"bg-blue-50 border-[#7042D2]":s==="dark"?"bg-gray-700 border-gray-700":"bg-white border-gray-200"}`,children:[a.jsx("div",{className:"flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3",children:a.jsx("img",{src:u.logo,alt:u.name,className:"h-6 w-6"})}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h4",{className:`font-medium ${s==="dark"?"text-white":"text-gray-900"}`,children:u.name}),a.jsx("p",{className:`text-sm ${s==="dark"?"text-gray-300":"text-gray-500"}`,children:u.description})]})]}),p.length>1&&a.jsxs("div",{className:"ml-4 space-y-2",children:[a.jsx("p",{className:`text-sm font-medium ${s==="dark"?"text-gray-300":"text-gray-700"}`,children:"Select Network:"}),a.jsx("div",{className:"grid grid-cols-2 gap-2",children:p.map(A=>{const N=v&&(o==null?void 0:o.network)===A,E=c(A);return a.jsx("button",{onClick:()=>w(u.id,A),disabled:!E,className:`p-2 rounded-md text-sm font-medium transition-colors ${N?"bg-[#7042D2] text-white":E?s==="dark"?"bg-gray-600 text-gray-200 hover:bg-gray-500":"bg-gray-100 text-gray-700 hover:bg-gray-200":s==="dark"?"bg-gray-800 text-gray-500 cursor-not-allowed":"bg-gray-50 text-gray-400 cursor-not-allowed"}`,children:a.jsxs("div",{className:"flex items-center justify-center space-x-1",children:[a.jsx("span",{children:l(A)}),!E&&a.jsx("span",{className:"text-xs",children:"(No wallet)"})]})},A)})})]}),p.length===1&&a.jsx("div",{className:"ml-4",children:a.jsx("button",{onClick:()=>w(u.id,p[0]),disabled:!c(p[0]),className:`w-full p-2 rounded-md text-sm font-medium transition-colors ${v?"bg-[#7042D2] text-white":c(p[0])?s==="dark"?"bg-gray-600 text-gray-200 hover:bg-gray-500":"bg-gray-100 text-gray-700 hover:bg-gray-200":s==="dark"?"bg-gray-800 text-gray-500 cursor-not-allowed":"bg-gray-50 text-gray-400 cursor-not-allowed"}`,children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("span",{children:l(p[0])}),!c(p[0])&&a.jsx("span",{className:"text-xs",children:"No wallet detected"}),v&&a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-4 w-4",viewBox:"0 0 20 20",fill:"currentColor",children:a.jsx("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",clipRule:"evenodd"})})]})})})]},u.id)})}),a.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-50 dark:bg-gray-800",children:[a.jsx("h4",{className:`text-sm font-medium mb-2 ${s==="dark"?"text-white":"text-gray-800"}`,children:"Detected Wallets:"}),a.jsx("div",{className:"space-y-1",children:Object.entries(h).map(([u,p])=>a.jsxs("div",{className:"flex items-center justify-between text-xs",children:[a.jsx("span",{className:`capitalize ${s==="dark"?"text-gray-300":"text-gray-600"}`,children:u.replace("_"," ")}),a.jsx("span",{className:`px-2 py-1 rounded-full ${p?"bg-green-100 text-green-800":"bg-red-100 text-red-800"}`,children:p?"Available":"Not detected"})]},u))})]})]})},dr="data:image/png;base64,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",yt=({isOpen:i,onClose:o,payment:s,paymentStatus:f,selectedPaymentMethod:h,onPaymentMethodSelect:m,onPayment:T,onBack:x,error:t,theme:n="light",merchantName:r,transactionHash:l,walletConnection:c,onConnectWallet:w,testMode:u=!1,supportedNetworks:p=[],availableWallets:v={},supportedWallets:A=[],step:N="select-currency"})=>{const E=C=>parseFloat(C).toFixed(2),F=C=>C?C.length<=14?C:`${C.slice(0,8)}...${C.slice(-6)}`:"",U=C=>({ethereum:"Ethereum",bsc:"BSC",tron:"Tron",algorand:"Algorand"})[C]||C,ee=C=>({[S.METAMASK]:"MetaMask",[S.TRONLINK]:"TronLink",[S.TRUST_WALLET]:"Trust Wallet",[S.LUTE]:"Lute Wallet"})[C]||C,ie=C=>({[S.METAMASK]:"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT3ymr3UNKopfI0NmUY95Dr-0589vG-91KuAA&s",[S.TRONLINK]:"https://www.tronlink.org/images/logo.png",[S.TRUST_WALLET]:"https://trustwallet.com/assets/images/trust_logotype.svg",[S.LUTE]:"https://lute.app/logo.png"})[C]||"";return i?a.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto bg-black/50",children:a.jsx("div",{className:"flex min-h-screen items-center justify-center p-4",children:a.jsxs("div",{className:"relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl bg-white text-gray-800",children:[a.jsxs("div",{className:"flex justify-between items-center mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[a.jsx("div",{className:"flex items-center",children:a.jsx("h2",{className:"text-xl font-bold text-gray-900",children:a.jsx("img",{src:dr,className:"w-32",alt:"Coinley Logo"})})}),a.jsx("button",{onClick:o,className:"text-gray-500 hover:text-gray-700 focus:outline-none",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),a.jsxs("div",{className:"mb-6 bg-[#F1ECFB] p-3 rounded-xl",children:[s&&a.jsxs("div",{className:"mb-6 p-4 rounded-lg",children:[a.jsxs("p",{className:"text-lg text-gray-800 font-semibold",children:["PAY: ",r]}),a.jsxs("div",{className:"flex justify-between items-center mt-2 bg-gray-100 px-3 rounded-lg",children:[a.jsx("span",{className:"font-medium text-gray-700",children:"Amount:"}),a.jsxs("span",{className:"font-bold text-xl text-[#7042D2]",children:["$",E(s.totalAmount||s.amount)]})]}),a.jsx("div",{className:"text-xs mt-1 text-right",children:a.jsxs("span",{className:"text-gray-500",children:["Payment ID: ",s.id?s.id.slice(0,8):"","..."]})})]}),N==="select-currency"&&a.jsx(wt,{onSelect:m,selected:h,theme:n,supportedNetworks:p}),N==="confirm"&&h&&s&&a.jsxs("div",{children:[a.jsxs("div",{className:"p-4 rounded-lg mb-4 bg-gray-100",children:[a.jsx("h3",{className:"text-lg font-medium mb-2 text-gray-800",children:"Payment Details"}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Currency:"}),a.jsx("span",{className:"font-medium",children:h.currency})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Network:"}),a.jsx("span",{className:"font-medium",children:U(h.network)})]}),a.jsxs("div",{className:"flex justify-between",children:[a.jsx("span",{className:"text-[#7042D2] font-semibold",children:"Fee:"}),a.jsx("span",{className:"font-medium",children:"1.75%"})]})]})]}),u?a.jsx("div",{className:"p-4 rounded-lg mb-4 bg-blue-50",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx("div",{className:"bg-[#7042D2] rounded-full p-2 mr-3",children:a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-gray-800",children:"Test Mode Payment"}),a.jsx("p",{className:"text-sm text-gray-600",children:'Click "Pay Now" to simulate a successful payment'})]})]})}):a.jsxs("div",{className:"space-y-3",children:[a.jsx("h4",{className:"font-medium text-gray-800",children:"Select Wallet:"}),A.length===0?a.jsx("div",{className:"p-4 rounded-lg bg-yellow-50",children:a.jsxs("div",{className:"flex items-center",children:[a.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6 text-yellow-500 mr-2",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:a.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-gray-800",children:"No Compatible Wallets"}),a.jsxs("p",{className:"text-sm text-gray-600",children:["No wallets detected for ",U(h.network)," network"]})]})]})}):A.map(C=>a.jsx("div",{className:"p-4 rounded-lg bg-blue-50",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("div",{className:"flex items-center",children:[a.jsx("img",{src:ie(C),alt:ee(C),className:"w-8 h-8 mr-2",onError:L=>{L.target.style.display="none"}}),a.jsxs("div",{children:[a.jsx("h3",{className:"font-medium text-gray-800",children:ee(C)}),a.jsxs("p",{className:"text-sm text-gray-600",children:["Pay with ",ee(C)]})]})]}),(c==null?void 0:c.walletType)===C?a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsx("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),a.jsx("span",{className:"text-sm text-green-600",children:"Connected"})]}):a.jsx("button",{onClick:()=>w(C),className:"py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",children:"Connect"})]})},C)),a.jsx("div",{className:"space-y-2",children:Object.entries(v).filter(([C,L])=>!L).map(([C])=>a.jsx("div",{className:"p-3 rounded-lg bg-gray-50",children:a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsxs("span",{className:"text-sm text-gray-600",children:[ee(C)," not detected"]}),a.jsx("a",{href:ur(C),target:"_blank",rel:"noopener noreferrer",className:"text-sm text-[#7042D2] hover:underline",children:"Install"})]})},C))})]}),a.jsxs("div",{className:"mt-6 grid grid-cols-2 gap-3",children:[a.jsx("button",{type:"button",onClick:x,className:"w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-[#7042D2] font-medium rounded-md",children:"Back"}),a.jsx("button",{type:"button",onClick:T,className:"w-full py-2 px-4 bg-[#7042D2] hover:bg-[#7042D2] text-white font-medium rounded-md",disabled:!u&&!c,children:"Pay Now"})]})]}),N==="processing"&&a.jsx(Ie,{status:"processing",theme:n,message:"Processing your payment..."}),N==="success"&&a.jsxs("div",{children:[a.jsx(Ie,{status:"success",theme:n,message:"Payment successful!"}),l&&a.jsxs("div",{className:"mt-4 p-3 rounded-lg bg-gray-100",children:[a.jsx("p",{className:"text-xs text-gray-600 mb-1",children:"Transaction Hash:"}),a.jsx("p",{className:"text-sm font-mono break-all text-gray-800",children:F(l)}),h&&a.jsx("a",{href:`${fr(h.network)}/tx/${l}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-[#7042D2] mt-2 inline-block",children:"View on Explorer →"})]})]}),N==="error"&&a.jsxs("div",{children:[a.jsx(Ie,{status:"error",theme:n,message:t||"An error occurred while processing your payment."}),a.jsx("button",{type:"button",onClick:x,className:"mt-4 w-full py-2 px-4 bg-gray-200 hover:bg-gray-300 text-gray-800 font-medium rounded-md",children:"Try Again"})]})]}),a.jsx("div",{className:"text-center text-xs text-gray-500",children:a.jsxs("p",{children:["Powered by ",a.jsx("span",{className:"text-[#7042D2]",children:"Coinley"})," - Secure Cryptocurrency Payments"]})})]})})}):null},fr=i=>({ethereum:"https://etherscan.io",bsc:"https://bscscan.com",tron:"https://tronscan.org",algorand:"https://algoexplorer.io"})[i]||"https://etherscan.io",vt=y.forwardRef(({apiKey:i,apiSecret:o,apiUrl:s,customerEmail:f,merchantName:h="Merchant",merchantWalletAddresses:m={},onSuccess:T,onError:x,onClose:t,theme:n,autoOpen:r=!1,debug:l=!1,testMode:c=!1,supportedNetworks:w=[],preferredNetwork:u=M.ETHEREUM,preferredWallet:p=S.METAMASK},v)=>{const A=Bt(),{theme:N}=_t(),[E,F]=y.useState(r),[U,ee]=y.useState(null),[ie,C]=y.useState("idle"),[L,le]=y.useState(null),[q,X]=y.useState(null),[$,V]=y.useState(null),[_,oe]=y.useState(null),[ae,he]=y.useState({}),[ce,te]=y.useState("select-currency");i||(A==null||A.apiKey),o||(A==null||A.apiSecret),s||(A==null||A.apiUrl);const ye=n||N,me=l||(A==null?void 0:A.debug),ve=w.length>0?w:[M.ETHEREUM,M.BSC,M.TRON,M.ALGORAND];y.useImperativeHandle(v,()=>({open:D=>{Ve(D)},close:()=>{xe()},getPayment:()=>U,getWalletConnection:()=>_}));const B=(D,G)=>{me&&console.log(`[Coinley SDK] ${D}`,G)};y.useEffect(()=>{if(typeof window!="undefined"){const D=Qe();he(D),B("Available wallets detected:",D)}},[me]);const Ve=D=>H(this,null,function*(){if(!D||!D.amount){X("Payment amount is required"),x&&x(new Error("Payment amount is required"));return}C("loading"),F(!0),te("select-currency");try{B("Creating payment with details:",D);const G=yield Le({amount:D.amount,currency:D.currency||"USDT",network:D.network||u,customerEmail:D.customerEmail||f,callbackUrl:D.callbackUrl,metadata:D.metadata||{},merchantWalletAddresses:de(de({},m),D.merchantWalletAddresses)});B("Payment created:",G),ee(G.payment),C("idle"),X(null),B("Payment created and state updated")}catch(G){B("Error creating payment:",G),X(G.message||"Failed to create payment"),C("error"),x&&x(G)}}),xe=()=>{F(!1),V(null),oe(null),le(null),te("select-currency"),t&&t()},ke=D=>{B("Payment method selected:",D),le(D),te("confirm")},Ee=()=>{ce==="confirm"&&(te("select-currency"),oe(null))},Me=D=>H(this,null,function*(){if(!L){X("Please select a payment method first");return}try{B("Connecting wallet:",{walletType:D,network:L.network});const G=yield tr(D,L.network);oe(G),X(null),B("Wallet connected successfully:",G)}catch(G){B("Wallet connection error:",G),X(G.message||"Failed to connect wallet")}}),be=()=>H(this,null,function*(){var D,G;if(!U||!L){X("Missing payment information");return}if(!_&&!c){X("Please connect your wallet first");return}B("Starting payment process..."),C("loading"),V(null);try{let re;if(c)B("Test mode: Generating mock transaction..."),re=`test_${Date.now().toString(16)}_${Math.random().toString(16).substring(2,10)}`;else{const ue=m[L.network];if(!ue)throw new Error(`No merchant wallet address configured for ${L.network}`);B("Sending transaction through wallet..."),re=yield or(_,{to:ue,amount:U.amount,tokenAddress:(D=L.tokenConfig)==null?void 0:D.address,tokenDecimals:(G=L.tokenConfig)==null?void 0:G.decimals})}B("Transaction hash:",re),V(re),B("Processing payment with backend...");const Ne=yield se({paymentId:U.id,transactionHash:re,network:L.network,currency:L.currency,senderAddress:_==null?void 0:_.address});B("Payment processed successfully:",Ne),C("success"),te("success"),T&&(B("Calling onSuccess callback..."),T(U.id,re,{network:L.network,currency:L.currency,amount:U.amount}))}catch(re){B("Payment error:",re),X(re.message||"Failed to process payment"),C("error"),te("error"),x&&x(re)}}),Ge=()=>L?gt(L.network):[];return a.jsx(a.Fragment,{children:E&&a.jsx(yt,{isOpen:E,onClose:xe,payment:U,paymentStatus:ie,selectedPaymentMethod:L,onPaymentMethodSelect:ke,onPayment:be,onBack:Ee,error:q,theme:ye,merchantName:h,transactionHash:$,walletConnection:_,onConnectWallet:Me,testMode:c,supportedNetworks:ve,availableWallets:ae,supportedWallets:Ge(),step:ce})})});vt.displayName="CoinleyCheckout";const hr={apiUrl:"https://coinleyserver-production.up.railway.app",debug:!1,testMode:!1,theme:"light"},mr="0.3.0";P.CoinleyCheckout=vt,P.CoinleyModal=yt,P.CoinleyProvider=zt,P.DEFAULT_CONFIG=hr,P.PaymentMethods=wt,P.PaymentStatus=Ie,P.QRCode=Xt,P.ThemeProvider=Wt,P.VERSION=mr,P.connectWallet=It,P.createPayment=Le,P.getPayment=Se,P.isMetaMaskInstalled=pe,P.processPayment=se,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
41
+ //# sourceMappingURL=coinley-checkout.umd.js.map