spaark-payapi-sdk 1.0.1 → 1.2.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.
package/dist/index.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { D as DepositRequest, a as DepositResponse, P as PayoutRequest, b as PayoutResponse, c as PaymentPageRequest, d as PaymentPageResponse, R as RefundRequest, e as RefundResponse, T as TransactionStatusResponse, f as PollOptions, g as TransactionFilters, A as ActionResponse, C as Currency, h as Correspondent, i as TransactionLimits, j as CorrespondentInfo, F as FailureReason } from './react-pjDvSSJA.mjs';
3
- export { k as CORRESPONDENTS, l as CORRESPONDENT_INFO, m as CorrespondentFeature, n as DEFAULT_LIMITS, o as DepositFailureCode, p as FinancialAddress, M as MMOAccount, q as PawapayTestDashboard, r as PawapayTestDashboardProps, s as PayoutFailureCode, t as TransactionStatus } from './react-pjDvSSJA.mjs';
2
+ import { D as DepositRequest, a as DepositResponse, P as PayoutRequest, b as PayoutResponse, c as PaymentPageRequest, d as PaymentPageResponse, R as RefundRequest, e as RefundResponse, T as TransactionStatusResponse, f as PollOptions, g as TransactionFilters, A as ActionResponse, C as Currency, h as Correspondent, i as TransactionLimits, j as CorrespondentInfo, F as FailureReason } from './react-ByYFxpk4.mjs';
3
+ export { k as CORRESPONDENTS, l as CORRESPONDENT_INFO, m as CorrespondentFeature, n as DEFAULT_LIMITS, o as DepositFailureCode, p as FinancialAddress, M as MMOAccount, q as PawapayTestDashboard, r as PawapayTestDashboardProps, s as PayoutFailureCode, t as TransactionStatus } from './react-ByYFxpk4.mjs';
4
4
  import 'react/jsx-runtime';
5
5
 
6
6
  type Environment = 'sandbox' | 'production';
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
- import { D as DepositRequest, a as DepositResponse, P as PayoutRequest, b as PayoutResponse, c as PaymentPageRequest, d as PaymentPageResponse, R as RefundRequest, e as RefundResponse, T as TransactionStatusResponse, f as PollOptions, g as TransactionFilters, A as ActionResponse, C as Currency, h as Correspondent, i as TransactionLimits, j as CorrespondentInfo, F as FailureReason } from './react-pjDvSSJA.js';
3
- export { k as CORRESPONDENTS, l as CORRESPONDENT_INFO, m as CorrespondentFeature, n as DEFAULT_LIMITS, o as DepositFailureCode, p as FinancialAddress, M as MMOAccount, q as PawapayTestDashboard, r as PawapayTestDashboardProps, s as PayoutFailureCode, t as TransactionStatus } from './react-pjDvSSJA.js';
2
+ import { D as DepositRequest, a as DepositResponse, P as PayoutRequest, b as PayoutResponse, c as PaymentPageRequest, d as PaymentPageResponse, R as RefundRequest, e as RefundResponse, T as TransactionStatusResponse, f as PollOptions, g as TransactionFilters, A as ActionResponse, C as Currency, h as Correspondent, i as TransactionLimits, j as CorrespondentInfo, F as FailureReason } from './react-ByYFxpk4.js';
3
+ export { k as CORRESPONDENTS, l as CORRESPONDENT_INFO, m as CorrespondentFeature, n as DEFAULT_LIMITS, o as DepositFailureCode, p as FinancialAddress, M as MMOAccount, q as PawapayTestDashboard, r as PawapayTestDashboardProps, s as PayoutFailureCode, t as TransactionStatus } from './react-ByYFxpk4.js';
4
4
  import 'react/jsx-runtime';
5
5
 
