<?php

if ( !defined( 'ABSPATH' ) ) {
    exit;
}

if ( !class_exists( 'Reon' ) ) {
    return;
}

if ( !class_exists( 'Pricely_Admin_Product_Prices_Panel_Conditions' ) ) {

    class Pricely_Admin_Product_Prices_Panel_Conditions {

        public function __construct() {

            add_filter( 'pricely_admin_product-pricing_get-panels', array( $this, 'get_panel' ), 100 );
        }

        public function get_panel( $in_fields ) {

            $in_fields[] = array(
                'id' => 'condition_args',
                'type' => 'panel',
                'full_width' => true,
                'center_head' => true,
                'white_panel' => true,
                'panel_size' => 'smaller',
                'width' => '100%',
                'merge_fields' => true,
                'last' => true,
                'field_css_class' => array( 'pricely_next_panel' ),
                'css_class' => array( 'rn-round-small' ),
                'fields' => $this->get_panel_fields( array() ),
            );

            return $in_fields;
        }

        private function get_panel_fields( $in_fields ) {

            $args = array(
                'module' => 'product-pricing',
                'format_text' => esc_html__( 'price adjustment', 'pricely-dynamic-pricing-cart-discounts' ),
            );

            return apply_filters( 'pricely_admin_get-panel-conditions-fields', $in_fields, $args );
        }

    }

    new Pricely_Admin_Product_Prices_Panel_Conditions();
}