{"version":3,"file":"sdk.cjs","sources":["../src/inflowpay-provider.ts","../src/index.ts"],"sourcesContent":["/**\n * InflowPayProvider - Compatibility layer for React SDK API\n * \n * Provides the same API structure as the original React SDK\n * but works with vanilla JavaScript\n */\n\nimport type { CardElement, CardElementOptions } from './card-element';\nimport type { PaymentSDKConfig } from './payment-sdk';\nimport { PaymentSDK } from './payment-sdk';\nimport { PaymentResult } from './react';\nimport type { Locale } from './types';\n\nexport interface InflowPayProviderConfig {\n  publicKey: string;\n  locale?: Locale;\n}\n\nexport interface CardElementProps {\n  paymentId: string;\n  container?: string | HTMLElement;\n  onComplete?: (result: PaymentResult) => void;\n  onError?: (error: any) => void;\n  onClose?: () => void;\n  onReady?: () => void;\n  onChange?: (state: { complete: boolean }) => void;\n  buttonText?: string;\n  buttonStyle?: any;\n  style?: any;\n  placeholders?: {\n    cardNumber?: string;\n    expiry?: string;\n    cvc?: string;\n  };\n}\n\n/**\n * InflowPayProvider - Global SDK configuration\n * \n * Similar to React's InflowPayProvider but for vanilla JS\n * \n * @example\n * ```typescript\n * const provider = new InflowPayProvider({\n *   config: { apiKey: 'inflow_pub_xxx' }\n * });\n * \n * const cardElement = provider.createCardElement({\n *   paymentId: 'pay_xxx',\n *   onComplete: (result) => {\n *     if (result.status === 'CHECKOUT_SUCCESS') {\n *       window.location.href = '/success';\n *     }\n *   }\n * });\n * \n * cardElement.mount();\n * ```\n */\nexport class InflowPayProvider {\n  private sdk: PaymentSDK;\n\n  constructor(options: { config: InflowPayProviderConfig }) {\n    const config: PaymentSDKConfig = {\n      publicKey: options.config.publicKey,\n      locale: options.config.locale,\n    };\n\n    this.sdk = new PaymentSDK(config);\n  }\n\n  /**\n   * Create a CardElement (similar to React's <CardElement />)\n   * \n   * @param props - CardElement props (same as React SDK)\n   * @returns CardElement instance\n   */\n  createCardElement(props: CardElementProps): CardElement {\n    let container: string | HTMLElement;\n    if (props.container) {\n      container = props.container;\n    } else {\n      const defaultContainer = document.createElement('div');\n      defaultContainer.id = 'inflowpay-card-element-container';\n      document.body.appendChild(defaultContainer);\n      container = defaultContainer;\n    }\n\n    const cardElementOptions: CardElementOptions = {\n      container: container,\n      paymentId: props.paymentId,\n      ...(props.style && { style: props.style }),\n      ...(props.buttonText && { buttonText: props.buttonText }),\n      ...(props.placeholders && { placeholders: props.placeholders }),\n      onComplete: (result) => {\n        if (props.onComplete) {\n          props.onComplete(result);\n        }\n      },\n      onError: props.onError,\n      onClose: props.onClose,\n    };\n\n    const cardElement = this.sdk.createCardElement(cardElementOptions);\n\n    if (props.onReady) {\n      const originalMount = cardElement.mount.bind(cardElement);\n      cardElement.mount = () => {\n        originalMount();\n        setTimeout(() => {\n          if (props.onReady) {\n            props.onReady();\n          }\n        }, 100);\n      };\n    }\n\n    if (props.onChange) {\n      setTimeout(() => {\n        if (props.onChange) {\n          props.onChange({ complete: false });\n        }\n      }, 100);\n    }\n\n    return cardElement;\n  }\n\n  /**\n   * Get the underlying PaymentSDK instance\n   */\n  getSDK(): PaymentSDK {\n    return this.sdk;\n  }\n}\n\n","/**\n * InflowPay SDK v2 - Entry point\n * \n * Provides the same API as the original React SDK but using iframe-based payment flow\n * Compatible with vanilla JavaScript and easy migration from React SDK\n */\n\nexport { InflowPayProvider } from './inflowpay-provider';\nexport type { CardElementProps, InflowPayProviderConfig } from './inflowpay-provider';\n\nexport { PaymentSDK } from './payment-sdk';\nexport type { PaymentSDKConfig } from './payment-sdk';\n\nexport { CardElement } from './card-element';\nexport type { CardElementOptions } from './card-element';\n\nexport type {\n  CardElementState, PaymentConfig,\n  PaymentError,\n  PaymentResult\n} from './types';\n\nexport { PaymentResultErrorCode, PaymentResultStatus } from './types';\n\nexport const VERSION = '0.8.0';\n"],"names":["InflowPayProvider","options","config","PaymentSDK","props","container","defaultContainer","cardElementOptions","result","cardElement","originalMount","VERSION"],"mappings":"6HA2DO,MAAMA,CAAkB,CAG7B,YAAYC,EAA8C,CACxD,MAAMC,EAA2B,CAC/B,UAAWD,EAAQ,OAAO,UAC1B,OAAQA,EAAQ,OAAO,MAAA,EAGzB,KAAK,IAAM,IAAIE,EAAAA,WAAWD,CAAM,CAClC,CAQA,kBAAkBE,EAAsC,CACtD,IAAIC,EACJ,GAAID,EAAM,UACRC,EAAYD,EAAM,cACb,CACL,MAAME,EAAmB,SAAS,cAAc,KAAK,EACrDA,EAAiB,GAAK,mCACtB,SAAS,KAAK,YAAYA,CAAgB,EAC1CD,EAAYC,CACd,CAEA,MAAMC,EAAyC,CAC7C,UAAAF,EACA,UAAWD,EAAM,UACjB,GAAIA,EAAM,OAAS,CAAE,MAAOA,EAAM,KAAA,EAClC,GAAIA,EAAM,YAAc,CAAE,WAAYA,EAAM,UAAA,EAC5C,GAAIA,EAAM,cAAgB,CAAE,aAAcA,EAAM,YAAA,EAChD,WAAaI,GAAW,CAClBJ,EAAM,YACRA,EAAM,WAAWI,CAAM,CAE3B,EACA,QAASJ,EAAM,QACf,QAASA,EAAM,OAAA,EAGXK,EAAc,KAAK,IAAI,kBAAkBF,CAAkB,EAEjE,GAAIH,EAAM,QAAS,CACjB,MAAMM,EAAgBD,EAAY,MAAM,KAAKA,CAAW,EACxDA,EAAY,MAAQ,IAAM,CACxBC,EAAA,EACA,WAAW,IAAM,CACXN,EAAM,SACRA,EAAM,QAAA,CAEV,EAAG,GAAG,CACR,CACF,CAEA,OAAIA,EAAM,UACR,WAAW,IAAM,CACXA,EAAM,UACRA,EAAM,SAAS,CAAE,SAAU,EAAA,CAAO,CAEtC,EAAG,GAAG,EAGDK,CACT,CAKA,QAAqB,CACnB,OAAO,KAAK,GACd,CACF,CC9GO,MAAME,EAAU"}