public function createAsset(EmbeddedAsset $embeddedAsset, VolumeFolder $folder): Asset
	{
		$hasReplaceMb4 = method_exists(StringHelper::class, 'replaceMb4');

		$assetsService = Craft::$app->getAssets();
		$pluginSettings = EmbeddedAssets::$plugin->getSettings();

		$tempFilePath = Assets::tempFilePath();
		$fileContents = Json::encode($embeddedAsset, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);

		FileHelper::writeToFile($tempFilePath, $fileContents);

		$assetTitle = $embeddedAsset->title ?: $embeddedAsset->url;

		// Ensure the title contains no emoji
		if ($hasReplaceMb4)
		{
			$assetTitle = StringHelper::replaceMb4($assetTitle, '');
		}
		else if (StringHelper::containsMb4($assetTitle))
		{
			$assetTitle = preg_replace_callback('/./u', function(array $match): string
			{
				return strlen($match[0]) >= 4 ? '' : $match[0];
			}, $assetTitle);
		}

		$fileName = Assets::prepareAssetName($assetTitle, false);
		$fileName = str_replace('.', '', $fileName);
		$fileName = $fileName ?: 'embedded-asset';
		$fileName = StringHelper::safeTruncate($fileName, $pluginSettings->maxFileNameLength) . '.json';
		$fileName = $assetsService->getNameReplacementInFolder($fileName, $folder->id);

		$asset = new Asset();
		$asset->title = StringHelper::safeTruncate($assetTitle, $pluginSettings->maxAssetNameLength);
		$asset->tempFilePath = $tempFilePath;
		$asset->filename = $fileName;
		$asset->newFolderId = $folder->id;
		$asset->volumeId = $folder->volumeId;
		$asset->avoidFilenameConflicts = true;
		$asset->setScenario(Asset::SCENARIO_CREATE);

		return $asset;
	}