<?php

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

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

require_once (dirname( __FILE__ ) . '/product-price-types-sale.php');

if ( !class_exists( 'Pricely_Admin_Product_Prices_Types' ) ) {

    class Pricely_Admin_Product_Prices_Types {

        private static $instance = null;

        public static function get_instance(): self {

            if ( null == self::$instance ) {

                self::$instance = new self();
            }

            return self::$instance;
        }

        public function get_modes( $args ) {

            return apply_filters( 'pricely_admin_product-pricing_get-mode-types', array(), $args );
        }

        public function get_mode_fields( $in_fields, $mode_type, $args ) {

            $fields = apply_filters( 'pricely_admin_product-pricing_get-mode-type-' . $mode_type . '-fields', array(), $args );

            foreach ( $fields as $field ) {

                if ( !isset( $field[ 'fold' ] ) ) {

                    $field[ 'fold' ] = array(
                        'target' => 'product_prices_mode',
                        'attribute' => 'value',
                        'value' => $mode_type,
                        'oparator' => 'eq',
                    );
                }

                $in_fields[] = $field;
            }

            return $in_fields;
        }

        public function get_adjustment_types( $args ) {

            return apply_filters( 'pricely_admin_product-pricing_get-adjustment-types', array(), $args );
        }

        public function get_adjustment_based_on_types( $args ) {

            return apply_filters( 'pricely_admin_product-pricing_get-adjustment-based-on-types', array(), $args );
        }

        public function get_default_adjustment_types( $args ) {
            
            if ( class_exists( 'Pricely_Admin_Product_Prices_Types_Regular' ) ) {

                return 'fixed_price';
            }

            return 'per_discount';
        }

        public function get_adjustment_based_on_visibility( $args ) {

            return apply_filters( 'pricely_admin_product-pricing_get-adjustment-based-on-visibility', array( 'per_discount', 'per_fee' ), $args );
        }

        public function get_calculate_from_visibility( $args ) {

            return apply_filters( 'pricely_admin_product-pricing_get-calculate-from-visibility', array( 'discount' => array( 'per_discount' ) ), $args );
        }

    }

}
 