6
6
  type Environment = 'sandbox' | 'production';
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var zod=require('zod'),te=require('axios'),crypto$1=require('crypto'),uuid=require('uuid'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var te__default=/*#__PURE__*/_interopDefault(te);var D={timeout:3e4,retries:3,retryDelay:1e3,logLevel:"info",sandboxUrl:"https://api.sandbox.pawapay.io",productionUrl:"https://api.pawapay.io"};var x={VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PHONE:"INVALID_PHONE",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",AMOUNT_TOO_LOW:"AMOUNT_TOO_LOW",AMOUNT_TOO_HIGH:"AMOUNT_TOO_HIGH",LIMIT_EXCEEDED:"LIMIT_EXCEEDED",DUPLICATE:"DUPLICATE",MMO_UNAVAILABLE:"MMO_UNAVAILABLE",TIMEOUT:"TIMEOUT",UNAUTHORIZED:"UNAUTHORIZED",RATE_LIMITED:"RATE_LIMITED",SERVER_ERROR:"SERVER_ERROR",NETWORK_ERROR:"NETWORK_ERROR",NOT_FOUND:"NOT_FOUND",REFUND_NOT_ALLOWED:"REFUND_NOT_ALLOWED"},_e=[{pawapayCode:"INVALID_PHONE_NUMBER",sdkCode:x.INVALID_PHONE,httpStatus:400,retryable:false,message:"Invalid phone number format"},{pawapayCode:"INSUFFICIENT_FUNDS",sdkCode:x.INSUFFICIENT_FUNDS,httpStatus:402,retryable:false,message:"Insufficient funds in account"},{pawapayCode:"AMOUNT_TOO_LOW",sdkCode:x.AMOUNT_TOO_LOW,httpStatus:400,retryable:false,message:"Amount below minimum"},{pawapayCode:"AMOUNT_TOO_HIGH",sdkCode:x.AMOUNT_TOO_HIGH,httpStatus:400,retryable:false,message:"Amount exceeds maximum"},{pawapayCode:"TRANSACTION_LIMIT_EXCEEDED",sdkCode:x.LIMIT_EXCEEDED,httpStatus:400,retryable:false,message:"Daily or monthly limit exceeded"},{pawapayCode:"DUPLICATE_TRANSACTION",sdkCode:x.DUPLICATE,httpStatus:409,retryable:false,message:"Transaction ID already used"},{pawapayCode:"CORRESPONDENT_UNAVAILABLE",sdkCode:x.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"CORRESPONDENT_TEMPORARILY_UNAVAILABLE",sdkCode:x.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"TIMEOUT",sdkCode:x.TIMEOUT,httpStatus:408,retryable:true,message:"Transaction timed out"},{pawapayCode:"INVALID_API_KEY",sdkCode:x.UNAUTHORIZED,httpStatus:401,retryable:false,message:"Invalid or expired API key"},{pawapayCode:"RATE_LIMIT_EXCEEDED",sdkCode:x.RATE_LIMITED,httpStatus:429,retryable:true,message:"Too many requests"},{pawapayCode:"INTERNAL_ERROR",sdkCode:x.SERVER_ERROR,httpStatus:500,retryable:true,message:"Pawapay internal error"},{pawapayCode:"REFUND_NOT_ALLOWED",sdkCode:x.REFUND_NOT_ALLOWED,httpStatus:400,retryable:false,message:"Refund not allowed for this transaction"}];function pe(i){return _e.find(e=>e.pawapayCode===i)}var l=class i extends Error{constructor(e,t,r,o){super(e),this.name="PawapayError",this.code=t,this.statusCode=r,this.failureReason=o?.failureReason,this.retryable=o?.retryable??false,this.originalError=o?.originalError,Error.captureStackTrace&&Error.captureStackTrace(this,i);}static fromPawapayResponse(e,t,r){let o=pe(e);return o?new i(t??o.message,o.sdkCode,o.httpStatus,{retryable:o.retryable,originalError:r}):new i(t??"Unknown error occurred",x.SERVER_ERROR,500,{retryable:false,originalError:r})}static validation(e){return new i(e,x.VALIDATION_ERROR,400,{retryable:false})}static network(e,t){return new i(e,x.NETWORK_ERROR,0,{retryable:true,originalError:t})}static timeout(e="Request timed out"){return new i(e,x.TIMEOUT,408,{retryable:true})}static unauthorized(e="Invalid or expired API key"){return new i(e,x.UNAUTHORIZED,401,{retryable:false})}static notFound(e="Resource not found"){return new i(e,x.NOT_FOUND,404,{retryable:false})}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,failureReason:this.failureReason,retryable:this.retryable}}};var Ue=zod.z.object({apiKey:zod.z.string().min(1,"API key is required"),environment:zod.z.enum(["sandbox","production"]),baseUrl:zod.z.string().url().optional(),callbackUrl:zod.z.string().url().optional(),timeout:zod.z.number().positive().max(6e5).optional(),retries:zod.z.number().int().min(0).max(10).optional(),retryDelay:zod.z.number().positive().max(6e4).optional(),logLevel:zod.z.enum(["debug","info","warn","error","none"]).optional()});function me(i){let e=Ue.safeParse(i);if(!e.success){let o=e.error.errors.map(u=>`${u.path.join(".")}: ${u.message}`);throw l.validation(`Invalid SDK configuration: ${o.join(", ")}`)}let t=e.data,r=t.baseUrl??(t.environment==="production"?D.productionUrl:D.sandboxUrl);return {apiKey:t.apiKey,environment:t.environment,baseUrl:r,callbackUrl:t.callbackUrl,timeout:t.timeout??D.timeout,retries:t.retries??D.retries,retryDelay:t.retryDelay??D.retryDelay,logLevel:t.logLevel??D.logLevel}}function ge(){let i=typeof process<"u"?process.env:{},e={};if(i.PAWAPAY_API_KEY&&(e.apiKey=i.PAWAPAY_API_KEY),i.PAWAPAY_ENVIRONMENT){let t=i.PAWAPAY_ENVIRONMENT.toLowerCase();(t==="production"||t==="sandbox")&&(e.environment=t);}if(i.PAWAPAY_BASE_URL&&(e.baseUrl=i.PAWAPAY_BASE_URL),i.PAWAPAY_CALLBACK_URL&&(e.callbackUrl=i.PAWAPAY_CALLBACK_URL),i.PAWAPAY_TIMEOUT){let t=parseInt(i.PAWAPAY_TIMEOUT,10);isNaN(t)||(e.timeout=t);}if(i.PAWAPAY_RETRIES){let t=parseInt(i.PAWAPAY_RETRIES,10);isNaN(t)||(e.retries=t);}if(i.PAWAPAY_LOG_LEVEL){let t=i.PAWAPAY_LOG_LEVEL.toLowerCase();["debug","info","warn","error","none"].includes(t)&&(e.logLevel=t);}return e}var Fe={maxAttempts:3,initialDelay:1e3,maxDelay:3e4,backoffMultiplier:2};function je(i){return new Promise(e=>setTimeout(e,i))}function $e(i,e){let t=e.initialDelay*Math.pow(e.backoffMultiplier,i-1),r=Math.random()*.3*t;return Math.min(t+r,e.maxDelay)}async function $(i,e={},t){let r={...Fe,...e},o;for(let u=1;u<=r.maxAttempts;u++)try{return await i()}catch(g){if(o=g instanceof Error?g:new Error(String(g)),!(g instanceof l?g.retryable:We(g))||u===r.maxAttempts)throw g;let p=$e(u,r);t?.warn(`Attempt ${u}/${r.maxAttempts} failed, retrying in ${Math.round(p)}ms`,{error:o.message}),await je(p);}throw o??new Error("Retry failed without error")}function We(i){return i instanceof l?i.retryable:i instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","Network Error","timeout","socket hang up"].some(t=>i.message.includes(t)||i.code===t):false}var q=class i{constructor(e){this.logger=e.logger,this.retries=e.retries,this.retryDelay=e.retryDelay,this.client=te__default.default.create({baseURL:e.baseUrl,timeout:e.timeout,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`}}),this.setupInterceptors();}setupInterceptors(){this.client.interceptors.request.use(e=>(this.logger.debug(`${e.method?.toUpperCase()} ${e.url}`,{params:e.params}),e),e=>(this.logger.error("Request error",e),Promise.reject(e))),this.client.interceptors.response.use(e=>(this.logger.debug(`${e.config.method?.toUpperCase()} ${e.config.url} -> ${e.status}`,{data:e.data}),e),e=>(te__default.default.isAxiosError(e)&&this.logger.error(`Request failed: ${e.config?.method?.toUpperCase()} ${e.config?.url}`,{status:e.response?.status,data:e.response?.data}),Promise.reject(e)));}handleError(e){if(te__default.default.isAxiosError(e)){if(e.code==="ECONNABORTED"||e.message.includes("timeout"))throw l.timeout();if(!e.response)throw l.network(e.message||"Network error",e);let{status:t,data:r}=e.response,o=r;if(t===401)throw l.unauthorized();if(t===404)throw l.notFound();let u=o?.errorCode??o?.rejectionReason?.rejectionCode;throw u?l.fromPawapayResponse(u,o?.errorMessage??o?.rejectionReason?.rejectionMessage,e):new l(o?.errorMessage??`HTTP error ${t}`,"SERVER_ERROR",t,{retryable:t>=500,originalError:e})}throw e instanceof l?e:l.network(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}async get(e,t){return $(async()=>{try{return (await this.client.get(e,t)).data}catch(r){this.handleError(r);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async post(e,t,r){return $(async()=>{try{return (await this.client.post(e,t,r)).data}catch(o){this.handleError(o);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async put(e,t,r){return $(async()=>{try{return (await this.client.put(e,t,r)).data}catch(o){this.handleError(o);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async delete(e,t){return $(async()=>{try{return (await this.client.delete(e,t)).data}catch(r){this.handleError(r);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}static fromConfig(e,t){return new i({baseUrl:e.baseUrl,apiKey:e.apiKey,timeout:e.timeout,retries:e.retries,retryDelay:e.retryDelay,logger:t})}};var ye={debug:0,info:1,warn:2,error:3,none:4},W=class{constructor(e,t="info"){this.prefix=e,this.level=t;}setLevel(e){this.level=e;}shouldLog(e){return ye[e]>=ye[this.level]}formatMessage(e,t){return `[${new Date().toISOString()}] ${e.toUpperCase().padEnd(5)} [${this.prefix}] ${t}`}sanitize(e){if(e==null||typeof e=="string"||typeof e!="object")return e;if(Array.isArray(e))return e.map(o=>this.sanitize(o));let t={},r=["apiKey","api_key","authorization","password","secret","token"];for(let[o,u]of Object.entries(e))r.some(g=>o.toLowerCase().includes(g))?t[o]="[REDACTED]":typeof u=="object"&&u!==null?t[o]=this.sanitize(u):t[o]=u;return t}debug(e,t){if(this.shouldLog("debug")){let r=this.formatMessage("debug",e);t!==void 0?console.debug(r,this.sanitize(t)):console.debug(r);}}info(e,t){if(this.shouldLog("info")){let r=this.formatMessage("info",e);t!==void 0?console.info(r,this.sanitize(t)):console.info(r);}}warn(e,t){if(this.shouldLog("warn")){let r=this.formatMessage("warn",e);t!==void 0?console.warn(r,this.sanitize(t)):console.warn(r);}}error(e,t){if(this.shouldLog("error")){let r=this.formatMessage("error",e);t!==void 0?console.error(r,this.sanitize(t)):console.error(r);}}};var U=["MTN_MOMO_CMR","ORANGE_CMR","MTN_MOMO_COG","AIRTEL_COG","MTN_MOMO_GAB","AIRTEL_GAB"],F={MTN_MOMO_CMR:{correspondent:"MTN_MOMO_CMR",name:"MTN Mobile Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(67|68|65[0-4])\d{6}$/},ORANGE_CMR:{correspondent:"ORANGE_CMR",name:"Orange Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(69|65[5-9])\d{6}$/},MTN_MOMO_COG:{correspondent:"MTN_MOMO_COG",name:"MTN Mobile Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^242(04|05|06)\d{7}$/},AIRTEL_COG:{correspondent:"AIRTEL_COG",name:"Airtel Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout"],phoneRegex:/^242(01|02|03)\d{7}$/},MTN_MOMO_GAB:{correspondent:"MTN_MOMO_GAB",name:"MTN Mobile Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^241(06|07)\d{6}$/},AIRTEL_GAB:{correspondent:"AIRTEL_GAB",name:"Airtel Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout"],phoneRegex:/^241(04|05)\d{6}$/}},V={MTN_MOMO_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},ORANGE_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},MTN_MOMO_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},MTN_MOMO_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6}};var Ge=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum(U),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),preAuthorisationCode:zod.z.string().optional(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),qe=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum(U),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),Ve=zod.z.object({depositId:zod.z.string().uuid(),returnUrl:zod.z.string().url(),phoneNumber:zod.z.string().optional(),amountDetails:zod.z.object({amount:zod.z.number().positive(),currency:zod.z.string().length(3)}).optional(),language:zod.z.enum(["EN","FR"]).optional(),country:zod.z.string().length(3).optional(),reason:zod.z.string().max(50).optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),Be=zod.z.object({depositId:zod.z.string().uuid(),amount:zod.z.number().positive("Amount must be positive"),transactionId:zod.z.string().uuid()});function Ke(i){return new Promise(e=>setTimeout(e,i))}var B=class{constructor(e,t){this.httpClient=e;this.logger=t;}async initiateDeposit(e){let t=Ge.parse(e),r={depositId:t.transactionId,amount:t.amount.toString(),currency:t.currency,payer:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},preAuthorisationCode:t.preAuthorisationCode,clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 deposit ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let o=await this.httpClient.post("/v2/deposits",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Deposit ${o.depositId} status: ${o.status}`),{depositId:o.depositId,status:o.status,created:o.created??new Date().toISOString(),nextStep:o.nextStep,redirectUrl:o.redirectUrl}}async initiatePayout(e){let t=qe.parse(e),r={payoutId:t.transactionId,amount:t.amount.toString(),currency:t.currency,recipient:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 payout ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let o=await this.httpClient.post("/v2/payouts",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Payout ${o.payoutId} status: ${o.status}`),{payoutId:o.payoutId,status:o.status,created:o.created??new Date().toISOString()}}async createPaymentPage(e){let t=Ve.parse(e),r={depositId:t.depositId,returnUrl:t.returnUrl,phoneNumber:t.phoneNumber,amountDetails:t.amountDetails?{amount:t.amountDetails.amount.toString(),currency:t.amountDetails.currency}:void 0,language:t.language,country:t.country,reason:t.reason,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Creating payment page for deposit ${t.depositId}`);let o=await this.httpClient.post("/v2/paymentpage",r);return this.logger.info(`Payment page created: ${o.redirectUrl}`),{redirectUrl:o.redirectUrl}}async refund(e){let t=Be.parse(e),r={refundId:t.transactionId,depositId:t.depositId,amount:t.amount.toString()};this.logger.info(`Initiating refund ${t.transactionId}`,{depositId:t.depositId,amount:t.amount});let o=await this.httpClient.post("/refunds",r);if(o.status==="REJECTED"&&o.rejectionReason)throw l.fromPawapayResponse(o.rejectionReason.rejectionCode,o.rejectionReason.rejectionMessage);return this.logger.info(`Refund ${o.refundId} status: ${o.status}`),{refundId:o.refundId,depositId:t.depositId,status:o.status,amount:t.amount,created:o.created??new Date().toISOString()}}async checkDepositStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid deposit ID format");let t=await this.httpClient.get(`/v2/deposits/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Deposit ${e} not found`);let r=t.data;return {depositId:r.depositId,status:r.status,amount:r.amount,currency:r.currency,country:r.country,payer:r.payer,created:r.created,customerMessage:r.customerMessage,clientReferenceId:r.clientReferenceId,providerTransactionId:r.providerTransactionId,failureReason:r.failureReason,metadata:r.metadata}}async checkPayoutStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");let t=await this.httpClient.get(`/v2/payouts/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Payout ${e} not found`);let r=t.data;return {payoutId:r.payoutId,status:r.status,amount:r.amount,currency:r.currency,country:r.country,recipient:r.recipient,created:r.created,customerMessage:r.customerMessage,clientReferenceId:r.clientReferenceId,providerTransactionId:r.providerTransactionId,failureReason:r.failureReason,metadata:r.metadata}}async checkStatus(e){try{return await this.checkDepositStatus(e)}catch(t){if(t instanceof l&&t.code==="NOT_FOUND")return await this.checkPayoutStatus(e);throw t}}async pollUntilComplete(e,t={}){let{interval:r=5e3,maxAttempts:o=12,onStatusChange:u}=t,g;for(let p=1;p<=o;p++){let P=await this.checkStatus(e);if(P.status!==g&&(g=P.status,u?.(P.status)),P.status==="COMPLETED"||P.status==="FAILED")return P;p<o&&await Ke(r);}return await this.checkStatus(e)}async listDeposits(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/deposits",{params:t})).map(o=>({depositId:o.depositId??"",status:o.status,created:o.created}))}async listPayouts(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/payouts",{params:t})).map(o=>({payoutId:o.payoutId??"",status:o.status,created:o.created}))}async resendDepositCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid deposit ID format");this.logger.info(`Resending callback for deposit ${e}`);let t=await this.httpClient.post(`/v2/deposits/${e}/resend-callback`,{});return this.logger.info(`Resend callback for deposit ${e}: ${t.status}`),t}async resendPayoutCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");this.logger.info(`Resending callback for payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/resend-callback`,{});return this.logger.info(`Resend callback for payout ${e}: ${t.status}`),t}async cancelEnqueuedPayout(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid payout ID format");this.logger.info(`Cancelling enqueued payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/cancel`,{});return this.logger.info(`Cancel payout ${e}: ${t.status}`),t}};var fe=zod.z.object({name:zod.z.string().min(1).max(100),description:zod.z.string().max(500).optional(),price:zod.z.number().positive(),currency:zod.z.enum(["XAF","XOF","USD"]),metadata:zod.z.record(zod.z.unknown()).optional()}),He=zod.z.object({productId:zod.z.string().uuid(),domain:zod.z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\.[a-zA-Z]{2,}$/)}),K=class{constructor(e){this.logger=e;this.products=new Map;}async create(e){let t=fe.parse(e),r=crypto.randomUUID(),o=new Date().toISOString(),u={id:r,name:t.name,description:t.description,price:t.price,currency:t.currency,domains:[],created:o,updated:o,metadata:t.metadata};return this.products.set(r,u),this.logger.info(`Created product ${r}`,{name:t.name}),this.toProduct(u)}async get(e){let t=this.products.get(e);if(!t)throw l.notFound(`Product ${e} not found`);return this.toProduct(t)}async list(){return Array.from(this.products.values()).map(e=>this.toProduct(e))}async update(e,t){let r=this.products.get(e);if(!r)throw l.notFound(`Product ${e} not found`);let o=fe.partial().parse(t),u={...r,...o,updated:new Date().toISOString()};return this.products.set(e,u),this.logger.info(`Updated product ${e}`),this.toProduct(u)}async delete(e){if(!this.products.get(e))throw l.notFound(`Product ${e} not found`);this.products.delete(e),this.logger.info(`Deleted product ${e}`);}async addDomain(e){let t=He.parse(e),r=this.products.get(t.productId);if(!r)throw l.notFound(`Product ${t.productId} not found`);if(r.domains.includes(t.domain))throw l.validation(`Domain ${t.domain} already added to product`);return r.domains.push(t.domain),r.updated=new Date().toISOString(),this.logger.info(`Added domain ${t.domain} to product ${t.productId}`),this.toProduct(r)}async removeDomain(e,t){let r=this.products.get(e);if(!r)throw l.notFound(`Product ${e} not found`);let o=r.domains.indexOf(t);if(o===-1)throw l.notFound(`Domain ${t} not found in product`);return r.domains.splice(o,1),r.updated=new Date().toISOString(),this.logger.info(`Removed domain ${t} from product ${e}`),this.toProduct(r)}toProduct(e){return {id:e.id,name:e.name,description:e.description,price:e.price,currency:e.currency,domains:[...e.domains],created:e.created,updated:e.updated}}};var H=class{constructor(e,t,r){this.httpClient=e;this.logger=t;this.webhookSecret=r?.webhookSecret;}setWebhookSecret(e){this.webhookSecret=e;}verifySignature(e,t){if(!this.webhookSecret)return this.logger.warn("Webhook secret not configured, skipping signature verification"),true;if(!t)return this.logger.warn("No signature provided in webhook request"),false;try{let r=crypto$1.createHmac("sha256",this.webhookSecret).update(e,"utf8").digest("hex"),o=Buffer.from(t,"hex"),u=Buffer.from(r,"hex");return o.length!==u.length?!1:crypto$1.timingSafeEqual(o,u)}catch(r){return this.logger.error("Error verifying webhook signature",r),false}}parseEvent(e){try{let t=JSON.parse(e);if(!t.eventId||!t.eventType||!t.timestamp)throw new Error("Invalid webhook event structure");return t}catch(t){throw l.validation(`Failed to parse webhook event: ${t instanceof Error?t.message:"Unknown error"}`)}}constructEvent(e,t){if(!this.verifySignature(e,t))throw l.unauthorized("Invalid webhook signature");return this.parseEvent(e)}async registerCallback(e){this.logger.info(`Registering callback URL: ${e}`),await this.httpClient.post("/webhooks",{url:e}),this.logger.info("Callback URL registered successfully");}async unregisterCallback(){this.logger.info("Unregistering callback URL"),await this.httpClient.delete("/webhooks"),this.logger.info("Callback URL unregistered successfully");}isDepositEvent(e){return e.startsWith("deposit.")}isPayoutEvent(e){return e.startsWith("payout.")}isRefundEvent(e){return e.startsWith("refund.")}isSuccessEvent(e){return e.endsWith(".completed")}isFailureEvent(e){return e.endsWith(".failed")}};var z=class{constructor(e,t){this.httpClient=e;this.logger=t;}generateTransactionId(){return uuid.v4()}validateTransactionId(e){return uuid.validate(e)&&uuid.version(e)===4}async getActiveConfiguration(e){let t={};e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching active configuration",e);let r=await this.httpClient.get("/v2/active-conf",{params:Object.keys(t).length>0?t:void 0});return this.logger.info(`Retrieved configuration for ${r.countries.length} countries`),r}async getProviderAvailability(e){let t={};return e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching provider availability",e),await this.httpClient.get("/v2/availability",{params:Object.keys(t).length>0?t:void 0})}async predictProvider(e){this.logger.info("Predicting provider for phone number");let t=await this.httpClient.post("/v2/predict-provider",{phoneNumber:e});return this.logger.info(`Predicted provider: ${t.provider} (${t.country})`),t}async getPublicKeys(){this.logger.info("Fetching public keys");let e=await this.httpClient.get("/v2/public-key/http");return this.logger.info(`Retrieved ${e.length} public keys`),e}async getTransactionLimits(e){try{let t=await this.getActiveConfiguration();for(let r of t.countries)for(let o of r.providers)if(o.provider===e){let u=o.currencies[0];if(u?.operationTypes){let g=u.operationTypes.DEPOSIT,y=u.operationTypes.PAYOUT,p=V[e];return {minDeposit:g?.minAmount?parseFloat(g.minAmount):p.minDeposit,maxDeposit:g?.maxAmount?parseFloat(g.maxAmount):p.maxDeposit,minPayout:y?.minAmount?parseFloat(y.minAmount):p.minPayout,maxPayout:y?.maxAmount?parseFloat(y.maxAmount):p.maxPayout,currency:u.currency,dailyLimit:p.dailyLimit}}}}catch(t){this.logger.warn(`Failed to fetch live limits for ${e}, using defaults`,t);}return V[e]}async checkMMOAvailability(e){try{let t=await this.getProviderAvailability();for(let r of t){let o=r.providers.find(u=>u.provider===e);if(o){let u=o.operationTypes.find(h=>h.operationType==="DEPOSIT"),g=o.operationTypes.find(h=>h.operationType==="PAYOUT"),y=u?.status==="OPERATIONAL"||g?.status==="OPERATIONAL",p=u?.status==="DELAYED"||g?.status==="DELAYED",P=u?.status==="CLOSED"&&g?.status==="CLOSED";return {correspondent:e,available:y||p,degraded:p,message:P?"Provider is currently closed":void 0}}}return {correspondent:e,available:!1,degraded:!1,message:"Correspondent not found in availability list"}}catch(t){return this.logger.warn(`Failed to check MMO availability for ${e}`,t),{correspondent:e,available:false,degraded:true,message:"Unable to verify availability"}}}formatPhoneNumber(e,t){let r=e.replace(/\D/g,"");r.startsWith("00")&&(r=r.slice(2));let u={CMR:"237",COG:"242",GAB:"241",ZMB:"260",GHA:"233",KEN:"254",TZA:"255",UGA:"256",RWA:"250",BEN:"229",CIV:"225",SEN:"221"}[t.toUpperCase()];return u&&!r.startsWith(u)&&(r.startsWith("0")&&(r=r.slice(1)),r=u+r),r}validatePhoneNumber(e,t){let r=F[t];if(!r)return false;let o=e.replace(/\D/g,"");return r.phoneRegex.test(o)}getSupportedCorrespondents(){return U}getCorrespondentInfo(e){return F[e]}getAllCorrespondentsInfo(){return Object.values(F)}detectCorrespondent(e){let t=e.replace(/\D/g,"");for(let[r,o]of Object.entries(F))if(o.phoneRegex.test(t))return r;return null}};var Qe=zod.z.object({wallet:zod.z.object({country:zod.z.string().length(3),currency:zod.z.string().length(3),provider:zod.z.string().optional()}),callbackUrl:zod.z.string().url(),startDate:zod.z.string(),endDate:zod.z.string(),compressed:zod.z.boolean().optional()}),X=class{constructor(e,t){this.httpClient=e;this.logger=t;}async getWalletBalances(){this.logger.info("Fetching wallet balances");let e=await this.httpClient.get("/v2/wallets/balances");return this.logger.info(`Retrieved ${e.balances.length} wallet balances`),e.balances}async generateStatement(e){let t=Qe.parse(e);this.logger.info("Generating statement",{wallet:t.wallet,startDate:t.startDate,endDate:t.endDate});let r=await this.httpClient.post("/v2/statements",t);if(r.status==="REJECTED"&&r.failureReason)throw l.fromPawapayResponse(r.failureReason.failureCode,r.failureReason.failureMessage);return this.logger.info(`Statement ${r.statementId} status: ${r.status}`),r}async checkStatementStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw l.validation("Invalid statement ID format");let t=await this.httpClient.get(`/v2/statements/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw l.notFound(`Statement ${e} not found`);return this.logger.info(`Statement ${e} status: ${t.data.status}`),t.data}async pollStatementUntilComplete(e,t={}){let{interval:r=5e3,maxAttempts:o=24}=t;for(let u=1;u<=o;u++){let g=await this.checkStatementStatus(e);if(g.status==="COMPLETED"||g.status==="FAILED")return g;u<o&&await new Promise(y=>setTimeout(y,r));}return this.checkStatementStatus(e)}};var re=class{constructor(e){let r={...ge(),...e};this.config=me(r),this.logger=new W("SpaarkPayApiSdk",this.config.logLevel),this.httpClient=q.fromConfig(this.config,this.logger),this.transactions=new B(this.httpClient,this.logger),this.products=new K(this.logger),this.webhooks=new H(this.httpClient,this.logger,{webhookSecret:this.getWebhookSecretFromEnv()}),this.utils=new z(this.httpClient,this.logger),this.finances=new X(this.httpClient,this.logger),this.logger.info("SpaarkPayApiSdk initialized",{environment:this.config.environment,baseUrl:this.config.baseUrl});}getWebhookSecretFromEnv(){if(typeof process<"u"&&process.env)return process.env.PAWAPAY_WEBHOOK_SECRET}getConfig(){return {...this.config}}setLogLevel(e){this.logger.setLevel(e);}setWebhookSecret(e){this.webhooks.setWebhookSecret(e);}};var et=i=>({depositId:i,status:"ACCEPTED",created:new Date().toISOString(),nextStep:"FINAL_STATUS"}),tt=i=>({payoutId:i,status:"ACCEPTED",created:new Date().toISOString()}),rt=i=>({depositId:i,status:["COMPLETED","ACCEPTED","PROCESSING","ENQUEUED"][Math.floor(Math.random()*4)],created:new Date(Date.now()-6e4).toISOString(),amount:"5000",currency:"XAF",country:"CMR",payer:{type:"MMO",accountDetails:{phoneNumber:"237670000000",provider:"MTN_MOMO_CMR"}}}),ot=()=>[{country:"CMR",providers:[{provider:"MTN_MOMO_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"OPERATIONAL"}]},{provider:"ORANGE_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"DELAYED"}]}]}],nt=i=>({country:"CMR",provider:i.startsWith("23767")?"MTN_MOMO_CMR":"ORANGE_CMR",phoneNumber:i.replace(/\D/g,"")}),at=()=>({companyName:"Demo Company",signatureConfiguration:{signedRequestsOnly:false,signedCallbacks:true},countries:[{country:"CMR",displayName:{en:"Cameroon",fr:"Cameroun"},prefix:"237",flag:"https://cdn.pawapay.io/flags/cmr.svg",providers:[{provider:"MTN_MOMO_CMR",displayName:"MTN Mobile Money",nameDisplayedToCustomer:"MTN MoMo",currencies:[{currency:"XAF",displayName:"CFA Franc",operationTypes:{DEPOSIT:{minAmount:"100",maxAmount:"1000000",status:"OPERATIONAL"},PAYOUT:{minAmount:"100",maxAmount:"500000",status:"OPERATIONAL"}}}]}]}]}),st=()=>({balances:[{country:"CMR",currency:"XAF",balance:"1250000.00"},{country:"COG",currency:"XAF",balance:"450000.00"},{country:"GAB",currency:"XAF",balance:"780000.00"}]}),it=()=>[{id:"key-001",key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."}],M=(i=800)=>new Promise(e=>setTimeout(e,i+Math.random()*400)),oe=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)}),he=[{value:"MTN_MOMO_CMR",label:"MTN Mobile Money",country:"Cameroun"},{value:"ORANGE_CMR",label:"Orange Money",country:"Cameroun"},{value:"MTN_MOMO_COG",label:"MTN Mobile Money",country:"Congo"},{value:"AIRTEL_COG",label:"Airtel Money",country:"Congo"},{value:"MTN_MOMO_GAB",label:"MTN Mobile Money",country:"Gabon"},{value:"AIRTEL_GAB",label:"Airtel Money",country:"Gabon"}],be=[{value:"XAF",label:"XAF (CFA Franc BEAC)"},{value:"XOF",label:"XOF (CFA Franc BCEAO)"},{value:"GHS",label:"GHS (Ghana Cedi)"},{value:"KES",label:"KES (Kenyan Shilling)"},{value:"RWF",label:"RWF (Rwandan Franc)"},{value:"TZS",label:"TZS (Tanzanian Shilling)"},{value:"UGX",label:"UGX (Ugandan Shilling)"},{value:"ZMW",label:"ZMW (Zambian Kwacha)"}];function ct({apiKey:i="",environment:e="sandbox",className:t="",demoMode:r=false,apiBasePath:o="/api/pawapay",onDepositComplete:u,onPayoutComplete:g,onError:y}){let[p,P]=react.useState(i),[h,se]=react.useState(e),[Re,Y]=react.useState(!!i||r),[f,ie]=react.useState(r),[E,j]=react.useState("deposit"),[A,Z]=react.useState("237670000000"),[I,ce]=react.useState("5000"),[L,ue]=react.useState("XAF"),[_,de]=react.useState("MTN_MOMO_CMR"),[J,Ce]=react.useState("Test Payment"),[O,Q]=react.useState(""),[ee,le]=react.useState([]),[R,v]=react.useState("idle"),m=react.useCallback((n,c,b,S)=>{let Ie={id:oe(),operation:n,status:c,response:b,error:S,timestamp:new Date().toLocaleTimeString()};le(Le=>[Ie,...Le].slice(0,20));},[]),we=react.useCallback(()=>{if(!p.trim()){m("Configuration","error",void 0,"API Key is required");return}Y(true),ie(false),m("Configuration","success",{environment:h,configured:true,apiBasePath:o});},[p,h,o,m]),Pe=react.useCallback(()=>{ie(true),Y(true),m("Configuration","success",{mode:"demo",message:"Demo mode activated - responses are simulated"});},[m]),Ee=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n=oe();Q(n);let c;if(f)await M(),c=et(n);else {let b=await fetch(`${o}/deposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,amount:parseFloat(I),currency:L,provider:_,phoneNumber:A,customerMessage:J.slice(0,22),transactionId:n})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Deposit failed");c=S;}v("success"),m("Deposit","success",c),u?.(c);}catch(n){v("error");let c=n instanceof Error?n.message:"Deposit failed";m("Deposit","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,I,L,_,A,J,m,u,y]),Ae=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n=oe();Q(n);let c;if(f)await M(),c=tt(n);else {let b=await fetch(`${o}/payout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,amount:parseFloat(I),currency:L,provider:_,phoneNumber:A,transactionId:n})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Payout failed");c=S;}v("success"),m("Payout","success",c),g?.(c);}catch(n){v("error");let c=n instanceof Error?n.message:"Payout failed";m("Payout","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,I,L,_,A,m,g,y]),Ne=react.useCallback(async()=>{if(!p&&!f||!O){m("Check Status","error",void 0,"No transaction ID");return}v("loading");try{let n;if(f)await M(),n=rt(O);else {let c=await fetch(`${o}/status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,transactionId:O})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Status check failed");n=b;}v("success"),m("Check Status","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Status check failed";m("Check Status","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}},[p,o,h,f,O,m,y]),ke=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=ot();else {let c=await fetch(`${o}/availability`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Availability check failed");n=b;}v("success"),m("Provider Availability","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Availability check failed";m("Provider Availability","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Te=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=nt(A);else {let c=await fetch(`${o}/predict-provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h,phoneNumber:A})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Prediction failed");n=b;}v("success"),m("Predict Provider","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Prediction failed";m("Predict Provider","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,A,m,y]),Oe=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=at();else {let c=await fetch(`${o}/active-config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get config");n=b;}v("success"),m("Active Configuration","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get config";m("Active Configuration","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Me=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=it();else {let c=await fetch(`${o}/public-keys`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get public keys");n=b;}v("success"),m("Public Keys","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get public keys";m("Public Keys","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),Se=react.useCallback(async()=>{if(!(!p&&!f)){v("loading");try{let n;if(f)await M(),n=st();else {let c=await fetch(`${o}/wallet-balances`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:p,environment:h})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get balances");n=b;}v("success"),m("Wallet Balances","success",n);}catch(n){v("error");let c=n instanceof Error?n.message:"Failed to get balances";m("Wallet Balances","error",void 0,c),y?.(n instanceof Error?n:new Error(c));}}},[p,o,h,f,m,y]),De=react.useCallback(n=>{navigator.clipboard.writeText(n);},[]);return Re?jsxRuntime.jsxs("div",{className:`space-y-6 ${t}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"SDK Test Console"}),f&&jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200",children:"DEMO"})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:f?"Mode d\xE9mo - Les r\xE9ponses sont simul\xE9es":`Test Pawapay SDK operations in ${h} mode`})]}),jsxRuntime.jsxs("button",{onClick:()=>Y(false),className:"h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Reconfigure"]})]}),jsxRuntime.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[jsxRuntime.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1 bg-muted p-1",children:[jsxRuntime.jsxs("button",{onClick:()=>j("deposit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="deposit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(ve,{}),"Deposit"]}),jsxRuntime.jsxs("button",{onClick:()=>j("payout"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="payout"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(ut,{}),"Payout"]}),jsxRuntime.jsxs("button",{onClick:()=>j("status"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="status"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(xe,{}),"Status"]}),jsxRuntime.jsxs("button",{onClick:()=>j("toolkit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="toolkit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(gt,{}),"Toolkit"]}),jsxRuntime.jsxs("button",{onClick:()=>j("finances"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="finances"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(yt,{}),"Finances"]})]}),E==="deposit"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Deposit"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Collect payment from a Mobile Money user"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:I,onChange:n=>ce(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:L,onChange:n=>ue(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(n=>jsxRuntime.jsx("option",{value:n.value,children:n.label},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:_,onChange:n=>de(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:he.map(n=>jsxRuntime.jsxs("option",{value:n.value,children:[n.label," (",n.country,")"]},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Customer Message (4-22 chars)"}),jsxRuntime.jsx("input",{placeholder:"Payment description",value:J,onChange:n=>Ce(n.target.value),maxLength:22,className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]})]}),jsxRuntime.jsxs("button",{onClick:Ee,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ae,{}),"Execute Deposit"]})]}),E==="payout"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Payout"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Send money to a Mobile Money account"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Recipient Phone"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:I,onChange:n=>ce(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:L,onChange:n=>ue(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(n=>jsxRuntime.jsx("option",{value:n.value,children:n.label},n.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:_,onChange:n=>de(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:he.map(n=>jsxRuntime.jsxs("option",{value:n.value,children:[n.label," (",n.country,")"]},n.value))})]})]}),jsxRuntime.jsxs("button",{onClick:Ae,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ae,{}),"Execute Payout"]})]}),E==="status"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Check Transaction Status"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Query the status of a transaction"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Transaction ID"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{placeholder:"Enter transaction ID (UUID)",value:O,onChange:n=>Q(n.target.value),className:"flex-1 h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring font-mono"}),O&&jsxRuntime.jsx("button",{onClick:()=>De(O),className:"w-8 h-8 border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center",title:"Copy to clipboard",children:jsxRuntime.jsx(dt,{})})]})]}),jsxRuntime.jsxs("button",{onClick:Ne,disabled:R==="loading"||!O,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(xe,{}),"Check Status"]})]})]}),E==="toolkit"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Predict Provider"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Predict the provider from a phone number"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"+237 670 000 000",value:A,onChange:n=>Z(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("button",{onClick:Te,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ft,{}),"Predict Provider"]})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[jsxRuntime.jsxs("button",{onClick:ke,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ht,{}),"Provider Availability"]}),jsxRuntime.jsxs("button",{onClick:Oe,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Active Config"]}),jsxRuntime.jsxs("button",{onClick:Me,disabled:R==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(bt,{}),"Public Keys"]})]})]}),E==="finances"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Wallet Balances"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"View balances for all your wallets"})]}),jsxRuntime.jsxs("button",{onClick:Se,disabled:R==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[R==="loading"?jsxRuntime.jsx(G,{}):jsxRuntime.jsx(ve,{}),"Get Wallet Balances"]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Statements"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate financial statements for your wallets"})]}),jsxRuntime.jsxs("div",{className:"p-4 bg-muted/50 text-xs text-muted-foreground",children:["Statement generation requires callback URL configuration. Use the SDK directly:",jsxRuntime.jsx("pre",{className:"mt-2 p-2 bg-background overflow-x-auto",children:`await sdk.finances.generateStatement({
1
+ 'use strict';var zod=require('zod'),fe=require('axios'),crypto$1=require('crypto'),uuid=require('uuid'),react=require('react'),jsxRuntime=require('react/jsx-runtime');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var fe__default=/*#__PURE__*/_interopDefault(fe);var I={timeout:3e4,retries:3,retryDelay:1e3,logLevel:"info",sandboxUrl:"https://api.sandbox.pawapay.io",productionUrl:"https://api.pawapay.io"};var N={VALIDATION_ERROR:"VALIDATION_ERROR",INVALID_PHONE:"INVALID_PHONE",INSUFFICIENT_FUNDS:"INSUFFICIENT_FUNDS",AMOUNT_TOO_LOW:"AMOUNT_TOO_LOW",AMOUNT_TOO_HIGH:"AMOUNT_TOO_HIGH",LIMIT_EXCEEDED:"LIMIT_EXCEEDED",DUPLICATE:"DUPLICATE",MMO_UNAVAILABLE:"MMO_UNAVAILABLE",TIMEOUT:"TIMEOUT",UNAUTHORIZED:"UNAUTHORIZED",RATE_LIMITED:"RATE_LIMITED",SERVER_ERROR:"SERVER_ERROR",NETWORK_ERROR:"NETWORK_ERROR",NOT_FOUND:"NOT_FOUND",REFUND_NOT_ALLOWED:"REFUND_NOT_ALLOWED"},Nt=[{pawapayCode:"INVALID_PHONE_NUMBER",sdkCode:N.INVALID_PHONE,httpStatus:400,retryable:false,message:"Invalid phone number format"},{pawapayCode:"INSUFFICIENT_FUNDS",sdkCode:N.INSUFFICIENT_FUNDS,httpStatus:402,retryable:false,message:"Insufficient funds in account"},{pawapayCode:"AMOUNT_TOO_LOW",sdkCode:N.AMOUNT_TOO_LOW,httpStatus:400,retryable:false,message:"Amount below minimum"},{pawapayCode:"AMOUNT_TOO_HIGH",sdkCode:N.AMOUNT_TOO_HIGH,httpStatus:400,retryable:false,message:"Amount exceeds maximum"},{pawapayCode:"TRANSACTION_LIMIT_EXCEEDED",sdkCode:N.LIMIT_EXCEEDED,httpStatus:400,retryable:false,message:"Daily or monthly limit exceeded"},{pawapayCode:"DUPLICATE_TRANSACTION",sdkCode:N.DUPLICATE,httpStatus:409,retryable:false,message:"Transaction ID already used"},{pawapayCode:"CORRESPONDENT_UNAVAILABLE",sdkCode:N.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"CORRESPONDENT_TEMPORARILY_UNAVAILABLE",sdkCode:N.MMO_UNAVAILABLE,httpStatus:503,retryable:true,message:"Mobile Money operator temporarily unavailable"},{pawapayCode:"TIMEOUT",sdkCode:N.TIMEOUT,httpStatus:408,retryable:true,message:"Transaction timed out"},{pawapayCode:"INVALID_API_KEY",sdkCode:N.UNAUTHORIZED,httpStatus:401,retryable:false,message:"Invalid or expired API key"},{pawapayCode:"RATE_LIMIT_EXCEEDED",sdkCode:N.RATE_LIMITED,httpStatus:429,retryable:true,message:"Too many requests"},{pawapayCode:"INTERNAL_ERROR",sdkCode:N.SERVER_ERROR,httpStatus:500,retryable:true,message:"Pawapay internal error"},{pawapayCode:"REFUND_NOT_ALLOWED",sdkCode:N.REFUND_NOT_ALLOWED,httpStatus:400,retryable:false,message:"Refund not allowed for this transaction"}];function Ue(i){return Nt.find(e=>e.pawapayCode===i)}var p=class i extends Error{constructor(e,t,n,a){super(e),this.name="PawapayError",this.code=t,this.statusCode=n,this.failureReason=a?.failureReason,this.retryable=a?.retryable??false,this.originalError=a?.originalError,Error.captureStackTrace&&Error.captureStackTrace(this,i);}static fromPawapayResponse(e,t,n){let a=Ue(e);return a?new i(t??a.message,a.sdkCode,a.httpStatus,{retryable:a.retryable,originalError:n}):new i(t??"Unknown error occurred",N.SERVER_ERROR,500,{retryable:false,originalError:n})}static validation(e){return new i(e,N.VALIDATION_ERROR,400,{retryable:false})}static network(e,t){return new i(e,N.NETWORK_ERROR,0,{retryable:true,originalError:t})}static timeout(e="Request timed out"){return new i(e,N.TIMEOUT,408,{retryable:true})}static unauthorized(e="Invalid or expired API key"){return new i(e,N.UNAUTHORIZED,401,{retryable:false})}static notFound(e="Resource not found"){return new i(e,N.NOT_FOUND,404,{retryable:false})}toJSON(){return {name:this.name,message:this.message,code:this.code,statusCode:this.statusCode,failureReason:this.failureReason,retryable:this.retryable}}};var Ct=zod.z.object({apiKey:zod.z.string().min(1,"API key is required"),environment:zod.z.enum(["sandbox","production"]),baseUrl:zod.z.string().url().optional(),callbackUrl:zod.z.string().url().optional(),timeout:zod.z.number().positive().max(6e5).optional(),retries:zod.z.number().int().min(0).max(10).optional(),retryDelay:zod.z.number().positive().max(6e4).optional(),logLevel:zod.z.enum(["debug","info","warn","error","none"]).optional()});function Fe(i){let e=Ct.safeParse(i);if(!e.success){let a=e.error.errors.map(d=>`${d.path.join(".")}: ${d.message}`);throw p.validation(`Invalid SDK configuration: ${a.join(", ")}`)}let t=e.data,n=t.baseUrl??(t.environment==="production"?I.productionUrl:I.sandboxUrl);return {apiKey:t.apiKey,environment:t.environment,baseUrl:n,callbackUrl:t.callbackUrl,timeout:t.timeout??I.timeout,retries:t.retries??I.retries,retryDelay:t.retryDelay??I.retryDelay,logLevel:t.logLevel??I.logLevel}}function We(){let i=typeof process<"u"?process.env:{},e={};if(i.PAWAPAY_API_KEY&&(e.apiKey=i.PAWAPAY_API_KEY),i.PAWAPAY_ENVIRONMENT){let t=i.PAWAPAY_ENVIRONMENT.toLowerCase();(t==="production"||t==="sandbox")&&(e.environment=t);}if(i.PAWAPAY_BASE_URL&&(e.baseUrl=i.PAWAPAY_BASE_URL),i.PAWAPAY_CALLBACK_URL&&(e.callbackUrl=i.PAWAPAY_CALLBACK_URL),i.PAWAPAY_TIMEOUT){let t=parseInt(i.PAWAPAY_TIMEOUT,10);isNaN(t)||(e.timeout=t);}if(i.PAWAPAY_RETRIES){let t=parseInt(i.PAWAPAY_RETRIES,10);isNaN(t)||(e.retries=t);}if(i.PAWAPAY_LOG_LEVEL){let t=i.PAWAPAY_LOG_LEVEL.toLowerCase();["debug","info","warn","error","none"].includes(t)&&(e.logLevel=t);}return e}var Rt={maxAttempts:3,initialDelay:1e3,maxDelay:3e4,backoffMultiplier:2};function wt(i){return new Promise(e=>setTimeout(e,i))}function Et(i,e){let t=e.initialDelay*Math.pow(e.backoffMultiplier,i-1),n=Math.random()*.3*t;return Math.min(t+n,e.maxDelay)}async function B(i,e={},t){let n={...Rt,...e},a;for(let d=1;d<=n.maxAttempts;d++)try{return await i()}catch(y){if(a=y instanceof Error?y:new Error(String(y)),!(y instanceof p?y.retryable:kt(y))||d===n.maxAttempts)throw y;let l=Et(d,n);t?.warn(`Attempt ${d}/${n.maxAttempts} failed, retrying in ${Math.round(l)}ms`,{error:a.message}),await wt(l);}throw a??new Error("Retry failed without error")}function kt(i){return i instanceof p?i.retryable:i instanceof Error?["ECONNRESET","ECONNREFUSED","ETIMEDOUT","ENOTFOUND","Network Error","timeout","socket hang up"].some(t=>i.message.includes(t)||i.code===t):false}var Y=class i{constructor(e){this.logger=e.logger,this.retries=e.retries,this.retryDelay=e.retryDelay,this.client=fe__default.default.create({baseURL:e.baseUrl,timeout:e.timeout,headers:{"Content-Type":"application/json",Authorization:`Bearer ${e.apiKey}`}}),this.setupInterceptors();}setupInterceptors(){this.client.interceptors.request.use(e=>(this.logger.debug(`${e.method?.toUpperCase()} ${e.url}`,{params:e.params}),e),e=>(this.logger.error("Request error",e),Promise.reject(e))),this.client.interceptors.response.use(e=>(this.logger.debug(`${e.config.method?.toUpperCase()} ${e.config.url} -> ${e.status}`,{data:e.data}),e),e=>(fe__default.default.isAxiosError(e)&&this.logger.error(`Request failed: ${e.config?.method?.toUpperCase()} ${e.config?.url}`,{status:e.response?.status,data:e.response?.data}),Promise.reject(e)));}handleError(e){if(fe__default.default.isAxiosError(e)){if(e.code==="ECONNABORTED"||e.message.includes("timeout"))throw p.timeout();if(!e.response)throw p.network(e.message||"Network error",e);let{status:t,data:n}=e.response,a=n;if(t===401)throw p.unauthorized();if(t===404)throw p.notFound();let d=a?.errorCode??a?.rejectionReason?.rejectionCode;throw d?p.fromPawapayResponse(d,a?.errorMessage??a?.rejectionReason?.rejectionMessage,e):new p(a?.errorMessage??`HTTP error ${t}`,"SERVER_ERROR",t,{retryable:t>=500,originalError:e})}throw e instanceof p?e:p.network(e instanceof Error?e.message:"Unknown error",e instanceof Error?e:void 0)}async get(e,t){return B(async()=>{try{return (await this.client.get(e,t)).data}catch(n){this.handleError(n);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async post(e,t,n){return B(async()=>{try{return (await this.client.post(e,t,n)).data}catch(a){this.handleError(a);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async put(e,t,n){return B(async()=>{try{return (await this.client.put(e,t,n)).data}catch(a){this.handleError(a);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}async delete(e,t){return B(async()=>{try{return (await this.client.delete(e,t)).data}catch(n){this.handleError(n);}},{maxAttempts:this.retries,initialDelay:this.retryDelay},this.logger)}static fromConfig(e,t){return new i({baseUrl:e.baseUrl,apiKey:e.apiKey,timeout:e.timeout,retries:e.retries,retryDelay:e.retryDelay,logger:t})}};var je={debug:0,info:1,warn:2,error:3,none:4},q=class{constructor(e,t="info"){this.prefix=e,this.level=t;}setLevel(e){this.level=e;}shouldLog(e){return je[e]>=je[this.level]}formatMessage(e,t){return `[${new Date().toISOString()}] ${e.toUpperCase().padEnd(5)} [${this.prefix}] ${t}`}sanitize(e){if(e==null||typeof e=="string"||typeof e!="object")return e;if(Array.isArray(e))return e.map(a=>this.sanitize(a));let t={},n=["apiKey","api_key","authorization","password","secret","token"];for(let[a,d]of Object.entries(e))n.some(y=>a.toLowerCase().includes(y))?t[a]="[REDACTED]":typeof d=="object"&&d!==null?t[a]=this.sanitize(d):t[a]=d;return t}debug(e,t){if(this.shouldLog("debug")){let n=this.formatMessage("debug",e);t!==void 0?console.debug(n,this.sanitize(t)):console.debug(n);}}info(e,t){if(this.shouldLog("info")){let n=this.formatMessage("info",e);t!==void 0?console.info(n,this.sanitize(t)):console.info(n);}}warn(e,t){if(this.shouldLog("warn")){let n=this.formatMessage("warn",e);t!==void 0?console.warn(n,this.sanitize(t)):console.warn(n);}}error(e,t){if(this.shouldLog("error")){let n=this.formatMessage("error",e);t!==void 0?console.error(n,this.sanitize(t)):console.error(n);}}};var $=["MTN_MOMO_CMR","ORANGE_CMR","MTN_MOMO_COG","AIRTEL_COG","MTN_MOMO_GAB","AIRTEL_GAB"],G={MTN_MOMO_CMR:{correspondent:"MTN_MOMO_CMR",name:"MTN Mobile Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(67|68|65[0-4])\d{6}$/},ORANGE_CMR:{correspondent:"ORANGE_CMR",name:"Orange Money",country:"Cameroon",countryCode:"CMR",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^237(69|65[5-9])\d{6}$/},MTN_MOMO_COG:{correspondent:"MTN_MOMO_COG",name:"MTN Mobile Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^242(04|05|06)\d{7}$/},AIRTEL_COG:{correspondent:"AIRTEL_COG",name:"Airtel Money",country:"Congo",countryCode:"COG",currency:"XAF",features:["deposit","payout"],phoneRegex:/^242(01|02|03)\d{7}$/},MTN_MOMO_GAB:{correspondent:"MTN_MOMO_GAB",name:"MTN Mobile Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout","refund"],phoneRegex:/^241(06|07)\d{6}$/},AIRTEL_GAB:{correspondent:"AIRTEL_GAB",name:"Airtel Money",country:"Gabon",countryCode:"GAB",currency:"XAF",features:["deposit","payout"],phoneRegex:/^241(04|05)\d{6}$/}},J={MTN_MOMO_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},ORANGE_CMR:{minDeposit:100,maxDeposit:1e6,minPayout:500,maxPayout:5e5,currency:"XAF",dailyLimit:2e6},MTN_MOMO_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_COG:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},MTN_MOMO_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6},AIRTEL_GAB:{minDeposit:100,maxDeposit:5e5,minPayout:500,maxPayout:3e5,currency:"XAF",dailyLimit:1e6}};var Pt=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum($),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),preAuthorisationCode:zod.z.string().optional(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),Tt=zod.z.object({amount:zod.z.number().positive("Amount must be positive").max(1e7),currency:zod.z.string().min(3).max(3),provider:zod.z.enum($),phoneNumber:zod.z.string().regex(/^[0-9]{9,15}$/,"Phone number must be 9-15 digits"),transactionId:zod.z.string().uuid(),clientReferenceId:zod.z.string().optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),At=zod.z.object({depositId:zod.z.string().uuid(),returnUrl:zod.z.string().url(),phoneNumber:zod.z.string().optional(),amountDetails:zod.z.object({amount:zod.z.number().positive(),currency:zod.z.string().length(3)}).optional(),language:zod.z.enum(["EN","FR"]).optional(),country:zod.z.string().length(3).optional(),reason:zod.z.string().max(50).optional(),customerMessage:zod.z.string().min(4).max(22).optional(),metadata:zod.z.array(zod.z.record(zod.z.unknown())).max(10).optional()}),St=zod.z.object({depositId:zod.z.string().uuid(),amount:zod.z.number().positive("Amount must be positive"),transactionId:zod.z.string().uuid()});function Ot(i){return new Promise(e=>setTimeout(e,i))}var Z=class{constructor(e,t){this.httpClient=e;this.logger=t;}async initiateDeposit(e){let t=Pt.parse(e),n={depositId:t.transactionId,amount:t.amount.toString(),currency:t.currency,payer:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},preAuthorisationCode:t.preAuthorisationCode,clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 deposit ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let a=await this.httpClient.post("/v2/deposits",n);if(a.status==="REJECTED"&&a.rejectionReason)throw p.fromPawapayResponse(a.rejectionReason.rejectionCode,a.rejectionReason.rejectionMessage);return this.logger.info(`Deposit ${a.depositId} status: ${a.status}`),{depositId:a.depositId,status:a.status,created:a.created??new Date().toISOString(),nextStep:a.nextStep,redirectUrl:a.redirectUrl}}async initiatePayout(e){let t=Tt.parse(e),n={payoutId:t.transactionId,amount:t.amount.toString(),currency:t.currency,recipient:{type:"MMO",accountDetails:{phoneNumber:t.phoneNumber,provider:t.provider}},clientReferenceId:t.clientReferenceId,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Initiating V2 payout ${t.transactionId}`,{amount:t.amount,currency:t.currency,provider:t.provider});let a=await this.httpClient.post("/v2/payouts",n);if(a.status==="REJECTED"&&a.rejectionReason)throw p.fromPawapayResponse(a.rejectionReason.rejectionCode,a.rejectionReason.rejectionMessage);return this.logger.info(`Payout ${a.payoutId} status: ${a.status}`),{payoutId:a.payoutId,status:a.status,created:a.created??new Date().toISOString()}}async createPaymentPage(e){let t=At.parse(e),n={depositId:t.depositId,returnUrl:t.returnUrl,phoneNumber:t.phoneNumber,amountDetails:t.amountDetails?{amount:t.amountDetails.amount.toString(),currency:t.amountDetails.currency}:void 0,language:t.language,country:t.country,reason:t.reason,customerMessage:t.customerMessage,metadata:t.metadata};this.logger.info(`Creating payment page for deposit ${t.depositId}`);let a=await this.httpClient.post("/v2/paymentpage",n);return this.logger.info(`Payment page created: ${a.redirectUrl}`),{redirectUrl:a.redirectUrl}}async refund(e){let t=St.parse(e),n={refundId:t.transactionId,depositId:t.depositId,amount:t.amount.toString()};this.logger.info(`Initiating refund ${t.transactionId}`,{depositId:t.depositId,amount:t.amount});let a=await this.httpClient.post("/refunds",n);if(a.status==="REJECTED"&&a.rejectionReason)throw p.fromPawapayResponse(a.rejectionReason.rejectionCode,a.rejectionReason.rejectionMessage);return this.logger.info(`Refund ${a.refundId} status: ${a.status}`),{refundId:a.refundId,depositId:t.depositId,status:a.status,amount:t.amount,created:a.created??new Date().toISOString()}}async checkDepositStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid deposit ID format");let t=await this.httpClient.get(`/v2/deposits/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw p.notFound(`Deposit ${e} not found`);let n=t.data;return {depositId:n.depositId,status:n.status,amount:n.amount,currency:n.currency,country:n.country,payer:n.payer,created:n.created,customerMessage:n.customerMessage,clientReferenceId:n.clientReferenceId,providerTransactionId:n.providerTransactionId,failureReason:n.failureReason,metadata:n.metadata}}async checkPayoutStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid payout ID format");let t=await this.httpClient.get(`/v2/payouts/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw p.notFound(`Payout ${e} not found`);let n=t.data;return {payoutId:n.payoutId,status:n.status,amount:n.amount,currency:n.currency,country:n.country,recipient:n.recipient,created:n.created,customerMessage:n.customerMessage,clientReferenceId:n.clientReferenceId,providerTransactionId:n.providerTransactionId,failureReason:n.failureReason,metadata:n.metadata}}async checkStatus(e){try{return await this.checkDepositStatus(e)}catch(t){if(t instanceof p&&t.code==="NOT_FOUND")return await this.checkPayoutStatus(e);throw t}}async pollUntilComplete(e,t={}){let{interval:n=5e3,maxAttempts:a=12,onStatusChange:d}=t,y;for(let l=1;l<=a;l++){let C=await this.checkStatus(e);if(C.status!==y&&(y=C.status,d?.(C.status)),C.status==="COMPLETED"||C.status==="FAILED")return C;l<a&&await Ot(n);}return await this.checkStatus(e)}async listDeposits(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/deposits",{params:t})).map(a=>({depositId:a.depositId??"",status:a.status,created:a.created}))}async listPayouts(e){let t={};return e?.from&&(t.from=e.from),e?.to&&(t.to=e.to),e?.status&&(t.status=e.status),e?.provider&&(t.provider=e.provider),e?.limit&&(t.limit=String(e.limit)),e?.offset&&(t.offset=String(e.offset)),(await this.httpClient.get("/v2/payouts",{params:t})).map(a=>({payoutId:a.payoutId??"",status:a.status,created:a.created}))}async resendDepositCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid deposit ID format");this.logger.info(`Resending callback for deposit ${e}`);let t=await this.httpClient.post(`/v2/deposits/${e}/resend-callback`,{});return this.logger.info(`Resend callback for deposit ${e}: ${t.status}`),t}async resendPayoutCallback(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid payout ID format");this.logger.info(`Resending callback for payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/resend-callback`,{});return this.logger.info(`Resend callback for payout ${e}: ${t.status}`),t}async cancelEnqueuedPayout(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid payout ID format");this.logger.info(`Cancelling enqueued payout ${e}`);let t=await this.httpClient.post(`/v2/payouts/${e}/cancel`,{});return this.logger.info(`Cancel payout ${e}: ${t.status}`),t}};var $e=zod.z.object({name:zod.z.string().min(1).max(100),description:zod.z.string().max(500).optional(),price:zod.z.number().positive(),currency:zod.z.enum(["XAF","XOF","USD"]),metadata:zod.z.record(zod.z.unknown()).optional()}),Mt=zod.z.object({productId:zod.z.string().uuid(),domain:zod.z.string().regex(/^[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]?\.[a-zA-Z]{2,}$/)}),Q=class{constructor(e){this.logger=e;this.products=new Map;}async create(e){let t=$e.parse(e),n=crypto.randomUUID(),a=new Date().toISOString(),d={id:n,name:t.name,description:t.description,price:t.price,currency:t.currency,domains:[],created:a,updated:a,metadata:t.metadata};return this.products.set(n,d),this.logger.info(`Created product ${n}`,{name:t.name}),this.toProduct(d)}async get(e){let t=this.products.get(e);if(!t)throw p.notFound(`Product ${e} not found`);return this.toProduct(t)}async list(){return Array.from(this.products.values()).map(e=>this.toProduct(e))}async update(e,t){let n=this.products.get(e);if(!n)throw p.notFound(`Product ${e} not found`);let a=$e.partial().parse(t),d={...n,...a,updated:new Date().toISOString()};return this.products.set(e,d),this.logger.info(`Updated product ${e}`),this.toProduct(d)}async delete(e){if(!this.products.get(e))throw p.notFound(`Product ${e} not found`);this.products.delete(e),this.logger.info(`Deleted product ${e}`);}async addDomain(e){let t=Mt.parse(e),n=this.products.get(t.productId);if(!n)throw p.notFound(`Product ${t.productId} not found`);if(n.domains.includes(t.domain))throw p.validation(`Domain ${t.domain} already added to product`);return n.domains.push(t.domain),n.updated=new Date().toISOString(),this.logger.info(`Added domain ${t.domain} to product ${t.productId}`),this.toProduct(n)}async removeDomain(e,t){let n=this.products.get(e);if(!n)throw p.notFound(`Product ${e} not found`);let a=n.domains.indexOf(t);if(a===-1)throw p.notFound(`Domain ${t} not found in product`);return n.domains.splice(a,1),n.updated=new Date().toISOString(),this.logger.info(`Removed domain ${t} from product ${e}`),this.toProduct(n)}toProduct(e){return {id:e.id,name:e.name,description:e.description,price:e.price,currency:e.currency,domains:[...e.domains],created:e.created,updated:e.updated}}};var ee=class{constructor(e,t,n){this.httpClient=e;this.logger=t;this.webhookSecret=n?.webhookSecret;}setWebhookSecret(e){this.webhookSecret=e;}verifySignature(e,t){if(!this.webhookSecret)return this.logger.warn("Webhook secret not configured, skipping signature verification"),true;if(!t)return this.logger.warn("No signature provided in webhook request"),false;try{let n=crypto$1.createHmac("sha256",this.webhookSecret).update(e,"utf8").digest("hex"),a=Buffer.from(t,"hex"),d=Buffer.from(n,"hex");return a.length!==d.length?!1:crypto$1.timingSafeEqual(a,d)}catch(n){return this.logger.error("Error verifying webhook signature",n),false}}parseEvent(e){try{let t=JSON.parse(e);if(!t.eventId||!t.eventType||!t.timestamp)throw new Error("Invalid webhook event structure");return t}catch(t){throw p.validation(`Failed to parse webhook event: ${t instanceof Error?t.message:"Unknown error"}`)}}constructEvent(e,t){if(!this.verifySignature(e,t))throw p.unauthorized("Invalid webhook signature");return this.parseEvent(e)}async registerCallback(e){this.logger.info(`Registering callback URL: ${e}`),await this.httpClient.post("/webhooks",{url:e}),this.logger.info("Callback URL registered successfully");}async unregisterCallback(){this.logger.info("Unregistering callback URL"),await this.httpClient.delete("/webhooks"),this.logger.info("Callback URL unregistered successfully");}isDepositEvent(e){return e.startsWith("deposit.")}isPayoutEvent(e){return e.startsWith("payout.")}isRefundEvent(e){return e.startsWith("refund.")}isSuccessEvent(e){return e.endsWith(".completed")}isFailureEvent(e){return e.endsWith(".failed")}};var te=class{constructor(e,t){this.httpClient=e;this.logger=t;}generateTransactionId(){return uuid.v4()}validateTransactionId(e){return uuid.validate(e)&&uuid.version(e)===4}async getActiveConfiguration(e){let t={};e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching active configuration",e);let n=await this.httpClient.get("/v2/active-conf",{params:Object.keys(t).length>0?t:void 0});return this.logger.info(`Retrieved configuration for ${n.countries.length} countries`),n}async getProviderAvailability(e){let t={};return e?.country&&(t.country=e.country),e?.operationType&&(t.operationType=e.operationType),this.logger.info("Fetching provider availability",e),await this.httpClient.get("/v2/availability",{params:Object.keys(t).length>0?t:void 0})}async predictProvider(e){this.logger.info("Predicting provider for phone number");let t=await this.httpClient.post("/v2/predict-provider",{phoneNumber:e});return this.logger.info(`Predicted provider: ${t.provider} (${t.country})`),t}async getPublicKeys(){this.logger.info("Fetching public keys");let e=await this.httpClient.get("/v2/public-key/http");return this.logger.info(`Retrieved ${e.length} public keys`),e}async getTransactionLimits(e){try{let t=await this.getActiveConfiguration();for(let n of t.countries)for(let a of n.providers)if(a.provider===e){let d=a.currencies[0];if(d?.operationTypes){let y=d.operationTypes.DEPOSIT,g=d.operationTypes.PAYOUT,l=J[e];return {minDeposit:y?.minAmount?parseFloat(y.minAmount):l.minDeposit,maxDeposit:y?.maxAmount?parseFloat(y.maxAmount):l.maxDeposit,minPayout:g?.minAmount?parseFloat(g.minAmount):l.minPayout,maxPayout:g?.maxAmount?parseFloat(g.maxAmount):l.maxPayout,currency:d.currency,dailyLimit:l.dailyLimit}}}}catch(t){this.logger.warn(`Failed to fetch live limits for ${e}, using defaults`,t);}return J[e]}async checkMMOAvailability(e){try{let t=await this.getProviderAvailability();for(let n of t){let a=n.providers.find(d=>d.provider===e);if(a){let d=a.operationTypes.find(m=>m.operationType==="DEPOSIT"),y=a.operationTypes.find(m=>m.operationType==="PAYOUT"),g=d?.status==="OPERATIONAL"||y?.status==="OPERATIONAL",l=d?.status==="DELAYED"||y?.status==="DELAYED",C=d?.status==="CLOSED"&&y?.status==="CLOSED";return {correspondent:e,available:g||l,degraded:l,message:C?"Provider is currently closed":void 0}}}return {correspondent:e,available:!1,degraded:!1,message:"Correspondent not found in availability list"}}catch(t){return this.logger.warn(`Failed to check MMO availability for ${e}`,t),{correspondent:e,available:false,degraded:true,message:"Unable to verify availability"}}}formatPhoneNumber(e,t){let n=e.replace(/\D/g,"");n.startsWith("00")&&(n=n.slice(2));let d={CMR:"237",COG:"242",GAB:"241",ZMB:"260",GHA:"233",KEN:"254",TZA:"255",UGA:"256",RWA:"250",BEN:"229",CIV:"225",SEN:"221"}[t.toUpperCase()];return d&&!n.startsWith(d)&&(n.startsWith("0")&&(n=n.slice(1)),n=d+n),n}validatePhoneNumber(e,t){let n=G[t];if(!n)return false;let a=e.replace(/\D/g,"");return n.phoneRegex.test(a)}getSupportedCorrespondents(){return $}getCorrespondentInfo(e){return G[e]}getAllCorrespondentsInfo(){return Object.values(G)}detectCorrespondent(e){let t=e.replace(/\D/g,"");for(let[n,a]of Object.entries(G))if(a.phoneRegex.test(t))return n;return null}};var Ft=zod.z.object({wallet:zod.z.object({country:zod.z.string().length(3),currency:zod.z.string().length(3),provider:zod.z.string().optional()}),callbackUrl:zod.z.string().url(),startDate:zod.z.string(),endDate:zod.z.string(),compressed:zod.z.boolean().optional()}),oe=class{constructor(e,t){this.httpClient=e;this.logger=t;}async getWalletBalances(){this.logger.info("Fetching wallet balances");let e=await this.httpClient.get("/v2/wallets/balances");return this.logger.info(`Retrieved ${e.balances.length} wallet balances`),e.balances}async generateStatement(e){let t=Ft.parse(e);this.logger.info("Generating statement",{wallet:t.wallet,startDate:t.startDate,endDate:t.endDate});let n=await this.httpClient.post("/v2/statements",t);if(n.status==="REJECTED"&&n.failureReason)throw p.fromPawapayResponse(n.failureReason.failureCode,n.failureReason.failureMessage);return this.logger.info(`Statement ${n.statementId} status: ${n.status}`),n}async checkStatementStatus(e){if(!zod.z.string().uuid().safeParse(e).success)throw p.validation("Invalid statement ID format");let t=await this.httpClient.get(`/v2/statements/${e}`);if(t.status==="NOT_FOUND"||!t.data)throw p.notFound(`Statement ${e} not found`);return this.logger.info(`Statement ${e} status: ${t.data.status}`),t.data}async pollStatementUntilComplete(e,t={}){let{interval:n=5e3,maxAttempts:a=24}=t;for(let d=1;d<=a;d++){let y=await this.checkStatementStatus(e);if(y.status==="COMPLETED"||y.status==="FAILED")return y;d<a&&await new Promise(g=>setTimeout(g,n));}return this.checkStatementStatus(e)}};var ye=class{constructor(e){let n={...We(),...e};this.config=Fe(n),this.logger=new q("SpaarkPayApiSdk",this.config.logLevel),this.httpClient=Y.fromConfig(this.config,this.logger),this.transactions=new Z(this.httpClient,this.logger),this.products=new Q(this.logger),this.webhooks=new ee(this.httpClient,this.logger,{webhookSecret:this.getWebhookSecretFromEnv()}),this.utils=new te(this.httpClient,this.logger),this.finances=new oe(this.httpClient,this.logger),this.logger.info("SpaarkPayApiSdk initialized",{environment:this.config.environment,baseUrl:this.config.baseUrl});}getWebhookSecretFromEnv(){if(typeof process<"u"&&process.env)return process.env.PAWAPAY_WEBHOOK_SECRET}getConfig(){return {...this.config}}setLogLevel(e){this.logger.setLevel(e);}setWebhookSecret(e){this.webhooks.setWebhookSecret(e);}};var L=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)});function Wt(i,e={}){let{transactionId:t=L(),amount:n="5000",currency:a="XAF",correspondent:d="MTN_MOMO_CMR",phoneNumber:y="237670000000",status:g=i==="deposit.failed"?"FAILED":"COMPLETED",failureCode:l="INSUFFICIENT_FUNDS",failureMessage:C="The payer has insufficient funds"}=e,m=new Date().toISOString(),R={depositId:t,status:g,amount:n,currency:a,correspondent:d,payer:{type:"MSISDN",address:{value:y}},customerTimestamp:m,created:m};return g==="COMPLETED"&&(R.receivedByPayer=m),g==="FAILED"&&(R.failureReason={failureCode:l,failureMessage:C}),{eventId:L(),eventType:i,timestamp:m,data:R}}function jt(i,e={}){let{transactionId:t=L(),amount:n="5000",currency:a="XAF",correspondent:d="MTN_MOMO_CMR",phoneNumber:y="237670000000",status:g=i==="payout.failed"?"FAILED":"COMPLETED",failureCode:l="RECIPIENT_NOT_FOUND",failureMessage:C="The recipient account was not found"}=e,m=new Date().toISOString(),R={payoutId:t,status:g,amount:n,currency:a,correspondent:d,recipient:{type:"MSISDN",address:{value:y}},customerTimestamp:m,created:m};return g==="COMPLETED"&&(R.receivedByRecipient=m),g==="FAILED"&&(R.failureReason={failureCode:l,failureMessage:C}),{eventId:L(),eventType:i,timestamp:m,data:R}}function $t(i,e={}){let{transactionId:t=L(),depositId:n=L(),amount:a="5000",currency:d="XAF",correspondent:y="MTN_MOMO_CMR",phoneNumber:g="237670000000",status:l=i==="refund.failed"?"FAILED":"COMPLETED",failureCode:C="REFUND_LIMIT_EXCEEDED",failureMessage:m="The refund limit has been exceeded"}=e,R=new Date().toISOString(),K={refundId:t,depositId:n,status:l,amount:a,currency:d,correspondent:y,recipient:{type:"MSISDN",address:{value:g}},created:R};return l==="FAILED"&&(K.failureReason={failureCode:C,failureMessage:m}),{eventId:L(),eventType:i,timestamp:R,data:K}}function Ge(i,e={}){return i.startsWith("deposit.")?Wt(i,e):i.startsWith("payout.")?jt(i,e):$t(i,e)}var Ve=["deposit.accepted","deposit.completed","deposit.failed","payout.accepted","payout.completed","payout.failed","refund.completed","refund.failed"];var Gt=i=>({depositId:i,status:"ACCEPTED",created:new Date().toISOString(),nextStep:"FINAL_STATUS"}),Vt=i=>({payoutId:i,status:"ACCEPTED",created:new Date().toISOString()}),Bt=i=>({depositId:i,status:["COMPLETED","ACCEPTED","PROCESSING","ENQUEUED"][Math.floor(Math.random()*4)],created:new Date(Date.now()-6e4).toISOString(),amount:"5000",currency:"XAF",country:"CMR",payer:{type:"MMO",accountDetails:{phoneNumber:"237670000000",provider:"MTN_MOMO_CMR"}}}),qt=()=>[{country:"CMR",providers:[{provider:"MTN_MOMO_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"OPERATIONAL"}]},{provider:"ORANGE_CMR",operationTypes:[{operationType:"DEPOSIT",status:"OPERATIONAL"},{operationType:"PAYOUT",status:"DELAYED"}]}]}],Ht=i=>({country:"CMR",provider:i.startsWith("23767")?"MTN_MOMO_CMR":"ORANGE_CMR",phoneNumber:i.replace(/\D/g,"")}),Kt=()=>({companyName:"Demo Company",signatureConfiguration:{signedRequestsOnly:false,signedCallbacks:true},countries:[{country:"CMR",displayName:{en:"Cameroon",fr:"Cameroun"},prefix:"237",flag:"https://cdn.pawapay.io/flags/cmr.svg",providers:[{provider:"MTN_MOMO_CMR",displayName:"MTN Mobile Money",nameDisplayedToCustomer:"MTN MoMo",currencies:[{currency:"XAF",displayName:"CFA Franc",operationTypes:{DEPOSIT:{minAmount:"100",maxAmount:"1000000",status:"OPERATIONAL"},PAYOUT:{minAmount:"100",maxAmount:"500000",status:"OPERATIONAL"}}}]}]}]}),zt=()=>({balances:[{country:"CMR",currency:"XAF",balance:"1250000.00"},{country:"COG",currency:"XAF",balance:"450000.00"},{country:"GAB",currency:"XAF",balance:"780000.00"}]}),Xt=()=>[{id:"key-001",key:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."}],D=(i=800)=>new Promise(e=>setTimeout(e,i+Math.random()*400));async function Be(i,e){let t=new TextEncoder,n=await crypto.subtle.importKey("raw",t.encode(e),{name:"HMAC",hash:"SHA-256"},false,["sign"]),a=await crypto.subtle.sign("HMAC",n,t.encode(i));return Array.from(new Uint8Array(a)).map(d=>d.toString(16).padStart(2,"0")).join("")}var re=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,i=>{let e=Math.random()*16|0;return (i==="x"?e:e&3|8).toString(16)}),be=[{value:"MTN_MOMO_CMR",label:"MTN Mobile Money",country:"Cameroun"},{value:"ORANGE_CMR",label:"Orange Money",country:"Cameroun"},{value:"MTN_MOMO_COG",label:"MTN Mobile Money",country:"Congo"},{value:"AIRTEL_COG",label:"Airtel Money",country:"Congo"},{value:"MTN_MOMO_GAB",label:"MTN Mobile Money",country:"Gabon"},{value:"AIRTEL_GAB",label:"Airtel Money",country:"Gabon"}],qe=[{value:"XAF",label:"XAF (CFA Franc BEAC)"},{value:"XOF",label:"XOF (CFA Franc BCEAO)"},{value:"GHS",label:"GHS (Ghana Cedi)"},{value:"KES",label:"KES (Kenyan Shilling)"},{value:"RWF",label:"RWF (Rwandan Franc)"},{value:"TZS",label:"TZS (Tanzanian Shilling)"},{value:"UGX",label:"UGX (Ugandan Shilling)"},{value:"ZMW",label:"ZMW (Zambian Kwacha)"}];function Yt({apiKey:i="",environment:e="sandbox",className:t="",demoMode:n=false,apiBasePath:a="/api/pawapay",onDepositComplete:d,onPayoutComplete:y,onError:g}){let[l,C]=react.useState(i),[m,R]=react.useState(e),[K,ae]=react.useState(!!i||n),[v,ve]=react.useState(n),[E,_]=react.useState("deposit"),[P,se]=react.useState("237670000000"),[U,xe]=react.useState("5000"),[F,Ne]=react.useState("XAF"),[W,Ce]=react.useState("MTN_MOMO_CMR"),[ie,Je]=react.useState("Test Payment"),[M,ce]=react.useState(""),[de,Re]=react.useState([]),[w,x]=react.useState("idle"),[we,Ze]=react.useState("whsec_test_secret_key"),[le,Ee]=react.useState([]),[z,Qe]=react.useState("deposit.completed"),[ke,et]=react.useState("5000"),[Pe,tt]=react.useState("237670000000"),[Te,ot]=react.useState("MTN_MOMO_CMR"),[ue,rt]=react.useState(""),[Ae,nt]=react.useState(""),[Se,at]=react.useState(""),[pe,st]=react.useState(""),[Oe,it]=react.useState(""),[X,Me]=react.useState(null),[De,ct]=react.useState(""),[j,Ie]=react.useState(null),[Le,_e]=react.useState(""),[V,dt]=react.useState("all"),f=react.useCallback((r,c,b,S)=>{let ge={id:re(),operation:r,status:c,response:b,error:S,timestamp:new Date().toLocaleTimeString()};Re(xt=>[ge,...xt].slice(0,20));},[]),lt=react.useCallback(()=>{if(!l.trim()){f("Configuration","error",void 0,"API Key is required");return}ae(true),ve(false),f("Configuration","success",{environment:m,configured:true,apiBasePath:a});},[l,m,a,f]),ut=react.useCallback(()=>{ve(true),ae(true),f("Configuration","success",{mode:"demo",message:"Demo mode activated - responses are simulated"});},[f]),pt=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r=re();ce(r);let c;if(v)await D(),c=Gt(r);else {let b=await fetch(`${a}/deposit`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m,amount:parseFloat(U),currency:F,provider:W,phoneNumber:P,customerMessage:ie.slice(0,22),transactionId:r})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Deposit failed");c=S;}x("success"),f("Deposit","success",c),d?.(c);}catch(r){x("error");let c=r instanceof Error?r.message:"Deposit failed";f("Deposit","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,U,F,W,P,ie,f,d,g]),mt=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r=re();ce(r);let c;if(v)await D(),c=Vt(r);else {let b=await fetch(`${a}/payout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m,amount:parseFloat(U),currency:F,provider:W,phoneNumber:P,transactionId:r})}),S=await b.json();if(!b.ok)throw new Error(S.error||"Payout failed");c=S;}x("success"),f("Payout","success",c),y?.(c);}catch(r){x("error");let c=r instanceof Error?r.message:"Payout failed";f("Payout","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,U,F,W,P,f,y,g]),gt=react.useCallback(async()=>{if(!l&&!v||!M){f("Check Status","error",void 0,"No transaction ID");return}x("loading");try{let r;if(v)await D(),r=Bt(M);else {let c=await fetch(`${a}/status`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m,transactionId:M})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Status check failed");r=b;}x("success"),f("Check Status","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Status check failed";f("Check Status","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}},[l,a,m,v,M,f,g]),ft=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r;if(v)await D(),r=qt();else {let c=await fetch(`${a}/availability`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Availability check failed");r=b;}x("success"),f("Provider Availability","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Availability check failed";f("Provider Availability","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,f,g]),yt=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r;if(v)await D(),r=Ht(P);else {let c=await fetch(`${a}/predict-provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m,phoneNumber:P})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Prediction failed");r=b;}x("success"),f("Predict Provider","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Prediction failed";f("Predict Provider","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,P,f,g]),bt=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r;if(v)await D(),r=Kt();else {let c=await fetch(`${a}/active-config`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get config");r=b;}x("success"),f("Active Configuration","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Failed to get config";f("Active Configuration","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,f,g]),ht=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r;if(v)await D(),r=Xt();else {let c=await fetch(`${a}/public-keys`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get public keys");r=b;}x("success"),f("Public Keys","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Failed to get public keys";f("Public Keys","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,f,g]),vt=react.useCallback(async()=>{if(!(!l&&!v)){x("loading");try{let r;if(v)await D(),r=zt();else {let c=await fetch(`${a}/wallet-balances`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({apiKey:l,environment:m})}),b=await c.json();if(!c.ok)throw new Error(b.error||"Failed to get balances");r=b;}x("success"),f("Wallet Balances","success",r);}catch(r){x("error");let c=r instanceof Error?r.message:"Failed to get balances";f("Wallet Balances","error",void 0,c),g?.(r instanceof Error?r:new Error(c));}}},[l,a,m,v,f,g]),me=react.useCallback(r=>{navigator.clipboard.writeText(r);},[]);return K?jsxRuntime.jsxs("div",{className:`space-y-6 ${t}`,children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Spaark Pay Console"}),v?jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900 dark:text-amber-200",children:"DEMO"}):m==="production"?jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",children:"PRODUCTION"}):jsxRuntime.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",children:"SANDBOX"})]}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:v?"Mode d\xE9mo - Les r\xE9ponses sont simul\xE9es":m==="production"?"Mode production - Transactions r\xE9elles":"Mode sandbox - Environnement de test"})]}),jsxRuntime.jsxs("button",{onClick:()=>ae(false),className:"h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center gap-2",children:[jsxRuntime.jsx(he,{}),"Reconfigure"]})]}),jsxRuntime.jsxs("div",{className:"grid lg:grid-cols-3 gap-6",children:[jsxRuntime.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex flex-wrap gap-1 bg-muted p-1",children:[jsxRuntime.jsxs("button",{onClick:()=>_("deposit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="deposit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(He,{}),"Deposit"]}),jsxRuntime.jsxs("button",{onClick:()=>_("payout"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="payout"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(Jt,{}),"Payout"]}),jsxRuntime.jsxs("button",{onClick:()=>_("status"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="status"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(Ke,{}),"Status"]}),jsxRuntime.jsxs("button",{onClick:()=>_("toolkit"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="toolkit"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(Qt,{}),"Toolkit"]}),jsxRuntime.jsxs("button",{onClick:()=>_("finances"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="finances"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(eo,{}),"Finances"]}),jsxRuntime.jsxs("button",{onClick:()=>_("webhooks"),className:`flex-1 min-w-[80px] h-8 px-3 text-xs font-medium transition-colors flex items-center justify-center gap-1.5 ${E==="webhooks"?"bg-background text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[jsxRuntime.jsx(no,{}),"Webhooks"]})]}),E==="deposit"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Deposit"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Collect payment from a Mobile Money user"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:P,onChange:r=>se(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:U,onChange:r=>xe(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:F,onChange:r=>Ne(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:qe.map(r=>jsxRuntime.jsx("option",{value:r.value,children:r.label},r.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:W,onChange:r=>Ce(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(r=>jsxRuntime.jsxs("option",{value:r.value,children:[r.label," (",r.country,")"]},r.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Customer Message (4-22 chars)"}),jsxRuntime.jsx("input",{placeholder:"Payment description",value:ie,onChange:r=>Je(r.target.value),maxLength:22,className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]})]}),jsxRuntime.jsxs("button",{onClick:pt,disabled:w==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[w==="loading"?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(ne,{}),"Execute Deposit"]})]}),E==="payout"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Initiate Payout"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Send money to a Mobile Money account"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Recipient Phone"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:P,onChange:r=>se(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:U,onChange:r=>xe(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Currency"}),jsxRuntime.jsx("select",{value:F,onChange:r=>Ne(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:qe.map(r=>jsxRuntime.jsx("option",{value:r.value,children:r.label},r.value))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:W,onChange:r=>Ce(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(r=>jsxRuntime.jsxs("option",{value:r.value,children:[r.label," (",r.country,")"]},r.value))})]})]}),jsxRuntime.jsxs("button",{onClick:mt,disabled:w==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[w==="loading"?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(ne,{}),"Execute Payout"]})]}),E==="status"&&jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Check Transaction Status"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Query the status of a transaction"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Transaction ID"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("input",{placeholder:"Enter transaction ID (UUID)",value:M,onChange:r=>ce(r.target.value),className:"flex-1 h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring font-mono"}),M&&jsxRuntime.jsx("button",{onClick:()=>me(M),className:"w-8 h-8 border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center",title:"Copy to clipboard",children:jsxRuntime.jsx(ze,{})})]})]}),jsxRuntime.jsxs("button",{onClick:gt,disabled:w==="loading"||!M,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[w==="loading"?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(Ke,{}),"Check Status"]})]})]}),E==="toolkit"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Predict Provider"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Predict the provider from a phone number"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"+237 670 000 000",value:P,onChange:r=>se(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("button",{onClick:yt,disabled:w==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[w==="loading"?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(to,{}),"Predict Provider"]})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-3 gap-3",children:[jsxRuntime.jsxs("button",{onClick:ft,disabled:w==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(oo,{}),"Provider Availability"]}),jsxRuntime.jsxs("button",{onClick:bt,disabled:w==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(he,{}),"Active Config"]}),jsxRuntime.jsxs("button",{onClick:ht,disabled:w==="loading",className:"h-10 px-3 text-xs font-medium border border-border bg-background hover:bg-muted disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ro,{}),"Public Keys"]})]})]}),E==="finances"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Wallet Balances"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"View balances for all your wallets"})]}),jsxRuntime.jsxs("button",{onClick:vt,disabled:w==="loading",className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors flex items-center justify-center gap-2",children:[w==="loading"?jsxRuntime.jsx(H,{}):jsxRuntime.jsx(He,{}),"Get Wallet Balances"]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Statements"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate financial statements for your wallets"})]}),jsxRuntime.jsxs("div",{className:"p-4 bg-muted/50 text-xs text-muted-foreground",children:["Statement generation requires callback URL configuration. Use the SDK directly:",jsxRuntime.jsx("pre",{className:"mt-2 p-2 bg-background overflow-x-auto",children:`await sdk.finances.generateStatement({
2
2
  wallet: { country: 'CMR', currency: 'XAF' },
3
3
  callbackUrl: 'https://your-site.com/callback',
4
4
  startDate: '2025-01-01T00:00:00Z',
5
5
  endDate: '2025-01-31T23:59:59Z',
6
- });`})]})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Results"}),ee.length>0&&jsxRuntime.jsx("button",{onClick:()=>le([]),className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]}),jsxRuntime.jsx("div",{className:"border border-border bg-background divide-y divide-border max-h-[600px] overflow-y-auto",children:ee.length===0?jsxRuntime.jsx("div",{className:"p-6 text-center text-muted-foreground text-xs",children:"No results yet. Execute an operation to see results here."}):ee.map(n=>jsxRuntime.jsxs("div",{className:"p-4 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[n.status==="success"?jsxRuntime.jsx(lt,{className:"text-green-600"}):jsxRuntime.jsx(pt,{className:"text-red-600"}),jsxRuntime.jsx("span",{className:"font-medium text-sm",children:n.operation})]}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:n.timestamp})]}),n.error?jsxRuntime.jsx("p",{className:"text-xs text-red-600",children:n.error}):jsxRuntime.jsx("pre",{className:"text-xs bg-muted p-2 overflow-x-auto max-h-48",children:JSON.stringify(n.response,null,2)})]},n.id))})]})]})]}):jsxRuntime.jsxs("div",{className:`space-y-8 ${t}`,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"SDK Test Console"}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:"Configure your Pawapay SDK credentials to start testing"})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 max-w-md space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 bg-muted flex items-center justify-center",children:jsxRuntime.jsx(ne,{})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"font-semibold",children:"SDK Configuration"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your API credentials"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"API Key"}),jsxRuntime.jsx("input",{type:"password",placeholder:"pk_sandbox_...",value:p,onChange:n=>P(n.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Environment"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsx("button",{onClick:()=>se("sandbox"),className:`h-8 px-3 text-xs font-medium border transition-colors ${h==="sandbox"?"bg-primary text-primary-foreground border-primary":"bg-background border-border hover:bg-muted"}`,children:"Sandbox"}),jsxRuntime.jsx("button",{onClick:()=>se("production"),className:`h-8 px-3 text-xs font-medium border transition-colors ${h==="production"?"bg-primary text-primary-foreground border-primary":"bg-background border-border hover:bg-muted"}`,children:"Production"})]})]}),jsxRuntime.jsxs("button",{onClick:we,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ae,{}),"Initialize SDK"]}),jsxRuntime.jsxs("div",{className:"relative flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"}),jsxRuntime.jsx("span",{className:"flex-shrink mx-3 text-xs text-muted-foreground",children:"ou"}),jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"})]}),jsxRuntime.jsxs("button",{onClick:Pe,className:"w-full h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(mt,{}),"Mode D\xE9mo (sans API key)"]})]})]})]})}var ne=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),ae=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),ve=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"})}),ut=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})}),xe=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),G=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),dt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),lt=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),pt=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),mt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})}),gt=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),yt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),ft=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),ht=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})}),bt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})});exports.CORRESPONDENTS=U;exports.CORRESPONDENT_INFO=F;exports.DEFAULT_LIMITS=V;exports.ERROR_CODES=x;exports.Logger=W;exports.PawapayError=l;exports.PawapayTestDashboard=ct;exports.SpaarkPayApiSdk=re;//# sourceMappingURL=index.js.map
6
+ });`})]})]})]}),E==="webhooks"&&jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Webhook Secret"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure the secret used for signing webhooks"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Secret Key"}),jsxRuntime.jsx("input",{type:"text",placeholder:"whsec_...",value:we,onChange:r=>Ze(r.target.value),className:"w-full h-8 px-2.5 text-xs font-mono border border-input bg-transparent rounded-none outline-none focus:border-ring"})]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Webhook Simulator"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Generate mock webhook events for testing"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Event Type"}),jsxRuntime.jsx("select",{value:z,onChange:r=>Qe(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:Ve.map(r=>jsxRuntime.jsx("option",{value:r,children:r},r))})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Amount"}),jsxRuntime.jsx("input",{type:"number",placeholder:"5000",value:ke,onChange:r=>et(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Phone Number"}),jsxRuntime.jsx("input",{placeholder:"237670000000",value:Pe,onChange:r=>tt(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Provider"}),jsxRuntime.jsx("select",{value:Te,onChange:r=>ot(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:be.map(r=>jsxRuntime.jsxs("option",{value:r.value,children:[r.label," (",r.country,")"]},r.value))})]})]}),jsxRuntime.jsxs("button",{onClick:async()=>{let r=Ge(z,{amount:ke,phoneNumber:Pe,correspondent:Te}),c=JSON.stringify(r,null,2),b=await Be(JSON.stringify(r),we);rt(c),nt(b);let S={id:re(),eventType:z,payload:r,signature:b,receivedAt:new Date().toLocaleTimeString(),isVerified:null};Ee(ge=>[S,...ge].slice(0,50)),f("Generate Webhook","success",{eventType:z,eventId:r.eventId});},className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Generate Event"]}),ue&&jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Generated Payload"}),jsxRuntime.jsx("button",{onClick:()=>me(ue),className:"text-xs text-muted-foreground hover:text-foreground",children:"Copy"})]}),jsxRuntime.jsx("pre",{className:"text-xs bg-muted p-3 overflow-x-auto max-h-48",children:ue}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Signature:"}),jsxRuntime.jsx("code",{className:"text-xs bg-muted px-2 py-1 font-mono flex-1 overflow-x-auto",children:Ae}),jsxRuntime.jsx("button",{onClick:()=>me(Ae),className:"w-8 h-8 border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center",children:jsxRuntime.jsx(ze,{})})]})]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Signature Verifier"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Test webhook signature verification"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Payload (JSON)"}),jsxRuntime.jsx("textarea",{placeholder:'{"eventId": "...", "eventType": "deposit.completed", ...}',value:Se,onChange:r=>at(r.target.value),rows:4,className:"w-full px-2.5 py-2 text-xs font-mono border border-input bg-transparent rounded-none outline-none focus:border-ring resize-none"})]}),jsxRuntime.jsxs("div",{className:"grid sm:grid-cols-2 gap-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Signature"}),jsxRuntime.jsx("input",{placeholder:"HMAC-SHA256 signature",value:pe,onChange:r=>st(r.target.value),className:"w-full h-8 px-2.5 text-xs font-mono border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Secret"}),jsxRuntime.jsx("input",{type:"password",placeholder:"whsec_...",value:Oe,onChange:r=>it(r.target.value),className:"w-full h-8 px-2.5 text-xs font-mono border border-input bg-transparent rounded-none outline-none focus:border-ring"})]})]}),jsxRuntime.jsxs("button",{onClick:async()=>{try{let r=JSON.parse(Se),c=await Be(JSON.stringify(r),Oe),b=c===pe;Me(b),f("Verify Signature",b?"success":"error",{isValid:b,expected:c,received:pe});}catch{Me(false),f("Verify Signature","error",void 0,"Invalid JSON payload");}},className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ao,{}),"Verify Signature"]}),X!==null&&jsxRuntime.jsxs("div",{className:`p-3 text-xs flex items-center gap-2 ${X?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200"}`,children:[X?jsxRuntime.jsx(Xe,{className:"text-green-600"}):jsxRuntime.jsx(Ye,{className:"text-red-600"}),X?"Signature is valid":"Signature is invalid"]})]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Event Parser"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Parse and analyze raw webhook JSON"})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Raw JSON"}),jsxRuntime.jsx("textarea",{placeholder:"Paste webhook JSON here...",value:De,onChange:r=>ct(r.target.value),rows:4,className:"w-full px-2.5 py-2 text-xs font-mono border border-input bg-transparent rounded-none outline-none focus:border-ring resize-none"})]}),jsxRuntime.jsxs("button",{onClick:()=>{try{let r=JSON.parse(De);Ie(r),_e(""),f("Parse Event","success",{eventType:r.eventType,eventId:r.eventId});}catch(r){Ie(null),_e(r instanceof Error?r.message:"Invalid JSON"),f("Parse Event","error",void 0,"Invalid JSON");}},className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(so,{}),"Parse Event"]}),Le&&jsxRuntime.jsx("div",{className:"p-3 text-xs bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200",children:Le}),j&&jsxRuntime.jsxs("div",{className:"space-y-3",children:[jsxRuntime.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[jsxRuntime.jsxs("div",{className:"p-2 bg-muted",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Event ID:"}),jsxRuntime.jsx("p",{className:"font-mono truncate",children:String(j.eventId??"N/A")})]}),jsxRuntime.jsxs("div",{className:"p-2 bg-muted",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Event Type:"}),jsxRuntime.jsx("p",{className:"font-medium",children:String(j.eventType??"N/A")})]}),jsxRuntime.jsxs("div",{className:"p-2 bg-muted",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Timestamp:"}),jsxRuntime.jsx("p",{className:"font-mono truncate",children:String(j.timestamp??"N/A")})]}),jsxRuntime.jsxs("div",{className:"p-2 bg-muted",children:[jsxRuntime.jsx("span",{className:"text-muted-foreground",children:"Status:"}),jsxRuntime.jsx("p",{className:"font-medium",children:String(j.data?.status??"N/A")})]})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Full Data"}),jsxRuntime.jsx("pre",{className:"text-xs bg-muted p-3 overflow-x-auto max-h-48",children:JSON.stringify(j,null,2)})]})]})]})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Event Log"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"History of generated webhook events"})]}),jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[jsxRuntime.jsxs("select",{value:V,onChange:r=>dt(r.target.value),className:"h-8 px-2 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring",children:[jsxRuntime.jsx("option",{value:"all",children:"All"}),jsxRuntime.jsx("option",{value:"deposit",children:"Deposits"}),jsxRuntime.jsx("option",{value:"payout",children:"Payouts"}),jsxRuntime.jsx("option",{value:"refund",children:"Refunds"})]}),le.length>0&&jsxRuntime.jsx("button",{onClick:()=>Ee([]),className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]})]}),jsxRuntime.jsx("div",{className:"divide-y divide-border max-h-64 overflow-y-auto",children:le.filter(r=>V==="all"||r.eventType.startsWith(V)).length===0?jsxRuntime.jsx("div",{className:"p-4 text-center text-muted-foreground text-xs",children:"No events yet. Generate a webhook event to see it here."}):le.filter(r=>V==="all"||r.eventType.startsWith(V)).map(r=>jsxRuntime.jsxs("div",{className:"py-3 space-y-1",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("div",{className:"flex items-center gap-2",children:jsxRuntime.jsx("span",{className:`px-1.5 py-0.5 text-xs font-medium ${r.eventType.includes("completed")?"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200":r.eventType.includes("failed")?"bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200"}`,children:r.eventType})}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:r.receivedAt})]}),jsxRuntime.jsxs("div",{className:"text-xs text-muted-foreground font-mono truncate",children:["sig: ",r.signature.slice(0,32),"..."]})]},r.id))})]})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsx("h3",{className:"font-semibold",children:"Results"}),de.length>0&&jsxRuntime.jsx("button",{onClick:()=>Re([]),className:"text-xs text-muted-foreground hover:text-foreground",children:"Clear"})]}),jsxRuntime.jsx("div",{className:"border border-border bg-background divide-y divide-border max-h-[600px] overflow-y-auto",children:de.length===0?jsxRuntime.jsx("div",{className:"p-6 text-center text-muted-foreground text-xs",children:"No results yet. Execute an operation to see results here."}):de.map(r=>jsxRuntime.jsxs("div",{className:"p-4 space-y-2",children:[jsxRuntime.jsxs("div",{className:"flex items-center justify-between",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-2",children:[r.status==="success"?jsxRuntime.jsx(Xe,{className:"text-green-600"}):jsxRuntime.jsx(Ye,{className:"text-red-600"}),jsxRuntime.jsx("span",{className:"font-medium text-sm",children:r.operation})]}),jsxRuntime.jsx("span",{className:"text-xs text-muted-foreground",children:r.timestamp})]}),r.error?jsxRuntime.jsx("p",{className:"text-xs text-red-600",children:r.error}):jsxRuntime.jsx("pre",{className:"text-xs bg-muted p-2 overflow-x-auto max-h-48",children:JSON.stringify(r.response,null,2)})]},r.id))})]})]})]}):jsxRuntime.jsxs("div",{className:`space-y-8 ${t}`,children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Spaark Pay Console"}),jsxRuntime.jsx("p",{className:"text-muted-foreground mt-1",children:"Configurez vos identifiants PawaPay pour commencer"})]}),jsxRuntime.jsxs("div",{className:"border border-border bg-background p-6 max-w-md space-y-6",children:[jsxRuntime.jsxs("div",{className:"flex items-center gap-3",children:[jsxRuntime.jsx("div",{className:"w-10 h-10 bg-muted flex items-center justify-center",children:jsxRuntime.jsx(he,{})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h2",{className:"font-semibold",children:"SDK Configuration"}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter your API credentials"})]})]}),jsxRuntime.jsxs("div",{className:"space-y-4",children:[jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"API Key"}),jsxRuntime.jsx("input",{type:"password",placeholder:"pk_sandbox_...",value:l,onChange:r=>C(r.target.value),className:"w-full h-8 px-2.5 text-xs border border-input bg-transparent rounded-none outline-none focus:border-ring"})]}),jsxRuntime.jsxs("div",{className:"space-y-2",children:[jsxRuntime.jsx("label",{className:"text-xs font-medium",children:"Environnement"}),jsxRuntime.jsxs("div",{className:"flex gap-2",children:[jsxRuntime.jsxs("button",{onClick:()=>R("sandbox"),className:`h-8 px-3 text-xs font-medium border transition-colors flex items-center gap-1.5 ${m==="sandbox"?"bg-blue-600 text-white border-blue-600":"bg-background border-border hover:bg-muted"}`,children:[jsxRuntime.jsx("span",{className:`w-2 h-2 rounded-full ${m==="sandbox"?"bg-blue-200":"bg-blue-500"}`}),"Sandbox"]}),jsxRuntime.jsxs("button",{onClick:()=>R("production"),className:`h-8 px-3 text-xs font-medium border transition-colors flex items-center gap-1.5 ${m==="production"?"bg-green-600 text-white border-green-600":"bg-background border-border hover:bg-muted"}`,children:[jsxRuntime.jsx("span",{className:`w-2 h-2 rounded-full ${m==="production"?"bg-green-200":"bg-green-500"}`}),"Production"]})]}),jsxRuntime.jsx("p",{className:"text-xs text-muted-foreground",children:m==="sandbox"?"Utilisez le sandbox pour tester sans frais r\xE9els":"Attention : les transactions en production sont r\xE9elles"})]}),jsxRuntime.jsxs("button",{onClick:lt,className:"w-full h-8 px-3 text-xs font-medium bg-primary text-primary-foreground hover:bg-primary/90 transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(ne,{}),"Initialize SDK"]}),jsxRuntime.jsxs("div",{className:"relative flex items-center py-2",children:[jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"}),jsxRuntime.jsx("span",{className:"flex-shrink mx-3 text-xs text-muted-foreground",children:"ou"}),jsxRuntime.jsx("div",{className:"flex-grow border-t border-border"})]}),jsxRuntime.jsxs("button",{onClick:ut,className:"w-full h-8 px-3 text-xs font-medium border border-border bg-background hover:bg-muted transition-colors flex items-center justify-center gap-2",children:[jsxRuntime.jsx(Zt,{}),"Mode D\xE9mo (sans API key)"]})]})]})]})}var he=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),ne=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})]}),He=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z"})}),Jt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z"})}),Ke=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),H=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4 animate-spin",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})}),ze=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})}),Xe=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})}),Ye=({className:i=""})=>jsxRuntime.jsx("svg",{className:`w-4 h-4 ${i}`,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"})}),Zt=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"})}),Qt=()=>jsxRuntime.jsxs("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]}),eo=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})}),to=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}),oo=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0"})}),ro=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 7a2 2 0 012 2m4 0a6 6 0 01-7.743 5.743L11 17H9v2H7v2H4a1 1 0 01-1-1v-2.586a1 1 0 01.293-.707l5.964-5.964A6 6 0 1121 9z"})}),no=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 10V3L4 14h7v7l9-11h-7z"})}),ao=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z"})}),so=()=>jsxRuntime.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:jsxRuntime.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10 20l4-16m4 4l4 4-4 4M6 16l-4-4 4-4"})});exports.CORRESPONDENTS=$;exports.CORRESPONDENT_INFO=G;exports.DEFAULT_LIMITS=J;exports.ERROR_CODES=N;exports.Logger=q;exports.PawapayError=p;exports.PawapayTestDashboard=Yt;exports.SpaarkPayApiSdk=ye;//# sourceMappingURL=index.js.map
7
7
  //# sourceMappingURL=index.js.map