<commit_before><?php

function Users_before_Q_responseExtras()
{
	Q_Response::addScript('{{Users}}/js/Users.js', 'Users');
	Q_Response::addScript('{{Users}}/js/UsersDevice.js', 'Users');
	$app = Q::app();
	$requireLogin = Q_Config::get('Users', 'requireLogin', array());
	$rl_array = array();
	foreach ($requireLogin as $rl => $value) {
		$rl_array[Q_Uri::url($rl)] = $value;
	}
	if (!Q_Request::isAjax()) {
		Q_Response::setScriptData('Q.plugins.Users.requireLogin', $rl_array);
		$successUrl = Q_Config::get('Users', 'uris', "$app/successUrl", "$app/home");
		$afterActivate = Q_Config::get('Users', 'uris', "$app/afterActivate", $successUrl);
		$loginOptions = Q_Config::get('Users', 'login', array(
			"identifierType" => 'email,mobile', 
			"userQueryUri" => 'Users/user',
			"using" => "native,wallet,facebook",
			"noRegister" => false
		));
		$loginOptions["afterActivate"] = Q_Uri::url($afterActivate);
		$loginOptions["successUrl"] = Q_Uri::url($successUrl);
		Q_Response::setScriptData('Q.plugins.Users.login.serverOptions', $loginOptions);
		$setIdentifierOptions = Q::take($loginOptions, array('identifierType'));
		Q_Response::setScriptData('Q.plugins.Users.setIdentifier.serverOptions', $setIdentifierOptions);
	}
	Q_Response::setScriptData('Q.plugins.Users.communityId', Users::communityId());
	Q_Response::setScriptData('Q.plugins.Users.communityName', Users::communityName());
	Q_Response::setScriptData('Q.plugins.Users.communitySuffix', Users::communitySuffix());
	Q_Response::setScriptData('Q.plugins.Users.currentCommunityId', Users::currentCommunityId());
	if ($sizes = Q_Image::getSizes('Users/icon', $maxStretch)) {
		ksort($sizes);
		Q_Response::setScriptData('Q.plugins.Users.icon.sizes', $sizes);
		Q_Response::setScriptData('Q.plugins.Users.icon.maxStretch', $maxStretch);
	}
	$defaultSize = Q_Image::getDefaultSize('Users/icon');
	Q_Response::setScriptData('Q.plugins.Users.icon.defaultSize', $defaultSize);
	Q_Response::addStylesheet("{{Users}}/css/Users.css", 'Users');
	$platforms = array(Q_Request::platform());
	foreach (Q_Config::get('Users', 'apps', 'export', array()) as $platform) {
		$platforms[] = $platform;
	}
	$platforms = array_unique($platforms);
	$browsers = array(Q_Request::browser());
	foreach (array('apps' => $platforms, 'browserApps' => $browsers) as $k => $arr) {
		$apps = array();
		foreach ($arr as $platform) {
			$appInfos = Q_Config::get('Users', 'apps', $platform, array());
			if (!$appInfos) continue;
			$private = Q_Config::get('Users', 'apps-private', $platform, array());
			foreach ($appInfos as $appName => $appInfo) {
				$apps[$platform][$appName] = $appInfo;
				foreach($appInfo as $key => $value) {
					if (stristr($key, 'private')) {
						unset($apps[$platform][$appName][$key]);
					}
				}
				foreach ($private as $p) {
					unset($apps[$platform][$appName][$p]);
				}
			}
		}
		Q_Response::setScriptData("Q.plugins.Users.$k", $apps);
	}

	// add apple signIn js lib
	if (Q_Request::platform() === 'ios') {
		Q_Response::addScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js', 'Users');
	}

	// fetch labels info
	Q_Response::setScriptData("Q.plugins.Users.labels", Users_Label::getLabels());
}<commit_msg>Load ethereum js libs if Users/apps/wallet config defined.<commit_after><?php

