<?php

namespace WKO\Controllers\Woocommerce;

use Automattic\WooCommerce\Blocks\Integrations\IntegrationInterface;
use WKO\Helpers\Config;


class CheckoutObserver implements IntegrationInterface
{
    public function get_name()
    {
        return 'checkout-observer';
    }

    public function initialize()
    {
        $scriptUrl = Config::__dist("blocks/checkout-observer/index.js");
        $assetPath = Config::__dist("blocks/checkout-observer/index.asset.php");

        $scriptAsset = file_exists($assetPath)
            ? require_once $assetPath
            : [
                'dependencies' => [],
                'version' => Config::__version(),
            ];

        wp_register_script(
            'wc-koin-official/checkout-observer',
            $scriptUrl,
            $scriptAsset['dependencies'],
            $scriptAsset['version'],
            true
        );
    }

    public function get_script_handles()
    {
        return ['wc-koin-official/checkout-observer'];
    }

    public function get_editor_script_handles()
    {
        return ['wc-koin-official/checkout-observer'];
    }

    public function get_script_data()
    {
        return [];
    }
}
