;(function($) {
    'use strict';

    let timerId = null;

    $('.wp-list-table .gutendraw-shortcode .gutendraw-btn').attr({'style':null});

    $('.wp-list-table').on('click', '.gutendraw-shortcode .gutendraw-btn', (e) => {
        const $btn = $(e.currentTarget);
        const shortcode = $btn.siblings('.gutendraw-val').text();

        if (navigator?.clipboard?.writeText) {
            navigator.clipboard.writeText(shortcode);

            $btn.addClass('gutendraw-done');

            clearTimeout(timerId);
            timerId = setTimeout(() => {
                $btn.removeClass('gutendraw-done');
            }, 1000);
        }
    });
})(jQuery);