function Users_before_Q_responseExtras()
{
	Q_Response::addScript('{{Users}}/js/Users.js', 'Users');
	Q_Response::addScript('{{Users}}/js/UsersDevice.js', 'Users');
	$app = Q::app();
	$requireLogin = Q_Config::get('Users', 'requireLogin', array());
	$rl_array = array();
	foreach ($requireLogin as $rl => $value) {
		$rl_array[Q_Uri::url($rl)] = $value;
	}
	if (!Q_Request::isAjax()) {
		Q_Response::setScriptData('Q.plugins.Users.requireLogin', $rl_array);
		$successUrl = Q_Config::get('Users', 'uris', "$app/successUrl", "$app/home");
		$afterActivate = Q_Config::get('Users', 'uris', "$app/afterActivate", $successUrl);
		$loginOptions = Q_Config::get('Users', 'login', array(
			"identifierType" => 'email,mobile', 
			"userQueryUri" => 'Users/user',
			"using" => "native,wallet,facebook",
			"noRegister" => false
		));
		$loginOptions["afterActivate"] = Q_Uri::url($afterActivate);
		$loginOptions["successUrl"] = Q_Uri::url($successUrl);
		Q_Response::setScriptData('Q.plugins.Users.login.serverOptions', $loginOptions);
		$setIdentifierOptions = Q::take($loginOptions, array('identifierType'));
		Q_Response::setScriptData('Q.plugins.Users.setIdentifier.serverOptions', $setIdentifierOptions);
	}
	Q_Response::setScriptData('Q.plugins.Users.communityId', Users::communityId());
	Q_Response::setScriptData('Q.plugins.Users.communityName', Users::communityName());
	Q_Response::setScriptData('Q.plugins.Users.communitySuffix', Users::communitySuffix());
	Q_Response::setScriptData('Q.plugins.Users.currentCommunityId', Users::currentCommunityId());
	if ($sizes = Q_Image::getSizes('Users/icon', $maxStretch)) {
		ksort($sizes);
		Q_Response::setScriptData('Q.plugins.Users.icon.sizes', $sizes);
		Q_Response::setScriptData('Q.plugins.Users.icon.maxStretch', $maxStretch);
	}
	$defaultSize = Q_Image::getDefaultSize('Users/icon');
	Q_Response::setScriptData('Q.plugins.Users.icon.defaultSize', $defaultSize);
	Q_Response::addStylesheet("{{Users}}/css/Users.css", 'Users');
	$platforms = array(Q_Request::platform());
	foreach (Q_Config::get('Users', 'apps', 'export', array()) as $platform) {
		$platforms[] = $platform;
	}
	$platforms = array_unique($platforms);
	$browsers = array(Q_Request::browser());
	foreach (array('apps' => $platforms, 'browserApps' => $browsers) as $k => $arr) {
		$apps = array();
		foreach ($arr as $platform) {
			$appInfos = Q_Config::get('Users', 'apps', $platform, array());
			if (!$appInfos) continue;
			$private = Q_Config::get('Users', 'apps-private', $platform, array());
			foreach ($appInfos as $appName => $appInfo) {
				$apps[$platform][$appName] = $appInfo;
				foreach($appInfo as $key => $value) {
					if (stristr($key, 'private')) {
						unset($apps[$platform][$appName][$key]);
					}
				}
				foreach ($private as $p) {
					unset($apps[$platform][$appName][$p]);
				}
			}
		}
		Q_Response::setScriptData("Q.plugins.Users.$k", $apps);
	}

	// add apple signIn js lib
	if (Q_Request::platform() === 'ios') {
		Q_Response::addScript('https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js', 'Users');
	}

	// fetch labels info
	Q_Response::setScriptData("Q.plugins.Users.labels", Users_Label::getLabels());

	// load ethers js libs if wallet config defined
	if (Q_Config::get("Users", "apps", "wallet", Users::communityId(), null)) {
		Q_Response::addScript('{{Users}}/js/wallet/ethers-5.2.umd.min.js', 'Users');
		Q_Response::addScript('{{Users}}/js/wallet/evm-chains.min.js', 'Users');
		Q_Response::addScript('{{Users}}/js/wallet/fortmatic.js', 'Users');
		Q_Response::addScript('{{Users}}/js/wallet/walletconnect.min.js', 'Users');
		Q_Response::addScript('{{Users}}/js/wallet/web3.min.js', 'Users');
		Q_Response::addScript('{{Users}}/js/wallet/web3modal.js', 'Users');
	}
}
{'fraction_non_alphanumeric': 0.20839220118677593, 'fraction_numerical': 0.0008476970895733258, 'mean_word_length': 6.373958333333333, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '532476', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2448, 'n_words': 355}