(function( window, document, undefined ) {
    "use strict";
    
    if ( typeof window.wc === 'undefined' || typeof window.wc.wcBlocksRegistry === 'undefined' ) {
        return;
    }
    
    if ( typeof window.wp === 'undefined' || typeof window.wp.element === 'undefined' ) {
        return;
    }
    
    const { registerPaymentMethod } = window.wc.wcBlocksRegistry;
    const { createElement } = window.wp.element;
    const { __ } = window.wp.i18n;
    
    // Get payment method data from PHP - try multiple possible keys
    const paymentMethodData = window.wc.wcSettings.getSetting('cregispay_data', {}) || 
                              window.wc.wcSettings.getSetting('wc/cregispay', {});
    const description = paymentMethodData.description || __('Pay with cryptocurrencies using Cregis', 'cregis-payment-for-woocommerce');
    
    const contentElement = createElement('div', {
        className: 'cregis-payment-content'
    }, description);
    
    const editElement = createElement('div', {
        className: 'cregis-payment-edit'
    }, __('Cregis Payment', 'cregis-payment-for-woocommerce'));
    
    registerPaymentMethod({
        name: 'cregispay',
        label: __('Cregis Payment', 'cregis-payment-for-woocommerce'),
        description: description,
        ariaLabel: __('Cregis Payment', 'cregis-payment-for-woocommerce'),
        canMakePayment: function() {
            return true;
        },
        content: contentElement,
        edit: editElement,
        supports: {
            features: ['products']
        }
    });
    
})( window, document );
