// phpcs:ignoreFile
/**
 * Admin Documentation JS.
 *
 * @package HJCyberX_Checkout_For_Paddle_Lite
 */

function pkSwitchTab(evt, tabId) {
	var i, tabcontent, tablinks, len;
	tabcontent = document.getElementsByClassName( "pk-tab-pane" );
	len        = tabcontent.length;
	for (i = 0; i < len; i++) {
		tabcontent[i].classList.remove( "active" );
	}
	tablinks = document.getElementsByClassName( "pk-nav-item" );
	len      = tablinks.length;
	for (i = 0; i < len; i++) {
		tablinks[i].classList.remove( "active" );
	}
	document.getElementById( tabId ).classList.add( "active" );
	evt.currentTarget.classList.add( "active" );
}

function pkCopyToClipboard(elementId) {
	var text = document.getElementById( elementId ).innerText;
	var elem = document.createElement( "textarea" );
	document.body.appendChild( elem );
	elem.value = text;
	elem.select();
	document.execCommand( "copy" );
	document.body.removeChild( elem );

	var btn              = event.target;
	var origText         = btn.innerText;
	btn.innerText        = (typeof pkLiteData !== 'undefined' && pkLiteData.copiedText) ? pkLiteData.copiedText : "Copied!";
	btn.style.background = "#059669";
	setTimeout(
		function () {
			btn.innerText        = origText;
			btn.style.background = "";
		},
		2000
	);
}
