diff --git a/classes/Storage/Driver/Backblaze/BackblazeSettings.php b/classes/Storage/Driver/Backblaze/BackblazeSettings.php new file mode 100755 index 00000000..d159a111 --- /dev/null +++ b/classes/Storage/Driver/Backblaze/BackblazeSettings.php @@ -0,0 +1,42 @@ + ['mcloud-storage-backblaze-account-id', 'ILAB_BACKBLAZE_ACCOUNT_ID', null], + 'key' => ['mcloud-storage-backblaze-key', 'ILAB_BACKBLAZE_KEY', null], + 'bucket' => ['mcloud-storage-s3-bucket', ['ILAB_AWS_S3_BUCKET','ILAB_CLOUD_BUCKET'], null], + 'settingsError' => ['ilab-backblaze-settings-error', null, false], + ]; +} \ No newline at end of file diff --git a/classes/Storage/Driver/Backblaze/BackblazeStorage.php b/classes/Storage/Driver/Backblaze/BackblazeStorage.php index 4000bf4b..6b96a0a2 100755 --- a/classes/Storage/Driver/Backblaze/BackblazeStorage.php +++ b/classes/Storage/Driver/Backblaze/BackblazeStorage.php @@ -27,49 +27,39 @@ use ILAB\MediaCloud\Storage\StorageException; use ILAB\MediaCloud\Storage\StorageFile; use ILAB\MediaCloud\Storage\StorageInterface; +use ILAB\MediaCloud\Storage\StorageManager; +use function ILAB\MediaCloud\Utilities\anyNull; +use function ILAB\MediaCloud\Utilities\arrayPath; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\Logging\ErrorCollector; use ILAB\MediaCloud\Utilities\Logging\Logger; use ILAB\MediaCloud\Utilities\NoticeManager; +use ILAB\MediaCloud\Wizard\ConfiguresWizard; +use ILAB\MediaCloud\Wizard\StorageWizardTrait; +use ILAB\MediaCloud\Wizard\WizardBuilder; if(!defined('ABSPATH')) { header('Location: /'); die; } -class BackblazeStorage implements StorageInterface, AuthCacheInterface { - //region Properties - /*** @var string */ - protected $accountId = null; - - /*** @var string */ - protected $key = null; +class BackblazeStorage implements StorageInterface, AuthCacheInterface, ConfiguresWizard { + use StorageWizardTrait; - /*** @var string */ - protected $bucket = null; + //region Properties + /** @var BackblazeSettings|null */ + protected $settings = null; /*** @var string */ protected $bucketUrl = false; - /*** @var bool */ - protected $settingsError = false; - /*** @var Client */ protected $client = null; //endregion //region Constructor public function __construct() { - $this->bucket = Environment::Option('mcloud-storage-s3-bucket', [ - 'ILAB_AWS_S3_BUCKET', - 'ILAB_CLOUD_BUCKET' - ]); - - $this->key = Environment::Option('mcloud-storage-backblaze-key', 'ILAB_BACKBLAZE_KEY'); - $this->accountId = Environment::Option('mcloud-storage-backblaze-account-id', 'ILAB_BACKBLAZE_ACCOUNT_ID'); - - $this->settingsError = get_option('ilab-backblaze-settings-error', false); - + $this->settings = new BackblazeSettings(); $this->client = $this->getClient(); } //endregion @@ -109,7 +99,7 @@ public function pathLink($bucket, $key) { //endregion //region Enabled/Options - public function usesSignedURLs() { + public function usesSignedURLs($type = null) { return false; } @@ -127,7 +117,7 @@ public function supportsBrowser() { */ public function validateSettings($errorCollector = null) { delete_option('ilab-backblaze-settings-error'); - $this->settingsError = false; + $this->settings->settingsError = false; $this->client = null; $valid = false; @@ -139,7 +129,7 @@ public function validateSettings($errorCollector = null) { $buckets = $client->listBuckets(); foreach($buckets as $bucket) { /** @var $bucket Bucket */ - if ($bucket->getName() == $this->bucket) { + if ($bucket->getName() == $this->settings->bucket) { $valid = true; break; } @@ -147,13 +137,13 @@ public function validateSettings($errorCollector = null) { if (!$valid) { if ($errorCollector) { - $errorCollector->addError("Unable to find bucket named {$this->bucket}."); + $errorCollector->addError("Unable to find bucket named {$this->settings->bucket}."); } } } if(!$valid) { - $this->settingsError = true; + $this->settings->settingsError = true; update_option('ilab-backblaze-settings-error', true); } else { $this->client = $client; @@ -168,14 +158,14 @@ public function validateSettings($errorCollector = null) { } public function enabled() { - if(!($this->key && $this->accountId && $this->bucket)) { + if(!($this->settings->key && $this->settings->accountId && $this->settings->bucket)) { $adminUrl = admin_url('admin.php?page=media-cloud-settings&tab=storage'); NoticeManager::instance()->displayAdminNotice('error', "To start using Cloud Storage, you will need to supply your Backblaze credentials..", true, 'ilab-cloud-storage-setup-warning', 'forever'); return false; } - if($this->settingsError) { + if($this->settings->settingsError) { NoticeManager::instance()->displayAdminNotice('error', 'Your Backblaze settings are incorrect or the bucket does not exist. Please verify your settings and update them.'); return false; @@ -185,7 +175,7 @@ public function enabled() { } public function settingsError() { - return $this->settingsError; + return $this->settings->settingsError; } public function client() { @@ -209,13 +199,13 @@ protected function getClient() { } try { - $client = new Client($this->accountId, $this->key, [], $this); + $client = new Client($this->settings->accountId, $this->settings->key, [], $this); - $this->bucketUrl = $client->downloadUrl().'/file/'.$this->bucket.'/'; + $this->bucketUrl = $client->downloadUrl().'/file/'.$this->settings->bucket.'/'; return $client; } catch (B2Exception $ex) { - $this->settingsError = true; + $this->settings->settingsError = true; update_option('ilab-backblaze-settings-error', true); } } @@ -224,7 +214,7 @@ protected function getClient() { //region File Functions public function bucket() { - return $this->bucket; + return $this->settings->bucket; } public function region() { @@ -239,12 +229,7 @@ public function exists($key) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $fileId = $this->mapKeyToFileId($key); - if (empty($fileId)) { - return false; - } - - return $this->client->fileExists(['BucketName' => $this->bucket, 'FileName' => $key]); + return $this->client->fileExists(['BucketName' => $this->settings->bucket, 'FileName' => $key]); } public function copy($sourceKey, $destKey, $acl, $mime = false, $cacheControl = false, $expires = false) { @@ -258,7 +243,7 @@ public function upload($key, $fileName, $acl, $cacheControl=null, $expires=null, try { Logger::startTiming("Start Upload", ['file' => $key]); $this->client->upload([ - 'BucketName' => $this->bucket, + 'BucketName' => $this->settings->bucket, 'FileName' => $key, 'Body' => fopen($fileName, 'r') ]); @@ -281,11 +266,11 @@ public function delete($key) { } try { - $this->client->deleteFile(['BucketName' => $this->bucket, 'FileName' => $key]); + $this->client->deleteFile(['BucketName' => $this->settings->bucket, 'FileName' => $key]); } catch(\Exception $ex) { Logger::error('Backblaze Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -309,7 +294,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Backblaze Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $file->key() ]); } @@ -324,7 +309,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Backblaze Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $file->key() ]); } @@ -336,7 +321,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Backblaze Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -349,7 +334,7 @@ public function dir($path = '', $delimiter = '/') { /** @var File[] $files */ $storageFiles = $this->client->listFiles([ - 'BucketName' => $this->bucket, + 'BucketName' => $this->settings->bucket, 'prefix' => $path, 'delimiter' => $delimiter ]); @@ -374,7 +359,7 @@ public function ls($path = '', $delimiter = '/') { /** @var File[] $files */ $storageFiles = $this->client->listFiles([ - 'BucketName' => $this->bucket, + 'BucketName' => $this->settings->bucket, 'prefix' => $path, 'delimiter' => $delimiter ]); @@ -395,7 +380,7 @@ public function info($key) { } try { - $file = $this->client->getFile(['BucketName' => $this->bucket, 'FileName' => $key]); + $file = $this->client->getFile(['BucketName' => $this->settings->bucket, 'FileName' => $key]); $length = $file->getSize(); $type = $file->getType(); } @@ -424,7 +409,7 @@ public function presignedUrl($key, $expiration = 0) { return $this->bucketUrl.$key; } - public function url($key) { + public function url($key, $type = null) { return $this->bucketUrl.$key; } //endregion @@ -439,7 +424,7 @@ public function enqueueUploaderScripts() { //region Adapter public function adapter() { - return new BackblazeAdapter($this->client, $this->bucket); + return new BackblazeAdapter($this->client, $this->settings->bucket); } //endregion @@ -470,4 +455,104 @@ public function cachedB2Auth($key) { return $authData['data']; } //endregion + + + //region Wizard + + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-backblaze', true); + } + + $builder + ->section('cloud-storage-backblaze', true) + ->select('Getting Started', 'Learn about Backblaze and how to set it up to work with Media Cloud.') + ->group('wizard.cloud-storage.providers.backblaze.intro', 'select-buttons') + ->option('read-tutorial', 'Step By Step Tutorial', null, null, 'cloud-storage-backblaze-tutorial') + ->endGroup() + ->endStep() + ->form('wizard.cloud-storage.providers.backblaze.form', 'Cloud Storage Settings', 'Configure Media Cloud with your cloud storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'backblaze') + ->textField('mcloud-storage-backblaze-account-id', 'Account Id or Key Id', '', null) + ->passwordField('mcloud-storage-backblaze-key', 'Key', '', null) + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->endStep() + ->testStep('wizard.cloud-storage.providers.backblaze.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.backblaze.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + $builder + ->tutorialSection('cloud-storage-backblaze-tutorial', true) + ->tutorial('wizard.cloud-storage.providers.backblaze.tutorial.step-1', 'Create Bucket', 'Create the bucket you will be using with Media Cloud.') + ->tutorial('wizard.cloud-storage.providers.backblaze.tutorial.step-2', 'Create Application Key', 'Generate the API keys Media Cloud uses to access Backblaze.', null, true) + ->endSection(); + + return $builder; + } + + public static function processWizardSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'update-storage-settings')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + $providerName = 'mcloud-storage-provider'; + $accessKeyName = 'mcloud-storage-backblaze-account-id'; + $secretName = 'mcloud-storage-backblaze-key'; + $bucketName = 'mcloud-storage-s3-bucket'; + + $provider = arrayPath($_POST, $providerName, null); + $accessKey = arrayPath($_POST, $accessKeyName, null); + $secret = arrayPath($_POST, $secretName, null); + $bucket = arrayPath($_POST, $bucketName, null); + + if (anyNull($provider, $accessKey, $secret, $bucket)) { + wp_send_json(['status' => 'error', 'message' => 'Missing required fields'], 200); + } + + $oldProvider = Environment::ReplaceOption($providerName, $provider); + $oldBucket = Environment::ReplaceOption($bucketName, $bucket); + $oldKey = Environment::ReplaceOption($accessKeyName, $accessKey); + $oldSecret = Environment::ReplaceOption($secretName, $secret); + + StorageManager::resetStorageInstance(); + + try { + $storage = new static(); + $restoreOld = !$storage->validateSettings(); + } catch (\Exception $ex) { + $restoreOld = true; + } + + if ($restoreOld) { + Environment::UpdateOption($providerName, $oldProvider); + Environment::UpdateOption($bucketName, $oldBucket); + Environment::UpdateOption($accessKeyName, $oldKey); + Environment::UpdateOption($secretName, $oldSecret); + + StorageManager::resetStorageInstance(); + + $message = "There was a problem with your settings. Please double check entries for potential mistakes."; + + wp_send_json([ 'status' => 'error', 'message' => $message], 200); + } else { + wp_send_json([ 'status' => 'ok'], 200); + } + } + + //endregion + } diff --git a/classes/Storage/Driver/GoogleCloud/GoogleStorage.php b/classes/Storage/Driver/GoogleCloud/GoogleStorage.php index 89b4f8b2..7d39f71e 100755 --- a/classes/Storage/Driver/GoogleCloud/GoogleStorage.php +++ b/classes/Storage/Driver/GoogleCloud/GoogleStorage.php @@ -26,10 +26,18 @@ use ILAB\MediaCloud\Storage\StorageException; use ILAB\MediaCloud\Storage\StorageFile; use ILAB\MediaCloud\Storage\StorageInterface; +use ILAB\MediaCloud\Storage\StorageGlobals; +use function ILAB\MediaCloud\Utilities\anyNull; +use function ILAB\MediaCloud\Utilities\arrayPath; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\Logging\ErrorCollector; use ILAB\MediaCloud\Utilities\Logging\Logger; use ILAB\MediaCloud\Utilities\NoticeManager; +use ILAB\MediaCloud\Utilities\Tracker; +use function ILAB\MediaCloud\Utilities\vomit; +use ILAB\MediaCloud\Wizard\ConfiguresWizard; +use ILAB\MediaCloud\Wizard\StorageWizardTrait; +use ILAB\MediaCloud\Wizard\WizardBuilder; use League\Flysystem\AdapterInterface; use Superbalist\Flysystem\GoogleStorage\GoogleStorageAdapter; @@ -38,18 +46,17 @@ die; } -class GoogleStorage implements StorageInterface { +class GoogleStorage implements StorageInterface, ConfiguresWizard { + use StorageWizardTrait; + const GOOGLE_ACL = [ StorageConstants::ACL_PRIVATE_READ => 'authenticatedRead', StorageConstants::ACL_PUBLIC_READ => 'publicRead' ]; //region Properties - /*** @var string */ - private $credentials = null; - - /*** @var string */ - private $bucket = null; + /** @var GoogleStorageSettings */ + protected $settings = null; /*** @var bool */ private $settingsError = false; @@ -60,51 +67,13 @@ class GoogleStorage implements StorageInterface { /** @var null|AdapterInterface */ protected $adapter = null; - /** @var bool */ - protected $usePresignedURLs = false; - - /** @var int */ - protected $presignedURLExpiration = 300; - - /** @var bool */ - protected $useBucketPolicyOnly = false; //endregion //region Constructor public function __construct() { - $this->bucket = Environment::Option('mcloud-storage-google-bucket', [ - 'ILAB_CLOUD_GOOGLE_BUCKET', - 'ILAB_AWS_S3_BUCKET', - 'ILAB_CLOUD_BUCKET' - ]); - - $credFile = Environment::Option('mcloud-storage-google-credentials-file', 'ILAB_CLOUD_GOOGLE_CREDENTIALS'); - if (!empty($credFile)) { - if (file_exists($credFile)) { - $this->credentials = json_decode(file_get_contents($credFile), true); - } else { - Logger::error("Credentials file '$credFile' could not be found."); - } - } - - if (empty($this->credentials)) { - $creds = Environment::Option('mcloud-storage-google-credentials'); - if (!empty($creds)) { - $this->credentials = json_decode($creds, true); - } - } + $this->settings = new GoogleStorageSettings(); $this->settingsError = Environment::Option('mcloud-google-settings-error', null, false); - - $this->usePresignedURLs = Environment::Option('mcloud-storage-use-presigned-urls', null, false); - $this->presignedURLExpiration = Environment::Option('mcloud-storage-presigned-expiration', null, 300); - if (empty($this->presignedURLExpiration)) { - $this->presignedURLExpiration = 300; - } - - $this->useBucketPolicyOnly = Environment::Option('mcloud-storage-bucket-policy-only', null, false); - - $this->client = $this->getClient(); } //endregion @@ -153,12 +122,56 @@ public function pathLink($bucket, $key) { //endregion //region Enabled/Options - public function usesSignedURLs() { - return $this->usePresignedURLs; + public function usesSignedURLs($type = null) { + if (($type == null) || (!empty($this->settings->usePresignedURLs))) { + return $this->settings->usePresignedURLs; + } + + if (strpos($type, 'image') === 0) { + return $this->settings->usePresignedURLsForImages; + } + + if (strpos($type, 'video') === 0) { + return $this->settings->usePresignedURLsForVideo; + } + + if (strpos($type, 'audio') === 0) { + return $this->settings->usePresignedURLsForAudio; + } + + if ((strpos($type, 'application') === 0) || (strpos($type, 'text') === 0)) { + return $this->settings->usePresignedURLsForDocs; + } + + return $this->settings->usePresignedURLs; } + public function signedURLExpirationForType($type = null) { + if (($type == null) || (!empty($this->settings->usePresignedURLs))) { + return $this->settings->presignedURLExpiration; + } + + if (strpos($type, 'image') === 0) { + return (empty($this->settings->presignedURLExpirationForImages)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForImages; + } + + if (strpos($type, 'video') === 0) { + return (empty($this->settings->presignedURLExpirationForVideo)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForVideo; + } + + if (strpos($type, 'audio') === 0) { + return (empty($this->settings->presignedURLExpirationForAudio)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForAudio; + } + + if ((strpos($type, 'application') === 0) || (strpos($type, 'text') === 0)) { + return (empty($this->settings->presignedURLExpirationForDocs)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForDocs; + } + + return $this->settings->presignedURLExpiration; + } + public function usesBucketPolicyOnly() { - return $this->useBucketPolicyOnly; + return $this->settings->useBucketPolicyOnly; } public function supportsDirectUploads() { @@ -185,18 +198,18 @@ public function validateSettings($errorCollector = null) { if($client) { try { - if($client->bucket($this->bucket)->exists()) { + if($client->bucket($this->settings->bucket)->exists()) { $valid = true; } else { if ($errorCollector) { - $errorCollector->addError("Bucket {$this->bucket} does not exist."); + $errorCollector->addError("Bucket {$this->settings->bucket} does not exist."); } Logger::info("Bucket does not exist."); } } catch (\Exception $ex) { if ($errorCollector) { - $errorCollector->addError("Error insuring that {$this->bucket} exists. Message: ".$ex->getMessage()); + $errorCollector->addError("Error insuring that {$this->settings->bucket} exists. Message: ".$ex->getMessage()); } Logger::error("Google Storage Error", ['exception' => $ex->getMessage()]); @@ -219,7 +232,7 @@ public function validateSettings($errorCollector = null) { } public function enabled() { - if(empty($this->credentials) || (!is_array($this->credentials)) || empty($this->bucket)) { + if(empty($this->settings->credentials) || (!is_array($this->settings->credentials)) || empty($this->settings->bucket)) { $adminUrl = admin_url('admin.php?page=media-cloud-settings&tab=storage'); NoticeManager::instance()->displayAdminNotice('info', "Welcome to Media Cloud! To get started, configure your cloud storage.", true, 'ilab-cloud-storage-setup-warning', 'forever'); return false; @@ -261,10 +274,10 @@ protected function getClient($errorCollector = null) { } $client = null; - if (!empty($this->credentials) && is_array($this->credentials)) { + if (!empty($this->settings->credentials) && is_array($this->settings->credentials)) { $client = new StorageClient([ - 'projectId' => $this->credentials['project_id'], - 'keyFile' => $this->credentials, + 'projectId' => $this->settings->credentials['project_id'], + 'keyFile' => $this->settings->credentials, 'scopes' => StorageClient::FULL_CONTROL_SCOPE ]); } @@ -283,7 +296,7 @@ protected function getClient($errorCollector = null) { //region File Functions public function bucket() { - return $this->bucket; + return $this->settings->bucket; } public function region() { @@ -292,7 +305,7 @@ public function region() { public function insureACL($key, $acl) { if (!$this->usesBucketPolicyOnly()) { - $object = $this->client->bucket($this->bucket)->object($key); + $object = $this->client->bucket($this->settings->bucket)->object($key); $object->update(['acl' => []], ['predefinedAcl' => self::GOOGLE_ACL[$acl]]); } } @@ -302,7 +315,7 @@ public function exists($key) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - return $this->client->bucket($this->bucket)->object($key)->exists(); + return $this->client->bucket($this->settings->bucket)->object($key)->exists(); } public function copy($sourceKey, $destKey, $acl, $mime = false, $cacheControl = false, $expires = false) { @@ -310,7 +323,7 @@ public function copy($sourceKey, $destKey, $acl, $mime = false, $cacheControl = throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $bucket = $this->client->bucket($this->bucket); + $bucket = $this->client->bucket($this->settings->bucket); $sourceObject = $bucket->object($sourceKey); @@ -337,7 +350,7 @@ public function upload($key, $fileName, $acl, $cacheControl=null, $expires=null, throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $bucket = $this->client->bucket($this->bucket); + $bucket = $this->client->bucket($this->settings->bucket); $metadata = []; if (!empty($cacheControl)) { @@ -388,7 +401,7 @@ public function delete($key) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $bucket = $this->client->bucket($this->bucket); + $bucket = $this->client->bucket($this->settings->bucket); try { $bucket->object($key)->delete(); @@ -402,7 +415,7 @@ public function info($key) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $object = $this->client->bucket($this->bucket)->object($key); + $object = $this->client->bucket($this->settings->bucket)->object($key); $info = $object->info(); $length = $info['size']; $type = $info['contentType']; @@ -410,7 +423,12 @@ public function info($key) { $url = $object->gcsUri(); $url = str_replace('gs://', static::defaultDownloadUrl().'/', $url); - $presignedUrl = $object->signedUrl(new Timestamp(new \DateTime("+{$this->presignedURLExpiration} minutes"))); + $expiration = $this->settings->presignedURLExpiration; + if (empty($expiration)) { + $expiration = 1; + } + + $presignedUrl = $object->signedUrl(new Timestamp(new \DateTime("+{$expiration} minutes"))); $size = null; if(strpos($type, 'image/') === 0) { @@ -432,7 +450,7 @@ public function createDirectory($key) { $key = trailingslashit($key); - $bucket = $this->client->bucket($this->bucket); + $bucket = $this->client->bucket($this->settings->bucket); try { Logger::startTiming("Start Create Directory", ['file' => $key]); @@ -474,7 +492,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Google Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $file->key() ]); } @@ -489,7 +507,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Google Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $file->key() ]); } @@ -501,7 +519,7 @@ public function deleteDirectory($key) { } catch (\Exception $ex) { Logger::error('Google Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -512,7 +530,7 @@ public function dir($path = '', $delimiter = '/') { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $fileIter = $this->client->bucket($this->bucket)->objects([ + $fileIter = $this->client->bucket($this->settings->bucket)->objects([ 'prefix' => $path, 'delimiter' => $delimiter ]); @@ -547,7 +565,7 @@ public function ls($path = '', $delimiter = '/') { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $fileIter = $this->client->bucket($this->bucket)->objects([ + $fileIter = $this->client->bucket($this->settings->bucket)->objects([ 'prefix' => $path, 'delimiter' => $delimiter ]); @@ -569,23 +587,24 @@ public function ls($path = '', $delimiter = '/') { //region URLs public function presignedUrl($key, $expiration = 0) { if (empty($expiration)) { - $expiration = $this->presignedURLExpiration; + $expiration = $this->settings->presignedURLExpiration; } - $object = $this->client->bucket($this->bucket)->object($key); + $object = $this->client->bucket($this->settings->bucket)->object($key); return $object->signedUrl(new Timestamp(new \DateTime("+{$expiration} minutes"))); } - public function url($key) { + public function url($key, $type = null) { if(!$this->client) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - if ($this->usePresignedURLs) { - return $this->presignedUrl($key); + if ($this->usesSignedURLs($type)) { + $expiration = $this->signedURLExpirationForType($type); + return $this->presignedUrl($key, $expiration); } - $object = $this->client->bucket($this->bucket)->object($key); + $object = $this->client->bucket($this->settings->bucket)->object($key); $url = $object->gcsUri(); $url = str_replace('gs://', static::defaultDownloadUrl().'/', $url); return $url; @@ -599,7 +618,7 @@ public function uploadUrl($key, $acl, $mimeType=null, $cacheControl = null, $exp throw new InvalidStorageSettingsException('Storage settings are invalid'); } - $bucket = $this->client->bucket($this->bucket); + $bucket = $this->client->bucket($this->settings->bucket); $object = $bucket->object($key); $options=[]; @@ -633,8 +652,107 @@ public function adapter() { return $this->adapter; } - $this->adapter = new GoogleStorageAdapter($this->client, $this->client->bucket($this->bucket)); + $this->adapter = new GoogleStorageAdapter($this->client, $this->client->bucket($this->settings->bucket)); return $this->adapter; } //endregion + + //region Wizard + + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-google', true); + } + + $builder + ->section('cloud-storage-google', true) + ->select('Getting Started', 'Learn about Google Cloud Storage and how to setup your Google Cloud account to work with Media Cloud.') + ->group('wizard.cloud-storage.providers.google.intro', 'select-buttons') + ->option('read-tutorial', 'Step By Step Tutorial', null, null, 'cloud-storage-s3-tutorial') + ->endGroup() + ->endStep() + ->form('wizard.cloud-storage.providers.google.form', 'Google Cloud Storage Settings', 'Configure Media Cloud with your Google Cloud Storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'google') + ->uploadField('mcloud-storage-google-credentials-file', 'Credentials JSON File', 'The JSON file containing your Google Cloud Storage credentials.', false) + ->textField('mcloud-storage-google-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->checkboxField('mcloud-storage-bucket-policy-only', 'Use Bucket Policy Only', "Set to true to when using a bucket which has the 'Bucket Policy Only' flag enabled. See this documentation for more information. Also, make sure to make the bucket public, as specified in this documentation.", false) + ->endStep() + ->testStep('wizard.cloud-storage.providers.google.test', 'Test Settings', 'Perform tests to insure that Google Cloud Storage is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.google.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + $builder + ->tutorialSection('cloud-storage-google-tutorial', true) + ->tutorial('wizard.cloud-storage.providers.google.tutorial.step-1', 'Create Role', 'Create a role that defines what capabilities are going to be granted to Media Cloud.') + ->tutorial('wizard.cloud-storage.providers.google.tutorial.step-2', 'Create Service Account', 'Create a service account that allows Media Cloud to interact with Google Cloud Storage.', null, true) + ->tutorial('wizard.cloud-storage.providers.google.tutorial.step-3', 'Create Bucket', 'Create the bucket we’ll be using with Media Cloud.', null, true) + ->tutorial('wizard.cloud-storage.providers.google.tutorial.step-4', 'CORS Configuration (Optional)', 'If you plan on using the Direct Uploads functionality, learn how to configure CORS to make that happen.', null, true) + ->endSection(); + + return $builder; + } + + public static function processWizardSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'update-storage-settings')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + if (isset($_FILES['mcloud-storage-google-credentials-file'])) { + $credentials = file_get_contents($_FILES['mcloud-storage-google-credentials-file']['tmp_name']); + } + + if (empty($credentials)) { + $credentials = Environment::Option('mcloud-storage-google-credentials'); + } + + + $bucket = arrayPath($_POST, 'mcloud-storage-google-bucket', null); + $bucketPolicyOnly = arrayPath($_POST, 'mcloud-storage-bucket-policy-only', false); + + if (anyNull($credentials, $bucket)) { + wp_send_json(['status' => 'error', 'message' => 'Missing required fields'], 200); + } + + $oldProvider = Environment::ReplaceOption('mcloud-storage-provider', 'google'); + $oldCredentials = Environment::ReplaceOption('mcloud-storage-google-credentials', $credentials); + $oldBucket = Environment::ReplaceOption('mcloud-storage-google-bucket', $bucket); + $oldBucketPolicyOnly = Environment::ReplaceOption('mcloud-storage-bucket-policy-only', $bucketPolicyOnly); + + try { + $storage = new GoogleStorage(); + $restoreOld = !$storage->validateSettings(); + } catch (\Exception $ex) { + $restoreOld = true; + } + + if ($restoreOld) { + Environment::UpdateOption('mcloud-storage-provider', $oldProvider); + Environment::UpdateOption('mcloud-storage-s3-bucket', $oldBucket); + Environment::UpdateOption('mcloud-storage-google-credentials', $oldCredentials); + Environment::UpdateOption('mcloud-storage-bucket-policy-only', $oldBucketPolicyOnly); + + $message = "There was a problem with your settings. Please double check entries for potential mistakes."; + + wp_send_json([ 'status' => 'error', 'message' => $message], 200); + } else { + wp_send_json([ 'status' => 'ok'], 200); + } + } + + //endregion + } diff --git a/classes/Storage/Driver/GoogleCloud/GoogleStorageSettings.php b/classes/Storage/Driver/GoogleCloud/GoogleStorageSettings.php new file mode 100755 index 00000000..ae1dff52 --- /dev/null +++ b/classes/Storage/Driver/GoogleCloud/GoogleStorageSettings.php @@ -0,0 +1,100 @@ + ['mcloud-storage-google-bucket', ['ILAB_CLOUD_GOOGLE_BUCKET', 'ILAB_AWS_S3_BUCKET', 'ILAB_CLOUD_BUCKET'], null], + 'useBucketPolicyOnly' => ['mcloud-storage-bucket-policy-only', false], + 'usePresignedURLs' => ['mcloud-storage-use-presigned-urls', null, false], + 'presignedURLExpiration' => ['mcloud-storage-presigned-expiration', null, 300], + 'usePresignedURLsForImages' => ['mcloud-storage-use-presigned-urls-images', null, false], + 'presignedURLExpirationForImages' => ['mcloud-storage-presigned-expiration-images', null, 0], + 'usePresignedURLsForAudio' => ['mcloud-storage-use-presigned-urls-audio', null, false], + 'presignedURLExpirationForAudio' => ['mcloud-storage-presigned-expiration-audio', null, 0], + 'usePresignedURLsForVideo' => ['mcloud-storage-use-presigned-urls-video', null, false], + 'presignedURLExpirationForVideo' => ['mcloud-storage-presigned-expiration-video', null, 0], + 'usePresignedURLsForDocs' => ['mcloud-storage-use-presigned-urls-docs', null, false], + 'presignedURLExpirationForDocs' => ['mcloud-storage-presigned-expiration-docs', null, 0], + ]; + + private $_credentials = null; + + public function __get($name) { + if ($name === 'credentials') { + if ($this->_credentials !== null) { + return $this->_credentials; + } + + $credFile = Environment::Option('mcloud-storage-google-credentials-file', 'ILAB_CLOUD_GOOGLE_CREDENTIALS'); + if (!empty($credFile)) { + if (file_exists($credFile)) { + $this->_credentials = json_decode(file_get_contents($credFile), true); + } else { + Logger::error("Credentials file '$credFile' could not be found."); + } + } + + if (empty($this->_credentials)) { + $creds = Environment::Option('mcloud-storage-google-credentials'); + if (!empty($creds)) { + $this->_credentials = json_decode($creds, true); + } + } + + return $this->_credentials; + } + + return parent::__get($name); + } + + public function __isset($name) { + if ($name === 'credentials') { + return true; + } + + return parent::__isset($name); + } + +} \ No newline at end of file diff --git a/classes/Storage/Driver/S3/DigitalOceanStorage.php b/classes/Storage/Driver/S3/DigitalOceanStorage.php index 1024f143..164a5239 100755 --- a/classes/Storage/Driver/S3/DigitalOceanStorage.php +++ b/classes/Storage/Driver/S3/DigitalOceanStorage.php @@ -16,6 +16,9 @@ namespace ILAB\MediaCloud\Storage\Driver\S3; +use function ILAB\MediaCloud\Utilities\anyNull; +use ILAB\MediaCloud\Wizard\WizardBuilder; + if (!defined( 'ABSPATH')) { header( 'Location: /'); die; } class DigitalOceanStorage extends OtherS3Storage { @@ -54,7 +57,7 @@ public function supportsDirectUploads() { return true; } - protected function settingsErrorOptionName() { + public static function settingsErrorOptionName() { return 'ilab-do-settings-error'; } //endregion @@ -73,4 +76,66 @@ public function enqueueUploaderScripts() { wp_enqueue_script('ilab-media-direct-upload-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-s3.js', [], false, true); } //endregion + + //region Wizard + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-do', true); + } + + $builder + ->section('cloud-storage-do', true) + ->select('Getting Started', 'Learn about DigitalOcean Spaces and how to setup spaces to work with Media Cloud.') + ->group('wizard.cloud-storage.providers.do.intro', 'select-buttons') + ->option('read-tutorial', 'Step By Step Tutorial', null, null, 'cloud-storage-do-tutorial') + ->endGroup() + ->endStep() + ->form('wizard.cloud-storage.providers.do.form', 'Cloud Storage Settings', 'Configure Media Cloud with your cloud storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'do') + ->textField('mcloud-storage-s3-access-key', 'Access Key', '', null) + ->passwordField('mcloud-storage-s3-secret', 'Secret', '', null) + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->hiddenField('mcloud-storage-s3-region', 'auto') + ->selectField('mcloud-storage-s3-endpoint', 'Custom Endpoint', "", null, [ + 'nyc3.digitaloceanspaces.com' => 'nyc3.digitaloceanspaces.com', + 'sfo2.digitaloceanspaces.com' => 'sfo2.digitaloceanspaces.com', + 'sgp1.digitaloceanspaces.com' => 'sgp1.digitaloceanspaces.com', + 'fra1.digitaloceanspaces.com' => 'fra1.digitaloceanspaces.com', + 'ams3.digitaloceanspaces.com' => 'ams3.digitaloceanspaces.com', + ]) + ->hiddenField('mcloud-storage-s3-use-path-style-endpoint', true) + ->endStep() + ->testStep('wizard.cloud-storage.providers.do.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.do.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + $builder + ->tutorialSection('cloud-storage-do-tutorial', true) + ->tutorial('wizard.cloud-storage.providers.do.tutorial.step-1', 'Create Space', 'Create the space you will be using with Media Cloud.') + ->tutorial('wizard.cloud-storage.providers.do.tutorial.step-2', 'Create API Key', 'Generate the API keys Media Cloud uses to access spaces.', null, true) + ->tutorial('wizard.cloud-storage.providers.do.tutorial.step-3', 'CORS Configuration (Optional)', 'If you plan on using the Direct Uploads functionality, learn how to configure CORS to make that happen.', null, true) + ->endSection(); + + return $builder; + } + + protected static function validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint) { + return !anyNull($provider, $accessKey, $secret, $bucket, $endpoint); + } + //endregion + } diff --git a/classes/Storage/Driver/S3/MinioStorage.php b/classes/Storage/Driver/S3/MinioStorage.php index 7301d924..b6f3534d 100755 --- a/classes/Storage/Driver/S3/MinioStorage.php +++ b/classes/Storage/Driver/S3/MinioStorage.php @@ -16,6 +16,8 @@ namespace ILAB\MediaCloud\Storage\Driver\S3; +use ILAB\MediaCloud\Wizard\WizardBuilder; + if (!defined( 'ABSPATH')) { header( 'Location: /'); die; } class MinioStorage extends OtherS3Storage { @@ -38,7 +40,7 @@ public static function name() { public static function bucketLink($bucket) { $instance = new self(); - return $instance->endpoint.'/minio/'.$bucket; + return $instance->settings->endpoint.'/minio/'.$bucket; } public function pathLink($bucket, $key) { @@ -47,7 +49,7 @@ public function pathLink($bucket, $key) { $key = implode('/', $keyParts).'/'; $instance = new self(); - return $instance->endpoint.'/minio/'.$bucket.'/'.$key; + return $instance->settings->endpoint.'/minio/'.$bucket.'/'.$key; } //endregion @@ -56,7 +58,7 @@ public function supportsDirectUploads() { return true; } - protected function settingsErrorOptionName() { + public static function settingsErrorOptionName() { return 'ilab-minio-settings-error'; } //endregion @@ -73,7 +75,7 @@ protected function settingsErrorOptionName() { //region Direct Uploads public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $expires = null) { $args = [ - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]; @@ -96,4 +98,67 @@ public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $e return new OtherS3UploadInfo($key, $presignedReq->getUri()->__toString(), $acl); } //endregion + + //region Wizard + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-minio', true); + } + + $builder + ->section('cloud-storage-minio', true) + ->intro('wizard.cloud-storage.providers.minio.intro', 'About Minio', '') + ->form('wizard.cloud-storage.providers.minio.form', 'Minio Settings', 'Configure Media Cloud with your cloud storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'minio') + ->textField('mcloud-storage-s3-access-key', 'Access Key', '', null) + ->passwordField('mcloud-storage-s3-secret', 'Secret', '', null) + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->selectField('mcloud-storage-s3-region', 'Region', "The region that your bucket is in. Set to 'auto' to have Media Cloud automatically determine what region your bucket is in. May not work with some S3 compatible providers.", 'auto', [ + "auto" => "Automatic", + 'us-east-2' => 'US East (Ohio)', + 'us-east-1' => 'US East (N. Virginia)', + 'us-west-1' => 'US West (N. California)', + 'us-west-2' => 'US West (Oregon)', + 'ca-central-1' => 'Canada (Central)', + 'ap-east-1' => 'Asia Pacific (Hong Kong)', + 'ap-south-1' => 'Asia Pacific (Mumbai)', + 'ap-northeast-1' => 'Asia Pacific (Tokyo)', + 'ap-northeast-2' => 'Asia Pacific (Seoul)', + 'ap-northeast-3' => 'Asia Pacific (Osaka-Local)', + 'ap-southeast-1' => 'Asia Pacific (Singapore)', + 'ap-southeast-2' => 'Asia Pacific (Sydney)', + 'eu-central-1' => 'EU (Frankfurt)', + 'eu-west-1' => 'EU (Ireland)', + 'eu-west-2' => 'EU (London)', + 'eu-west-3' => 'EU (Paris)', + 'eu-north-1' => 'EU (Stockholm)', + 'sa-east-1' => 'South America (São Paulo)', + 'cn-north-1' => 'China (Beijing)', + 'cn-northwest-1' => 'China (Ningxia)', + ]) + ->textField('mcloud-storage-s3-endpoint', 'Custom Endpoint', "Some S3 compatible services use a custom API endpoint URL or server name. For example, with a DigitalOcean space in NYC-3 region, this value would be nyc3.digitaloceanspaces.com", null) + ->hiddenField('mcloud-storage-s3-use-path-style-endpoint', true) + ->endStep() + ->testStep('wizard.cloud-storage.providers.minio.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.minio.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + return $builder; + } + //endregion + } diff --git a/classes/Storage/Driver/S3/OtherS3Storage.php b/classes/Storage/Driver/S3/OtherS3Storage.php index e8e9198e..c2cafedf 100755 --- a/classes/Storage/Driver/S3/OtherS3Storage.php +++ b/classes/Storage/Driver/S3/OtherS3Storage.php @@ -20,7 +20,14 @@ use ILAB\MediaCloud\Storage\FileInfo; use ILAB\MediaCloud\Storage\InvalidStorageSettingsException; use ILAB\MediaCloud\Storage\StorageException; +use ILAB\MediaCloud\Storage\StorageManager; +use ILAB\MediaCloud\Storage\StorageGlobals; +use function ILAB\MediaCloud\Utilities\anyNull; use function ILAB\MediaCloud\Utilities\arrayPath; +use ILAB\MediaCloud\Utilities\Environment; +use ILAB\MediaCloud\Wizard\ConfiguresWizard; +use ILAB\MediaCloud\Wizard\StorageWizardTrait; +use ILAB\MediaCloud\Wizard\WizardBuilder; if (!defined( 'ABSPATH')) { header( 'Location: /'); die; } @@ -44,12 +51,12 @@ public static function name() { public static function bucketLink($bucket) { $instance = new self(); - return $instance->endpoint; + return $instance->settings->endpoint; } public function pathLink($bucket, $key) { $instance = new self(); - return $instance->endpoint; + return $instance->settings->endpoint; } //endregion @@ -58,7 +65,7 @@ public function supportsDirectUploads() { return false; } - protected function settingsErrorOptionName() { + public static function settingsErrorOptionName() { return 'ilab-other-s3-settings-error'; } //endregion @@ -121,4 +128,138 @@ public function enqueueUploaderScripts() { wp_enqueue_script('ilab-media-direct-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], false, true); } //endregion + + //region Wizard + + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-other-s3', true); + } + + $builder + ->section('cloud-storage-other-s3', true) + ->intro('wizard.cloud-storage.providers.other-s3.intro', 'About S3 Compatible Cloud Storage', '') + ->form('wizard.cloud-storage.providers.other-s3.form', 'Cloud Storage Settings', 'Configure Media Cloud with your cloud storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'other-s3') + ->textField('mcloud-storage-s3-access-key', 'Access Key', '', null) + ->passwordField('mcloud-storage-s3-secret', 'Secret', '', null) + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->selectField('mcloud-storage-s3-region', 'Region', "The region that your bucket is in. Set to 'auto' to have Media Cloud automatically determine what region your bucket is in. May not work with some S3 compatible providers.", 'auto', [ + "auto" => "Automatic", + 'us-east-2' => 'US East (Ohio)', + 'us-east-1' => 'US East (N. Virginia)', + 'us-west-1' => 'US West (N. California)', + 'us-west-2' => 'US West (Oregon)', + 'ca-central-1' => 'Canada (Central)', + 'ap-east-1' => 'Asia Pacific (Hong Kong)', + 'ap-south-1' => 'Asia Pacific (Mumbai)', + 'ap-northeast-1' => 'Asia Pacific (Tokyo)', + 'ap-northeast-2' => 'Asia Pacific (Seoul)', + 'ap-northeast-3' => 'Asia Pacific (Osaka-Local)', + 'ap-southeast-1' => 'Asia Pacific (Singapore)', + 'ap-southeast-2' => 'Asia Pacific (Sydney)', + 'eu-central-1' => 'EU (Frankfurt)', + 'eu-west-1' => 'EU (Ireland)', + 'eu-west-2' => 'EU (London)', + 'eu-west-3' => 'EU (Paris)', + 'eu-north-1' => 'EU (Stockholm)', + 'sa-east-1' => 'South America (São Paulo)', + 'cn-north-1' => 'China (Beijing)', + 'cn-northwest-1' => 'China (Ningxia)', + ]) + ->textField('mcloud-storage-s3-endpoint', 'Custom Endpoint', "Some S3 compatible services use a custom API endpoint URL or server name. For example, with a DigitalOcean space in NYC-3 region, this value would be nyc3.digitaloceanspaces.com", null) + ->hiddenField('mcloud-storage-s3-use-path-style-endpoint', true) + ->endStep() + ->testStep('wizard.cloud-storage.providers.other-s3.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.other-s3.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + return $builder; + } + + protected static function validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint) { + return !anyNull($provider, $accessKey, $secret, $bucket, $region, $endpoint); + } + + public static function processWizardSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'update-storage-settings')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + /** + * @var string $providerName + * @var string $accessKeyName + * @var string $secretName + * @var string $bucketName + * @var string $regionName + * @var string $endpointName + * @var string $pathStyleEndpointName + * @var string $useTransferAccelerationName + */ + extract(static::fetchWizardInputNames(), EXTR_OVERWRITE); + + $provider = arrayPath($_POST, $providerName, null); + $accessKey = arrayPath($_POST, $accessKeyName, null); + $secret = arrayPath($_POST, $secretName, null); + $bucket = arrayPath($_POST, $bucketName, null); + $region = arrayPath($_POST, $regionName, 'auto'); + $endpoint = arrayPath($_POST, $endpointName, null); + $pathStyleEndpoint = arrayPath($_POST, $pathStyleEndpointName, true); + + if (!static::validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint)) { + wp_send_json(['status' => 'error', 'message' => 'Missing required fields'], 200); + } + + $oldProvider = Environment::ReplaceOption($providerName, $provider); + $oldBucket = Environment::ReplaceOption($bucketName, $bucket); + $oldKey = Environment::ReplaceOption($accessKeyName, $accessKey); + $oldSecret = Environment::ReplaceOption($secretName, $secret); + $oldRegion = Environment::ReplaceOption($regionName, $region); + $oldEndpoint = Environment::ReplaceOption($endpointName, $endpoint); + $oldPathStyleEndpoint = Environment::ReplaceOption($pathStyleEndpointName, $pathStyleEndpoint); + + StorageManager::resetStorageInstance(); + + try { + $storage = new static(); + $restoreOld = !$storage->validateSettings(); + } catch (\Exception $ex) { + $restoreOld = true; + } + + if ($restoreOld) { + Environment::UpdateOption($providerName, $oldProvider); + Environment::UpdateOption($bucketName, $oldBucket); + Environment::UpdateOption($accessKeyName, $oldKey); + Environment::UpdateOption($secretName, $oldSecret); + Environment::UpdateOption($regionName, $oldRegion); + Environment::UpdateOption($endpointName, $oldEndpoint); + Environment::UpdateOption($pathStyleEndpointName, $oldPathStyleEndpoint); + + StorageManager::resetStorageInstance(); + + $message = "There was a problem with your settings. Please double check entries for potential mistakes."; + + wp_send_json([ 'status' => 'error', 'message' => $message], 200); + } else { + wp_send_json([ 'status' => 'ok'], 200); + } + } + + //endregion + } diff --git a/classes/Storage/Driver/S3/S3Storage.php b/classes/Storage/Driver/S3/S3Storage.php index bff8dba7..d2bb6ccb 100755 --- a/classes/Storage/Driver/S3/S3Storage.php +++ b/classes/Storage/Driver/S3/S3Storage.php @@ -21,12 +21,16 @@ use ILAB\MediaCloud\Storage\InvalidStorageSettingsException; use ILAB\MediaCloud\Storage\StorageException; use ILAB\MediaCloud\Storage\StorageFile; -use ILAB\MediaCloud\Storage\StorageInterface; use ILAB\MediaCloud\Storage\StorageManager; +use function ILAB\MediaCloud\Utilities\anyNull; +use function ILAB\MediaCloud\Utilities\arrayPath; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\Logging\ErrorCollector; use ILAB\MediaCloud\Utilities\Logging\Logger; use ILAB\MediaCloud\Utilities\NoticeManager; +use ILAB\MediaCloud\Wizard\ConfiguresWizard; +use ILAB\MediaCloud\Wizard\StorageWizardTrait; +use ILAB\MediaCloud\Wizard\WizardBuilder; use ILABAmazon\Credentials\CredentialProvider; use ILABAmazon\Exception\AwsException; use ILABAmazon\Exception\CredentialsException; @@ -41,122 +45,24 @@ die; } -class S3Storage implements StorageInterface { - //region Properties - /*** @var string */ - protected $key = null; - - /*** @var string */ - protected $secret = null; - - /*** @var string */ - protected $bucket = null; - - /*** @var bool */ - protected $useCredentialProvider = false; - - /*** @var string */ - protected $region = false; - - /*** @var bool */ - protected $settingsError = false; +class S3Storage implements S3StorageInterface, ConfiguresWizard { + use StorageWizardTrait; - /*** @var string */ - protected $endpoint = null; - - /*** @var bool */ - protected $endPointPathStyle = true; + //region Properties + /** @var S3StorageSettings|null */ + protected $settings = null; - /*** @var bool */ - protected $useTransferAcceleration = false; + /** @var null|AdapterInterface */ + protected $adapter = null; /*** @var S3Client|S3MultiRegionClient|null */ protected $client = null; - /** @var bool */ - protected $usePresignedURLs = false; - - /** @var int */ - protected $presignedURLExpiration = 300; - - /** @var null|AdapterInterface */ - protected $adapter = null; - //endregion //region Constructor public function __construct() { - $this->bucket = Environment::Option('mcloud-storage-s3-bucket', [ - 'ILAB_AWS_S3_BUCKET', - 'ILAB_CLOUD_BUCKET' - ]); - - $this->key = Environment::Option('mcloud-storage-s3-access-key', [ - 'ILAB_AWS_S3_ACCESS_KEY', - 'ILAB_CLOUD_ACCESS_KEY' - ]); - - $this->secret = Environment::Option('mcloud-storage-s3-secret', [ - 'ILAB_AWS_S3_ACCESS_SECRET', - 'ILAB_CLOUD_ACCESS_SECRET' - ]); - - $this->useCredentialProvider = Environment::Option('mcloud-storage-s3-use-credential-provider', [ - 'ILAB_AWS_S3_USE_CREDENTIAL_PROVIDER', - 'ILAB_CLOUD_USE_CREDENTIAL_PROVIDER' - ], false); - - $thisClass = get_class($this); - - $this->usePresignedURLs = Environment::Option('mcloud-storage-use-presigned-urls', null, false); - $this->presignedURLExpiration = Environment::Option('mcloud-storage-presigned-expiration', null, 300); - if (empty($this->presignedURLExpiration)) { - $this->presignedURLExpiration = 300; - } - - if(StorageManager::driver() == 's3') { - $this->useTransferAcceleration = Environment::Option('mcloud-storage-s3-use-transfer-acceleration', 'ILAB_AWS_S3_TRANSFER_ACCELERATION', false); - } else { - if ($thisClass::endpoint() !== null) { - $this->endpoint = $thisClass::endpoint(); - } else { - $this->endpoint = Environment::Option('mcloud-storage-s3-endpoint', [ - 'ILAB_AWS_S3_ENDPOINT', - 'ILAB_CLOUD_ENDPOINT' - ], false); - } - - if(!empty($this->endpoint)) { - if(!preg_match('#^[aA-zZ0-9]+\:\/\/#', $this->endpoint)) { - $this->endpoint = 'https://'.$this->endpoint; - } - } - - if ($thisClass::pathStyleEndpoint() !== null) { - $this->endPointPathStyle = $thisClass::pathStyleEndpoint(); - } else { - $this->endPointPathStyle = Environment::Option('mcloud-storage-s3-use-path-style-endpoint', [ - 'ILAB_AWS_S3_ENDPOINT_PATH_STYLE', - 'ILAB_CLOUD_ENDPOINT_PATH_STYLE' - ], true); - } - } - - $this->settingsError = Environment::Option($this->settingsErrorOptionName(), null, false); - - if ($thisClass::defaultRegion() !== null) { - $this->region = $thisClass::defaultRegion(); - } else if ((StorageManager::driver() != 'wasabi') && (StorageManager::driver() != 'do')) { - $region = Environment::Option('mcloud-storage-s3-region', [ - 'ILAB_AWS_S3_REGION', - 'ILAB_CLOUD_REGION' - ], 'auto'); - - if($region != 'auto') { - $this->region = $region; - } - } - + $this->settings = new S3StorageSettings($this); $this->client = $this->getClient(null); } //endregion @@ -187,20 +93,64 @@ public static function bucketLink($bucket) { } public function pathLink($bucket, $key) { - return "https://s3.console.aws.amazon.com/s3/object/{$bucket}/{$key}?region={$this->region}&tab=overview"; + return "https://s3.console.aws.amazon.com/s3/object/{$bucket}/{$key}?region={$this->settings->region}&tab=overview"; } //endregion //region Enabled/Options - public function usesSignedURLs() { - return $this->usePresignedURLs; + public function usesSignedURLs($type = null) { + if (($type == null) || (!empty($this->settings->usePresignedURLs))) { + return $this->settings->usePresignedURLs; + } + + if (strpos($type, 'image') === 0) { + return $this->settings->usePresignedURLsForImages; + } + + if (strpos($type, 'video') === 0) { + return $this->settings->usePresignedURLsForVideo; + } + + if (strpos($type, 'audio') === 0) { + return $this->settings->usePresignedURLsForAudio; + } + + if (strpos($type, 'application') === 0) { + return $this->settings->usePresignedURLsForDocs; + } + + return $this->settings->usePresignedURLs; + } + + public function signedURLExpirationForType($type = null) { + if (($type == null) || (!empty($this->settings->usePresignedURLs))) { + return $this->settings->presignedURLExpiration; + } + + if (strpos($type, 'image') === 0) { + return (empty($this->settings->presignedURLExpirationForImages)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForImages; + } + + if (strpos($type, 'video') === 0) { + return (empty($this->settings->presignedURLExpirationForVideo)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForVideo; + } + + if (strpos($type, 'audio') === 0) { + return (empty($this->settings->presignedURLExpirationForAudio)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForAudio; + } + + if (strpos($type, 'application') === 0) { + return (empty($this->settings->presignedURLExpirationForDocs)) ? $this->settings->presignedURLExpiration : $this->settings->presignedURLExpirationForDocs; + } + + return $this->settings->presignedURLExpiration; } public function supportsDirectUploads() { - return (StorageManager::driver() == 's3'); + return (StorageManager::driver() === 's3'); } - protected function settingsErrorOptionName() { + public static function settingsErrorOptionName() { return 'ilab-s3-settings-error'; } @@ -213,8 +163,8 @@ public function supportsBrowser() { * @return bool */ public function validateSettings($errorCollector = null) { - Environment::DeleteOption($this->settingsErrorOptionName()); - $this->settingsError = false; + Environment::DeleteOption(static::settingsErrorOptionName()); + $this->settings->settingsError = false; $valid = false; $this->client = null; @@ -225,7 +175,7 @@ public function validateSettings($errorCollector = null) { $connectError = false; try { - if($client->doesBucketExist($this->bucket)) { + if($client->doesBucketExist($this->settings->bucket)) { $valid = true; } } catch (\Exception $ex) { @@ -234,7 +184,7 @@ public function validateSettings($errorCollector = null) { if ($errorCollector) { if ($ex instanceof CredentialsException) { - if ($this->useCredentialProvider) { + if ($this->settings->useCredentialProvider) { $errorCollector->addError("Your Amazon credentials are invalid. You have enabled Use Credential Provider but it appears that isn't configured properly. Either turn off that setting and provide an access key and secret, or double check your credential provider setup."); } else { $errorCollector->addError("Your Amazon credentials are invalid. Verify that the access key, secret and bucket name are correct and try this test again."); @@ -255,7 +205,7 @@ public function validateSettings($errorCollector = null) { $buckets = $result->get('Buckets'); if(!empty($buckets)) { foreach($buckets as $bucket) { - if($bucket['Name'] == $this->bucket) { + if($bucket['Name'] == $this->settings->bucket) { $valid = true; break; } @@ -264,7 +214,7 @@ public function validateSettings($errorCollector = null) { if (!$valid) { if ($errorCollector) { - $errorCollector->addError("Bucket {$this->bucket} does not exist."); + $errorCollector->addError("Bucket {$this->settings->bucket} does not exist."); } Logger::info("Bucket does not exist."); @@ -272,11 +222,11 @@ public function validateSettings($errorCollector = null) { } catch(AwsException $ex) { if ($errorCollector) { $adminUrl = admin_url('admin.php?page=media-cloud-settings&tab=storage'); - if ($ex->getAwsErrorCode() == 'SignatureDoesNotMatch') { + if ($ex->getAwsErrorCode() === 'SignatureDoesNotMatch') { $errorCollector->addError("Your S3 credentials are invalid. It appears that the Secret you specified is invalid. Please double check your settings."); - } else if ($ex->getAwsErrorCode() == 'InvalidAccessKeyId') { + } else if ($ex->getAwsErrorCode() === 'InvalidAccessKeyId') { $errorCollector->addError("Your S3 credentials are invalid. It appears that the Access Key you specified is invalid. Please double check your settings."); - } else if ($ex->getAwsErrorCode() == 'AccessDenied') { + } else if ($ex->getAwsErrorCode() === 'AccessDenied') { $errorCollector->addError("The Bucket you specified doesn't exist or you don't have access to it. You may have also specified the wrong Region. It's also possible that you don't have the correct permissions specified in your IAM policy. Please set the Region to Automatic and double check the Bucket Name in your settings."); } else { $errorCollector->addError($ex->getAwsErrorMessage()); @@ -289,8 +239,7 @@ public function validateSettings($errorCollector = null) { } if(!$valid) { - $this->settingsError = true; - Environment::UpdateOption($this->settingsErrorOptionName(), true); + $this->settings->settingsError = true; } else { $this->client = $client; } @@ -304,14 +253,14 @@ public function validateSettings($errorCollector = null) { } public function enabled() { - if (!((($this->key && $this->secret) || $this->useCredentialProvider) && $this->bucket)) { + if (!((($this->settings->key && $this->settings->secret) || $this->settings->useCredentialProvider) && $this->settings->bucket)) { $adminUrl = admin_url('admin.php?page=media-cloud-settings&tab=storage'); NoticeManager::instance()->displayAdminNotice('info', "Welcome to Media Cloud! To get started, configure your cloud storage.", true, 'ilab-cloud-storage-setup-warning', 'forever'); return false; } - if ($this->settingsError) { + if ($this->settings->settingsError) { return false; } @@ -319,7 +268,7 @@ public function enabled() { } public function settingsError() { - return $this->settingsError; + return $this->settings->settingsError; } public function client() { @@ -342,7 +291,7 @@ protected function getBucketRegion() { return false; } - if($this->useCredentialProvider) { + if($this->settings->useCredentialProvider) { $config = [ 'version' => 'latest', 'credentials' => CredentialProvider::defaultProvider() @@ -351,15 +300,15 @@ protected function getBucketRegion() { $config = [ 'version' => 'latest', 'credentials' => [ - 'key' => $this->key, - 'secret' => $this->secret + 'key' => $this->settings->key, + 'secret' => $this->settings->secret ] ]; } - if(!empty($this->endpoint)) { - $config['endpoint'] = $this->endpoint; - if($this->endPointPathStyle) { + if(!empty($this->settings->endpoint)) { + $config['endpoint'] = $this->settings->endpoint; + if($this->settings->endPointPathStyle) { $config['use_path_style_endpoint'] = true; } } @@ -367,7 +316,7 @@ protected function getBucketRegion() { $s3 = new S3MultiRegionClient($config); $region = false; try { - $region = $s3->determineBucketRegion($this->bucket); + $region = $s3->determineBucketRegion($this->settings->bucket); } catch(AwsException $ex) { Logger::error("AWS Error fetching region", ['exception' => $ex->getMessage()]); @@ -385,9 +334,7 @@ protected function getS3MultiRegionClient() { return null; } - - - if($this->useCredentialProvider) { + if($this->settings->useCredentialProvider) { $config = [ 'version' => 'latest', 'credentials' => CredentialProvider::defaultProvider() @@ -396,21 +343,21 @@ protected function getS3MultiRegionClient() { $config = [ 'version' => 'latest', 'credentials' => [ - 'key' => $this->key, - 'secret' => $this->secret + 'key' => $this->settings->key, + 'secret' => $this->settings->secret ] ]; } - if(!empty($this->endpoint)) { - $config['endpoint'] = $this->endpoint; + if(!empty($this->settings->endpoint)) { + $config['endpoint'] = $this->settings->endpoint; - if($this->endPointPathStyle) { + if($this->settings->endPointPathStyle) { $config['use_path_style_endpoint'] = true; } } - if($this->useTransferAcceleration) { + if($this->settings->useTransferAcceleration && (StorageManager::driver() === 's3')) { $config['use_accelerate_endpoint'] = true; } @@ -432,9 +379,9 @@ protected function getS3Client($region = false, $errorCollector = null) { } if(empty($region)) { - if(empty($this->region)) { - $this->region = $this->getBucketRegion(); - if(empty($this->region)) { + if(empty($this->settings->region)) { + $this->settings->region = $this->getBucketRegion(); + if(empty($this->settings->region)) { if ($errorCollector) { $errorCollector->addError('Could not determine region.'); } @@ -444,10 +391,10 @@ protected function getS3Client($region = false, $errorCollector = null) { return null; } - Environment::UpdateOption('mcloud-storage-s3-region', $this->region); + Environment::UpdateOption('mcloud-storage-s3-region', $this->settings->region); } - $region = $this->region; + $region = $this->settings->region; } if(empty($region)) { @@ -458,9 +405,7 @@ protected function getS3Client($region = false, $errorCollector = null) { return null; } - - - if($this->useCredentialProvider) { + if($this->settings->useCredentialProvider) { $config = [ 'version' => 'latest', 'credentials' => CredentialProvider::defaultProvider(), @@ -470,21 +415,21 @@ protected function getS3Client($region = false, $errorCollector = null) { $config = [ 'version' => 'latest', 'credentials' => [ - 'key' => $this->key, - 'secret' => $this->secret + 'key' => $this->settings->key, + 'secret' => $this->settings->secret ], 'region' => $region ]; } - if(!empty($this->endpoint)) { - $config['endpoint'] = $this->endpoint; - if($this->endPointPathStyle) { + if(!empty($this->settings->endpoint)) { + $config['endpoint'] = $this->settings->endpoint; + if($this->settings->endPointPathStyle) { $config['use_path_style_endpoint'] = true; } } - if($this->useTransferAcceleration) { + if($this->settings->useTransferAcceleration) { $config['use_accelerate_endpoint'] = true; } @@ -528,11 +473,11 @@ protected function getClient($errorCollector = null) { //region File Functions public function bucket() { - return $this->bucket; + return $this->settings->bucket; } public function region() { - return $this->region; + return $this->settings->region; } public function insureACL($key, $acl) { @@ -544,7 +489,7 @@ public function exists($key) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - return $this->client->doesObjectExist($this->bucket, $key); + return $this->client->doesObjectExist($this->settings->bucket, $key); } public function copy($sourceKey, $destKey, $acl, $mime = false, $cacheControl = false, $expires = false) { @@ -554,9 +499,9 @@ public function copy($sourceKey, $destKey, $acl, $mime = false, $cacheControl = $copyOptions = [ 'MetadataDirective' => 'REPLACE', - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $destKey, - 'CopySource' => $this->bucket.'/'.$sourceKey, + 'CopySource' => $this->settings->bucket.'/'.$sourceKey, 'ACL' => $acl ]; @@ -617,7 +562,7 @@ public function upload($key, $fileName, $acl, $cacheControl=null, $expires=null, $file = fopen($fileName, 'r'); Logger::startTiming("Start Upload", ['file' => $key]); - $result = $this->client->upload($this->bucket, $key, $file, $acl, $options); + $result = $this->client->upload($this->settings->bucket, $key, $file, $acl, $options); Logger::endTiming("End Upload", ['file' => $key]); fclose($file); @@ -628,7 +573,7 @@ public function upload($key, $fileName, $acl, $cacheControl=null, $expires=null, fclose($file); Logger::error('S3 Upload Error', [ 'exception' => $ex->getMessage(), - 'bucket' => $this->bucket, + 'bucket' => $this->settings->bucket, 'key' => $key, 'privacy' => $acl, 'options' => $options @@ -645,13 +590,13 @@ public function delete($key) { try { Logger::startTiming("Deleting '$key'"); - $this->client->deleteObject(['Bucket' => $this->bucket, 'Key' => $key]); + $this->client->deleteObject(['Bucket' => $this->settings->bucket, 'Key' => $key]); Logger::endTiming("Deleted '$key'"); } catch(AwsException $ex) { Logger::error('S3 Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -664,13 +609,13 @@ public function deleteDirectory($key) { try { Logger::startTiming("Deleting directory '$key'"); - $this->client->deleteMatchingObjects($this->bucket, $key); + $this->client->deleteMatchingObjects($this->settings->bucket, $key); Logger::endTiming("Deleted directory '$key'"); } catch(AwsException $ex) { Logger::error('S3 Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -687,7 +632,7 @@ public function createDirectory($key) { Logger::startTiming("Creating folder '$key'"); $this->client->putObject([ - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key, 'Body' => '', 'ACL' => 'public-read', @@ -700,7 +645,7 @@ public function createDirectory($key) { catch(AwsException $ex) { Logger::error('S3 Delete File Error', [ 'exception' => $ex->getMessage(), - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Key' => $key ]); } @@ -714,7 +659,7 @@ public function info($key) { } try { - $result = $this->client->headObject(['Bucket' => $this->bucket, 'Key' => $key]); + $result = $this->client->headObject(['Bucket' => $this->settings->bucket, 'Key' => $key]); $length = $result->get('ContentLength'); $type = $result->get('ContentType'); } @@ -750,7 +695,7 @@ public function dir($path = '', $delimiter = '/') { $contents = []; try { $args = [ - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Prefix' => $path ]; @@ -792,7 +737,7 @@ public function ls($path = '', $delimiter = '/') { $contents = []; try { $args = [ - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'Prefix' => $path ]; @@ -828,10 +773,14 @@ protected function presignedRequest($key, $expiration = 0) { } if (empty($expiration)) { - $expiration = $this->presignedURLExpiration; + $expiration = $this->settings->presignedURLExpiration; + } + + if (empty($expiration)) { + $expiration = 1; } - $command = $this->client->getCommand('GetObject', ['Bucket' => $this->bucket, 'Key' => $key]); + $command = $this->client->getCommand('GetObject', ['Bucket' => $this->settings->bucket, 'Key' => $key]); return $this->client->createPresignedRequest($command, "+".((int)$expiration)." minutes"); } @@ -844,15 +793,16 @@ public function presignedUrl($key, $expiration = 0) { return $url; } - public function url($key) { + public function url($key, $type = null) { if(!$this->client) { throw new InvalidStorageSettingsException('Storage settings are invalid'); } - if ($this->usePresignedURLs) { - return $this->presignedUrl($key); + if ($this->usesSignedURLs($type)) { + $expiration = $this->signedURLExpirationForType($type); + return $this->presignedUrl($key, $expiration); } else { - return $this->client->getObjectUrl($this->bucket, $key); + return $this->client->getObjectUrl($this->settings->bucket, $key); } } //endregion @@ -868,7 +818,7 @@ public function url($key) { */ protected function getOptionsData($acl, $key) { return [ - ['bucket' => $this->bucket], + ['bucket' => $this->settings->bucket], ['acl' => $acl], ['key' => $key], ['starts-with', '$Content-Type', ''] @@ -887,7 +837,7 @@ public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $e $optionsData[] = ['Expires' => $expires]; } - $postObject = new PostObjectV4($this->client, $this->bucket, [], $optionsData, '+15 minutes'); + $postObject = new PostObjectV4($this->client, $this->settings->bucket, [], $optionsData, '+15 minutes'); return new S3UploadInfo($key, $postObject, $acl, $cacheControl, $expires); } @@ -908,8 +858,168 @@ public function adapter() { return $this->adapter; } - $this->adapter = new AwsS3Adapter($this->client, $this->bucket); + $this->adapter = new AwsS3Adapter($this->client, $this->settings->bucket); return $this->adapter; } //endregion + + //region Wizard + + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-s3', true); + } + + $builder + ->section('cloud-storage-s3', true) + ->select('Getting Started', 'Learn about Amazon S3 and how to setup your Amazon AWS Account to work with Media Cloud.') + ->group('wizard.cloud-storage.providers.s3.intro', 'select-buttons') + ->option('watch-tutorial', 'Watch Video Tutorial', null, null, 'cloud-storage-s3-video-tutorial') + ->option('read-tutorial', 'Step By Step Tutorial', null, null, 'cloud-storage-s3-tutorial') + ->endGroup() + ->endStep() + ->form('wizard.cloud-storage.providers.s3.form', 'Amazon S3 Settings', 'Configure Media Cloud with your Amazon S3 settings.', [S3Storage::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 's3') + ->textField('mcloud-storage-s3-access-key', 'Access Key', '', null) + ->passwordField('mcloud-storage-s3-secret', 'Secret', '', null) + ->hiddenField('mcloud-storage-s3-region', 'auto') + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->checkboxField('mcloud-storage-s3-use-transfer-acceleration', 'Use Transfer Acceleration', 'Amazon S3 Transfer Acceleration enables fast, easy, and secure transfers of files over long distances between your client and an S3 bucket. Transfer Acceleration takes advantage of Amazon CloudFront’s globally distributed edge locations. You must have it enabled on your bucket in the S3 console.', false) + ->endStep() + ->testStep('wizard.cloud-storage.providers.s3.test', 'Test Settings', 'Perform tests to insure that Amazon S3 is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.s3.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + +// $builder->next('wizard.cloud-storage.providers.s3.success', 'Complete', 'Success! Everything is setup and ready to go.', null); + + $builder->section('cloud-storage-s3-video-tutorial', false) + ->video('https://www.youtube.com/watch?v=kjFCACrPRtU', null, null, null, true) + ->endSection(); + + $builder + ->tutorialSection('cloud-storage-s3-tutorial', true) + ->tutorial('wizard.cloud-storage.providers.s3.tutorial.step-1', 'Create an S3 Bucket', 'Learn how to create an S3 bucket for use with Media Cloud.') + ->tutorial('wizard.cloud-storage.providers.s3.tutorial.step-2', 'Create Policy', 'Policies control how Media Cloud interacts with your S3 bucket and what it can do.', null, true) + ->tutorial('wizard.cloud-storage.providers.s3.tutorial.step-3', 'Create IAM User', 'Creates the IAM user credentials that Media Cloud will use to access your S3 bucket.', null, true) + ->tutorial('wizard.cloud-storage.providers.s3.tutorial.step-4', 'CORS Configuration (Optional)', 'If you plan on using the Direct Uploads functionality, learn how to configure CORS to make that happen.', null, true) + ->endSection(); + + return $builder; + } + + protected static function validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint) { + return !anyNull($provider, $accessKey, $secret, $bucket, $region); + } + + /** + * @return array[ + * 'providerName' => string, + * 'accessKeyName' => string, + * 'secretName' => string, + * 'bucketName' => string, + * 'regionName' => string, + * 'endpointName' => string, + * 'pathStyleEndpointName' => string, + * 'useTransferAccelerationName' => string + * ] + */ + protected static function fetchWizardInputNames() { + return [ + 'providerName' => 'mcloud-storage-provider', + 'accessKeyName' => 'mcloud-storage-s3-access-key', + 'secretName' => 'mcloud-storage-s3-secret', + 'bucketName' => 'mcloud-storage-s3-bucket', + 'regionName' => 'mcloud-storage-s3-region', + 'endpointName' => 'mcloud-storage-s3-endpoint', + 'pathStyleEndpointName' => 'mcloud-storage-s3-use-path-style-endpoint', + 'useTransferAccelerationName' => 'mcloud-storage-s3-use-transfer-acceleration' + ]; + } + + public static function processWizardSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'update-storage-settings')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + /** + * @var string $providerName + * @var string $accessKeyName + * @var string $secretName + * @var string $bucketName + * @var string $regionName + * @var string $endpointName + * @var string $pathStyleEndpointName + * @var string $useTransferAccelerationName + */ + extract(static::fetchWizardInputNames(), EXTR_OVERWRITE); + + $provider = arrayPath($_POST, $providerName, null); + $accessKey = arrayPath($_POST, $accessKeyName, null); + $secret = arrayPath($_POST, $secretName, null); + $bucket = arrayPath($_POST, $bucketName, null); + $region = arrayPath($_POST, $regionName, 'auto'); + $endpoint = arrayPath($_POST, $endpointName, null); + $pathStyleEndpoint = arrayPath($_POST, $pathStyleEndpointName, true); + $useTransferAcceleration = arrayPath($_POST, $useTransferAccelerationName, false); + + if (!static::validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint)) { + wp_send_json(['status' => 'error', 'message' => 'Missing required fields'], 200); + } + + $oldProvider = Environment::ReplaceOption($providerName, $provider); + $oldBucket = Environment::ReplaceOption($bucketName, $bucket); + $oldKey = Environment::ReplaceOption($accessKeyName, $accessKey); + $oldSecret = Environment::ReplaceOption($secretName, $secret); + $oldRegion = Environment::ReplaceOption($regionName, $region); + $oldEndpoint = Environment::ReplaceOption($endpointName, $endpoint); + $oldPathStyleEndpoint = Environment::ReplaceOption($pathStyleEndpointName, $pathStyleEndpoint); + $oldUseTransferAcceleration = Environment::ReplaceOption($useTransferAccelerationName, $useTransferAcceleration); + + StorageManager::resetStorageInstance(); + + try { + $storage = new static(); + $restoreOld = !$storage->validateSettings(); + } catch (\Exception $ex) { + $restoreOld = true; + } + + if ($restoreOld) { + Environment::UpdateOption($providerName, $oldProvider); + Environment::UpdateOption($bucketName, $oldBucket); + Environment::UpdateOption($accessKeyName, $oldKey); + Environment::UpdateOption($secretName, $oldSecret); + Environment::UpdateOption($regionName, $oldRegion); + Environment::UpdateOption($endpointName, $oldEndpoint); + Environment::UpdateOption($pathStyleEndpointName, $oldPathStyleEndpoint); + Environment::UpdateOption($useTransferAccelerationName, $oldUseTransferAcceleration); + + StorageManager::resetStorageInstance(); + + $message = "There was a problem with your settings. Please double check entries for potential mistakes."; + + wp_send_json([ 'status' => 'error', 'message' => $message], 200); + } else { + wp_send_json([ 'status' => 'ok'], 200); + } + + } + + + + //endregion } diff --git a/classes/Storage/Driver/S3/S3StorageInterface.php b/classes/Storage/Driver/S3/S3StorageInterface.php new file mode 100755 index 00000000..4c079a68 --- /dev/null +++ b/classes/Storage/Driver/S3/S3StorageInterface.php @@ -0,0 +1,23 @@ + ['mcloud-storage-s3-access-key', ['ILAB_AWS_S3_ACCESS_KEY', 'ILAB_CLOUD_ACCESS_KEY'], null], + 'secret' => ['mcloud-storage-s3-secret', ['ILAB_AWS_S3_ACCESS_SECRET', 'ILAB_CLOUD_ACCESS_SECRET'], null], + 'bucket' => ['mcloud-storage-s3-bucket', ['ILAB_AWS_S3_BUCKET','ILAB_CLOUD_BUCKET'], null], + 'useCredentialProvider' => ['mcloud-storage-s3-use-credential-provider', ['ILAB_AWS_S3_USE_CREDENTIAL_PROVIDER', 'ILAB_CLOUD_USE_CREDENTIAL_PROVIDER'], false], + 'useTransferAcceleration' => ['mcloud-storage-s3-use-transfer-acceleration', 'ILAB_AWS_S3_TRANSFER_ACCELERATION', false], + 'usePresignedURLs' => ['mcloud-storage-use-presigned-urls', null, false], + 'presignedURLExpiration' => ['mcloud-storage-presigned-expiration', null, 300], + 'usePresignedURLsForImages' => ['mcloud-storage-use-presigned-urls-images', null, false], + 'presignedURLExpirationForImages' => ['mcloud-storage-presigned-expiration-images', null, 0], + 'usePresignedURLsForAudio' => ['mcloud-storage-use-presigned-urls-audio', null, false], + 'presignedURLExpirationForAudio' => ['mcloud-storage-presigned-expiration-audio', null, 0], + 'usePresignedURLsForVideo' => ['mcloud-storage-use-presigned-urls-video', null, false], + 'presignedURLExpirationForVideo' => ['mcloud-storage-presigned-expiration-video', null, 0], + 'usePresignedURLsForDocs' => ['mcloud-storage-use-presigned-urls-docs', null, false], + 'presignedURLExpirationForDocs' => ['mcloud-storage-presigned-expiration-docs', null, 0], + 'settingsError' => ['ilab-backblaze-settings-error', null, false], + ]; + + /** @var S3StorageInterface */ + private $storage = null; + + private $_endpoint = null; + private $_pathStyleEndpoint = null; + private $_region = null; + private $_settingsError = null; + + /** + * S3StorageSettings constructor. + * + * @param StorageInterface $storage + */ + public function __construct($storage) { + $this->storage = $storage; + } + + public function __get($name) { + if ($name === 'endpoint') { + if (StorageManager::driver() === 's3') { + return null; + } + + if ($this->_endpoint !== null) { + return $this->_endpoint; + } + + /** @var StorageInterface $storageClass */ + $storageClass = get_class($this->storage); + + if ($storageClass::endpoint() !== null) { + $this->_endpoint = $storageClass::endpoint(); + } else { + $this->_endpoint = Environment::Option('mcloud-storage-s3-endpoint', ['ILAB_AWS_S3_ENDPOINT', 'ILAB_CLOUD_ENDPOINT'], null); + } + + if(!empty($this->_endpoint)) { + if(!preg_match('#^[aA-zZ0-9]+\:\/\/#', $this->_endpoint)) { + $this->_endpoint = 'https://'.$this->_endpoint; + } + } + + return $this->_endpoint; + } else if ($name === 'endPointPathStyle') { + if ($this->_pathStyleEndpoint !== null) { + return $this->_pathStyleEndpoint; + } + + /** @var StorageInterface $storageClass */ + $storageClass = get_class($this->storage); + + if ($storageClass::pathStyleEndpoint() !== null) { + $this->_endPointPathStyle = $storageClass::pathStyleEndpoint(); + } else { + $this->_endPointPathStyle = Environment::Option('mcloud-storage-s3-use-path-style-endpoint', ['ILAB_AWS_S3_ENDPOINT_PATH_STYLE', 'ILAB_CLOUD_ENDPOINT_PATH_STYLE'], true); + } + + return $this->_pathStyleEndpoint; + + } else if ($name === 'region') { + + if ($this->_region !== null) { + return $this->_region; + } + + /** @var StorageInterface $storageClass */ + $storageClass = get_class($this->storage); + + if ($storageClass::defaultRegion() !== null) { + $this->region = $storageClass::defaultRegion(); + } else if ((StorageManager::driver() !== 'wasabi') && (StorageManager::driver() !== 'do')) { + $region = Environment::Option('mcloud-storage-s3-region', ['ILAB_AWS_S3_REGION', 'ILAB_CLOUD_REGION'], 'auto'); + + if($region !== 'auto') { + $this->_region = $region; + } + } else if (StorageManager::driver() === 'wasabi') { + $this->_region = Environment::Option('mcloud-storage-wasabi-region', null, null); + } + + return $this->_region; + } else if ($name === 'settingsError') { + if ($this->_settingsError === null) { + return $this->_settingsError; + } + + /** @var S3StorageInterface $storageClass */ + $storageClass = get_class($this->storage); + $this->_settingsError = Environment::Option($storageClass::settingsErrorOptionName(), null, false); + return $this->_settingsError; + } + + return parent::__get($name); + } + + public function __set($name, $value) { + if ($name === 'region') { + $this->_region = $value; + Environment::UpdateOption('mcloud-storage-s3-region', $value); + } else if ($name === 'settingsError') { + /** @var S3StorageInterface $storageClass */ + $storageClass = get_class($this->storage); + $this->_settingsError = $value; + Environment::UpdateOption($storageClass::settingsErrorOptionName(), $value); + } + + parent::__set($name, $value); + } + + public function __isset($name) { + if (in_array($name, ['region', 'endPointPathStyle', 'endpoint', 'settingsError'])) { + return true; + } + + return parent::__isset($name); + } + +} \ No newline at end of file diff --git a/classes/Storage/Driver/S3/WasabiStorage.php b/classes/Storage/Driver/S3/WasabiStorage.php index 9d29ff54..25f301ae 100755 --- a/classes/Storage/Driver/S3/WasabiStorage.php +++ b/classes/Storage/Driver/S3/WasabiStorage.php @@ -20,28 +20,16 @@ use ILAB\MediaCloud\Storage\FileInfo; use ILAB\MediaCloud\Storage\InvalidStorageSettingsException; use ILAB\MediaCloud\Storage\StorageException; +use function ILAB\MediaCloud\Utilities\anyNull; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\Logging\Logger; +use ILAB\MediaCloud\Utilities\Tracker; +use ILAB\MediaCloud\Wizard\WizardBuilder; use ILABAmazon\Exception\AwsException; if (!defined( 'ABSPATH')) { header( 'Location: /'); die; } class WasabiStorage extends OtherS3Storage { - //region Properties - - //endregion - - //region Constructor - public function __construct() { - parent::__construct(); - - $region = Environment::Option('mcloud-storage-wasabi-region', null, null); - if(!empty($region)) { - $this->region = $region; - } - } - //endregion - //region Static Information Methods public static function identifier() { return 'wasabi'; @@ -69,7 +57,7 @@ public function supportsDirectUploads() { return true; } - protected function settingsErrorOptionName() { + public static function settingsErrorOptionName() { return 'ilab-wasabi-settings-error'; } @@ -102,7 +90,7 @@ public function insureACL($key, $acl) { } try { - $this->client->putObjectAcl(['Bucket' => $this->bucket, 'Key' => $key, 'ACL' => $acl]); + $this->client->putObjectAcl(['Bucket' => $this->settings->bucket, 'Key' => $key, 'ACL' => $acl]); } catch (AwsException $ex) { throw new StorageException($ex->getMessage(), $ex->getStatusCode(), $ex); } @@ -114,7 +102,7 @@ public function info($key) { } try { - $result = $this->client->headObject(['Bucket' => $this->bucket, 'Key' => $key]); + $result = $this->client->headObject(['Bucket' => $this->settings->bucket, 'Key' => $key]); $length = $result->get('ContentLength'); $type = $result->get('ContentType'); } @@ -146,7 +134,7 @@ public function info($key) { public function uploadUrl($key, $acl, $mimeType = null, $cacheControl = null, $expires = null) { try { $optionsData = [ - 'Bucket' => $this->bucket, + 'Bucket' => $this->settings->bucket, 'ContentType' => $mimeType, 'Key' => $key ]; @@ -175,4 +163,122 @@ public function enqueueUploaderScripts() { wp_enqueue_script('ilab-media-upload-other-s3', ILAB_PUB_JS_URL.'/ilab-media-direct-upload-other-s3.js', [], false, true); } //endregion + + //region Wizard + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if (empty($builder)) { + $builder = new WizardBuilder('cloud-storage-wasabi', true); + } + + $builder + ->section('cloud-storage-wasabi', true) + ->select('Getting Started', 'Learn about Wasabi and how to set it up to work with Media Cloud.') + ->group('wizard.cloud-storage.providers.wasabi.intro', 'select-buttons') + ->option('read-tutorial', 'Step By Step Tutorial', null, null, 'cloud-storage-wasabi-tutorial') + ->endGroup() + ->endStep() + ->form('wizard.cloud-storage.providers.wasabi.form', 'Cloud Storage Settings', 'Configure Media Cloud with your cloud storage settings.', [static::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-storage-settings')) + ->hiddenField('mcloud-storage-provider', 'wasabi') + ->textField('mcloud-storage-s3-access-key', 'Access Key', '', null) + ->passwordField('mcloud-storage-s3-secret', 'Secret', '', null) + ->textField('mcloud-storage-s3-bucket', 'Bucket', 'The name of bucket you wish to store your media in.', null) + ->selectField('mcloud-storage-wasabi-region', 'Region', '', null, [ + 'us-east-1' => 'US East', + 'us-west-1' => 'US West', + 'eu-central-1' => 'EU' + ]) + ->endStep() + ->testStep('wizard.cloud-storage.providers.wasabi.test', 'Test Settings', 'Perform tests to insure that your cloud storage provider is configured correctly.', false); + + static::addTests($builder); + + $builder->select('Complete', 'Basic setup is now complete! Configure advanced settings or setup imgix.') + ->group('wizard.cloud-storage.providers.wasabi.success', 'select-buttons') + ->option('configure-imgix', 'Set Up imgix', null, null, 'imgix') + ->option('advanced-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-storage') + ->endGroup() + ->endStep(); + + $builder + ->tutorialSection('cloud-storage-wasabi-tutorial', true) + ->tutorial('wizard.cloud-storage.providers.wasabi.tutorial.step-1', 'Create IAM User', 'Create the IAM user account and credentials Media Cloud will use to access Wasabi.') + ->tutorial('wizard.cloud-storage.providers.wasabi.tutorial.step-2', 'Create Bucket', 'Create the bucket that Media Cloud will use.', null, true) + ->endSection(); + + return $builder; + } + + protected static function validateWizardInput($provider, $accessKey, $secret, $bucket, $region, $endpoint) { + return !anyNull($provider, $accessKey, $secret, $bucket, $region); + } + + /** + * @return array[ + * 'providerName' => string, + * 'accessKeyName' => string, + * 'secretName' => string, + * 'bucketName' => string, + * 'regionName' => string, + * 'endpointName' => string, + * 'pathStyleEndpointName' => string, + * 'useTransferAccelerationName' => string + * ] + */ + protected static function fetchWizardInputNames() { + return [ + 'providerName' => 'mcloud-storage-provider', + 'accessKeyName' => 'mcloud-storage-s3-access-key', + 'secretName' => 'mcloud-storage-s3-secret', + 'bucketName' => 'mcloud-storage-s3-bucket', + 'regionName' => 'mcloud-storage-wasabi-region', + 'endpointName' => 'mcloud-storage-s3-endpoint', + 'pathStyleEndpointName' => 'mcloud-storage-s3-use-path-style-endpoint', + 'useTransferAccelerationName' => 'mcloud-storage-s3-use-transfer-acceleration' + ]; + } + + public static function testStorageAcl() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Tracker::trackView("System Test - Test Public", "/system-test/public"); + + $client = new static(); + $errors = []; + try { + $result = null; + $url = $client->url('_troubleshooter/sample.txt'); + + $result = ilab_file_get_contents($url); + + if ($result != file_get_contents(ILAB_TOOLS_DIR.'/public/text/sample-upload.txt')) { + $errors[] = "Upload sample file is not publicly viewable."; + } + } catch (\Exception $ex) { + $errors[] = $ex->getMessage(); + } + + if (empty($errors)) { + wp_send_json([ + 'status' => 'success', + 'message' => 'The uploaded file is publicly accessible.', + ]); + } else { + wp_send_json([ + 'status' => 'warning', + 'message' => 'The uploaded file is not publicly accessible. If you are using a Wasabi trial account, this is expected because trial accounts don\'t allow public files. If you are using a paid account, double check your bucket settings because this shouldn\'t happen.', + 'errors' => $errors + ]); + } + } + //endregion + } diff --git a/classes/Storage/StorageSettings.php b/classes/Storage/StorageGlobals.php similarity index 89% rename from classes/Storage/StorageSettings.php rename to classes/Storage/StorageGlobals.php index af33573b..3ae58482 100755 --- a/classes/Storage/StorageSettings.php +++ b/classes/Storage/StorageGlobals.php @@ -23,9 +23,9 @@ if (!defined('ABSPATH')) { header('Location: /'); die; } -final class StorageSettings { +final class StorageGlobals { //region Class variables - /** @var StorageSettings */ + /** @var StorageGlobals */ private static $instance = null; /** @var string|null */ @@ -43,6 +43,18 @@ final class StorageSettings { /** @var string */ private $privacy = 'public-read'; + /** @var string */ + private $privacyImages = 'inherit'; + + /** @var string */ + private $privacyVideo = 'inherit'; + + /** @var string */ + private $privacyAudio = 'inherit'; + + /** @var string */ + private $privacyDocs = 'inherit'; + /** @var array */ private $ignoredMimeTypes = []; @@ -100,6 +112,11 @@ private function __construct() { $this->privacy = 'public-read'; } + $this->privacyImages = Environment::Option('mcloud-storage-privacy-images', null, "inherit"); + $this->privacyAudio = Environment::Option('mcloud-storage-privacy-audio', null, "inherit"); + $this->privacyVideo = Environment::Option('mcloud-storage-privacy-video', null, "inherit"); + $this->privacyDocs = Environment::Option('mcloud-storage-privacy-docs', null, "inherit"); + $ignored = Environment::Option('mcloud-storage-ignored-mime-types', null, ''); $ignored_lines = explode("\n", $ignored); if(count($ignored_lines) <= 1) { @@ -152,11 +169,11 @@ private function __construct() { } /** - * @return StorageSettings|null + * @return StorageGlobals|null */ private static function instance() { if (!self::$instance) { - self::$instance = new StorageSettings(); + self::$instance = new StorageGlobals(); } return self::$instance; @@ -195,8 +212,31 @@ public static function expires() { } /** @return string */ - public static function privacy() { - return self::instance()->privacy; + public static function privacy($type = null) { + /** @var StorageGlobals $instance */ + $instance = self::instance(); + + if ($type === null) { + return $instance->privacy; + } + + if (strpos($type, 'image') === 0) { + return ($instance->privacyImages === 'inherit') ? $instance->privacy : $instance->privacyImages; + } + + if (strpos($type, 'video') === 0) { + return ($instance->privacyVideo === 'inherit') ? $instance->privacy : $instance->privacyVideo; + } + + if (strpos($type, 'audio') === 0) { + return ($instance->privacyAudio === 'inherit') ? $instance->privacy : $instance->privacyAudio; + } + + if ((strpos($type, 'application') === 0) || (strpos($type, 'text') === 0)) { + return ($instance->privacyDocs === 'inherit') ? $instance->privacy : $instance->privacyDocs; + } + + return $instance->privacy; } /** @return array */ @@ -386,6 +426,14 @@ private static function migrateStatelessSettings() { //endregion + //region Maintenance + + public static function reloadSettings() { + self::$instance = new StorageGlobals(); + } + + //endregion + //region Offload Migrations private static function migrateOffloadMiscSettings($offloadConfig) { diff --git a/classes/Storage/StorageInterface.php b/classes/Storage/StorageInterface.php index 70fe6d2e..f449d419 100755 --- a/classes/Storage/StorageInterface.php +++ b/classes/Storage/StorageInterface.php @@ -17,6 +17,7 @@ namespace ILAB\MediaCloud\Storage; use ILAB\MediaCloud\Utilities\Logging\ErrorCollector; +use ILAB\MediaCloud\Wizard\WizardBuilder; use League\Flysystem\AdapterInterface; if (!defined('ABSPATH')) { header('Location: /'); die; } @@ -80,12 +81,14 @@ public static function bucketLink($bucket); */ public function pathLink($bucket, $key); - /** - * Returns true/false if this storage is using signed URLs. - * - * @return bool - */ - public function usesSignedURLs(); + /** + * Returns true/false if this storage is using signed URLs. + * + * @param string|null $type + * + * @return bool + */ + public function usesSignedURLs($type = null); /** * Insures that all the configuration settings are valid and that the storage is enabled. @@ -216,10 +219,11 @@ public function presignedUrl($key, $expiration = 0); /** * Returns the URL (not-signed) for the item in a bucket * @param string $key + * @param string|null $type * @throws StorageException * @return string */ - public function url($key); + public function url($key, $type = null); /** * Generates a signed URL for direct uploads diff --git a/classes/Storage/StorageManager.php b/classes/Storage/StorageManager.php index f1f9d76c..a78bb754 100755 --- a/classes/Storage/StorageManager.php +++ b/classes/Storage/StorageManager.php @@ -59,6 +59,7 @@ public static function driver() { * Resets the current storage interface */ public static function resetStorageInstance() { + self::$driver = null; self::$instance = null; } diff --git a/classes/Tasks/AttachmentTask.php b/classes/Tasks/AttachmentTask.php index 45bc19a1..a3a98825 100755 --- a/classes/Tasks/AttachmentTask.php +++ b/classes/Tasks/AttachmentTask.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tasks; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Utilities\Logging\Logger; abstract class AttachmentTask extends Task { @@ -110,7 +110,7 @@ public function prepare($options = [], $selectedItems = []) { $args['nopaging'] = true; } - $args['post_mime_type'] = StorageSettings::allowedMimeTypes(); + $args['post_mime_type'] = StorageGlobals::allowedMimeTypes(); $args = $this->filterPostArgs($args); diff --git a/classes/Tools/BatchProcessing/BatchProcessingTool.php b/classes/Tools/BatchProcessing/BatchProcessingTool.php index 5c3dc765..6c7a704a 100755 --- a/classes/Tools/BatchProcessing/BatchProcessingTool.php +++ b/classes/Tools/BatchProcessing/BatchProcessingTool.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\BatchProcessing; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\Tool; use ILAB\MediaCloud\Tools\ToolsManager; diff --git a/classes/Tools/Crop/CropTool.php b/classes/Tools/Crop/CropTool.php index d77b4c5b..bf770da8 100755 --- a/classes/Tools/Crop/CropTool.php +++ b/classes/Tools/Crop/CropTool.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\Crop; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\Tool; use ILAB\MediaCloud\Tools\ToolsManager; @@ -529,7 +529,7 @@ private function doPerformCrop($post_id, $size, $crop_x, $crop_y, $crop_width, $ list($full_src,$full_width,$full_height,$full_cropped)=$attrs; if ($storageTool->enabled()) { - if(StorageSettings::deleteOnUpload() && !StorageSettings::queuedDeletes()) { + if(StorageGlobals::deleteOnUpload() && !StorageGlobals::queuedDeletes()) { $toDelete = trailingslashit($save_path).$filename; if (file_exists($toDelete)) { @unlink($toDelete); diff --git a/classes/Tools/Debugging/System/SystemCompatibilityTool.php b/classes/Tools/Debugging/System/SystemCompatibilityTool.php index 48fde5a0..b4d672fb 100755 --- a/classes/Tools/Debugging/System/SystemCompatibilityTool.php +++ b/classes/Tools/Debugging/System/SystemCompatibilityTool.php @@ -15,7 +15,7 @@ use Carbon\CarbonInterval; use FasterImage\FasterImage; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tasks\TaskRunner; use ILAB\MediaCloud\Tools\Imgix\ImgixTool; use ILAB\MediaCloud\Tools\Storage\StorageTool; @@ -374,7 +374,7 @@ private function testUploadClient() { $errors = []; try { - $url = $storageTool->client()->upload('_troubleshooter/sample.txt',ILAB_TOOLS_DIR.'/public/text/sample-upload.txt', StorageSettings::privacy()); + $url = $storageTool->client()->upload('_troubleshooter/sample.txt',ILAB_TOOLS_DIR.'/public/text/sample-upload.txt', StorageGlobals::privacy()); Tracker::trackView("System Test - Test Uploads - Success", "/system-test/uploads/success"); } catch (\Exception $ex) { Tracker::trackView("System Test - Test Uploads - Error", "/system-test/uploads/error"); @@ -534,7 +534,7 @@ private function testImgix() { $errors = []; try { - $storageTool->client()->upload('_troubleshooter/sample.jpg',ILAB_TOOLS_DIR.'/public/img/test-image.jpg', StorageSettings::privacy()); + $storageTool->client()->upload('_troubleshooter/sample.jpg',ILAB_TOOLS_DIR.'/public/img/test-image.jpg', StorageGlobals::privacy()); $imgixURL = $imgixTool->urlForKey('_troubleshooter/sample.jpg'); $faster = new FasterImage(); diff --git a/classes/Tools/DynamicImages/DynamicImagesTool.php b/classes/Tools/DynamicImages/DynamicImagesTool.php index fda3f429..87d75fa0 100755 --- a/classes/Tools/DynamicImages/DynamicImagesTool.php +++ b/classes/Tools/DynamicImages/DynamicImagesTool.php @@ -124,16 +124,6 @@ public function setup() { add_filter('image_get_intermediate_size', [$this, 'imageGetIntermediateSize'], 0, 3); - if (Environment::Option('mcloud-imgix-disable-srcset', null, false)) { - add_filter('media-cloud/storage/can-calculate-srcset', function($can) { - return false; - }); - - add_filter('wp_calculate_image_srcset', function($sources, $size_array, $image_src, $image_meta, $attachment_id) { - return []; - }, 10001, 5); - } - add_action('admin_enqueue_scripts', [$this, 'enqueueTheGoods']); add_action('wp_ajax_ilab_dynamic_images_edit_page', [$this, 'displayEditUI']); add_action('wp_ajax_ilab_dynamic_images_save', [$this, 'saveAdjustments']); diff --git a/classes/Tools/Imgix/ImgixTool.php b/classes/Tools/Imgix/ImgixTool.php index d3c411d1..fcb896c4 100755 --- a/classes/Tools/Imgix/ImgixTool.php +++ b/classes/Tools/Imgix/ImgixTool.php @@ -13,11 +13,16 @@ namespace ILAB\MediaCloud\Tools\Imgix; +use FasterImage\FasterImage; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tools\DynamicImages\DynamicImagesTool; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\ToolsManager; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\Logging\Logger; +use ILAB\MediaCloud\Utilities\Tracker; +use ILAB\MediaCloud\Wizard\ConfiguresWizard; +use ILAB\MediaCloud\Wizard\WizardBuilder; use Imgix\UrlBuilder; use function ILAB\MediaCloud\Utilities\arrayPath; @@ -32,28 +37,23 @@ * * Imgix tool. */ -class ImgixTool extends DynamicImagesTool { - protected $imgixDomains; - protected $autoFormat; - protected $autoCompress; - protected $enableGifs; - protected $skipGifs; - protected $noGifSizes; - protected $useHTTPS; - protected $enabledAlternativeFormats; - protected $renderPDF; - protected $detectFaces; +class ImgixTool extends DynamicImagesTool implements ConfiguresWizard { + /** @var ImgixToolSettings */ + protected $settings; + //region Constructor public function __construct($toolName, $toolInfo, $toolManager) { parent::__construct($toolName, $toolInfo, $toolManager); + $this->settings = new ImgixToolSettings(); + add_filter('media-cloud/imgix/enabled', function($enabled){ return $this->enabled(); }); add_filter('media-cloud/imgix/alternative-formats/enabled', function($enabled){ - return ($this->enabled() && $this->enabledAlternativeFormats); + return ($this->enabled() && $this->settings->enabledAlternativeFormats); }); } //endregion @@ -62,8 +62,7 @@ public function __construct($toolName, $toolInfo, $toolManager) { public function enabled() { $enabled = parent::enabled(); - if(!Environment::Option('mcloud-imgix-domains')) { -// NoticeManager::instance()->displayAdminNotice('error', "To start using Imgix, you will need to set it up.", true, 'disable-ilab-imgix-warning'); + if (empty($this->settings->imgixDomains)) { return false; } @@ -74,6 +73,14 @@ public function hasSettings() { return true; } + public function hasWizard() { + return true; + } + + public function wizardLink() { + return admin_url('admin.php?page=media-cloud-wizard&wizard=imgix'); + } + public function setup() { if(!$this->enabled()) { return; @@ -81,46 +88,7 @@ public function setup() { parent::setup(); - $this->noGifSizes = []; - $noGifSizes = Environment::Option('mcloud-imgix-no-gif-sizes', null, ''); - $noGifSizesArray = explode("\n", $noGifSizes); - if(count($noGifSizesArray) <= 1) { - $noGifSizesArray = explode(',', $noGifSizes); - } - foreach($noGifSizesArray as $gs) { - if(!empty($gs)) { - $this->noGifSizes[] = trim($gs); - } - } - - $this->imgixDomains = []; - $domains = Environment::Option('mcloud-imgix-domains', null, ''); - $domain_lines = explode("\n", $domains); - if(count($domain_lines) <= 1) { - $domain_lines = explode(',', $domains); - } - foreach($domain_lines as $d) { - if(!empty($d)) { - $this->imgixDomains[] = trim($d); - } - } - - $this->useHTTPS = Environment::Option('mcloud-imgix-use-https', null, true); - - $this->signingKey = Environment::Option('mcloud-imgix-signing-key'); - - $this->imageQuality = Environment::Option('mcloud-imgix-default-quality'); - $this->autoFormat = Environment::Option('mcloud-imgix-auto-format'); - $this->autoCompress = Environment::Option('mcloud-imgix-auto-compress'); - $this->enableGifs = Environment::Option('mcloud-imgix-enable-gifs'); - $this->skipGifs = Environment::Option('mcloud-imgix-skip-gifs', null, false); - $this->detectFaces = Environment::Option('mcloud-imgix-detect-faces', null, false); - - $this->enabledAlternativeFormats = Environment::Option('mcloud-imgix-enable-alt-formats'); - $this->renderPDF = Environment::Option('mcloud-imgix-render-pdf-files'); - $this->keepThumbnails = Environment::Option('mcloud-imgix-generate-thumbnails', null, true); - - if($this->enabledAlternativeFormats) { + if($this->settings->enabledAlternativeFormats) { add_filter('file_is_displayable_image', [$this, "fileIsDisplayableImage"], 0, 2); add_filter('upload_mimes', function($mime_types) { @@ -149,17 +117,17 @@ public function setup() { add_filter('imgix_build_gif_jpeg', [$this, 'buildGifJpeg'], 0, 3); add_filter('media-cloud/imgix/render-pdf', function() { - return $this->renderPDF; + return $this->settings->renderPDF; }); do_action('media-cloud/imgix/setup'); - if ($this->detectFaces) { + if ($this->settings->detectFaces) { add_filter('media-cloud/storage/after-upload', [$this, 'processImageMeta'], 1000, 2); } add_filter('media-cloud/imgix/detect-faces', function($detectFaces) { - return ($this->enabled() && $this->detectFaces); + return ($this->enabled() && $this->settings->detectFaces); }); } //endregion @@ -176,11 +144,11 @@ public function setup() { private function buildImgixParams($params, $mimetype = '') { $format = null; if(!isset($params['fm'])) { - if(($mimetype == 'image/gif') && $this->enableGifs) { + if(($mimetype == 'image/gif') && $this->settings->enableGifs) { $format = 'gif'; - } else if(($mimetype == 'image/png') && !$this->autoFormat) { + } else if(($mimetype == 'image/png') && !$this->settings->autoFormat) { $format = 'png'; - } else if(!$this->autoFormat) { + } else if(!$this->settings->autoFormat) { $format = 'pjpg'; } } else { @@ -200,22 +168,22 @@ private function buildImgixParams($params, $mimetype = '') { } if(!$format) { - if($this->autoCompress && $this->autoFormat) { + if($this->settings->autoCompress && $this->settings->autoFormat) { $auto[] = 'compress'; $auto[] = 'format'; - } else if($this->autoCompress) { + } else if($this->settings->autoCompress) { $auto[] = 'compress'; - } else if($this->autoFormat) { + } else if($this->settings->autoFormat) { $auto[] = 'format'; } } else if($format) { $params['fm'] = $format; - if($this->autoCompress) { + if($this->settings->autoCompress) { $auto[] = 'compress'; } } else { $params['fm'] = 'pjpg'; - if($this->autoCompress) { + if($this->settings->autoCompress) { $auto[] = 'compress'; } } @@ -227,8 +195,8 @@ private function buildImgixParams($params, $mimetype = '') { unset($params['enhance']); unset($params['redeye']); - if($this->imageQuality) { - $params['q'] = $this->imageQuality; + if($this->settings->imageQuality) { + $params['q'] = $this->settings->imageQuality; } foreach($this->paramPropsByType['media-chooser'] as $key => $info) { @@ -290,10 +258,10 @@ public function buildSizedImage($id, $size) { return []; } - $imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS); + $imgix = new UrlBuilder($this->settings->imgixDomains, $this->settings->useHTTPS); - if($this->signingKey) { - $imgix->setSignKey($this->signingKey); + if($this->settings->signingKey) { + $imgix->setSignKey($this->settings->signingKey); } if (isset($size['crop'])) { @@ -403,13 +371,13 @@ public function buildImage($id, $size, $params = null, $skipParams = false, $mer $mimetype = get_post_mime_type($id); - if (!$this->renderPDF && ($mimetype == 'application/pdf')) { + if (!$this->settings->renderPDF && ($mimetype == 'application/pdf')) { return false; } $meta = wp_get_attachment_metadata($id); if(!$meta || empty($meta)) { - if(($this->renderPDF && ($mimetype == 'application/pdf')) || ($this->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) { + if(($this->settings->renderPDF && ($mimetype == 'application/pdf')) || ($this->settings->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) { $meta = get_post_meta($id, 'ilab_s3_info', true); } @@ -423,17 +391,17 @@ public function buildImage($id, $size, $params = null, $skipParams = false, $mer } if(!isset($meta['s3'])) { - if(($this->renderPDF && ($mimetype == 'application/pdf')) || ($this->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) { + if(($this->settings->renderPDF && ($mimetype == 'application/pdf')) || ($this->settings->enabledAlternativeFormats && ($mimetype == 'application/vnd.adobe.illustrator'))) { $meta = get_post_meta($id, 'ilab_s3_info', true); } else { return false; } } - $imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS); + $imgix = new UrlBuilder($this->settings->imgixDomains, $this->settings->useHTTPS); - if($this->signingKey) { - $imgix->setSignKey($this->signingKey); + if($this->settings->signingKey) { + $imgix->setSignKey($this->settings->signingKey); } if($size == 'full' && !$newSize) { @@ -688,17 +656,17 @@ public function buildImage($id, $size, $params = null, $skipParams = false, $mer } public function urlForStorageMedia($key, $params = []) { - $imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS); + $imgix = new UrlBuilder($this->settings->imgixDomains, $this->settings->useHTTPS); - if($this->signingKey) { - $imgix->setSignKey($this->signingKey); + if($this->settings->signingKey) { + $imgix->setSignKey($this->settings->signingKey); } return $imgix->createURL(str_replace('%2F', '/', urlencode($key)), $params); } public function fixCleanedUrls($good_protocol_url, $original_url, $context) { - foreach($this->imgixDomains as $domain) { + foreach($this->settings->imgixDomains as $domain) { if (strpos($good_protocol_url, $domain) !== false) { return $original_url; } @@ -780,7 +748,7 @@ function prepareAttachmentForJS($response, $attachment, $meta) { return $response; } - if($this->renderPDF && isset($meta['s3'])) { + if($this->settings->renderPDF && isset($meta['s3'])) { if($attachment->post_mime_type == 'application/pdf') { $response['type'] = 'image'; $response['mime'] = 'image/pdf'; @@ -798,7 +766,7 @@ function prepareAttachmentForJS($response, $attachment, $meta) { } } - $generateUrls = !($this->skipGifs && ($attachment->post_mime_type == 'image/gif')); + $generateUrls = !($this->settings->skipGifs && ($attachment->post_mime_type == 'image/gif')); if ($generateUrls) { foreach($response['sizes'] as $key => $sizeInfo) { $res = $this->buildImage($response['id'], $key); @@ -819,7 +787,7 @@ function prepareAttachmentForJS($response, $attachment, $meta) { * @throws \ILAB\MediaCloud\Storage\StorageException */ public function getAttachmentURL($url, $post_id) { - if ($this->skipGifs) { + if ($this->settings->skipGifs) { $mimeType = get_post_mime_type($post_id); if ($mimeType == 'image/gif') { /** @var StorageTool $storageTool */ @@ -842,7 +810,7 @@ public function getAttachmentURL($url, $post_id) { * @throws \ILAB\MediaCloud\Storage\StorageException */ public function imageDownsize($fail, $id, $size) { - if ($this->skipGifs) { + if ($this->settings->skipGifs) { $mimeType = get_post_mime_type($id); if ($mimeType == 'image/gif') { /** @var StorageTool $storageTool */ @@ -865,7 +833,7 @@ public function imageDownsize($fail, $id, $size) { * @return array */ public function generateAttachmentMetadata($metadata, $attachment_id) { - if(!$this->enabledAlternativeFormats) { + if(!$this->settings->enabledAlternativeFormats) { return $metadata; } @@ -968,7 +936,7 @@ public function fileIsDisplayableImage($result, $path) { * @return string */ public function mediaSendToEditor($html, $id, $attachment) { - if(!$this->renderPDF) { + if(!$this->settings->renderPDF) { return $html; } @@ -1000,14 +968,140 @@ public function mediaSendToEditor($html, $id, $attachment) { //region Testing public function urlForKey($key) { - $imgix = new UrlBuilder($this->imgixDomains, $this->useHTTPS); + $imgix = new UrlBuilder($this->settings->imgixDomains, $this->settings->useHTTPS); - if($this->signingKey) { - $imgix->setSignKey($this->signingKey); + if($this->settings->signingKey) { + $imgix->setSignKey($this->settings->signingKey); } return $imgix->createURL($key, []); } //endregion + + + //region Wizard + /** + * @param WizardBuilder|null $builder + * + * @return WizardBuilder|null + * @throws \Exception + */ + public static function configureWizard($builder = null) { + if ($builder == null) { + $builder = new WizardBuilder('imgix', true); + } + + $builder + ->section('imgix', true) + ->select('Intro', "Let's get started setting up imgix!") + ->group('wizard.imgix.intro', 'select-buttons') + ->option('imgix-doc', 'imgix Documentation', null, null, null, null, 'https://docs.imgix.com/setup', '_blank') + ->endGroup() + ->endStep() + ->form('wizard.imgix.settings', 'imgix Settings', 'Configure Media Cloud with your imgix settings.', [ImgixTool::class, 'processWizardSettings']) + ->hiddenField('nonce', wp_create_nonce('update-imgix-settings')) + ->textField('mcloud-imgix-domains', 'imgix Domain', "Your imgix domain name. For more information, please read the imgix documentation", null) + ->passwordField('mcloud-imgix-signing-key', 'Signing Key', "Optional signing key to create secure URLs. Recommended. For information on setting it up, refer to the imgix documentation.", null, false) + ->checkboxField('mcloud-imgix-use-https', 'Use HTTPS', 'Use HTTPS for image URLs', true) + ->endStep() + ->testStep('wizard.imgix.test', 'Test Settings', 'Perform tests to insure that imgix is configured correctly.', false) + ->test('Test imgix Configuration', 'Running tests ...', [static::class, 'testImgix']) + ->endStep() + ->select('Complete', 'imgix setup is now complete!') + ->group('wizard.imgix.success', 'select-buttons') + ->option('other-features', 'Explore Other Features', null, null, null, null, 'admin:admin.php?page=media-cloud') + ->option('advanced-imgix-settings', 'Advanced Settings', null, null, null, null, 'admin:admin.php?page=media-cloud-settings-imgix') + ->endGroup() + ->endStep(); + + return $builder; + } + + public static function processWizardSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'update-imgix-settings')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + $domain = arrayPath($_POST, 'mcloud-imgix-domains', null); + $signingKey = arrayPath($_POST, 'mcloud-imgix-signing-key', null); + $useHttps = arrayPath($_POST, 'mcloud-imgix-use-https', null); + + if (empty($domain)) { + wp_send_json(['status' => 'error', 'message' => 'Missing imgix domain.'], 200); + } + + Environment::UpdateOption('mcloud-imgix-domains', $domain); + Environment::UpdateOption('mcloud-imgix-signing-key', $signingKey); + Environment::UpdateOption('mcloud-imgix-use-https', $useHttps); + + wp_send_json([ 'status' => 'ok'], 200); + } + + public static function testImgix() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Tracker::trackView("System Test - Imgix", "/system-test/imgix"); + + /** @var StorageTool $storageTool */ + $storageTool = ToolsManager::instance()->tools['storage']; + if (!$storageTool->enabled()) { + wp_send_json([ + 'status' => 'error', + 'message' => 'Cloud Storage is not currently enabled.', + 'errors' => [] + ]); + } + + /** @var ImgixTool $imgixTool */ + $imgixTool = ToolsManager::instance()->tools['imgix']; + + + $errors = []; + + try { + $storageTool->client()->upload('_troubleshooter/sample.jpg',ILAB_TOOLS_DIR.'/public/img/test-image.jpg', StorageGlobals::privacy()); + $imgixURL = $imgixTool->urlForKey('_troubleshooter/sample.jpg'); + + $faster = new FasterImage(); + $result = $faster->batch([$imgixURL]); + $result = $result[$imgixURL]; + $size = $result['size']; + + if (empty($size) || ($size == 'failed')) { + $errors[] = "Unable to access Imgix sample image. Possibly wrong signing key or Imgix can't access the master image."; + } else if (count($size) > 1) { + list($w, $h) = $size; + + if (($w != 320) && ($h != 320)) { + $errors[] = "Invalid image size for sample image. $w x $h (should be 320 x 320)"; + } + } + } catch (\Exception $ex) { + $errors[] = $ex->getMessage(); + } + + if (empty($errors)) { + Environment::UpdateOption('mcloud-tool-enabled-imgix', true); + Environment::UpdateOption('mcloud-tool-enabled-crop', true); + + Tracker::trackView("System Test - Imgix - Success", "/system-test/imgix/success"); + wp_send_json([ + 'status' => 'success', + 'message' => 'Was able to view sample image on imgix.' + ]); + } else { + Environment::UpdateOption('mcloud-tool-enabled-imgix', false); + Tracker::trackView("System Test - Imgix - Error", "/system-test/imgix/error"); + wp_send_json([ + 'status' => 'error', + 'message' => 'There was an error attempting to view an image on imgix. Please check that your domain or signing key are correct.', + 'errors' => [] + ]); + } + } + + //endregion } diff --git a/classes/Tools/Imgix/ImgixToolSettings.php b/classes/Tools/Imgix/ImgixToolSettings.php new file mode 100755 index 00000000..142b4234 --- /dev/null +++ b/classes/Tools/Imgix/ImgixToolSettings.php @@ -0,0 +1,128 @@ + ['mcloud-imgix-auto-format', null, false], + 'signingKey' => ['mcloud-imgix-signing-key', null, null], + 'autoCompress' => ['mcloud-imgix-auto-compress', null, false], + 'enableGifs' => ['mcloud-imgix-enable-gifs', null, false], + 'skipGifs' => ['mcloud-imgix-skip-gifs', null, false], + 'useHTTPS' => ['mcloud-imgix-use-https', null, true], + 'enabledAlternativeFormats' => ['mcloud-imgix-enable-alt-formats', null, false], + 'renderPDF' => ['mcloud-imgix-render-pdf-files', null, false], + 'detectFaces' => ['mcloud-imgix-detect-faces', null, false], + 'generateThumbnails' => ['mcloud-imgix-generate-thumbnails', null, true], + 'imageQuality' => ['mcloud-imgix-default-quality', null, null], + ]; + + public function __get($name) { + if ($name === 'imgixDomains') { + if ($this->_imgixDomains === null) { + $this->_imgixDomains = []; + $domains = Environment::Option('mcloud-imgix-domains', null, ''); + $domain_lines = explode("\n", $domains); + + if(count($domain_lines) <= 1) { + $domain_lines = explode(',', $domains); + } + + foreach($domain_lines as $d) { + if(!empty($d)) { + $this->_imgixDomains[] = trim($d); + } + } + } + + return $this->_imgixDomains; + } else if ($name === 'noGifSizes') { + if ($this->_noGifSizes === null) { + $this->_noGifSizes = []; + $noGifSizes = Environment::Option('mcloud-imgix-no-gif-sizes', null, ''); + $noGifSizesArray = explode("\n", $noGifSizes); + if(count($noGifSizesArray) <= 1) { + $noGifSizesArray = explode(',', $noGifSizes); + } + + foreach($noGifSizesArray as $gs) { + if(!empty($gs)) { + $this->_noGifSizes[] = trim($gs); + } + } + } + + return $this->_noGifSizes; + } + + return parent::__get($name); + } + + public function __set($name, $value) { + if ($name === 'imgixDomains') { + if (empty($value)) { + Environment::UpdateOption('mcloud-imgix-domains', ''); + } else if (is_array($value)) { + Environment::UpdateOption('mcloud-imgix-domains', implode("\n", $value)); + } else { + Environment::UpdateOption('mcloud-imgix-domains', $value); + } + } else if ($name === 'noGifSizes') { + if (empty($value)) { + Environment::UpdateOption('mcloud-imgix-no-gif-sizes', ''); + } else if (is_array($value)) { + Environment::UpdateOption('mcloud-imgix-no-gif-sizes', implode("\n", $value)); + } else { + Environment::UpdateOption('mcloud-imgix-no-gif-sizes', $value); + } + } else { + parent::__set($name, $value); + } + } + + public function __isset($name) { + if ($name === 'imgixDomains') { + return true; + } else if ($name === 'noGifSizes') { + return true; + } + + return parent::__isset($name); // TODO: Change the autogenerated stub + } + +} \ No newline at end of file diff --git a/classes/Tools/Permissions/OptInTool.php b/classes/Tools/Permissions/OptInTool.php index 7ccf16dc..95303c1c 100755 --- a/classes/Tools/Permissions/OptInTool.php +++ b/classes/Tools/Permissions/OptInTool.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\Permissions; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\Tool; use ILAB\MediaCloud\Tools\ToolsManager; diff --git a/classes/Tools/SettingsTrait.php b/classes/Tools/SettingsTrait.php index 869bd44b..f4e49ff7 100755 --- a/classes/Tools/SettingsTrait.php +++ b/classes/Tools/SettingsTrait.php @@ -372,13 +372,13 @@ public function renderNumberFieldSetting($args) { * @param null $description * @param null $conditions */ - protected function registerSelectSetting($option_name, $options, $title, $settings_slug, $description=null, $conditions=null) { + protected function registerSelectSetting($option_name, $options, $title, $settings_slug, $default, $description=null, $conditions=null) { add_settings_field($option_name, $title, [$this,'renderSelectSetting'], $this->options_page, $settings_slug, - ['option'=>$option_name,'options'=>$options,'description'=>$description, 'conditions'=>$conditions]); + ['default' => $default, 'option'=>$option_name,'options'=>$options,'description'=>$description, 'conditions'=>$conditions]); } /** @@ -412,6 +412,7 @@ public function renderSelectSetting($args) { echo View::render_view('base/fields/select.php',[ 'value' => Environment::Option($args['option']), 'name' => $args['option'], + 'default' => isset($args['default']) ? $args['default'] : null, 'options' => $options, 'conditions' => $args['conditions'], 'description' => (isset($args['description'])) ? $args['description'] : false @@ -442,6 +443,73 @@ public function renderSiteSelectSetting($args) { ]); } + /** + * Registers an option with a dropdown/select input + * @param $option_name + * @param $title + * @param $settings_slug + * @param $conditions + * @throws \Freemius_Exception + */ + protected function registerAdvancedPresignedURLs($option_name, $title, $settings_slug, $conditions) { + if (media_cloud_licensing()->is_plan('pro')) { + add_settings_field($option_name, + $title, + [$this,'renderAdvancedPresignedURLs'], + $this->options_page, + $settings_slug, + ['option' => $option_name, 'conditions' => $conditions]); + } + } + + /** + * Renders the select + * @param $args + * @throws \Freemius_Exception + */ + public function renderAdvancedPresignedURLs($args) { + if (media_cloud_licensing()->is_plan('pro')) { + echo View::render_view('base/fields/advanced-presigned-urls', [ + 'name' => $args['option'], + 'conditions' => $args['conditions'] + ]); + } + } + + /** + * Registers an option with a dropdown/select input + * @param $option_name + * @param $title + * @param $settings_slug + * @param $conditions + * @throws \Freemius_Exception + */ + protected function registerAdvancedPrivacy($option_name, $title, $settings_slug, $conditions) { + if (media_cloud_licensing()->is_plan('pro')) { + add_settings_field($option_name, + $title, + [$this,'renderAdvancedPrivacy'], + $this->options_page, + $settings_slug, + ['option' => $option_name, 'conditions' => $conditions]); + } + } + + /** + * Renders the select + * @param $args + * @throws \Freemius_Exception + */ + public function renderAdvancedPrivacy($args) { + if (media_cloud_licensing()->is_plan('pro')) { + echo View::render_view('base/fields/advanced-privacy', [ + 'name' => $args['option'], + 'conditions' => $args['conditions'] + ]); + } + } + + /** * Registers an option with a dropdown/select input * @param $option_name diff --git a/classes/Tools/Storage/CLI/StorageCommands.php b/classes/Tools/Storage/CLI/StorageCommands.php index eef0513e..66a5b806 100755 --- a/classes/Tools/Storage/CLI/StorageCommands.php +++ b/classes/Tools/Storage/CLI/StorageCommands.php @@ -19,7 +19,7 @@ use GuzzleHttp\Client ; use GuzzleHttp\Exception\ClientException ; use ILAB\MediaCloud\CLI\Command ; -use ILAB\MediaCloud\Storage\StorageSettings ; +use ILAB\MediaCloud\Storage\StorageGlobals ; use ILAB\MediaCloud\Tools\Browser\Tasks\ImportFromStorageTask ; use ILAB\MediaCloud\Tools\Integrations\PlugIns\Elementor\Tasks\UpdateElementorTask ; use ILAB\MediaCloud\Tools\Integrations\PlugIns\NextGenGallery\Tasks\MigrateNextGenTask ; diff --git a/classes/Tools/Storage/StorageTool.php b/classes/Tools/Storage/StorageTool.php index 88eb4283..23ebc96f 100755 --- a/classes/Tools/Storage/StorageTool.php +++ b/classes/Tools/Storage/StorageTool.php @@ -17,7 +17,7 @@ use ILAB\MediaCloud\Storage\StorageException ; use ILAB\MediaCloud\Storage\StorageInterface ; use ILAB\MediaCloud\Storage\StorageManager ; -use ILAB\MediaCloud\Storage\StorageSettings ; +use ILAB\MediaCloud\Storage\StorageGlobals ; use ILAB\MediaCloud\Tasks\TaskManager ; use ILAB\MediaCloud\Tasks\TaskSchedule ; use ILAB\MediaCloud\Tools\Storage\Tasks\CleanUploadsTask ; @@ -30,6 +30,7 @@ use ILAB\MediaCloud\Utilities\Logging\Logger ; use ILAB\MediaCloud\Utilities\NoticeManager ; use ILAB\MediaCloud\Utilities\Prefixer ; +use function ILAB\MediaCloud\Utilities\typeFromMeta ; use ILAB\MediaCloud\Utilities\View ; use Smalot\PdfParser\Parser ; use function ILAB\MediaCloud\Utilities\arrayPath ; @@ -74,6 +75,11 @@ class StorageTool extends Tool /** @var null|array */ protected $allSizes = null ; private $disableSrcSet = false ; + private $replaceSrcSet = false ; + private $disableBigImageSize = false ; + private $uploadOriginal = true ; + /** @var array Already processed post IDs */ + private $processed = array() ; //endregion //region Constructor public function __construct( $toolName, $toolInfo, $toolManager ) @@ -116,10 +122,41 @@ public function __construct( $toolName, $toolInfo, $toolManager ) if ( !function_exists( 'wp_generate_attachment_metadata' ) ) { require_once ABSPATH . 'wp-admin/includes/image.php'; } + $this->disableBigImageSize = empty(Environment::Option( 'mcloud-storage-enable-big-size-threshold', null, true )); + $this->uploadOriginal = !empty(Environment::Option( 'mcloud-storage-big-size-upload-original', null, true )); if ( is_admin() ) { + if ( media_cloud_licensing()->is_plan( 'pro' ) ) { + add_filter( 'whitelist_options', function ( $options ) { + $options['ilab-media-s3'][] = 'mcloud-storage-privacy-images'; + $options['ilab-media-s3'][] = 'mcloud-storage-privacy-video'; + $options['ilab-media-s3'][] = 'mcloud-storage-privacy-audio'; + $options['ilab-media-s3'][] = 'mcloud-storage-privacy-docs'; + $options['ilab-media-s3'][] = 'mcloud-storage-use-presigned-urls-images'; + $options['ilab-media-s3'][] = 'mcloud-storage-use-presigned-urls-video'; + $options['ilab-media-s3'][] = 'mcloud-storage-use-presigned-urls-audio'; + $options['ilab-media-s3'][] = 'mcloud-storage-use-presigned-urls-docs'; + $options['ilab-media-s3'][] = 'mcloud-storage-presigned-expiration-images'; + $options['ilab-media-s3'][] = 'mcloud-storage-presigned-expiration-video'; + $options['ilab-media-s3'][] = 'mcloud-storage-presigned-expiration-audio'; + $options['ilab-media-s3'][] = 'mcloud-storage-presigned-expiration-docs'; + return $options; + } ); + } + + if ( $this->disableBigImageSize ) { + add_filter( 'big_image_size_threshold', '__return_false' ); + } else { + $threshold = (int) Environment::Option( 'mcloud-storage-big-size-threshold', null, 2560 ); + if ( $threshold !== 2560 ) { + add_filter( 'big_image_size_threshold', function () use( $threshold ) { + return $threshold; + }, PHP_INT_MAX ); + } + } - if ( StorageSettings::deleteOnUpload() ) { + + if ( StorageGlobals::deleteOnUpload() ) { add_filter( 'wp_die_ajax_handler', [ $this, 'hookDieHandler' ] ); add_filter( 'wp_die_json_handler', [ $this, 'hookDieHandler' ] ); add_filter( 'wp_die_jsonp_handler', [ $this, 'hookDieHandler' ] ); @@ -162,11 +199,21 @@ public function hasSettings() return true; } + public function hasWizard() + { + return true; + } + + public function wizardLink() + { + return admin_url( 'admin.php?page=media-cloud-wizard' ); + } + public function activate() { $provider = Environment::Option( 'mcloud-storage-provider', 'ILAB_CLOUD_STORAGE_PROVIDER', null ); if ( empty($provider) ) { - StorageSettings::migrateFromOtherPlugin(); + StorageGlobals::migrateFromOtherPlugin(); } } @@ -237,13 +284,30 @@ function ( $file, $type, $fullsize ) { if ( $this->usingImageOptimizer ) { $this->displayOptimizerAdminNotice(); } + global $wp_version ; $this->disableSrcSet = Environment::Option( 'mcloud-storage-disable-srcset', null, false ); - add_filter( - 'wp_update_attachment_metadata', - [ $this, 'handleUpdateAttachmentMetadata' ], - 1000, - 2 - ); + $this->replaceSrcSet = empty($this->disableSrcSet) && version_compare( $wp_version, '5.3', '>=' ); + if ( $this->replaceSrcSet ) { + $this->replaceSrcSet = Environment::Option( 'mcloud-storage-replace-srcset', null, true ); + } + global $wp_version ; + + if ( version_compare( $wp_version, '5.3', '>=' ) && (isset( $_REQUEST['action'] ) && $_REQUEST['action'] === 'upload-attachment') ) { + add_filter( + 'wp_update_attachment_metadata', + [ $this, 'handleUpdateAttachmentMetadataFor53' ], + 1000, + 2 + ); + } else { + add_filter( + 'wp_update_attachment_metadata', + [ $this, 'handleUpdateAttachmentMetadata' ], + 1000, + 2 + ); + } + add_filter( 'wp_handle_upload_prefilter', function ( $file ) { $addFilter = true; @@ -310,12 +374,30 @@ function ( $file, $type, $fullsize ) { ); add_action( 'add_attachment', [ $this, 'addAttachment' ], 1000 ); add_action( 'edit_attachment', [ $this, 'editAttachment' ] ); + add_filter( + 'the_content', + [ $this, 'fixGutenbergFigures' ], + PHP_INT_MAX - 2, + 1 + ); + add_filter( + 'the_content', + [ $this, 'filterGutenbergContent' ], + PHP_INT_MAX - 1, + 1 + ); add_filter( 'the_content', [ $this, 'filterContent' ], PHP_INT_MAX, 1 ); + add_filter( + 'render_block', + [ $this, 'filterBlocks' ], + PHP_INT_MAX, + 2 + ); add_filter( 'media-cloud/storage/process-file-name', function ( $filename ) { @@ -335,7 +417,7 @@ function ( $filename ) { add_filter( 'wp_image_editors', function ( $editors ) { array_unshift( $editors, '\\ILAB\\MediaCloud\\Tools\\Storage\\StorageImageEditor' ); return $editors; - } ); + }, PHP_INT_MAX ); } add_filter( 'wp_calculate_image_srcset', @@ -420,6 +502,37 @@ public function client() //endregion //region WordPress Upload/Attachment Hooks & Filters + public function handleUpdateAttachmentMetadataFor53( $data, $id ) + { + // Uploads are handled by a different method for non-images + if ( !wp_attachment_is_image( $id ) ) { + return $data; + } + // This means sizes haven't been generated yet. + if ( empty($data['sizes']) ) { + return $data; + } + // In 5.3 `wp_update_attachment_metadata` is called a few times, but we only want to handle the last time its called + // to prevent uploading stuff twice. + + if ( !in_array( $id, $this->processed ) ) { + $this->processed[] = $id; + return $data; + } + + // Now the goods + $data = $this->handleUpdateAttachmentMetadata( $data, $id ); + + if ( $this->uploadOriginal && isset( $data['original_image'] ) ) { + $s3Data = $this->uploadOriginalImage( $data, $id, $this->preserveFilePaths ); + if ( !empty($s3Data) ) { + $data['original_image_s3'] = $s3Data; + } + } + + return $data; + } + public function handleUpdateAttachmentMetadata( $data, $id ) { $ignoreOptimizers = apply_filters( 'media-cloud/storage/ignore-optimizers', false, $id ); @@ -433,6 +546,65 @@ public function handleUpdateAttachmentMetadata( $data, $id ) return $this->updateAttachmentMetadata( $data, $id, $this->preserveFilePaths ); } + /** + * Filter for when attachments are updated (https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/post.php#L5013) + * + * @param array $data + * @param integer $id + * @param string $preserveFilePaths + * @param bool $skipThumbnails + * + * @return array + */ + public function uploadOriginalImage( $data, $id, $preserveFilePaths = 'replace' ) + { + $path_base = pathinfo( $data['file'] )['dirname']; + if ( $path_base === '.' ) { + $path_base = ''; + } + $originalImage = trailingslashit( $path_base ) . $data['original_image']; + $mime = get_post_mime_type( $id ); + $upload_info = wp_upload_dir(); + $upload_path = $upload_info['basedir']; + $newData = [ + 'file' => $originalImage, + ]; + + if ( $preserveFilePaths === 'replace' ) { + $upload_path .= DIRECTORY_SEPARATOR . $path_base; + $newData['prefix'] = $path_base; + $newData['file'] = trim( str_replace( $path_base, '', $newData['file'] ), DIRECTORY_SEPARATOR ); + } + + if ( !file_exists( $upload_path . DIRECTORY_SEPARATOR . $newData['file'] ) ) { + return []; + } + if ( !$mime ) { + $mime = wp_get_image_mime( $upload_path . DIRECTORY_SEPARATOR . $newData['file'] ); + } + $newData['mime-type'] = $mime; + Prefixer::setType( $mime ); + + if ( $this->client && $this->client->enabled() ) { + Logger::info( "\tProcessing main file {$newData['file']}" ); + $privacy = Environment::Option( 'mcloud-storage-big-size-original-privacy', null, 'authenticated-read' ); + $doUpload = apply_filters( 'media-cloud/storage/upload-master', true ); + $newData = $this->processFile( + $upload_path, + $newData['file'], + $newData, + $id, + $preserveFilePaths, + $doUpload, + $privacy + ); + } + + Prefixer::setType( null ); + Prefixer::nextVersion(); + return ( isset( $newData['s3'] ) ? $newData['s3'] : [] ); + } + /** * Filter for when attachments are updated (https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/post.php#L5013) * @@ -521,7 +693,7 @@ public function updateAttachmentMetadata( $mime = wp_get_image_mime( $upload_path . DIRECTORY_SEPARATOR . $data['file'] ); } $ignoreMimeTypes = apply_filters( 'media-cloud/storage/ignore-mime-types', true ); - if ( $mime && $ignoreMimeTypes && StorageSettings::mimeTypeIsIgnored( $mime ) ) { + if ( $mime && $ignoreMimeTypes && StorageGlobals::mimeTypeIsIgnored( $mime ) ) { return $originalData; } Prefixer::setType( $mime ); @@ -633,7 +805,7 @@ public function updateAttachmentMetadata( */ public function deleteAttachment( $id ) { - if ( !StorageSettings::deleteFromStorage() ) { + if ( !StorageGlobals::deleteFromStorage() ) { return $id; } $data = wp_get_attachment_metadata( $id ); @@ -709,10 +881,10 @@ public function getUploadDir( $uploads ) if ( !empty($job_manager_upload) && !empty($job_manager_uploading_file) ) { return $uploads; } - if ( empty(StorageSettings::prefixFormat()) ) { + if ( empty(StorageGlobals::prefixFormat()) ) { return $uploads; } - $prefix = trim( StorageSettings::prefix( null ), '/' ); + $prefix = trim( StorageGlobals::prefix( null ), '/' ); if ( is_multisite() && !is_main_site() ) { @@ -785,7 +957,7 @@ public function handleUpload( $upload, $context = 'upload' ) return $upload; } $ignoreMimeTypes = apply_filters( 'media-cloud/storage/ignore-mime-types', true ); - if ( isset( $upload['type'] ) && $ignoreMimeTypes && StorageSettings::mimeTypeIsIgnored( $upload['type'] ) ) { + if ( isset( $upload['type'] ) && $ignoreMimeTypes && StorageGlobals::mimeTypeIsIgnored( $upload['type'] ) ) { return $upload; } if ( $this->fileIsDisplayableImage( $upload['file'] ) ) { @@ -844,8 +1016,8 @@ public function handleUpload( $upload, $context = 'upload' ) $upload = $this->processFile( $upload_path, $file, $upload ); if ( isset( $upload['s3'] ) ) { - if ( StorageSettings::docCdn() ) { - $upload['url'] = trim( StorageSettings::docCdn(), '/' ) . '/' . $file; + if ( StorageGlobals::docCdn() ) { + $upload['url'] = trim( StorageGlobals::docCdn(), '/' ) . '/' . $file; } else { if ( isset( $upload['s3']['url'] ) ) { $upload['url'] = $upload['s3']['url']; @@ -887,9 +1059,9 @@ public function getAttachedFile( $file, $attachment_id ) $new_url = $this->getAttachmentURLFromMeta( $meta ); } else { - if ( !$meta && StorageSettings::docCdn() ) { + if ( !$meta && StorageGlobals::docCdn() ) { $post = \WP_Post::get_instance( $attachment_id ); - if ( $post && strpos( $post->guid, StorageSettings::docCdn() ) === 0 ) { + if ( $post && strpos( $post->guid, StorageGlobals::docCdn() ) === 0 ) { $new_url = $post->guid; } } @@ -1063,7 +1235,7 @@ private function updateAttachmentS3Props( $id, $meta ) if ( isset( $_POST['s3-access-acl'] ) || isset( $_POST['s3-cache-control'] ) || isset( $_POST['s3-expires'] ) ) { $mime = get_post_mime_type( $id ); - $acl = ( isset( $meta['s3']['privacy'] ) ? $meta['s3']['privacy'] : StorageSettings::privacy() ); + $acl = ( isset( $meta['s3']['privacy'] ) ? $meta['s3']['privacy'] : StorageGlobals::privacy( $mime ) ); $acl = ( isset( $_POST['s3-access-acl'] ) ? $_POST['s3-access-acl'] : $acl ); $meta['s3']['privacy'] = $acl; $cacheControl = false; @@ -1154,7 +1326,7 @@ public function calculateSrcSet( if ( !apply_filters( 'media-cloud/storage/can-calculate-srcset', true ) ) { return $sources; } - if ( $this->disableSrcSet ) { + if ( $this->disableSrcSet || $this->replaceSrcSet ) { return []; } $attachment_id = apply_filters( @@ -1228,7 +1400,7 @@ public function prepareAttachmentForJS( $response, $attachment, $meta ) if ( isset( $meta['s3'] ) ) { $response['s3'] = $meta['s3']; if ( !isset( $response['s3']['privacy'] ) ) { - $response['s3']['privacy'] = StorageSettings::privacy(); + $response['s3']['privacy'] = StorageGlobals::privacy( $attachment->post_mime_type ); } } @@ -1277,6 +1449,28 @@ public function getThemeOptionURL( $url ) return $url; } + private function loadOffloadMetadata( $post_id ) + { + $offloadS3Info = get_post_meta( $post_id, 'amazonS3_info', true ); + if ( !empty($offloadS3Info) ) { + return $offloadS3Info; + } + $schemaVersion = get_option( 'as3cf_schema_version' ); + if ( empty($schemaVersion) ) { + return null; + } + if ( version_compare( $schemaVersion, '2.3', '<' ) ) { + return null; + } + global $wpdb ; + /** @var array|null $info */ + $info = $wpdb->get_row( "select * from {$wpdb->prefix}as3cf_items where source_id={$post_id}", ARRAY_A ); + if ( !empty($info) ) { + $info['key'] = $info['path']; + } + return $info; + } + /** * Filters the attachment's url. (https://core.trac.wordpress.org/browser/tags/4.8/src/wp-includes/post.php#L5077) * @@ -1304,7 +1498,7 @@ public function getAttachmentURL( $url, $post_id ) } if ( empty($new_url) ) { - $offloadS3Info = get_post_meta( $post_id, 'amazonS3_info', true ); + $offloadS3Info = $this->loadOffloadMetadata( $post_id ); if ( !empty($offloadS3Info) ) { $new_url = $this->importOffloadMetadata( $post_id, $meta, $offloadS3Info ); @@ -1318,9 +1512,9 @@ public function getAttachmentURL( $url, $post_id ) } - if ( !$meta && StorageSettings::docCdn() ) { + if ( !$meta && StorageGlobals::docCdn() ) { $post = \WP_Post::get_instance( $post_id ); - if ( $post && strpos( $post->guid, StorageSettings::docCdn() ) === 0 ) { + if ( $post && strpos( $post->guid, StorageGlobals::docCdn() ) === 0 ) { $new_url = $post->guid; } } @@ -1349,13 +1543,14 @@ public function getAttachmentURLFromMeta( $meta ) if ( empty($this->client) ) { return null; } + $type = typeFromMeta( $meta ); - if ( $this->client->usesSignedURLs() ) { - $url = $this->client->url( $meta['s3']['key'] ); + if ( $this->client->usesSignedURLs( $type ) ) { + $url = $this->client->url( $meta['s3']['key'], $type ); - if ( !empty(StorageSettings::cdn()) ) { - $cdnScheme = parse_url( StorageSettings::cdn(), PHP_URL_SCHEME ); - $cdnHost = parse_url( StorageSettings::cdn(), PHP_URL_HOST ); + if ( !empty(StorageGlobals::cdn()) ) { + $cdnScheme = parse_url( StorageGlobals::cdn(), PHP_URL_SCHEME ); + $cdnHost = parse_url( StorageGlobals::cdn(), PHP_URL_HOST ); $urlScheme = parse_url( $url, PHP_URL_SCHEME ); $urlHost = parse_url( $url, PHP_URL_HOST ); return str_replace( "{$urlScheme}://{$urlHost}", "{$cdnScheme}://{$cdnHost}", $url ); @@ -1365,13 +1560,13 @@ public function getAttachmentURLFromMeta( $meta ) } else { - if ( StorageSettings::cdn() ) { - return StorageSettings::cdn() . '/' . $meta['s3']['key']; + if ( StorageGlobals::cdn() ) { + return StorageGlobals::cdn() . '/' . $meta['s3']['key']; } else { if ( isset( $meta['s3']['url'] ) ) { - if ( isset( $meta['file'] ) && StorageSettings::docCdn() ) { + if ( isset( $meta['file'] ) && StorageGlobals::docCdn() ) { $ext = strtolower( pathinfo( $meta['file'], PATHINFO_EXTENSION ) ); $image_exts = array( 'jpg', @@ -1381,7 +1576,7 @@ public function getAttachmentURLFromMeta( $meta ) 'png' ); if ( !in_array( $ext, $image_exts ) ) { - return trim( StorageSettings::docCdn(), '/' ) . '/' . $meta['s3']['key']; + return trim( StorageGlobals::docCdn(), '/' ) . '/' . $meta['s3']['key']; } } @@ -1505,6 +1700,7 @@ private function importOffloadMetadata( $post_id, $meta, $offloadS3Data ) ), 'provider' => $provider, 'bucket' => $bucket, + 'key' => $key, 'privacy' => 'public-read', 'v' => MEDIA_CLOUD_INFO_VERSION, 'mime-type' => $mime, @@ -1601,6 +1797,209 @@ private function getOffloadS3URL( return null; } + /** + * Fixes Gutenberg's image block, why put the size on the f*cking
and not the ? + * + * @param $content + * + * @return mixed + */ + public function fixGutenbergFigures( $content ) + { + if ( !apply_filters( 'media-cloud/storage/fix-gutenberg-image-blocks', true ) ) { + return $content; + } + if ( preg_match_all( '/())/m', $content, $figures ) ) { + foreach ( $figures[0] as $figureMatch ) { + + if ( preg_match( '/]+)>/m', $figureMatch, $imageTagMatch ) ) { + + if ( preg_match( '/\\s+src=[\'"]([^\'"]+)[\'"]+/', $imageTagMatch[0], $srcs ) ) { + $newUrl = wp_get_attachment_image_src( $imageId, $size ); + + if ( !empty($newUrl) ) { + $newImage = str_replace( $srcs[0], " src=\"{$newUrl[0]}\"", $imageTagMatch[0] ); + $newFigure = str_replace( $imageTagMatch[0], $newImage, $figureMatch ); + $newFigure = str_replace( "wp-image-{$imageId}", "wp-image-{$imageId} mcloud-attachment-{$imageId}", $newFigure ); + $content = str_replace( $figureMatch, $newFigure, $content ); + } + + } + + } + } + + } + + } + } + return $content; + } + + /** + * Filter the content for the blocks we've already processed + * @param $content + * + * @return mixed + * @throws StorageException + */ + public function filterGutenbergContent( $content ) + { + if ( !apply_filters( 'media-cloud/storage/can-filter-content', true ) ) { + return $content; + } + $replacements = []; + //Filter Anchors + if ( preg_match_all( '/]+>/m', $content, $anchors ) ) { + foreach ( $anchors[0] as $anchor ) { + + if ( preg_match( '/mcloud-attachment-([0-9]+)/', $anchor, $attachmentId ) ) { + $id = $attachmentId[1]; + + if ( preg_match( '/href\\s*=\\s*"([^"]+)"/', $anchor, $hrefs ) ) { + $newUrl = wp_get_attachment_url( $id ); + if ( $newUrl !== $hrefs[1] ) { + $content = str_replace( $hrefs[1], $newUrl, $content ); + } + } + + } + + } + } + //Filter Audio or Video Tags + if ( preg_match_all( '/<(?:audio|video)\\s+[^>]+>/m', $content, $audioTags ) ) { + foreach ( $audioTags[0] as $audioTag ) { + + if ( preg_match( '/mcloud-attachment-([0-9]+)/', $audioTag, $attachmentId ) ) { + $id = $attachmentId[1]; + + if ( preg_match( '/src\\s*=\\s*"([^"]+)"/', $audioTag, $srcs ) ) { + $newUrl = wp_get_attachment_url( $id ); + if ( $newUrl !== $srcs[1] ) { + $content = str_replace( $srcs[1], $newUrl, $content ); + } + } + + } + + } + } + // Filter Cover Images + if ( preg_match_all( '/]+)wp-block-cover(?:[^>]+)>/m', $content, $coverImages ) ) { + foreach ( $coverImages[0] as $coverImage ) { + if ( strpos( $coverImage, 'background-image' ) === false ) { + continue; + } + + if ( preg_match( '/mcloud-attachment-([0-9]+)/', $coverImage, $attachmentId ) ) { + $id = $attachmentId[1]; + + if ( preg_match( '/background-image:url\\(([^)]+)\\)/', $coverImage, $backgroundUrl ) ) { + $newUrl = wp_get_attachment_url( $id ); + if ( $backgroundUrl[1] === $newUrl ) { + continue; + } + $newCoverImage = str_replace( $backgroundUrl[1], $newUrl, $coverImage ); + $content = str_replace( $coverImage, $newCoverImage, $content ); + } + + } + + } + } + //Fix Galleries + $galleryAnchors = []; + $galleryImages = []; + preg_match_all( '/]*)blocks-gallery-item(?:[^>]+)>\\s*]*)>\\s*(]+>)\\s*<\\/figure>\\s*<\\/li>/m', $content, $galleryElements ); + + if ( count( $galleryElements ) === 2 && !empty($galleryElements[1]) ) { + $galleryImages = $galleryElements[1]; + } else { + preg_match_all( + '/]*)blocks-gallery-item(?:[^>]+)>\\s*]*)>\\s*(]+>)\\s*(]+>)\\s*<\\/a>\\s*<\\/figure>\\s*<\\/li>/m', + $content, + $galleryElements, + PREG_SET_ORDER, + 0 + ); + if ( !empty($galleryElements) ) { + foreach ( $galleryElements as $galleryElement ) { + $galleryAnchors[] = $galleryElement[1]; + $galleryImages[] = $galleryElement[2]; + } + } + } + + + if ( !empty($galleryImages) || !empty($galleryAnchors) ) { + $attachmentIds = []; + foreach ( $galleryImages as $galleryImage ) { + + if ( preg_match( '/data-id\\s*=\\s*[\'"]+([0-9]+)/', $galleryImage, $attachmentId ) ) { + $id = $attachmentId[1]; + $attachmentIds[] = $id; + + if ( preg_match( '/data-full-url\\s*=\\s*["\']([^\'"]+)/m', $galleryImage, $fullUrl ) ) { + $newUrl = wp_get_attachment_image_src( $id, 'full' ); + + if ( !empty($newUrl) && $fullUrl[1] !== $newUrl[0] ) { + $newGalleryImage = str_replace( $fullUrl[0], "data-full-url=\"{$newUrl[0]}\"", $galleryImage ); + + if ( preg_match( '/\\s+src\\s*=\\s*["\']([^\'"]+)/m', $newGalleryImage, $srcs ) ) { + $newUrl = wp_get_attachment_image_src( $id, 'large' ); + + if ( !empty($newUrl) && $srcs[1] !== $newUrl[0] ) { + $newGalleryImage = str_replace( $srcs[0], " src=\"{$newUrl[0]}\"", $newGalleryImage ); + $newGalleryImage = str_replace( 'class="', "class=\"mcloud-attachment-{$id} ", $newGalleryImage ); + $content = str_replace( $galleryImage, $newGalleryImage, $content ); + } + + } + + } + + } + + } + + } + $anchorIndex = 0; + foreach ( $galleryAnchors as $galleryAnchor ) { + + if ( strpos( $galleryAnchor, 'attachment-link' ) !== false ) { + $anchorIndex++; + continue; + } + + if ( strpos( $galleryAnchor, 'media-link' ) !== false ) { + if ( preg_match( '/\\s+href\\s*=\\s*["\']([^\'"]+)/m', $galleryAnchor, $srcs ) ) { + + if ( $anchorIndex < count( $attachmentIds ) ) { + $id = $attachmentIds[$anchorIndex]; + $newUrl = wp_get_attachment_image_src( $id, 'full' ); + + if ( !empty($newUrl) && $srcs[1] !== $newUrl[0] ) { + $newGalleryAnchor = str_replace( $srcs[0], " href=\"{$newUrl[0]}\"", $galleryAnchor ); + $content = str_replace( $galleryAnchor, $newGalleryAnchor, $content ); + } + + } + + } + } + $anchorIndex++; + } + } + + return $content; + } + /** * Filter the content to replace CDN * @param $content @@ -1621,7 +2020,7 @@ public function filterContent( $content ) $resizedReplacements = []; foreach ( $matches[0] as $image ) { $imageFound = false; - if ( !preg_match( "#src=['\"]+([^'\"]+)['\"]+#", $image, $srcMatches ) ) { + if ( !preg_match( "#src=['\"]+([^'\"]+)['\"]+#", $image, $srcMatches ) || strpos( $image, 'mcloud-attachment-' ) !== false ) { continue; } $src = $srcMatches[1]; @@ -1689,8 +2088,9 @@ public function filterContent( $content ) if ( !empty($id) && is_numeric( $id ) ) { $imageFound = true; $replacements[$id] = [ - 'src' => $src, - 'size' => $size, + 'image' => $image, + 'src' => $src, + 'size' => $size, ]; } @@ -1721,14 +2121,16 @@ public function filterContent( $content ) if ( !empty($textSize) ) { $resizedReplacements[$id . '-' . $textSize] = [ - 'id' => $id, - 'src' => $matchedUrl, - 'size' => $size, + 'id' => $id, + 'image' => $image, + 'src' => $matchedUrl, + 'size' => $size, ]; } else { $replacements[$id] = [ - 'src' => $matchedUrl, - 'size' => $size, + 'image' => $image, + 'src' => $matchedUrl, + 'size' => $size, ]; } @@ -1748,6 +2150,128 @@ public function filterContent( $content ) return $content; } + private function generateSrcSet( $id, $sizeName ) + { + if ( $this->allSizes == null ) { + $this->allSizes = ilab_get_image_sizes(); + } + if ( $sizeName !== 'full' && !isset( $this->allSizes[$sizeName] ) ) { + return ''; + } + $meta = wp_get_attachment_metadata( $id ); + $w = ( empty($meta['width']) ? (int) 0 : (int) $meta['width'] ); + $h = ( empty($meta['height']) ? (int) 0 : (int) $meta['height'] ); + if ( !isset( $meta['sizes'] ) || empty($w) || empty($h) ) { + return ''; + } + + if ( $sizeName === 'full' ) { + $size = [ + 'width' => $w, + 'height' => $h, + 'crop' => false, + ]; + } else { + $size = $this->allSizes[$sizeName]; + } + + $cropped = !empty($size['crop']); + $sw = ( empty($size['width']) ? (int) 0 : (int) $size['width'] ); + $sh = ( empty($size['height']) ? (int) 0 : (int) $size['height'] ); + if ( $cropped && (empty($sw) || empty($sh)) ) { + return ''; + } + + if ( $cropped ) { + $filteredSizes = array_filter( $this->allSizes, function ( $v, $k ) use( $meta, $sw, $sh ) { + if ( empty($v['crop']) ) { + return false; + } + $nsw = ( empty($v['width']) ? (int) 0 : (int) $v['width'] ); + $nsh = ( empty($v['height']) ? (int) 0 : (int) $v['height'] ); + if ( empty($nsw) || empty($nsh) ) { + return false; + } + $nratio = floor( $nsw / $nsh * 10 ); + $sratio = floor( $sw / $sh * 10 ); + return ($k === 'full' || isset( $meta['sizes'][$k] )) && $nratio === $sratio && $nsw <= $sw; + }, ARRAY_FILTER_USE_BOTH ); + } else { + $currentSize = sizeToFitSize( + $w, + $h, + $sw, + $sh + ); + $filteredSizes = array_filter( $this->allSizes, function ( $v, $k ) use( + $meta, + $currentSize, + $w, + $h, + $sw, + $sh + ) { + $nsw = ( empty($v['width']) ? (int) 0 : (int) $v['width'] ); + $nsh = ( empty($v['height']) ? (int) 0 : (int) $v['height'] ); + if ( $nsw === 0 ) { + $nsw = 100000; + } + if ( $nsh === 0 ) { + $nsh = 100000; + } + $newSize = sizeToFitSize( + $w, + $h, + $nsw, + $nsh + ); + return ($k === 'full' || isset( $meta['sizes'][$k] )) && empty($v['crop']) && $newSize[0] <= $currentSize[0] && $newSize[1] <= $currentSize[1]; + }, ARRAY_FILTER_USE_BOTH ); + } + + $sortedFilteredSizes = $filteredSizes; + uksort( $sortedFilteredSizes, function ( $a, $b ) use( $meta ) { + $aw = (int) $meta['sizes'][$a]['width']; + $bw = (int) $meta['sizes'][$b]['width']; + if ( $aw === $bw ) { + return 0; + } + return ( $aw < $bw ? -1 : 1 ); + } ); + if ( $sizeName === 'full' ) { + $sortedFilteredSizes['full'] = $size; + } + if ( count( $sortedFilteredSizes ) <= 1 ) { + return ''; + } + $sources = []; + foreach ( $sortedFilteredSizes as $name => $sizeInfo ) { + $csize = ( $name === 'full' ? $size : $meta['sizes'][$name] ); + $sw = (int) $csize['width']; + + if ( $name != $sizeName ) { + $sizeKey = "(max-width: {$sw}px) {$sw}px"; + } else { + $sizeKey = "100vw"; + } + + $src = wp_get_attachment_image_src( $id, $name ); + if ( !empty($src) ) { + $sources[$sizeKey] = $src[0] . " {$sw}w"; + } + } + + if ( !empty($sources) ) { + $sizes = "(max-width: {$sw}px) 100vw, {$sw}px"; + //implode(', ', array_keys($sources)); + $srcset = implode( ', ', array_values( $sources ) ); + $generated = "srcset='{$srcset}' sizes='{$sizes}'"; + return $generated; + } + + return ''; + } + private function replaceImageInContent( $id, $data, $content ) { $id = apply_filters( @@ -1760,8 +2284,10 @@ private function replaceImageInContent( $id, $data, $content ) if ( empty($data['size']) ) { $meta = wp_get_attachment_metadata( $id ); $url = $this->getAttachmentURLFromMeta( $meta ); + $srcSet = ''; } else { $url = image_downsize( $id, $data['size'] ); + $srcSet = ( empty($data['image']) ? '' : $this->generateSrcSet( $id, $data['size'] ) ); } @@ -1780,9 +2306,20 @@ private function replaceImageInContent( $id, $data, $content ) $url = $url[0]; } $url = preg_replace( '/&lang=[aA-zZ0-9]+/m', '', $url ); - if ( empty($url) || $url == $data['src'] ) { + if ( empty($url) || $url == $data['src'] && empty($srcSet) ) { return $content; } + + if ( !empty($data['image']) && $this->replaceSrcSet ) { + $image = $data['image']; + $image = preg_replace( '/(sizes\\s*=\\s*[\'"]{1}(?:[^\'"]*)[\'"]{1})/m', '', $image ); + $image = preg_replace( '/(srcset\\s*=\\s*[\'"]{1}(?:[^\'"]*)[\'"]{1})/m', '', $image ); + if ( !empty($srcSet) ) { + $image = str_replace( ']*)>/m', + $block_content, + $anchors, + PREG_SET_ORDER, + 0 + ) ) { + foreach ( $anchors as $anchor ) { + + if ( preg_match( '/class\\s*=\\s*"([^"]*)\\"/', $anchor[0], $class ) ) { + $newAnchor = str_replace( $class[1], "{$class[1]} mcloud-attachment-{$id}", $anchor[0] ); + } else { + $newAnchor = str_replace( ">", " class=\"mcloud-attachment-{$id}\">", $anchor[0] ); + } + + $block_content = str_replace( $anchor[0], $newAnchor, $block_content ); + } + } + return $block_content; + } + + private function processAudioBlock( $id, $block_content ) + { + if ( preg_match_all( + '/]*)>/m', + $block_content, + $audioTags, + PREG_SET_ORDER, + 0 + ) ) { + foreach ( $audioTags as $audioTag ) { + + if ( preg_match( '/class\\s*=\\s*"([^"]*)\\"/', $audioTag[0], $class ) ) { + $newAudioTag = str_replace( $class[1], "{$class[1]} mcloud-attachment-{$id}", $audioTag[0] ); + } else { + $newAudioTag = str_replace( ">", " class=\"mcloud-attachment-{$id}\">", $audioTag[0] ); + } + + + if ( preg_match( '/src\\s*=\\s*"(.*)\\"/', $audioTag[0], $source ) ) { + $newUrl = wp_get_attachment_url( $id ); + $newAudioTag = str_replace( $source[1], $newUrl, $newAudioTag ); + } + + $block_content = str_replace( $audioTag[0], $newAudioTag, $block_content ); + } + } + return $block_content; + } + + private function processVideoBlock( $id, $block_content ) + { + if ( preg_match_all( + '/]*)>/m', + $block_content, + $videoTags, + PREG_SET_ORDER, + 0 + ) ) { + foreach ( $videoTags as $videoTag ) { + + if ( preg_match( '/class\\s*=\\s*"([^"]*)\\"/', $videoTag[0], $class ) ) { + $newVideoTag = str_replace( $class[1], "{$class[1]} mcloud-attachment-{$id}", $videoTag[0] ); + } else { + $newVideoTag = str_replace( ">", " class=\"mcloud-attachment-{$id}\">", $videoTag[0] ); + } + + + if ( preg_match( '/src\\s*=\\s*"(.*)\\"/', $videoTag[0], $source ) ) { + $newUrl = wp_get_attachment_url( $id ); + $newVideoTag = str_replace( $source[1], $newUrl, $newVideoTag ); + } + + $block_content = str_replace( $videoTag[0], $newVideoTag, $block_content ); + } + } + return $block_content; + } + + private function processCoverBlock( $id, $block_content ) + { + if ( preg_match_all( + '/class\\s*=\\s*"([^"]*)/m', + $block_content, + $classes, + PREG_SET_ORDER, + 0 + ) ) { + foreach ( $classes as $class ) { + if ( strpos( $class[1], 'inner_container' ) !== false ) { + continue; + } + if ( strpos( $class[1], 'wp-block-cover' ) === false ) { + continue; + } + $block_content = str_replace( $class[1], "{$class[1]} mcloud-attachment-{$id}", $block_content ); + } + } + return $block_content; + } + + private function processGallery( $linkType, $block_content ) + { + if ( preg_match_all( '/]+)>/m', $block_content, $anchors ) ) { + foreach ( $anchors[0] as $anchor ) { + + if ( strpos( 'class=', $anchor ) === false ) { + $newAnchor = str_replace( 'processFileBlock( $id, $block_content ); + } else { + + if ( $block['blockName'] === 'core/audio' ) { + $block_content = $this->processAudioBlock( $id, $block_content ); + } else { + + if ( $block['blockName'] === 'core/video' ) { + $block_content = $this->processVideoBlock( $id, $block_content ); + } else { + if ( $block['blockName'] === 'core/cover' ) { + $block_content = $this->processCoverBlock( $id, $block_content ); + } + } + + } + + } + + } else { + + if ( $block['blockName'] === 'core/gallery' ) { + $linkTo = arrayPath( $block, 'attrs/linkTo' ); + if ( !empty($linkTo) ) { + $block_content = $this->processGallery( $linkTo, $block_content ); + } + } + + } + + } + + return $block_content; + } + //endregion //region Crop Tool Related /** @@ -1857,7 +2568,8 @@ public function processFile( $data, $id = null, $preserveFilePath = 'replace', - $uploadFile = true + $uploadFile = true, + $forcedAcl = null ) { @@ -1876,7 +2588,7 @@ public function processFile( } $shouldUseCustomPrefix = apply_filters( 'media-cloud/storage/should-use-custom-prefix', true ); - $shouldUseCustomPrefix = !empty(StorageSettings::prefixFormat()) && $shouldUseCustomPrefix; + $shouldUseCustomPrefix = !empty(StorageGlobals::prefixFormat()) && $shouldUseCustomPrefix; if ( $preserveFilePath == 'replace' ) { @@ -1891,7 +2603,7 @@ public function processFile( } } else { - $prefix = trailingslashit( StorageSettings::prefix( $id ) ); + $prefix = trailingslashit( StorageGlobals::prefix( $id ) ); } } else { @@ -1915,7 +2627,7 @@ public function processFile( $prefix = trailingslashit( str_replace( $bn, '', $filename ) ); } - $prefix = trailingslashit( StorageSettings::prefix( $id ) ) . $prefix; + $prefix = trailingslashit( StorageGlobals::prefix( $id ) ) . $prefix; } } @@ -1943,15 +2655,20 @@ public function processFile( } + $uploadType = typeFromMeta( $data ); + $privacy = StorageGlobals::privacy( $uploadType ); + if ( !empty($forcedAcl) ) { + $privacy = $forcedAcl; + } if ( $uploadFile || empty($url) ) { Logger::info( "\tUploading {$filename} to S3." ); $url = $this->client->upload( $prefix . $bucketFilename, $upload_path . '/' . $filename, - StorageSettings::privacy(), - StorageSettings::cacheControl(), - StorageSettings::expires() + $privacy, + StorageGlobals::cacheControl(), + StorageGlobals::expires() ); Logger::info( "\tFinished uploading {$filename} to S3." ); } else { @@ -1975,13 +2692,13 @@ public function processFile( $this->client->upload( $prefix . $webpBasename, $webpPath, - StorageSettings::privacy(), - StorageSettings::cacheControl(), - StorageSettings::expires(), + $privacy, + StorageGlobals::cacheControl(), + StorageGlobals::expires(), 'image/webp' ); - if ( StorageSettings::deleteOnUpload() ) { + if ( StorageGlobals::deleteOnUpload() ) { $this->deleteCache[] = $webpPath; // unlink($webpPath); } @@ -1992,11 +2709,11 @@ public function processFile( $options = []; $params = []; - if ( !empty(StorageSettings::cacheControl()) ) { - $params['CacheControl'] = StorageSettings::cacheControl(); + if ( !empty(StorageGlobals::cacheControl()) ) { + $params['CacheControl'] = StorageGlobals::cacheControl(); } - if ( !empty(StorageSettings::expires()) ) { - $params['Expires'] = StorageSettings::expires(); + if ( !empty(StorageGlobals::expires()) ) { + $params['Expires'] = StorageGlobals::expires(); } if ( !empty($params) ) { $options['params'] = $params; @@ -2006,7 +2723,7 @@ public function processFile( $data['s3'] = [ 'url' => $url, 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => $privacy, 'key' => $prefix . $bucketFilename, 'provider' => $providerId, 'v' => MEDIA_CLOUD_INFO_VERSION, @@ -2025,7 +2742,7 @@ public function processFile( 'exception' => $ex->getMessage(), 'prefix' => $prefix, 'bucketFilename' => $bucketFilename, - 'privacy' => StorageSettings::privacy(), + 'privacy' => $privacy, ] ); } @@ -2051,7 +2768,7 @@ public function processFile( } - if ( StorageSettings::deleteOnUpload() ) { + if ( StorageGlobals::deleteOnUpload() ) { if ( file_exists( $upload_path . '/' . $filename ) ) { $fileToDelete = $upload_path . '/' . $filename; @@ -2076,7 +2793,7 @@ public function cleanUploads( $message, $title = '', $args = array() ) if ( count( $this->deleteCache ) > 0 ) { Logger::info( "Cleaning uploads ..." ); - if ( StorageSettings::queuedDeletes() ) { + if ( StorageGlobals::queuedDeletes() ) { $task = TaskSchedule::nextScheduledTaskOfType( DeleteUploadsTask::identifier() ); if ( !empty($task) ) { @@ -2870,16 +3587,16 @@ public function processImport( */ public function uploadUrlForFile( $filename ) { - $prefix = StorageSettings::prefix( null ); + $prefix = StorageGlobals::prefix( null ); $parts = explode( '/', $filename ); $bucketFilename = array_pop( $parts ); if ( $this->client && $this->client->enabled() ) { try { return $this->client->uploadUrl( $prefix . $bucketFilename, - StorageSettings::privacy(), - StorageSettings::cacheControl(), - StorageSettings::expires() + StorageGlobals::privacy(), + StorageGlobals::cacheControl(), + StorageGlobals::expires() ); } catch ( StorageException $ex ) { Logger::error( 'Generate File Upload URL Error', [ @@ -2907,7 +3624,7 @@ public function importImageAttachmentFromStorage( $fileInfo, $thumbs = array() ) if ( !is_array( $fileInfo->size() ) ) { return null; } - $this->client->insureACL( $fileInfo->key(), StorageSettings::privacy() ); + $this->client->insureACL( $fileInfo->key(), StorageGlobals::privacy( $fileInfo->mimeType() ) ); $fileParts = explode( '/', $fileInfo->key() ); $filename = array_pop( $fileParts ); $url = $this->client->url( $fileInfo->key() ); @@ -2915,18 +3632,18 @@ public function importImageAttachmentFromStorage( $fileInfo, $thumbs = array() ) 'url' => $url, 'mime-type' => $fileInfo->mimeType(), 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => StorageGlobals::privacy( $fileInfo->mimeType() ), 'key' => $fileInfo->key(), 'v' => MEDIA_CLOUD_INFO_VERSION, 'options' => [ 'params' => [], ], ]; - if ( !empty(StorageSettings::cacheControl()) ) { - $s3Info['options']['params']['CacheControl'] = StorageSettings::cacheControl(); + if ( !empty(StorageGlobals::cacheControl()) ) { + $s3Info['options']['params']['CacheControl'] = StorageGlobals::cacheControl(); } - if ( !empty(StorageSettings::expires()) ) { - $s3Info['options']['params']['Expires'] = StorageSettings::expires(); + if ( !empty(StorageGlobals::expires()) ) { + $s3Info['options']['params']['Expires'] = StorageGlobals::expires(); } $meta = [ 'width' => $fileInfo->size()[0], @@ -3060,18 +3777,18 @@ public function importExistingAttachmentFromStorage( $postId, $fileInfo, $thumbs 'url' => $url, 'mime-type' => $fileInfo->mimeType(), 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => StorageGlobals::privacy( $fileInfo->mimeType() ), 'key' => $fileInfo->key(), 'v' => MEDIA_CLOUD_INFO_VERSION, 'options' => [ 'params' => [], ], ]; - if ( !empty(StorageSettings::cacheControl()) ) { - $s3Info['options']['params']['CacheControl'] = StorageSettings::cacheControl(); + if ( !empty(StorageGlobals::cacheControl()) ) { + $s3Info['options']['params']['CacheControl'] = StorageGlobals::cacheControl(); } - if ( !empty(StorageSettings::expires()) ) { - $s3Info['options']['params']['Expires'] = StorageSettings::expires(); + if ( !empty(StorageGlobals::expires()) ) { + $s3Info['options']['params']['Expires'] = StorageGlobals::expires(); } $meta = wp_get_attachment_metadata( $postId, true ); $meta['s3'] = $s3Info; @@ -3106,18 +3823,18 @@ public function importExistingImageAttachmentFromStorage( $postId, $fileInfo, $t 'url' => $url, 'mime-type' => $fileInfo->mimeType(), 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => StorageGlobals::privacy( $fileInfo->mimeType() ), 'key' => $fileInfo->key(), 'v' => MEDIA_CLOUD_INFO_VERSION, 'options' => [ 'params' => [], ], ]; - if ( !empty(StorageSettings::cacheControl()) ) { - $s3Info['options']['params']['CacheControl'] = StorageSettings::cacheControl(); + if ( !empty(StorageGlobals::cacheControl()) ) { + $s3Info['options']['params']['CacheControl'] = StorageGlobals::cacheControl(); } - if ( !empty(StorageSettings::expires()) ) { - $s3Info['options']['params']['Expires'] = StorageSettings::expires(); + if ( !empty(StorageGlobals::expires()) ) { + $s3Info['options']['params']['Expires'] = StorageGlobals::expires(); } $meta = wp_get_attachment_metadata( $postId, true ); $meta['s3'] = $s3Info; @@ -3205,7 +3922,7 @@ public function importAttachmentFromStorage( $fileInfo, $thumbs = array() ) if ( $fileInfo->mimeType() && strpos( $fileInfo->mimeType(), 'image/' ) === 0 ) { return $this->importImageAttachmentFromStorage( $fileInfo, $thumbs ); } - $this->client->insureACL( $fileInfo->key(), StorageSettings::privacy() ); + $this->client->insureACL( $fileInfo->key(), StorageGlobals::privacy( $fileInfo->mimeType() ) ); $fileParts = explode( '/', $fileInfo->key() ); $filename = array_pop( $fileParts ); $url = $this->client->url( $fileInfo->key() ); @@ -3213,18 +3930,18 @@ public function importAttachmentFromStorage( $fileInfo, $thumbs = array() ) 'url' => $url, 'mime-type' => $fileInfo->mimeType(), 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => StorageGlobals::privacy( $fileInfo->mimeType() ), 'key' => $fileInfo->key(), 'v' => MEDIA_CLOUD_INFO_VERSION, 'options' => [ 'params' => [], ], ]; - if ( !empty(StorageSettings::cacheControl()) ) { - $s3Info['options']['params']['CacheControl'] = StorageSettings::cacheControl(); + if ( !empty(StorageGlobals::cacheControl()) ) { + $s3Info['options']['params']['CacheControl'] = StorageGlobals::cacheControl(); } - if ( !empty(StorageSettings::expires()) ) { - $s3Info['options']['params']['Expires'] = StorageSettings::expires(); + if ( !empty(StorageGlobals::expires()) ) { + $s3Info['options']['params']['Expires'] = StorageGlobals::expires(); } $meta = [ 'file' => $fileInfo->key(), @@ -3478,6 +4195,7 @@ private function doImportFile( $key, $thumbs ) if ( empty($postId) ) { $filetype = wp_check_filetype( basename( $destFile ), null ); + $mimeType = $filetype['type']; $attachment = [ 'guid' => $desturl, 'post_mime_type' => $filetype['type'], @@ -3497,6 +4215,7 @@ private function doImportFile( $key, $thumbs ) unset( $meta['sizes'][$size] ); } } + $mimeType = typeFromMeta( $meta ); } @@ -3519,7 +4238,7 @@ private function doImportFile( $key, $thumbs ) $meta['sizes'] = []; $s3Info = [ 'bucket' => $this->client->bucket(), - 'privacy' => StorageSettings::privacy(), + 'privacy' => StorageGlobals::privacy( $mimeType ), 'v' => MEDIA_CLOUD_INFO_VERSION, 'options' => [ 'params' => [], diff --git a/classes/Tools/Storage/Tasks/CleanUploadsTask.php b/classes/Tools/Storage/Tasks/CleanUploadsTask.php index 67041e3f..f37ff1b2 100755 --- a/classes/Tools/Storage/Tasks/CleanUploadsTask.php +++ b/classes/Tools/Storage/Tasks/CleanUploadsTask.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\Storage\Tasks; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tasks\AttachmentTask; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\ToolsManager; diff --git a/classes/Tools/Storage/Tasks/DeleteUploadsTask.php b/classes/Tools/Storage/Tasks/DeleteUploadsTask.php index e0cf37a0..83ef72c6 100755 --- a/classes/Tools/Storage/Tasks/DeleteUploadsTask.php +++ b/classes/Tools/Storage/Tasks/DeleteUploadsTask.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\Storage\Tasks; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tasks\AttachmentTask; use ILAB\MediaCloud\Tasks\Task; use ILAB\MediaCloud\Tools\Storage\StorageTool; diff --git a/classes/Tools/Storage/Tasks/UnlinkTask.php b/classes/Tools/Storage/Tasks/UnlinkTask.php index 5e3621e2..59be8833 100755 --- a/classes/Tools/Storage/Tasks/UnlinkTask.php +++ b/classes/Tools/Storage/Tasks/UnlinkTask.php @@ -13,7 +13,7 @@ namespace ILAB\MediaCloud\Tools\Storage\Tasks; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Tasks\AttachmentTask; use ILAB\MediaCloud\Tools\Storage\StorageTool; use ILAB\MediaCloud\Tools\ToolsManager; diff --git a/classes/Tools/Tool.php b/classes/Tools/Tool.php index 32d59aef..2d062f2b 100755 --- a/classes/Tools/Tool.php +++ b/classes/Tools/Tool.php @@ -16,7 +16,7 @@ namespace ILAB\MediaCloud\Tools; -use ILAB\MediaCloud\Storage\StorageSettings; +use ILAB\MediaCloud\Storage\StorageGlobals; use ILAB\MediaCloud\Utilities\Environment; use ILAB\MediaCloud\Utilities\NoticeManager; use function ILAB\MediaCloud\Utilities\arrayPath; @@ -282,6 +282,24 @@ public function hasSettings() { return false; } + + /** + * Determines if the tool has a setup wizard + * @return bool + */ + public function hasWizard() { + return false; + } + + + /** + * The URL for the wizard + * @return bool + */ + public function wizardLink() { + return false; + } + /** * Determines if this tool installs, or wants to install, items in the admin menu bar * @return bool @@ -404,6 +422,8 @@ public function registerSettings() { }, 10, 3); } + global $wp_version; + $groups=$this->toolInfo['settings']['groups']; foreach($groups as $group => $groupInfo) { $groupWatch = !empty($groupInfo['watch']); @@ -411,6 +431,25 @@ public function registerSettings() { $this->registerSettingsSection($group, $groupInfo['title'], arrayPath($groupInfo, 'description', null)); if (isset($groupInfo['options'])) { foreach($groupInfo['options'] as $option => $optionInfo) { + if (isset($optionInfo['wp_version'])) { + $comparison = $optionInfo['wp_version']; + if (!version_compare($wp_version, $comparison[1], $comparison[0])) { + continue; + } + } + + if (!empty($optionInfo['multisite'])) { + if (!is_multisite()) { + continue; + } + } + + if (!empty($optionInfo['plan'])) { + if (!media_cloud_licensing()->is_plan($optionInfo['plan'])) { + continue; + } + } + $optionWatch = !empty($optionInfo['watch']); $this->registerSetting($option); @@ -455,7 +494,7 @@ public function registerSettings() { $this->registerNumberFieldSetting($option,$optionInfo['title'],$group,$description, $default, $conditions, $min, $max, $increment); break; case 'select': - $this->registerSelectSetting($option,$optionInfo['options'],$optionInfo['title'],$group,$description, $conditions); + $this->registerSelectSetting($option, $optionInfo['options'], $optionInfo['title'], $group, isset($optionInfo['default']) ? $optionInfo['default'] : null, $description, $conditions); break; case 'dynamic-select': $this->registerDynamicSelectSetting($option,$optionInfo['options'],$optionInfo['title'],$group,$description, $conditions); @@ -466,6 +505,12 @@ public function registerSettings() { case 'sites': $this->registerSiteSelectSetting($option,$optionInfo['title'],$group,$description, $conditions); break; + case 'advanced-presigned': + $this->registerAdvancedPresignedURLs($option, $optionInfo['title'], $group, $conditions); + break; + case 'advanced-privacy': + $this->registerAdvancedPrivacy($option, $optionInfo['title'], $group, $conditions); + break; } } } diff --git a/classes/Tools/ToolSettings.php b/classes/Tools/ToolSettings.php index 06904b45..b986008c 100755 --- a/classes/Tools/ToolSettings.php +++ b/classes/Tools/ToolSettings.php @@ -79,8 +79,7 @@ public function __get($name) { } $this->settings[$name] = $val = Environment::Option($setting, $envSetting, $default); - Logger::info("SETTINGS $name = $val"); - return $val; + return $val; } /** diff --git a/classes/Tools/ToolsManager.php b/classes/Tools/ToolsManager.php index eb0468df..5d196ced 100755 --- a/classes/Tools/ToolsManager.php +++ b/classes/Tools/ToolsManager.php @@ -21,6 +21,7 @@ use ILAB\MediaCloud\Utilities\View ; use function ILAB\MediaCloud\Utilities\arrayPath ; use function ILAB\MediaCloud\Utilities\json_response ; +use ILAB\MediaCloud\Wizard\SetupWizard ; if ( !defined( 'ABSPATH' ) ) { header( 'Location: /' ); @@ -59,6 +60,8 @@ final class ToolsManager private $multisiteTools = array() ; /** @var bool Determines if any media cloud settings have changed. */ private $settingsDidChange = false ; + /** @var SetupWizard|null */ + private $wizard = null ; //endregion //region Constructor public function __construct() @@ -182,7 +185,12 @@ public function __construct() wp_enqueue_script( 'mcloud-admin-js', ILAB_PUB_JS_URL . '/mcloud-admin.js', - [ 'jquery', 'wp-util' ], + [ + 'jquery', + 'wp-util', + 'wp-blocks', + 'wp-element' + ], MEDIA_CLOUD_VERSION, true ); @@ -197,6 +205,7 @@ public function __construct() } ); if ( is_admin() ) { + $this->wizard = new SetupWizard(); add_action( 'wp_ajax_ilab_pin_tool', function () { $this->handlePinTool(); } ); @@ -385,6 +394,7 @@ public function addMenus( $networkMode, $networkAdminMenu ) 'media-cloud', [ $this, 'renderFeatureSettings' ] ); + $this->wizard->registerMenu( 'media-cloud', $networkMode, $networkAdminMenu ); } else { add_menu_page( 'Settings', @@ -409,6 +419,7 @@ public function addMenus( $networkMode, $networkAdminMenu ) $this->networkTool = new NetworkTool( 'network', include ILAB_CONFIG_DIR . '/network.config.php', $this ); $this->networkTool->registerSettings(); $this->networkTool->registerMenu( 'media-cloud', true, true ); + $this->wizard->registerMenu( 'media-cloud', $networkMode, $networkAdminMenu ); } if ( $isLocal || $isNetworkModeAdmin ) { @@ -633,6 +644,9 @@ public static function activate() foreach ( static::instance()->tools as $key => $tool ) { $tool->activate(); } + if ( empty(Environment::Option( 'mcloud-tool-enabled-storage', null, false )) ) { + update_option( 'mcloud_show_wizard', true ); + } } /** @@ -715,6 +729,7 @@ public function updateNetworkOptions() $page_slug = $_POST['option_page']; check_admin_referer( $page_slug . '-options' ); global $new_whitelist_options ; + $new_whitelist_options = apply_filters( 'whitelist_options', $new_whitelist_options ); $options = $new_whitelist_options[$page_slug]; foreach ( $options as $option ) { diff --git a/classes/Utilities/Environment.php b/classes/Utilities/Environment.php index e8e78f92..b1d69c4e 100755 --- a/classes/Utilities/Environment.php +++ b/classes/Utilities/Environment.php @@ -121,6 +121,20 @@ public static function UpdateOption($optionName, $value) { } } + /** + * Replaces an option, returning the previous valus + * + * @param $optionName + * @param $value + * + * @return array|false|mixed|string|null + */ + public static function ReplaceOption($optionName, $value) { + $oldValue = static::Option($optionName); + static::UpdateOption($optionName, $value); + return $oldValue; + } + /** * Deletes an option, automatically updating for network if in network mode * @param $optionName diff --git a/classes/Utilities/Helpers.php b/classes/Utilities/Helpers.php index 734c873b..a3c9307c 100755 --- a/classes/Utilities/Helpers.php +++ b/classes/Utilities/Helpers.php @@ -169,6 +169,22 @@ function objectPath($object, $path, $default = null) { } } + /** + * Insures all items are not null + * @param array $set + * + * @return bool + */ + function anyNull(...$set) { + foreach($set as $item) { + if($item === null) { + return true; + } + } + + return false; + } + /** * Determines if a postIdExists * @@ -214,5 +230,35 @@ function phpMemoryLimit($default = '64M') { return intval($num); } + + /** + * Determines the mime type based on the metadata for an attachment + * + * @param $meta + * + * @return string|null + */ + function typeFromMeta($meta) { + if (isset($meta['sizes']) || isset($meta['image_meta'])) { + return 'image'; + } + + if (isset($meta['type'])) { + $typeParts = explode('/', $meta['type']); + return $typeParts[0]; + } + + if (isset($meta['mime-type'])) { + $typeParts = explode('/', $meta['mime-type']); + return $typeParts[0]; + } + + if (isset($meta['s3']) && isset($meta['s3']['mime-type'])) { + $typeParts = explode('/', $meta['s3']['mime-type']); + return $typeParts[0]; + } + + return null; + } } diff --git a/classes/Wizard/Config/Config.php b/classes/Wizard/Config/Config.php new file mode 100755 index 00000000..c4d59863 --- /dev/null +++ b/classes/Wizard/Config/Config.php @@ -0,0 +1,113 @@ +initialSection = arrayPath($config, 'initialSection', null); + $this->initialSectionHasSteps = arrayPath($config, 'hasSteps', false); + if (empty($this->initialSection)) { + throw new \Exception("Missing 'initialSection' in configuration."); + } + + $sections = arrayPath($config, 'sections', []); + foreach($sections as $sectionId => $section) { + $this->sections[$sectionId] = new Section($this, $sectionId, $section); + } + + if (!isset($this->sections[$this->initialSection])) { + throw new \Exception("'initialSection' is specified, but the related section is missing in the configuration."); + } + } + + /** + * @return Section[] + */ + public function sections() { + return $this->sections; + } + + /** + * @param $sectionName + * + * @return Section|null + */ + public function section($sectionName) { + return (isset($this->sections[$sectionName])) ? $this->sections[$sectionName] : null; + } + + /** + * @return string + */ + public function initialSectionName() { + return $this->initialSection; + } + + + /** + * @return bool + */ + public function initialSectionHasSteps() { + return $this->initialSectionHasSteps; + } + + /** + * @param $newInitialSection + * + * @throws \Exception + */ + public function setInitialSectionName($newInitialSection) { + if (!isset($this->sections[$newInitialSection])) { + throw new \Exception("Invalid section."); + } + + $this->initialSection = $newInitialSection; + } + + /** + * @return Section + */ + public function initialSection() { + return $this->sections[$this->initialSection]; + } + + /** + * @param $section + * @param $step + * + * @return Step|null + */ + public function findStep($section, $step) { + if (isset($this->sections[$section])) { + return $this->sections[$section]->step($step); + } + + return null; + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Field.php b/classes/Wizard/Config/Field.php new file mode 100755 index 00000000..3ce1e534 --- /dev/null +++ b/classes/Wizard/Config/Field.php @@ -0,0 +1,156 @@ +name = arrayPath($fieldData, 'name', null); + if (empty($this->name)) { + throw new \Exception("Missing name for field."); + } + + $this->type = arrayPath($fieldData, 'type', null); + if (empty($this->type)) { + throw new \Exception("Missing type for field."); + } + + $this->title = arrayPath($fieldData, 'title', null); + $this->description = arrayPath($fieldData, 'description', null); + + $default = arrayPath($fieldData, 'default', null); + if ($this->type == 'hidden') { + $this->default = $default; + } else { + $this->default = Environment::Option($this->name, null, $default); + } + + $this->options = arrayPath($fieldData, 'options', []); + + $this->min = arrayPath($fieldData, 'min', 0); + $this->max = arrayPath($fieldData, 'max', 0); + $this->step = arrayPath($fieldData, 'step', 0); + $this->required = arrayPath($fieldData, 'required', true); + } + + /** + * @return string + */ + function name() { + return $this->name; + } + + /** + * @return string|null + */ + function title() { + return $this->title; + } + + /** + * @return string + */ + function type() { + return $this->type; + } + + /** + * @return string|null + */ + function description() { + return $this->description; + } + + /** + * @return mixed|null + */ + function default() { + return $this->default; + } + + /** + * @return string[string] + */ + function options() { + return $this->options; + } + + /** + * @return int + */ + function min() { + return $this->min; + } + + /** + * @return int + */ + function max() { + return $this->max; + } + + /** + * @return int + */ + function step() { + return $this->step; + } + + /** + * @return bool + */ + function required() { + return $this->required; + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Group.php b/classes/Wizard/Config/Group.php new file mode 100755 index 00000000..a6853d99 --- /dev/null +++ b/classes/Wizard/Config/Group.php @@ -0,0 +1,89 @@ +index = $groupIndex; + $this->introView = arrayPath($fieldData, 'introView', null); + $this->class = arrayPath($fieldData, 'class', null); + $this->conditions = arrayPath($fieldData, 'conditions', []); + + $options = arrayPath($fieldData, 'options', []); + foreach($options as $option) { + $this->options[] = new Option($option); + } + } + + /** + * @return string|null + */ + public function introView() { + return $this->introView; + } + + /** + * @return string|null + */ + public function class() { + return $this->class; + } + + /** + * @return array|null + */ + public function conditions() { + return $this->conditions; + } + + /** + * @return int + */ + public function index() { + return $this->index; + } + + + /** + * @return Option[] + */ + public function options() { + return $this->options; + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Option.php b/classes/Wizard/Config/Option.php new file mode 100755 index 00000000..18520f85 --- /dev/null +++ b/classes/Wizard/Config/Option.php @@ -0,0 +1,107 @@ +title = arrayPath($fieldData, 'title', null); + $this->icon = arrayPath($fieldData, 'icon', null); + $this->next = arrayPath($fieldData, 'next', null); + $this->class = arrayPath($fieldData, 'class', null); + $this->link = arrayPath($fieldData, 'link', null); + $this->target = arrayPath($fieldData, 'target', null); + $this->descriptionView = arrayPath($fieldData, 'descriptionView', null); + } + + /** + * @return string|null + */ + public function title() { + return $this->title; + } + + /** + * @return string|null + */ + public function descriptionView() { + return $this->descriptionView; + } + + /** + * @return string|null + */ + public function icon() { + return $this->icon; + } + + /** + * @return string|null + */ + public function next() { + return $this->next; + } + + /** + * @return string|null + */ + public function class() { + return $this->class; + } + + /** + * @return string|null + */ + public function link() { + return $this->link; + } + + /** + * @return string|null + */ + public function target() { + return $this->target; + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Section.php b/classes/Wizard/Config/Section.php new file mode 100755 index 00000000..440ff9ed --- /dev/null +++ b/classes/Wizard/Config/Section.php @@ -0,0 +1,130 @@ +config = $config; + $this->id = $sectionId; + + $this->displaySteps = arrayPath($sectionConfig, 'displaySteps', false); + $this->class = arrayPath($sectionConfig, 'class', null); + + $steps = arrayPath($sectionConfig, 'steps', []); + $stepIndex = 0; + foreach($steps as $stepData) { + $this->steps[] = new Step($this, $stepIndex, $stepData); + $stepIndex++; + } + } + + /** + * @return Config + */ + public function config() { + return $this->config; + } + + /** + * @return string + */ + public function id() { + return $this->id; + } + + /** + * @return string|null + */ + public function class() { + return $this->class; + } + + /** + * @return bool + */ + public function displaySteps() { + return $this->displaySteps; + } + + /** + * @return Step[] + */ + public function steps() { + return $this->steps; + } + + /** + * @return int + */ + public function stepCount() { + return count($this->steps); + } + + /** + * @param $stepIndex + * + * @return Step|null + */ + public function step($stepIndex) { + if ($stepIndex < count($this->steps)) { + return $this->steps[$stepIndex]; + } + + return null; + } + + public function stepJson() { + $data = []; + + $index = 1; + /** @var Step $step */ + foreach($this->steps as $step) { + $data[] = [ + 'id' => $this->id().'-'.$index, + 'index' => $index, + 'title' => $step->title(), + 'description' => $step->description() + ]; + + $index++; + } + + return json_encode($data, JSON_PRETTY_PRINT); + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Step.php b/classes/Wizard/Config/Step.php new file mode 100755 index 00000000..d6621bf3 --- /dev/null +++ b/classes/Wizard/Config/Step.php @@ -0,0 +1,266 @@ +id = $section->id().'-'.$stepIndex; + + $this->section = $section; + $this->type = arrayPath($stepData, 'type', null); + if (empty($this->type)) { + throw new \Exception("Missing type specifier for step."); + } + + $this->introView = arrayPath($stepData, 'introView', null); + $this->title = arrayPath($stepData, 'title', null); + $this->description = arrayPath($stepData, 'description', null); + + $groups = arrayPath($stepData, 'groups', []); + $groupIndex = 0; + foreach($groups as $groupData) { + $this->groups[] = new Group($groupIndex, $groupData); + $groupIndex++; + } + + + $fields = arrayPath($stepData, 'fields', []); + foreach($fields as $field) { + $this->fields[] = new Field($field); + } + + $this->handler = arrayPath($stepData, 'handler', null); + $this->next = arrayPath($stepData, 'next', null); + $this->class = arrayPath($stepData, 'class', null); + $this->return = arrayPath($stepData, 'return', null); + $this->successView = arrayPath($stepData, 'successView', null); + $this->errorView = arrayPath($stepData, 'errorView', null); + $this->videoUrl = arrayPath($stepData, 'videoUrl', null); + $this->autoStart = arrayPath($stepData, 'autoStart', null); + + $tests = arrayPath($stepData, 'tests', []); + $testIndex = 0; + foreach($tests as $testData) { + $this->tests[] = new Test($section, $stepIndex, $testIndex, $testData); + $testIndex++; + } + + if (!empty($this->handler) && is_callable($this->handler)) { + add_action('wp_ajax_'.$this->id, $this->handler); + } + } + + /** + * @return string + */ + function id() { + return $this->id; + } + + /** + * @return Section + */ + function section() { + return $this->section; + } + + /** + * @return string + */ + function type() { + return $this->type; + } + + /** + * @return string|null + */ + function class() { + return $this->class; + } + + /** + * @return string|null + */ + function introView() { + return $this->introView; + } + + /** + * @return string|null + */ + function successView() { + return $this->successView; + } + + /** + * @return string|null + */ + function errorView() { + return $this->errorView; + } + + /** + * @return string|null + */ + function title() { + return $this->title; + } + + /** + * @return string|null + */ + function description() { + return $this->description; + } + + /** + * @return Group[] + */ + function groups() { + return $this->groups; + } + + /** + * @return Field[] + */ + function fields() { + return $this->fields; + } + + /** + * @return callable|null + */ + function handler() { + return $this->handler; + } + + /** + * @return string|null + */ + function next() { + return $this->next; + } + + /** + * @return string|null + */ + function return() { + return $this->return; + } + + /** + * @return bool + */ + function autoStart() { + return $this->autoStart; + } + + /** + * @return string|null + */ + function videoUrl() { + return $this->videoUrl; + } + + public function testsJson() { + $data = []; + + $index = 1; + /** @var Test $test */ + foreach($this->tests as $test) { + $data[] = [ + 'action' => $test->id(), + 'index' => $index, + 'title' => $test->title(), + 'nonce' => wp_create_nonce('media-cloud-wizard-test'), + 'description' => $test->description() + ]; + + $index++; + } + + return json_encode($data, JSON_PRETTY_PRINT); + } +} \ No newline at end of file diff --git a/classes/Wizard/Config/Test.php b/classes/Wizard/Config/Test.php new file mode 100755 index 00000000..d91b467d --- /dev/null +++ b/classes/Wizard/Config/Test.php @@ -0,0 +1,86 @@ +id = $section->id().'-'.$stepIndex.'-'.$testIndex; + + $this->title = arrayPath($testData, 'title', null); + $this->description = arrayPath($testData, 'description', null); + $this->handler = arrayPath($testData, 'handler', null); + + if (!empty($this->handler) && is_callable($this->handler)) { + add_action('wp_ajax_'.$this->id, $this->handler); + } + } + + /** + * @return string + */ + function id() { + return $this->id; + } + + /** + * @return string|null + */ + function title() { + return $this->title; + } + + /** + * @return string|null + */ + function description() { + return $this->description; + } + + /** + * @return callable|null + */ + function handler() { + return $this->handler; + } +} \ No newline at end of file diff --git a/classes/Wizard/ConfiguresWizard.php b/classes/Wizard/ConfiguresWizard.php new file mode 100755 index 00000000..686bb9c9 --- /dev/null +++ b/classes/Wizard/ConfiguresWizard.php @@ -0,0 +1,27 @@ +defaultConfig = new Config($config); + + $registry = include ILAB_CONFIG_DIR.'/wizard-registry.config.php'; + if (!is_array($registry)) { + throw new \Exception("Invalid wizard registry."); + } + + $this->registry = []; + foreach($registry as $key => $class) { + if (class_exists($class)) { + $builder = call_user_func([$class, 'configureWizard']); + $this->registry[$key] = new Config($builder->build()); + } + } + } + + /** + * Register menu pages related to this tool + * + * @param $top_menu_slug + */ + public function registerMenu($top_menu_slug, $networkMode = false, $networkAdminMenu = false) { + add_submenu_page('media-cloud', 'Media Cloud Setup Wizard', 'Setup Wizard', 'manage_options', 'media-cloud-wizard', [$this, 'renderSetupWizard']); + } + + public function renderSetupWizard() { + if (isset($_REQUEST['wizard'])) { + $which = sanitize_text_field($_REQUEST['wizard']); + if (isset($this->registry[$which])) { + $config = $this->registry[$which]; + } else { + $config = $this->defaultConfig; + } + } else { + $config = $this->defaultConfig; + } + + echo View::render_view( 'wizard.wizard', ['config' => $config]); + } +} \ No newline at end of file diff --git a/classes/Wizard/StorageWizardTrait.php b/classes/Wizard/StorageWizardTrait.php new file mode 100755 index 00000000..29a567e3 --- /dev/null +++ b/classes/Wizard/StorageWizardTrait.php @@ -0,0 +1,168 @@ +test('Validate Storage Settings', 'Running tests ...', [static::class, 'testStorageSettings']); + $builder->test('Upload Sample File', 'Running tests ...', [static::class, 'testUploadSampleFile']); + $builder->test('Verify Uploaded File Is Publicly Accessble', 'Running tests ...', [static::class, 'testStorageAcl']); + $builder->test('Delete Uploaded File', 'Running tests ...', [static::class, 'testDeleteFromStorage']); + } + + + public static function testStorageSettings() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Environment::UpdateOption('mcloud-tool-enabled-storage', false); + + Tracker::trackView("System Test - Validate Client", "/system-test/validate-client"); + + $client = new static(); + $errorCollector = new ErrorCollector(); + try { + $isValid = $client->validateSettings($errorCollector); + Tracker::trackView("System Test - Validate Client - Success", "/system-test/validate-client/success"); + } catch (\Exception $ex) { + Tracker::trackView("System Test - Validate Client - Error", "/system-test/validate-client/error"); + $errorCollector->addError("Error validating client settings. Message: ".$ex->getMessage()); + } + + if ($isValid) { + wp_send_json([ + 'status' => 'success', + 'message' => 'Was able to successfully connect to storage provider.' + ]); + } else { + wp_send_json([ + 'status' => 'error', + 'message' => 'There was an error or errors trying to connect to the storage provider.', + 'errors' => $errorCollector->errors() + ]); + } + } + + public static function testUploadSampleFile() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Tracker::trackView("System Test - Test Uploads", "/system-test/uploads"); + + $client = new static(); + $errors = []; + try { + $client->upload('_troubleshooter/sample.txt',ILAB_TOOLS_DIR.'/public/text/sample-upload.txt', StorageGlobals::privacy()); + Tracker::trackView("System Test - Test Uploads - Success", "/system-test/uploads/success"); + } catch (\Exception $ex) { + Tracker::trackView("System Test - Test Uploads - Error", "/system-test/uploads/error"); + $errors[] = $ex->getMessage(); + } + + if (empty($errors)) { + wp_send_json([ + 'status' => 'success', + 'message' => 'Was able to successfully upload a sample file.' + ]); + } else { + wp_send_json([ + 'status' => 'error', + 'message' => 'There was an error trying to upload a sample file.', + 'errors' => $errors + ]); + } + } + + public static function testStorageAcl() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Tracker::trackView("System Test - Test Public", "/system-test/public"); + + $client = new static(); + $errors = []; + try { + $result = null; + $url = $client->url('_troubleshooter/sample.txt'); + + $result = ilab_file_get_contents($url); + + if ($result != file_get_contents(ILAB_TOOLS_DIR.'/public/text/sample-upload.txt')) { + $errors[] = "Upload sample file is not publicly viewable."; + } + } catch (\Exception $ex) { + $errors[] = $ex->getMessage(); + } + + if (empty($errors)) { + wp_send_json([ + 'status' => 'success', + 'message' => 'The uploaded file is publicly accessible.', + ]); + } else { + wp_send_json([ + 'status' => 'warning', + 'message' => 'The uploaded file is not publicly accessible. If you are using Imgix, this may not be matter if you are using S3 or Google Cloud Storage. For Digital Ocean and others, this is a big deal.', + 'errors' => $errors + ]); + } + } + + public static function testDeleteFromStorage() { + if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'media-cloud-wizard-test')) { + wp_send_json(['status' => 'error', 'message' => 'Nonce is invalid. Please try refreshing the page and submitting the form again.'], 200); + } + + Tracker::trackView("System Test - Deleting", "/system-test/delete"); + + + $client = new static(); + $errors = []; + try { + $client->delete('_troubleshooter/sample.txt'); + Tracker::trackView("System Test - Deleting - Success", "/system-test/delete/success"); + } catch (\Exception $ex) { + $errors[] = $ex->getMessage(); + Tracker::trackView("System Test - Deleting - Error", "/system-test/delete/error"); + } + + if (empty($errors)) { + Environment::UpdateOption('mcloud-tool-enabled-storage', true); + wp_send_json([ + 'status' => 'success', + 'message' => 'The uploaded file was successfully deleted.', + ]); + } else { + wp_send_json([ + 'status' => 'error', + 'message' => 'The uploaded file was successfully could not be deleted.', + 'errors' => $errors + ]); + } + } +} \ No newline at end of file diff --git a/classes/Wizard/WizardBuilder.php b/classes/Wizard/WizardBuilder.php new file mode 100755 index 00000000..c4b14e03 --- /dev/null +++ b/classes/Wizard/WizardBuilder.php @@ -0,0 +1,303 @@ + [] + ]; + + private $currentSection = null; + private $currentSectionData = null; + + private $currentStep = null; + private $currentStepType = null; + + private $currentGroup = null; + + public function __construct($initialSection, $hasSteps = false) { + $this->data['initialSection'] = $initialSection; + $this->data['hasSteps'] = $hasSteps; + } + + public static function instance($initialSection) { + return new WizardBuilder($initialSection); + } + + public function section($identifier, $displaySteps = false, $class = null) { + if (!empty($this->currentSection)) { + $this->endSection(); + } + + $this->currentSection = $identifier; + $this->currentSectionData = [ + 'displaySteps' => $displaySteps, + 'steps' => [], + 'class' => $class + ]; + + return $this; + } + + public function tutorialSection($identifier, $displaySteps = false) { + return $this->section($identifier, $displaySteps, 'section-tutorial'); + } + + public function endSection() { + if (!empty($this->currentStep)) { + $this->endStep(); + } + + if (!empty($this->currentSection)) { + $this->data['sections'][$this->currentSection] = $this->currentSectionData; + } + + $this->currentSection = null; + $this->currentSectionData = null; + + return $this; + } + + private function confirmStep($type) { + if ($this->currentStep == null) { + throw new \Exception("No step has been started yet."); + } + + if ($this->currentStepType != $type) { + throw new \Exception("Invalid step type"); + } + } + + private function startStep($type, $introView, $title, $description, $next = null, $return = null) { + if (!empty($this->currentStep)) { + $this->endStep(); + } + + if ($this->currentSectionData === null) { + throw new \Exception("Section must be defined before starting a step."); + } + + $this->currentStep = [ + 'type' => $type, + 'introView' => $introView, + 'title' => $title, + 'description' => $description, + 'next' => $next, + 'return' => $return + ]; + + $this->currentStepType = $type; + } + + public function endGroup() { + if ($this->currentGroup != null) { + $this->currentStep['groups'][] = $this->currentGroup; + $this->currentGroup = null; + } + + return $this; + } + + public function endStep() { + if (!empty($this->currentStep)) { + $this->endGroup(); + + if ($this->currentSectionData === null) { + throw new \Exception("Section must be defined before ending a step."); + } + + $this->currentSectionData['steps'][] = $this->currentStep; + } + + $this->currentStepType = null; + $this->currentStep = null; + + return $this; + } + + public function intro($introView, $title, $description, $next = null, $return = null) { + $this->startStep('intro', $introView, $title, $description, $next, $return); + $this->endStep(); + + return $this; + } + + public function video($videoUrl, $title, $description, $next = null, $return = null) { + $this->startStep('video', null, $title, $description, $next, $return); + $this->currentStep['videoUrl'] = $videoUrl; + $this->endStep(); + + return $this; + } + + public function tutorial($introView, $title, $description, $next = null, $return = null) { + $this->startStep('tutorial', $introView, $title, $description, $next, $return); + $this->endStep(); + + return $this; + } + + public function select($title, $description, $class = null) { + $this->startStep('select', null, $title, $description); + $this->currentStep['class'] = $class; + + $this->currentStep['groups'] = []; + + return $this; + } + + public function group($introView, $class = null, $conditions = []) { + $this->endGroup(); + + $this->currentGroup = [ + 'introView' => $introView, + 'class' => $class, + 'conditions' => $conditions, + 'options' => [] + ]; + + return $this; + } + + public function option($identifier, $title, $descriptionView, $icon, $next, $class = null, $link = null, $target = false) { + $this->confirmStep('select'); + + if ($this->currentGroup == null) { + throw new \Exception("You must start a group before adding an option."); + } + + if (!empty($link) && (strpos($link, 'admin:') === 0)) { + $link = admin_url(str_replace('admin:', '', $link)); + } + + $this->currentGroup['options'][$identifier] = [ + 'title' => $title, + 'descriptionView' => $descriptionView, + 'icon' => $icon, + 'next' => $next, + 'class' => $class, + 'link' => $link, + 'target' => $target + ]; + + return $this; + } + + public function form($introView, $title, $description, $handler, $next = null, $return = null) { + $this->startStep('form', $introView, $title, $description, $next, $return); + $this->currentStep['fields'] = []; + $this->currentStep['handler'] = $handler; + + return $this; + } + + public function field($name, $type, $title, $description, $default, $options = []) { + $this->confirmStep('form'); + + $field = [ + 'name' => $name, + 'title' => $title, + 'type' => $type, + 'description' => $description, + 'default' => $default + ]; + + if (!empty($options)) { + $field = array_merge($field, $options); + } + + $this->currentStep['fields'][] = $field; + + + return $this; + } + + public function textField($name, $title, $description, $default, $required = true) { + return $this->field($name, 'text-field', $title, $description, $default, ['required' => $required]); + } + + public function uploadField($name, $title, $description, $required = true) { + return $this->field($name, 'upload', $title, $description, null, ['required' => $required]); + } + + public function passwordField($name, $title, $description, $default, $required = true) { + return $this->field($name, 'password', $title, $description, $default, ['required' => $required]); + } + + public function checkboxField($name, $title, $description, $default) { + return $this->field($name, 'checkbox', $title, $description, $default); + } + + public function selectField($name, $title, $description, $default, $options) { + return $this->field($name, 'select', $title, $description, $default, [ + 'options' => $options + ]); + } + + public function numberField($name, $title, $description, $default, $min, $max, $step, $required = true) { + return $this->field('number', $title, $description, $default, [ + 'min' => $min, + 'max' => $max, + 'step' => $step, + 'required' => $required + ]); + } + + public function hiddenField($name, $default) { + return $this->field($name, 'hidden', null, null, $default); + } + + public function testStep($introView, $title, $description, $autoStart = false, $next = null, $return = null) { + $this->startStep('test', $introView, $title, $description, $next, $return); + $this->currentStep['autoStart'] = $autoStart; + $this->currentStep['tests'] = []; + + return $this; + } + + public function test($title, $description, $handler) { + $this->currentStep['tests'][] = [ + 'title' => $title, + 'description' => $description, + 'handler' => $handler + ]; + + return $this; + } + + public function task($introView, $title, $description, $handler, $autoStart = false, $next = null, $return = null) { + $this->startStep('task', $introView, $title, $description, $next, $return); + $this->currentStep['autoStart'] = $autoStart; + $this->currentStep['handler'] = $handler; + $this->endStep(); + + return $this; + } + + public function next($introView, $title, $description, $next = null, $return = null) { + $this->startStep('next', $introView, $title, $description, $next, $return); + $this->endStep(); + + return $this; + } + + public function build() { + $this->endSection(); + + return $this->data; + } +} \ No newline at end of file diff --git a/config/imgix.config.php b/config/imgix.config.php index 1c2f579c..77fa7ecb 100755 --- a/config/imgix.config.php +++ b/config/imgix.config.php @@ -114,18 +114,6 @@ ] ] ], - "ilab-media-imgix-gutenberg-settings" => [ - "title" => "Imgix Gutenberg Integration", - "description" => "Controls integration of Imgix with Gutenberg", - "options" => [ - "mcloud-imgix-disable-srcset" => [ - "title" => "Disable srcset on image tags", - "description" => "Gutenberg's image block has a lot of issues and problems. For example, it omits the width and height attributes which is a really bad practice. And it's also because of this that it's impossible to calculate a srcset that is realistic when using Imgix. Until they fix this, we recommend disabling srcset on image tags - but only if you use Gutenberg. If you are not using Gutenberg, carry on with your bad self!", - "type" => "checkbox", - "default" => false - ] - ] - ], "ilab-media-imgix-gif-settings" => [ "title" => "Imgix GIF Settings", "description" => "Controls how animated gifs appear on the site. You must have a premium Imgix account to have animated GIF support. See here for more details or contact their sales team for more information.", diff --git a/config/storage.config.php b/config/storage.config.php index a62cd031..2cb4aa9c 100755 --- a/config/storage.config.php +++ b/config/storage.config.php @@ -47,7 +47,8 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\S3\\S3Storage", 'config' => '/storage/s3.config.php', 'help' => [ - [ 'title' => 'Watch Tutorial', 'url' => 'https://www.youtube.com/watch?v=kjFCACrPRtU' ], + [ 'title' => 'Setup Wizard', 'wizard' => 's3' ], + [ 'title' => 'Watch Tutorial', 'video_url' => 'https://www.youtube.com/watch?v=kjFCACrPRtU' ], [ 'title' => 'Read Documentation', 'url' => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/setting-up-amazon-s3' ], ] ], @@ -56,6 +57,7 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\GoogleCloud\\GoogleStorage", 'config' => '/storage/google.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'google' ], [ 'title' => 'Read Documentation', 'url' => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/setting-up-google-cloud-storage' ], ] ], @@ -64,6 +66,7 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\S3\\DigitalOceanStorage", 'config' => '/storage/do.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'do' ], [ 'title' => 'Read Documentation', 'url' => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/setting-up-digitalocean-spaces' ], ] ], @@ -72,6 +75,7 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\S3\\MinioStorage", 'config' => '/storage/minio.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'minio' ] ] ], 'wasabi' => [ @@ -79,6 +83,7 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\S3\\WasabiStorage", 'config' => '/storage/wasabi.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'wasabi' ], [ 'title' => 'Read Documentation', 'url' => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/setting-up-wasabi' ], ] ], @@ -87,6 +92,7 @@ 'class' => "\\ILAB\\MediaCloud\\Storage\\Driver\\S3\\OtherS3Storage", 'config' => '/storage/other-s3.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'other-s3' ], ] ], 'backblaze' => [ @@ -94,6 +100,7 @@ 'class' => \ILAB\MediaCloud\Storage\Driver\Backblaze\BackblazeStorage::class, 'config' => '/storage/backblaze.config.php', 'help' => [ + [ 'title' => 'Setup Wizard', 'wizard' => 'backblaze' ], [ 'title' => 'Read Documentation', 'url' => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/setting-up-backblaze' ], ] ], @@ -124,12 +131,6 @@ "dynamic" => true, "options" => [], ], - "ilab-media-cloud-signed-urls" => [ - "title" => "Pre-Signed URL Settings", - "description" => "These settings control how pre-signed URLs work.", - "dynamic" => true, - "options" => [], - ], "ilab-media-cloud-upload-handling" => [ "title" => "Upload Handling", "dynamic" => true, @@ -144,65 +145,99 @@ ], "mcloud-storage-subsite-prefixes" => [ "title" => "Subsite Upload Paths", - "display-order" => 10, + "display-order" => 11, "description" => "This allows you to override the default upload path for individual subsites in your multisite network. If left blank, that subsite will use your default upload path. As with the Upload Path setting, you can use the following variables: @{date:format}, @{site-name}, @{site-host}, @{site-id}, @{versioning}, @{user-name}, @{unique-id}, @{unique-path}, @{type}.", - "type" => "subsite-upload-paths" + "type" => "subsite-upload-paths", + "multisite" => true, ], "mcloud-storage-upload-images" => [ "title" => "Upload Images", "description" => "Upload image files to cloud storage.", - "display-order" => 10, + "display-order" => 12, "type" => "checkbox", "default" => true ], "mcloud-storage-upload-videos" => [ "title" => "Upload Video Files", "description" => "Upload video files to cloud storage.", - "display-order" => 10, + "display-order" => 13, "type" => "checkbox", "default" => true ], "mcloud-storage-upload-audio" => [ "title" => "Upload Audio Files", "description" => "Upload audio files to cloud storage.", - "display-order" => 10, + "display-order" => 14, "type" => "checkbox", "default" => true ], "mcloud-storage-upload-documents" => [ "title" => "Upload Documents", "description" => "Upload non-image files such as Word documents, PDF files, zip files, etc.", - "display-order" => 10, + "display-order" => 15, "type" => "checkbox", "default" => true ], "mcloud-storage-ignored-mime-types" => [ "title" => "Ignored MIME Types", "description" => "List of MIME types to ignore. Any files with matching MIME types will not be uploaded. You can also use wildcards. For example image/* would disable uploading for any image.", - "display-order" => 10, + "display-order" => 16, "type" => "text-area" ], "mcloud-storage-delete-uploads" => [ "title" => "Delete Uploaded Files", "description" => "Deletes uploaded files from the WordPress server after they've been uploaded.", - "display-order" => 10, + "display-order" => 30, "type" => "checkbox" ], "mcloud-storage-queue-deletes" => [ "title" => "Queue Deletes", "description" => "When this option is enabled, uploads won't be deleted right away, they will be queued for deletion two to five minutes later. This allows other plugins the ability to process any uploads before they are deleted from your WordPress server. If Delete From Storage is disabled, this setting is ignored.", - "display-order" => 10, + "display-order" => 31, "type" => "checkbox", "default" => true ], "mcloud-storage-delete-from-server" => [ "title" => "Delete From Storage", "description" => "When you delete from the media library, turning this on will also delete the file from cloud storage.", - "display-order" => 10, + "display-order" => 32, "type" => "checkbox" ], + "mcloud-storage-enable-big-size-threshold" => [ + "title" => "Enable Big Size Threshold", + "description" => "WordPress 5.3 introduced a new feature that automatically resizes large image uploads to be 'web-ready'. It essentially replaces your uploaded master image with a version scaled down to 2560x2560. Use this toggle to enable or disable this feature.", + "display-order" => 40, + "wp_version" => ['>=', "5.3"], + "type" => "checkbox", + "default" => true, + ], + "mcloud-storage-big-size-threshold" => [ + "title" => "Big Size Threshold", + "description" => "WordPress 5.3 introduced a new feature that automatically resizes large image uploads to be 'web-ready'. Use this setting to control the threshold that triggers the resize.", + "display-order" => 41, + "wp_version" => ['>=', "5.3"], + "type" => "number", + "min" => 1024, + "max" => 100000, + "default" => 2560, + ], + "mcloud-storage-big-size-upload-original" => [ + "title" => "Upload Original", + "description" => "WordPress 5.3 introduced a new feature that automatically resizes large image uploads to be 'web-ready'. Use this setting to upload the unscaled original image to cloud storage. If this is disabled and you have Delete Uploads enabled, the original file will not be deleted.", + "display-order" => 42, + "wp_version" => ['>=', "5.3"], + "type" => "checkbox", + "default" => true, + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "doc_link" => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/pre-signed-url-settings/', + "dynamic" => true, + "options" => [], + ], "ilab-media-cloud-cdn-settings" => [ "title" => "CDN Settings", "doc_link" => 'https://kb.mediacloud.press/articles/documentation/cloud-storage/cdn-settings', @@ -239,15 +274,22 @@ ] ] ], - "ilab-media-cloud-gutenberg-settings" => [ - "title" => "Gutenberg Integration", - "description" => "Controls integration of Dynamic Images with Gutenberg", + "ilab-media-cloud-srcset-settings" => [ + "title" => "Responsive Image Settings", + "description" => "Controls how responsive image tags are generated.", "options" => [ "mcloud-storage-disable-srcset" => [ "title" => "Disable srcset on image tags", - "description" => "Gutenberg's image block has a lot of issues and problems. For example, it omits the width and height attributes which is a really bad practice. And it's also because of this that it's impossible to calculate a srcset that is realistic when using Imgix. Until they fix this, we recommend disabling srcset on image tags - but only if you use Gutenberg. If you are not using Gutenberg, carry on with your bad self!", + "description" => "Gutenberg's image block, before WordPress 5.3, had a lot of issues and problems. For example, which is still an issue in 5.3, WordPress omits the width and height attributes which is a really bad practice. And it's also because of this that it's impossible to calculate a srcset that is realistic. If you are using WordPress prior to 5.3, we recommend disabling srcset on image tags - but only if you use Gutenberg. If you are using the Classic Editor, you do not need to disable this!", "type" => "checkbox", "default" => false + ], + "mcloud-storage-replace-srcset" => [ + "title" => "Replace srcset on image tags", + "description" => "MediaCloud can generate a more optimal srcset for image tags with WordPress versions greater than 5.3. This is enabled by default, however if you are having issues, you should disable it to use WordPress's default srcset generation. If Disable srcset on image tags is enabled, this setting will have no effect.", + "type" => "checkbox", + "wp_version" => ['>=', "5.3"], + "default" => true ] ] ] diff --git a/config/storage/backblaze.config.php b/config/storage/backblaze.config.php index 61c9191a..b7665051 100755 --- a/config/storage/backblaze.config.php +++ b/config/storage/backblaze.config.php @@ -44,4 +44,11 @@ "options" => [ ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + ] + ], ]; \ No newline at end of file diff --git a/config/storage/do.config.php b/config/storage/do.config.php index d4e36ad5..e6242576 100755 --- a/config/storage/do.config.php +++ b/config/storage/do.config.php @@ -46,20 +46,6 @@ "type" => "checkbox", "default" => true, ], - "mcloud-storage-use-presigned-urls" => [ - "title" => "Use Pre-Signed URLs", - "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", - "display-order" => 14, - "type" => "checkbox", - "default" => false, - ], - "mcloud-storage-presigned-expiration" => [ - "title" => "Pre-Signed URL Expiration", - "description" => "The number of minutes the signed URL is valid for.", - "display-order" => 15, - "type" => "number", - "default" => 10, - ], ] ], "ilab-media-cloud-upload-handling" => [ @@ -73,22 +59,68 @@ "display-order" => 1, "type" => "select", "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" + "public-read" => "Public", + "authenticated-read" => "Private" ], ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "display-order" => 2, + "description" => "", + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", - "display-order" => 2, + "display-order" => 20, "type" => "text-field", ], "mcloud-storage-expires" => [ "title" => "Content Expiration", "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", - "display-order" => 3, + "display-order" => 21, "type" => "text-field", ], + "mcloud-storage-big-size-original-privacy" => [ + "title" => "Original Image Privacy ACL", + "description" => "This will set the privacy for the original image upload.", + "display-order" => 43, + "type" => "select", + "default" => 'authenticated-read', + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + "mcloud-storage-use-presigned-urls" => [ + "title" => "Use Pre-Signed URLs", + "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", + "display-order" => 1, + "type" => "checkbox", + "default" => false, + ], + "mcloud-storage-presigned-expiration" => [ + "title" => "Pre-Signed URL Expiration", + "description" => "The number of minutes the signed URL is valid for.", + "display-order" => 2, + "type" => "number", + "default" => 10, + ], + "mcloud-storage-use-presigned-urls-advanced" => [ + "title" => "Advanced Pre-Signed URL Settings", + "description" => "", + "display-order" => 3, + "type" => "advanced-presigned", + "plan" => "pro" + ], + ] + ], ]; \ No newline at end of file diff --git a/config/storage/google.config.php b/config/storage/google.config.php index 868b65dd..119a6e35 100755 --- a/config/storage/google.config.php +++ b/config/storage/google.config.php @@ -29,20 +29,6 @@ "display-order" => 2, "type" => "text-field", ], - "mcloud-storage-use-presigned-urls" => [ - "title" => "Use Pre-Signed URLs", - "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", - "display-order" => 14, - "type" => "checkbox", - "default" => false, - ], - "mcloud-storage-presigned-expiration" => [ - "title" => "Pre-Signed URL Expiration", - "description" => "The number of minutes the signed URL is valid for.", - "display-order" => 15, - "type" => "number", - "default" => 10, - ], "mcloud-storage-bucket-policy-only" => [ "title" => "Use Bucket Policy Only", "description" => "Set to true to when using a bucket which has the 'Bucket Policy Only' flag enabled. See this documentation for more information. Also, make sure to make the bucket public, as specified in this documentation.", @@ -63,22 +49,57 @@ "display-order" => 1, "type" => "select", "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" + "public-read" => "Public", + "authenticated-read" => "Private" ], ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "description" => "", + "display-order" => 2, + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", - "display-order" => 2, + "display-order" => 20, "type" => "text-field", ], "mcloud-storage-expires" => [ "title" => "Content Expiration", "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", - "display-order" => 3, + "display-order" => 21, "type" => "text-field", ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + "mcloud-storage-use-presigned-urls" => [ + "title" => "Use Pre-Signed URLs", + "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", + "display-order" => 1, + "type" => "checkbox", + "default" => false, + ], + "mcloud-storage-presigned-expiration" => [ + "title" => "Pre-Signed URL Expiration", + "description" => "The number of minutes the signed URL is valid for.", + "display-order" => 2, + "type" => "number", + "default" => 10, + ], + "mcloud-storage-use-presigned-urls-advanced" => [ + "title" => "Advanced Pre-Signed URL Settings", + "description" => "", + "display-order" => 3, + "type" => "advanced-presigned", + "plan" => "pro" + ], + ] + ], ]; \ No newline at end of file diff --git a/config/storage/minio.config.php b/config/storage/minio.config.php index 696225b4..2be2d704 100755 --- a/config/storage/minio.config.php +++ b/config/storage/minio.config.php @@ -69,20 +69,6 @@ "type" => "checkbox", "default" => true, ], - "mcloud-storage-use-presigned-urls" => [ - "title" => "Use Pre-Signed URLs", - "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", - "display-order" => 14, - "type" => "checkbox", - "default" => false, - ], - "mcloud-storage-presigned-expiration" => [ - "title" => "Pre-Signed URL Expiration", - "description" => "The number of minutes the signed URL is valid for.", - "display-order" => 15, - "type" => "number", - "default" => 10, - ], ] ], "ilab-media-cloud-upload-handling" => [ @@ -95,10 +81,16 @@ "description" => "This will set the privacy for each upload. You should leave it as public-read unless you are using Imgix.", "type" => "select", "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" + "public-read" => "Public", + "authenticated-read" => "Private" ], ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "description" => "", + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", @@ -109,6 +101,45 @@ "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", "type" => "text-field", ], + "mcloud-storage-big-size-original-privacy" => [ + "title" => "Original Image Privacy ACL", + "description" => "This will set the privacy for the original image upload.", + "display-order" => 43, + "type" => "select", + "default" => 'authenticated-read', + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + "mcloud-storage-use-presigned-urls" => [ + "title" => "Use Pre-Signed URLs", + "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", + "display-order" => 1, + "type" => "checkbox", + "default" => false, + ], + "mcloud-storage-presigned-expiration" => [ + "title" => "Pre-Signed URL Expiration", + "description" => "The number of minutes the signed URL is valid for.", + "display-order" => 2, + "type" => "number", + "default" => 10, + ], + "mcloud-storage-use-presigned-urls-advanced" => [ + "title" => "Advanced Pre-Signed URL Settings", + "description" => "", + "display-order" => 3, + "type" => "advanced-presigned", + "plan" => "pro" + ], + ] + ], ]; \ No newline at end of file diff --git a/config/storage/other-s3.config.php b/config/storage/other-s3.config.php index aa84a776..a0b846d1 100755 --- a/config/storage/other-s3.config.php +++ b/config/storage/other-s3.config.php @@ -35,25 +35,31 @@ ], "mcloud-storage-s3-region" => [ "title" => "Region", - "description" => "The region that your bucket is in. Set to 'auto' to have Media Cloud automatically determine what region your bucket is in.", + "description" => "The region that your bucket is in. Set to 'auto' to have Media Cloud automatically determine what region your bucket is in. May not work with some S3 compatible providers.", "display-order" => 11, "type" => "select", "options" => [ - "auto" => "Automatic", - 'us-east-2' => 'US East (Ohio)', - 'us-east-1' => 'US East (N. Virginia)', - 'us-west-1' => 'US West (N. California)', - 'us-west-2' => 'US West (Oregon)', - 'ca-central-1' => 'Canada (Central)', - 'ap-south-1' => 'Asia Pacific (Mumbai)', - 'ap-northeast-2' => 'Asia Pacific (Seoul)', - 'ap-southeast-1' => 'Asia Pacific (Singapore)', - 'ap-southeast-2' => 'Asia Pacific (Sydney)', - 'ap-northeast-1' => 'Asia Pacific (Tokyo)', - 'eu-central-1' => 'EU (Frankfurt)', - 'eu-west-1' => 'EU (Ireland)', - 'eu-west-2' => 'EU (London)', - 'sa-east-1' => 'South America (São Paulo)', + "auto" => "Automatic", + 'us-east-2' => 'US East (Ohio)', + 'us-east-1' => 'US East (N. Virginia)', + 'us-west-1' => 'US West (N. California)', + 'us-west-2' => 'US West (Oregon)', + 'ca-central-1' => 'Canada (Central)', + 'ap-east-1' => 'Asia Pacific (Hong Kong)', + 'ap-south-1' => 'Asia Pacific (Mumbai)', + 'ap-northeast-1' => 'Asia Pacific (Tokyo)', + 'ap-northeast-2' => 'Asia Pacific (Seoul)', + 'ap-northeast-3' => 'Asia Pacific (Osaka-Local)', + 'ap-southeast-1' => 'Asia Pacific (Singapore)', + 'ap-southeast-2' => 'Asia Pacific (Sydney)', + 'eu-central-1' => 'EU (Frankfurt)', + 'eu-west-1' => 'EU (Ireland)', + 'eu-west-2' => 'EU (London)', + 'eu-west-3' => 'EU (Paris)', + 'eu-north-1' => 'EU (Stockholm)', + 'sa-east-1' => 'South America (São Paulo)', + 'cn-north-1' => 'China (Beijing)', + 'cn-northwest-1' => 'China (Ningxia)', ], ], "mcloud-storage-s3-endpoint" => [ @@ -69,20 +75,6 @@ "type" => "checkbox", "default" => true, ], - "mcloud-storage-use-presigned-urls" => [ - "title" => "Use Pre-Signed URLs", - "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", - "display-order" => 14, - "type" => "checkbox", - "default" => false, - ], - "mcloud-storage-presigned-expiration" => [ - "title" => "Pre-Signed URL Expiration", - "description" => "The number of minutes the signed URL is valid for.", - "display-order" => 15, - "type" => "number", - "default" => 10, - ], ] ], "ilab-media-cloud-upload-handling" => [ @@ -94,21 +86,70 @@ "title" => "Upload Privacy ACL", "description" => "This will set the privacy for each upload. You should leave it as public-read unless you are using Imgix.", "type" => "select", + "display-order" => 1, "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" + "public-read" => "Public", + "authenticated-read" => "Private" ], ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "description" => "", + "display-order" => 2, + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", + "display-order" => 20, "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", "type" => "text-field", ], "mcloud-storage-expires" => [ "title" => "Content Expiration", + "display-order" => 21, "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", "type" => "text-field", ], + "mcloud-storage-big-size-original-privacy" => [ + "title" => "Original Image Privacy ACL", + "description" => "This will set the privacy for the original image upload.", + "display-order" => 43, + "type" => "select", + "default" => 'authenticated-read', + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + "mcloud-storage-use-presigned-urls" => [ + "title" => "Use Pre-Signed URLs", + "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", + "display-order" => 1, + "type" => "checkbox", + "default" => false, + ], + "mcloud-storage-presigned-expiration" => [ + "title" => "Pre-Signed URL Expiration", + "description" => "The number of minutes the signed URL is valid for.", + "display-order" => 2, + "type" => "number", + "default" => 10, + ], + "mcloud-storage-use-presigned-urls-advanced" => [ + "title" => "Advanced Pre-Signed URL Settings", + "description" => "", + "display-order" => 3, + "type" => "advanced-presigned", + "plan" => "pro" + ], + ] + ], ]; \ No newline at end of file diff --git a/config/storage/s3.config.php b/config/storage/s3.config.php index b79500ae..b5c6ebf0 100755 --- a/config/storage/s3.config.php +++ b/config/storage/s3.config.php @@ -77,20 +77,6 @@ "type" => "checkbox", "default" => false, ], - "mcloud-storage-use-presigned-urls" => [ - "title" => "Use Pre-Signed URLs", - "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", - "display-order" => 14, - "type" => "checkbox", - "default" => false, - ], - "mcloud-storage-presigned-expiration" => [ - "title" => "Pre-Signed URL Expiration", - "description" => "The number of minutes the signed URL is valid for.", - "display-order" => 15, - "type" => "number", - "default" => 10, - ], ] ], "ilab-media-cloud-upload-handling" => [ @@ -98,28 +84,74 @@ "dynamic" => true, "description" => "The following options control how the storage tool handles uploads.", "options" => [ - "mcloud-storage-privacy" => [ - "title" => "Upload Privacy ACL", - "description" => "This will set the privacy for each upload. You should leave it as public-read unless you are using Imgix.", - "display-order" => 1, - "type" => "select", - "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" - ], - ], + "mcloud-storage-privacy" => [ + "title" => "Upload Privacy ACL", + "description" => "This will set the privacy for each upload. You should leave it as public-read unless you are using Imgix.", + "display-order" => 1, + "type" => "select", + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "description" => "", + "display-order" => 2, + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", - "display-order" => 2, + "display-order" => 20, "type" => "text-field", ], "mcloud-storage-expires" => [ "title" => "Content Expiration", "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", - "display-order" => 3, + "display-order" => 21, "type" => "text-field", ], + "mcloud-storage-big-size-original-privacy" => [ + "title" => "Original Image Privacy ACL", + "description" => "This will set the privacy for the original image upload.", + "display-order" => 43, + "type" => "select", + "default" => 'authenticated-read', + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + "mcloud-storage-use-presigned-urls" => [ + "title" => "Use Pre-Signed URLs", + "description" => "Set to true to generate signed URLs that will expire within a specified time period. You should use this if you've set the default ACL to private.", + "display-order" => 1, + "type" => "checkbox", + "default" => false, + ], + "mcloud-storage-presigned-expiration" => [ + "title" => "Pre-Signed URL Expiration", + "description" => "The number of minutes the signed URL is valid for.", + "display-order" => 2, + "type" => "number", + "default" => 10, + ], + "mcloud-storage-use-presigned-urls-advanced" => [ + "title" => "Advanced Pre-Signed URL Settings", + "description" => "", + "display-order" => 3, + "type" => "advanced-presigned", + "plan" => "pro" + ], + ], + ], ]; \ No newline at end of file diff --git a/config/storage/wasabi.config.php b/config/storage/wasabi.config.php index 361d11ff..a342b26a 100755 --- a/config/storage/wasabi.config.php +++ b/config/storage/wasabi.config.php @@ -35,7 +35,7 @@ ], "mcloud-storage-wasabi-region" => [ "title" => "Region", - "description" => "The region that your bucket is in. Set to 'auto' to have Media Cloud automatically determine what region your bucket is in.", + "description" => "The region that your bucket is in.", "display-order" => 11, "type" => "select", "options" => [ @@ -55,21 +55,49 @@ "title" => "Upload Privacy ACL", "description" => "This will set the privacy for each upload. You should leave it as public-read unless you are using Imgix.", "type" => "select", + "display-order" => 1, "options" => [ - "public-read" => "public-read", - "authenticated-read" => "authenticated-read" + "public-read" => "Public", + "authenticated-read" => "Private" ], ], + "mcloud-storage-advanced-privacy" => [ + "title" => "Advanced Privacy", + "display-order" => 2, + "description" => "", + "type" => "advanced-privacy", + "plan" => "pro" + ], "mcloud-storage-cache-control" => [ "title" => "Cache Control", + "display-order" => 20, "description" => "Sets the Cache-Control metadata for uploads, e.g. public,max-age=2592000.", "type" => "text-field", ], "mcloud-storage-expires" => [ "title" => "Content Expiration", + "display-order" => 21, "description" => "Sets the Expire metadata for uploads. This is the number of minutes from the date of upload.", "type" => "text-field", ], + "mcloud-storage-big-size-original-privacy" => [ + "title" => "Original Image Privacy ACL", + "description" => "This will set the privacy for the original image upload.", + "display-order" => 43, + "type" => "select", + "default" => 'authenticated-read', + "options" => [ + "public-read" => "Public", + "authenticated-read" => "Private" + ], + ], ] ], + "ilab-media-cloud-signed-urls" => [ + "title" => "Pre-Signed URL Settings", + "description" => "These settings control how pre-signed URLs work.", + "dynamic" => true, + "options" => [ + ] + ], ]; \ No newline at end of file diff --git a/config/wizard-registry.config.php b/config/wizard-registry.config.php new file mode 100755 index 00000000..916033a9 --- /dev/null +++ b/config/wizard-registry.config.php @@ -0,0 +1,24 @@ + \ILAB\MediaCloud\Storage\Driver\S3\S3Storage::class, + 'imgix' => \ILAB\MediaCloud\Tools\Imgix\ImgixTool::class, + 'google' => \ILAB\MediaCloud\Storage\Driver\GoogleCloud\GoogleStorage::class, + 'other-s3' => \ILAB\MediaCloud\Storage\Driver\S3\OtherS3Storage::class, + 'do' => \ILAB\MediaCloud\Storage\Driver\S3\DigitalOceanStorage::class, + 'wasabi' => \ILAB\MediaCloud\Storage\Driver\S3\WasabiStorage::class, + 'minio' => \ILAB\MediaCloud\Storage\Driver\S3\MinioStorage::class, + 'backblaze' => \ILAB\MediaCloud\Storage\Driver\Backblaze\BackblazeStorage::class, +]; \ No newline at end of file diff --git a/config/wizard.config.php b/config/wizard.config.php new file mode 100755 index 00000000..e375af16 --- /dev/null +++ b/config/wizard.config.php @@ -0,0 +1,49 @@ +section('intro') + ->intro('wizard.intros.intro', null, null, 'cloud-storage') + ->endSection() + ->section('cloud-storage') + ->select(null, null ) + ->group('wizard.cloud-storage.intro', 'select-icons') + ->option('s3', 'Amazon S3', 'wizard.cloud-storage.providers.s3.description', 'wizard-icon-s3.svg', 'cloud-storage-s3', 'select-s3') + ->option('google', 'Google Cloud Storage', 'wizard.cloud-storage.providers.google.description', 'wizard-icon-google.svg', 'cloud-storage-google') + ->option('do', 'DigitalOcean Spaces', 'wizard.cloud-storage.providers.do.description', 'wizard-icon-do.svg', 'cloud-storage-do') + ->option('wasabi', 'Wasabi', 'wizard.cloud-storage.providers.wasabi.description', 'wizard-icon-wasabi.png', 'cloud-storage-wasabi') + ->option('backblaze', 'Backblaze', 'wizard.cloud-storage.providers.backblaze.description', 'wizard-icon-backblaze.svg', 'cloud-storage-backblaze') + ->option('minio', 'Minio', 'wizard.cloud-storage.providers.minio.description', 'wizard-icon-minio.png', 'cloud-storage-minio') + ->option('other-s3', 'S3 Compatible', 'wizard.cloud-storage.providers.other-s3.description', 'wizard-icon-other-s3.svg', 'cloud-storage-other-s3') + ->endGroup() + ->endStep() + ->endSection() +; + +S3Storage::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\GoogleCloud\GoogleStorage::configureWizard($builder); +\ILAB\MediaCloud\Tools\Imgix\ImgixTool::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\S3\OtherS3Storage::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\S3\DigitalOceanStorage::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\S3\WasabiStorage::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\S3\MinioStorage::configureWizard($builder); +\ILAB\MediaCloud\Storage\Driver\Backblaze\BackblazeStorage::configureWizard($builder); + +return $builder->build(); + + diff --git a/ilab-media-tools.php b/ilab-media-tools.php index 7fe02e02..6f215b8c 100755 --- a/ilab-media-tools.php +++ b/ilab-media-tools.php @@ -5,7 +5,7 @@ Plugin URI: https://github.com/interfacelab/ilab-media-tools Description: Automatically upload media to Amazon S3 and integrate with Imgix, a real-time image processing CDN. Boosts site performance and simplifies workflows. Author: interfacelab -Version: 3.2.7 +Version: 3.3.0 Author URI: http://interfacelab.io */ // Copyright (c) 2016 Interfacelab LLC. All rights reserved. @@ -93,7 +93,7 @@ } // Version Defines -define( 'MEDIA_CLOUD_VERSION', '3.2.7' ); +define( 'MEDIA_CLOUD_VERSION', '3.3.0' ); define( 'MEDIA_CLOUD_INFO_VERSION', '1.0.0' ); // Directory defines define( 'ILAB_TOOLS_DIR', dirname( __FILE__ ) ); @@ -122,6 +122,10 @@ if ( !function_exists( 'media_cloud_licensing' ) ) { // Create a helper function for easy SDK access. + /** + * @return Freemius + * @throws Freemius_Exception + */ function media_cloud_licensing() { global $media_cloud_licensing ; @@ -132,6 +136,7 @@ function media_cloud_licensing() if ( !defined( 'WP_FS__PRODUCT_1431_MULTISITE' ) ) { define( 'WP_FS__PRODUCT_1431_MULTISITE', true ); } + /** @var Freemius $media_cloud_licensing */ $media_cloud_licensing = fs_dynamic_init( array( 'id' => '1431', 'slug' => 'ilab-media-tools', @@ -183,6 +188,7 @@ function ( $user, $install ) { 1000, 2 ); + media_cloud_licensing()->add_action( 'after_uninstall', [ "\\ILAB\\MediaCloud\\Tools\\ToolsManager", 'uninstall' ] ); // Signal that SDK was initiated. do_action( 'media_cloud_licensing_loaded' ); } @@ -192,4 +198,13 @@ function ( $user, $install ) { } ); register_activation_hook( __FILE__, [ "\\ILAB\\MediaCloud\\Tools\\ToolsManager", 'activate' ] ); register_deactivation_hook( __FILE__, [ "\\ILAB\\MediaCloud\\Tools\\ToolsManager", 'deactivate' ] ); -media_cloud_licensing()->add_action( 'after_uninstall', [ "\\ILAB\\MediaCloud\\Tools\\ToolsManager", 'uninstall' ] ); \ No newline at end of file +add_action( 'admin_init', function () { + if ( !wp_doing_ajax() && !media_cloud_licensing()->is_activation_mode() ) { + + if ( get_option( 'mcloud_show_wizard' ) ) { + delete_option( 'mcloud_show_wizard' ); + exit( wp_redirect( admin_url( 'admin.php?page=media-cloud-wizard' ) ) ); + } + + } +} ); \ No newline at end of file diff --git a/public/css/ilab-media-cloud.css b/public/css/ilab-media-cloud.css index 1207fe44..b5f70630 100755 --- a/public/css/ilab-media-cloud.css +++ b/public/css/ilab-media-cloud.css @@ -8,4 +8,4 @@ * Date: 2018-04-01T06:26:32.417Z */.cropper-container{direction:ltr;font-size:0;line-height:0;position:relative;touch-action:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.cropper-container img{display:block;height:100%;image-orientation:0deg;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;width:100%}.cropper-canvas,.cropper-crop-box,.cropper-drag-box,.cropper-modal,.cropper-wrap-box{bottom:0;left:0;position:absolute;right:0;top:0}.cropper-canvas,.cropper-wrap-box{overflow:hidden}.cropper-drag-box{background-color:#fff;opacity:0}.cropper-modal{background-color:#000;opacity:.5}.cropper-view-box{display:block;height:100%;outline-color:rgba(51,153,255,.75);outline:1px solid #39f;overflow:hidden;width:100%}.cropper-dashed{border:0 dashed #eee;display:block;opacity:.5;position:absolute}.cropper-dashed.dashed-h{border-bottom-width:1px;border-top-width:1px;height:33.33333%;left:0;top:33.33333%;width:100%}.cropper-dashed.dashed-v{border-left-width:1px;border-right-width:1px;height:100%;left:33.33333%;top:0;width:33.33333%}.cropper-center{display:block;height:0;left:50%;opacity:.75;position:absolute;top:50%;width:0}.cropper-center:after,.cropper-center:before{background-color:#eee;content:" ";display:block;position:absolute}.cropper-center:before{height:1px;left:-3px;top:0;width:7px}.cropper-center:after{height:7px;left:0;top:-3px;width:1px}.cropper-face,.cropper-line,.cropper-point{display:block;height:100%;opacity:.1;position:absolute;width:100%}.cropper-face{background-color:#fff;left:0;top:0}.cropper-line{background-color:#39f}.cropper-line.line-e{cursor:ew-resize;right:-3px;top:0;width:5px}.cropper-line.line-n{cursor:ns-resize;height:5px;left:0;top:-3px}.cropper-line.line-w{cursor:ew-resize;left:-3px;top:0;width:5px}.cropper-line.line-s{bottom:-3px;cursor:ns-resize;height:5px;left:0}.cropper-point{background-color:#39f;height:5px;opacity:.75;width:5px}.cropper-point.point-e{cursor:ew-resize;margin-top:-3px;right:-3px;top:50%}.cropper-point.point-n{cursor:ns-resize;left:50%;margin-left:-3px;top:-3px}.cropper-point.point-w{cursor:ew-resize;left:-3px;margin-top:-3px;top:50%}.cropper-point.point-s{bottom:-3px;cursor:s-resize;left:50%;margin-left:-3px}.cropper-point.point-ne{cursor:nesw-resize;right:-3px;top:-3px}.cropper-point.point-nw{cursor:nwse-resize;left:-3px;top:-3px}.cropper-point.point-sw{bottom:-3px;cursor:nesw-resize;left:-3px}.cropper-point.point-se{bottom:-3px;cursor:nwse-resize;height:20px;opacity:1;right:-3px;width:20px}@media (min-width:768px){.cropper-point.point-se{height:15px;width:15px}}@media (min-width:992px){.cropper-point.point-se{height:10px;width:10px}}@media (min-width:1200px){.cropper-point.point-se{height:5px;opacity:.75;width:5px}}.cropper-point.point-se:before{background-color:#39f;bottom:-50%;content:" ";display:block;height:200%;opacity:0;position:absolute;right:-50%;width:200%}.cropper-invisible{opacity:0}.cropper-bg{background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAAA3NCSVQICAjb4U/gAAAABlBMVEXMzMz////TjRV2AAAACXBIWXMAAArrAAAK6wGCiw1aAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M26LyyjAAAABFJREFUCJlj+M/AgBVhF/0PAH6/D/HkDxOGAAAAAElFTkSuQmCC")}.cropper-hide{display:block;height:0;position:absolute;width:0}.cropper-hidden{display:none!important}.cropper-move{cursor:move}.cropper-crop{cursor:crosshair}.cropper-disabled .cropper-drag-box,.cropper-disabled .cropper-face,.cropper-disabled .cropper-line,.cropper-disabled .cropper-point{cursor:not-allowed}.ilab-admin-separator-container{display:flex;height:12px;align-items:center;margin:0 -10px 0 0}.ilab-admin-separator-container .ilab-admin-separator-title{font-size:.68em;text-transform:uppercase;font-weight:700;margin-right:10px;color:hsla(0,0%,100%,.25)}.ilab-admin-separator-container .ilab-admin-separator{display:block;flex:1;padding:0;height:1px;line-height:1px;background:hsla(0,0%,100%,.125)}#wpadminbar #wp-admin-bar-media-cloud-admin-bar>.ab-item>.ab-icon:before{content:"\F176";top:3px}.ilabm-backdrop{position:fixed;display:block;background-color:rgba(0,0,0,.66)}.ilabm-backdrop,.ilabm-container{left:0;top:0;right:0;bottom:0;z-index:160000!important}.ilabm-container{background-color:#fcfcfc;position:absolute;border-radius:0;display:flex;flex-direction:column}.ilabm-titlebar{border-bottom:1px solid #ddd;min-height:50px;max-height:50px;box-shadow:0 0 4px rgba(0,0,0,.15);display:flex;align-items:center}.ilabm-titlebar h1{flex:1;padding:0 16px;font-size:22px;line-height:50px;margin:0 50px 0 0;display:flex;align-items:center;justify-content:space-between}.ilabm-titlebar .modal-actions{display:flex}.ilabm-titlebar .modal-actions a{margin-left:8px;display:flex;align-items:center}.ilabm-titlebar .modal-actions a svg{height:12px;width:auto;margin-right:4px}.ilabm-titlebar .modal-actions a svg>path,.ilabm-titlebar .modal-actions a svg>rect{fill:#000}.ilabm-titlebar .modal-actions div.spacer{width:8px;min-width:8px}.ilabm-titlebar>a{display:block;max-width:50px;min-width:50px;border-left:1px solid #ddd}.ilabm-window-area{flex:2 100%;display:flex;flex-direction:row}.ilabm-window-area-content{background-color:#fff;flex:2 100%;display:flex;flex-direction:column}.ilabm-editor-container{flex:2 100%;position:relative}.ilabm-editor-area{position:absolute;left:0;top:0;right:0;bottom:0;background-image:url(../img/ilab-imgix-edit-bg.png);display:block;margin:10px}.ilabm-sidebar{min-width:380px;max-width:380px;background-color:#f3f3f3;display:flex;flex-direction:column;border-left:3px solid #ddd}.ilabm-sidebar-content{position:relative;display:flex;flex:2 100%}.ilabm-sidebar-tabs{background:#ddd;display:flex;min-height:36px;max-height:36px}.ilabm-sidebar-tabs .ilabm-sidebar-tab{min-width:40px;white-space:nowrap;text-align:center;margin-top:3px;background-color:#ccc;line-height:30px;padding:0 15px;margin-right:3px;font-size:11px;text-transform:uppercase;color:#888;font-weight:700;cursor:pointer!important}.ilabm-sidebar-tabs .active-tab{background-color:#f3f3f3;color:#777}.ilabm-sidebar-actions{display:flex;justify-content:flex-end;background-color:#fff;border-top:1px solid #eee;padding:11px}.ilabm-sidebar-actions a{display:block;margin-left:10px!important}a.button-reset{background:#a00!important;border-color:#700!important;color:#fff!important;box-shadow:inset 0 1px 0 #d00,0 1px 0 rgba(0,0,0,.15)!important;text-shadow:none!important}.ilabm-editor-tabs{background:#ddd;overflow:hidden;min-height:36px}.ilabm-editor-tabs,.ilabm-editor-tabs .ilabm-tabs-select-ui{display:flex;flex-direction:row}.ilabm-editor-tabs .ilabm-tabs-select-ui .ilabm-tabs-select-label{margin-top:3px;line-height:32px;padding:0 5px 0 15px;margin-right:3px;font-size:11px;text-transform:uppercase;color:#888;font-weight:700;cursor:pointer!important}.ilabm-editor-tabs .ilabm-tabs-select-ui .ilabm-tabs-select{margin-top:4px;line-height:32px;font-size:11px}.ilabm-editor-tabs .ilabm-tabs-ui{display:flex;flex-direction:row}.ilabm-editor-tabs .ilabm-tabs-ui .ilabm-editor-tab{white-space:nowrap;min-width:50px;text-align:center;min-height:32px;max-height:33px;margin-top:3px;background-color:#ccc;line-height:31px;padding:0 15px;margin-right:3px;font-size:11px;text-transform:uppercase;color:#888;font-weight:700;cursor:pointer!important}.ilabm-editor-tabs .ilabm-tabs-ui .active-tab{background:#fff;margin-top:2px;border-right:1px solid #ddd;border-left:1px solid #ddd;border-top:1px solid #ddd}.ilabm-status-container{display:flex;flex:1;justify-content:flex-start}.ilabm-status-container .is-hidden{display:none}.ilabm-status-container .spinner{margin:0 8px 0 0}.ilabm-status-label{font-size:13px}.ilabm-preview-wait-modal{position:absolute;box-shadow:0 0 10px 1px rgba(0,0,0,.75);text-align:center;padding:20px 40px;border-radius:10px;background-color:hsla(0,0%,100%,.66);left:50%;top:50%;margin-left:-60px;margin-top:-32px}.ilabm-preview-wait-modal h3{text-transform:uppercase;font-size:13px}.ilabm-preview-wait-modal span.spinner{float:none!important}.ilabm-bottom-bar{font-size:12px!important;padding:0 10px 10px;display:flex!important;justify-content:flex-end;align-items:center;min-height:20px}.ilabm-bottom-bar .ilabm-bottom-bar-seperator{position:relative;width:1px;height:20px;background-color:#ccc;margin:0 10px 0 20px!important}.ilabm-bottom-bar a,.ilabm-bottom-bar select{margin-left:10px!important}.ilabm-bottom-bar select{font-size:13px!important;min-width:140px}.ilabm-bottom-bar label{font-size:13px!important}.is-hidden{display:none}.ilabm-modal-close{top:0;right:0;cursor:pointer;color:#777;background-color:transparent;height:50px;width:50px;position:absolute;text-align:center;border:0;border-left:1px solid #ddd;transition:color .1s ease-in-out,background .1s ease-in-out;text-decoration:none;z-index:1000;box-sizing:content-box;transition-property:border,background,color;transition-duration:.05s;transition-timing-function:ease-in-out}.ilabm-modal-icon{background-repeat:no-repeat;display:block;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}.ilabm-modal-icon:before{content:"\F335";font:normal 22px/1 dashicons;vertical-align:middle;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;color:#666}.setup-body{display:flex;flex-direction:column;align-items:center;justify-content:center;padding-top:40px}.setup-body .service-selection-grid{display:grid;grid-template-columns:repeat(3,1fr);grid-gap:15px;grid-auto-rows:158px}.setup-body .service-selection-grid a{border-radius:5px;background-color:#fff;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;border:1px solid #eaeaea;width:128px;height:128px;text-align:center;text-decoration:none;padding:15px;background-position:50% calc(50% - 15px);background-repeat:no-repeat;transition:transform .5s ease-out}.setup-body .service-selection-grid a:hover{transform:scale(1.1)}.setup-body .service-selection-grid a[data-service=s3]{grid-column:1;grid-row:1;background-image:url(../img/icon-service-s3.svg)}.setup-body .service-selection-grid a[data-service=google]{grid-column:2;grid-row:1;background-image:url(../img/icon-service-google.svg)}.setup-body .service-selection-grid a[data-service=minio]{grid-column:3;grid-row:1;background-image:url(../img/icon-service-minio.svg)}.setup-body .service-selection-grid a[data-service=backblaze]{grid-column:1;grid-row:2;background-image:url(../img/icon-service-backblaze.svg)}.setup-body .service-selection-grid a[data-service=do]{grid-column:2;grid-row:2;background-image:url(../img/icon-service-do.svg)}.setup-body .service-selection-grid a[data-service=other-s3]{grid-column:3;grid-row:2;background-image:url(../img/icon-service-other-s3.svg)}#ilab-video-upload-target{position:relative;padding:30px;border:4px dashed #e0e0e0;background-color:#fafafa;margin:20px 0;display:flex;flex-wrap:wrap;min-height:128px;cursor:pointer;transition:border .5s ease-out}#ilab-video-upload-target.drag-inside{border:4px solid #70a9dd;background-color:#bcd3e2}.ilab-upload-item{position:relative;min-width:128px;min-height:128px;max-width:128px;max-height:128px;width:128px;height:128px;background-color:#eaeaea;margin:10px;border-radius:0;border:1px solid #ddd;overflow:hidden;transition:opacity .5s ease-out,left .3s ease-out,top .3s ease-out,width .3s ease-out,height .3s ease-out,transform .3s ease-out;background-repeat:no-repeat;background-position:50%}.ilab-upload-item.upload-error{background-color:#eabab3;border:1px solid #bb6a6b}.ilab-upload-item.ilab-upload-selected{box-shadow:0 0 0 2px #fff,0 0 0 5px #0073aa}.ilab-upload-cell-image{background-image:url(../img/ilab-icon-image.svg);background-size:60px}.ilab-upload-cell-video{background-image:url(../img/ilab-icon-video.svg);background-size:60px}.ilab-upload-cell-doc{background-image:url(../img/ilab-icon-document.svg);background-size:45px}.no-mouse{cursor:default!important}.ilab-upload-item-background{position:absolute;left:-5px;top:-5px;right:-5px;bottom:-5px;background-repeat:no-repeat;background-size:cover;background-position:50%;transition:opacity .5s}.ilab-upload-status-container{position:absolute;left:0;top:0;right:0;bottom:0;display:flex;flex-direction:column;justify-content:center;align-items:center}.ilab-upload-status{color:#fff;font-weight:700;font-size:1em;text-shadow:0 0 3px #000}.ilab-upload-progress{width:80%;max-width:80%;height:9px;overflow:hidden;position:relative;margin-top:10px;border-radius:9px;background-color:hsla(0,0%,100%,.66)}.ilab-upload-progress-track{background-color:#0085ba;position:absolute;left:0;top:0;bottom:0;transition:width .125s ease-out}.ilab-upload-directions{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);font-size:2em;opacity:.5}.ilab-loader-container{display:flex;justify-content:center;align-items:center;position:absolute;left:0;top:0;right:0;bottom:0;transition:opacity .5s}.ilab-loader,.ilab-loader:after{border-radius:50%;width:24px;height:24px}.ilab-loader{font-size:5px;text-indent:-9999em;border:1.1em solid hsla(0,0%,100%,.2);border-left-color:#fff;-webkit-animation:load8 1.1s linear infinite;animation:load8 1.1s linear infinite}.ilab-loader.ilab-loader-dark{border:1.1em solid rgba(0,0,0,.2);border-left-color:#000}.ilab-upload-footer{padding-right:10px;position:absolute;left:0;right:0;border-top:1px solid #ddd;bottom:0;height:52px;background-color:#fff;display:flex;justify-content:flex-end;align-items:center;background-color:#fcfcfc;visibility:hidden}#ilab-attachment-info{position:absolute;right:-300px;top:0;bottom:54px;width:267px;transition:right .33s ease-out}.ilab-upload-insert-mode{position:relative;background-color:#fff}.ilab-upload-insert-mode div.wrap{position:absolute;left:0;top:0;right:0;bottom:52px;margin:0;padding:0 20px;overflow:auto;transition:right .33s ease-out}.ilab-upload-insert-mode div.wrap h2:first-of-type{display:none}.ilab-upload-insert-mode .ilab-upload-footer{visibility:visible}.ilab-item-selected div.wrap{right:300px}.ilab-item-selected #ilab-attachment-info{right:0}.media-cloud-upload-logo{width:240px;height:auto;margin-bottom:40px;opacity:.66;margin-top:-40px}.has-upload-message .upload-ui .media-cloud-upload-logo{display:none}.attachments-browser .upload-ui .media-cloud-upload-logo{margin-top:0}.minicolors{position:relative}.minicolors-sprite{background-image:url(../img/jquery.minicolors.png)}.minicolors-swatch{position:absolute;vertical-align:middle;background-position:-80px 0;border:1px solid #ccc;cursor:text;padding:0;margin:0;display:inline-block}.minicolors-swatch-color{position:absolute;top:0;left:0;right:0;bottom:0}.minicolors input[type=hidden]+.minicolors-swatch{width:28px;position:static;cursor:pointer}.minicolors input[type=hidden][disabled]+.minicolors-swatch{cursor:default}.minicolors-panel{position:absolute;width:173px;background:#fff;border:1px solid #ccc;box-shadow:0 0 20px rgba(0,0,0,.2);z-index:99999;box-sizing:content-box;display:none}.minicolors-panel.minicolors-visible{display:block}.minicolors-position-top .minicolors-panel{top:-154px}.minicolors-position-right .minicolors-panel{right:0}.minicolors-position-bottom .minicolors-panel{top:auto}.minicolors-position-left .minicolors-panel{left:0}.minicolors-with-opacity .minicolors-panel{width:194px}.minicolors .minicolors-grid{position:relative;top:1px;left:1px;width:150px;height:150px;margin-bottom:2px;background-position:-120px 0;cursor:crosshair}[dir=rtl] .minicolors .minicolors-grid{right:1px}.minicolors .minicolors-grid-inner{position:absolute;top:0;left:0;width:150px;height:150px}.minicolors-slider-saturation .minicolors-grid{background-position:-420px 0}.minicolors-slider-saturation .minicolors-grid-inner{background-position:-270px 0;background-image:inherit}.minicolors-slider-brightness .minicolors-grid{background-position:-570px 0}.minicolors-slider-brightness .minicolors-grid-inner{background-color:#000}.minicolors-slider-wheel .minicolors-grid{background-position:-720px 0}.minicolors-opacity-slider,.minicolors-slider{position:absolute;top:1px;left:152px;width:20px;height:150px;background-color:#fff;background-position:0 0;cursor:row-resize}[dir=rtl] .minicolors-opacity-slider,[dir=rtl] .minicolors-slider{right:152px}.minicolors-slider-saturation .minicolors-slider{background-position:-60px 0}.minicolors-slider-brightness .minicolors-slider,.minicolors-slider-wheel .minicolors-slider{background-position:-20px 0}.minicolors-opacity-slider{left:173px;background-position:-40px 0;display:none}[dir=rtl] .minicolors-opacity-slider{right:173px}.minicolors-with-opacity .minicolors-opacity-slider{display:block}.minicolors-grid .minicolors-picker{position:absolute;top:70px;left:70px;width:12px;height:12px;border:1px solid #000;border-radius:10px;margin-top:-6px;margin-left:-6px;background:none}.minicolors-grid .minicolors-picker>div{position:absolute;top:0;left:0;width:8px;height:8px;border-radius:8px;border:2px solid #fff;box-sizing:content-box}.minicolors-picker{position:absolute;top:0;left:0;width:18px;height:2px;background:#fff;border:1px solid #000;margin-top:-2px;box-sizing:content-box}.minicolors-swatches,.minicolors-swatches li{margin:5px 0 3px 5px;padding:0;list-style:none;overflow:hidden}[dir=rtl] .minicolors-swatches,[dir=rtl] .minicolors-swatches li{margin:5px 5px 3px 0}.minicolors-swatches .minicolors-swatch{position:relative;float:left;cursor:pointer;margin:0 4px 0 0}[dir=rtl] .minicolors-swatches .minicolors-swatch{float:right;margin:0 0 0 4px}.minicolors-with-opacity .minicolors-swatches .minicolors-swatch{margin-right:7px}[dir=rtl] .minicolors-with-opacity .minicolors-swatches .minicolors-swatch{margin-right:0;margin-left:7px}.minicolors-swatch.selected{border-color:#000}.minicolors-inline{display:inline-block}.minicolors-inline .minicolors-input{display:none!important}.minicolors-inline .minicolors-panel{position:relative;top:auto;left:auto;box-shadow:none;z-index:auto;display:inline-block}[dir=rtl] .minicolors-inline .minicolors-panel{right:auto}.minicolors-theme-default .minicolors-swatch{top:5px;left:5px;width:18px;height:18px}[dir=rtl] .minicolors-theme-default .minicolors-swatch{right:5px}.minicolors-theme-default .minicolors-swatches .minicolors-swatch{margin-bottom:2px;top:0;left:0;width:18px;height:18px}[dir=rtl] .minicolors-theme-default .minicolors-swatches .minicolors-swatch{right:0}.minicolors-theme-default.minicolors-position-right .minicolors-swatch{left:auto;right:5px}[dir=rtl] .minicolors-theme-default.minicolors-position-left .minicolors-swatch{right:auto;left:5px}.minicolors-theme-default.minicolors{display:inline-block}.minicolors-theme-default .minicolors-input{height:20px;width:auto;display:inline-block;padding-left:26px}[dir=rtl] .minicolors-theme-default .minicolors-input{text-align:right;unicode-bidi:-moz-plaintext;unicode-bidi:plaintext;padding-left:1px;padding-right:26px}.minicolors-theme-default.minicolors-position-right .minicolors-input{padding-right:26px;padding-left:inherit}[dir=rtl] .minicolors-theme-default.minicolors-position-left .minicolors-input{padding-right:inherit;padding-left:26px}.minicolors-theme-bootstrap .minicolors-swatch{z-index:2;top:3px;left:3px;width:28px;height:28px;border-radius:3px}[dir=rtl] .minicolors-theme-bootstrap .minicolors-swatch{right:3px}.minicolors-theme-bootstrap .minicolors-swatches .minicolors-swatch{margin-bottom:2px;top:0;left:0;width:20px;height:20px}[dir=rtl] .minicolors-theme-bootstrap .minicolors-swatches .minicolors-swatch{right:0}.minicolors-theme-bootstrap .minicolors-swatch-color{border-radius:inherit}.minicolors-theme-bootstrap.minicolors-position-right>.minicolors-swatch{left:auto;right:3px}[dir=rtl] .minicolors-theme-bootstrap.minicolors-position-left>.minicolors-swatch{right:auto;left:3px}.minicolors-theme-bootstrap .minicolors-input{float:none;padding-left:44px}[dir=rtl] .minicolors-theme-bootstrap .minicolors-input{text-align:right;unicode-bidi:-moz-plaintext;unicode-bidi:plaintext;padding-left:12px;padding-right:44px}.minicolors-theme-bootstrap.minicolors-position-right .minicolors-input{padding-right:44px;padding-left:12px}[dir=rtl] .minicolors-theme-bootstrap.minicolors-position-left .minicolors-input{padding-right:12px;padding-left:44px}.minicolors-theme-bootstrap .minicolors-input.input-lg+.minicolors-swatch{top:4px;left:4px;width:37px;height:37px;border-radius:5px}[dir=rtl] .minicolors-theme-bootstrap .minicolors-input.input-lg+.minicolors-swatch{right:4px}.minicolors-theme-bootstrap .minicolors-input.input-sm+.minicolors-swatch{width:24px;height:24px}.minicolors-theme-bootstrap .minicolors-input.input-xs+.minicolors-swatch{width:18px;height:18px}.input-group .minicolors-theme-bootstrap:not(:first-child) .minicolors-input{border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group .minicolors-theme-bootstrap .minicolors-input{border-radius:4px}[dir=rtl] .input-group .minicolors-theme-bootstrap:not(:first-child) .minicolors-input{border-top-right-radius:0;border-bottom-right-radius:0}[dir=rtl] .input-group .minicolors-theme-bootstrap:not(:last-child) .minicolors-input{border-top-left-radius:0;border-bottom-left-radius:0}[dir=rtl] .input-group-addon,[dir=rtl] .input-group-btn>.btn,[dir=rtl] .input-group-btn>.btn-group>.btn,[dir=rtl] .input-group-btn>.dropdown-toggle,[dir=rtl] .input-group .form-control{border:1px solid #ccc;border-radius:4px}[dir=rtl] .input-group-addon:first-child,[dir=rtl] .input-group-btn:first-child>.btn,[dir=rtl] .input-group-btn:first-child>.btn-group>.btn,[dir=rtl] .input-group-btn:first-child>.dropdown-toggle,[dir=rtl] .input-group-btn:last-child>.btn-group:not(:last-child)>.btn,[dir=rtl] .input-group-btn:last-child>.btn:not(:last-child):not(.dropdown-toggle),[dir=rtl] .input-group .form-control:first-child{border-top-left-radius:0;border-bottom-left-radius:0;border-left:0}[dir=rtl] .input-group-addon:last-child,[dir=rtl] .input-group-btn:first-child>.btn-group:not(:first-child)>.btn,[dir=rtl] .input-group-btn:first-child>.btn:not(:first-child),[dir=rtl] .input-group-btn:last-child>.btn,[dir=rtl] .input-group-btn:last-child>.btn-group>.btn,[dir=rtl] .input-group-btn:last-child>.dropdown-toggle,[dir=rtl] .input-group .form-control:last-child{border-top-right-radius:0;border-bottom-right-radius:0}.minicolors-theme-semanticui .minicolors-swatch{top:0;left:0;padding:18px}[dir=rtl] .minicolors-theme-semanticui .minicolors-swatch{right:0}.minicolors-theme-semanticui input{text-indent:30px}.imgix-preview-image{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);max-width:100%;max-height:100%;display:block;pointer-events:none}.imgix-parameters-container{position:absolute;left:0;top:0;bottom:0;right:0;overflow-x:hidden;overflow-y:auto;display:flex;flex-direction:column;padding:15px 10px}.imgix-parameters-container.is-hidden{display:none}.imgix-parameters-container .imgix-parameter-group select{font-size:12px}.imgix-parameters-container .imgix-parameter-group h4{margin:0;font-size:10px;text-transform:uppercase;color:#999;background-color:#ddd;padding:5px 15px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.imgix-parameters-container .imgix-parameter-group>div{padding:15px}.imgix-parameter{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;padding-bottom:15px;margin-bottom:15px}.imgix-parameter .imgix-param-imagick-warning{position:absolute;left:-10px;top:-5px;right:-10px;bottom:0;padding:0 5px;display:flex;align-items:center;justify-content:center;background:hsla(0,0%,100%,.8)}.imgix-parameter .imgix-param-imagick-warning>div{text-align:center}.imgix-parameter:last-of-type{margin-bottom:0;padding-bottom:0}.imgix-param-title{display:flex;align-items:baseline;margin-bottom:0}.imgix-param-title-colortype{align-items:center!important;margin-bottom:8px}.imgix-param-title-colortype h3{margin:0!important}.imgix-param-title-left{flex:1 50%}.imgix-param-title-right{flex:1 50%;padding-left:40px;text-align:right;position:relative}.imgix-param-title-right h3{text-align:right}.imgix-param-blend-mode h3,.imgix-param-title h3{margin-top:0;font-size:11px;text-transform:uppercase;color:#666}.imgix-media-param-title .imgix-param-title-left{flex:2 80%}.imgix-media-param-title .imgix-param-title-right{flex:1 20%}.imgix-media-param-title .imgix-param-title-right a{text-align:center!important}.minicolors-theme-default.minicolors{width:auto;display:block;padding:0!important;margin:0;min-height:29px}.ilab-color-input{position:relative;top:0;right:0;height:30px!important;margin:0!important;padding-left:8px!important;padding-right:30px!important}.imgix-param-blend-mode{margin-top:15px;display:flex;align-items:baseline}.imgix-param-blend-mode h3{flex:1 50%}.imgix-param-blend-mode select{flex:2 100%}.imgix-parameter input[type=range]{display:block;width:100%;-webkit-appearance:none;margin:0 0 10px;background:none;padding:0!important}.imgix-parameter input[type=range]:focus{outline:none}.imgix-parameter input[type=range]:focus::-webkit-slider-runnable-track{background:#fff}.imgix-parameter input[type=range]::-webkit-slider-runnable-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:inset 1px 1px 2px 0 rgba(0,0,0,.25);background:#d4cfd4;border-radius:4px;border:0 solid #000101}.imgix-parameter input[type=range]::-webkit-slider-thumb{border:1px solid rgba(0,0,0,.25);box-shadow:inset 0 2px 2px 0 hsla(0,0%,100%,.5);height:17px;width:17px;border-radius:9px;background:#dcdcdc;cursor:pointer;-webkit-appearance:none;margin-top:-6px}.imgix-parameter input[type=range]::-moz-range-track{width:100%;height:5px;cursor:pointer;animate:.2s;box-shadow:inset 1px 1px 2px 0 rgba(0,0,0,.25);background:#d4cfd4;border-radius:4px;border:0 solid #000101}.imgix-parameter input[type=range]::-moz-range-thumb{border:1px solid rgba(0,0,0,.25);box-shadow:inset 0 2px 2px 0 hsla(0,0%,100%,.5);height:17px;width:17px;border-radius:9px;background:#dcdcdc;cursor:pointer;-webkit-appearance:none;margin-top:-6px}.imgix-parameter .imgix-param-reset{display:flex;width:100%;justify-content:flex-end}.imgix-parameter .imgix-param-reset a{font-size:11px;font-style:italic;text-decoration:none}.imgix-parameter .imgix-param-reset a,.imgix-parameter a:focus{outline:none!important;border:0!important}.imgix-media-preview{position:relative;margin:0!important;padding:0 0 100%!important;background-image:url(../img/ilab-imgix-edit-bg.png);width:100%}.imgix-media-preview img{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);max-width:100%;max-height:100%;display:block}.imgix-media-preview-inner{position:absolute;left:0;right:0;bottom:0;top:0;display:flex;align-items:center;justify-content:center}.imgix-alignment-container{display:flex;flex:row;flex-wrap:wrap;justify-content:space-around;align-items:baseline;padding:0 35px}.imgix-alignment-button{background-color:#ddd;display:block;width:60px;height:60px;margin:5px;text-decoration:none;border-radius:4px;border:1px solid #888;box-shadow:inset 0 1px 0 #fff,0 1px 0 rgba(0,0,0,.15)!important}.selected-alignment{background-color:#bbb;box-shadow:inset 1px 1px 1px rgba(0,0,0,.25),0 1px 0 rgba(0,0,0,.15)!important}.ilabm-pillbox{flex-wrap:wrap;border-bottom:0!important}.ilabm-pillbox,.ilabm-pillbox .ilabm-pill{align-items:center;display:flex;justify-content:center}.ilabm-pillbox .ilabm-pill{white-space:nowrap;line-height:1;height:14px;min-height:32px;width:140px;min-width:140px;max-width:140px;font-size:10px;background-color:#eaeaea;text-transform:uppercase;font-weight:700;color:#444;text-decoration:none;border-radius:8px;margin:3px}.ilabm-pillbox .ilabm-pill span{display:block;margin-right:8px}.ilabm-pillbox .ilabm-pill span.icon{width:18px;height:18px;min-width:18px;min-height:18px;max-width:18px;max-height:18px;background-repeat:no-repeat;background-position:50%;background-size:contain;margin-left:8px}.ilabm-pillbox .pill-selected{background-color:#ccc;box-shadow:inset 1px 1px 1px rgba(0,0,0,.25);color:#fff}.ilabm-pillbox-no-icon .ilabm-pill{width:100px;min-width:100px;max-width:100px}.ilabm-pillbox-no-icon .ilabm-pill span{margin-right:0}.ilabm-pillbox-no-icon .ilabm-pill span.icon{display:none}.imgix-pill-enhance>span.icon{background-image:url(../img/ilab-imgix-magic-wand-black.svg)}.imgix-pill-enhance.pill-selected>span.icon{background-image:url(../img/ilab-imgix-magic-wand-white.svg)}.imgix-pill-redeye>span.icon{background-image:url(../img/ilab-imgix-red-eye-black.svg)}.imgix-pill-redeye.pill-selected>span.icon{background-image:url(../img/ilab-imgix-red-eye-white.svg)}.imgix-pill-usefaces>span.icon{background-image:url(../img/ilab-imgix-faces-black.svg)}.imgix-pill-usefaces.pill-selected>span.icon{background-image:url(../img/ilab-imgix-faces-white.svg)}.imgix-pill-focalpoint>span.icon{background-image:url(../img/ilab-imgix-focalpoint-black.svg)}.imgix-pill-focalpoint.pill-selected>span.icon{background-image:url(../img/ilab-imgix-focalpoint-white.svg)}.imgix-pill-entropy>span.icon{background-image:url(../img/ilab-imgix-chaos-black.svg)}.imgix-pill-entropy.pill-selected>span.icon{background-image:url(../img/ilab-imgix-chaos-white.svg)}.imgix-pill-edges>span.icon{background-image:url(../img/ilab-imgix-edges-black.svg)}.imgix-pill-edges.pill-selected>span.icon{background-image:url(../img/ilab-imgix-edges-white.svg)}.imgix-pill-h>span.icon{background-image:url(../img/ilab-flip-horizontal-black.svg)}.imgix-pill-h.pill-selected>span.icon{background-image:url(../img/ilab-flip-horizontal-white.svg)}.imgix-pill-v>span.icon{background-image:url(../img/ilab-flip-vertical-black.svg)}.imgix-pill-v.pill-selected>span.icon{background-image:url(../img/ilab-flip-vertical-white.svg)}.imgix-pill-clip>span.icon{background-image:url(../img/ilab-imgix-clip-black.svg)}.imgix-pill-clip.pill-selected>span.icon{background-image:url(../img/ilab-imgix-clip-white.svg)}.imgix-pill-crop>span.icon{background-image:url(../img/ilab-imgix-crop-black.svg)}.imgix-pill-crop.pill-selected>span.icon{background-image:url(../img/ilab-imgix-crop-white.svg)}.imgix-pill-max>span.icon{background-image:url(../img/ilab-imgix-max-black.svg)}.imgix-pill-max.pill-selected>span.icon{background-image:url(../img/ilab-imgix-max-white.svg)}.imgix-pill-scale>span.icon{background-image:url(../img/ilab-imgix-scale-black.svg)}.imgix-pill-scale.pill-selected>span.icon{background-image:url(../img/ilab-imgix-scale-white.svg)}.imgix-preset-make-default-container{align-items:center;display:flex;min-height:30px;margin-left:10px}.imgix-preset-container{align-items:center;display:flex}.imgix-preset-container.is-hidden,.imgix-preset-make-default-container.is-hidden{display:none}.imgix-param-label{font-style:italic;text-transform:none!important}.imgix-label-editor{position:absolute;right:-4px;top:0;width:40px;font-size:11px;padding:1px;text-align:right}.ilabm-focal-point-icon{position:absolute;background-image:url(../img/ilab-imgix-focalpoint-icon.svg);width:24px;height:24px;background-size:contain;pointer-events:none}.ilab-face-outline{position:absolute;border:3px solid #fff;-webkit-filter:drop-shadow(0 2px 3px #000);filter:drop-shadow(0 2px 3px black);opacity:.33;z-index:999;cursor:pointer}.ilab-face-outline span{display:block;position:absolute;background-color:#fff;color:#000;font-size:9px;width:12px;height:12px;text-align:center;font-weight:700;line-height:1}.ilab-face-outline.active{opacity:1;z-index:1000}.ilab-all-faces-outline{position:absolute;border:3px solid #fff;-webkit-filter:drop-shadow(0 2px 3px #000);filter:drop-shadow(0 2px 3px black)}input[type=range].imgix-param{-webkit-appearance:none;-moz-appearance:none;appearance:none}input[type=range].imgix-param:focus{outline:none}input[type=range].imgix-param:focus::-webkit-slider-runnable-track{background:#bababa}input[type=range].imgix-param::-webkit-slider-runnable-track{width:100%;height:17px;cursor:pointer;animate:.2s;background:#cfcfcf;border-radius:17px;box-shadow:none}input[type=range].imgix-param::-moz-range-track{width:100%;height:17px;cursor:pointer;animate:.2s;background:#cfcfcf;border-radius:17px;box-shadow:none}input[type=range].imgix-param::-webkit-slider-thumb{-webkit-appearance:none;cursor:pointer;width:18px;height:17px;border-radius:17px;margin-top:0}input[type=range].imgix-param::-moz-range-thumb{-webkit-appearance:none;cursor:pointer;width:18px;height:17px;border-radius:17px;margin-top:0}.ilab-crop-preview{overflow:hidden;max-width:100%;max-height:100%}.ilab-crop-now-wrapper{margin-top:12px}.ilabc-cropper{max-width:100%;max-height:100%}.ilabm-sidebar-content-cropper{flex-direction:column!important;padding:10px;overflow:scroll}.ilabm-sidebar-content-cropper h3{margin-top:0;font-size:11px;text-transform:uppercase;color:#888;font-weight:700}.cropper-dashed.dashed-h{top:38.4615385%;height:23.076923%}.cropper-dashed.dashed-v{left:38.4615385%;width:23.076923%}.ilabc-current-crop-container{position:relative;margin-bottom:15px}.ilabc-crop-preview-container,.ilabc-current-crop-container{background-image:url(../img/ilab-imgix-edit-bg.png);display:flex;align-items:center;justify-content:center;flex:1}.ilab-current-crop-img{position:absolute;-o-object-fit:contain;object-fit:contain;padding:0!important;margin:0!important;height:100%;width:100%}#ilab-crop-aspect-checkbox-container{display:flex;align-items:center}#ilab-crop-aspect-checkbox-container input{margin:0 8px 0 0;padding:0}#ilab-s3-info-meta .inside{padding:0 5px 10px}.info-panel-tabs{margin:-7px -5px 0;padding:6px 10px 0;background-color:rgba(0,0,0,.125)}.info-panel-tabs ul{display:flex;margin:0;padding:0;height:100%}.info-panel-tabs ul li{padding:5px 10px;font-size:11px;text-transform:uppercase;margin:0 10px 0 0;display:block;background-color:rgba(0,0,0,.0625);cursor:pointer;font-weight:700}.info-panel-tabs ul li.info-panel-missing-sizes{color:#9e0000}.info-panel-tabs ul li.active{background-color:#fff}.info-panel-contents{padding:15px 10px 0}.info-panel-contents .info-line{display:flex;flex-direction:column;margin-bottom:15px}.info-panel-contents .info-line h3,.info-panel-contents .info-line label{font-size:11px;text-transform:uppercase;margin:0;font-weight:700}.info-panel-contents .info-line label{margin-bottom:4px}.info-panel-contents .info-line select{font-size:12px!important}.info-panel-contents .info-line a{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.info-panel-contents .info-notice{padding:10px 5px 20px}.info-panel-contents .info-size-selector{margin-bottom:15px}.info-panel-contents .button-row{margin-bottom:15px;border-top:1px solid #eaeaea;padding-top:15px;display:flex;justify-content:flex-end;align-items:center}.info-panel-contents .button-row #ilab-info-regenerate-status{display:flex;padding:0;justify-content:center;align-items:center;width:100%;font-size:12px}.info-panel-contents .button-row #ilab-info-regenerate-status .spinner{float:none;display:block;margin:0 8px 0 0;width:16px;height:16px;background-size:16px 16px}.info-panel-contents .links-row{display:flex;align-items:center;justify-content:center;background-color:rgba(0,0,0,.05);border:1px solid rgba(0,0,0,.1);border-radius:8px;padding:10px 0;margin-bottom:15px}.info-panel-contents .links-row a{color:#000;display:flex;align-items:center;margin-right:20px;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:11px}.info-panel-contents .links-row a:last-of-type{margin-right:0}.info-panel-contents .links-row a .dashicons{margin-right:3px;width:16px;height:16px;font-size:16px}#ilab-media-grid-info-popup{position:absolute;z-index:170000;opacity:1;transition:opacity .33s;-webkit-filter:drop-shadow(0 0 5px rgba(50,50,50,.5));filter:drop-shadow(0 0 5px rgba(50,50,50,.5));display:flex;align-items:center}#ilab-media-grid-info-popup.hidden{opacity:0;pointer-events:none}#ilab-media-grid-info-popup h2{text-transform:uppercase;font-size:9px;padding:4px 10px;margin:0;color:rgba(0,0,0,.33)}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content{min-height:554px;background-color:#fff;width:275px;max-width:275px;padding-bottom:1px;display:flex;flex-direction:column;position:relative}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .info-panel-tabs{margin:0}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .info-panel-contents>div{display:flex;flex-direction:column}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .info-panel-contents>div>div{flex:1}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .info-panel-contents .info-file-info-size{flex-grow:1;display:flex;flex-direction:column}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .button-row{position:absolute;bottom:0;right:0;left:0}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .ilab-loader-container{display:flex;justify-content:center;align-items:center;position:absolute;left:0;top:0;right:0;bottom:0;transition:opacity .5s}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .ilab-loader,#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .ilab-loader:after{border-radius:50%;width:24px;height:24px}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .ilab-loader{font-size:5px;text-indent:-9999em;border:1.1em solid hsla(0,0%,100%,.2);border-left-color:#fff;-webkit-animation:load8 1.1s linear infinite;animation:load8 1.1s linear infinite}#ilab-media-grid-info-popup .ilab-media-grid-info-popup-content .ilab-loader.ilab-loader-dark{border:1.1em solid rgba(0,0,0,.2);border-left-color:#000}@-webkit-keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}@keyframes load8{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}#ilab-media-grid-info-popup .ilab-media-popup-arrow-left{width:45px;display:flex;justify-content:flex-end}#ilab-media-grid-info-popup .ilab-media-popup-arrow-left>div{width:0;height:0;border-color:transparent #fff transparent transparent;border-style:solid;border-width:9px 15.6px 9px 0}#ilab-media-grid-info-popup .ilab-media-popup-arrow-right{width:45px;display:flex;justify-content:flex-start}#ilab-media-grid-info-popup .ilab-media-popup-arrow-right>div{width:0;height:0;border-color:transparent transparent transparent #fff;border-style:solid;border-width:9px 0 9px 15.6px;margin-right:30px}#ilab-media-grid-info-popup.popup-left .ilab-media-popup-arrow-right,#ilab-media-grid-info-popup.popup-right .ilab-media-popup-arrow-left{display:none}li.attachment{transition:opacity .3s ease-out,transform .3s ease-out,box-shadow .3s ease-out}li.attachment .ilab-loader-container{z-index:100}li.attachment.info-focused{transform:scale(1.1)}li.attachment.info-focused>div:first-of-type{box-shadow:0 0 5px 0 rgba(50,50,50,.5)}li.attachment.info-unfocused{opacity:.33}#ilab-media-grid-info-popup.ilab-popup-document h2{background-color:rgba(0,0,0,.125);color:#000}#ilab-media-grid-info-popup.ilab-popup-document .info-panel-contents{padding:10px 10px 0}#ilab-media-grid-info-popup.ilab-popup-document .ilab-media-grid-info-popup-content{min-height:484px}table.ilab-image-sizes{border-collapse:collapse;width:100%}table.ilab-image-sizes td,table.ilab-image-sizes th{padding:10px}table.ilab-image-sizes td.center{text-align:center}table.ilab-image-sizes thead th{border:2px solid #f1f1f1;background-color:#dadada}table.ilab-image-sizes tr{border-bottom:1px solid #dadada}.ilab-add-image-size-backdrop{display:flex;align-items:center;justify-content:center}.ilab-add-image-size-container{left:auto;right:auto;bottom:auto;top:auto}.ilab-new-image-size-form{padding:20px;display:flex;flex-direction:column}.ilab-new-image-size-form div.row{display:flex;align-items:center;margin-bottom:15px}.ilab-new-image-size-form div.row>label{width:90px;text-align:right;margin-right:15px;font-weight:700}.ilab-new-image-size-form div.button-row{padding:10px;text-align:right}.ilab-delete-size-button{font-size:0;display:inline-block;width:18px;height:18px;background-image:url(../img/ilab-ui-icon-trash.svg);background-size:contain;background-position:50%;background-repeat:no-repeat;background-size:12px;margin-right:10px}.ilab-delete-size-button.disabled{opacity:.33;pointer-events:none}.ilab-delete-size-button:hover{background-image:url(../img/ilab-ui-icon-trash-hover.svg)}.ilab-size-settings-button{font-size:0;display:inline-block;width:18px;height:18px;background-image:url(../img/ilab-ui-icon-settings.svg);background-size:contain;background-position:50%;background-repeat:no-repeat;background-size:14px}.ilab-size-settings-button.disabled{opacity:.33;pointer-events:none}.ilab-size-settings-button:hover{background-image:url(../img/ilab-ui-icon-settings-hover.svg)}.ilab-browser-select-table-container table,.ilab-storage-browser table{border-collapse:collapse;width:100%;font-size:1.1em}.ilab-browser-select-table-container table td,.ilab-browser-select-table-container table th,.ilab-storage-browser table td,.ilab-storage-browser table th{padding:12px}.ilab-browser-select-table-container table thead tr th,.ilab-storage-browser table thead tr th{text-align:left;border:2px solid #f1f1f1;background-color:#dadada}.ilab-browser-select-table-container table thead tr th.checkbox,.ilab-storage-browser table thead tr th.checkbox{max-width:30px;width:30px;text-align:center}.ilab-browser-select-table-container table tbody tr,.ilab-storage-browser table tbody tr{transition:background-color .125s linear;cursor:pointer}.ilab-browser-select-table-container table tbody tr:hover,.ilab-storage-browser table tbody tr:hover{background-color:#fff}.ilab-browser-select-table-container table tbody tr input[type=checkbox],.ilab-storage-browser table tbody tr input[type=checkbox]{z-index:1000}.ilab-browser-select-table-container table tbody tr td,.ilab-storage-browser table tbody tr td{text-decoration:none}.ilab-browser-select-table-container table tbody tr td.checkbox,.ilab-storage-browser table tbody tr td.checkbox{max-width:30px;width:30px;text-align:center}.ilab-browser-select-table-container table tbody tr td.entry,.ilab-storage-browser table tbody tr td.entry{display:flex;align-items:center}.ilab-browser-select-table-container table tbody tr td.actions,.ilab-storage-browser table tbody tr td.actions{text-align:center;width:130px;max-width:130px}.ilab-browser-select-table-container table tbody tr td.actions .button-delete,.ilab-storage-browser table tbody tr td.actions .button-delete{margin-right:0;margin-left:10px;color:#fff;border-color:#920002;background:#ca0002;box-shadow:0 1px 0 #cc0005}.ilab-browser-select-table-container table tbody tr td.actions .button-delete svg,.ilab-storage-browser table tbody tr td.actions .button-delete svg{height:14px}.ilab-browser-select-table-container table tbody tr td.actions .button-delete.disabled,.ilab-storage-browser table tbody tr td.actions .button-delete.disabled{color:#ff6468!important;border-color:#920002!important;background:#c6282a!important;box-shadow:0 1px 0 #cc0005!important;text-shadow:0 1px 0 #cc0005!important}.ilab-browser-select-table-container table tbody tr td.actions .button-delete.disabled svg>path,.ilab-browser-select-table-container table tbody tr td.actions .button-delete.disabled svg>rect,.ilab-storage-browser table tbody tr td.actions .button-delete.disabled svg>path,.ilab-storage-browser table tbody tr td.actions .button-delete.disabled svg>rect{fill:#ff6468}.ilab-browser-select-table-container table tbody tr td img.loader,.ilab-storage-browser table tbody tr td img.loader{display:none;margin-right:10px;width:16px;height:16px}.ilab-browser-select-table-container table tbody tr td span,.ilab-storage-browser table tbody tr td span{display:block;width:16px;height:16px;background-size:contain;background-repeat:no-repeat;margin-right:10px}.ilab-browser-select-table-container table tbody tr td span.icon-dir,.ilab-storage-browser table tbody tr td span.icon-dir{background-image:url(../img/ilab-ui-icon-folder.svg)}.ilab-browser-select-table-container table tbody tr td span.icon-file,.ilab-storage-browser table tbody tr td span.icon-file{background-image:url(../img/ilab-ui-icon-file.svg)}.ilab-browser-select-table-container table tbody tr td span.icon-up,.ilab-storage-browser table tbody tr td span.icon-up{background-image:url(../img/ilab-ui-icon-up-dir.svg)}.ilab-browser-select-table-container table tr,.ilab-storage-browser table tr{border-bottom:1px solid #dadada}.mcsb-buttons .button{margin-right:5px;display:flex;align-items:center}.mcsb-buttons .button svg{height:16px;width:auto;margin-right:8px}.mcsb-buttons .button svg>path,.mcsb-buttons .button svg>rect{fill:#fff}.mcsb-buttons .button-primary.disabled svg>path,.mcsb-buttons .button-primary.disabled svg>rect{fill:#66c6e4}.mcsb-buttons .button-create-folder svg{height:12px}.mcsb-buttons .button-import{margin-left:10px}.mcsb-buttons .button-import svg{height:14px}.mcsb-buttons .button-delete{margin-right:0;margin-left:10px;color:#fff;border-color:#920002;background:#ca0002;box-shadow:0 1px 0 #cc0005}.mcsb-buttons .button-delete svg{height:14px}.mcsb-buttons .button-delete.disabled{color:#ff6468!important;border-color:#920002!important;background:#c6282a!important;box-shadow:0 1px 0 #cc0005!important;text-shadow:0 1px 0 #cc0005!important}.mcsb-buttons .button-delete.disabled svg>path,.mcsb-buttons .button-delete.disabled svg>rect{fill:#ff6468}.mcsb-buttons .button-cancel{color:#fff;border-color:#920002;background:#ca0002;text-shadow:0 1px 0 #cc0005!important;box-shadow:0 1px 0 #cc0005}.mcsb-buttons .button-cancel:hover{border-color:#9f0002;background:#d80002;text-shadow:0 1px 0 #d60005!important;box-shadow:0 1px 0 #d60005}.mcsb-actions{margin-bottom:18px;font-size:1.1em}.mcsb-actions,.mcsb-actions div.mcsb-action-buttons{display:flex;align-items:center}.ilab-storage-browser-header{flex:1;padding:14px 9px;box-shadow:inset 0 0 3px 0 rgba(0,0,0,.125);border:1px solid #ddd;border-radius:8px;margin-right:18px}.ilab-storage-browser-header ul{margin:0;padding:0;display:flex}.ilab-storage-browser-header ul li{padding:0;position:relative;display:block;margin:0 30px 0 0}.ilab-storage-browser-header ul li a{text-decoration:none}.ilab-storage-browser-header ul li:first-of-type{padding-left:35px}.ilab-storage-browser-header ul li:first-of-type:before{background-image:url(../img/ilab-ui-icon-folder.svg);width:16px;height:16px;left:0}.ilab-storage-browser-header ul li:after,.ilab-storage-browser-header ul li:first-of-type:before{content:" ";position:absolute;background-size:contain;background-position:50%;background-repeat:no-repeat;top:50%;margin-left:10px;transform:translateY(-50%)}.ilab-storage-browser-header ul li:after{background-image:url(../img/ilab-ui-path-divider.svg);width:9px;height:9px}.ilab-storage-browser-header ul li:last-of-type:after{display:none}#mcsb-progress-modal{z-index:10000;position:fixed;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.66);display:flex;align-items:center;justify-content:center;transition:opacity .15s linear;opacity:1;pointer-events:none}#mcsb-progress-modal.hidden{opacity:0}#mcsb-progress-modal .mcsb-progress-container{min-width:40vw;background-color:#fff;padding:30px}#mcsb-progress-modal .mcsb-progress-container .mcsb-progress-label{font-weight:700;font-size:1.1em;margin-bottom:20px}#mcsb-progress-modal .mcsb-progress-container .mcsb-progress-bar{position:relative;background-color:#eaeaea;height:24px;border-radius:12px;overflow:hidden}#mcsb-progress-modal .mcsb-progress-container .mcsb-progress-bar #mcsb-progress{position:absolute;left:0;top:0;bottom:0;background-color:#4f90c4}#mcsb-import-options-modal{z-index:10000;position:fixed;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.66);display:flex;align-items:center;justify-content:center;transition:opacity .15s linear;opacity:1;pointer-events:none}#mcsb-import-options-modal.hidden{opacity:0}#mcsb-import-options-modal.hidden .mcsb-import-options-container{pointer-events:none}#mcsb-import-options-modal .mcsb-import-options-container{min-width:40vw;max-width:800px;background-color:#fff;padding:30px;pointer-events:all;display:flex;flex-direction:column}#mcsb-import-options-modal .mcsb-import-options-container h3{display:block;padding:0;margin:0 0 25px;position:relative;font-weight:700;font-size:1.125em}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options{margin-bottom:50px}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options ul{display:grid;grid-template-columns:repeat(1,1fr);grid-row-gap:20px;grid-column-gap:10px}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options ul li{display:flex;align-items:flex-start}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options ul li h4{margin:0;padding:0;font-size:1em}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options ul li .mcsb-option{padding-top:2px}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-options ul li .mcsb-option-description{margin-left:15px}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-buttons{display:flex;justify-content:flex-end}#mcsb-import-options-modal .mcsb-import-options-container div.mcsb-import-buttons .button{margin:0 0 0 20px}#ilab-upload-target{position:fixed;left:0;right:0;bottom:0;top:0;display:flex;justify-content:center;align-items:center;font-size:2em;font-weight:700;color:#fff;background-color:rgba(28,90,129,.75);z-index:100000;transition:opacity .125s linear;opacity:0;pointer-events:none}#wpbody.drag-inside #ilab-upload-target{opacity:1}#mcsb-upload-modal{position:fixed;left:0;right:0;bottom:0;top:0;display:flex;justify-content:center;align-items:center;background:rgba(0,0,0,.66);z-index:100000;transition:opacity .125s linear;opacity:1}#mcsb-upload-modal.hidden{opacity:0;pointer-events:none}#mcsb-upload-modal #mcsb-upload-container{min-width:630px;min-height:385px;background-color:#fff;display:flex;flex-direction:column}#mcsb-upload-modal #mcsb-upload-container div.mcsb-upload-header{padding:20px;position:relative;font-weight:700}#mcsb-upload-modal #mcsb-upload-container div.mcsb-upload-items{position:relative;flex:1;background-color:#eaeaea}#mcsb-upload-modal #mcsb-upload-container div.mcsb-upload-items #mcsb-upload-items-container{padding:15px;position:absolute;left:0;top:0;right:0;bottom:0;overflow:auto;display:flex;flex-wrap:wrap}.ilab-browser-select{position:absolute;left:0;top:0;width:100%;height:100%;display:flex;flex-direction:column}.ilab-browser-select .ilab-browser-select-header{height:48px;min-height:48px;padding-left:12px;padding-right:64px;display:flex;align-items:center}.ilab-browser-select .ilab-browser-select-header input{flex:1;padding:7px 11px;border-radius:4px}.ilab-browser-select .ilab-browser-select-header input:disabled{color:#000}.ilab-browser-select .ilab-browser-select-table-container{flex:1;overflow-y:auto;background-color:#efefef}.ilab-browser-select .ilab-browser-select-footer{height:48px;min-height:48px;display:flex;align-items:center;justify-content:flex-end;padding-right:12px}.ilab-browser-select .ilab-browser-select-footer .button{margin-left:12px}.mcsb-modal-contents{border-radius:8px}.mcsb-modal-contents h3{background-image:url(../img/icon-cloud.svg);background-position:0;background-repeat:no-repeat;background-size:44px 44px;padding:12px 0 12px 60px!important}#task-manager div.available-tasks{padding:15px 20px 10px;display:flex;flex-direction:column;border-radius:8px;margin-bottom:25px;margin-top:30px;background-color:#e4e4e4}#task-manager div.available-tasks h2{margin:0 0 15px;padding:0;text-transform:uppercase;font-size:11px;color:#777}#task-manager div.available-tasks div.buttons{display:flex;flex-wrap:wrap}#task-manager div.available-tasks div.buttons .button{margin:0 10px 10px 0}#task-manager div.task-list{padding:18px 20px;border-radius:8px;background-color:#e4e4e4;margin-bottom:25px}#task-manager div.task-list h2{margin:0 0 15px;padding:0;text-transform:uppercase;font-size:11px;color:#777;display:flex;align-items:center;justify-content:space-between}#task-manager div.task-list table.task-table{width:100%;font-size:.9em}#task-manager div.task-list table.task-table td,#task-manager div.task-list table.task-table th{text-align:left;white-space:nowrap;padding:10px 20px;background-color:#efefef}#task-manager div.task-list table.task-table td.progress,#task-manager div.task-list table.task-table td.schedule,#task-manager div.task-list table.task-table th.progress,#task-manager div.task-list table.task-table th.schedule{width:100%}#task-manager div.task-list table.task-table th{background-color:#3a5674;color:#fff}#task-manager div.task-list table.task-table th:first-of-type{border-top-left-radius:4px}#task-manager div.task-list table.task-table th:last-of-type{border-top-right-radius:4px}#task-manager div.task-list table.task-table td.status{text-transform:capitalize}#task-manager div.task-list table.task-table td.status.status-complete{font-weight:700;color:green}#task-manager div.task-list table.task-table td.status.status-error{font-weight:700;color:#a70000}#task-manager div.task-list table.task-table td.progress{position:relative}#task-manager div.task-list table.task-table td.progress div.progress-bar{position:absolute;left:10px;top:10px;bottom:10px;right:10px;background-color:#ccc;display:flex;align-items:center;justify-content:center;overflow:hidden;border-radius:4px}#task-manager div.task-list table.task-table td.progress div.progress-bar .bar{position:absolute;left:0;top:0;bottom:0;width:75%;background-color:#50ade2}#task-manager div.task-list table.task-table td.progress div.progress-bar .amount{z-index:2;color:#fff;font-weight:700}#task-manager div.task-list table.task-table tbody tr:last-of-type td:first-of-type{border-bottom-left-radius:4px}#task-manager div.task-list table.task-table tbody tr:last-of-type td:last-of-type{border-bottom-right-radius:4px}.task-options-modal{position:fixed;left:0;top:0;right:0;bottom:0;background:rgba(0,0,0,.75);z-index:100000;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear}.task-options-modal.invisible{opacity:0}.task-options-modal.invisible .task-modal{transform:scale(.95)}.task-options-modal .task-modal{background-color:#fff;padding:30px;border-radius:8px;transition:transform .25s ease-in-out}.task-options-modal .task-modal h2{padding:0;font-size:1.2em;margin:0 0 40px}.task-options-modal .task-modal form ul{padding:0;display:flex;flex-direction:column;margin:20px 0 0}.task-options-modal .task-modal form ul li{display:flex;margin-bottom:30px}.task-options-modal .task-modal form ul li:last-of-type{margin-bottom:0}.task-options-modal .task-modal form ul li>div:first-of-type{padding:10px 10px 20px 0;width:160px;min-width:160px;line-height:1.3;font-weight:600}.task-options-modal .task-modal form ul li>div:last-of-type{flex:1}.task-options-modal .task-modal form ul li div.description{margin-top:8px}.task-options-modal .task-modal form ul li div.option-ui{display:flex;align-items:center;width:100%}.task-options-modal .task-modal form ul li div.option-ui.option-ui-browser input[type=text]{flex:1;margin-right:10px;padding:7px 11px;border-radius:4px}.task-options-modal .task-modal form ul li div.option-ui.option-ui-browser input[type=text]:disabled{color:#000}.task-options-modal .task-modal form ul li div.option-ui.option-ui-media-select{display:flex;flex:1}.task-options-modal .task-modal form ul li div.option-ui.option-ui-media-select .media-select-label{flex:1;box-sizing:border-box;margin-right:10px;padding:7px 11px;border-radius:4px;background-color:hsla(0,0%,100%,.498039);border:1px solid hsla(0,0%,87.1%,.74902)}.task-options-modal .task-modal form ul li div.option-ui.option-ui-media-select .button{margin-right:5px}.task-options-modal .task-modal div.buttons{margin-top:40px;display:flex;justify-content:flex-end}.task-options-modal .task-modal div.buttons .button{margin-left:15px}#task-batch div.buttons{display:flex;justify-content:flex-end;margin-top:40px}#task-batch div.buttons .button-whoa{background:#a42929!important;border-color:#e62a2a #a42929 #a42929!important;box-shadow:0 1px 0 #a42929!important;color:#fff!important;text-decoration:none!important;text-shadow:0 -1px 1px #a42929,1px 0 1px #a42929,0 1px 1px #a42929,-1px 0 1px #a42929!important}#task-batch div.task-info .info-warning{border:1px solid orange;padding:24px;background:rgba(255,165,0,.125);margin-top:20px;border-radius:8px}#task-batch div.task-info .info-warning h4{padding:0;font-size:14px;margin:0 0 8px}#task-batch div.task-info .wp-cli-callout{padding:24px;background:#ddd;margin-top:20px;border-radius:8px}#task-batch div.task-info .wp-cli-callout h3{margin:0;padding:0;font-size:14px}#task-batch div.task-info .wp-cli-callout code{background-color:#bbb;padding:10px 15px;margin-top:5px;display:inline-block}#task-batch div.task-info .task-options{padding:24px;background:#e7e7e7;margin-top:20px;border-radius:8px}#task-batch div.task-info .task-options h3{margin:0;padding:0;font-size:14px}#task-batch div.task-info .task-options ul{padding:0;display:flex;flex-direction:column;margin:20px 0 0}#task-batch div.task-info .task-options ul li{display:flex;margin-bottom:30px}#task-batch div.task-info .task-options ul li:last-of-type{margin-bottom:0}#task-batch div.task-info .task-options ul li>div:first-of-type{padding:10px 10px 20px 0;width:160px;min-width:160px;line-height:1.3;font-weight:600}#task-batch div.task-info .task-options ul li div.description{margin-top:8px}#task-batch div.task-info .task-options ul li div.option-ui{display:flex;align-items:center}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-browser{display:flex;width:50vw}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-browser input[type=text]{flex:1;margin-right:10px;padding:7px 11px;border-radius:4px}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-browser input[type=text]:disabled{color:#000}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-media-select{display:flex;width:50vw}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-media-select .media-select-label{flex:1;box-sizing:border-box;margin-right:10px;padding:7px 11px;border-radius:4px;background-color:hsla(0,0%,100%,.498039)}#task-batch div.task-info .task-options ul li div.option-ui.option-ui-media-select .button{margin-right:5px}#task-batch div.task-progress{padding:24px;background:#ddd;border-radius:8px}#task-batch div.task-progress .progress-container{position:relative;width:100%;height:14px;background:#aaa;border-radius:16px;overflow:hidden;background-image:url(../img/candy-stripe.svg)}#task-batch div.task-progress .progress-container .progress-bar{background-color:#4f90c4;height:100%;width:10px}#task-batch div.task-progress .progress-thumbnails{position:relative;width:100%;height:150px;margin-bottom:15px}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container{position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;-webkit-mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%)}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container img{width:150px;height:150px;max-width:150px;max-height:150px;border-radius:4px;margin-right:10px}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container .item-title{color:#fff;position:absolute;right:10px;bottom:7px;text-align:right;left:10px;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;text-shadow:1px 1px 2px rgba(0,0,0,.75);font-weight:700}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container .progress-thumb{position:absolute;left:0;top:0;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;background-size:cover;background-position:50%;background-repeat:no-repeat;margin-right:10px;border-radius:4px;background-color:#888;transition:opacity .25s linear,transform .25s linear}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container .progress-thumb.invisible{opacity:0;transform:scale(.7)}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container .progress-icon{position:absolute;left:0;top:0;position:relative;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear,transform .25s linear}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-container .progress-icon.invisible{opacity:0;transform:scale(.8)}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-fade{background:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);position:absolute;left:150px;top:0;right:0;bottom:0}@supports ((-webkit-mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%)) or (mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%))){#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-fade{display:none}}#task-batch div.task-progress .progress-thumbnails .progress-thumbnails-cloud{position:absolute;right:20px;top:50%;transform:translateY(-50%)}#task-batch div.task-progress .progress-stats{margin-top:20px;display:flex;align-items:center;justify-content:center}@media (max-width:960px){#task-batch div.task-progress .progress-stats{flex-direction:column;align-items:flex-start;justify-content:flex-start}}#task-batch div.task-progress .progress-stats div.group-break{display:flex;margin-right:1.2195121951vw}#task-batch div.task-progress .progress-stats div.group-break:last-of-type{margin-right:0}#task-batch div.task-progress .progress-stats div.group-break:first-of-type{flex:1}@media (max-width:960px){#task-batch div.task-progress .progress-stats div.group-break{width:100%;margin-bottom:1.2195121951vw}}#task-batch div.task-progress .progress-stats div.group{display:flex;align-items:center;padding:1.0975609756vw 0;background-color:#e6e6e6;border-radius:8px;margin-right:1.2195121951vw}#task-batch div.task-progress .progress-stats div.group *{white-space:nowrap}@media (max-width:960px){#task-batch div.task-progress .progress-stats div.group.mobile-flexed{flex:1}}#task-batch div.task-progress .progress-stats div.group.flexed{flex:1}#task-batch div.task-progress .progress-stats div.group:last-of-type{margin-right:0}#task-batch div.task-progress .progress-stats div.group div.callout{position:relative;margin-right:.6097560976vw;padding:0 1.4634146341vw}#task-batch div.task-progress .progress-stats div.group div.callout:after{display:block;position:absolute;content:"";height:50%;width:1px;right:0;top:25%;background-color:rgba(0,0,0,.25)}#task-batch div.task-progress .progress-stats div.group div.callout:last-of-type:after{display:none}#task-batch div.task-progress .progress-stats div.group div.callout p.value{line-height:1;padding:0;font-size:1.5853658537vw;font-weight:300;margin:0 0 .487804878vw}#task-batch div.task-progress .progress-stats div.group div.callout p.value.status{text-transform:capitalize}@media (max-width:960px){#task-batch div.task-progress .progress-stats div.group div.callout p.value{font-size:2.9268292683vw}}#task-batch div.task-progress .progress-stats div.group div.callout h4{line-height:1;margin:0;padding:0;font-size:.6097560976vw;text-transform:uppercase}@media (max-width:960px){#task-batch div.task-progress .progress-stats div.group div.callout h4{font-size:.8536585366vw}} -/*! mediabox v1.1.3 | (c) 2018 Pedro Rogerio | https://github.com/pinceladasdaweb/mediabox */.stop-scroll{height:100%;overflow:hidden}.mediabox-wrap{position:fixed;width:100%;height:100%;background-color:rgba(0,0,0,.8);top:0;left:0;opacity:0;z-index:999;-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:mediabox;animation-name:mediabox}@-webkit-keyframes mediabox{0%{opacity:0}to{opacity:1}}@keyframes mediabox{0%{opacity:0}to{opacity:1}}.mediabox-content{max-width:853px;display:block;margin:0 auto;height:100%;position:relative}.mediabox-content iframe{max-width:100%!important;width:100%!important;display:block!important;height:480px!important;border:none!important;position:absolute;top:0;bottom:0;margin:auto 0}.mediabox-hide{-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:mediaboxhide;animation-name:mediaboxhide}@-webkit-keyframes mediaboxhide{0%{opacity:1}to{opacity:0}}@keyframes mediaboxhide{0%{opacity:1}to{opacity:0}}.mediabox-close{position:absolute;top:0;cursor:pointer;bottom:528px;right:0;margin:auto 0;width:24px;height:24px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMvSURBVHja7Js9aBRBFMd/d1lPY6FiJVjY+Fkoxl7wA1Q0prQRS6tgoZV2MWIRRVHUUq3U+JnESrS2sBXBzipREWMlATXwt8gFznC5nd15M7Nn8uC45nZnfr/dY96+N1uTxFKOOks8lgUU/H2t4tJqIQUcAiaBGeBymcECRgO4B/wBPgJ9zkdKcvkclfRL/8ZtSTXH40N+GpLGF8zth6Q9Lse7DHCsDXxVJLSDLyQhb4B+Sb/VOVJJ6ATfKqGvrIDjDvCpJLjAz8d0JwmLDTBQAD62hIakiYJzm5a021VAfwn4WBLKwLdK2JUnIJP0XX4RSoIP/Hy8W3jeepv1dL3nmjwI3DLOExrAU2DA8zwb8xKhGeCuwYQtJTSAZwbwAHdcEqFM0mPZhO/foSHppdFcrraby2IDV0FCcPi8PCClhCjwLplgCgkrDeGv5I3pcjViSogK7yogloTo8EUEhJaQBL6oAGsJ9yVtkrRD0qsU8JKolagKZ8AD4ETFymFXgPOAQpXE5mMWOAk86XZ4n6pwlSSUhvcti1dBghe8RV8gpYQRX3irxkgKCSPABV94y85QTAlm8NatsRgSTOGBUnmAS57w3KiA0Ro3gHOW8KEEAOwE3hvfXWubFauu6A6vCND07OmW9viq5vpsGT3AtRAN2XoA+BfAwQBiTweoNpMZw48BRwKuAoPN7zNVWwZjwAfpO9S7DN5cQmYAPw4cTvAsYPJ3qHcpvNmdUO9ieBMJZQT0AhMVgfeWUC8BP87cjjHfuA6sATY0c4c0EgpUUHslvTaq3l5aUL1N1oarAnxSCVWBTyYhJvyw41XJJI3GkpAH/yYyfHQJi01gdUL4qBKqCh9NQrtBx4wGvGi0XS6T9MhoTkN5AtZVDN5awlTePsGfwDfPjGwYGDKu3s4Cp4BRz/N8cskED0iaqciVt7wTvkra5roKlJEQGt5HwhdJ24vmAUUkDEV+VyCT9NBxbp/bXXnXTNBFQmz4IhI6wrs+C+zvICEVvIuEKUlbrZ4G97WRkBq+k4RJSVusd4ntlfSheVudrQh8q4SbmntH6K2kzSF3if1Xsfzq7LKAJR5/BwCdAQBJn4egPgAAAABJRU5ErkJggg==") no-repeat;background-size:24px 24px}.mediabox-close:hover{opacity:.5}@media (max-width:768px){.mediabox-content{max-width:90%}}@media (max-width:600px){.mediabox-content iframe{height:320px!important}.mediabox-close{bottom:362px}}@media (max-width:480px){.mediabox-content iframe{height:220px!important}.mediabox-close{bottom:262px}}.mediabox-wrap{z-index:1000000}.mediabox-content{max-width:75vw}.mediabox-content iframe{height:42.1875vw!important}.mediabox-close{bottom:46vw}.ic-Super-toggle__label{box-sizing:border-box;margin:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle__label{display:inline-flex;align-items:center}.ic-Super-toggle__input{opacity:0;position:absolute;top:0;left:0}.ic-Super-toggle__input:checked~label .ic-Super-toggle-switch:after{transform:translate3d(100%,0,0)}.ic-Super-toggle__input:checked~label .ic-Super-toggle__disabled-msg:before{content:attr(data-checked)}.ic-Super-toggle__input[disabled]{opacity:0!important}.ic-Super-toggle__input[disabled]~label .ic-Super-toggle-switch{opacity:.33}.ic-Super-toggle-switch{transition:background .1s,border-color .1s;display:inline-block;position:relative;line-height:1;display:flex;align-items:center;background-clip:padding-box}.ic-Super-toggle-switch:after{transition:all .1s ease-in-out;content:"";position:absolute;top:0;left:0;transform:translateZ(0);border-radius:100%;box-shadow:0 3px 6px rgba(0,0,0,.3);background-image:url(https://cl.ly/320m31452k2X/handle.svg);background-position:50% 50%;background-repeat:no-repeat;background-size:20px}.ic-Super-toggle__disabled-msg{display:none}.ic-Super-toggle__disabled-msg:before{content:attr(data-unchecked);font-style:italic;opacity:.8}[class^=ic-Super-toggle-option-]{transition:all .2s ease-out;flex:0 0 50%;text-align:center;position:relative;z-index:1;text-transform:uppercase;font-weight:700;line-height:1;speak:none;box-sizing:border-box}.ic-Super-toggle__screenreader{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute}.ic-Super-toggle--on-off{display:inline-block;vertical-align:middle}.ic-Super-toggle--on-off .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#4cace3;border-color:#4cace3}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #4cace3,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--on-off .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle--on-off .ic-Super-toggle-switch{flex:0 0 50px}.ic-Super-toggle--on-off .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--on-off [class^=ic-Super-toggle-option-]{transition-delay:.1s}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT{transform:scale(.1);opacity:0}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT,.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{transform:scale(1);opacity:1}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{transform:scale(.1);opacity:0}.toggle-warning{display:inline-block;vertical-align:middle}.toggle-warning .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#ffaa10;border-color:#ffaa10}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #ffaa10,0 3px 6px rgba(0,0,0,.3)}.toggle-warning .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .toggle-warning .ic-Super-toggle-switch{flex:0 0 50px}.toggle-warning .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.toggle-warning .ic-Super-toggle-option-LEFT{color:#fff}.toggle-warning .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle-option-RIGHT{color:#fff}.toggle-warning .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--ui-switch{display:inline-block;vertical-align:middle}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#5b6c79;border-color:#5b6c79}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle--ui-switch .ic-Super-toggle-switch{flex:0 0 50px}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT{color:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT{color:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--ui-switch .ic-Super-toggle__label{display:inline-flex;align-items:center}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch{display:block}.ic-Super-toggle--ui-switch [class^=ic-Super-toggle-option-]{flex:none;min-width:24px}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT{text-align:left;transform:scale(1.1)}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT{text-align:right;transform:scale(.9)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{transform:scale(.9)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{transform:scale(1.1)}.settings-container{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;margin:0 0 64px -20px}.settings-container header{position:relative;background-image:url(../img/settings-bg-large.svg);background-position:0;background-size:cover;height:80px;width:100%;display:flex;align-items:center}.settings-container header>img{margin:0 20px;width:88px;max-width:88px}.settings-container header h1{margin-left:5px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;text-transform:uppercase;font-weight:400;font-size:1.5em;color:#777}.settings-container header .header-actions{position:absolute!important;right:40px;top:50%;transform:translateY(-50%)!important;display:flex}.settings-container header .header-actions a{margin-left:8px;display:flex;align-items:center}.settings-container header .header-actions a svg{height:16px;width:auto;margin-right:8px}.settings-container header .header-actions a svg>path,.settings-container header .header-actions a svg>rect{fill:#fff}.settings-container header .header-actions div.spacer{width:8px;min-width:8px}.settings-container header.all-settings{position:relative;height:104px;background-image:url(../img/settings-bg-large.svg)}.settings-container header.all-settings>img{margin:0;position:absolute;left:23px;top:50%;transform:translateY(-50%);width:108px;max-width:108px}.settings-container header.all-settings div.settings-select-container{background-color:hsla(0,0%,100%,.6);padding:10px 14px;border-radius:8px;position:absolute;right:30px;top:50%;transform:translateY(-50%);z-index:1000}.settings-container header.all-settings div.settings-select-container nav.dropdown{display:flex;align-items:center;z-index:1000}.settings-container header.all-settings div.settings-select-container nav.dropdown>div:first-of-type{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;margin-right:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:1em}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown{position:relative;width:200px;height:36px;z-index:1000;cursor:pointer}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.current{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;display:flex;align-items:center;position:absolute;left:0;top:0;right:0;bottom:0;background-color:#eee;border:1px solid #ddd;padding-left:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:13px;cursor:pointer;background-image:url(../img/icon-dropdown-arrow.svg);background-repeat:no-repeat;background-position:right 12px center;transition:background-color .15s linear}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.current:hover{background-color:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items{z-index:1001;position:absolute;top:0;left:0;right:0;transition:opacity .15s linear,transform .15s linear;opacity:0;pointer-events:none}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items.visible{pointer-events:auto;opacity:1}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul{margin:0;padding:0;box-shadow:0 0 8px 1px rgba(0,0,0,.125)}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li{position:relative;margin:0;padding:0;border:1px solid #ddd;border-top:0;align-items:center}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li:first-of-type{border:1px solid #ddd}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool{position:relative;display:flex;align-items:center;height:36px;background-color:#eee;padding-left:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:13px;transition:background-color .15s linear}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool:hover{background:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool-pin{display:block;position:absolute;top:0;width:36px;height:36px;right:0;background-image:url(../img/icon-pin-deselected.svg);background-repeat:no-repeat;background-position:50%}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool-pin.pinned{background-image:url(../img/icon-pin-selected.svg)}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li.active a.tool{background:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown.active div.dropdown div.current{background-color:#ddd}.settings-container .settings-body{margin:20px}.settings-container .settings-body .settings-description{font-size:1.1em;text-align:center;background-color:#fafafa;padding:25px;border-radius:8px;margin-bottom:20px}.settings-container .settings-body.show-upgrade{display:flex}.settings-container .settings-body.show-upgrade>.settings-interior{flex:1;margin-right:20px}@media (max-width:64em){.settings-container .settings-body.show-upgrade>.settings-interior{order:1;margin-right:0}}@media (max-width:64em){.settings-container .settings-body.show-upgrade{flex-direction:column}}.settings-container .settings-body .upgrade-feature{background-color:#fafafa;border-radius:8px;padding:15px 20px}.settings-container .settings-body .upgrade-feature h2{padding:0;margin:0 0 30px;color:#46a4dd}.settings-container .settings-body .upgrade-feature ul{margin-left:20px;list-style:unset}.settings-container .settings-body .upgrade-feature ul li{list-style-type:square}.settings-container .settings-body .upgrade-feature div.button-container{text-align:right;padding:20px 0}.settings-container .settings-body .upgrade-feature div.button-container a{padding:10px;background-color:#46a4dd;border-radius:6px;color:#fff;text-decoration:none;font-weight:700;font-size:1.1em}.settings-container .settings-body .upgrade-promo{min-width:200px;max-width:320px;position:relative}.settings-container .settings-body .upgrade-promo .upgrade-interior{position:relative;background-color:#fafafa;border-radius:8px;padding:15px 20px}.settings-container .settings-body .upgrade-promo .upgrade-interior h2{padding:0;margin:0 0 30px;color:#46a4dd}.settings-container .settings-body .upgrade-promo .upgrade-interior ul{margin-left:20px}.settings-container .settings-body .upgrade-promo .upgrade-interior ul li{list-style-type:square}@media (max-width:64em){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{display:flex;flex-wrap:wrap;width:100%}@supports (display:grid){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{display:grid;grid-template-columns:1fr 1fr 1fr}}.settings-container .settings-body .upgrade-promo .upgrade-interior ul li{margin-right:30px}}@media (max-width:48.9275em){@supports (display:grid){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{grid-template-columns:1fr 1fr}}}.settings-container .settings-body .upgrade-promo .upgrade-interior div.button-container{text-align:right;padding:20px 0}.settings-container .settings-body .upgrade-promo .upgrade-interior div.button-container a{padding:10px;background-color:#46a4dd;border-radius:6px;color:#fff;text-decoration:none;font-weight:700;font-size:1.1em}.settings-container .settings-body .upgrade-promo .upgrade-interior a.upgrade-close{display:none;position:absolute;top:15px;right:20px}@media (max-width:64em){.settings-container .settings-body .upgrade-promo .upgrade-interior a.upgrade-close{display:block}}@media (max-width:64em){.settings-container .settings-body .upgrade-promo{order:0;margin-bottom:20px;max-width:100%}}@media (max-width:64em){.settings-container .settings-body .upgrade-promo.hide-on-mobile{display:none}}.button-warning{background:#dd9000!important;border-color:#dd9000 #b97800 #b97800!important;box-shadow:0 1px 0 #b97800!important;color:#fff!important;text-decoration:none!important;text-shadow:0 -1px 1px #b97800,1px 0 1px #b97800,0 1px 1px #b97800,-1px 0 1px #b97800!important}.media-cloud-tool-description{padding:24px;background:#ddd;border-radius:8px;margin-bottom:20px}.media-cloud-tool-description h2{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;text-transform:uppercase;margin:0 0 5px;padding:0}.media-cloud-tool-description p{margin-top:0;font-size:1.2em}.ilab-notification-container .notice{margin-left:0;margin-right:0;margin-bottom:10px}.ilab-notification-container .notice:last-of-type{margin-bottom:20px}.ilab-settings-section{background-color:#fafafa;padding:25px;border-radius:8px;margin-bottom:20px;overflow:hidden}.ilab-settings-section h2{padding:10px 25px;background-color:#ddd;margin:-25px -25px 0;font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;font-weight:700;font-size:13px;color:rgba(0,0,0,.5)!important;text-transform:uppercase;display:flex;align-items:center}.ilab-settings-section h2 a.help-beacon{margin:0 0 0 10px;padding:0;display:block;width:16px;height:16px;color:transparent;overflow:hidden;background-image:url(../img/mcloud-icon-help.svg);background-position:50%;background-size:contain;background-repeat:no-repeat}.ilab-settings-section .section-description{margin-top:20px;margin-bottom:15px;font-style:italic}.ilab-settings-section .checkbox-w-description{display:flex;align-items:center}.ilab-settings-section .checkbox-w-description label{margin-right:20px}.ilab-settings-section .checkbox-w-description>div>p{margin:0}.ilab-settings-toggle{padding:0 25px 5px}.ilab-settings-toggle table.form-table tr{display:flex;flex-direction:row;align-items:center}@media (max-width:48.9275em){.ilab-settings-toggle table.form-table tr{flex-direction:column;align-items:flex-start}}.ilab-settings-toggle table.form-table tr th{min-width:200px;max-width:200px}@media (max-width:48.9275em){.ilab-settings-toggle table.form-table tr{margin-bottom:20px}.ilab-settings-toggle table.form-table tr th{margin-bottom:10px}}.ilab-settings-features{padding:10px 25px 15px}.ilab-settings-features table.form-table tr{display:flex;flex-direction:row;align-items:center}.ilab-settings-features table.form-table tr td.toggle{display:flex;align-items:center;max-width:220px;min-width:220px}.ilab-settings-features table.form-table tr td.toggle div.title{display:flex;flex-direction:column;margin-left:30px;white-space:nowrap;font-weight:700;font-size:1.05em}.ilab-settings-features table.form-table tr td.toggle div.title a{margin-top:5px;font-size:.85em;font-weight:400}.ilab-settings-features table.form-table tr td.description p{font-size:1.05em}@media (max-width:48.9275em){.ilab-settings-features table.form-table tr{flex-direction:column;align-items:flex-start;margin-bottom:30px}.ilab-settings-features table.form-table td.toggle div.title{font-size:1.2em!important}}.ilab-settings-button{display:flex;justify-content:center}.ilab-settings-button p{padding:0;margin:0}.ilab-settings-batch-tools{display:flex;padding-right:10px;margin-right:20px;border-right:1px solid #ccc}.ilab-settings-batch-tools a.button{margin-right:10px}span.tool-indicator{background:#ccc;border:1px solid #979797;display:block;width:9px;height:9px;border-radius:9px;margin-right:6px}span.tool-indicator.tool-active{background:#6dd51b}span.tool-indicator.tool-env-active{background:#fdac00}div.ilab-section-doc-links{margin-top:10px}div.ilab-section-doc-links div.doc-links-setting{background-color:rgba(0,0,0,.04);width:100%;border-radius:6px;display:flex;align-items:center;justify-content:center;padding:12px 0}div.ilab-section-doc-links div.doc-links-setting a{margin:0 5px!important}.troubleshooter-info li{margin:0;padding:8px 0 8px 28px;list-style:none;background-repeat:no-repeat;background-position:left top 6px;background-size:20px}.troubleshooter-info li.info-warning{background-image:url(../img/icon-warning.svg)}.troubleshooter-info li.info-success{background-image:url(../img/icon-success.svg)}.troubleshooter-info li.info-error{background-image:url(../img/icon-error.svg)}.troubleshooter-wait{display:flex;align-items:center}.troubleshooter-wait.hidden{display:none}.troubleshooter-wait>img{margin-right:7px;height:18px}.upload-path-preview{margin:10px 0;padding:10px;font-style:italic;background-color:#fff;border:1px dashed #ddd;display:flex;line-height:1;align-items:center}.upload-path-preview span:first-of-type{text-transform:uppercase;color:#ccc;font-size:11px;font-style:normal;margin-right:10px}.subsite-setting-group{margin-bottom:20px}.subsite-setting-group:last-of-type{margin-bottom:0}.subsite-upload-path{display:flex;align-items:center}.subsite-upload-path label{min-width:100px}#beacon-container iframe{z-index:200000!important}.ilab-popup{position:fixed;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,.85);pointer-events:all;z-index:100002;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear;opacity:1}.ilab-popup .ilab-popup-body{position:relative}.ilab-popup .ilab-popup-body .ilab-popup-contents{width:80vw;height:80vh;min-width:80vw;min-height:80vh;max-width:80vw;max-height:80vh;background-color:#fff}.ilab-popup .ilab-popup-body .ilab-popup-close{position:absolute;right:38px;top:12px;font-size:0}.ilab-popup .ilab-popup-body .ilab-popup-close:after,.ilab-popup .ilab-popup-body .ilab-popup-close:before{position:absolute;left:13px;content:" ";height:25px;width:2px;background-color:#000}.ilab-popup .ilab-popup-body .ilab-popup-close:before{transform:rotate(45deg)}.ilab-popup .ilab-popup-body .ilab-popup-close:after{transform:rotate(-45deg)}.ilab-popup.hidden{pointer-events:none;opacity:0}.mcloud-inline-help-container{position:fixed;left:0;top:0;right:0;bottom:0;z-index:100002;transition:opacity .25s linear}.mcloud-inline-help-container .mcloud-inline-help{background-color:#fff;position:absolute;width:375px;height:425px;box-shadow:0 0 10px 1px rgba(0,0,0,.25);border-radius:8px;transform-origin:left center;transition:transform .25s ease-out}.mcloud-inline-help-container .mcloud-inline-help .mcloud-inline-help-arrow{right:100%;top:50%;content:" ";height:0;width:0;position:absolute;pointer-events:none;border:10px solid hsla(0,0%,100%,0);border-right-color:#fff;margin-top:-10px}.mcloud-inline-help-container .mcloud-inline-help .mcloud-inline-help-body{box-sizing:border-box;position:absolute;left:15px;top:15px;right:7.5px;bottom:15px;padding-right:15px;overflow:auto}.mcloud-inline-help-container.mcloud-invisible{opacity:0;pointer-events:none}.mcloud-inline-help-container.mcloud-invisible .mcloud-inline-help{transform:scale(.8)}.mcloud-sidebar-help-container{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000001}.mcloud-sidebar-help-container .mcloud-sidebar-help{position:absolute;right:0;top:0;bottom:0;width:450px;transition:transform .25s linear;background-color:#fff;box-shadow:0 0 10px 1px rgba(0,0,0,.25)}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body{box-sizing:border-box;position:absolute;left:15px;top:0;right:7.5px;bottom:0;padding-top:15px;padding-right:22.5px;overflow:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body figure{margin-left:0;margin-right:0;padding-left:0;padding-right:0}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body figure img{width:100%;height:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body div.code-block{overflow-x:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close{display:block;position:absolute;right:10px;top:10px;font-size:0;line-height:0;width:14px;height:14px}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close:before{position:absolute;content:"";width:14px;height:2px;background-color:#aaa;transform:translateX(-50%) rotate(-45deg);left:50%;top:50%}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close:after{position:absolute;content:"";width:14px;height:2px;background-color:#aaa;transform:translateX(-50%) rotate(45deg);left:50%;top:50%}.mcloud-sidebar-help-container.mcloud-invisible{pointer-events:none}.mcloud-sidebar-help-container.mcloud-invisible .mcloud-sidebar-help{transform:translateX(100%)}body.modal-open #beacon-container{display:none!important}.BeaconContainer{right:10px!important;bottom:88px!important}.BeaconFabButtonFrame{right:10px!important;bottom:10px!important}#s3-importer-progress{padding:24px;background:#ddd;border-radius:8px}#s3-importer-progress .button-whoa{background:#a42929!important;border-color:#e62a2a #a42929 #a42929!important;box-shadow:0 1px 0 #a42929!important;color:#fff!important;text-decoration:none!important;text-shadow:0 -1px 1px #a42929,1px 0 1px #a42929,0 1px 1px #a42929,-1px 0 1px #a42929!important}#s3-importer-progress>button{margin-top:20px}.s3-importer-progress-container{position:relative;width:100%;height:32px;background:#aaa;border-radius:16px;overflow:hidden;background-image:url(../img/candy-stripe.svg)}#s3-importer-progress-bar{background-color:#4f90c4;height:100%}.tool-disabled{padding:10px 15px;border:1px solid #df8403}.force-cancel-help{margin-top:20px}.wp-cli-callout{padding:24px;background:#ddd;margin-top:20px;border-radius:8px}.wp-cli-callout>h3{margin:0;padding:0;font-size:14px}.wp-cli-callout>code{background-color:#bbb;padding:10px 15px;margin-top:5px;display:inline-block}#s3-importer-options{padding:24px;background:#e7e7e7;margin-top:20px;border-radius:8px}#s3-importer-options h3{margin:0;padding:0;font-size:14px}#s3-importer-options ul{padding:0;display:flex;flex-direction:column;margin:20px 0 0}#s3-importer-options ul li{display:flex;margin-bottom:30px}#s3-importer-options ul li:last-of-type{margin-bottom:0}#s3-importer-options ul li>div:first-of-type{padding:10px 10px 20px 0;width:160px;min-width:160px;line-height:1.3;font-weight:600}#s3-importer-options ul li div.description{margin-top:8px}#s3-importer-options ul li div.option-ui{display:flex;align-items:center}#s3-importer-options ul li div.option-ui.option-ui-browser input[type=text]{width:40vw;margin-right:10px;padding:7px 11px;border-radius:4px}#s3-importer-options ul li div.option-ui.option-ui-browser input[type=text]:disabled{color:#000}#s3-timing-stats{display:none}#s3-importer-status-text{position:absolute;left:16px;top:0;bottom:0;right:16px;display:flex;align-items:center;color:#fff;font-weight:700}#s3-importer-thumbnails{position:relative;width:100%;height:150px;margin-bottom:15px}#s3-importer-thumbnails-container{position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;-webkit-mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%)}#s3-importer-thumbnails-container img{width:150px;height:150px;max-width:150px;max-height:150px;border-radius:4px}#s3-importer-thumbnails-container>img{margin-right:10px}#s3-importer-thumbnails-fade{background:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);position:absolute;left:150px;top:0;right:0;bottom:0}@supports ((-webkit-mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%)) or (mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%))){#s3-importer-thumbnails-fade{display:none}}#s3-importer-thumbnails-cloud{position:absolute;right:20px;top:50%;transform:translateY(-50%)}.s3-importer-thumb{position:absolute;left:0;top:0;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;background-size:cover;background-position:50%;background-repeat:no-repeat;margin-right:10px;border-radius:4px;background-color:#888;transition:opacity .25s linear,transform .25s linear}.s3-importer-thumb.ilab-hidden{opacity:0;transform:scale(.7)}.s3-importer-image-icon{position:absolute;left:0;top:0;position:relative;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear,transform .25s linear}.s3-importer-image-icon.ilab-hidden{opacity:0;transform:scale(.8)}.s3-importer-info-warning{border:1px solid orange;padding:24px;background:rgba(255,165,0,.125);margin-top:20px;border-radius:8px}.s3-importer-info-warning h4{padding:0;font-size:14px;margin:0 0 8px} \ No newline at end of file +/*! mediabox v1.1.3 | (c) 2018 Pedro Rogerio | https://github.com/pinceladasdaweb/mediabox */.stop-scroll{height:100%;overflow:hidden}.mediabox-wrap{position:fixed;width:100%;height:100%;background-color:rgba(0,0,0,.8);top:0;left:0;opacity:0;z-index:999;-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:mediabox;animation-name:mediabox}@-webkit-keyframes mediabox{0%{opacity:0}to{opacity:1}}@keyframes mediabox{0%{opacity:0}to{opacity:1}}.mediabox-content{max-width:853px;display:block;margin:0 auto;height:100%;position:relative}.mediabox-content iframe{max-width:100%!important;width:100%!important;display:block!important;height:480px!important;border:none!important;position:absolute;top:0;bottom:0;margin:auto 0}.mediabox-hide{-webkit-animation-duration:.5s;animation-duration:.5s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-name:mediaboxhide;animation-name:mediaboxhide}@-webkit-keyframes mediaboxhide{0%{opacity:1}to{opacity:0}}@keyframes mediaboxhide{0%{opacity:1}to{opacity:0}}.mediabox-close{position:absolute;top:0;cursor:pointer;bottom:528px;right:0;margin:auto 0;width:24px;height:24px;background:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAIGNIUk0AAHolAACAgwAA+f8AAIDpAAB1MAAA6mAAADqYAAAXb5JfxUYAAAMvSURBVHja7Js9aBRBFMd/d1lPY6FiJVjY+Fkoxl7wA1Q0prQRS6tgoZV2MWIRRVHUUq3U+JnESrS2sBXBzipREWMlATXwt8gFznC5nd15M7Nn8uC45nZnfr/dY96+N1uTxFKOOks8lgUU/H2t4tJqIQUcAiaBGeBymcECRgO4B/wBPgJ9zkdKcvkclfRL/8ZtSTXH40N+GpLGF8zth6Q9Lse7DHCsDXxVJLSDLyQhb4B+Sb/VOVJJ6ATfKqGvrIDjDvCpJLjAz8d0JwmLDTBQAD62hIakiYJzm5a021VAfwn4WBLKwLdK2JUnIJP0XX4RSoIP/Hy8W3jeepv1dL3nmjwI3DLOExrAU2DA8zwb8xKhGeCuwYQtJTSAZwbwAHdcEqFM0mPZhO/foSHppdFcrraby2IDV0FCcPi8PCClhCjwLplgCgkrDeGv5I3pcjViSogK7yogloTo8EUEhJaQBL6oAGsJ9yVtkrRD0qsU8JKolagKZ8AD4ETFymFXgPOAQpXE5mMWOAk86XZ4n6pwlSSUhvcti1dBghe8RV8gpYQRX3irxkgKCSPABV94y85QTAlm8NatsRgSTOGBUnmAS57w3KiA0Ro3gHOW8KEEAOwE3hvfXWubFauu6A6vCND07OmW9viq5vpsGT3AtRAN2XoA+BfAwQBiTweoNpMZw48BRwKuAoPN7zNVWwZjwAfpO9S7DN5cQmYAPw4cTvAsYPJ3qHcpvNmdUO9ieBMJZQT0AhMVgfeWUC8BP87cjjHfuA6sATY0c4c0EgpUUHslvTaq3l5aUL1N1oarAnxSCVWBTyYhJvyw41XJJI3GkpAH/yYyfHQJi01gdUL4qBKqCh9NQrtBx4wGvGi0XS6T9MhoTkN5AtZVDN5awlTePsGfwDfPjGwYGDKu3s4Cp4BRz/N8cskED0iaqciVt7wTvkra5roKlJEQGt5HwhdJ24vmAUUkDEV+VyCT9NBxbp/bXXnXTNBFQmz4IhI6wrs+C+zvICEVvIuEKUlbrZ4G97WRkBq+k4RJSVusd4ntlfSheVudrQh8q4SbmntH6K2kzSF3if1Xsfzq7LKAJR5/BwCdAQBJn4egPgAAAABJRU5ErkJggg==") no-repeat;background-size:24px 24px}.mediabox-close:hover{opacity:.5}@media (max-width:768px){.mediabox-content{max-width:90%}}@media (max-width:600px){.mediabox-content iframe{height:320px!important}.mediabox-close{bottom:362px}}@media (max-width:480px){.mediabox-content iframe{height:220px!important}.mediabox-close{bottom:262px}}.mediabox-wrap{z-index:1000000}.mediabox-content{max-width:75vw}.mediabox-content iframe{height:42.1875vw!important}.mediabox-close{bottom:46vw}.ic-Super-toggle__label{box-sizing:border-box;margin:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle__label{display:inline-flex;align-items:center}.ic-Super-toggle__input{opacity:0;position:absolute;top:0;left:0}.ic-Super-toggle__input:checked~label .ic-Super-toggle-switch:after{transform:translate3d(100%,0,0)}.ic-Super-toggle__input:checked~label .ic-Super-toggle__disabled-msg:before{content:attr(data-checked)}.ic-Super-toggle__input[disabled]{opacity:0!important}.ic-Super-toggle__input[disabled]~label .ic-Super-toggle-switch{opacity:.33}.ic-Super-toggle-switch{transition:background .1s,border-color .1s;display:inline-block;position:relative;line-height:1;display:flex;align-items:center;background-clip:padding-box}.ic-Super-toggle-switch:after{transition:all .1s ease-in-out;content:"";position:absolute;top:0;left:0;transform:translateZ(0);border-radius:100%;box-shadow:0 3px 6px rgba(0,0,0,.3);background-image:url(https://cl.ly/320m31452k2X/handle.svg);background-position:50% 50%;background-repeat:no-repeat;background-size:20px}.ic-Super-toggle__disabled-msg{display:none}.ic-Super-toggle__disabled-msg:before{content:attr(data-unchecked);font-style:italic;opacity:.8}[class^=ic-Super-toggle-option-]{transition:all .2s ease-out;flex:0 0 50%;text-align:center;position:relative;z-index:1;text-transform:uppercase;font-weight:700;line-height:1;speak:none;box-sizing:border-box}.ic-Super-toggle__screenreader{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute}.ic-Super-toggle--on-off{display:inline-block;vertical-align:middle}.ic-Super-toggle--on-off .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#4cace3;border-color:#4cace3}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #4cace3,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--on-off .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle--on-off .ic-Super-toggle-switch{flex:0 0 50px}.ic-Super-toggle--on-off .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT{color:#fff}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.ic-Super-toggle--on-off .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--on-off [class^=ic-Super-toggle-option-]{transition-delay:.1s}.ic-Super-toggle--on-off .ic-Super-toggle-option-LEFT{transform:scale(.1);opacity:0}.ic-Super-toggle--on-off .ic-Super-toggle-option-RIGHT,.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{transform:scale(1);opacity:1}.ic-Super-toggle--on-off .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{transform:scale(.1);opacity:0}.toggle-warning{display:inline-block;vertical-align:middle}.toggle-warning .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#ffaa10;border-color:#ffaa10}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#fff}.toggle-warning .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #ffaa10,0 3px 6px rgba(0,0,0,.3)}.toggle-warning .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .toggle-warning .ic-Super-toggle-switch{flex:0 0 50px}.toggle-warning .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.toggle-warning .ic-Super-toggle-option-LEFT{color:#fff}.toggle-warning .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle-option-RIGHT{color:#fff}.toggle-warning .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#fff}.toggle-warning .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--ui-switch{display:inline-block;vertical-align:middle}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-switch{background:#5b6c79;border-color:#5b6c79}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{color:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{color:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked:focus~label .ic-Super-toggle-switch:after{box-shadow:inset 0 0 0 1px #fff,inset 0 0 0 3px #5b6c79,0 3px 6px rgba(0,0,0,.3)}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch{width:50px;height:25px;background:#5b6c79;border:2px solid #5b6c79;border-radius:14.5px}.ic-Form-group.ic-Form-group--horizontal .ic-Super-toggle--ui-switch .ic-Super-toggle-switch{flex:0 0 50px}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch:after{background-color:#fff;width:25px;height:25px}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT{color:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT .ic-Super-toggle__svg>*{fill:#08c}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT{color:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT .ic-Super-toggle__svg>*{fill:#888}.ic-Super-toggle--ui-switch .ic-Super-toggle__svg{max-width:12.5px;max-height:12.5px}.ic-Super-toggle--ui-switch .ic-Super-toggle__label{display:inline-flex;align-items:center}.ic-Super-toggle--ui-switch .ic-Super-toggle-switch{display:block}.ic-Super-toggle--ui-switch [class^=ic-Super-toggle-option-]{flex:none;min-width:24px}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-LEFT{text-align:left;transform:scale(1.1)}.ic-Super-toggle--ui-switch .ic-Super-toggle-option-RIGHT{text-align:right;transform:scale(.9)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-LEFT{transform:scale(.9)}.ic-Super-toggle--ui-switch .ic-Super-toggle__input:checked~label .ic-Super-toggle-option-RIGHT{transform:scale(1.1)}.settings-container{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;margin:0 0 64px -20px}.settings-container header{position:relative;background-image:url(../img/settings-bg-large.svg);background-position:0;background-size:cover;height:80px;width:100%;display:flex;align-items:center}.settings-container header>img{margin:0 20px;width:88px;max-width:88px}.settings-container header h1{margin-left:5px;font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;text-transform:uppercase;font-weight:400;font-size:1.5em;color:#777}.settings-container header .header-actions{position:absolute!important;right:40px;top:50%;transform:translateY(-50%)!important;display:flex}.settings-container header .header-actions a{margin-left:8px;display:flex;align-items:center}.settings-container header .header-actions a svg{height:16px;width:auto;margin-right:8px}.settings-container header .header-actions a svg>path,.settings-container header .header-actions a svg>rect{fill:#fff}.settings-container header .header-actions div.spacer{width:8px;min-width:8px}.settings-container header.all-settings{position:relative;height:104px;background-image:url(../img/settings-bg-large.svg)}.settings-container header.all-settings>img{margin:0;position:absolute;left:23px;top:50%;transform:translateY(-50%);width:108px;max-width:108px}.settings-container header.all-settings div.settings-select-container{background-color:hsla(0,0%,100%,.6);padding:10px 14px;border-radius:8px;position:absolute;right:30px;top:50%;transform:translateY(-50%);z-index:1000}.settings-container header.all-settings div.settings-select-container nav.dropdown{display:flex;align-items:center;z-index:1000}.settings-container header.all-settings div.settings-select-container nav.dropdown>div:first-of-type{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;margin-right:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:1em}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown{position:relative;width:200px;height:36px;z-index:1000;cursor:pointer}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.current{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;display:flex;align-items:center;position:absolute;left:0;top:0;right:0;bottom:0;background-color:#eee;border:1px solid #ddd;padding-left:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:13px;cursor:pointer;background-image:url(../img/icon-dropdown-arrow.svg);background-repeat:no-repeat;background-position:right 12px center;transition:background-color .15s linear}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.current:hover{background-color:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items{z-index:1001;position:absolute;top:0;left:0;right:0;transition:opacity .15s linear,transform .15s linear;opacity:0;pointer-events:none}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items.visible{pointer-events:auto;opacity:1}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul{margin:0;padding:0;box-shadow:0 0 8px 1px rgba(0,0,0,.125)}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li{position:relative;margin:0;padding:0;border:1px solid #ddd;border-top:0;align-items:center}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li:first-of-type{border:1px solid #ddd}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool{position:relative;display:flex;align-items:center;height:36px;background-color:#eee;padding-left:10px;color:#777;text-decoration:none;text-transform:uppercase;font-weight:700;font-size:13px;transition:background-color .15s linear}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool:hover{background:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool-pin{display:block;position:absolute;top:0;width:36px;height:36px;right:0;background-image:url(../img/icon-pin-deselected.svg);background-repeat:no-repeat;background-position:50%}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li a.tool-pin.pinned{background-image:url(../img/icon-pin-selected.svg)}.settings-container header.all-settings div.settings-select-container nav.dropdown div.dropdown div.items ul li.active a.tool{background:#fff}.settings-container header.all-settings div.settings-select-container nav.dropdown.active div.dropdown div.current{background-color:#ddd}.settings-container .settings-body{margin:20px}.settings-container .settings-body .settings-description{font-size:1.1em;text-align:center;background-color:#fafafa;padding:25px;border-radius:8px;margin-bottom:20px}.settings-container .settings-body.show-upgrade{display:flex}.settings-container .settings-body.show-upgrade>.settings-interior{flex:1;margin-right:20px}@media (max-width:64em){.settings-container .settings-body.show-upgrade>.settings-interior{order:1;margin-right:0}}@media (max-width:64em){.settings-container .settings-body.show-upgrade{flex-direction:column}}.settings-container .settings-body .upgrade-feature{background-color:#fafafa;border-radius:8px;padding:15px 20px}.settings-container .settings-body .upgrade-feature h2{padding:0;margin:0 0 30px;color:#46a4dd}.settings-container .settings-body .upgrade-feature ul{margin-left:20px;list-style:unset}.settings-container .settings-body .upgrade-feature ul li{list-style-type:square}.settings-container .settings-body .upgrade-feature div.button-container{text-align:right;padding:20px 0}.settings-container .settings-body .upgrade-feature div.button-container a{padding:10px;background-color:#46a4dd;border-radius:6px;color:#fff;text-decoration:none;font-weight:700;font-size:1.1em}.settings-container .settings-body .upgrade-promo{min-width:200px;max-width:320px;position:relative}.settings-container .settings-body .upgrade-promo .upgrade-interior{position:relative;background-color:#fafafa;border-radius:8px;padding:15px 20px}.settings-container .settings-body .upgrade-promo .upgrade-interior h2{padding:0;margin:0 0 30px;color:#46a4dd}.settings-container .settings-body .upgrade-promo .upgrade-interior ul{margin-left:20px}.settings-container .settings-body .upgrade-promo .upgrade-interior ul li{list-style-type:square}@media (max-width:64em){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{display:flex;flex-wrap:wrap;width:100%}@supports (display:grid){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{display:grid;grid-template-columns:1fr 1fr 1fr}}.settings-container .settings-body .upgrade-promo .upgrade-interior ul li{margin-right:30px}}@media (max-width:48.9275em){@supports (display:grid){.settings-container .settings-body .upgrade-promo .upgrade-interior ul{grid-template-columns:1fr 1fr}}}.settings-container .settings-body .upgrade-promo .upgrade-interior div.button-container{text-align:right;padding:20px 0}.settings-container .settings-body .upgrade-promo .upgrade-interior div.button-container a{padding:10px;background-color:#46a4dd;border-radius:6px;color:#fff;text-decoration:none;font-weight:700;font-size:1.1em}.settings-container .settings-body .upgrade-promo .upgrade-interior a.upgrade-close{display:none;position:absolute;top:15px;right:20px}@media (max-width:64em){.settings-container .settings-body .upgrade-promo .upgrade-interior a.upgrade-close{display:block}}@media (max-width:64em){.settings-container .settings-body .upgrade-promo{order:0;margin-bottom:20px;max-width:100%}}@media (max-width:64em){.settings-container .settings-body .upgrade-promo.hide-on-mobile{display:none}}.button-warning{background:#dd9000!important;border-color:#dd9000 #b97800 #b97800!important;box-shadow:0 1px 0 #b97800!important;color:#fff!important;text-decoration:none!important;text-shadow:0 -1px 1px #b97800,1px 0 1px #b97800,0 1px 1px #b97800,-1px 0 1px #b97800!important}.media-cloud-tool-description{padding:24px;background:#ddd;border-radius:8px;margin-bottom:20px}.media-cloud-tool-description h2{font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;text-transform:uppercase;margin:0 0 5px;padding:0}.media-cloud-tool-description p{margin-top:0;font-size:1.2em}.ilab-notification-container .notice{margin-left:0;margin-right:0;margin-bottom:10px}.ilab-notification-container .notice:last-of-type{margin-bottom:20px}.ilab-settings-section{background-color:#fafafa;padding:25px;border-radius:8px;margin-bottom:20px;overflow:hidden}.ilab-settings-section h2{padding:10px 25px;background-color:#ddd;margin:-25px -25px 0;font-family:system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif;font-weight:700;font-size:13px;color:rgba(0,0,0,.5)!important;text-transform:uppercase;display:flex;align-items:center}.ilab-settings-section h2 a.help-beacon{margin:0 0 0 10px;padding:0;display:block;width:16px;height:16px;color:transparent;overflow:hidden;background-image:url(../img/mcloud-icon-help.svg);background-position:50%;background-size:contain;background-repeat:no-repeat}.ilab-settings-section .section-description{margin-top:20px;margin-bottom:15px;font-style:italic}.ilab-settings-section .checkbox-w-description{display:flex;align-items:center}.ilab-settings-section .checkbox-w-description label{margin-right:20px}.ilab-settings-section .checkbox-w-description>div>p{margin:0}.ilab-settings-toggle{padding:0 25px 5px}.ilab-settings-toggle table.form-table tr{display:flex;flex-direction:row;align-items:center}@media (max-width:48.9275em){.ilab-settings-toggle table.form-table tr{flex-direction:column;align-items:flex-start}}.ilab-settings-toggle table.form-table tr th{min-width:200px;max-width:200px}@media (max-width:48.9275em){.ilab-settings-toggle table.form-table tr{margin-bottom:20px}.ilab-settings-toggle table.form-table tr th{margin-bottom:10px}}.ilab-settings-features{padding:10px 25px 15px}.ilab-settings-features table.form-table tr{display:flex;flex-direction:row;align-items:center}.ilab-settings-features table.form-table tr td.toggle{display:flex;align-items:center;max-width:220px;min-width:220px}.ilab-settings-features table.form-table tr td.toggle div.title{display:flex;flex-direction:column;margin-left:30px;white-space:nowrap;font-weight:700;font-size:1.05em}.ilab-settings-features table.form-table tr td.toggle div.title div.tool-links{display:flex}.ilab-settings-features table.form-table tr td.toggle div.title div.tool-links a{margin-right:10px;margin-top:5px;font-size:.85em;font-weight:400}.ilab-settings-features table.form-table tr td.toggle div.title div.tool-links a:last-of-type{margin-right:0}.ilab-settings-features table.form-table tr td.description p{font-size:1.05em}@media (max-width:48.9275em){.ilab-settings-features table.form-table tr{flex-direction:column;align-items:flex-start;margin-bottom:30px}.ilab-settings-features table.form-table td.toggle div.title{font-size:1.2em!important}}.ilab-settings-button{display:flex;justify-content:center}.ilab-settings-button p{padding:0;margin:0}.ilab-settings-batch-tools{display:flex;padding-right:10px;margin-right:20px;border-right:1px solid #ccc}.ilab-settings-batch-tools a.button{margin-right:10px}span.tool-indicator{background:#ccc;border:1px solid #979797;display:block;width:9px;height:9px;border-radius:9px;margin-right:6px}span.tool-indicator.tool-active{background:#6dd51b}span.tool-indicator.tool-env-active{background:#fdac00}div.ilab-section-doc-links{margin-top:10px}div.ilab-section-doc-links div.doc-links-setting{background-color:rgba(0,0,0,.04);width:100%;border-radius:6px;display:flex;align-items:center;justify-content:center;padding:12px 0}div.ilab-section-doc-links div.doc-links-setting a{margin:0 5px!important}.troubleshooter-info li{margin:0;padding:8px 0 8px 28px;list-style:none;background-repeat:no-repeat;background-position:left top 6px;background-size:20px}.troubleshooter-info li.info-warning{background-image:url(../img/icon-warning.svg)}.troubleshooter-info li.info-success{background-image:url(../img/icon-success.svg)}.troubleshooter-info li.info-error{background-image:url(../img/icon-error.svg)}.troubleshooter-wait{display:flex;align-items:center}.troubleshooter-wait.hidden{display:none}.troubleshooter-wait>img{margin-right:7px;height:18px}.upload-path-preview{margin:10px 0;padding:10px;font-style:italic;background-color:#fff;border:1px dashed #ddd;display:flex;line-height:1;align-items:center}.upload-path-preview span:first-of-type{text-transform:uppercase;color:#ccc;font-size:11px;font-style:normal;margin-right:10px}.subsite-setting-group{margin-bottom:20px}.subsite-setting-group:last-of-type{margin-bottom:0}.subsite-upload-path{display:flex;align-items:center}.subsite-upload-path label{min-width:100px}.presigned-url-container>div{display:flex;align-items:flex-start;margin-bottom:20px}.presigned-url-container>div:nth-of-type(2n){margin-bottom:40px}.presigned-url-container>div:last-of-type{margin-bottom:0}.presigned-url-container>div div.presigned-label{line-height:1.3;font-weight:600;margin-right:10px;margin-top:6px;min-width:175px}.privacy-container>div{display:flex;align-items:flex-start;margin-bottom:20px}.privacy-container>div:last-of-type{margin-bottom:0}.privacy-container>div div.privacy-label{line-height:1.3;font-weight:600;margin-right:10px;margin-top:6px;min-width:135px}#beacon-container iframe{z-index:200000!important}.ilab-popup{position:fixed;left:0;top:0;width:100%;height:100%;background-color:rgba(0,0,0,.85);pointer-events:all;z-index:100002;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear;opacity:1}.ilab-popup .ilab-popup-body{position:relative}.ilab-popup .ilab-popup-body .ilab-popup-contents{width:80vw;height:80vh;min-width:80vw;min-height:80vh;max-width:80vw;max-height:80vh;background-color:#fff}.ilab-popup .ilab-popup-body .ilab-popup-close{position:absolute;right:38px;top:12px;font-size:0}.ilab-popup .ilab-popup-body .ilab-popup-close:after,.ilab-popup .ilab-popup-body .ilab-popup-close:before{position:absolute;left:13px;content:" ";height:25px;width:2px;background-color:#000}.ilab-popup .ilab-popup-body .ilab-popup-close:before{transform:rotate(45deg)}.ilab-popup .ilab-popup-body .ilab-popup-close:after{transform:rotate(-45deg)}.ilab-popup.hidden{pointer-events:none;opacity:0}.mcloud-inline-help-container{position:fixed;left:0;top:0;right:0;bottom:0;z-index:100002;transition:opacity .25s linear}.mcloud-inline-help-container .mcloud-inline-help{background-color:#fff;position:absolute;width:375px;height:425px;box-shadow:0 0 10px 1px rgba(0,0,0,.25);border-radius:8px;transform-origin:left center;transition:transform .25s ease-out}.mcloud-inline-help-container .mcloud-inline-help .mcloud-inline-help-arrow{right:100%;top:50%;content:" ";height:0;width:0;position:absolute;pointer-events:none;border:10px solid hsla(0,0%,100%,0);border-right-color:#fff;margin-top:-10px}.mcloud-inline-help-container .mcloud-inline-help .mcloud-inline-help-body{box-sizing:border-box;position:absolute;left:15px;top:15px;right:7.5px;bottom:15px;padding-right:15px;overflow:auto}.mcloud-inline-help-container.mcloud-invisible{opacity:0;pointer-events:none}.mcloud-inline-help-container.mcloud-invisible .mcloud-inline-help{transform:scale(.8)}.mcloud-sidebar-help-container{position:fixed;left:0;top:0;right:0;bottom:0;z-index:1000001}.mcloud-sidebar-help-container .mcloud-sidebar-help{position:absolute;right:0;top:0;bottom:0;width:450px;transition:transform .25s linear;background-color:#fff;box-shadow:0 0 10px 1px rgba(0,0,0,.25)}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body{box-sizing:border-box;position:absolute;left:15px;top:0;right:7.5px;bottom:0;padding-top:15px;padding-right:22.5px;overflow:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body figure{margin-left:0;margin-right:0;padding-left:0;padding-right:0}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body figure img{width:100%;height:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-help-body div.code-block{overflow-x:auto}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close{display:block;position:absolute;right:10px;top:10px;font-size:0;line-height:0;width:14px;height:14px}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close:before{position:absolute;content:"";width:14px;height:2px;background-color:#aaa;transform:translateX(-50%) rotate(-45deg);left:50%;top:50%}.mcloud-sidebar-help-container .mcloud-sidebar-help .mcloud-sidebar-close:after{position:absolute;content:"";width:14px;height:2px;background-color:#aaa;transform:translateX(-50%) rotate(45deg);left:50%;top:50%}.mcloud-sidebar-help-container.mcloud-invisible{pointer-events:none}.mcloud-sidebar-help-container.mcloud-invisible .mcloud-sidebar-help{transform:translateX(100%)}body.modal-open #beacon-container{display:none!important}.BeaconContainer{right:10px!important;bottom:88px!important}.BeaconFabButtonFrame{right:10px!important;bottom:10px!important}.wizard-container{position:fixed;left:0;top:0;width:100%;height:100%;background-color:#000;z-index:100000;display:flex;align-items:center;justify-content:center;overflow:hidden;transition:opacity .333s linear}.wizard-container *{font-family:SF Pro Text,SFProText,system-ui,-apple-system,BlinkMacSystemFont,Avenir Next,Avenir,Segoe UI,Lucida Grande,Helvetica Neue,Helvetica,Fira Sans,Roboto,Noto,Droid Sans,Cantarell,Oxygen,Ubuntu,Franklin Gothic Medium,Century Gothic,Liberation Sans,sans-serif}.wizard-container a{text-decoration:none}.wizard-container a:focus{outline:none;box-shadow:none}.wizard-container .wizard-modal{position:relative;width:87.8048780488vw;height:51.2195121951vw;transition:transform .333s linear,opacity .333s linear}@media (min-width:102.5em){.wizard-container .wizard-modal{width:1440px}}@media (max-width:48.9275em){.wizard-container .wizard-modal{width:94.5083014049vw}}@media (min-width:102.5em){.wizard-container .wizard-modal{height:840px}}@media (max-width:48.9275em){.wizard-container .wizard-modal{height:81.7369093231vw}}.wizard-container .wizard-modal div.steps-background{position:absolute;left:calc(100% - 320px);top:-100vh;width:100vw;height:300vh;background-color:rgba(58,86,116,.5);transition:transform .25s linear,opacity .25s linear}@media (max-width:48.9275em){.wizard-container .wizard-modal div.steps-background{left:calc(100% - 26.81992vw)}}@media (min-width:48.9375em) and (max-width:102.49em){.wizard-container .wizard-modal div.steps-background{left:calc(100% - 19.5122vw)}}.wizard-container .wizard-modal a.close-modal{position:absolute;left:.6097560976vw;top:.6097560976vw;width:1.7073170732vw;height:1.7073170732vw;background-image:url(../img/wizard-close-modal.svg);background-position:50%;background-repeat:no-repeat;background-size:contain;font-size:0;line-height:0}@media (min-width:102.5em){.wizard-container .wizard-modal a.close-modal{left:10px}}@media (max-width:48.9275em){.wizard-container .wizard-modal a.close-modal{left:1.2771392082vw}}@media (min-width:102.5em){.wizard-container .wizard-modal a.close-modal{top:10px}}@media (max-width:48.9275em){.wizard-container .wizard-modal a.close-modal{top:1.2771392082vw}}@media (min-width:102.5em){.wizard-container .wizard-modal a.close-modal{width:28px}}@media (max-width:48.9275em){.wizard-container .wizard-modal a.close-modal{width:3.5759897829vw}}@media (min-width:102.5em){.wizard-container .wizard-modal a.close-modal{height:28px}}@media (max-width:48.9275em){.wizard-container .wizard-modal a.close-modal{height:3.5759897829vw}}.wizard-content{position:absolute;left:0;top:0;right:0;bottom:0;font-size:.9756097561vw;border-radius:.7317073171vw;overflow:hidden;background-color:#fff;display:flex;flex-direction:column}@media (min-width:102.5em){.wizard-content{font-size:16px}}@media (max-width:48.9275em){.wizard-content{font-size:1.7879948914vw}}@media (min-width:102.5em){.wizard-content{border-radius:12px}}@media (max-width:48.9275em){.wizard-content{border-radius:1.5325670498vw}}.wizard-content div.sections{flex:1;position:relative;overflow:hidden}.wizard-content div.sections div.wizard-section{position:absolute;left:0;right:0;top:0;bottom:0;transform:translateX(87.8048780488vw);transition:transform .25s linear,opacity .25s linear,filter .25s linear,-webkit-filter .25s linear;overflow-x:hidden;opacity:0}.wizard-content div.sections div.wizard-section.current{opacity:1;transform:translateX(0)}.wizard-content div.sections div.wizard-section.past{transform:translateX(-87.8048780488vw)}@media (min-width:102.5em){.wizard-content div.sections div.wizard-section{transform:translateX(1440px)}.wizard-content div.sections div.wizard-section.past{transform:translateX(-1440px)}}.wizard-content div.sections div.wizard-section div.wizard-step{position:absolute;left:0;right:0;top:0;bottom:0;transform:translateX(100%);transition:transform .25s linear,opacity .25s linear;opacity:0}.wizard-content div.sections div.wizard-section div.wizard-step.current{opacity:1;transform:translateX(0)}.wizard-content div.sections div.wizard-section div.wizard-step.past{transform:translateX(-100%)}.wizard-content div.sections div.wizard-section[data-display-steps=true]{max-width:68.29268vw}@media (max-width:48.9275em){.wizard-content div.sections div.wizard-section[data-display-steps=true]{max-width:67.68838vw}}@media (min-width:102.5em){.wizard-content div.sections div.wizard-section[data-display-steps=true]{max-width:1120px}}.wizard-content div.sections div.wizard-section.section-tutorial[data-display-steps=true]{max-width:66.46341vw}@media (max-width:48.9275em){.wizard-content div.sections div.wizard-section.section-tutorial[data-display-steps=true]{max-width:61.30268vw}}@media (min-width:102.5em){.wizard-content div.sections div.wizard-section.section-tutorial[data-display-steps=true]{max-width:1090px}}.wizard-content div.steps{position:absolute;right:0;top:0;bottom:0;width:19.512195122vw;background-color:#3a5674;padding-top:2.9268292683vw;background-image:url(../img/wizard-steps-bg.svg);background-repeat:no-repeat;background-position:bottom;background-size:19.512195122vw;transition:transform .25s linear,opacity .25s linear}@media (min-width:102.5em){.wizard-content div.steps{width:320px}}@media (max-width:48.9275em){.wizard-content div.steps{width:26.8199233716vw}}@media (min-width:102.5em){.wizard-content div.steps{padding-top:48px}}@media (max-width:48.9275em){.wizard-content div.steps{padding-top:4.0868454662vw}}@media (min-width:102.5em){.wizard-content div.steps{background-size:320px}}@media (max-width:48.9275em){.wizard-content div.steps{background-size:26.8199233716vw}}.wizard-content div.steps ul{padding:0;margin:0}.wizard-content div.steps ul li{display:flex;align-items:flex-start;margin:0 0 2.9268292683vw;padding:0 1.4634146341vw 0 0;perspective:1000px}@media (min-width:102.5em){.wizard-content div.steps ul li{margin-bottom:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li{margin-bottom:3.0651340996vw}}@media (min-width:102.5em){.wizard-content div.steps ul li{padding-right:24px}}@media (max-width:48.9275em){.wizard-content div.steps ul li{padding-right:1.5325670498vw}}.wizard-content div.steps ul li input[type=checkbox]{display:none}.wizard-content div.steps ul li div.step-number{position:relative;width:3.9024390244vw;min-width:3.9024390244vw;max-width:3.9024390244vw;height:3.9024390244vw;min-height:3.9024390244vw;max-height:3.9024390244vw;margin-top:-.487804878vw;display:flex;align-items:center;justify-content:center;transform:translateX(-50%);transform-style:preserve-3d;transition:transform .5s linear}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{width:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{width:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{min-width:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{min-width:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{max-width:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{max-width:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{height:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{height:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{min-height:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{min-height:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{max-height:64px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{max-height:8.1736909323vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number{margin-top:-8px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number{margin-top:-1.0217113665vw}}.wizard-content div.steps ul li div.step-number span{position:absolute;left:.487804878vw;top:.487804878vw;width:2.9268292683vw;min-width:2.9268292683vw;max-width:2.9268292683vw;height:2.9268292683vw;min-height:2.9268292683vw;max-height:2.9268292683vw;border-radius:2.9268292683vw;border:.0609756098vw solid #e6e6e6;background-color:#fff;color:#50ade2;display:flex;align-items:center;justify-content:center;transition:border-width .25s linear,border-color .25s linear,transform .25s linear;-webkit-backface-visibility:hidden;backface-visibility:hidden}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{left:8px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{left:1.0217113665vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{top:8px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{top:1.0217113665vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{width:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{width:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{min-width:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{min-width:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{max-width:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{max-width:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{height:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{height:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{min-height:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{min-height:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{max-height:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{max-height:6.1302681992vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span{border-radius:48px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span{border-radius:6.1302681992vw}}.wizard-content div.steps ul li div.step-number span.back{transform:rotateY(180deg)}.wizard-content div.steps ul li div.step-number span.back img{width:.9756097561vw;min-width:.9756097561vw;max-width:.9756097561vw;height:auto}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span.back img{width:16px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span.back img{width:2.0434227331vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span.back img{min-width:16px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span.back img{min-width:2.0434227331vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.step-number span.back img{max-width:16px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.step-number span.back img{max-width:2.0434227331vw}}.wizard-content div.steps ul li.current div.step-number span{background:linear-gradient(135.29deg,#62c5f1 7.95%,#50ade2 101.07%);color:#fff;border:.487804878vw solid #fff;transform:translate(-12.5%,-12.5%)}.wizard-content div.steps ul li.current div.step-number span.back{transform:translate(-12.5%,-12.5%) rotateY(180deg)}@media (min-width:102.5em){.wizard-content div.steps ul li.current div.step-number span{border:8px solid #fff}}.wizard-content div.steps ul li.current div.description h3{color:#fff}.wizard-content div.steps ul li.complete div.step-number{transform:translateX(-50%) rotateY(180deg)}.wizard-content div.steps ul li.complete div.step-number span{background:linear-gradient(135.29deg,#62c5f1 7.95%,#50ade2 101.07%);color:#fff;border:0 solid hsla(0,0%,100%,0)}.wizard-content div.steps ul li div.description{margin-left:-.487804878vw}@media (min-width:102.5em){.wizard-content div.steps ul li div.description{margin-left:-8px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.description{margin-left:-2.5542784163vw}}.wizard-content div.steps ul li div.description h3{padding:0;color:hsla(0,0%,100%,.5);font-weight:700;font-size:1em;line-height:1.5em;margin:.7317073171vw 0 .487804878vw;transition:margin-top .25s linear}@media (min-width:102.5em){.wizard-content div.steps ul li div.description h3{margin-top:12px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.description h3{margin-top:1.5325670498vw}}@media (min-width:102.5em){.wizard-content div.steps ul li div.description h3{margin-bottom:8px}}@media (max-width:48.9275em){.wizard-content div.steps ul li div.description h3{margin-bottom:1.0217113665vw}}.wizard-content div.steps ul li div.description div.description-container{max-height:0;overflow:hidden;transition:max-height .25s linear}.wizard-content div.steps ul li div.description div.description-container p{opacity:0;margin:0;padding:0;font-size:.875em;color:hsla(0,0%,100%,.7);line-height:1.5em;transition:opacity .25s linear}.wizard-content div.steps ul li input[type=checkbox]:checked+div.description h3{margin-top:0}.wizard-content div.steps ul li input[type=checkbox]:checked+div.description div.description-container{max-height:8.5365853659vw}@media (min-width:102.5em){.wizard-content div.steps ul li input[type=checkbox]:checked+div.description div.description-container{max-height:140px}}@media (max-width:48.9275em){.wizard-content div.steps ul li input[type=checkbox]:checked+div.description div.description-container{max-height:17.8799489144vw}}.wizard-content div.steps ul li input[type=checkbox]:checked+div.description div.description-container p{opacity:1}.wizard-content footer{display:flex;height:5.8536585366vw;margin-right:19.512195122vw;padding:0 7.3170731707vw;align-items:center;justify-content:space-between;border-top:1px solid #e6e6e6;transition:margin-right .25s linear}@media (min-width:102.5em){.wizard-content footer{height:96px}}@media (max-width:48.9275em){.wizard-content footer{height:12.2605363985vw}}@media (min-width:102.5em){.wizard-content footer{margin-right:320px}}@media (max-width:48.9275em){.wizard-content footer{margin-right:26.8199233716vw}}@media (min-width:102.5em){.wizard-content footer{padding-bottom:0}}@media (max-width:48.9275em){.wizard-content footer{padding-bottom:0}}@media (min-width:102.5em){.wizard-content footer{padding-top:0}}@media (max-width:48.9275em){.wizard-content footer{padding-top:0}}@media (min-width:102.5em){.wizard-content footer{padding-left:120px}}@media (max-width:48.9275em){.wizard-content footer{padding-left:7.662835249vw}}@media (min-width:102.5em){.wizard-content footer{padding-right:120px}}@media (max-width:48.9275em){.wizard-content footer{padding-right:7.662835249vw}}.wizard-content footer img.logo{width:3.9024390244vw;height:auto}@media (min-width:102.5em){.wizard-content footer img.logo{width:64px}}@media (max-width:48.9275em){.wizard-content footer img.logo{width:8.1736909323vw}}.wizard-content footer a{font-style:normal;font-weight:500;font-size:1em;display:flex;align-items:center;justify-content:center;letter-spacing:.0457317073vw;text-transform:uppercase;text-decoration:none;color:#50abe0;transition:opacity .25s linear,background .25s linear}@media (min-width:102.5em){.wizard-content footer a{letter-spacing:.75px}}@media (max-width:48.9275em){.wizard-content footer a{letter-spacing:.0957854406vw}}.wizard-content footer a.disabled{color:#b3b3b3;pointer-events:none}.wizard-content footer a.invisible{opacity:0;pointer-events:none}.wizard-content footer nav{display:flex}.wizard-content footer nav a{margin-left:.6097560976vw;padding:.9146341463vw 2.1341463415vw}@media (min-width:102.5em){.wizard-content footer nav a{margin-left:10px}}@media (max-width:48.9275em){.wizard-content footer nav a{margin-left:1.2771392082vw}}@media (min-width:102.5em){.wizard-content footer nav a{padding-bottom:15px}}@media (max-width:48.9275em){.wizard-content footer nav a{padding-bottom:1.1494252874vw}}@media (min-width:102.5em){.wizard-content footer nav a{padding-top:15px}}@media (max-width:48.9275em){.wizard-content footer nav a{padding-top:1.1494252874vw}}@media (min-width:102.5em){.wizard-content footer nav a{padding-left:35px}}@media (max-width:48.9275em){.wizard-content footer nav a{padding-left:3.0651340996vw}}@media (min-width:102.5em){.wizard-content footer nav a{padding-right:35px}}@media (max-width:48.9275em){.wizard-content footer nav a{padding-right:3.0651340996vw}}.wizard-content footer nav a.hidden{display:none}.wizard-content footer nav a.next,.wizard-content footer nav a.return{color:#fff;border-radius:6.0975609756vw;background:linear-gradient(180deg,#62c5f1,#50ade2)}@media (min-width:102.5em){.wizard-content footer nav a.next,.wizard-content footer nav a.return{border-radius:100px}}@media (max-width:48.9275em){.wizard-content footer nav a.next,.wizard-content footer nav a.return{border-radius:6.3856960409vw}}.wizard-content footer nav a.next.disabled,.wizard-content footer nav a.return.disabled{background:linear-gradient(180deg,#f0f0f0,#e0e0e0)}.wizard-step{padding:0 7.3170731707vw;display:flex;flex-direction:column;justify-content:center;flex:1}@media (min-width:102.5em){.wizard-step{padding-bottom:0}}@media (max-width:48.9275em){.wizard-step{padding-bottom:0}}@media (min-width:102.5em){.wizard-step{padding-top:0}}@media (max-width:48.9275em){.wizard-step{padding-top:0}}@media (min-width:102.5em){.wizard-step{padding-left:120px}}@media (max-width:48.9275em){.wizard-step{padding-left:7.662835249vw}}@media (min-width:102.5em){.wizard-step{padding-right:120px}}@media (max-width:48.9275em){.wizard-step{padding-right:7.662835249vw}}.wizard-step .intro{margin-bottom:3.6585365854vw}.wizard-step .intro h1{line-height:1.2;margin-bottom:2.4390243902vw}@media (min-width:102.5em){.wizard-step .intro h1{margin-bottom:40px}}@media (max-width:48.9275em){.wizard-step .intro h1{margin-bottom:2.5542784163vw}}@media (min-width:102.5em){.wizard-step .intro{margin-bottom:60px}}@media (max-width:48.9275em){.wizard-step .intro{margin-bottom:3.8314176245vw}}.wizard-step .intro p{padding:0;margin:0 0 1.0975609756vw;font-size:1.125em;text-align:left}@media (min-width:102.5em){.wizard-step .intro p{margin-bottom:18px}}@media (max-width:48.9275em){.wizard-step .intro p{margin-bottom:1.1494252874vw}}.wizard-step .intro p:last-of-type{margin-bottom:0}div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding:0 5.487804878vw 0 7.3170731707vw}@media (min-width:102.5em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-left:120px}}@media (max-width:48.9275em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-left:7.662835249vw}}@media (min-width:102.5em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-top:0}}@media (max-width:48.9275em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-top:0}}@media (min-width:102.5em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-right:90px}}@media (max-width:48.9275em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-right:0}}@media (min-width:102.5em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-bottom:0}}@media (max-width:48.9275em){div.wizard-section.section-tutorial[data-display-steps=true] .wizard-step-tutorial{padding-bottom:0}}.wizard-step-select div.step-contents{margin-bottom:2.4390243902vw}@media (min-width:102.5em){.wizard-step-select div.step-contents{margin-bottom:40px}}@media (max-width:48.9275em){.wizard-step-select div.step-contents{margin-bottom:2.5542784163vw}}.wizard-step-select div.step-contents:last-of-type{margin-bottom:0}.wizard-step-select .intro{text-align:center}.wizard-step-select ul{display:flex;flex-wrap:wrap;padding:0;margin:0;justify-content:center;align-items:center}.wizard-step-select ul li{position:relative;display:block;padding:0;margin:1.8292682927vw 2.4390243902vw}@media (min-width:102.5em){.wizard-step-select ul li{margin-top:30px}}@media (max-width:48.9275em){.wizard-step-select ul li{margin-top:1.9157088123vw}}@media (min-width:102.5em){.wizard-step-select ul li{margin-bottom:30px}}@media (max-width:48.9275em){.wizard-step-select ul li{margin-bottom:1.9157088123vw}}@media (min-width:102.5em){.wizard-step-select ul li{margin-left:40px}}@media (max-width:48.9275em){.wizard-step-select ul li{margin-left:5.1085568327vw}}@media (min-width:102.5em){.wizard-step-select ul li{margin-right:40px}}@media (max-width:48.9275em){.wizard-step-select ul li{margin-right:5.1085568327vw}}.wizard-step-select ul li div.description{position:absolute;left:50%;transform:translate(-50%,24px) scale(.7);bottom:calc(100% + 30px);padding:1.4634146341vw;background-color:#3a5674;color:#fff;width:17.6829268293vw;display:flex;flex-direction:column;align-items:center;justify-content:center;border-radius:10px;box-shadow:0 0 10px 1px rgba(0,0,0,.25);opacity:0;pointer-events:none;transition:transform .125s linear,opacity .125s linear}@media (min-width:102.5em){.wizard-step-select ul li div.description{padding:24px}}@media (max-width:48.9275em){.wizard-step-select ul li div.description{padding:1.5325670498vw}}@media (min-width:102.5em){.wizard-step-select ul li div.description{width:290px}}@media (max-width:48.9275em){.wizard-step-select ul li div.description{width:32.5670498084vw}}.wizard-step-select ul li div.description div.arrow-down{position:absolute;bottom:-13px;width:0;height:0;left:calc(50% - 14px);border-left:14px solid transparent;border-right:14px solid transparent;border-top:14px solid #3a5674}.wizard-step-select ul li:hover div.description{opacity:1;transform:translate(-50%) scale(1)}ul.options.select-icons li:hover a img{transform:scale(1.2)}ul.options.select-icons li a{font-size:0}ul.options.select-icons li a img{transition:transform .2s linear;height:2.9268292683vw;width:auto}@media (min-width:102.5em){ul.options.select-icons li a img{height:48px}}@media (max-width:48.9275em){ul.options.select-icons li a img{height:3.0651340996vw}}ul.options.select-icons li a.select-s3 img{height:3.6585365854vw}@media (min-width:102.5em){ul.options.select-icons li a.select-s3 img{height:60px}}@media (max-width:48.9275em){ul.options.select-icons li a.select-s3 img{height:3.8314176245vw}}ul.options.select-buttons li{margin:1.8292682927vw .9146341463vw}@media (min-width:102.5em){ul.options.select-buttons li{margin-top:30px}}@media (max-width:48.9275em){ul.options.select-buttons li{margin-top:1.9157088123vw}}@media (min-width:102.5em){ul.options.select-buttons li{margin-bottom:30px}}@media (max-width:48.9275em){ul.options.select-buttons li{margin-bottom:1.9157088123vw}}@media (min-width:102.5em){ul.options.select-buttons li{margin-left:15px}}@media (max-width:48.9275em){ul.options.select-buttons li{margin-left:1.0217113665vw}}@media (min-width:102.5em){ul.options.select-buttons li{margin-right:15px}}@media (max-width:48.9275em){ul.options.select-buttons li{margin-right:1.0217113665vw}}ul.options.select-buttons li a{font-style:normal;font-weight:500;font-size:1em;display:flex;align-items:center;justify-content:center;letter-spacing:.0457317073vw;text-transform:uppercase;text-decoration:none;color:#fff;border-radius:6.0975609756vw;padding:.9146341463vw 2.1341463415vw;background:linear-gradient(180deg,#62c5f1,#50ade2)}@media (min-width:102.5em){ul.options.select-buttons li a{letter-spacing:.75px;padding:15px 35px}}ul.options.select-flat-buttons li{margin:1.8292682927vw .9146341463vw}@media (min-width:102.5em){ul.options.select-flat-buttons li{margin-top:30px}}@media (max-width:48.9275em){ul.options.select-flat-buttons li{margin-top:1.9157088123vw}}@media (min-width:102.5em){ul.options.select-flat-buttons li{margin-bottom:30px}}@media (max-width:48.9275em){ul.options.select-flat-buttons li{margin-bottom:1.9157088123vw}}@media (min-width:102.5em){ul.options.select-flat-buttons li{margin-left:15px}}@media (max-width:48.9275em){ul.options.select-flat-buttons li{margin-left:1.0217113665vw}}@media (min-width:102.5em){ul.options.select-flat-buttons li{margin-right:15px}}@media (max-width:48.9275em){ul.options.select-flat-buttons li{margin-right:1.0217113665vw}}ul.options.select-flat-buttons li a{font-style:normal;font-weight:500;font-size:1.5em;letter-spacing:.0457317073vw;text-transform:uppercase;text-decoration:none;border-bottom:1px dotted #50ade2;color:#50ade2}@media (min-width:102.5em){ul.options.select-flat-buttons li a{letter-spacing:.75px}}.wizard-step-video{padding:0}.wizard-step-video .step-contents .video,.wizard-step-video .step-contents .video iframe{position:absolute;top:0;left:0;width:100%;height:100%}@-webkit-keyframes logo-rotate{0%{transform:rotateY(0deg)}to{transform:rotateY(-1turn)}}@keyframes logo-rotate{0%{transform:rotateY(0deg)}to{transform:rotateY(-1turn)}}@-webkit-keyframes logo-rotate-x{0%{transform:rotateX(0deg)}to{transform:rotateX(-1turn)}}@keyframes logo-rotate-x{0%{transform:rotateX(0deg)}to{transform:rotateX(-1turn)}}@-webkit-keyframes logo-rotate-z{0%{transform:rotate(-1turn)}to{transform:rotate(0deg)}}@keyframes logo-rotate-z{0%{transform:rotate(-1turn)}to{transform:rotate(0deg)}}.wizard-step-form div.intro{margin-bottom:1.8292682927vw}@media (min-width:102.5em){.wizard-step-form div.intro{margin-bottom:30px}}@media (max-width:48.9275em){.wizard-step-form div.intro{margin-bottom:1.9157088123vw}}.wizard-step-form form{display:flex;flex-direction:column}.wizard-step-form form div.form-field{display:flex;flex-direction:column;border:1px solid #f3f3f3;background-color:#f3f3f3;padding:1.2195121951vw;border-radius:.9756097561vw;margin-bottom:1.2195121951vw}@media (min-width:102.5em){.wizard-step-form form div.form-field{padding:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field{padding:1.2771392082vw}}@media (min-width:102.5em){.wizard-step-form form div.form-field{border-radius:16px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field{border-radius:1.0217113665vw}}@media (min-width:102.5em){.wizard-step-form form div.form-field{margin-bottom:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field{margin-bottom:1.2771392082vw}}.wizard-step-form form div.form-field:last-of-type{margin-bottom:0}.wizard-step-form form div.form-field:focus-within{border:1px solid #50ade2}.wizard-step-form form div.form-field label{font-weight:500;font-size:.75em;line-height:1em;text-transform:uppercase;color:#3a5674;margin-bottom:.487804878vw}@media (min-width:102.5em){.wizard-step-form form div.form-field label{margin-bottom:8px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field label{margin-bottom:.5108556833vw}}.wizard-step-form form div.form-field input[type=password],.wizard-step-form form div.form-field input[type=text]{box-shadow:none;padding:0;border:0;background:none;font-size:1.125em}.wizard-step-form form div.form-field input[type=password]::-webkit-input-placeholder,.wizard-step-form form div.form-field input[type=text]::-webkit-input-placeholder{color:rgba(0,0,0,.125)}.wizard-step-form form div.form-field input[type=password]::-moz-placeholder,.wizard-step-form form div.form-field input[type=text]::-moz-placeholder{color:rgba(0,0,0,.125)}.wizard-step-form form div.form-field input[type=password]:-ms-input-placeholder,.wizard-step-form form div.form-field input[type=text]:-ms-input-placeholder{color:rgba(0,0,0,.125)}.wizard-step-form form div.form-field input[type=password]::-ms-input-placeholder,.wizard-step-form form div.form-field input[type=text]::-ms-input-placeholder{color:rgba(0,0,0,.125)}.wizard-step-form form div.form-field input[type=password]::placeholder,.wizard-step-form form div.form-field input[type=text]::placeholder{color:rgba(0,0,0,.125)}.wizard-step-form form div.form-field select{-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;background:transparent;outline:0;font-size:1.125em}.wizard-step-form form div.form-field select:focus{outline:0}.wizard-step-form form div.form-field.field-checkbox{background:none;flex-direction:row;align-items:flex-start;padding:1.2195121951vw 0;border:1px solid #fff}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox{padding-bottom:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox{padding-bottom:1.2771392082vw}}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox{padding-top:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox{padding-top:1.2771392082vw}}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox{padding-left:0}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox{padding-left:0}}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox{padding-right:0}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox{padding-right:0}}.wizard-step-form form div.form-field.field-checkbox div.checkbox{margin-right:1.2195121951vw}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox div.checkbox{margin-right:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox div.checkbox{margin-right:1.2771392082vw}}.wizard-step-form form div.form-field.field-checkbox div.title{padding-top:.3048780488vw;margin-right:1.2195121951vw;white-space:nowrap;font-size:1em;font-weight:500}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox div.title{padding-top:5px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox div.title{padding-top:.6385696041vw}}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox div.title{margin-right:20px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox div.title{margin-right:1.2771392082vw}}.wizard-step-form form div.form-field.field-checkbox div.description{padding-top:.3048780488vw;font-size:1em;font-weight:300}@media (min-width:102.5em){.wizard-step-form form div.form-field.field-checkbox div.description{padding-top:5px}}@media (max-width:48.9275em){.wizard-step-form form div.form-field.field-checkbox div.description{padding-top:.6385696041vw;display:none}}.wizard-step-form .progress{position:absolute;left:0;right:0;bottom:0;top:0;display:flex;flex-direction:column;align-items:center;justify-content:center;opacity:0;pointer-events:none;transition:opacity .25s linear;perspective:100em}.wizard-step-form .progress h3{color:#50abe0;margin-bottom:3.0487804878vw;font-size:1.625em}@media (min-width:102.5em){.wizard-step-form .progress h3{margin-bottom:50px}}.wizard-step-form .progress div.logo-spinner{-webkit-animation:logo-rotate 2s;animation:logo-rotate 2s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-timing-function:linear;animation-timing-function:linear}.wizard-step-form .progress div.logo-spinner img{width:7.3170731707vw;height:auto}@media (min-width:102.5em){.wizard-step-form .progress div.logo-spinner img{width:120px}}.wizard-step-form.processing .progress{opacity:1}.wizard-step-form.processing div.step-contents{-webkit-filter:blur(5px);filter:blur(5px)}.wizard-step-test{justify-content:flex-start}.wizard-step-test div.step-contents{margin-top:3.0487804878vw}@media (min-width:102.5em){.wizard-step-test div.step-contents{margin-top:50px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents{margin-top:6.3856960409vw}}.wizard-step-test div.step-contents div.intro{margin-bottom:1.8292682927vw}@media (min-width:102.5em){.wizard-step-test div.step-contents div.intro{margin-bottom:30px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents div.intro{margin-bottom:1.9157088123vw}}.wizard-step-test div.step-contents div.start-buttons{display:flex;justify-content:center;margin-bottom:1.8292682927vw}@media (max-width:48.9275em){.wizard-step-test div.step-contents div.start-buttons{margin-bottom:1.9157088123vw}}.wizard-step-test div.step-contents div.start-buttons a{font-style:normal;font-weight:500;font-size:1em;display:flex;align-items:center;justify-content:center;letter-spacing:.0457317073vw;text-transform:uppercase;text-decoration:none;color:#fff;border-radius:6.0975609756vw;padding:.9146341463vw 2.1341463415vw;background:linear-gradient(180deg,#62c5f1,#50ade2)}@media (min-width:102.5em){.wizard-step-test div.step-contents div.start-buttons a{letter-spacing:.75px;padding:15px 35px}}@media (min-width:102.5em){.wizard-step-test div.step-contents div.start-buttons{margin-bottom:30px}}.wizard-step-test div.step-contents ul.tests>li{border:1px solid #f3f3f3;background-color:#f3f3f3;border-radius:.9756097561vw;padding:1.2195121951vw;margin-bottom:20xp;display:flex;transition:opacity .25s linear}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li{border-radius:16px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li{border-radius:1.0217113665vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li{padding:20px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li{padding:1.2771392082vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li{margin-bottom:20xp}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li{margin-bottom:1.2771392082vw}}.wizard-step-test div.step-contents ul.tests>li.hidden{opacity:0}.wizard-step-test div.step-contents ul.tests>li div.icon{width:1.4634146341vw;min-width:1.4634146341vw;max-width:1.4634146341vw;height:1.4634146341vw;min-height:1.4634146341vw;max-height:1.4634146341vw;display:flex;justify-content:center;align-items:center;margin-right:.6097560976vw}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{width:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{width:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{min-width:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{min-width:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{max-width:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{max-width:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{height:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{height:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{min-height:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{min-height:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{max-height:24px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{max-height:3.0651340996vw}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.icon{margin-right:10px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.icon{margin-right:1.2771392082vw}}.wizard-step-test div.step-contents ul.tests>li div.icon img{display:none;width:100%;height:auto}.wizard-step-test div.step-contents ul.tests>li.waiting div.icon{perspective:100em}.wizard-step-test div.step-contents ul.tests>li.waiting div.icon img.waiting{display:block;-webkit-animation:logo-rotate-z 1s;animation:logo-rotate-z 1s;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-iteration-count:infinite;animation-iteration-count:infinite;-webkit-animation-timing-function:linear;animation-timing-function:linear}.wizard-step-test div.step-contents ul.tests>li.error>div.icon>img.error,.wizard-step-test div.step-contents ul.tests>li.success>div.icon>img.success,.wizard-step-test div.step-contents ul.tests>li.warning>div.icon>img.warning{display:block}.wizard-step-test div.step-contents ul.tests>li div.description h3{margin:.243902439vw 0;padding:0;font-size:1.125em}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-top:4px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-top:0}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-bottom:4px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-bottom:0}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-left:0}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-left:0}}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-right:0}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.description h3{margin-right:0}}.wizard-step-test div.step-contents ul.tests>li div.description p{margin:0 0 4px;padding:0;font-size:1em}.wizard-step-test div.step-contents ul.tests>li div.description ul.errors{margin-left:1.2195121951vw;list-style:disc}@media (min-width:102.5em){.wizard-step-test div.step-contents ul.tests>li div.description ul.errors{margin-left:20px}}@media (max-width:48.9275em){.wizard-step-test div.step-contents ul.tests>li div.description ul.errors{margin-left:1.2771392082vw}}.wizard-step-test div.step-contents ul.tests>li div.description ul.errors li{display:list-item;font-size:1em}.wizard-step-tutorial{justify-content:flex-start}.wizard-step-tutorial div.tutorial{padding-top:2.4390243902vw;margin-bottom:60px}@media (min-width:102.5em){.wizard-step-tutorial div.tutorial{padding-top:40px}}@media (max-width:48.9275em){.wizard-step-tutorial div.tutorial{padding-top:5.1085568327vw}}.wizard-step-tutorial div.tutorial h2,.wizard-step-tutorial div.tutorial h3{margin-top:2.4390243902vw}@media (min-width:102.5em){.wizard-step-tutorial div.tutorial h2,.wizard-step-tutorial div.tutorial h3{margin-top:40px}}@media (max-width:48.9275em){.wizard-step-tutorial div.tutorial h2,.wizard-step-tutorial div.tutorial h3{margin-top:2.5542784163vw}}.wizard-step-tutorial div.tutorial p{padding:0;margin:0 0 .6097560976vw;font-size:1.125em}@media (min-width:102.5em){.wizard-step-tutorial div.tutorial p{margin-bottom:10px}}@media (max-width:48.9275em){.wizard-step-tutorial div.tutorial p{margin-bottom:1.2771392082vw}}.wizard-step-tutorial div.tutorial p:last-of-type{margin-bottom:0}.wizard-step-tutorial div.tutorial figure{padding:0;margin:2.4390243902vw 0}@media (min-width:102.5em){.wizard-step-tutorial div.tutorial figure{margin-top:40px}}@media (max-width:48.9275em){.wizard-step-tutorial div.tutorial figure{margin-top:2.5542784163vw}}@media (min-width:102.5em){.wizard-step-tutorial div.tutorial figure{margin-bottom:40px}}@media (max-width:48.9275em){.wizard-step-tutorial div.tutorial figure{margin-bottom:2.5542784163vw}}.wizard-step-tutorial div.tutorial figure img{width:100%;height:auto}.wizard-step-tutorial div.tutorial ul{margin-left:20px;margin-bottom:30px;list-style:disc}.wizard-step-tutorial div.tutorial ul li{display:list-item}.wizard-modal.no-steps div.steps-background{opacity:0}.wizard-modal.no-steps div.wizard-content div.steps{transform:translateX(calc(100% + 1.95122vw));opacity:0}@media (min-width:102.5em){.wizard-modal.no-steps div.wizard-content div.steps{transform:translateX(calc(100% + 32px))}}.wizard-modal.no-steps div.wizard-content footer{margin-right:0}.wizard-modal.no-animations *{transition:none!important}.wizard-invisible .wizard-modal{transform:scale(.8);opacity:0}#s3-importer-progress{padding:24px;background:#ddd;border-radius:8px}#s3-importer-progress .button-whoa{background:#a42929!important;border-color:#e62a2a #a42929 #a42929!important;box-shadow:0 1px 0 #a42929!important;color:#fff!important;text-decoration:none!important;text-shadow:0 -1px 1px #a42929,1px 0 1px #a42929,0 1px 1px #a42929,-1px 0 1px #a42929!important}#s3-importer-progress>button{margin-top:20px}.s3-importer-progress-container{position:relative;width:100%;height:32px;background:#aaa;border-radius:16px;overflow:hidden;background-image:url(../img/candy-stripe.svg)}#s3-importer-progress-bar{background-color:#4f90c4;height:100%}.tool-disabled{padding:10px 15px;border:1px solid #df8403}.force-cancel-help{margin-top:20px}.wp-cli-callout{padding:24px;background:#ddd;margin-top:20px;border-radius:8px}.wp-cli-callout>h3{margin:0;padding:0;font-size:14px}.wp-cli-callout>code{background-color:#bbb;padding:10px 15px;margin-top:5px;display:inline-block}#s3-importer-options{padding:24px;background:#e7e7e7;margin-top:20px;border-radius:8px}#s3-importer-options h3{margin:0;padding:0;font-size:14px}#s3-importer-options ul{padding:0;display:flex;flex-direction:column;margin:20px 0 0}#s3-importer-options ul li{display:flex;margin-bottom:30px}#s3-importer-options ul li:last-of-type{margin-bottom:0}#s3-importer-options ul li>div:first-of-type{padding:10px 10px 20px 0;width:160px;min-width:160px;line-height:1.3;font-weight:600}#s3-importer-options ul li div.description{margin-top:8px}#s3-importer-options ul li div.option-ui{display:flex;align-items:center}#s3-importer-options ul li div.option-ui.option-ui-browser input[type=text]{width:40vw;margin-right:10px;padding:7px 11px;border-radius:4px}#s3-importer-options ul li div.option-ui.option-ui-browser input[type=text]:disabled{color:#000}#s3-timing-stats{display:none}#s3-importer-status-text{position:absolute;left:16px;top:0;bottom:0;right:16px;display:flex;align-items:center;color:#fff;font-weight:700}#s3-importer-thumbnails{position:relative;width:100%;height:150px;margin-bottom:15px}#s3-importer-thumbnails-container{position:absolute;left:0;top:0;right:0;bottom:0;overflow:hidden;-webkit-mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);mask-image:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%)}#s3-importer-thumbnails-container img{width:150px;height:150px;max-width:150px;max-height:150px;border-radius:4px}#s3-importer-thumbnails-container>img{margin-right:10px}#s3-importer-thumbnails-fade{background:linear-gradient(90deg,#ddd 0,hsla(0,0%,86.7%,0) 90%);position:absolute;left:150px;top:0;right:0;bottom:0}@supports ((-webkit-mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%)) or (mask-image:linear-gradient(to left,rgba(221,221,221,0) 0%,#dddddd 95%,#dddddd 100%))){#s3-importer-thumbnails-fade{display:none}}#s3-importer-thumbnails-cloud{position:absolute;right:20px;top:50%;transform:translateY(-50%)}.s3-importer-thumb{position:absolute;left:0;top:0;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;background-size:cover;background-position:50%;background-repeat:no-repeat;margin-right:10px;border-radius:4px;background-color:#888;transition:opacity .25s linear,transform .25s linear}.s3-importer-thumb.ilab-hidden{opacity:0;transform:scale(.7)}.s3-importer-image-icon{position:absolute;left:0;top:0;position:relative;width:150px;min-width:150px;max-width:150px;height:150px;min-height:150px;max-height:150px;display:flex;align-items:center;justify-content:center;transition:opacity .25s linear,transform .25s linear}.s3-importer-image-icon.ilab-hidden{opacity:0;transform:scale(.8)}.s3-importer-info-warning{border:1px solid orange;padding:24px;background:rgba(255,165,0,.125);margin-top:20px;border-radius:8px}.s3-importer-info-warning h4{padding:0;font-size:14px;margin:0 0 8px} \ No newline at end of file diff --git a/public/img/Group 3.svg b/public/img/Group 3.svg new file mode 100755 index 00000000..aab493c1 --- /dev/null +++ b/public/img/Group 3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/icon-cloud-w-type.svg b/public/img/icon-cloud-w-type.svg index 587ae2f8..639538d3 100755 --- a/public/img/icon-cloud-w-type.svg +++ b/public/img/icon-cloud-w-type.svg @@ -1 +1 @@ -MEDIA CLOUD \ No newline at end of file +MEDIA CLOUD \ No newline at end of file diff --git a/public/img/wizard-check.svg b/public/img/wizard-check.svg new file mode 100755 index 00000000..acd1606b --- /dev/null +++ b/public/img/wizard-check.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-close-modal.svg b/public/img/wizard-close-modal.svg new file mode 100755 index 00000000..2a3c9e69 --- /dev/null +++ b/public/img/wizard-close-modal.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-backblaze.png b/public/img/wizard-icon-backblaze.png new file mode 100755 index 00000000..4e0f36b2 Binary files /dev/null and b/public/img/wizard-icon-backblaze.png differ diff --git a/public/img/wizard-icon-backblaze.svg b/public/img/wizard-icon-backblaze.svg new file mode 100755 index 00000000..dec9ad0c --- /dev/null +++ b/public/img/wizard-icon-backblaze.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-do.svg b/public/img/wizard-icon-do.svg new file mode 100755 index 00000000..47c231d2 --- /dev/null +++ b/public/img/wizard-icon-do.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-error.svg b/public/img/wizard-icon-error.svg new file mode 100755 index 00000000..fc541e05 --- /dev/null +++ b/public/img/wizard-icon-error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-google.svg b/public/img/wizard-icon-google.svg new file mode 100755 index 00000000..2c8cd01e --- /dev/null +++ b/public/img/wizard-icon-google.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-humanmade.svg b/public/img/wizard-icon-humanmade.svg new file mode 100755 index 00000000..b7c26550 --- /dev/null +++ b/public/img/wizard-icon-humanmade.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-minio.png b/public/img/wizard-icon-minio.png new file mode 100755 index 00000000..cc577243 Binary files /dev/null and b/public/img/wizard-icon-minio.png differ diff --git a/public/img/wizard-icon-offload.svg b/public/img/wizard-icon-offload.svg new file mode 100755 index 00000000..8aef70c1 --- /dev/null +++ b/public/img/wizard-icon-offload.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-other-s3.svg b/public/img/wizard-icon-other-s3.svg new file mode 100755 index 00000000..0fdd279f --- /dev/null +++ b/public/img/wizard-icon-other-s3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-s3.svg b/public/img/wizard-icon-s3.svg new file mode 100755 index 00000000..fed92ad5 --- /dev/null +++ b/public/img/wizard-icon-s3.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-stateless.png b/public/img/wizard-icon-stateless.png new file mode 100755 index 00000000..e4f1c8fb Binary files /dev/null and b/public/img/wizard-icon-stateless.png differ diff --git a/public/img/wizard-icon-stateless.svg b/public/img/wizard-icon-stateless.svg new file mode 100755 index 00000000..ac700c5d --- /dev/null +++ b/public/img/wizard-icon-stateless.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-success.svg b/public/img/wizard-icon-success.svg new file mode 100755 index 00000000..37955c90 --- /dev/null +++ b/public/img/wizard-icon-success.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-warning.svg b/public/img/wizard-icon-warning.svg new file mode 100755 index 00000000..c2d6e002 --- /dev/null +++ b/public/img/wizard-icon-warning.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-icon-wasabi.png b/public/img/wizard-icon-wasabi.png new file mode 100755 index 00000000..01128f88 Binary files /dev/null and b/public/img/wizard-icon-wasabi.png differ diff --git a/public/img/wizard-spinner.svg b/public/img/wizard-spinner.svg new file mode 100755 index 00000000..f261881f --- /dev/null +++ b/public/img/wizard-spinner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizard-steps-bg.svg b/public/img/wizard-steps-bg.svg new file mode 100755 index 00000000..67d8160e --- /dev/null +++ b/public/img/wizard-steps-bg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/img/wizards-steps-full-bg.svg b/public/img/wizards-steps-full-bg.svg new file mode 100755 index 00000000..76a8b31e --- /dev/null +++ b/public/img/wizards-steps-full-bg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/public/js/ilab-dismiss-notice.js b/public/js/ilab-dismiss-notice.js index 3416131a..84739e79 100755 --- a/public/js/ilab-dismiss-notice.js +++ b/public/js/ilab-dismiss-notice.js @@ -1 +1 @@ -!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=280)}({280:function(e,t,n){e.exports=n(281)},281:function(e,t){var n;(n=jQuery)(function(){n("div[data-dismissible] button.notice-dismiss").click(function(e){e.preventDefault();var t,r=n(this);t={action:"ilab_dismiss_admin_notice",option_name:r.parent().attr("data-dismissible"),dismissible_length:r.parent().attr("data-dismissible-length"),nonce:ilab_dismissible_notice.nonce},n.post(ajaxurl,t)})})}}); \ No newline at end of file +!function(e){var t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(r,i,function(t){return e[t]}.bind(null,i));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=281)}({281:function(e,t,n){e.exports=n(282)},282:function(e,t){var n;(n=jQuery)(function(){n("div[data-dismissible] button.notice-dismiss").click(function(e){e.preventDefault();var t,r=n(this);t={action:"ilab_dismiss_admin_notice",option_name:r.parent().attr("data-dismissible"),dismissible_length:r.parent().attr("data-dismissible-length"),nonce:ilab_dismissible_notice.nonce},n.post(ajaxurl,t)})})}}); \ No newline at end of file diff --git a/public/js/ilab-face-detect.js b/public/js/ilab-face-detect.js index 2bfac012..89dc4b0b 100755 --- a/public/js/ilab-face-detect.js +++ b/public/js/ilab-face-detect.js @@ -1 +1 @@ -!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=302)}({14:function(t,e,r){t.exports=r(304)},302:function(t,e,r){t.exports=r(303)},303:function(t,e,r){"use strict";r.r(e);var n=r(14),i=r.n(n);function o(t,e,r,n,i,o,a){try{var h=t[o](a),u=h.value}catch(t){return void r(t)}h.done?e(u):Promise.resolve(u).then(n,i)}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function h(t){o(a,n,i,h,u,"next",t)}function u(t){o(a,n,i,h,u,"throw",t)}h(void 0)})}}window.ILABFaceDetector=function(t,e){if("undefined"==typeof faceapi)return null;var r=function(t,e){var r=Number.MAX_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,i=0,o=0;return t.forEach(function(t){r=Math.min(r,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),o=Math.max(o,t.y)}),{x1:r/e.width,x2:i/e.width,y1:n/e.height,y2:o/e.height,midX:(r+(i-r)/2)/e.width,midY:(n+(o-n)/2)/e.height,width:(i-r)/e.width,height:(o-n)/e.height}},n=function(t,e,r){var n=[];return t.forEach(function(t){var i=Math.sin(e),o=Math.cos(e);n.push({x:o*(t.x-r.x)-i*(t.y-r.y)+r.x,y:i*(t.x-r.x)+o*(t.y-r.y)+r.y})}),n},o=function(t,e){return{x:t.x/e.width,y:t.y/e.height}},h=function(t,e,i){var a=n(t,-e.angle,e.center),h=r(a,{width:1,height:1}),u=[{x:h.x1,y:h.y1},{x:h.x2,y:h.y2},{x:h.x1,y:h.y2},{x:h.x2,y:h.y1},{x:h.midX,y:h.y1},{x:h.x2,y:h.midY},{x:h.midX,y:h.y2},{x:h.x1,y:h.midY},{x:h.midX,y:h.midY}];return{x1:(u=n(u,e.angle,e.center))[0].x/i.width,x2:u[1].x/i.width,y1:u[0].y/i.height,y2:u[1].y/i.height,midX:u[2].x/i.width,midY:u[2].y/i.height,width:h.width/i.width,height:h.height/i.height,topLeft:o(u[0],i),bottomRight:o(u[1],i),bottomLeft:o(u[2],i),topRight:o(u[3],i),topMiddle:o(u[4],i),middleRight:o(u[5],i),bottomMiddle:o(u[6],i),middleLeft:o(u[7],i)}},u=function(t){var e=r(t.getLeftEye(),{width:1,height:1}),n=r(t.getRightEye(),{width:1,height:1}),i=Math.max(n.midX,e.midX),o=Math.min(n.midX,e.midX),a=Math.max(n.midY,e.midY),h=o-i,u=Math.min(n.midY,e.midY)-a;return{angle:Math.atan2(n.midY-e.midY,n.midX-e.midX),center:{x:i+h/2,y:a+u/2}}},c=function(){var t=a(i.a.mark(function t(){return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},250)}));case 1:case"end":return t.stop()}},t)}));return function(){return t.apply(this,arguments)}}(),d=function(){var t=a(i.a.mark(function t(o){var a;return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(window.loadedFaceData){t.next=6;break}return console.log("waiting for loaded."),t.next=4,c();case 4:t.next=0;break;case 6:return a=[],t.next=9,faceapi.detectAllFaces(o).withFaceLandmarks();case 9:t.sent.forEach(function(t){var e=t.detection.imageDims,i={Left:t.detection.box.x/e.width,Top:t.detection.box.y/e.height,Width:t.detection.box.width/e.width,Height:t.detection.box.height/e.height},o=[],c=u(t.landmarks);c.center={x:i.Left+i.Width/2,y:i.Top+i.Height/2};var d=h(t.landmarks.getMouth(),c,t.detection.imageDims);0!=d.width&&0!=d.height&&(o.push({Type:"mouthLeft",X:d.middleLeft.x,Y:d.middleLeft.y}),o.push({Type:"mouthRight",X:d.middleRight.x,Y:d.middleRight.y}),o.push({Type:"mouthUp",X:d.topMiddle.x,Y:d.topMiddle.y}),o.push({Type:"mouthDown",X:d.bottomMiddle.x,Y:d.bottomMiddle.y}));var f=h(t.landmarks.getLeftEye(),c,t.detection.imageDims);0!=f.width&&0!=f.height&&(o.push({Type:"eyeLeft",X:f.midX,Y:f.midY}),o.push({Type:"leftEyeLeft",X:f.middleLeft.x,Y:f.middleLeft.y}),o.push({Type:"leftEyeRight",X:f.middleRight.x,Y:f.middleRight.y}),o.push({Type:"leftEyeUp",X:f.topMiddle.x,Y:f.topMiddle.y}),o.push({Type:"leftEyeDown",X:f.bottomMiddle.x,Y:f.bottomMiddle.y}));var l=h(t.landmarks.getLeftEyeBrow(),c,t.detection.imageDims);0!=l.width&&0!=l.height&&(o.push({Type:"leftEyeBrowLeft",X:l.bottomLeft.x,Y:l.bottomLeft.y}),o.push({Type:"leftEyeBrowRight",X:l.bottomRight.x,Y:l.bottomRight.y}),o.push({Type:"leftEyeBrowUp",X:l.topMiddle.x,Y:l.topMiddle.y}));var s=h(t.landmarks.getRightEye(),c,t.detection.imageDims);0!=s.width&&0!=s.height&&(o.push({Type:"eyeRight",X:s.midX,Y:s.midY}),o.push({Type:"rightEyeLeft",X:s.middleLeft.x,Y:s.middleLeft.y}),o.push({Type:"rightEyeRight",X:s.middleRight.x,Y:s.middleRight.y}),o.push({Type:"rightEyeUp",X:s.topMiddle.x,Y:s.topMiddle.y}),o.push({Type:"rightEyeDown",X:s.bottomMiddle.x,Y:s.bottomMiddle.y}));var y=h(t.landmarks.getRightEyeBrow(),c,t.detection.imageDims);0!=y.width&&0!=y.height&&(o.push({Type:"rightEyeBrowLeft",X:y.bottomLeft.x,Y:y.bottomLeft.y}),o.push({Type:"rightEyeBrowRight",X:y.bottomRight.x,Y:y.bottomRight.y}),o.push({Type:"rightEyeBrowUp",X:y.topMiddle.x,Y:y.topMiddle.y}));var p=h(t.landmarks.getNose(),c,t.detection.imageDims);0!=p.width&&0!=p.height&&(o.push({Type:"nose",X:p.midX,Y:p.midY}),o.push({Type:"noseLeft",X:p.bottomLeft.x,Y:p.bottomLeft.y}),o.push({Type:"noseRight",X:p.bottomRight.x,Y:p.bottomRight.y}),o.push({Type:"noseUp",X:p.topMiddle.x,Y:p.topMiddle.y}),o.push({Type:"noseDown",X:p.bottomMiddle.x,Y:p.bottomMiddle.y}));var m=t.landmarks.getJawOutline();if(m.length>0){var g=n(m,-c.angle,c.center),x=r(g,{width:1,height:1}),w={x:Number.MAX_SAFE_INTEGER,y:Number.MAX_SAFE_INTEGER},v={x:0,y:Number.MAX_SAFE_INTEGER},E={x:Number.MAX_SAFE_INTEGER,y:Number.MAX_SAFE_INTEGER},b={x:0,y:Number.MAX_SAFE_INTEGER},L={x:x.midX,y:x.y2};g.forEach(function(t){t.y=0;--o){var a=this.tryEntries[o],h=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}}}); \ No newline at end of file +!function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="/",r(r.s=303)}({15:function(t,e,r){t.exports=r(305)},303:function(t,e,r){t.exports=r(304)},304:function(t,e,r){"use strict";r.r(e);var n=r(15),i=r.n(n);function o(t,e,r,n,i,o,a){try{var h=t[o](a),u=h.value}catch(t){return void r(t)}h.done?e(u):Promise.resolve(u).then(n,i)}function a(t){return function(){var e=this,r=arguments;return new Promise(function(n,i){var a=t.apply(e,r);function h(t){o(a,n,i,h,u,"next",t)}function u(t){o(a,n,i,h,u,"throw",t)}h(void 0)})}}window.ILABFaceDetector=function(t,e){if("undefined"==typeof faceapi)return null;var r=function(t,e){var r=Number.MAX_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,i=0,o=0;return t.forEach(function(t){r=Math.min(r,t.x),i=Math.max(i,t.x),n=Math.min(n,t.y),o=Math.max(o,t.y)}),{x1:r/e.width,x2:i/e.width,y1:n/e.height,y2:o/e.height,midX:(r+(i-r)/2)/e.width,midY:(n+(o-n)/2)/e.height,width:(i-r)/e.width,height:(o-n)/e.height}},n=function(t,e,r){var n=[];return t.forEach(function(t){var i=Math.sin(e),o=Math.cos(e);n.push({x:o*(t.x-r.x)-i*(t.y-r.y)+r.x,y:i*(t.x-r.x)+o*(t.y-r.y)+r.y})}),n},o=function(t,e){return{x:t.x/e.width,y:t.y/e.height}},h=function(t,e,i){var a=n(t,-e.angle,e.center),h=r(a,{width:1,height:1}),u=[{x:h.x1,y:h.y1},{x:h.x2,y:h.y2},{x:h.x1,y:h.y2},{x:h.x2,y:h.y1},{x:h.midX,y:h.y1},{x:h.x2,y:h.midY},{x:h.midX,y:h.y2},{x:h.x1,y:h.midY},{x:h.midX,y:h.midY}];return{x1:(u=n(u,e.angle,e.center))[0].x/i.width,x2:u[1].x/i.width,y1:u[0].y/i.height,y2:u[1].y/i.height,midX:u[2].x/i.width,midY:u[2].y/i.height,width:h.width/i.width,height:h.height/i.height,topLeft:o(u[0],i),bottomRight:o(u[1],i),bottomLeft:o(u[2],i),topRight:o(u[3],i),topMiddle:o(u[4],i),middleRight:o(u[5],i),bottomMiddle:o(u[6],i),middleLeft:o(u[7],i)}},u=function(t){var e=r(t.getLeftEye(),{width:1,height:1}),n=r(t.getRightEye(),{width:1,height:1}),i=Math.max(n.midX,e.midX),o=Math.min(n.midX,e.midX),a=Math.max(n.midY,e.midY),h=o-i,u=Math.min(n.midY,e.midY)-a;return{angle:Math.atan2(n.midY-e.midY,n.midX-e.midX),center:{x:i+h/2,y:a+u/2}}},c=function(){var t=a(i.a.mark(function t(){return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise(function(t){setTimeout(function(){t()},250)}));case 1:case"end":return t.stop()}},t)}));return function(){return t.apply(this,arguments)}}(),d=function(){var t=a(i.a.mark(function t(o){var a;return i.a.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(window.loadedFaceData){t.next=6;break}return console.log("waiting for loaded."),t.next=4,c();case 4:t.next=0;break;case 6:return a=[],t.next=9,faceapi.detectAllFaces(o).withFaceLandmarks();case 9:t.sent.forEach(function(t){var e=t.detection.imageDims,i={Left:t.detection.box.x/e.width,Top:t.detection.box.y/e.height,Width:t.detection.box.width/e.width,Height:t.detection.box.height/e.height},o=[],c=u(t.landmarks);c.center={x:i.Left+i.Width/2,y:i.Top+i.Height/2};var d=h(t.landmarks.getMouth(),c,t.detection.imageDims);0!=d.width&&0!=d.height&&(o.push({Type:"mouthLeft",X:d.middleLeft.x,Y:d.middleLeft.y}),o.push({Type:"mouthRight",X:d.middleRight.x,Y:d.middleRight.y}),o.push({Type:"mouthUp",X:d.topMiddle.x,Y:d.topMiddle.y}),o.push({Type:"mouthDown",X:d.bottomMiddle.x,Y:d.bottomMiddle.y}));var f=h(t.landmarks.getLeftEye(),c,t.detection.imageDims);0!=f.width&&0!=f.height&&(o.push({Type:"eyeLeft",X:f.midX,Y:f.midY}),o.push({Type:"leftEyeLeft",X:f.middleLeft.x,Y:f.middleLeft.y}),o.push({Type:"leftEyeRight",X:f.middleRight.x,Y:f.middleRight.y}),o.push({Type:"leftEyeUp",X:f.topMiddle.x,Y:f.topMiddle.y}),o.push({Type:"leftEyeDown",X:f.bottomMiddle.x,Y:f.bottomMiddle.y}));var l=h(t.landmarks.getLeftEyeBrow(),c,t.detection.imageDims);0!=l.width&&0!=l.height&&(o.push({Type:"leftEyeBrowLeft",X:l.bottomLeft.x,Y:l.bottomLeft.y}),o.push({Type:"leftEyeBrowRight",X:l.bottomRight.x,Y:l.bottomRight.y}),o.push({Type:"leftEyeBrowUp",X:l.topMiddle.x,Y:l.topMiddle.y}));var s=h(t.landmarks.getRightEye(),c,t.detection.imageDims);0!=s.width&&0!=s.height&&(o.push({Type:"eyeRight",X:s.midX,Y:s.midY}),o.push({Type:"rightEyeLeft",X:s.middleLeft.x,Y:s.middleLeft.y}),o.push({Type:"rightEyeRight",X:s.middleRight.x,Y:s.middleRight.y}),o.push({Type:"rightEyeUp",X:s.topMiddle.x,Y:s.topMiddle.y}),o.push({Type:"rightEyeDown",X:s.bottomMiddle.x,Y:s.bottomMiddle.y}));var y=h(t.landmarks.getRightEyeBrow(),c,t.detection.imageDims);0!=y.width&&0!=y.height&&(o.push({Type:"rightEyeBrowLeft",X:y.bottomLeft.x,Y:y.bottomLeft.y}),o.push({Type:"rightEyeBrowRight",X:y.bottomRight.x,Y:y.bottomRight.y}),o.push({Type:"rightEyeBrowUp",X:y.topMiddle.x,Y:y.topMiddle.y}));var p=h(t.landmarks.getNose(),c,t.detection.imageDims);0!=p.width&&0!=p.height&&(o.push({Type:"nose",X:p.midX,Y:p.midY}),o.push({Type:"noseLeft",X:p.bottomLeft.x,Y:p.bottomLeft.y}),o.push({Type:"noseRight",X:p.bottomRight.x,Y:p.bottomRight.y}),o.push({Type:"noseUp",X:p.topMiddle.x,Y:p.topMiddle.y}),o.push({Type:"noseDown",X:p.bottomMiddle.x,Y:p.bottomMiddle.y}));var m=t.landmarks.getJawOutline();if(m.length>0){var g=n(m,-c.angle,c.center),x=r(g,{width:1,height:1}),w={x:Number.MAX_SAFE_INTEGER,y:Number.MAX_SAFE_INTEGER},v={x:0,y:Number.MAX_SAFE_INTEGER},E={x:Number.MAX_SAFE_INTEGER,y:Number.MAX_SAFE_INTEGER},b={x:0,y:Number.MAX_SAFE_INTEGER},L={x:x.midX,y:x.y2};g.forEach(function(t){t.y=0;--o){var a=this.tryEntries[o],h=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),T(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:R(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}}}); \ No newline at end of file diff --git a/public/js/ilab-image-sizes.js b/public/js/ilab-image-sizes.js index 874e751d..5b9d5f9b 100755 --- a/public/js/ilab-image-sizes.js +++ b/public/js/ilab-image-sizes.js @@ -1 +1 @@ -!function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=282)}({282:function(e,t,n){e.exports=n(283)},283:function(e,t){jQuery(document).ready(function(e){var t=null;e(".ilab-size-row").each(function(){var n=e(this),i=e(this).hasClass("ilab-custom-size-row"),a=e(n.find("input[name=nonce]")[0]).val(),o=n.find('input[name="size"]').val(),u=0,r=function(){var t=n.find('input[name="width"]').val(),i=n.find('input[name="height"]').val(),r=n.find('input[name="'+o+'__crop"]')[0].checked,l=n.find('select[name="x-axis"]').val(),c=n.find('select[name="y-axis"]').val(),s={action:"ilab_update_image_size",size:o,nonce:a,width:t,height:i,crop:r,xAxis:l,yAxis:c};clearTimeout(u),u=setTimeout(function(){e.post(ajaxurl,s,function(e){})},1e3)};i&&(n.find('input[type="number"]').on("change",function(){r()}),n.find('input[type="checkbox"]').on("change",function(){r()}),n.find("select").on("change",function(){r()}),n.find(".ilab-delete-size-button").on("click",function(t){if(t.preventDefault(),confirm("Are you sure you want to delete this image size?")){var i={action:"ilab_delete_image_size",size:o,nonce:a};e.post(ajaxurl,i,function(e){"ok"==e.status&&n.remove()})}return!1})),n.find(".ilab-size-settings-button").on("click",function(e){if(e.preventDefault(),null==t){alert("Select a sample image to use to edit this image size settings.");var n=wp.media({title:"Select a image to use",button:{text:"Use this image"},multiple:!1});n.on("select",function(){t=n.state().get("selection").first().toJSON().id,ILabModal.loadURL(ajaxurl+"?action=ilab_dynamic_images_edit_page&image_id="+t+"&size="+o+"&mode=size",!1,null)}),n.open()}else ILabModal.loadURL(ajaxurl+"?action=ilab_dynamic_images_edit_page&image_id="+t+"&size="+o+"&mode=size",!1,null);return!1})})})}}); \ No newline at end of file +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var a=t[i]={i:i,l:!1,exports:{}};return e[i].call(a.exports,a,a.exports,n),a.l=!0,a.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(i,a,function(t){return e[t]}.bind(null,a));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=283)}({283:function(e,t,n){e.exports=n(284)},284:function(e,t){jQuery(document).ready(function(e){var t=null;e(".ilab-size-row").each(function(){var n=e(this),i=e(this).hasClass("ilab-custom-size-row"),a=e(n.find("input[name=nonce]")[0]).val(),o=n.find('input[name="size"]').val(),u=0,r=function(){var t=n.find('input[name="width"]').val(),i=n.find('input[name="height"]').val(),r=n.find('input[name="'+o+'__crop"]')[0].checked,l=n.find('select[name="x-axis"]').val(),c=n.find('select[name="y-axis"]').val(),s={action:"ilab_update_image_size",size:o,nonce:a,width:t,height:i,crop:r,xAxis:l,yAxis:c};clearTimeout(u),u=setTimeout(function(){e.post(ajaxurl,s,function(e){})},1e3)};i&&(n.find('input[type="number"]').on("change",function(){r()}),n.find('input[type="checkbox"]').on("change",function(){r()}),n.find("select").on("change",function(){r()}),n.find(".ilab-delete-size-button").on("click",function(t){if(t.preventDefault(),confirm("Are you sure you want to delete this image size?")){var i={action:"ilab_delete_image_size",size:o,nonce:a};e.post(ajaxurl,i,function(e){"ok"==e.status&&n.remove()})}return!1})),n.find(".ilab-size-settings-button").on("click",function(e){if(e.preventDefault(),null==t){alert("Select a sample image to use to edit this image size settings.");var n=wp.media({title:"Select a image to use",button:{text:"Use this image"},multiple:!1});n.on("select",function(){t=n.state().get("selection").first().toJSON().id,ILabModal.loadURL(ajaxurl+"?action=ilab_dynamic_images_edit_page&image_id="+t+"&size="+o+"&mode=size",!1,null)}),n.open()}else ILabModal.loadURL(ajaxurl+"?action=ilab_dynamic_images_edit_page&image_id="+t+"&size="+o+"&mode=size",!1,null);return!1})})})}}); \ No newline at end of file diff --git a/public/js/ilab-media-direct-upload-google.js b/public/js/ilab-media-direct-upload-google.js index 1760a3e8..b2b45fde 100755 --- a/public/js/ilab-media-direct-upload-google.js +++ b/public/js/ilab-media-direct-upload-google.js @@ -1 +1 @@ -!function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="/",r(r.s=274)}({274:function(e,o,r){e.exports=r(275)},275:function(e,o){window.ILABUploadToGoogleStorage=function(e,o,r,t){var n={action:"ilab_upload_prepare",filename:e.name,type:r};t.hasOwnProperty("uploadDirectory")&&(n.directory=t.uploadDirectory),jQuery.post(ajaxurl,n,function(r){if("ready"==r.status){t.set({state:"uploading"});var n=r.key;r.acl;jQuery.ajax({url:r.url,method:"POST",headers:{"x-goog-resumable":"start","Content-Type":e.type},success:function(r,a,u){var l=u.getResponseHeader("location");jQuery.ajax({url:l,method:"PUT",processData:!1,crossDomain:!0,data:e,contentType:e.type,xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){t.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){t.uploadFinished(n,o)},error:function(e){t.uploadError()}})},error:function(e){t.uploadError()}})}else t.uploadError()})},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToGoogleStorage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToGoogleStorage}}); \ No newline at end of file +!function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="/",r(r.s=275)}({275:function(e,o,r){e.exports=r(276)},276:function(e,o){window.ILABUploadToGoogleStorage=function(e,o,r,t){var n={action:"ilab_upload_prepare",filename:e.name,type:r};t.hasOwnProperty("uploadDirectory")&&(n.directory=t.uploadDirectory),jQuery.post(ajaxurl,n,function(r){if("ready"==r.status){t.set({state:"uploading"});var n=r.key;r.acl;jQuery.ajax({url:r.url,method:"POST",headers:{"x-goog-resumable":"start","Content-Type":e.type},success:function(r,a,u){var l=u.getResponseHeader("location");jQuery.ajax({url:l,method:"PUT",processData:!1,crossDomain:!0,data:e,contentType:e.type,xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){t.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){t.uploadFinished(n,o)},error:function(e){t.uploadError()}})},error:function(e){t.uploadError()}})}else t.uploadError()})},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToGoogleStorage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToGoogleStorage}}); \ No newline at end of file diff --git a/public/js/ilab-media-direct-upload-other-s3.js b/public/js/ilab-media-direct-upload-other-s3.js index 75dd373f..62dfd263 100755 --- a/public/js/ilab-media-direct-upload-other-s3.js +++ b/public/js/ilab-media-direct-upload-other-s3.js @@ -1 +1 @@ -!function(e){var o={};function t(r){if(o[r])return o[r].exports;var n=o[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)t.d(r,n,function(o){return e[o]}.bind(null,n));return r},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="/",t(t.s=276)}({276:function(e,o,t){e.exports=t(277)},277:function(e,o){window.ILABUploadToOtherS3Storage=function(e,o,t,r){var n={action:"ilab_upload_prepare",filename:e.name,type:t};r.hasOwnProperty("uploadDirectory")&&(n.directory=r.uploadDirectory),jQuery.post(ajaxurl,n,function(t){if("ready"==t.status){r.set({state:"uploading"});var n=new XMLHttpRequest;n.open("PUT",t.url,!0),n.upload.onprogress=function(e){r.set({progress:e.loaded/e.total*100})},n.onload=function(){t.hasOwnProperty("key")?r.uploadFinished(t.key,o):r.uploadError()},n.onerror=function(){r.uploadError()},n.send(e)}else r.uploadError()}.bind(this))},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToOtherS3Storage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToOtherS3Storage}}); \ No newline at end of file +!function(e){var o={};function t(r){if(o[r])return o[r].exports;var n=o[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)t.d(r,n,function(o){return e[o]}.bind(null,n));return r},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="/",t(t.s=277)}({277:function(e,o,t){e.exports=t(278)},278:function(e,o){window.ILABUploadToOtherS3Storage=function(e,o,t,r){var n={action:"ilab_upload_prepare",filename:e.name,type:t};r.hasOwnProperty("uploadDirectory")&&(n.directory=r.uploadDirectory),jQuery.post(ajaxurl,n,function(t){if("ready"==t.status){r.set({state:"uploading"});var n=new XMLHttpRequest;n.open("PUT",t.url,!0),n.upload.onprogress=function(e){r.set({progress:e.loaded/e.total*100})},n.onload=function(){t.hasOwnProperty("key")?r.uploadFinished(t.key,o):r.uploadError()},n.onerror=function(){r.uploadError()},n.send(e)}else r.uploadError()}.bind(this))},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToOtherS3Storage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToOtherS3Storage}}); \ No newline at end of file diff --git a/public/js/ilab-media-direct-upload-s3.js b/public/js/ilab-media-direct-upload-s3.js index 8ed25da7..bd407676 100755 --- a/public/js/ilab-media-direct-upload-s3.js +++ b/public/js/ilab-media-direct-upload-s3.js @@ -1 +1 @@ -!function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="/",r(r.s=272)}({272:function(e,o,r){e.exports=r(273)},273:function(e,o){window.ILABUploadToS3Storage=function(e,o,r,t){console.log(e,t);var n={action:"ilab_upload_prepare",filename:e.name,type:r};t.hasOwnProperty("uploadDirectory")&&(n.directory=t.uploadDirectory),console.log(t),jQuery.post(ajaxurl,n,function(n){if(console.log(t),"ready"==n.status){t.set({state:"uploading"});var a=new FormData;_.each(Object.keys(n.formData),function(e){"key"!=e&&a.append(e,n.formData[e])}),null!=n.cacheControl&&n.cacheControl.length>0&&a.append("Cache-Control",n.cacheControl),null!=n.expires&&a.append("Expires",n.expires),a.append("Content-Type",r),a.append("acl",n.acl),a.append("key",n.key),a.append("file",e),jQuery.ajax({url:n.url,method:"POST",contentType:!1,processData:!1,data:a,xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){t.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){n.hasOwnProperty("key")?t.uploadFinished(n.key,o):t.uploadError()},error:function(e){t.uploadError()}})}else t.uploadError()})},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToS3Storage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToS3Storage}}); \ No newline at end of file +!function(e){var o={};function r(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=o,r.d=function(e,o,t){r.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,o){if(1&o&&(e=r(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var n in e)r.d(t,n,function(o){return e[o]}.bind(null,n));return t},r.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(o,"a",o),o},r.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},r.p="/",r(r.s=273)}({273:function(e,o,r){e.exports=r(274)},274:function(e,o){window.ILABUploadToS3Storage=function(e,o,r,t){console.log(e,t);var n={action:"ilab_upload_prepare",filename:e.name,type:r};t.hasOwnProperty("uploadDirectory")&&(n.directory=t.uploadDirectory),console.log(t),jQuery.post(ajaxurl,n,function(n){if(console.log(t),"ready"==n.status){t.set({state:"uploading"});var a=new FormData;_.each(Object.keys(n.formData),function(e){"key"!=e&&a.append(e,n.formData[e])}),null!=n.cacheControl&&n.cacheControl.length>0&&a.append("Cache-Control",n.cacheControl),null!=n.expires&&a.append("Expires",n.expires),a.append("Content-Type",r),a.append("acl",n.acl),a.append("key",n.key),a.append("file",e),jQuery.ajax({url:n.url,method:"POST",contentType:!1,processData:!1,data:a,xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){t.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){n.hasOwnProperty("key")?t.uploadFinished(n.key,o):t.uploadError()},error:function(e){t.uploadError()}})}else t.uploadError()})},"undefined"!=typeof DirectUploadItem&&(DirectUploadItem.prototype.uploadToStorage=ILABUploadToS3Storage),ilabMediaUploadItem.prototype.uploadToStorage=ILABUploadToS3Storage}}); \ No newline at end of file diff --git a/public/js/ilab-media-direct-upload.js b/public/js/ilab-media-direct-upload.js index 849f0226..8bda1cc8 100755 --- a/public/js/ilab-media-direct-upload.js +++ b/public/js/ilab-media-direct-upload.js @@ -1 +1 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=184)}([,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=(e,t,r,n)=>{if(t+r>e.length){if("function"!=typeof n)throw new Error("Buffer out of space and no valid flush() function found");return n(e,t),0}return t};t.UINT8={len:1,get:(e,t)=>e.readUInt8(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=255),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt8(r,s),s-t+this.len}},t.UINT16_LE={len:2,get:(e,t)=>e.readUInt16LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=65535),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt16LE(r,s),s-t+this.len}},t.UINT16_BE={len:2,get:(e,t)=>e.readUInt16BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=65535),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt16BE(r,s),s-t+this.len}},t.UINT24_LE={len:3,get:(e,t)=>e.readUIntLE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=16777215),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUIntLE(r,s,3),s-t+this.len}},t.UINT24_BE={len:3,get:(e,t)=>e.readUIntBE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=16777215),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUIntBE(r,s,3),s-t+this.len}},t.UINT32_LE={len:4,get:(e,t)=>e.readUInt32LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=4294967295),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt32LE(r,s),s-t+this.len}},t.UINT32_BE={len:4,get:(e,t)=>e.readUInt32BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=4294967295),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt32BE(r,s),s-t+this.len}},t.INT8={len:1,get:(e,t)=>e.readInt8(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-128&&r<=127),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt8(r,s),s-t+this.len}},t.INT16_BE={len:2,get:(e,t)=>e.readInt16BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-32768&&r<=32767),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt16BE(r,s),s-t+this.len}},t.INT16_LE={len:2,get:(e,t)=>e.readInt16LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-32768&&r<=32767),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt16LE(r,s),s-t+this.len}},t.INT24_LE={len:3,get:(e,t)=>e.readIntLE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-8388608&&r<=8388607),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeIntLE(r,s,3),s-t+this.len}},t.INT24_BE={len:3,get:(e,t)=>e.readIntBE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-8388608&&r<=8388607),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeIntBE(r,s,3),s-t+this.len}},t.INT32_BE={len:4,get:(e,t)=>e.readInt32BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-2147483648&&r<=2147483647),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt32BE(r,s),s-t+this.len}},t.INT32_LE={len:4,get:(e,t)=>e.readInt32LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-2147483648&&r<=2147483647),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt32LE(r,s),s-t+this.len}},t.UINT64_LE={len:8,get(e,t){return function(e,t,r){r>>>=0;let n=e[t>>>=0],i=1,a=0;for(;++a>>=0;let i=1,a=0;e[r>>>=0]=255&t;for(;++a>>=0;let n=e[t>>>=0],i=1,a=0;for(;++a=(i*=128)&&(n-=Math.pow(2,8*r));return n}(e,t,this.len)},put(e,t,r){return s(e,r,t,this.len)}},t.UINT64_BE={len:8,get(e,t){return o(e,t,this.len)},put(e,t,r){return c(e,r,t,this.len)}},t.INT64_BE={len:8,get(e,t){return u(e,t,this.len)},put(e,t,r){return l(e,r,t,this.len)}};t.IgnoreType=class{constructor(e){this.len=e}get(e,t){return null}};t.BufferType=class{constructor(e){this.len=e}get(e,t){return e.slice(t,t+this.len)}};t.StringType=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t){return e.toString(this.encoding,t,t+this.len)}};class a{constructor(e){this.len=e}static decode(e,t,r){let n="";for(let i=t;i>10),56320+(1023&e)))}static singleByteDecoder(e){if(a.inRange(e,0,127))return e;const t=a.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}get(e,t=0){return a.decode(e,t,t+this.len)}}function s(e,t,r,n){t=+t;let i=0,a=1,s=0;for(e[r>>>=0]=255&t;++i>0)-s&255;return r+n}function o(e,t,r){r>>>=0;let n=e[(t>>>=0)+--r],i=1;for(;r>0&&(i*=256);)n+=e[t+--r]*i;return n}function c(e,t,r,n){t=+t;let i=(n>>>=0)-1,a=1;for(e[(r>>>=0)+i]=255&t;--i>=0&&(a*=256);)e[r+i]=t/a&255;return r+n}function u(e,t,r){let n=r>>>=0,i=1,a=e[(t>>>=0)+--n];for(;n>0&&(i*=256);)a+=e[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*r)),a}function l(e,t,r,n){t=+t;let i=n-1,a=1,s=0;for(e[(r>>>=0)+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==e[r+i+1]&&(s=1),e[r+i]=(t/a>>0)-s&255;return r+n}a.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],t.AnsiStringType=a,t.writeIntLE=s,t.readUIntBE=o,t.writeUIntBE=c,t.readIntBE=u,t.writeIntBE=l},function(e,t,r){(function(n){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(208)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){"use strict";(function(e){var n=r(186),i=r(187),a=r(33);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function h(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return F(this,t,r);case"latin1":case"binary":return A(this,t,r);case"base64":return C(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var a,s=1,o=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(a=r;ao&&(r=o-c),a=r;a>=0;a--){for(var d=!0,f=0;fi&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var s=0;s>8,i=r%256,a.push(i),a.push(n);return a}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function E(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+d<=r)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(a=e[i+1]))&&(c=(31&u)<<6|63&a)>127&&(l=c);break;case 3:a=e[i+1],s=e[i+2],128==(192&a)&&128==(192&s)&&(c=(15&u)<<12|(63&a)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:a=e[i+1],s=e[i+2],o=e[i+3],128==(192&a)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&a)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=d}return function(e){var t=e.length;if(t<=_)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),o=Math.min(a,s),u=this.slice(n,i),l=e.slice(t,r),d=0;di)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return T(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return I(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function F(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,i,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function D(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function O(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function R(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,a){return a||R(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,a){return a||R(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||B(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||B(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||B(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||B(e,t,this.length);for(var n=this[e],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||B(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||B(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||B(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||B(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||B(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):O(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);M(this,e,t,r,i-1,-i)}var a=0,s=1,o=0;for(this[t]=255&e;++a>0)-o&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);M(this,e,t,r,i-1,-i)}var a=r-1,s=1,o=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/s>>0)-o&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(214);class a{static findZero(e,t,r,n){let i=t;if("utf16"===n){for(;0!==e[i]||0!==e[i+1];){if(i>=r)return r;i+=2}return i}for(;0!==e[i];){if(i>=r)return r;i++}return i}static trimRightNull(e){const t=e.indexOf("\0");return-1===t?e:e.substr(0,t)}static swapBytes(e){const t=e.length;n.ok(0==(1&t),"Buffer length must be even");for(let r=0;r>i;const o=8-i,c=n-o;return c<0?s>>=8-i-n:c>0&&(s<<=c,s|=a.getBitAllignedNumber(e,t,r+o,c)),s}static isBitSet(e,t,r){return 1===a.getBitAllignedNumber(e,t,r,1)}static a2hex(e){const t=[];for(let r=0,n=e.length;r0!=(e[t]&1<e.trim().toLowerCase());if(t.length>=1){const e=parseFloat(t[0]);return 2===t.length&&"db"===t[1]?{dB:e,ratio:o(e)}:{dB:s(e),ratio:e}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),i=/^[\w-©][\w-\x000-3]/;t.FourCcToken={len:4,get:(e,r)=>{const a=e.toString("binary",r,r+t.FourCcToken.len);if(!a.match(i))throw new Error(`FourCC contains invalid characters: ${n.default.a2hex(a)}`);return a},put:(t,r,n)=>{const i=e.from(n,"binary");if(4!==i.length)throw new Error("Invalid length");return i.copy(t,r)}}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(195);function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i=0;u--)if(l[u]!==d[u])return!1;for(u=l.length-1;u>=0;u--)if(o=l[u],!w(e[o],t[o],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function T(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function I(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&b(i,r,"Missing expected exception"+n);var a="string"==typeof n,o=!e&&i&&!r;if((!e&&s.isError(i)&&a&&v(i,r)||o)&&b(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}f.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return m(g(e.actual),128)+" "+e.operator+" "+m(g(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=h(t),a=n.indexOf("\n"+i);if(a>=0){var s=n.indexOf("\n",a+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(f.AssertionError,Error),f.fail=b,f.ok=y,f.equal=function(e,t,r){e!=t&&b(e,t,r,"==",f.equal)},f.notEqual=function(e,t,r){e==t&&b(e,t,r,"!=",f.notEqual)},f.deepEqual=function(e,t,r){w(e,t,!1)||b(e,t,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,r){w(e,t,!0)||b(e,t,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,r){w(e,t,!1)&&b(e,t,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function e(t,r,n){w(t,r,!0)&&b(t,r,n,"notDeepStrictEqual",e)},f.strictEqual=function(e,t,r){e!==t&&b(e,t,r,"===",f.strictEqual)},f.notStrictEqual=function(e,t,r){e===t&&b(e,t,r,"!==",f.notStrictEqual)},f.throws=function(e,t,r){I(!0,e,t,r)},f.doesNotThrow=function(e,t,r){I(!1,e,t,r)},f.ifError=function(e){if(e)throw e},f.strict=n(function e(t,r){t||b(t,!0,r,"==",e)},f,{equal:f.strictEqual,deepEqual:f.deepStrictEqual,notEqual:f.notStrictEqual,notDeepEqual:f.notDeepStrictEqual}),f.strict.strict=f.strict;var k=Object.keys||function(e){var t=[];for(var r in e)o.call(e,r)&&t.push(r);return t}}).call(this,r(11))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BasicParser=class{constructor(){this.warnings=[]}init(e,t,r){return this.metadata=e,this.tokenizer=t,this.options=r,this}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(24);class i{constructor(e,t){this.tagTypes=e,this.tagMap=t}static parseGenre(e){const t=e.trim().split(/\((.*?)\)/g).filter(e=>""!==e),r=[];for(let e of t)/^\d+$/.test(e)&&!isNaN(parseInt(e,10))&&(e=n.Genres[e]),r.push(e);return r.filter(e=>void 0!==e).join("/")}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase()){case"image/jpg":return"image/jpeg"}return e}static toIntOrNull(e){const t=parseInt(e,10);return isNaN(t)?null:t}static normalizeTrack(e){const t=e.toString().split("/");return{no:parseInt(t[0],10)||null,of:parseInt(t[1],10)||null}}mapGenericTag(e){e={id:e.id,value:e.value},this.postMap(e);const t=this.getCommonName(e.id);return t?{id:t,value:e.value}:null}getCommonName(e){return this.tagMap[e]}postMap(e){}}i.maxRatingScore=1,t.CommonTagMapper=i},function(e,t){var r,n,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var c,u=[],l=!1,d=-1;function f(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&p())}function p(){if(!l){var e=o(f);l=!0;for(var t=u.length;t;){for(c=u,u=[];++d1)for(var r=1;r0?this.parseExtendedHeaderData(t,e.size):this.parseId3Data(this.id3Header.size-e.size)}async parseExtendedHeaderData(t,r){const n=e.alloc(t);return await this.tokenizer.readBuffer(n,0,t),this.parseId3Data(this.id3Header.size-r)}async parseId3Data(t){const r=e.alloc(t);await this.tokenizer.readBuffer(r,0,t);for(const e of this.parseMetadata(r))if("TXXX"===e.id)for(const t of e.value.text)this.addTag(o.makeDescriptionTagName(e.id,e.value.description),t);else if("COM"===e.id)for(const t of e.value)this.addTag(o.makeDescriptionTagName(e.id,t.description),t.text);else if(Array.isArray(e.value))for(const t of e.value)this.addTag(e.id,t);else this.addTag(e.id,e.value)}addTag(e,t){this.metadata.addTag(this.headerType,e,t)}parseMetadata(e){let t=0;const r=[];for(;t!==e.length;){const n=o.getFrameHeaderLength(this.id3Header.version.major);if(t+n>e.length)break;const i=e.slice(t,t+=n),a=o.readFrameHeader(i,this.id3Header.version.major);if(""===a.id||"\0\0\0\0"===a.id||-1==="ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(a.id[0]))break;const s=e.slice(t,t+=a.length),c=o.readFrameData(s,a,this.id3Header.version.major,!this.options.skipCovers);r.push({id:a.id,value:c})}return r}}t.ID3v2Parser=o}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);!function(e){e[e.Other=0]="Other",e[e["32x32 pixels 'file icon' (PNG only)"]=1]="32x32 pixels 'file icon' (PNG only)",e[e["Other file icon"]=2]="Other file icon",e[e["Cover (front)"]=3]="Cover (front)",e[e["Cover (back)"]=4]="Cover (back)",e[e["Leaflet page"]=5]="Leaflet page",e[e["Media (e.g. label side of CD)"]=6]="Media (e.g. label side of CD)",e[e["Lead artist/lead performer/soloist"]=7]="Lead artist/lead performer/soloist",e[e["Artist/performer"]=8]="Artist/performer",e[e.Conductor=9]="Conductor",e[e["Band/Orchestra"]=10]="Band/Orchestra",e[e.Composer=11]="Composer",e[e["Lyricist/text writer"]=12]="Lyricist/text writer",e[e["Recording Location"]=13]="Recording Location",e[e["During recording"]=14]="During recording",e[e["During performance"]=15]="During performance",e[e["Movie/video screen capture"]=16]="Movie/video screen capture",e[e["A bright coloured fish"]=17]="A bright coloured fish",e[e.Illustration=18]="Illustration",e[e["Band/artist logotype"]=19]="Band/artist logotype",e[e["Publisher/Studio logotype"]=20]="Publisher/Studio logotype"}(t.AttachedPictureType||(t.AttachedPictureType={})),t.UINT32SYNCSAFE={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},t.ID3v2Header={len:10,get:(e,r)=>({fileIdentifier:new n.StringType(3,"ascii").get(e,r),version:{major:n.INT8.get(e,r+3),revision:n.INT8.get(e,r+4)},flags:{raw:n.INT8.get(e,r+4),unsynchronisation:i.default.strtokBITSET.get(e,r+5,7),isExtendedHeader:i.default.strtokBITSET.get(e,r+5,6),expIndicator:i.default.strtokBITSET.get(e,r+5,5),footer:i.default.strtokBITSET.get(e,r+5,4)},size:t.UINT32SYNCSAFE.get(e,r+6)})},t.ExtendedHeader={len:10,get:(e,t)=>({size:n.UINT32_BE.get(e,t),extendedFlags:n.UINT16_BE.get(e,t+4),sizeOfPadding:n.UINT32_BE.get(e,t+6),crcDataPresent:i.default.strtokBITSET.get(e,t+4,31)})},t.TextEncodingToken={len:1,get:(e,t)=>{switch(e.readUInt8(t)){case 0:return{encoding:"iso-8859-1"};case 1:return{encoding:"utf16",bom:!0};case 2:return{encoding:"utf16",bom:!1};case 3:default:return{encoding:"utf8",bom:!1}}}}},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(192),i=r(202);t.fromStream=function(e,t){return new n.ReadStreamTokenizer(e,t)},t.fromBuffer=function(e){return new i.BufferTokenizer(e)}},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var a,s,o=arguments.length;switch(o){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(a=new Array(o-1),s=0;s1?e.blocksPerFrame*(e.totalFrames-1):0;return(t+=e.finalFrameBlocks)/e.sampleRate}static async parseTagHeader(t,r,n){if(r.fileSize&&r.fileSize-r.position0?this.parseDescriptorExpansion(t):this.parseHeader());return await this.tokenizer.readToken(new a.IgnoreType(r.forwardBytes)),p.parseTagHeader(this.metadata,this.tokenizer,this.options)}async parseDescriptorExpansion(e){return await this.tokenizer.readToken(new a.IgnoreType(e)),this.parseHeader()}async parseHeader(){const e=await this.tokenizer.readToken(u.Header);return this.metadata.setFormat("lossless",!0),this.metadata.setFormat("container","Monkey's Audio"),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("sampleRate",e.sampleRate),this.metadata.setFormat("numberOfChannels",e.channel),this.metadata.setFormat("duration",p.calculateDuration(e)),{forwardBytes:this.ape.descriptor.seekTableBytes+this.ape.descriptor.headerDataBytes+this.ape.descriptor.apeFrameDataBytes+this.ape.descriptor.terminatingDataBytes}}}t.APEv2Parser=p}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(18),a=r(17),s=r(24),o=r(2),c=r(7),u=o("music-metadata:parser:ID3");t.AbstractID3Parser=class extends c.BasicParser{constructor(){super(...arguments),this.id3parser=new a.ID3v2Parser}static async startsWithID3v2Header(e){return"ID3"===(await e.peekToken(i.ID3v2Header)).fileIdentifier}parse(){return this.parseID3v2().catch(e=>{if(e.message!==n.endOfFile)throw e})}finalize(){}async parseID3v2(){if(await this.tryReadId3v2Headers(),u("End of ID3v2 header, go to MPEG-parser: pos=%s",this.tokenizer.position),await this._parse(),this.options.skipPostHeaders&&this.metadata.hasAny())this.finalize();else{const e=new s.ID3v1Parser;await e.init(this.metadata,this.tokenizer,this.options).parse(),this.finalize()}}async tryReadId3v2Headers(){if("ID3"===(await this.tokenizer.peekToken(i.ID3v2Header)).fileIdentifier)return u("Found ID3v2 header, pos=%s",this.tokenizer.position),await this.id3parser.parse(this.metadata,this.tokenizer,this.options),this.tryReadId3v2Headers()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(4),a=r(1),s=r(7),o=n("music-metadata:parser:ID3v1");t.Genres=["Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal","New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death Metal","Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise","Alt. Rock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock","Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic","Pop-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta Rap","Top 40","Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychedelic","Rave","Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical","Rock & Roll","Hard Rock","Folk","Folk/Rock","National Folk","Swing","Fast-Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock","Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band","Chorus","Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music","Sonata","Symphony","Booty Bass","Primus","Porn Groove","Satire","Slow Jam","Club","Tango","Samba","Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle","Duet","Punk Rock","Drum Solo","A Cappella","Euro-House","Dance Hall","Goa","Drum & Bass","Club-House","Hardcore","Terror","Indie","BritPop","Negerpunk","Polsk Punk","Beat","Christian Gangsta Rap","Heavy Metal","Black Metal","Crossover","Contemporary Christian","Christian Rock","Merengue","Salsa","Thrash Metal","Anime","JPop","Synthpop","Abstract","Art Rock","Baroque","Bhangra","Big Beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math Rock","New Romantic","Nu-Breakz","Post-Punk","Post-Rock","Psytrance","Shoegaze","Space Rock","Trop Rock","World Music","Neoclassical","Audiobook","Audio Theatre","Neue Deutsche Welle","Podcast","Indie Rock","G-Funk","Dubstep","Garage Rock","Psybient"];const c={len:128,get:(e,t)=>{const r=new u(3).get(e,t);return"TAG"===r?{header:r,title:new u(30).get(e,t+3),artist:new u(30).get(e,t+33),album:new u(30).get(e,t+63),year:new u(4).get(e,t+93),comment:new u(28).get(e,t+97),zeroByte:a.UINT8.get(e,t+127),track:a.UINT8.get(e,t+126),genre:a.UINT8.get(e,t+127)}:null}};class u extends a.StringType{constructor(e){super(e,"binary")}get(e,t){let r=super.get(e,t);return(r=(r=i.default.trimRightNull(r)).trim()).length>0?r:void 0}}class l extends s.BasicParser{static getGenre(e){if(ee)return void o("Already consumed the last 128 bytes");const t=await this.tokenizer.readToken(c,e);if(t){o("ID3v1 header found at: pos=%s",this.tokenizer.fileSize-c.len);for(const e of["title","artist","album","comment","track","year"])t[e]&&""!==t[e]&&this.addTag(e,t[e]);const e=l.getGenre(t.genre);e&&this.addTag("genre",e)}else o("ID3v1 header not found at: pos=%s",this.tokenizer.fileSize-c.len)}addTag(e,t){this.metadata.addTag("ID3v1",e,t)}}t.ID3v1Parser=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(35);t.ID3Stream=class extends n.Readable{constructor(e){super(),this.buf=e}_read(){this.push(this.buf),this.push(null)}}},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,a=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var i,a,s,o;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),s=a[t]),void 0===s)s=a[t]=r,++e._eventsCount;else if("function"==typeof s?s=a[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,o=c,console&&console.warn&&console.warn(o)}return e}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)a(c,this,t);else{var u=c.length,l=h(c,u);for(r=0;r=0;a--)if(r[a]===t||r[a].listener===t){s=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){(t=e.exports=r(36)).Stream=t,t.Readable=t,t.Writable=r(29),t.Duplex=r(12),t.Transform=r(40),t.PassThrough=r(233)},function(e,t,r){var n=r(3),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(a(n,t),t.Buffer=s),a(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t,n,i){var a=r(21);function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=y;var o,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:a.nextTick;y.WritableState=b;var u=r(19);u.inherits=r(15);var l={deprecate:r(231)},d=r(37),f=r(28).Buffer,p=i.Uint8Array||function(){};var h,m=r(38);function g(){}function b(e,t){o=o||r(12),e=e||{};var n=t instanceof o;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var d=!1===e.decodeStrings;this.decodeStrings=!d,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(a.nextTick(i,n),a.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var s=I(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||v(e,r),n?c(T,e,r,s,i):T(e,r,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function y(e){if(o=o||r(12),!(h.call(y,this)||this instanceof o))return new y(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),d.call(this)}function w(e,t,r,n,i,a,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function T(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function v(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var o=0,c=!0;r;)i[o]=r,r.isBuf||(c=!1),r=r.next,o+=1;i.allBuffers=c,w(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,d=r.callback;if(w(e,t,!1,t.objectMode?1:u.length,u,l,d),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function I(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function k(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var r=I(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,a.nextTick(k,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(y,d),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(h=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!h.call(this,e)||this===y&&(e&&e._writableState instanceof b)}})):h=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,o=!i.objectMode&&(n=e,f.isBuffer(n)||n instanceof p);return o&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=g),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),a.nextTick(t,r)}(this,r):(o||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),a.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,a){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var o=t.objectMode?1:n.length;t.length+=o;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?a.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(9),r(229).setImmediate,r(11))},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(42),s=i("music-metadata:parser:ogg:vorbis1");t.VorbisParser=class{constructor(e,t){this.metadata=e,this.options=t,this.codecName="Vorbis I",this.pageSegments=[]}parsePage(t,r){if(t.headerType.firstPage)this.parseFirstPage(t,r);else{if(t.headerType.continued){if(0===this.pageSegments.length)throw new Error("Cannot continue on previous page");this.pageSegments.push(r)}if(t.headerType.lastPage||!t.headerType.continued){if(this.pageSegments.length>0){const t=e.concat(this.pageSegments);this.parseFullPage(t)}this.pageSegments=t.headerType.lastPage?[]:[r]}}t.headerType.lastPage&&this.calculateDuration(t)}flush(){this.parseFullPage(e.concat(this.pageSegments))}parseFirstPage(e,t){this.metadata.setFormat("codec","Vorbis I"),s("Parse first page");const r=a.CommonHeader.get(t,0);if("vorbis"!==r.vorbis)throw new Error("Metadata does not look like Vorbis");if(1!==r.packetType)throw new Error("First Ogg page should be type 1: the identification header");{const e=a.IdentificationHeader.get(t,a.CommonHeader.len);this.metadata.setFormat("sampleRate",e.sampleRate),this.metadata.setFormat("bitrate",e.bitrateNominal),this.metadata.setFormat("numberOfChannels",e.channelMode),s("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s",e.sampleRate,e.bitrateNominal,e.channelMode)}}parseFullPage(e){const t=a.CommonHeader.get(e,0);switch(s("Parse full page: type=%s, byteLength=%s",t.packetType,e.byteLength),t.packetType){case 3:return this.parseUserCommentList(e,a.CommonHeader.len)}}calculateDuration(e){this.metadata.format.sampleRate&&e.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",e.absoluteGranulePosition),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate))}parseUserCommentList(e,t){const r=n.UINT32_LE.get(e,t);t+=4,new n.StringType(r,"utf-8").get(e,t),t+=r;let i=n.UINT32_LE.get(e,t);for(t+=4;i-- >0;)t+=this.parseUserComment(e,t)}parseUserComment(e,t){const r=n.UINT32_LE.get(e,t),i=new n.StringType(r,"utf-8").get(e,t+4),o=i.indexOf("="),c=i.slice(0,o).toUpperCase();let u=i.slice(o+1);return"METADATA_BLOCK_PICTURE"===c&&(u=this.options.skipCovers?null:a.VorbisPictureToken.fromBase64(u)),null!==u&&(s("Push tag: id=%s, value=%s",c,u),this.metadata.addTag("vorbis",c,u)),n.UINT32_LE.len+r}}}).call(this,r(3).Buffer)},,,function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(module,exports,__webpack_require__){"use strict";(function(Buffer){const{multiByteIndexOf:multiByteIndexOf,stringToBytes:stringToBytes,readUInt64LE:readUInt64LE,tarHeaderChecksumMatches:tarHeaderChecksumMatches,uint8ArrayUtf8ByteString:uint8ArrayUtf8ByteString}=__webpack_require__(204),supported=__webpack_require__(205),xpiZipFilename=stringToBytes("META-INF/mozilla.rsa"),oxmlContentTypes=stringToBytes("[Content_Types].xml"),oxmlRels=stringToBytes("_rels/.rels"),fileType=e=>{if(!(e instanceof Uint8Array||e instanceof ArrayBuffer||Buffer.isBuffer(e)))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);if(!(t&&t.length>1))return;const r=(e,r)=>{r={offset:0,...r};for(let n=0;nr(stringToBytes(e),t);if(r([255,216,255]))return{ext:"jpg",mime:"image/jpeg"};if(r([137,80,78,71,13,10,26,10])){const e=33,r=t.findIndex((r,n)=>n>=e&&73===t[n]&&68===t[n+1]&&65===t[n+2]&&84===t[n+3]),n=t.subarray(e,r);return n.findIndex((e,t)=>97===n[t]&&99===n[t+1]&&84===n[t+2]&&76===n[t+3])>=0?{ext:"apng",mime:"image/apng"}:{ext:"png",mime:"image/png"}}if(r([71,73,70]))return{ext:"gif",mime:"image/gif"};if(r([87,69,66,80],{offset:8}))return{ext:"webp",mime:"image/webp"};if(r([70,76,73,70]))return{ext:"flif",mime:"image/flif"};if((r([73,73,42,0])||r([77,77,0,42]))&&r([67,82],{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(r([73,73,42,0])&&(r([16,251,134,1],{offset:4})||r([8,0,0,0,19,0],{offset:4})||r([8,0,0,0,18,0],{offset:4})))return{ext:"arw",mime:"image/x-sony-arw"};if(r([73,73,42,0,8,0,0,0])&&(r([45,0,254,0],{offset:8})||r([39,0,254,0],{offset:8})))return{ext:"dng",mime:"image/x-adobe-dng"};if(r([73,73,42,0])&&r([28,0,254,0],{offset:8}))return{ext:"nef",mime:"image/x-nikon-nef"};if(r([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(n("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(r([73,73,42,0])||r([77,77,0,42]))return{ext:"tif",mime:"image/tiff"};if(r([66,77]))return{ext:"bmp",mime:"image/bmp"};if(r([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(r([56,66,80,83]))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};const i=[80,75,3,4];if(r(i)){if(r([109,105,109,101,116,121,112,101,97,112,112,108,105,99,97,116,105,111,110,47,101,112,117,98,43,122,105,112],{offset:30}))return{ext:"epub",mime:"application/epub+zip"};if(r(xpiZipFilename,{offset:30}))return{ext:"xpi",mime:"application/x-xpinstall"};if(n("mimetypeapplication/vnd.oasis.opendocument.text",{offset:30}))return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};if(n("mimetypeapplication/vnd.oasis.opendocument.spreadsheet",{offset:30}))return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};if(n("mimetypeapplication/vnd.oasis.opendocument.presentation",{offset:30}))return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};let e,a=0,s=!1;do{const o=a+30;if(s||(s=r(oxmlContentTypes,{offset:o})||r(oxmlRels,{offset:o})),e||(n("word/",{offset:o})?e={ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:n("ppt/",{offset:o})?e={ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:n("xl/",{offset:o})&&(e={ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),s&&e)return e;a=multiByteIndexOf(t,i,o)}while(a>=0);if(e)return e}if(r([80,75])&&(3===t[2]||5===t[2]||7===t[2])&&(4===t[3]||6===t[3]||8===t[3]))return{ext:"zip",mime:"application/zip"};if(r([48,48,48,48,48,48],{offset:148,mask:[248,248,248,248,248,248]})&&tarHeaderChecksumMatches(t))return{ext:"tar",mime:"application/x-tar"};if(r([82,97,114,33,26,7])&&(0===t[6]||1===t[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(r([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(r([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(r([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(r([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(r([102,114,101,101],{offset:4})||r([109,100,97,116],{offset:4})||r([109,111,111,118],{offset:4})||r([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(r([102,116,121,112],{offset:4})&&0!=(96&t[8])&&0!=(96&t[9])&&0!=(96&t[10])&&0!=(96&t[11])){const e=uint8ArrayUtf8ByteString(t,8,12);switch(e){case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt ":return{ext:"mov",mime:"video/quicktime"};case"M4V ":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P ":return{ext:"m4p",mime:"video/mp4"};case"M4B ":return{ext:"m4b",mime:"audio/mp4"};case"M4A ":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V ":return{ext:"f4v",mime:"video/mp4"};case"F4P ":return{ext:"f4p",mime:"video/mp4"};case"F4A ":return{ext:"f4a",mime:"audio/mp4"};case"F4B ":return{ext:"f4b",mime:"audio/mp4"};default:return e.startsWith("3g")?e.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(r([77,84,104,100]))return{ext:"mid",mime:"audio/midi"};if(r([26,69,223,163])){const e=t.subarray(4,4100),r=e.findIndex((e,t,r)=>66===r[t]&&130===r[t+1]);if(-1!==r){const t=r+3,n=r=>[...r].every((r,n)=>e[t+n]===r.charCodeAt(0));if(n("matroska"))return{ext:"mkv",mime:"video/x-matroska"};if(n("webm"))return{ext:"webm",mime:"video/webm"}}}if(r([82,73,70,70])){if(r([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(r([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/vnd.wave"};if(r([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(r([48,38,178,117,142,102,207,17,166,217])){let e=30;do{const n=readUInt64LE(t,e+16);if(r([145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101],{offset:e})){if(r([64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wma",mime:"audio/x-ms-wma"};if(r([192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wmv",mime:"video/x-ms-asf"};break}e+=n}while(e+24<=t.length);return{ext:"asf",mime:"application/vnd.ms-asf"}}if(r([0,0,1,186])||r([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};for(let e=0;e<2&&enew Promise((resolve,reject)=>{const stream=eval("require")("stream");readableStream.on("error",reject),readableStream.once("readable",()=>{const e=new stream.PassThrough,t=readableStream.read(module.exports.minimumBytes)||readableStream.read();try{e.fileType=fileType(t)}catch(e){reject(e)}readableStream.unshift(t),stream.pipeline?resolve(stream.pipeline(readableStream,e,()=>{})):resolve(readableStream.pipe(e))})}),Object.defineProperty(fileType,"extensions",{get:()=>new Set(supported.extensions)}),Object.defineProperty(fileType,"mimeTypes",{get:()=>new Set(supported.mimeTypes)})}).call(this,__webpack_require__(3).Buffer)},function(e,t,r){e.exports=i;var n=r(26).EventEmitter;function i(){n.call(this)}r(15)(i,n),i.Readable=r(27),i.Writable=r(234),i.Duplex=r(235),i.Transform=r(236),i.PassThrough=r(237),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function a(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",a),e._isStdio||t&&!1===t.end||(r.on("end",o),r.on("close",c));var s=!1;function o(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",i),e.removeListener("drain",a),r.removeListener("end",o),r.removeListener("close",c),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",u),e.on("error",u),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(t,n){var i=r(21);e.exports=w;var a,s=r(33);w.ReadableState=y;r(26).EventEmitter;var o=function(e,t){return e.listeners(t).length},c=r(37),u=r(28).Buffer,l=t.Uint8Array||function(){};var d=r(19);d.inherits=r(15);var f=r(226),p=void 0;p=f&&f.debuglog?f.debuglog("stream"):function(){};var h,m=r(227),g=r(38);d.inherits(w,c);var b=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var n=t instanceof(a=a||r(12));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,s=e.readableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(s||0===s)?s:o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(39).StringDecoder),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function w(e){if(a=a||r(12),!(this instanceof w))return new w(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function T(e,t,r,n,i){var a,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,S(e)}(e,s)):(i||(a=function(e,t){var r;n=t,u.isBuffer(n)||n instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(s,t)),a?e.emit("error",a):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):v(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?v(e,s,t,!1):E(e,s)):v(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=I?e=I:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(C,e):C(e))}function C(e){p("emit readable"),e.emit("readable"),x(e)}function E(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(_,e,t))}function _(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;ea.length?a.length:e;if(s===a.length?i+=a:i+=a.slice(0,e),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=u.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var a=n.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),0===(e-=s)){s===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):S(this),null;if(0===(e=k(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e0?P(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},w.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(e,t){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:w;function u(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",b),e.removeListener("finish",y),e.removeListener("drain",d),e.removeListener("error",g),e.removeListener("unpipe",u),r.removeListener("end",l),r.removeListener("end",w),r.removeListener("data",m),f=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||d())}function l(){p("onend"),e.end()}a.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",u);var d=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,x(e))}}(r);e.on("drain",d);var f=!1;var h=!1;function m(t){p("ondata"),h=!1,!1!==e.write(t)||h||((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==D(a.pipes,e))&&!f&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,h=!0),r.pause())}function g(t){p("onerror",t),w(),e.removeListener("error",g),0===o(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",y),w()}function y(){p("onfinish"),e.removeListener("close",b),w()}function w(){p("unpipe"),r.unpipe(e)}return r.on("data",m),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",g),e.once("close",b),e.once("finish",y),e.emit("pipe",r),a.flowing||(p("pipe resume"),r.resume()),e},w.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";e.exports=s;var n=r(12),i=r(19);function a(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length({packetType:e.readUInt8(t),vorbis:new n.StringType(6,"ascii").get(e,t+1)})},t.IdentificationHeader={len:23,get:(e,t)=>({version:e.readUInt32LE(t+0),channelMode:e.readUInt8(t+4),sampleRate:e.readUInt32LE(t+5),bitrateMax:e.readUInt32LE(t+9),bitrateNominal:e.readUInt32LE(t+13),bitrateMin:e.readUInt32LE(t+17)})}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5),a=r(2)("music-metadata:parser:MP4:atom");t.Header={len:8,get:(e,t)=>{const r=n.UINT32_BE.get(e,t);if(r<0)throw new Error("Invalid atom header length");return{length:r,name:i.FourCcToken.get(e,t+4)}},put:(e,t,r)=>(n.UINT32_BE.put(e,t,r.length),i.FourCcToken.put(e,t+4,r.name))},t.ExtendedSize=n.UINT64_BE,t.ftyp={len:4,get:(e,t)=>({type:new n.StringType(4,"ascii").get(e,t)})},t.mhdr={len:8,get:(e,t)=>({version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),nextItemID:n.UINT32_BE.get(e,t+4)})};class s{constructor(e,t,r){if(this.len=e,et&&a(`Warning: atom ${r} expected to be ${t}, but was actually ${e} bytes long.`)}}t.FixedLengthAtom=s;t.MdhdAtom=class extends s{constructor(e){super(e,24,"mdhd"),this.len=e}get(e,t){return{version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),timeScale:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+16),language:n.UINT16_BE.get(e,t+20),quality:n.UINT16_BE.get(e,t+22)}}};t.MvhdAtom=class extends s{constructor(e){super(e,100,"mvhd"),this.len=e}get(e,t){return{version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),timeScale:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+16),preferredRate:n.UINT32_BE.get(e,t+20),preferredVolume:n.UINT16_BE.get(e,t+24),previewTime:n.UINT32_BE.get(e,t+72),previewDuration:n.UINT32_BE.get(e,t+76),posterTime:n.UINT32_BE.get(e,t+80),selectionTime:n.UINT32_BE.get(e,t+84),selectionDuration:n.UINT32_BE.get(e,t+88),currentTime:n.UINT32_BE.get(e,t+92),nextTrackID:n.UINT32_BE.get(e,t+96)}}};t.DataAtom=class{constructor(e){this.len=e}get(e,t){return{type:{set:n.UINT8.get(e,t+0),type:n.UINT24_BE.get(e,t+1)},locale:n.UINT24_BE.get(e,t+4),value:new n.BufferType(this.len-8).get(e,t+8)}}};t.NameAtom=class{constructor(e){this.len=e}get(e,t){return{version:n.UINT8.get(e,t),flags:n.UINT24_BE.get(e,t+1),name:new n.StringType(this.len-4,"utf-8").get(e,t+4)}}};t.TrackHeaderAtom=class{constructor(e){this.len=e}get(e,t){return{version:n.UINT8.get(e,t),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),trackId:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+20),layer:n.UINT16_BE.get(e,t+24),alternateGroup:n.UINT16_BE.get(e,t+26),volume:n.UINT16_BE.get(e,t+28)}}};const o={len:8,get:(e,t)=>({version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),numberOfEntries:n.UINT32_BE.get(e,t+4)})};class c{constructor(e){this.len=e}get(e,t){return{dataFormat:i.FourCcToken.get(e,t),dataReferenceIndex:n.UINT16_BE.get(e,t+10),description:new n.BufferType(this.len-12).get(e,t+12)}}}t.StsdAtom=class{constructor(e){this.len=e}get(e,t){const r=o.get(e,t);t+=o.len;const i=[];for(let a=0;a({version:n.INT16_BE.get(e,t),revision:n.INT16_BE.get(e,t+2),vendor:n.INT32_BE.get(e,t+4)})},t.SoundSampleDescriptionV0={len:12,get:(e,t)=>({numAudioChannels:n.INT16_BE.get(e,t+0),sampleSize:n.INT16_BE.get(e,t+2),compressionId:n.INT16_BE.get(e,t+4),packetSize:n.INT16_BE.get(e,t+6),sampleRate:n.UINT16_BE.get(e,t+8)+n.UINT16_BE.get(e,t+10)/1e4})}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(188),i=r(191),a=r(269),s=r(270),o=n("music-metadata-browser:main");t.parseNodeStream=i.parseStream,t.parseReadableStream=async function(e,r,n){const i=new a.ReadableWeToNodeStream(e),s=await t.parseNodeStream(i,r,n);return o(`Completed parsing from stream bytesRead=${i.bytesRead} / fileSize=${n&&n.fileSize?n.fileSize:"?"}`),await i.close(),s},t.parseBuffer=i.parseBuffer,t.parseBlob=function(e,t){return function(e){return new Promise((t,r)=>{const n=new FileReader;n.onloadend=e=>{let r=e.target.result;r instanceof ArrayBuffer&&(r=s(new Uint8Array(e.target.result))),t(r)},n.onerror=e=>{r(new Error(e.type))},n.onabort=e=>{r(new Error(e.type))},n.readAsArrayBuffer(e)})}(e).then(r=>i.parseBuffer(r,e.type,t))},t.fetchFromUrl=async function(e,t){const r=await fetch(e),n=r.headers.get("Content-Type"),i=[];if(r.headers.forEach(e=>{i.push(e)}),r.ok){if(r.body){const e=await this.parseReadableStream(r.body,n,t);return o("Closing HTTP-readable-stream..."),r.body.locked||await r.body.cancel(),o("HTTP-readable-stream closed."),e}return this.parseBlob(await r.blob(),t)}throw new Error(`HTTP error status=${r.status}: ${r.statusText}`)},t.parseFromTokenizer=i.parseFromTokenizer,t.orderTags=i.orderTags,t.ratingToStars=i.ratingToStars},function(e,t,r){var i;(function(){var r=!1,a=function(e){return e instanceof a?e:this instanceof a?void(this.EXIFwrapped=e):new a(e)};e.exports&&(t=e.exports=a),t.EXIF=a;var s=a.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},o=a.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},c=a.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},u=a.IFD1Tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",296:"ResolutionUnit",513:"JpegIFOffset",514:"JpegIFByteCount",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite"},l=a.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}};function d(e){return!!e.exifdata}function f(e,t){function n(n){var i=p(n);e.exifdata=i||{};var s=function(e){var t=new DataView(e);r&&console.log("Got file of length "+e.byteLength);if(255!=t.getUint8(0)||216!=t.getUint8(1))return r&&console.log("Not a valid JPEG"),!1;var n=2,i=e.byteLength,a=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};for(;n")+8,l=(c=c.substring(c.indexOf("4?p:t+8,s=[],c=0;c4?p:t+8,f-1);case 3:if(1==f)return e.getUint16(t+8,!i);for(a=f>2?p:t+8,s=[],c=0;ce.byteLength)return{};var a=g(e,t,t+i,u,n);if(a.Compression)switch(a.Compression){case 6:if(a.JpegIFOffset&&a.JpegIFByteCount){var s=t+a.JpegIFOffset,o=a.JpegIFByteCount;a.blob=new Blob([new Uint8Array(e.buffer,s,o)],{type:"image/jpeg"})}break;case 1:console.log("Thumbnail image format is TIFF, which is not implemented.");break;default:console.log("Unknown thumbnail image format '%s'",a.Compression)}else 2==a.PhotometricInterpretation&&console.log("Thumbnail image format is RGB, which is not implemented.");return a}(e,p,h,n),i}function T(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var r=0;r0)for(var r=0;r{if(!t.isBuffer(e))return{};let i={},a=e.indexOf(n);for(;-1!==a;){let t=(a=e.indexOf(n,a+n.byteLength))+n.byteLength,s=t+1,o=s+2,c=e.readUInt8(t),u=e.readUInt16BE(s);if(!r.has(c))continue;if(u>e.length-(o+u))throw new Error("Invalid IPTC directory");let l=r.get(c),d=e.slice(o,o+u).toString();null==i[l]?i[l]=d:Array.isArray(i[l])?i[l].push(d):i[l]=[i[l],d]}return i}}).call(this,r(3).Buffer)},,,,,,,,,function(e,t,r){e.exports=r(185)},function(e,t,r){"use strict";r.r(t),function(e){var t=r(173),n=r(174),i=r.n(n),a=r(175),s=r.n(a);window.mediaCloudReaderCache={readers:[],getFreeReader:function(){return this.readers.length>0?(console.log("Got cached reader."),this.readers.splice(0,1)[0]):new FileReader},cacheReader:function(e){this.readers.push(e)}},window.DirectUploadItem=Backbone.Model.extend({initialize:function(e){this.on("change:progress",this.updateProgress,this)},updateProgress:function(){var e=this.get("attachment"),t=this.get("progress");e.set({percent:t})},startUpload:function(){if("uploadToStorage"in DirectUploadItem.prototype){var e=this.get("file"),t=this.get("faces"),r=this.get("mimeType");this.get("isDirectUpload")?(console.log("Uploading to Cloud Storage"),this.uploadToStorage(e,t,r,this)):this.uploadToWordPress(e,t,this)}else alert("Direct upload is misconfigured.")},uploadToWordPress:function(e,t,r){console.log("Uploading to WordPress");var n=new FormData;n.append("action",_wpPluploadSettings.defaults.multipart_params.action),n.append("_wpnonce",_wpPluploadSettings.defaults.multipart_params._wpnonce),n.append("name",e.name),n.append("async-upload",e),jQuery.ajax({url:_wpPluploadSettings.defaults.url,method:"POST",contentType:!1,processData:!1,data:n,dataType:"json",xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){r.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){e.hasOwnProperty("success")&&e.success?r.wordpressUploadFinished(e,t):r.uploadError()},error:function(e){r.uploadError()}})},finishWordpressUpload:function(e){var t=this.get("attachment");_.each(["file","loaded","size","percent"],function(e){t.unset(e)}),t.set(_.extend(e.data,{uploading:!1})),wp.media.model.Attachment.get(e.data.id,t),this.set({state:"done"}),wp.Uploader.queue.remove(t),wp.Uploader.queue.all(function(e){return!e.get("uploading")})&&wp.Uploader.queue.reset()},wordpressUploadFinished:function(e,t){if(null!=t){var r={action:"ilab_add_face_data",post_id:e.data.id,faces:t};jQuery.post(ajaxurl,r,function(t){this.finishWordpressUpload(e)}.bind(this))}else this.finishWordpressUpload(e)},doUploadFinished:function(e,t,r){var n=this.get("attachment"),i={action:"ilab_upload_import_cloud_file",key:e};null!=r&&(i.metadata=r),console.log("Upload finished"),console.log(i),null!=t&&t.length>0&&(i.faces=t),jQuery.post(ajaxurl,i,function(e){_.each(["file","loaded","size","percent"],function(e){n.unset(e)}),"success"==e.status?(n.set(_.extend(e.attachment,{uploading:!1})),wp.media.model.Attachment.get(e.attachment.id,n),this.set({state:"done"})):this.set({state:"error"}),wp.Uploader.queue.remove(n),wp.Uploader.queue.all(function(e){return!e.get("uploading")})&&wp.Uploader.queue.reset()}.bind(this))},mapID3Meta:function(e,t,r,n){r.hasOwnProperty(e)&&(n[t]=r[e])},mapIndexedID3Meta:function(e,t,r,n){r.hasOwnProperty(e)&&r[e].length>0&&(n[t]=r[e][0])},assignAudioMetadata:function(e,t){if(this.mapID3Meta("album","album",e.common,t),this.mapID3Meta("artist","artist",e.common,t),this.mapIndexedID3Meta("genre","genre",e.common,t),this.mapID3Meta("title","title",e.common,t),e.common.hasOwnProperty("track")&&null!=e.common.track.no&&(t.track_number=e.common.track.no),this.mapID3Meta("year","year",e.common,t),this.mapIndexedID3Meta("composer","composer",e.common,t),this.mapIndexedID3Meta("lyricist","lyricist",e.common,t),this.mapIndexedID3Meta("writer","writer",e.common,t),this.mapIndexedID3Meta("conductor","conductor",e.common,t),this.mapIndexedID3Meta("remixer","remixer",e.common,t),this.mapIndexedID3Meta("arranger","arranger",e.common,t),this.mapIndexedID3Meta("engineer","engineer",e.common,t),this.mapIndexedID3Meta("producer","producer",e.common,t),this.mapIndexedID3Meta("djmixer","dj_mixer",e.common,t),this.mapIndexedID3Meta("mixer","mixer",e.common,t),this.mapIndexedID3Meta("technician","technician",e.common,t),this.mapIndexedID3Meta("label","label",e.common,t),this.mapIndexedID3Meta("subtitle","subtitle",e.common,t),this.mapIndexedID3Meta("compilation","compilation",e.common,t),this.mapID3Meta("bpm","bpm",e.common,t),this.mapID3Meta("mood","mood",e.common,t),this.mapID3Meta("media","media",e.common,t),this.mapID3Meta("tvShow","tv_show",e.common,t),this.mapID3Meta("tvSeason","tv_season",e.common,t),this.mapID3Meta("tvEpisode","tv_episode",e.common,t),this.mapID3Meta("tvNetwork","tv_network",e.common,t),this.mapID3Meta("podcast","podcast",e.common,t),this.mapID3Meta("podcasturl","podcast_url",e.common,t),this.mapID3Meta("releasestatus","release_status",e.common,t),this.mapID3Meta("releasetype","release_type",e.common,t),this.mapID3Meta("releasecountry","release_country",e.common,t),this.mapID3Meta("language","language",e.common,t),this.mapID3Meta("copyright","copyright",e.common,t),this.mapID3Meta("license","license",e.common,t),this.mapID3Meta("encodedby","encoded_by",e.common,t),this.mapID3Meta("encodersettings","encoder_options",e.common,t),this.mapID3Meta("gapless","gapless",e.common,t),this.mapID3Meta("barcode","barcode",e.common,t),this.mapID3Meta("asin","asin",e.common,t),this.mapID3Meta("website","website",e.common,t),this.mapID3Meta("averageLevel","average_level",e.common,t),this.mapID3Meta("peakLevel","peak_level",e.common,t),this.mapID3Meta("bitrate","bitrate",e.format,t),this.mapID3Meta("codec","dataformat",e.format,t),this.mapID3Meta("codecProfile","bitrate_mode",e.format,t),this.mapID3Meta("lossless","lossless",e.format,t),this.mapID3Meta("numberOfChannels","channels",e.format,t),this.mapID3Meta("duration","length",e.format,t),this.mapID3Meta("sampleRate","sample_rate",e.format,t),e.common.hasOwnProperty("picture")&&e.common.picture.length>0){var r=e.common.picture[0];t.thumbnail={mimeType:r.format,data:r.data.toString("base64")},t.image=[{mime:r.format}]}},mapImageMeta:function(e,t,r,n,i){if(t.hasOwnProperty(r)){var a=t[r];if("string"==e){if(!(o="string"==typeof a||a instanceof String))return;n[i]=a.trim()}else if("strings"==e){if(o="string"==typeof a||a instanceof String){a=a.split(",");for(var s=0;s0&&(n[i]=a)}else if("date"==e){var o;if(!(o="string"==typeof a||a instanceof String))return;var c=a.split(" ");if(2!=c.length)return;var u=c[0].split(":");if(3!=u.length)return;var l=u[0],d=u[1],f=u[2],p=new Date("".concat(d,"/").concat(f,"/").concat(l," ").concat(c[1]));n[i]=(p.getTime()/1e3).toFixed(0)}else if("frac"==e){if(o)return;if(!("number"==typeof a||a instanceof Number))return;n[i]=a.numerator/a.denominator}else if("number"==e){if(o)return;if(!("number"==typeof a||a instanceof Number))return;n[i]=a}}},assignImageMetadata:function(e,t,r){console.log(e),console.log(t);var n={};this.mapImageMeta("string",e,"headline",n,"title"),this.mapImageMeta("string",e,"caption",n,"caption"),this.mapImageMeta("string",e,"credit",n,"credit"),this.mapImageMeta("string",e,"copyright",n,"copyright"),this.mapImageMeta("strings",e,"keywords",n,"keywords"),0!=t&&(this.mapImageMeta("string",t,"ImageDescription",n,"title"),n.hasOwnProperty("caption")||this.mapImageMeta("bytes",t,"UserComment",n,"caption"),n.hasOwnProperty("copyright")||this.mapImageMeta("bytes",t,"Copyright",n,"copyright"),this.mapImageMeta("string",t,"Artist",n,"credit"),n.hasOwnProperty("credit")||this.mapImageMeta("string",t,"Author",n,"credit"),this.mapImageMeta("string",t,"Copyright",n,"copyright"),this.mapImageMeta("string",t,"Model",n,"camera"),this.mapImageMeta("string",t,"ISOSpeedRatings",n,"iso"),this.mapImageMeta("number",t,"ISOSpeedRatings",n,"iso"),this.mapImageMeta("date",t,"DateTimeDigitized",n,"created_timestamp"),this.mapImageMeta("frac",t,"FocalLength",n,"focal_length"),this.mapImageMeta("frac",t,"FNumber",n,"aperture"),this.mapImageMeta("frac",t,"ExposureTime",n,"shutter_speed"),this.mapImageMeta("number",t,"Orientation",n,"orientation")),r.image_meta=n},uploadFinished:function(r,n){var a=this.get("attachment").get("file"),o={filesize:a.size},c=this.get("mimeType");if(0===c.indexOf("audio/")){var u=c.split("/")[1];o.fileformat=u,t.parseBlob(a,{duration:!0}).then(function(e){this.assignAudioMetadata(e,o),this.doUploadFinished(r,n,o)}.bind(this)).catch(function(e){this.doUploadFinished(r,n,o)}.bind(this))}else if(0==c.indexOf("image/")){var l=mediaCloudReaderCache.getFreeReader();l.onload=function(t){var a={};try{a=s()(e.from(l.result))}catch(e){console.log("IPTC Error",e)}var c=i.a.readFromBinaryFile(l.result);this.assignImageMetadata(a,c,o),mediaCloudReaderCache.cacheReader(l),this.doUploadFinished(r,n,o)}.bind(this),l.onerror=function(e){mediaCloudReaderCache.cacheReader(l),this.doUploadFinished(r,n,o)}.bind(this),l.readAsArrayBuffer(a)}else this.doUploadFinished(r,n,o)},uploadError:function(){this.set({state:"error"});var e=this.get("attachment");_.each(["file","loaded","size","percent"],function(t){e.unset(t)}),wp.Uploader.queue.remove(e),e.destroy()}}),window.DirectUploader=Backbone.Model.extend({initialize:function(e){this.totalFilesDropped=0,this.totalFilesUploaded=0,this.files=[],this.toBulkProcess=[],this.uploadingFiles=[],this.watchToken=0,this.settings=mediaCloudDirectUploadSettings},queueNext:function(){if(clearTimeout(this.watchToken),this.uploadingFiles.length0){for(var e=this.settings.maxUploads-this.uploadingFiles.length,t=0;t0){var r=this.files.shift();this.uploadingFiles.push(r),r.startUpload()}}else if(0==this.uploadingFiles.length&&this.toBulkProcess.length>0&&this.totalFilesDropped==this.totalFilesUploaded){var n={action:"ilab_upload_process_batch",batch:this.toBulkProcess};this.toBulkProcess=[],this.totalFilesDropped=0,this.totalFilesUploaded=0,jQuery.post(ajaxurl,n,function(e){})}this.watchToken=setTimeout(this.queueNext.bind(this),500)},addFile:function(e){if(console.log("Adding File"),""==e.type)return!1;var t=e.type;"application/x-photoshop"==t&&(t="image/psd");var r=-1!=this.settings.allowedMimes.indexOf(t);console.log("Is Direct Upload?",r);var n=t.split("/"),i=n[0],a=n[1];a="jpg"==a?"jpeg":a,this.totalFilesDropped++;var s={file:e,uploading:!0,date:new Date,filename:e.name,isDirectUpload:r,menuOrder:0,uploadedTo:wp.media.model.settings.post.id,loaded:0,size:e.size,percent:0,type:i,subType:a},o=wp.media.model.Attachment.create(s);wp.Uploader.queue.add(o);var c=new DirectUploadItem({attachment:o,file:e,mimeType:t,isDirectUpload:r,progress:0,driver:this.settings.driver,faces:null,state:"waiting"});c.on("change:state",function(e,t){if("done"==t||"error"==t){this.totalFilesUploaded++,"done"==t&&this.toBulkProcess.push(o.id);var r=this.files.indexOf(c);r>-1&&this.files.splice(r),(r=this.uploadingFiles.indexOf(c))>-1&&this.uploadingFiles.splice(r),this.queueNext()}}.bind(this)),"undefined"!=typeof ILABFaceDetector?ILABFaceDetector(e,function(e){c.set("faces",e),this.files.push(c)}.bind(this)):this.files.push(c)}}),wp.media.view.UploaderWindow.prototype.__ready=wp.media.view.UploaderWindow.prototype.ready,wp.media.view.UploaderWindow.prototype.ready=function(){this.__ready(),this.directUploader=new DirectUploader({}),this.uploader.uploader.unbind("FilesAdded"),this.uploader.uploader.bind("FilesAdded",function(e,t){_.each(t,function(e){this.directUploader.addFile(e.getNative())}.bind(this)),this.directUploader.queueNext()}.bind(this))},wp.media.view.UploaderInline=wp.media.view.UploaderInline.extend({template:wp.template("media-cloud-direct-upload")})}.call(this,r(3).Buffer)},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=u(e),n=r[0],s=r[1],o=new a(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),c=0,l=s>0?n-4:n,d=0;d>16&255,o[c++]=t>>8&255,o[c++]=255&t;2===s&&(t=i[e.charCodeAt(d)]<<2|i[e.charCodeAt(d+1)]>>4,o[c++]=255&t);1===s&&(t=i[e.charCodeAt(d)]<<10|i[e.charCodeAt(d+1)]<<4|i[e.charCodeAt(d+2)]>>2,o[c++]=t>>8&255,o[c++]=255&t);return o},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],s=0,o=r-i;so?o:s+16383));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=s.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,a,s=[],o=t;o>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var a,s,o=8*i-n-1,c=(1<>1,l=-7,d=r?i-1:0,f=r?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-l)-1,p>>=-l,l+=o;l>0;a=256*a+e[t+d],d+=f,l-=8);for(s=a&(1<<-l)-1,a>>=-l,l+=n;l>0;s=256*s+e[t+d],d+=f,l-=8);if(0===a)a=1-u;else{if(a===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),a-=u}return(p?-1:1)*s*Math.pow(2,a-n)},t.write=function(e,t,r,n,i,a){var s,o,c,u=8*a-i-1,l=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,h=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=l?(o=0,s=l):s+d>=1?(o=(t*c-1)*Math.pow(2,i),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&o,p+=h,o/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=h,s/=256,u-=8);e[r+p-h]|=128*m}},function(e,t,r){(function(n){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(189)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){e.exports=function(e){function t(e){let t=0;for(let r=0;r{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(20),i=r(203);function a(e,t,r){return!e.fileSize&&r.fileSize&&(e.fileSize=r.fileSize),i.ParserFactory.parse(e,t,r)}t.parseStream=function(e,t,r={}){return a(n.fromStream(e),t,r)},t.parseBuffer=function(e,t,r={}){return a(n.fromBuffer(e),t,r)},t.parseFromTokenizer=a,t.orderTags=function(e){const t={};for(const r of e)(t[r.id]=t[r.id]||[]).push(r.value);return t},t.ratingToStars=function(e){return void 0===e?0:1+Math.round(4*e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(193),i=r(10),a=r(194),s=r(199)("strtok3:ReadStreamTokenizer");t.ReadStreamTokenizer=class extends n.AbstractTokenizer{constructor(e,t){super(),this.streamReader=new a.StreamReader(e),this.fileSize=t}async readBuffer(e,t=0,r=e.length,n){if(0===r)return 0;if(n){const i=n-this.position;if(i>0)return await this.ignore(n-this.position),this.readBuffer(e,t,r);if(i<0)throw new Error("Cannot read from a negative offset in a stream")}let s;try{s=await this.streamReader.read(e,t,r),this.position+=s}catch(e){throw e.message===a.endOfStream?new Error(i.endOfFile):e}if(s0){const a=e.alloc(n+i);return c=await this.peekBuffer(a,0,i+n,void 0,o),a.copy(t,r,i),c-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}try{c=await this.streamReader.peek(t,r,n)}catch(e){throw e.message===a.endOfStream?new Error(i.endOfFile):e}if(!o&&c{this.reject=t,this.resolve=e})}}t.endOfStream="End-Of-Stream";t.StreamReader=class{constructor(e){if(this.s=e,this.endOfStream=!1,this.peekQueue=[],!e.read||!e.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new Error(t.endOfStream))),this.s.once("error",e=>this.reject(e)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(e,t,r){const n=await this.read(e,t,r);return this.peekQueue.push(e.slice(t,t+n)),n}async read(e,r,n){if(0===n)return 0;if(0===this.peekQueue.length&&this.endOfStream)throw new Error(t.endOfStream);let i=n,a=0;for(;this.peekQueue.length>0&&i>0;){const t=this.peekQueue.pop(),n=Math.min(t.length,i);t.copy(e,r+a,0,n),a+=n,i-=n,n0&&!this.endOfStream&&(a+=await this._read(e,r+a,i)),a}async _read(e,t,r){n.ok(!this.request,"Concurrent read operation?");const a=this.s.read(r);return a?(a.copy(e,t),a.length):(this.request={buffer:e,offset:t,length:r,deferred:new i},this.s.once("readable",()=>{this.tryRead()}),this.request.deferred.promise.then(e=>(this.request=null,e)).catch(e=>{throw this.request=null,e}))}tryRead(){const e=this.s.read(this.request.length);e?(e.copy(this.request.buffer,this.request.offset),this.request.deferred.resolve(e.length)):this.s.once("readable",()=>{this.tryRead()})}reject(e){this.endOfStream=!0,this.request&&(this.request.deferred.reject(e),this.request=null)}}},function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function s(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,o,c=s(e),u=1;u=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(r)?n.showHidden=r:r&&t._extend(n,r),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),l(n,e,n.depth)}function c(e,t){var r=o.styles[t];return r?"["+o.colors[r][0]+"m"+e+"["+o.colors[r][1]+"m":e}function u(e,t){return e}function l(e,r,n){if(e.customInspect&&r&&k(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return b(i)||(i=l(e,i,n)),i}var a=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(g(t))return e.stylize(""+t,"number");if(h(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,r);if(a)return a;var s=Object.keys(r),o=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),I(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(r);if(0===s.length){if(k(r)){var c=r.name?": "+r.name:"";return e.stylize("[Function"+c+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(v(r))return e.stylize(Date.prototype.toString.call(r),"date");if(I(r))return d(r)}var u,T="",S=!1,C=["{","}"];(p(r)&&(S=!0,C=["[","]"]),k(r))&&(T=" [Function"+(r.name?": "+r.name:"")+"]");return w(r)&&(T=" "+RegExp.prototype.toString.call(r)),v(r)&&(T=" "+Date.prototype.toUTCString.call(r)),I(r)&&(T=" "+d(r)),0!==s.length||S&&0!=r.length?n<0?w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),u=S?function(e,t,r,n,i){for(var a=[],s=0,o=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(u,T,C)):C[0]+T+C[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i,a){var s,o,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?o=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(o=e.stylize("[Setter]","special")),F(n,i)||(s="["+i+"]"),o||(e.seen.indexOf(c.value)<0?(o=m(r)?l(e,c.value,null):l(e,c.value,r-1)).indexOf("\n")>-1&&(o=a?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),y(s)){if(a&&i.match(/^\d+$/))return o;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+o}function p(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return void 0===e}function w(e){return T(e)&&"[object RegExp]"===S(e)}function T(e){return"object"==typeof e&&null!==e}function v(e){return T(e)&&"[object Date]"===S(e)}function I(e){return T(e)&&("[object Error]"===S(e)||e instanceof Error)}function k(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(y(a)&&(a=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(a)){var n=e.pid;s[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else s[r]=function(){};return s[r]},t.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=h,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=y,t.isRegExp=w,t.isObject=T,t.isDate=v,t.isError=I,t.isFunction=k,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(197);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function _(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),E[e.getMonth()],t].join(" ")}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",_(),t.format.apply(t,arguments))},t.inherits=r(198),t._extend=function(e,t){if(!t||!T(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var A="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function x(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(A&&e[A]){var t;if("function"!=typeof(t=e[A]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,A,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise(function(e,n){t=e,r=n}),i=[],a=0;a{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(200)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){e.exports=function(e){function t(e){let t=0;for(let r=0;r{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10);t.BufferTokenizer=class{constructor(e){this.buffer=e,this.position=0,this.fileSize=e.length}async readBuffer(e,t,r,n){return this.position=n||this.position,this.peekBuffer(e,t,r,this.position).then(e=>(this.position+=e,e))}async peekBuffer(e,t,r,i,a=!1){i=i||this.position,r||(r=e.length);const s=Math.min(this.buffer.length-i,r);if(!a&&s[...e].map(e=>e.charCodeAt(0));const r=(e,t,r)=>String.fromCharCode(...e.slice(t,r));t.readUInt64LE=(e,t=0)=>{let r=e[t],n=1,i=0;for(;++i<8;)n*=256,r+=e[t+i]*n;return r},t.tarHeaderChecksumMatches=e=>{if(e.length<512)return!1;let t=256,n=0;for(let r=0;r<148;r++){const i=e[r];t+=i,n+=128&i}for(let r=156;r<512;r++){const i=e[r];t+=i,n+=128&i}const i=parseInt(r(e,148,154),8);return i===t||i===t-(n<<1)},t.multiByteIndexOf=(t,r,n=0)=>{if(e&&e.isBuffer(t))return t.indexOf(e.from(r),n);const i=(e,t,r)=>{for(let n=1;n=0;){if(i(t,r,a))return a;a=t.indexOf(r[0],a+1)}return-1},t.uint8ArrayUtf8ByteString=r}).call(this,r(3).Buffer)},function(e,t,r){"use strict";e.exports={extensions:["jpg","png","apng","gif","webp","flif","cr2","orf","arw","dng","nef","rw2","raf","tif","bmp","jxr","psd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","wmv","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","msi","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","wmv","wma","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a"],mimeTypes:["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-canon-cr2","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/vnd.wave","audio/qcelp","audio/x-ms-wma","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-msi","application/mxf","video/mp2t","application/x-blender","image/bpg","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/ktx","application/dicom","audio/x-musepack","text/calendar","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a"]}},function(e,t,r){"use strict";var n=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,i=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,a=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,s=/\\([\u000b\u0020-\u00ff])/g,o=/([\\"])/g,c=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function u(e){var t=String(e);if(a.test(t))return t;if(t.length>0&&!i.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(o,"\\$1")+'"'}function l(e){this.parameters=Object.create(null),this.type=e}t.format=function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!c.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var i,s=Object.keys(t).sort(),o=0;o{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(211),a=r(212),s=r(8),o=r(4),c=n("music-metadata:collector"),u=["APEv2","vorbis","ID3v2.4","ID3v2.3","ID3v2.2","exif","asf","iTunes","ID3v1"];function l(e){return e.length>2?e.slice(0,e.length-1).join(", ")+" & "+e[e.length-1]:e.join(" & ")}t.MetadataCollector=class{constructor(e){this.opts=e,this.format={tagTypes:[]},this.native={},this.common={track:{no:null,of:null},disk:{no:null,of:null}},this.commonOrigin={},this.originPriority={},this.tagMapper=new a.CombinedTagMapper;let t=1;for(const e of u)this.originPriority[e]=t++;this.originPriority.artificial=500,this.originPriority.id3v1=600}hasAny(){for(const e in this.native)return!0;return!1}setFormat(e,t){c(`format: ${e} = ${t}`),this.format[e]=t,this.opts.observer&&this.opts.observer({metadata:this,tag:{type:"format",id:e,value:t}})}addTag(e,t,r){c(`tag ${e}.${t} = ${r}`),this.native[e]||(this.format.tagTypes.push(e),this.native[e]=[]),this.native[e].push({id:t,value:r}),this.toCommon(e,t,r)}getNativeMetadata(){return{format:this.format,native:this.native}}postMap(e,t){switch(t.id){case"artist":if(this.commonOrigin.artist===this.originPriority[e])return this.postMap("artificial",{id:"artists",value:t.value});this.common.artists||this.setGenericTag("artificial",{id:"artists",value:t.value});break;case"artists":if(!(this.common.artist&&this.commonOrigin.artist!==this.originPriority.artificial||this.common.artists&&-1!==this.common.artists.indexOf(t.value))){const e={id:"artist",value:l((this.common.artists||[]).concat([t.value]))};this.setGenericTag("artificial",e)}break;case"genre":t.value=s.CommonTagMapper.parseGenre(t.value);break;case"picture":t.value.format=s.CommonTagMapper.fixPictureMimeType(t.value.format);break;case"totaltracks":return void(this.common.track.of=s.CommonTagMapper.toIntOrNull(t.value));case"totaldiscs":return void(this.common.disk.of=s.CommonTagMapper.toIntOrNull(t.value));case"track":case"disk":const r=this.common[t.id].of;return this.common[t.id]=s.CommonTagMapper.normalizeTrack(t.value),void(this.common[t.id].of=null!=r?r:this.common[t.id].of);case"year":case"originalyear":t.value=parseInt(t.value,10);break;case"date":const n=parseInt(t.value.substr(0,4),10);n&&!isNaN(n)&&(this.common.year=n);break;case"discogs_label_id":case"discogs_release_id":case"discogs_master_release_id":case"discogs_artist_id":case"discogs_votes":t.value="string"==typeof t.value?parseInt(t.value,10):t.value;break;case"replaygain_track_gain":case"replaygain_track_peak":t.value=o.toRatio(t.value);break;case"gapless":t.value="1"===t.value}this.setGenericTag(e,t)}toCommonMetadata(){return{format:this.format,native:this.opts.native?this.native:void 0,common:this.common}}toCommon(e,t,r){const n={id:t,value:r},i=this.tagMapper.mapTag(e,n);i&&this.postMap(e,i)}setGenericTag(e,t){c(`common.${t.id} = ${t.value}`);const r=this.commonOrigin[t.id]||1e3,n=this.originPriority[e];if(i.isSingleton(t.id)){if(!(n<=r))return c(`Ignore native tag (singleton): ${e}.${t.id} = ${t.value}`);this.common[t.id]=t.value,this.commonOrigin[t.id]=n}else if(n===r)i.isUnique(t.id)&&-1!==this.common[t.id].indexOf(t.value)?c(`Ignore duplicate value: ${e}.${t.id} = ${t.value}`):this.common[t.id].push(t.value);else{if(!(n{this.registerTagMapper(e)})}mapTag(e,t){if(this.tagMappers[e])return this.tagMappers[e].mapGenericTag(t);throw new Error("No generic tag mapper defined for tag-format: "+e)}registerTagMapper(e){for(const t of e.tagTypes)this.tagMappers[t]=e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={title:"title",artist:"artist",album:"album",year:"year",comment:"comment",track:"track",genre:"genre"};t.ID3v1TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v1"],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{static decode(e){let t="";for(const r in e)e.hasOwnProperty(r)&&(t+=n.codePointToString(n.singleByteDecoder(e[r])));return t}static inRange(e,t,r){return t<=e&&e<=r}static codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}static singleByteDecoder(e){if(n.inRange(e,0,127))return e;const t=n.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}}n.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],t.Windows1292Decoder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i=r(4),a={TIT2:"title",TPE1:"artist","TXXX:Artists":"artists",TPE2:"albumartist",TALB:"album",TDRV:"date",TORY:"originalyear",TPOS:"disk",TCON:"genre",APIC:"picture",TCOM:"composer","USLT:description":"lyrics",TSOA:"albumsort",TSOT:"titlesort",TOAL:"originalalbum",TSOP:"artistsort",TSO2:"albumartistsort",TSOC:"composersort",TEXT:"lyricist","TXXX:Writer":"writer",TPE3:"conductor",TPE4:"remixer","IPLS:arranger":"arranger","IPLS:engineer":"engineer","IPLS:producer":"producer","IPLS:DJ-mix":"djmixer","IPLS:mix":"mixer",TPUB:"label",TIT1:"grouping",TIT3:"subtitle",TRCK:"track",TCMP:"compilation",POPM:"rating",TBPM:"bpm",TMED:"media","TXXX:CATALOGNUMBER":"catalognumber","TXXX:MusicBrainz Album Status":"releasestatus","TXXX:MusicBrainz Album Type":"releasetype","TXXX:MusicBrainz Album Release Country":"releasecountry","TXXX:RELEASECOUNTRY":"releasecountry","TXXX:SCRIPT":"script",TLAN:"language",TCOP:"copyright",WCOP:"license",TENC:"encodedby",TSSE:"encodersettings","TXXX:BARCODE":"barcode",TSRC:"isrc","TXXX:ASIN":"asin","TXXX:originalyear":"originalyear","UFID:http://musicbrainz.org":"musicbrainz_recordingid","TXXX:MusicBrainz Release Track Id":"musicbrainz_trackid","TXXX:MusicBrainz Album Id":"musicbrainz_albumid","TXXX:MusicBrainz Artist Id":"musicbrainz_artistid","TXXX:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","TXXX:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","TXXX:MusicBrainz Work Id":"musicbrainz_workid","TXXX:MusicBrainz TRM Id":"musicbrainz_trmid","TXXX:MusicBrainz Disc Id":"musicbrainz_discid","TXXX:ACOUSTID_ID":"acoustid_id","TXXX:Acoustid Id":"acoustid_id","TXXX:Acoustid Fingerprint":"acoustid_fingerprint","TXXX:MusicIP PUID":"musicip_puid","TXXX:MusicMagic Fingerprint":"musicip_fingerprint",WOAR:"website",TDRC:"date",TYER:"year",TDOR:"originaldate","TIPL:arranger":"arranger","TIPL:engineer":"engineer","TIPL:producer":"producer","TIPL:DJ-mix":"djmixer","TIPL:mix":"mixer",TMOO:"mood",SYLT:"lyrics",TSST:"discsubtitle",TKEY:"key",COMM:"comment",TOPE:"originalartist","PRIV:AverageLevel":"averageLevel","PRIV:PeakLevel":"peakLevel","TXXX:DISCOGS_ARTIST_ID":"discogs_artist_id","TXXX:DISCOGS_ARTISTS":"artists","TXXX:DISCOGS_ARTIST_NAME":"artists","TXXX:DISCOGS_ALBUM_ARTISTS":"albumartist","TXXX:DISCOGS_CATALOG":"catalognumber","TXXX:DISCOGS_COUNTRY":"releasecountry","TXXX:DISCOGS_DATE":"originaldate","TXXX:DISCOGS_LABEL":"label","TXXX:DISCOGS_LABEL_ID":"discogs_label_id","TXXX:DISCOGS_MASTER_RELEASE_ID":"discogs_master_release_id","TXXX:DISCOGS_RATING":"discogs_rating","TXXX:DISCOGS_RELEASED":"date","TXXX:DISCOGS_RELEASE_ID":"discogs_release_id","TXXX:DISCOGS_VOTES":"discogs_votes","TXXX:CATALOGID":"catalognumber","TXXX:STYLE":"genre","TXXX:replaygain_track_peak":"replaygain_track_peak","TXXX:replaygain_track_gain":"replaygain_track_gain"};class s extends n.CommonTagMapper{static toRating(e){return{source:e.email,rating:e.rating>0?(e.rating-1)/254*n.CommonTagMapper.maxRatingScore:void 0}}constructor(){super(["ID3v2.3","ID3v2.4"],a)}postMap(e){switch(e.id){case"UFID":"http://musicbrainz.org"===e.value.owner_identifier&&(e.id+=":"+e.value.owner_identifier,e.value=i.default.decodeString(e.value.identifier,"iso-8859-1"));break;case"PRIV":switch(e.value.owner_identifier){case"AverageLevel":case"PeakValue":e.id+=":"+e.value.owner_identifier,e.value=4===e.value.data.length?e.value.data.readUInt32LE(0):null}break;case"COMM":e.value=e.value?e.value.text:null;break;case"POPM":e.value=s.toRating(e.value)}}}t.ID3v24TagMapper=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Author:"artist","WM/AlbumArtist":"albumartist","WM/AlbumTitle":"album","WM/Year":"date","WM/OriginalReleaseTime":"originaldate","WM/OriginalReleaseYear":"originalyear",Description:"comment","WM/TrackNumber":"track","WM/PartOfSet":"disk","WM/Genre":"genre","WM/Composer":"composer","WM/Lyrics":"lyrics","WM/AlbumSortOrder":"albumsort","WM/TitleSortOrder":"titlesort","WM/ArtistSortOrder":"artistsort","WM/AlbumArtistSortOrder":"albumartistsort","WM/ComposerSortOrder":"composersort","WM/Writer":"lyricist","WM/Conductor":"conductor","WM/ModifiedBy":"remixer","WM/Engineer":"engineer","WM/Producer":"producer","WM/DJMixer":"djmixer","WM/Mixer":"mixer","WM/Publisher":"label","WM/ContentGroupDescription":"grouping","WM/SubTitle":"subtitle","WM/SetSubTitle":"discsubtitle","WM/IsCompilation":"compilation","WM/SharedUserRating":"rating","WM/BeatsPerMinute":"bpm","WM/Mood":"mood","WM/Media":"media","WM/CatalogNo":"catalognumber","MusicBrainz/Album Status":"releasestatus","MusicBrainz/Album Type":"releasetype","MusicBrainz/Album Release Country":"releasecountry","WM/Script":"script","WM/Language":"language",Copyright:"copyright",LICENSE:"license","WM/EncodedBy":"encodedby","WM/EncodingSettings":"encodersettings","WM/Barcode":"barcode","WM/ISRC":"isrc","MusicBrainz/Track Id":"musicbrainz_recordingid","MusicBrainz/Release Track Id":"musicbrainz_trackid","MusicBrainz/Album Id":"musicbrainz_albumid","MusicBrainz/Artist Id":"musicbrainz_artistid","MusicBrainz/Album Artist Id":"musicbrainz_albumartistid","MusicBrainz/Release Group Id":"musicbrainz_releasegroupid","MusicBrainz/Work Id":"musicbrainz_workid","MusicBrainz/TRM Id":"musicbrainz_trmid","MusicBrainz/Disc Id":"musicbrainz_discid","Acoustid/Id":"acoustid_id","Acoustid/Fingerprint":"acoustid_fingerprint","MusicIP/PUID":"musicip_puid","WM/ARTISTS":"artists","WM/InitialKey":"key",ASIN:"asin","WM/Work":"work","WM/AuthorURL":"website","WM/Picture":"picture"};class a extends n.CommonTagMapper{static toRating(e){return{rating:parseFloat(e+1)/5}}constructor(){super(["asf"],i)}postMap(e){switch(e.id){case"WM/SharedUserRating":const t=e.id.split(":");e.value=a.toRating(e.value),e.id=t[0]}}}t.AsfTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.id3v22TagMap={TT2:"title",TP1:"artist",TP2:"albumartist",TAL:"album",TYE:"year",COM:"comment",TRK:"track",TPA:"disk",TCO:"genre",PIC:"picture",TCM:"composer",TOR:"originaldate",TOT:"work",TXT:"lyricist",TP3:"conductor",TPB:"label",TT1:"grouping",TT3:"subtitle",TLA:"language",TCR:"copyright",WCP:"license",TEN:"encodedby",TSS:"encodersettings",WAR:"website","COM:iTunPGAP":"gapless"};t.ID3v22TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v2.2"],t.id3v22TagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Artist:"artist",Artists:"artists","Album Artist":"albumartist",Album:"album",Year:"date",Originalyear:"originalyear",Originaldate:"originaldate",Comment:"comment",Track:"track",Disc:"disk",DISCNUMBER:"disk",Genre:"genre","Cover Art (Front)":"picture","Cover Art (Back)":"picture",Composer:"composer",Lyrics:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",Lyricist:"lyricist",Writer:"writer",Conductor:"conductor",MixArtist:"remixer",Arranger:"arranger",Engineer:"engineer",Producer:"producer",DJMixer:"djmixer",Mixer:"mixer",Label:"label",Grouping:"grouping",Subtitle:"subtitle",DiscSubtitle:"discsubtitle",Compilation:"compilation",BPM:"bpm",Mood:"mood",Media:"media",CatalogNumber:"catalognumber",MUSICBRAINZ_ALBUMSTATUS:"releasestatus",MUSICBRAINZ_ALBUMTYPE:"releasetype",RELEASECOUNTRY:"releasecountry",Script:"script",Language:"language",Copyright:"copyright",LICENSE:"license",EncodedBy:"encodedby",EncoderSettings:"encodersettings",Barcode:"barcode",ISRC:"isrc",ASIN:"asin",musicbrainz_trackid:"musicbrainz_recordingid",musicbrainz_releasetrackid:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",Acoustid_Id:"acoustid_id",ACOUSTID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",Weblink:"website"};t.APEv2TagMapper=class extends n.CommonTagMapper{constructor(){const e={};for(const t in i)e[t.toUpperCase()]=i[t];super(["APEv2"],e)}getCommonName(e){return this.tagMap[e.toUpperCase()]}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={"©nam":"title","©ART":"artist",aART:"albumartist","----:com.apple.iTunes:Band":"albumartist","©alb":"album","©day":"date","©cmt":"comment",trkn:"track",disk:"disk","©gen":"genre",covr:"picture","©wrt":"composer","©lyr":"lyrics",soal:"albumsort",sonm:"titlesort",soar:"artistsort",soaa:"albumartistsort",soco:"composersort","----:com.apple.iTunes:LYRICIST":"lyricist","----:com.apple.iTunes:CONDUCTOR":"conductor","----:com.apple.iTunes:REMIXER":"remixer","----:com.apple.iTunes:ENGINEER":"engineer","----:com.apple.iTunes:PRODUCER":"producer","----:com.apple.iTunes:DJMIXER":"djmixer","----:com.apple.iTunes:MIXER":"mixer","----:com.apple.iTunes:LABEL":"label","©grp":"grouping","----:com.apple.iTunes:SUBTITLE":"subtitle","----:com.apple.iTunes:DISCSUBTITLE":"discsubtitle",cpil:"compilation",tmpo:"bpm","----:com.apple.iTunes:MOOD":"mood","----:com.apple.iTunes:MEDIA":"media","----:com.apple.iTunes:CATALOGNUMBER":"catalognumber",tvsh:"tvShow",tvsn:"tvSeason",tves:"tvEpisode",sosn:"tvShowSort",tven:"tvEpisodeId",tvnn:"tvNetwork",pcst:"podcast",purl:"podcasturl","----:com.apple.iTunes:MusicBrainz Album Status":"releasestatus","----:com.apple.iTunes:MusicBrainz Album Type":"releasetype","----:com.apple.iTunes:MusicBrainz Album Release Country":"releasecountry","----:com.apple.iTunes:SCRIPT":"script","----:com.apple.iTunes:LANGUAGE":"language",cprt:"copyright","----:com.apple.iTunes:LICENSE":"license","©too":"encodedby",pgap:"gapless","----:com.apple.iTunes:BARCODE":"barcode","----:com.apple.iTunes:ISRC":"isrc","----:com.apple.iTunes:ASIN":"asin","----:com.apple.iTunes:NOTES":"comment","----:com.apple.iTunes:MusicBrainz Track Id":"musicbrainz_recordingid","----:com.apple.iTunes:MusicBrainz Release Track Id":"musicbrainz_trackid","----:com.apple.iTunes:MusicBrainz Album Id":"musicbrainz_albumid","----:com.apple.iTunes:MusicBrainz Artist Id":"musicbrainz_artistid","----:com.apple.iTunes:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","----:com.apple.iTunes:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","----:com.apple.iTunes:MusicBrainz Work Id":"musicbrainz_workid","----:com.apple.iTunes:MusicBrainz TRM Id":"musicbrainz_trmid","----:com.apple.iTunes:MusicBrainz Disc Id":"musicbrainz_discid","----:com.apple.iTunes:Acoustid Id":"acoustid_id","----:com.apple.iTunes:Acoustid Fingerprint":"acoustid_fingerprint","----:com.apple.iTunes:MusicIP PUID":"musicip_puid","----:com.apple.iTunes:fingerprint":"musicip_fingerprint",gnre:"genre","----:com.apple.iTunes:ALBUMARTISTSORT":"albumartistsort","----:com.apple.iTunes:ARTISTS":"artists","----:com.apple.iTunes:ORIGINALDATE":"originaldate","----:com.apple.iTunes:ORIGINALYEAR":"originalyear",desc:"description",ldes:"description"};t.tagType="iTunes";t.MP4TagMapper=class extends n.CommonTagMapper{constructor(){super([t.tagType],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={TITLE:"title",ARTIST:"artist",ARTISTS:"artists",ALBUMARTIST:"albumartist",ALBUM:"album",DATE:"date",ORIGINALDATE:"originaldate",ORIGINALYEAR:"originalyear",COMMENT:"comment",TRACKNUMBER:"track",DISCNUMBER:"disk",GENRE:"genre",METADATA_BLOCK_PICTURE:"picture",COMPOSER:"composer",LYRICS:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",LYRICIST:"lyricist",WRITER:"writer",CONDUCTOR:"conductor",REMIXER:"remixer",ARRANGER:"arranger",ENGINEER:"engineer",PRODUCER:"producer",DJMIXER:"djmixer",MIXER:"mixer",LABEL:"label",GROUPING:"grouping",SUBTITLE:"subtitle",DISCSUBTITLE:"discsubtitle",TRACKTOTAL:"totaltracks",DISCTOTAL:"totaldiscs",COMPILATION:"compilation",RATING:"rating",BPM:"bpm",MOOD:"mood",MEDIA:"media",CATALOGNUMBER:"catalognumber",RELEASESTATUS:"releasestatus",RELEASETYPE:"releasetype",RELEASECOUNTRY:"releasecountry",SCRIPT:"script",LANGUAGE:"language",COPYRIGHT:"copyright",LICENSE:"license",ENCODEDBY:"encodedby",ENCODERSETTINGS:"encodersettings",BARCODE:"barcode",ISRC:"isrc",ASIN:"asin",MUSICBRAINZ_TRACKID:"musicbrainz_recordingid",MUSICBRAINZ_RELEASETRACKID:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",ACOUSTID_ID:"acoustid_id",ACOUSTID_ID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",WEBSITE:"website",NOTES:"notes",TOTALTRACKS:"totaltracks",TOTALDISCS:"totaldiscs",DISCOGS_ARTIST_ID:"discogs_artist_id",DISCOGS_ARTISTS:"artists",DISCOGS_ARTIST_NAME:"artists",DISCOGS_ALBUM_ARTISTS:"albumartist",DISCOGS_CATALOG:"catalognumber",DISCOGS_COUNTRY:"releasecountry",DISCOGS_DATE:"originaldate",DISCOGS_LABEL:"label",DISCOGS_LABEL_ID:"discogs_label_id",DISCOGS_MASTER_RELEASE_ID:"discogs_master_release_id",DISCOGS_RATING:"discogs_rating",DISCOGS_RELEASED:"date",DISCOGS_RELEASE_ID:"discogs_release_id",DISCOGS_VOTES:"discogs_votes",CATALOGID:"catalognumber",STYLE:"genre",REPLAYGAIN_TRACK_GAIN:"replaygain_track_gain",REPLAYGAIN_TRACK_PEAK:"replaygain_track_peak"};class a extends n.CommonTagMapper{static toRating(e,t){return{source:e?e.toLowerCase():e,rating:parseFloat(t)*n.CommonTagMapper.maxRatingScore}}constructor(){super(["vorbis"],i)}postMap(e){if(0===e.id.indexOf("RATING:")){const t=e.id.split(":");e.value=a.toRating(t[1],e.value),e.id=t[0]}}}t.VorbisTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.riffInfoTagMap={IART:"artist",ICRD:"date",INAM:"title",TITL:"title",IPRD:"album",ITRK:"track",COMM:"comment",ICMT:"comment",ICNT:"releasecountry",GNRE:"genre",IWRI:"writer",RATE:"rating",YEAR:"year",ISFT:"encodedby",CODE:"encodedby",TURL:"website",IGNR:"genre",IENG:"engineer",ITCH:"technician",IMED:"media",IRPD:"album"};t.RiffInfoTagMapper=class extends n.CommonTagMapper{constructor(){super(["exif"],t.riffInfoTagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(10),s=r(20),o=r(17),c=r(5),u=r(7),l=r(224),d=r(225),f=r(25),p=i("music-metadata:parser:aiff");t.AIFFParser=class extends u.BasicParser{async parse(){if("FORM"!==(await this.tokenizer.readToken(d.Header)).chunkID)throw new Error("Invalid Chunk-ID, expected 'FORM'");const e=await this.tokenizer.readToken(c.FourCcToken);switch(e){case"AIFF":this.metadata.setFormat("container",e),this.isCompressed=!1;break;case"AIFC":this.metadata.setFormat("container","AIFF-C"),this.isCompressed=!0;break;default:throw Error("Unsupported AIFF type: "+e)}this.metadata.setFormat("lossless",!this.isCompressed);try{for(;;){const e=await this.tokenizer.readToken(d.Header);p(`Chunk id=${e.chunkID}`);const t=2*Math.round(e.chunkSize/2),r=await this.readData(e);await this.tokenizer.ignore(t-r)}}catch(e){if(e.message!==a.endOfFile)throw e}}async readData(e){switch(e.chunkID){case"COMM":const t=await this.tokenizer.readToken(new l.Common(e,this.isCompressed));return this.metadata.setFormat("bitsPerSample",t.sampleSize),this.metadata.setFormat("sampleRate",t.sampleRate),this.metadata.setFormat("numberOfChannels",t.numChannels),this.metadata.setFormat("numberOfSamples",t.numSampleFrames),this.metadata.setFormat("duration",t.numSampleFrames/t.sampleRate),this.metadata.setFormat("codec",t.compressionName),e.chunkSize;case"ID3 ":const r=await this.tokenizer.readToken(new n.BufferType(e.chunkSize)),i=new f.ID3Stream(r),a=s.fromStream(i);return await(new o.ID3v2Parser).parse(this.metadata,a,this.options),e.chunkSize;case"SSND":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*e.chunkSize/this.metadata.format.duration),0;default:return 0}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(4),s=r(18),o=n("music-metadata:id3v2:frame-parser"),c="iso-8859-1";class u{static readData(t,r,n,l){const{encoding:d,bom:f}=s.TextEncodingToken.get(t,0),p=t.length;let h=0,m=[];const g=u.getNullTerminatorLength(d);let b;const y={};switch(o(`Parsing tag type=${r}, encoding=${d}, bom=${f}`),"TXXX"!==r&&"T"===r[0]?"T*":r){case"T*":case"IPLS":const w=a.default.decodeString(t.slice(1),d).replace(/\x00+$/,"");switch(r){case"TMCL":case"TIPL":case"IPLS":m=u.splitValue(4,w),m=u.functionList(m);break;case"TRK":case"TRCK":case"TPOS":m=w;break;case"TCOM":case"TEXT":case"TOLY":case"TOPE":case"TPE1":case"TSRC":m=u.splitValue(n,w);break;default:m=n>=4?u.splitValue(n,w):[w]}break;case"TXXX":m={description:(m=u.readIdentifierAndData(t,h+1,p,d)).id,text:u.splitValue(n,a.default.decodeString(m.data,d).replace(/\x00+$/,""))};break;case"PIC":case"APIC":if(l){const r={};switch(h+=1,n){case 2:r.format=a.default.decodeString(t.slice(h,h+3),d),h+=3;break;case 3:case 4:b=a.default.findZero(t,h,p,c),r.format=a.default.decodeString(t.slice(h,b),c),h=b+1;break;default:throw new Error("Warning: unexpected major versionIndex: "+n)}r.format=u.fixPictureMimeType(r.format),r.type=s.AttachedPictureType[t[h]],h+=1,b=a.default.findZero(t,h,p,d),r.description=a.default.decodeString(t.slice(h,b),d),h=b+g,r.data=e.from(t.slice(h,p)),m=r}break;case"CNT":case"PCNT":m=i.UINT32_BE.get(t,0);break;case"SYLT":for(h+=7,m=[];h=5?t.readUInt32BE(h+1):void 0};break;case"GEOB":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d);const r=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d),m={type:e,filename:r,description:a.default.decodeString(t.slice(h+1,b),c),data:t.slice(h+1,p)};break}case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":m=a.default.decodeString(t.slice(h,b),d);break;case"WXXX":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,m={description:e,url:a.default.decodeString(t.slice(h,p-h),d)};break}case"MCDI":m=t.slice(0,p);break;default:o("Warning: unsupported id3v2-tag-type: "+r)}return m}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase()){case"jpg":return"image/jpeg";case"png":return"image/png"}return e}static functionList(e){const t={};for(let r=0;r+1=4?/\x00/g:/\//g);return u.trimArray(r)}static trimArray(e){for(let t=0;t=r,`COMMON CHUNK size should always be at least ${r}`),this.len=e.chunkSize}get(e,t){const r=e.readUInt16BE(t+8)-16398,i=e.readUInt16BE(t+8+2),s={numChannels:e.readUInt16BE(t),numSampleFrames:e.readUInt32BE(t+2),sampleSize:e.readUInt16BE(t+6),sampleRate:r<0?i>>Math.abs(r):i<22){const r=e.readInt8(t+22);if(23+r+(r+1)%2!==this.len)throw new Error("Illegal pstring length");s.compressionName=new n.StringType(r,"binary").get(e,t+23)}}else s.compressionName="PCM";return s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5);t.Header={len:8,get:(e,t)=>({chunkID:n.FourCcToken.get(e,t),chunkSize:e.readUInt32BE(t+4)})}},function(e,t){},function(e,t,r){"use strict";var n=r(28).Buffer,i=r(228);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,a=n.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,r=a,i=o,t.copy(r,i),o+=s.data.length,s=s.next;return a},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function a(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new a(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new a(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(230),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(11))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,a,s,o,c=1,u={},l=!1,d=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){h(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((a=new MessageChannel).port1.onmessage=function(e){h(e.data)},n=function(e){a.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(i=d.documentElement,n=function(e){var t=d.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(h,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&h(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),n=function(t){e.postMessage(s+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>1}}function s(e,t){return 0!=(e&1<({ID:i.FourCcToken.get(e,t),version:n.UINT32_LE.get(e,t+4)/1e3,descriptorBytes:n.UINT32_LE.get(e,t+8),headerBytes:n.UINT32_LE.get(e,t+12),seekTableBytes:n.UINT32_LE.get(e,t+16),headerDataBytes:n.UINT32_LE.get(e,t+20),apeFrameDataBytes:n.UINT32_LE.get(e,t+24),apeFrameDataBytesHigh:n.UINT32_LE.get(e,t+28),terminatingDataBytes:n.UINT32_LE.get(e,t+32),fileMD5:new n.BufferType(16).get(e,t+36)})},t.Header={len:24,get:(e,t)=>({compressionLevel:n.UINT16_LE.get(e,t),formatFlags:n.UINT16_LE.get(e,t+2),blocksPerFrame:n.UINT32_LE.get(e,t+4),finalFrameBlocks:n.UINT32_LE.get(e,t+8),totalFrames:n.UINT32_LE.get(e,t+12),bitsPerSample:n.UINT16_LE.get(e,t+16),channel:n.UINT16_LE.get(e,t+18),sampleRate:n.UINT32_LE.get(e,t+20)})},t.TagFooter={len:32,get:(e,t)=>({ID:new n.StringType(8,"ascii").get(e,t),version:n.UINT32_LE.get(e,t+8),size:n.UINT32_LE.get(e,t+12),fields:n.UINT32_LE.get(e,t+16),flags:a(n.UINT32_LE.get(e,t+20))})},t.TagItemHeader={len:8,get:(e,t)=>({size:n.UINT32_LE.get(e,t),flags:a(n.UINT32_LE.get(e,t+4))})},t.TagField=e=>new n.BufferType(e.size-t.TagFooter.len),t.parseTagFlags=a,t.isBitSet=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(41),i=r(240),a=r(2),s=r(7),o=a("music-metadata:parser:ASF"),c="asf";t.AsfParser=class extends s.BasicParser{async parse(){const e=await this.tokenizer.readToken(i.TopLevelHeaderObjectToken);if(!e.objectId.equals(n.default.HeaderObject))throw new Error("expected asf header; but was not found; got: "+e.objectId.str);try{await this.parseObjectHeader(e.numberOfHeaderObjects)}catch(e){o("Error while parsing ASF: %s",e)}}async parseObjectHeader(e){let t;do{const e=await this.tokenizer.readToken(i.HeaderObjectToken);switch(o("header GUID=%s",e.objectId.str),e.objectId.str){case i.FilePropertiesObject.guid.str:const r=await this.tokenizer.readToken(new i.FilePropertiesObject(e));this.metadata.setFormat("duration",r.playDuration/1e7),this.metadata.setFormat("bitrate",r.maximumBitrate);break;case i.StreamPropertiesObject.guid.str:const a=await this.tokenizer.readToken(new i.StreamPropertiesObject(e));this.metadata.setFormat("container","ASF/"+a.streamType);break;case i.HeaderExtensionObject.guid.str:const s=await this.tokenizer.readToken(new i.HeaderExtensionObject);await this.parseExtensionObject(s.extensionDataSize);break;case i.ContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ContentDescriptionObjectState(e)),this.addTags(t);break;case i.ExtendedContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ExtendedContentDescriptionObjectState(e)),this.addTags(t);break;case n.default.CodecListObject.str:case n.default.StreamBitratePropertiesObject.str:await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;case n.default.PaddingObject.str:o("Padding: %s bytes",e.objectSize-i.HeaderObjectToken.len),await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+e.objectId.str),o("Ignore ASF-Object-GUID: %s",e.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(e))}}while(--e)}addTags(e){e.forEach(e=>{this.metadata.addTag(c,e.id,e.value)})}async parseExtensionObject(e){do{const t=await this.tokenizer.readToken(i.HeaderObjectToken);switch(t.objectId.str){case i.ExtendedStreamPropertiesObjectState.guid.str:await this.tokenizer.readToken(new i.ExtendedStreamPropertiesObjectState(t));break;case i.MetadataObjectState.guid.str:const e=await this.tokenizer.readToken(new i.MetadataObjectState(t));this.addTags(e);break;case i.MetadataLibraryObjectState.guid.str:const r=await this.tokenizer.readToken(new i.MetadataLibraryObjectState(t));this.addTags(r);break;case n.default.PaddingObject.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.CompatibilityObject.str:this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.ASF_Index_Placeholder_Object.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+t.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(t))}e-=t.objectSize}while(e>0)}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),i=r(1),a=r(41),s=r(241),o=r(18);!function(e){e[e.UnicodeString=0]="UnicodeString",e[e.ByteArray=1]="ByteArray",e[e.Bool=2]="Bool",e[e.DWord=3]="DWord",e[e.QWord=4]="QWord",e[e.Word=5]="Word"}(t.DataType||(t.DataType={})),t.TopLevelHeaderObjectToken={len:30,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16),numberOfHeaderObjects:i.UINT32_LE.get(e,t+24)})},t.HeaderObjectToken={len:24,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16)})};class c{constructor(e){this.len=e.objectSize-t.HeaderObjectToken.len}postProcessTag(e,t,r,n){if("WM/Picture"===t)e.push({id:t,value:b.fromBuffer(n)});else{const i=s.AsfUtil.getParserForAttr(r);if(!i)throw new Error("unexpected value headerType: "+r);e.push({id:t,value:i(n)})}}}t.State=c;t.IgnoreObjectState=class extends c{constructor(e){super(e)}get(e,t){return null}};class u extends c{constructor(e){super(e)}get(e,t){return{fileId:a.default.fromBin(e,t),fileSize:i.UINT64_LE.get(e,t+16),creationDate:i.UINT64_LE.get(e,t+24),dataPacketsCount:i.UINT64_LE.get(e,t+32),playDuration:i.UINT64_LE.get(e,t+40),sendDuration:i.UINT64_LE.get(e,t+48),preroll:i.UINT64_LE.get(e,t+56),flags:{broadcast:n.default.strtokBITSET.get(e,t+64,24),seekable:n.default.strtokBITSET.get(e,t+64,25)},minimumDataPacketSize:i.UINT32_LE.get(e,t+68),maximumDataPacketSize:i.UINT32_LE.get(e,t+72),maximumBitrate:i.UINT32_LE.get(e,t+76)}}}u.guid=a.default.FilePropertiesObject,t.FilePropertiesObject=u;class l extends c{constructor(e){super(e)}get(e,t){return{streamType:a.default.decodeMediaType(a.default.fromBin(e,t)),errorCorrectionType:a.default.fromBin(e,t+8)}}}l.guid=a.default.StreamPropertiesObject,t.StreamPropertiesObject=l;class d{constructor(){this.len=22}get(e,t){return{reserved1:a.default.fromBin(e,t),reserved2:e.readUInt16LE(t+16),extensionDataSize:e.readUInt32LE(t+18)}}}d.guid=a.default.HeaderExtensionObject,t.HeaderExtensionObject=d;class f extends c{constructor(e){super(e)}get(e,t){const r=[];let n=t+10;for(let i=0;i0){const t=f.contentDescTags[i],o=n+a;r.push({id:t,value:s.AsfUtil.parseUnicodeAttr(e.slice(n,o))}),n=o}}return r}}f.guid=a.default.ContentDescriptionObject,f.contentDescTags=["Title","Author","Copyright","Description","Rating"],t.ContentDescriptionObjectState=f;class p extends c{constructor(e){super(e)}get(e,t){const r=[],n=e.readUInt16LE(t);let i=t+2;for(let t=0;t({lastBlock:n.default.strtokBITSET.get(e,t,7),type:n.default.getBitAllignedNumber(e,t,1,7),length:i.UINT24_BE.get(e,t+1)})},d.BlockStreamInfo={len:34,get:(e,t)=>({minimumBlockSize:i.UINT16_BE.get(e,t),maximumBlockSize:i.UINT16_BE.get(e,t+2)/1e3,minimumFrameSize:i.UINT24_BE.get(e,t+4),maximumFrameSize:i.UINT24_BE.get(e,t+7),sampleRate:i.UINT24_BE.get(e,t+10)>>4,channels:n.default.getBitAllignedNumber(e,t+12,4,3)+1,bitsPerSample:n.default.getBitAllignedNumber(e,t+12,7,5)+1,totalSamples:n.default.getBitAllignedNumber(e,t+13,4,36),fileMD5:new i.BufferType(16).get(e,t+18)})};class f{constructor(e){this.data=e,this.offset=0}readInt32(){const e=i.UINT32_LE.get(this.data,this.offset);return this.offset+=4,e}readStringUtf8(){const e=this.readInt32(),t=this.data.toString("utf8",this.offset,this.offset+e);return this.offset+=e,t}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(7),s=r(244),o=r(43),c=r(24),u=n("music-metadata:parser:MP4"),l="iTunes",d={raw:{lossy:!1,format:"raw"},MAC3:{lossy:!0,format:"MACE 3:1"},MAC6:{lossy:!0,format:"MACE 6:1"},ima4:{lossy:!0,format:"IMA 4:1"},ulaw:{lossy:!0,format:"uLaw 2:1"},alaw:{lossy:!0,format:"uLaw 2:1"},Qclp:{lossy:!0,format:"QUALCOMM PureVoice"},".mp3":{lossy:!0,format:"MPEG-1 layer 3"},alac:{lossy:!1,format:"ALAC"},"ac-3":{lossy:!0,format:"AC-3"},mp4a:{lossy:!0,format:"MPEG-4/AAC"},mp4s:{lossy:!0,format:"MP4S"},c608:{lossy:!0,format:"CEA-608"},c708:{lossy:!0,format:"CEA-708"}};function f(e,t,r){return r.indexOf(e)===t}class p extends a.BasicParser{static read_BE_Signed_Integer(e){return i.readIntBE(e,0,e.length)}static read_BE_Unsigned_Integer(e){return i.readUIntBE(e,0,e.length)}async parse(){this.formatList=[];const e=new s.Atom({name:"mp4",length:this.tokenizer.fileSize},!1,null);await e.readAtoms(this.tokenizer,async e=>{if(e.parent)switch(e.parent.header.name){case"ilst":case"":return this.parseMetadataItemData(e);case"stbl":switch(e.header.name){case"stsd":return this.parseAtom_stsd(e.dataLen);default:u(`Ignore: stbl/${e.header.name} atom`)}}switch(e.header.name){case"ftyp":const t=await this.parseAtom_ftyp(e.dataLen);u(`ftyp: ${t.join("/")}`);const r=t.filter(f).join("/");return void this.metadata.setFormat("container",r);case"mdhd":return this.parseAtom_mdhd(e);case"mvhd":return this.parseAtom_mvhd(e);case"mdat":this.audioLengthInBytes=e.dataLen,this.calculateBitRate()}await this.tokenizer.readToken(new i.IgnoreType(e.dataLen)),u(`Ignore atom data: path=${e.atomPath}, payload-len=${e.dataLen}`)},this.tokenizer.fileSize),this.metadata.setFormat("codec",this.formatList.filter(f).join("+"))}calculateBitRate(){this.audioLengthInBytes&&this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*this.audioLengthInBytes/this.metadata.format.duration)}addTag(e,t){this.metadata.addTag(l,e,t)}addWarning(e){u("Warning:"+e),this.warnings.push(e)}parseMetadataItemData(e){let t=e.header.name;return e.readAtoms(this.tokenizer,async e=>{switch(e.header.name){case"data":return this.parseValueAtom(t,e);case"name":const r=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+r.name;break;case"mean":const n=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+n.name;break;default:const a=await this.tokenizer.readToken(new i.BufferType(e.dataLen));this.addWarning("Unsupported meta-item: "+t+"["+e.header.name+"] => value="+a.toString("hex")+" ascii="+a.toString("ascii"))}},e.dataLen)}async parseValueAtom(t,r){const n=await this.tokenizer.readToken(new o.DataAtom(r.header.length-o.Header.len));if(0!==n.type.set)throw new Error("Unsupported type-set != 0: "+n.type.set);switch(n.type.type){case 0:switch(t){case"trkn":case"disk":const e=i.UINT8.get(n.value,3),r=i.UINT8.get(n.value,5);this.addTag(t,e+"/"+r);break;case"gnre":const a=i.UINT8.get(n.value,1),s=c.Genres[a-1];this.addTag(t,s)}break;case 1:case 18:this.addTag(t,n.value.toString("utf-8"));break;case 13:if(this.options.skipCovers)break;this.addTag(t,{format:"image/jpeg",data:e.from(n.value)});break;case 14:if(this.options.skipCovers)break;this.addTag(t,{format:"image/png",data:e.from(n.value)});break;case 21:this.addTag(t,p.read_BE_Signed_Integer(n.value));break;case 22:this.addTag(t,p.read_BE_Unsigned_Integer(n.value));break;case 65:this.addTag(t,n.value.readInt8(0));break;case 66:this.addTag(t,n.value.readInt16BE(0));break;case 67:this.addTag(t,n.value.readInt32BE(0));break;default:this.addWarning(`atom key=${t}, has unknown well-known-type (data-type): ${n.type.type}`)}}async parseAtom_mvhd(e){const t=await this.tokenizer.readToken(new o.MvhdAtom(e.dataLen));this.parse_mxhd(t)}async parseAtom_mdhd(e){const t=await this.tokenizer.readToken(new o.MdhdAtom(e.dataLen));this.parse_mxhd(t)}parse_mxhd(e){if(e.timeScale&&!this.metadata.format.duration){const t=e.duration/e.timeScale;this.metadata.setFormat("duration",t),this.calculateBitRate()}}async parseAtom_ftyp(e){const t=await this.tokenizer.readToken(o.ftyp);if((e-=o.ftyp.len)>0){const r=await this.parseAtom_ftyp(e),n=t.type.replace(/\W/g,"");return n.length>0&&r.push(n),r}return[]}async parseAtom_stsd(e){const t=await this.tokenizer.readToken(new o.StsdAtom(e)),r=[];for(const e of t.table){const t=d[e.dataFormat];t?(this.parseSoundSampleDescription(e),this.metadata.setFormat("lossless",!t.lossy),r.push(t.format)):u(`Warning: data-format '${e.dataFormat}' missing in MP4Parser.encoderDict`)}r.length>0&&this.formatList.push(r.join("/"))}parseSoundSampleDescription(e){let t=0;const r=o.SoundSampleDescriptionVersion.get(e.description,t);if(t+=o.SoundSampleDescriptionVersion.len,0===r.version||1===r.version){const r=o.SoundSampleDescriptionV0.get(e.description,t);this.metadata.setFormat("sampleRate",r.sampleRate),this.metadata.setFormat("bitsPerSample",r.sampleSize),this.metadata.setFormat("numberOfChannels",r.numAudioChannels)}else u(`Warning: sound-sample-description ${r} not implemented`)}}t.MP4Parser=p}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(2),a=r(1),s=r(43),o=i("music-metadata:parser:MP4:Atom");class c{constructor(e,t,r){this.header=e,this.extended=t,this.parent=r,this.children=[],this.atomPath=(this.parent?this.parent.atomPath+"/":"")+this.header.name,this.dataLen=this.header.length-(t?16:8)}async readAtoms(e,t,r){const i=await this.readAtom(e,t);return this.children.push(i),void 0===r?this.readAtoms(e,t,r).catch(e=>{if(e.message!==n.endOfFile)throw e;o("Reached end-of-file")}):(r-=i.header.length)>0?this.readAtoms(e,t,r):void 0}async readAtom(e,t){const r=e.position,n=await e.readToken(s.Header),i=1===n.length;i&&(n.length=await e.readToken(s.ExtendedSize));const a=new c(n,i,this);return o(`parse atom name=${a.atomPath}, extended=${a.extended}, offset=${r}, len=${a.header.length}`),await a.readData(e,t),a}async readData(e,t){switch(this.header.name){case"moov":case"udta":case"trak":case"mdia":case"minf":case"stbl":case"":case"ilst":return this.readAtoms(e,t,this.dataLen);case"meta":return await e.readToken(new a.IgnoreType(4)),this.readAtoms(e,t,this.dataLen-4);case"mdhd":case"mvhd":case"tkhd":case"stsz":case"mdat":default:return t(this)}}}t.Atom=c},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(10),s=r(2),o=r(4),c=r(23),u=r(246),l=s("music-metadata:parser:mpeg"),d=1024,f={AudioObjectTypes:["AAC Main","AAC LC","AAC SSR","AAC LTP"],SamplingFrequencies:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,void 0,void 0,-1]},p=[void 0,["front-center"],["front-left","front-right"],["front-center","front-left","front-right"],["front-center","front-left","front-right","back-center"],["front-center","front-left","front-right","back-left","back-right"],["front-center","front-left","front-right","back-left","back-right","LFE-channel"],["front-center","front-left","front-right","side-left","side-right","back-left","back-right","LFE-channel"]];class h{constructor(e,t){this.versionIndex=o.default.getBitAllignedNumber(e,t+1,3,2),this.layer=h.LayerDescription[o.default.getBitAllignedNumber(e,t+1,5,2)],this.versionIndex>1&&0===this.layer?this.parseAdtsHeader(e,t):this.parseMpegHeader(e,t),this.isProtectedByCRC=!o.default.isBitSet(e,t+1,7)}calcDuration(e){return e*this.calcSamplesPerFrame()/this.samplingRate}calcSamplesPerFrame(){return h.samplesInFrameTable[1===this.version?0:1][this.layer]}calculateSideInfoLength(){if(3!==this.layer)return 2;if(3===this.channelModeIndex){if(1===this.version)return 17;if(2===this.version||2.5===this.version)return 9}else{if(1===this.version)return 32;if(2===this.version||2.5===this.version)return 17}}calcSlotSize(){return[null,4,1,1][this.layer]}parseMpegHeader(e,t){this.container="MPEG",this.bitrateIndex=o.default.getBitAllignedNumber(e,t+2,0,4),this.sampRateFreqIndex=o.default.getBitAllignedNumber(e,t+2,4,2),this.padding=o.default.isBitSet(e,t+2,6),this.privateBit=o.default.isBitSet(e,t+2,7),this.channelModeIndex=o.default.getBitAllignedNumber(e,t+3,0,2),this.modeExtension=o.default.getBitAllignedNumber(e,t+3,2,2),this.isCopyrighted=o.default.isBitSet(e,t+3,4),this.isOriginalMedia=o.default.isBitSet(e,t+3,5),this.emphasis=o.default.getBitAllignedNumber(e,t+3,7,2),this.version=h.VersionID[this.versionIndex],this.channelMode=h.ChannelMode[this.channelModeIndex],this.codec="MP"+this.layer;const r=this.calcBitrate();if(!r)throw new Error("Cannot determine bit-rate");if(this.bitrate=1e3*r,this.samplingRate=this.calcSamplingRate(),null==this.samplingRate)throw new Error("Cannot determine sampling-rate")}parseAdtsHeader(e,t){l("layer=0 => ADTS"),this.version=2===this.versionIndex?4:2,this.container="ADTS/MPEG-"+this.version;const r=o.default.getBitAllignedNumber(e,t+2,0,2);this.codec="AAC",this.codecProfile=f.AudioObjectTypes[r],l(`MPEG-4 audio-codec=${this.codec}`);const n=o.default.getBitAllignedNumber(e,t+2,2,4);this.samplingRate=f.SamplingFrequencies[n],l(`sampling-rate=${this.samplingRate}`);const i=o.default.getBitAllignedNumber(e,t+2,7,3);this.mp4ChannelConfig=p[i],l(`channel-config=${this.mp4ChannelConfig.join("+")}`),this.frameLength=o.default.getBitAllignedNumber(e,t+3,6,2)<<11}calcBitrate(){if(0===this.bitrateIndex)return null;if(15===this.bitrateIndex)return null;const e=this.version.toString()+this.layer;return h.bitrate_index[this.bitrateIndex][e]}calcSamplingRate(){return 3===this.sampRateFreqIndex?null:h.sampling_rate_freq_index[this.version][this.sampRateFreqIndex]}}h.SyncByte1=255,h.SyncByte2=224,h.VersionID=[2.5,null,2,1],h.LayerDescription=[0,3,2,1],h.ChannelMode=["stereo","joint_stereo","dual_channel","mono"],h.bitrate_index={1:{11:32,12:32,13:32,21:32,22:8,23:8},2:{11:64,12:48,13:40,21:48,22:16,23:16},3:{11:96,12:56,13:48,21:56,22:24,23:24},4:{11:128,12:64,13:56,21:64,22:32,23:32},5:{11:160,12:80,13:64,21:80,22:40,23:40},6:{11:192,12:96,13:80,21:96,22:48,23:48},7:{11:224,12:112,13:96,21:112,22:56,23:56},8:{11:256,12:128,13:112,21:128,22:64,23:64},9:{11:288,12:160,13:128,21:144,22:80,23:80},10:{11:320,12:192,13:160,21:160,22:96,23:96},11:{11:352,12:224,13:192,21:176,22:112,23:112},12:{11:384,12:256,13:224,21:192,22:128,23:128},13:{11:416,12:320,13:256,21:224,22:144,23:144},14:{11:448,12:384,13:320,21:256,22:160,23:160}},h.sampling_rate_freq_index={1:{0:44100,1:48e3,2:32e3},2:{0:22050,1:24e3,2:16e3},2.5:{0:11025,1:12e3,2:8e3}},h.samplesInFrameTable=[[0,384,1152,1152],[0,384,1152,576]];const m={len:4,get:(e,t)=>new h(e,t)};t.MpegParser=class extends c.AbstractID3Parser{constructor(){super(...arguments),this.frameCount=0,this.syncFrameCount=-1,this.countSkipFrameData=0,this.totalDataLength=0,this.bitrates=[],this.calculateEofDuration=!1,this.buf_frame_header=e.alloc(4),this.syncPeek={buf:e.alloc(d),len:0}}async _parse(){this.metadata.setFormat("lossless",!1);try{let e=!1;for(;!e;)await this.sync(),e=await this.parseCommonMpegHeader()}catch(e){if(e.message!==a.endOfFile)throw e;if(this.calculateEofDuration){const e=this.frameCount*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",e);const t=e/this.metadata.format.sampleRate;l(`Calculate duration at EOF: ${t} sec.`,t),this.metadata.setFormat("duration",t)}}}finalize(){const e=this.metadata.format,t=this.metadata.native.hasOwnProperty("ID3v1");if(e.duration&&this.tokenizer.fileSize){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0);e.codecProfile&&"V"===e.codecProfile[0]&&this.metadata.setFormat("bitrate",8*r/e.duration)}else if(this.tokenizer.fileSize&&"CBR"===e.codecProfile){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0),n=Math.round(r/this.frame_size)*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",n);const i=n/e.sampleRate;l("Calculate CBR duration based on file size: %s",i),this.metadata.setFormat("duration",i)}}async sync(){let e=!1;for(;;){let t=0;if(this.syncPeek.len=await this.tokenizer.peekBuffer(this.syncPeek.buf,0,d,this.tokenizer.position,!0),this.syncPeek.len<=256)throw new Error(a.endOfFile);if(0===this.syncPeek.len)throw new Error(a.endOfFile);for(;;){if(e&&224==(224&this.syncPeek.buf[t]))return this.buf_frame_header[0]=h.SyncByte1,this.buf_frame_header[1]=this.syncPeek.buf[t],await this.tokenizer.ignore(t),l(`Sync at offset=${this.tokenizer.position-1}, frameCount=${this.frameCount}`),this.syncFrameCount===this.frameCount&&(l(`Re-synced MPEG stream, frameCount=${this.frameCount}`),this.frameCount=0,this.frame_size=0),void(this.syncFrameCount=this.frameCount);if(e=!1,-1===(t=this.syncPeek.buf.indexOf(h.SyncByte1,t))){if(this.syncPeek.len=2&&0===e.layer?this.parseAdts(e):this.parseAudioFrameHeader(e)}async parseAudioFrameHeader(e){this.metadata.setFormat("numberOfChannels","mono"===e.channelMode?1:2),this.metadata.setFormat("bitrate",e.bitrate),this.frameCount<2e5&&l("offset=%s MP%s bitrate=%s sample-rate=%s",this.tokenizer.position-4,e.layer,e.bitrate,e.samplingRate);const t=e.calcSlotSize();if(null===t)throw new Error("invalid slot_size");const r=e.calcSamplesPerFrame();l(`samples_per_frame=${r}`);const n=r/8*e.bitrate/e.samplingRate+(e.padding?t:0);if(this.frame_size=Math.floor(n),this.audioFrameHeader=e,this.bitrates.push(e.bitrate),1===this.frameCount)return this.offset=m.len,await this.skipSideInformation(),!1;if(3===this.frameCount){if(this.areAllSame(this.bitrates)){if(this.samplesPerFrame=r,this.metadata.setFormat("codecProfile","CBR"),this.tokenizer.fileSize)return!0}else if(this.metadata.format.duration)return!0;if(!this.options.duration)return!0}return this.options.duration&&4===this.frameCount&&(this.samplesPerFrame=r,this.calculateEofDuration=!0),this.offset=4,e.isProtectedByCRC?(await this.parseCrc(),!1):(await this.skipSideInformation(),!1)}async parseAdts(t){const r=e.alloc(3);await this.tokenizer.readBuffer(r),t.frameLength+=o.default.getBitAllignedNumber(r,0,0,11),this.tokenizer.ignore(t.frameLength-7),this.totalDataLength+=t.frameLength,this.samplesPerFrame=1024;const n=t.samplingRate/this.samplesPerFrame,i=8*(0===this.frameCount?0:this.totalDataLength/this.frameCount)*n+.5;if(this.metadata.setFormat("codecProfile",t.codecProfile),this.metadata.setFormat("bitrate",i),t.mp4ChannelConfig&&this.metadata.setFormat("numberOfChannels",t.mp4ChannelConfig.length),l(`frame-count=${this.frameCount}, size=${t.frameLength} bytes, bit-rate=${i}`),3===this.frameCount){if(!this.options.duration)return!0;this.calculateEofDuration=!0}return!1}async parseCrc(){return this.crc=await this.tokenizer.readNumber(i.INT16_BE),this.offset+=2,this.skipSideInformation()}async skipSideInformation(){const e=this.audioFrameHeader.calculateSideInfoLength();await this.tokenizer.readToken(new i.BufferType(e)),this.offset+=e,await this.readXtraInfoHeader()}async readXtraInfoHeader(){const e=await this.tokenizer.readToken(u.InfoTagHeaderTag);switch(this.offset+=u.InfoTagHeaderTag.len,e){case"Info":return this.metadata.setFormat("codecProfile","CBR"),this.readXingInfoHeader();case"Xing":const t=await this.readXingInfoHeader(),r="V"+(100-t.vbrScale)/10;return this.metadata.setFormat("codecProfile",r),null;case"Xtra":break;case"LAME":const n=await this.tokenizer.readToken(u.LameEncoderVersion);return this.offset+=u.LameEncoderVersion.len,this.metadata.setFormat("tool","LAME "+n),await this.skipFrameData(this.frame_size-this.offset),null}const t=this.frame_size-this.offset;return t<0?this.warnings.push("Frame "+this.frameCount+"corrupt: negative frameDataLeft"):await this.skipFrameData(t),null}async readXingInfoHeader(){const e=await this.tokenizer.readToken(u.XingInfoTag);if(this.offset+=u.XingInfoTag.len,this.metadata.setFormat("tool",o.default.stripNulls(e.codec)),1==(1&e.headerFlags[3])){const t=this.audioFrameHeader.calcDuration(e.numFrames);return this.metadata.setFormat("duration",t),l("Get duration from Xing header: %s",this.metadata.format.duration),e}const t=this.frame_size-this.offset;return await this.skipFrameData(t),e}async skipFrameData(e){n.ok(e>=0,"frame-data-left cannot be negative"),await this.tokenizer.readToken(new i.IgnoreType(e)),this.countSkipFrameData+=e}areAllSame(e){const t=e[0];return e.every(e=>e===t)}}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.InfoTagHeaderTag=new n.StringType(4,"ascii"),t.LameEncoderVersion=new n.StringType(6,"ascii"),t.XingInfoTag={len:136,get:(e,t)=>({headerFlags:new n.BufferType(4).get(e,t),numFrames:n.UINT32_BE.get(e,t+4),streamSize:n.UINT32_BE.get(e,t+8),vbrScale:n.UINT32_BE.get(e,t+112),codec:new n.StringType(9,"ascii").get(e,t+116),infoTagRevision:n.UINT8.get(e,t+125)>>4,vbrMethod:15&n.UINT8.get(e,t+125)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(248),s=r(250),o=r(23),c=n("music-metadata:parser:musepack");t.default=class extends o.AbstractID3Parser{async _parse(){let e;switch(await this.tokenizer.peekToken(new i.StringType(3,"binary"))){case"MP+":c("Musepack stream-version 7"),e=new s.MpcSv7Parser;break;case"MPC":c("Musepack stream-version 8"),e=new a.MpcSv8Parser;break;default:throw new Error("Invalid Musepack signature prefix")}return e.init(this.metadata,this.tokenizer,this.options),e.parse()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(249),o=r(22),c=r(5),u=n("music-metadata:parser:musepack");t.MpcSv8Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(c.FourCcToken);return i.equal(e,"MPCK","Magic number"),this.metadata.setFormat("container","Musepack, SV8"),this.parsePacket()}async parsePacket(){const e=new s.StreamReader(this.tokenizer);for(;;){const t=await e.readPacketHeader();switch(u(`packet-header key=${t.key}, payloadLength=${t.payloadLength}`),t.key){case"SH":const r=await e.readStreamHeader(t.payloadLength);this.metadata.setFormat("numberOfSamples",r.sampleCount),this.metadata.setFormat("sampleRate",r.sampleFrequency),this.metadata.setFormat("duration",r.sampleCount/r.sampleFrequency),this.metadata.setFormat("numberOfChannels",r.channelCount);break;case"AP":this.audioLength+=t.payloadLength,await this.tokenizer.ignore(t.payloadLength);break;case"RG":case"EI":case"SO":case"ST":case"CT":await this.tokenizer.ignore(t.payloadLength);break;case"SE":return this.metadata.setFormat("bitrate",8*this.audioLength/this.metadata.format.duration),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options);default:throw new Error(`Unexpected header: ${t.key}`)}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4),a=r(2)("music-metadata:parser:musepack:sv8"),s=new n.StringType(2,"binary"),o={len:5,get:(e,t)=>({crc:n.UINT32_LE.get(e,t),streamVersion:n.UINT8.get(e,t+4)})},c={len:2,get:(e,t)=>({sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t,0,3)],maxUsedBands:i.default.getBitAllignedNumber(e,t,3,5),channelCount:i.default.getBitAllignedNumber(e,t+1,0,4)+1,msUsed:i.default.isBitSet(e,t+1,4),audioBlockFrames:i.default.getBitAllignedNumber(e,t+1,5,3)})};t.StreamReader=class{constructor(e){this.tokenizer=e}async readPacketHeader(){const e=await this.tokenizer.readToken(s),t=await this.readVariableSizeField();return{key:e,payloadLength:t.value-2-t.len}}async readStreamHeader(e){const t={};a(`Reading SH at offset=${this.tokenizer.position}`);const r=await this.tokenizer.readToken(o);e-=o.len,Object.assign(t,r),a(`SH.streamVersion = ${r.streamVersion}`);const n=await this.readVariableSizeField();e-=n.len,t.sampleCount=n.value;const i=await this.readVariableSizeField();e-=i.len,t.beginningOfSilence=i.value;const s=await this.tokenizer.readToken(c);return e-=c.len,Object.assign(t,s),await this.tokenizer.ignore(e),t}async readVariableSizeField(e=1,t=0){let r=await this.tokenizer.readToken(n.UINT8);return 0==(128&r)?{len:e,value:t+r}:(r&=127,r+=t,this.readVariableSizeField(e+1,r<<7))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(251),o=r(22),c=r(252),u=n("music-metadata:parser:musepack");t.MpcSv7Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(s.Header);i.equal(e.signature,"MP+","Magic number"),u(`stream-version=${e.streamMajorVersion}.${e.streamMinorVersion}`),this.metadata.setFormat("container","Musepack, SV7"),this.metadata.setFormat("sampleRate",e.sampleFrequency);const t=1152*(e.frameCount-1)+e.lastFrameLength;this.metadata.setFormat("numberOfSamples",t),this.duration=t/e.sampleFrequency,this.metadata.setFormat("duration",this.duration),this.bitreader=new c.BitReader(this.tokenizer),this.metadata.setFormat("numberOfChannels",e.midSideStereo||e.intensityStereo?2:1);const r=await this.bitreader.read(8);return this.metadata.setFormat("codec",(r/100).toFixed(2)),await this.skipAudioData(e.frameCount),u(`End of audio stream, switching to APEv2, offset=${this.tokenizer.position}`),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async skipAudioData(e){for(;e-- >0;){const e=await this.bitreader.read(20);this.audioLength+=20+e,await this.bitreader.ignore(e)}const t=await this.bitreader.read(11);this.audioLength+=t,this.metadata.setFormat("bitrate",this.audioLength/this.duration)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:24,get:(e,t)=>{const r={signature:e.toString("binary",t,t+3),streamMinorVersion:i.default.getBitAllignedNumber(e,t+3,0,4),streamMajorVersion:i.default.getBitAllignedNumber(e,t+3,4,4),frameCount:n.UINT32_LE.get(e,t+4),maxLevel:n.UINT16_LE.get(e,t+8),sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t+10,0,2)],link:i.default.getBitAllignedNumber(e,t+10,2,2),profile:i.default.getBitAllignedNumber(e,t+10,4,4),maxBand:i.default.getBitAllignedNumber(e,t+11,0,6),intensityStereo:i.default.isBitSet(e,t+11,6),midSideStereo:i.default.isBitSet(e,t+11,7),titlePeak:n.UINT16_LE.get(e,t+12),titleGain:n.UINT16_LE.get(e,t+14),albumPeak:n.UINT16_LE.get(e,t+16),albumGain:n.UINT16_LE.get(e,t+18),lastFrameLength:n.UINT32_LE.get(e,t+20)>>>20&2047,trueGapless:i.default.isBitSet(e,t+23,0)};return r.lastFrameLength=r.trueGapless?n.UINT32_LE.get(e,20)>>>20&2047:0,r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.BitReader=class{constructor(e){this.tokenizer=e,this.pos=0,this.dword=void 0}async read(e){for(;void 0===this.dword;)this.dword=await this.tokenizer.readToken(n.UINT32_LE);let t=this.dword;return this.pos+=e,this.pos<32?(t>>>=32-this.pos)&(1<>>32-this.pos),t&(1<0){const t=32-this.pos;this.dword=void 0,e-=t,this.pos=0}const t=e%32,r=(e-t)/32;return await this.tokenizer.ignore(4*r),this.read(t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(6),s=r(4),o=r(5),c=r(30),u=r(254),l=r(256),d=r(7),f=r(258),p=i("music-metadata:parser:ogg");class h{static sum(e,t,r){let n=0;for(let i=t;i0)return this.warnings.push("Invalid FourCC ID, maybe last OGG-page is not marked with last-page flag"),this.pageConsumer.flush();throw e}}}m.Header={len:27,get:(e,t)=>({capturePattern:o.FourCcToken.get(e,t),version:e.readUInt8(t+4),headerType:{continued:s.default.strtokBITSET.get(e,t+5,0),firstPage:s.default.strtokBITSET.get(e,t+5,1),lastPage:s.default.strtokBITSET.get(e,t+5,2)},absoluteGranulePosition:e.readIntLE(t+6,6),streamSerialNumber:n.UINT32_LE.get(e,t+14),pageSequenceNo:n.UINT32_LE.get(e,t+18),pageChecksum:n.UINT32_LE.get(e,t+22),page_segments:e.readUInt8(t+26)})},t.OggParser=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(255),a=r(30);t.OpusParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r,this.lastPos=-1}parseFirstPage(e,t){if(this.metadata.setFormat("codec","Opus"),this.idHeader=new i.IdHeader(t.length).get(t,0),"OpusHead"!==this.idHeader.magicSignature)throw new Error("Illegal ogg/Opus magic-signature");this.metadata.setFormat("sampleRate",this.idHeader.inputSampleRate),this.metadata.setFormat("numberOfChannels",this.idHeader.channelCount)}parseFullPage(e){switch(new n.StringType(8,"ascii").get(e,0)){case"OpusTags":this.parseUserCommentList(e,8),this.lastPos=this.tokenizer.position}}calculateDuration(e){if(this.metadata.format.sampleRate&&e.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",e.absoluteGranulePosition-this.idHeader.preSkip),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.idHeader.inputSampleRate),-1!==this.lastPos&&this.tokenizer.fileSize&&this.metadata.format.duration)){const e=this.tokenizer.fileSize-this.lastPos;this.metadata.setFormat("bitrate",8*e/this.metadata.format.duration)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdHeader=class{constructor(e){if(this.len=e,e<19)throw new Error("ID-header-page 0 should be at least 19 bytes long")}get(e,t){return{magicSignature:new n.StringType(8,"ascii").get(e,t+0),version:e.readUInt8(t+8),channelCount:e.readUInt8(t+9),preSkip:e.readInt16LE(t+10),inputSampleRate:e.readInt32LE(t+12),outputGain:e.readInt16LE(t+16),channelMapping:e.readUInt8(t+18)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(257),a=r(30),s=n("music-metadata:parser:ogg:speex");t.SpeexParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r}parseFirstPage(e,t){s("First Ogg/Speex page");const r=i.Header.get(t,0);this.metadata.setFormat("codec",`Speex ${r.version}`),this.metadata.setFormat("numberOfChannels",r.nb_channels),this.metadata.setFormat("sampleRate",r.rate),-1!==r.bitrate&&this.metadata.setFormat("bitrate",r.bitrate)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:80,get:(e,t)=>({speex:new n.StringType(8,"ascii").get(e,t+0),version:i.default.trimRightNull(new n.StringType(20,"ascii").get(e,t+8)),version_id:e.readInt32LE(t+28),header_size:e.readInt32LE(t+32),rate:e.readInt32LE(t+36),mode:e.readInt32LE(t+40),mode_bitstream_version:e.readInt32LE(t+44),nb_channels:e.readInt32LE(t+48),bitrate:e.readInt32LE(t+52),frame_size:e.readInt32LE(t+56),vbr:e.readInt32LE(t+60),frames_per_packet:e.readInt32LE(t+64),extra_headers:e.readInt32LE(t+68),reserved1:e.readInt32LE(t+72),reserved2:e.readInt32LE(t+76)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(259),a=n("music-metadata:parser:ogg:theora");t.TheoraParser=class{constructor(e,t,r){this.metadata=e,this.tokenizer=r}parsePage(e,t){e.headerType.firstPage&&this.parseFirstPage(e,t)}flush(){a("flush")}parseFirstPage(e,t){a("First Ogg/Theora page"),this.metadata.setFormat("codec","Theora");const r=i.IdentificationHeader.get(t,0);this.metadata.setFormat("bitrate",r.nombr)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdentificationHeader={len:42,get:(e,t)=>({id:new n.StringType(7,"ascii").get(e,t),vmaj:e.readUInt8(t+7),vmin:e.readUInt8(t+8),vrev:e.readUInt8(t+9),vmbw:e.readUInt16BE(t+10),vmbh:e.readUInt16BE(t+17),nombr:n.UINT24_BE.get(e,t+37),nqual:e.readUInt8(t+40)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(20),a=r(1),s=r(2),o=r(261),c=r(262),u=r(17),l=r(4),d=r(5),f=r(7),p=r(25),h=s("music-metadata:parser:RIFF");t.WaveParser=class extends f.BasicParser{async parse(){const e=await this.tokenizer.readToken(o.Header);if(h(`pos=${this.tokenizer.position}, parse: chunkID=${e.chunkID}`),"RIFF"===e.chunkID)return this.parseRiffChunk().catch(e=>{if(e.message!==n.endOfFile)throw e})}async parseRiffChunk(){const e=await this.tokenizer.readToken(d.FourCcToken);switch(this.metadata.setFormat("container",e),e){case"WAVE":return this.readWaveChunk();default:throw new Error(`Unsupported RIFF format: RIFF/${e}`)}}async readWaveChunk(){for(;;){const e=await this.tokenizer.readToken(o.Header);switch(this.header=e,h(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${e.chunkID}`),e.chunkID){case"LIST":await this.parseListTag(e);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new c.FactChunk(e));break;case"fmt ":const t=await this.tokenizer.readToken(new c.Format(e));let r=c.WaveFormat[t.wFormatTag];r||(h("WAVE/non-PCM format="+t.wFormatTag),r="non-PCM ("+t.wFormatTag+")"),this.metadata.setFormat("codec",r),this.metadata.setFormat("bitsPerSample",t.wBitsPerSample),this.metadata.setFormat("sampleRate",t.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",t.nChannels),this.metadata.setFormat("bitrate",t.nBlockAlign*t.nSamplesPerSec*8),this.blockAlign=t.nBlockAlign;break;case"id3 ":case"ID3 ":const n=await this.tokenizer.readToken(new a.BufferType(e.chunkSize)),s=new p.ID3Stream(n),o=i.fromStream(s);await(new u.ID3v2Parser).parse(this.metadata,o,this.options);break;case"data":!1!==this.metadata.format.lossless&&this.metadata.setFormat("lossless",!0);const l=this.fact?this.fact.dwSampleLength:e.chunkSize/this.blockAlign;this.metadata.setFormat("numberOfSamples",l),this.metadata.setFormat("duration",l/this.metadata.format.sampleRate),this.metadata.setFormat("bitrate",this.metadata.format.numberOfChannels*this.blockAlign*this.metadata.format.sampleRate),await this.tokenizer.ignore(e.chunkSize);break;default:h(`Ignore chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.warnings.push("Ignore chunk: RIFF/"+e.chunkID),await this.tokenizer.ignore(e.chunkSize)}this.header.chunkSize%2==1&&(h("Read odd padding byte"),await this.tokenizer.ignore(1))}}async parseListTag(e){const t=await this.tokenizer.readToken(d.FourCcToken);switch(h("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,t),t){case"INFO":return this.parseRiffInfoTags(e.chunkSize-4);case"adtl":default:return this.warnings.push("Ignore chunk: RIFF/WAVE/LIST/"+t),h("Ignoring chunkID=RIFF/WAVE/LIST/"+t),this.tokenizer.ignore(e.chunkSize-4)}}async parseRiffInfoTags(e){for(;e>=8;){const t=await this.tokenizer.readToken(o.Header),r=new o.ListInfoTagValue(t),n=await this.tokenizer.readToken(r);this.addTag(t.chunkID,l.default.stripNulls(n)),e-=8+r.len}if(0!==e)throw Error("Illegal remaining size: "+e)}addTag(e,t){this.metadata.addTag("exif",e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.Header={len:8,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:e.readUInt32LE(t+4)})};t.ListInfoTagValue=class{constructor(e){this.tagHeader=e,this.len=e.chunkSize,this.len+=1&this.len}get(e,t){return new n.StringType(this.tagHeader.chunkSize,"ascii").get(e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6);!function(e){e[e.PCM=1]="PCM",e[e.ADPCM=2]="ADPCM",e[e.IEEE_FLOAT=3]="IEEE_FLOAT",e[e.MPEG_ADTS_AAC=5632]="MPEG_ADTS_AAC",e[e.MPEG_LOAS=5634]="MPEG_LOAS",e[e.RAW_AAC1=255]="RAW_AAC1",e[e.DOLBY_AC3_SPDIF=146]="DOLBY_AC3_SPDIF",e[e.DVM=8192]="DVM",e[e.RAW_SPORT=576]="RAW_SPORT",e[e.ESST_AC3=577]="ESST_AC3",e[e.DRM=9]="DRM",e[e.DTS2=8193]="DTS2",e[e.MPEG=80]="MPEG"}(t.WaveFormat||(t.WaveFormat={}));t.Format=class{constructor(e){n.ok(e.chunkSize>=16,"16 for PCM."),this.len=e.chunkSize}get(e,t){return{wFormatTag:e.readUInt16LE(t),nChannels:e.readUInt16LE(t+2),nSamplesPerSec:e.readUInt32LE(t+4),nAvgBytesPerSec:e.readUInt32LE(t+8),nBlockAlign:e.readUInt16LE(t+12),wBitsPerSample:e.readUInt16LE(t+14)}}};t.FactChunk=class{constructor(e){n.ok(e.chunkSize>=4,"minimum fact chunk size."),this.len=e.chunkSize}get(e,t){return{dwSampleLength:e.readUInt32LE(t)}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(6),a=r(22),s=r(5),o=r(7),c=r(264),u=r(2)("music-metadata:parser:WavPack");t.WavPackParser=class extends o.BasicParser{async parse(){return this.audioDataSize=0,await this.parseWavPackBlocks(),a.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if("wvpk"!==await this.tokenizer.peekToken(s.FourCcToken))break;const e=await this.tokenizer.readToken(c.WavPack.BlockHeaderToken);i.strictEqual(e.BlockID,"wvpk","WavPack Block-ID"),u(`WavPack header blockIndex=${e.blockIndex}, len=${c.WavPack.BlockHeaderToken.len}`),0!==e.blockIndex||this.metadata.format.container||(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!e.flags.isHybrid),this.metadata.setFormat("bitsPerSample",e.flags.bitsPerSample),e.flags.isDSD||(this.metadata.setFormat("sampleRate",e.flags.samplingRate),this.metadata.setFormat("duration",e.totalSamples/e.flags.samplingRate)),this.metadata.setFormat("numberOfChannels",e.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",e.totalSamples),this.metadata.setFormat("codec",e.flags.isDSD?"DSD":"PCM"));const t=e.blockSize-(c.WavPack.BlockHeaderToken.len-8);0===e.blockIndex?await this.parseMetadataSubBlock(e,t):await this.tokenizer.ignore(t),e.blockSamples>0&&(this.audioDataSize+=e.blockSize)}while(!this.tokenizer.fileSize||this.tokenizer.fileSize-this.tokenizer.position>=c.WavPack.BlockHeaderToken.len);this.metadata.setFormat("bitrate",8*this.audioDataSize/this.metadata.format.duration)}async parseMetadataSubBlock(t,r){for(;r>c.WavPack.MetadataIdToken.len;){const a=await this.tokenizer.readToken(c.WavPack.MetadataIdToken),s=await this.tokenizer.readNumber(a.largeBlock?n.UINT24_LE:n.UINT8),o=e.alloc(2*s-(a.isOddSize?1:0));switch(await this.tokenizer.readBuffer(o,0,o.length),u(`Metadata Sub-Blocks functionId=0x${a.functionId.toString(16)}, id.largeBlock=${a.largeBlock},data-size=${o.length}`),a.functionId){case 0:break;case 14:u("ID_DSD_BLOCK");const e=1<>>t&4294967295>>>32-r}}s.BlockHeaderToken={len:32,get:(e,t)=>{const r=n.UINT32_LE.get(e,t+24),o={BlockID:i.FourCcToken.get(e,t),blockSize:n.UINT32_LE.get(e,t+4),version:n.UINT16_LE.get(e,t+8),totalSamples:(n.UINT8.get(e,t+11)<<32)+n.UINT32_LE.get(e,t+12),blockIndex:(n.UINT8.get(e,t+10)<<32)+n.UINT32_LE.get(e,t+16),blockSamples:n.UINT32_LE.get(e,t+20),flags:{bitsPerSample:8*(1+s.getBitAllignedNumber(r,0,2)),isMono:s.isBitSet(r,2),isHybrid:s.isBitSet(r,3),isJointStereo:s.isBitSet(r,4),crossChannel:s.isBitSet(r,5),hybridNoiseShaping:s.isBitSet(r,6),floatingPoint:s.isBitSet(r,7),samplingRate:a[s.getBitAllignedNumber(r,23,4)],isDSD:s.isBitSet(r,31)},crc:new n.BufferType(4).get(e,t+28)};return o.flags.isDSD&&(o.totalSamples*=8),o}},s.MetadataIdToken={len:1,get:(e,t)=>({functionId:s.getBitAllignedNumber(e[t],0,6),isOptional:s.isBitSet(e[t],5),isOddSize:s.isBitSet(e[t],6),largeBlock:s.isBitSet(e[t],7)})},t.WavPack=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(23),i=r(6),a=r(2),s=r(266),o=r(17),c=a("music-metadata:parser:DSF");t.DsfParser=class extends n.AbstractID3Parser{async _parse(){const e=this.tokenizer.position,t=await this.tokenizer.readToken(s.ChunkHeader);i.strictEqual(t.id,"DSD ","Invalid chunk signature"),this.metadata.setFormat("container","DSF"),this.metadata.setFormat("lossless",!0);const r=await this.tokenizer.readToken(s.DsdChunk);if(0!==r.metadataPointer)return c(`expect ID3v2 at offset=${r.metadataPointer}`),await this.parseChunks(r.fileSize-t.size),await this.tokenizer.ignore(r.metadataPointer-this.tokenizer.position-e),(new o.ID3v2Parser).parse(this.metadata,this.tokenizer,this.options);c("No ID3v2 tag present")}async parseChunks(e){for(;e>=s.ChunkHeader.len;){const t=await this.tokenizer.readToken(s.ChunkHeader);switch(c(`Parsing chunk name=${t.id} size=${t.size}`),t.id){case"fmt ":const e=await this.tokenizer.readToken(s.FormatChunk);this.metadata.setFormat("numberOfChannels",e.channelNum),this.metadata.setFormat("sampleRate",e.samplingFrequency),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("numberOfSamples",e.sampleCount),this.metadata.setFormat("duration",e.sampleCount/e.samplingFrequency);const r=e.bitsPerSample*e.samplingFrequency*e.channelNum;return void this.metadata.setFormat("bitrate",r);default:this.tokenizer.ignore(t.size-s.ChunkHeader.len)}e-=t.size}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({id:i.FourCcToken.get(e,t),size:n.UINT64_LE.get(e,t+4)})},t.DsdChunk={len:16,get:(e,t)=>({fileSize:n.INT64_LE.get(e,t),metadataPointer:n.INT64_LE.get(e,t+8)})},function(e){e[e.mono=1]="mono",e[e.stereo=2]="stereo",e[e.channels=3]="channels",e[e.quad=4]="quad",e[e["4 channels"]=5]="4 channels",e[e["5 channels"]=6]="5 channels",e[e["5.1 channels"]=7]="5.1 channels"}(t.ChannelType||(t.ChannelType={})),t.FormatChunk={len:40,get:(e,t)=>({formatVersion:n.INT32_LE.get(e,t),formatID:n.INT32_LE.get(e,t+4),channelType:n.INT32_LE.get(e,t+8),channelNum:n.INT32_LE.get(e,t+12),samplingFrequency:n.INT32_LE.get(e,t+16),bitsPerSample:n.INT32_LE.get(e,t+20),sampleCount:n.INT64_LE.get(e,t+24),blockSizePerChannel:n.INT32_LE.get(e,t+32)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(2),s=r(5),o=r(7),c=r(25),u=r(268),l=r(20),d=r(17),f=a("music-metadata:parser:aiff");t.DsdiffParser=class extends o.BasicParser{async parse(){const e=await this.tokenizer.readToken(u.ChunkHeader);n.strictEqual(e.chunkID,"FRM8");const t=(await this.tokenizer.readToken(s.FourCcToken)).trim();switch(t){case"DSD":return this.metadata.setFormat("container",`DSDIFF/${t}`),this.metadata.setFormat("lossless",!0),this.readFmt8Chunks(e.chunkSize-s.FourCcToken.len);default:throw Error(`Unsupported DSDIFF type: ${t}`)}}async readFmt8Chunks(e){for(;e>=u.ChunkHeader.len;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Chunk id=${t.chunkID}`),await this.readData(t),e-=u.ChunkHeader.len+t.chunkSize}}async readData(e){f(`Reading data of chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);const t=this.tokenizer.position;switch(e.chunkID.trim()){case"FVER":const t=await this.tokenizer.readToken(i.UINT32_LE);f(`DSDIFF version=${t}`);break;case"PROP":const r=await this.tokenizer.readToken(s.FourCcToken);n.strictEqual(r,"SND "),await this.handleSoundPropertyChunks(e.chunkSize-s.FourCcToken.len);break;case"ID3":const a=await this.tokenizer.readToken(new i.BufferType(e.chunkSize)),o=new c.ID3Stream(a),u=l.fromStream(o);await(new d.ID3v2Parser).parse(this.metadata,u,this.options);break;default:f(`Ignore chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);break;case"DSD":this.metadata.setFormat("numberOfSamples",8*e.chunkSize/this.metadata.format.numberOfChannels),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate)}const r=e.chunkSize-(this.tokenizer.position-t);r>0&&(f(`After Parsing chunk, remaining ${r} bytes`),await this.tokenizer.ignore(r))}async handleSoundPropertyChunks(e){for(f(`Parsing sound-property-chunks, remainingSize=${e}`);e>0;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`);const r=this.tokenizer.position;switch(t.chunkID.trim()){case"FS":const e=await this.tokenizer.readToken(i.UINT32_BE);this.metadata.setFormat("sampleRate",e);break;case"CHNL":const r=await this.tokenizer.readToken(i.UINT16_BE);this.metadata.setFormat("numberOfChannels",r),await this.handleChannelChunks(t.chunkSize-i.UINT16_BE.len);break;case"CMPR":const n=(await this.tokenizer.readToken(s.FourCcToken)).trim(),a=await this.tokenizer.readToken(i.UINT8),o=await this.tokenizer.readToken(new i.StringType(a,"ascii"));"DSD"===n&&(this.metadata.setFormat("lossless",!0),this.metadata.setFormat("bitsPerSample",1)),this.metadata.setFormat("codec",`${n} (${o})`);break;case"ABSS":const c=await this.tokenizer.readToken(i.UINT16_BE),u=await this.tokenizer.readToken(i.UINT8),l=await this.tokenizer.readToken(i.UINT8),d=await this.tokenizer.readToken(i.UINT32_BE);f(`ABSS ${c}:${u}:${l}.${d}`);break;case"LSCO":const p=await this.tokenizer.readToken(i.UINT16_BE);f(`LSCO lsConfig=${p}`);break;case"COMT":default:f(`Unknown sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`),await this.tokenizer.ignore(t.chunkSize)}const n=t.chunkSize-(this.tokenizer.position-r);n>0&&(f(`After Parsing sound-property-chunk ${t.chunkSize}, remaining ${n} bytes`),await this.tokenizer.ignore(n)),e-=u.ChunkHeader.len+t.chunkSize,f(`Parsing sound-property-chunks, remainingSize=${e}`)}if(this.metadata.format.lossless&&this.metadata.format.sampleRate&&this.metadata.format.numberOfChannels&&this.metadata.format.bitsPerSample){const e=this.metadata.format.sampleRate*this.metadata.format.numberOfChannels*this.metadata.format.bitsPerSample;this.metadata.setFormat("bitrate",e)}}async handleChannelChunks(e){f(`Parsing channel-chunks, remainingSize=${e}`);const t=[];for(;e>=s.FourCcToken.len;){const r=await this.tokenizer.readToken(s.FourCcToken);f(`Channel[ID=${r}]`),t.push(r),e-=s.FourCcToken.len}return f(`Channels: ${t.join(", ")}`),t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:n.INT64_BE.get(e,t+4)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(35);t.ReadableWeToNodeStream=class extends n.Readable{constructor(e){super(),this.bytesRead=0,this.released=!1,this.reader=e.getReader()}async _read(){if(this.released)return void this.push(null);this.pendingRead=this.reader.read();const e=await this.pendingRead;delete this.pendingRead,e.done||this.released?this.push(null):(this.bytesRead+=e.value.length,this.push(e.value))}async waitForReadToComplete(){this.pendingRead&&await this.pendingRead}async close(){await this.syncAndRelease()}async syncAndRelease(){this.released=!0,await this.waitForReadToComplete(),await this.reader.releaseLock()}}},function(e,t,r){(function(t){var n=r(271).strict;e.exports=function(e){if(n(e)){var r=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(r=r.slice(e.byteOffset,e.byteOffset+e.byteLength)),r}return t.from(e)}}).call(this,r(3).Buffer)},function(e,t){e.exports=i,i.strict=a,i.loose=s;var r=Object.prototype.toString,n={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return n[r.call(e)]}}]); \ No newline at end of file +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/",r(r.s=185)}([,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=(e,t,r,n)=>{if(t+r>e.length){if("function"!=typeof n)throw new Error("Buffer out of space and no valid flush() function found");return n(e,t),0}return t};t.UINT8={len:1,get:(e,t)=>e.readUInt8(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=255),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt8(r,s),s-t+this.len}},t.UINT16_LE={len:2,get:(e,t)=>e.readUInt16LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=65535),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt16LE(r,s),s-t+this.len}},t.UINT16_BE={len:2,get:(e,t)=>e.readUInt16BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=65535),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt16BE(r,s),s-t+this.len}},t.UINT24_LE={len:3,get:(e,t)=>e.readUIntLE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=16777215),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUIntLE(r,s,3),s-t+this.len}},t.UINT24_BE={len:3,get:(e,t)=>e.readUIntBE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=16777215),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUIntBE(r,s,3),s-t+this.len}},t.UINT32_LE={len:4,get:(e,t)=>e.readUInt32LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=4294967295),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt32LE(r,s),s-t+this.len}},t.UINT32_BE={len:4,get:(e,t)=>e.readUInt32BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=0&&r<=4294967295),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeUInt32BE(r,s),s-t+this.len}},t.INT8={len:1,get:(e,t)=>e.readInt8(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-128&&r<=127),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt8(r,s),s-t+this.len}},t.INT16_BE={len:2,get:(e,t)=>e.readInt16BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-32768&&r<=32767),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt16BE(r,s),s-t+this.len}},t.INT16_LE={len:2,get:(e,t)=>e.readInt16LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-32768&&r<=32767),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt16LE(r,s),s-t+this.len}},t.INT24_LE={len:3,get:(e,t)=>e.readIntLE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-8388608&&r<=8388607),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeIntLE(r,s,3),s-t+this.len}},t.INT24_BE={len:3,get:(e,t)=>e.readIntBE(t,3),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-8388608&&r<=8388607),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeIntBE(r,s,3),s-t+this.len}},t.INT32_BE={len:4,get:(e,t)=>e.readInt32BE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-2147483648&&r<=2147483647),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt32BE(r,s),s-t+this.len}},t.INT32_LE={len:4,get:(e,t)=>e.readInt32LE(t),put(e,t,r,a){n.equal(typeof t,"number"),n.equal(typeof r,"number"),n.ok(r>=-2147483648&&r<=2147483647),n.ok(t>=0),n.ok(this.len<=e.length);const s=i(e,t,this.len,a);return e.writeInt32LE(r,s),s-t+this.len}},t.UINT64_LE={len:8,get(e,t){return function(e,t,r){r>>>=0;let n=e[t>>>=0],i=1,a=0;for(;++a>>=0;let i=1,a=0;e[r>>>=0]=255&t;for(;++a>>=0;let n=e[t>>>=0],i=1,a=0;for(;++a=(i*=128)&&(n-=Math.pow(2,8*r));return n}(e,t,this.len)},put(e,t,r){return s(e,r,t,this.len)}},t.UINT64_BE={len:8,get(e,t){return o(e,t,this.len)},put(e,t,r){return c(e,r,t,this.len)}},t.INT64_BE={len:8,get(e,t){return u(e,t,this.len)},put(e,t,r){return l(e,r,t,this.len)}};t.IgnoreType=class{constructor(e){this.len=e}get(e,t){return null}};t.BufferType=class{constructor(e){this.len=e}get(e,t){return e.slice(t,t+this.len)}};t.StringType=class{constructor(e,t){this.len=e,this.encoding=t}get(e,t){return e.toString(this.encoding,t,t+this.len)}};class a{constructor(e){this.len=e}static decode(e,t,r){let n="";for(let i=t;i>10),56320+(1023&e)))}static singleByteDecoder(e){if(a.inRange(e,0,127))return e;const t=a.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}get(e,t=0){return a.decode(e,t,t+this.len)}}function s(e,t,r,n){t=+t;let i=0,a=1,s=0;for(e[r>>>=0]=255&t;++i>0)-s&255;return r+n}function o(e,t,r){r>>>=0;let n=e[(t>>>=0)+--r],i=1;for(;r>0&&(i*=256);)n+=e[t+--r]*i;return n}function c(e,t,r,n){t=+t;let i=(n>>>=0)-1,a=1;for(e[(r>>>=0)+i]=255&t;--i>=0&&(a*=256);)e[r+i]=t/a&255;return r+n}function u(e,t,r){let n=r>>>=0,i=1,a=e[(t>>>=0)+--n];for(;n>0&&(i*=256);)a+=e[t+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*r)),a}function l(e,t,r,n){t=+t;let i=n-1,a=1,s=0;for(e[(r>>>=0)+i]=255&t;--i>=0&&(a*=256);)t<0&&0===s&&0!==e[r+i+1]&&(s=1),e[r+i]=(t/a>>0)-s&255;return r+n}a.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],t.AnsiStringType=a,t.writeIntLE=s,t.readUIntBE=o,t.writeUIntBE=c,t.readIntBE=u,t.writeIntBE=l},function(e,t,r){(function(n){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(209)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){"use strict";(function(e){var n=r(187),i=r(188),a=r(34);function s(){return c.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function o(e,t){if(s()=s())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s().toString(16)+" bytes");return 0|e}function h(e,t){if(c.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return j(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return j(e).length;t=(""+t).toLowerCase(),n=!0}}function m(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return x(this,t,r);case"utf8":case"utf-8":return E(this,t,r);case"ascii":return F(this,t,r);case"latin1":case"binary":return A(this,t,r);case"base64":return C(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function b(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,i);if("number"==typeof t)return t&=255,c.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):y(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,r,n,i){var a,s=1,o=e.length,c=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;s=2,o/=2,c/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var l=-1;for(a=r;ao&&(r=o-c),a=r;a>=0;a--){for(var d=!0,f=0;fi&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var s=0;s>8,i=r%256,a.push(i),a.push(n);return a}(t,e.length-r),e,r,n)}function C(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function E(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:u>223?3:u>191?2:1;if(i+d<=r)switch(d){case 1:u<128&&(l=u);break;case 2:128==(192&(a=e[i+1]))&&(c=(31&u)<<6|63&a)>127&&(l=c);break;case 3:a=e[i+1],s=e[i+2],128==(192&a)&&128==(192&s)&&(c=(15&u)<<12|(63&a)<<6|63&s)>2047&&(c<55296||c>57343)&&(l=c);break;case 4:a=e[i+1],s=e[i+2],o=e[i+3],128==(192&a)&&128==(192&s)&&128==(192&o)&&(c=(15&u)<<18|(63&a)<<12|(63&s)<<6|63&o)>65535&&c<1114112&&(l=c)}null===l?(l=65533,d=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),i+=d}return function(e){var t=e.length;if(t<=_)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},c.prototype.compare=function(e,t,r,n,i){if(!c.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var a=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),o=Math.min(a,s),u=this.slice(n,i),l=e.slice(t,r),d=0;di)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return T(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return I(this,e,t,r);case"base64":return k(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var _=4096;function F(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function M(e,t,r,n,i,a){if(!c.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function D(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function O(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function R(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,a){return a||R(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function L(e,t,r,n,a){return a||R(e,0,r,8),i.write(e,t,r,n,52,8),r+8}c.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},c.prototype.readUInt8=function(e,t){return t||B(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return t||B(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return t||B(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return t||B(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},c.prototype.readUInt32BE=function(e,t){return t||B(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||B(e,t,this.length);for(var n=this[e],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*t)),n},c.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||B(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},c.prototype.readInt8=function(e,t){return t||B(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},c.prototype.readInt16LE=function(e,t){t||B(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt16BE=function(e,t){t||B(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},c.prototype.readInt32LE=function(e,t){return t||B(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return t||B(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return t||B(e,4,this.length),i.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return t||B(e,4,this.length),i.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return t||B(e,8,this.length),i.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return t||B(e,8,this.length),i.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||M(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+r},c.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,255,0),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,65535,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):O(this,e,t,!0),t+4},c.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,4294967295,0),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);M(this,e,t,r,i-1,-i)}var a=0,s=1,o=0;for(this[t]=255&e;++a>0)-o&255;return t+r},c.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);M(this,e,t,r,i-1,-i)}var a=r-1,s=1,o=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/s>>0)-o&255;return t+r},c.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,1,127,-128),c.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):D(this,e,t,!0),t+2},c.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,2,32767,-32768),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):D(this,e,t,!1),t+2},c.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),c.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):O(this,e,t,!0),t+4},c.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||M(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),c.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):O(this,e,t,!1),t+4},c.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return L(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return L(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(a<1e3||!c.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(z,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(12))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(215);class a{static findZero(e,t,r,n){let i=t;if("utf16"===n){for(;0!==e[i]||0!==e[i+1];){if(i>=r)return r;i+=2}return i}for(;0!==e[i];){if(i>=r)return r;i++}return i}static trimRightNull(e){const t=e.indexOf("\0");return-1===t?e:e.substr(0,t)}static swapBytes(e){const t=e.length;n.ok(0==(1&t),"Buffer length must be even");for(let r=0;r>i;const o=8-i,c=n-o;return c<0?s>>=8-i-n:c>0&&(s<<=c,s|=a.getBitAllignedNumber(e,t,r+o,c)),s}static isBitSet(e,t,r){return 1===a.getBitAllignedNumber(e,t,r,1)}static a2hex(e){const t=[];for(let r=0,n=e.length;r0!=(e[t]&1<e.trim().toLowerCase());if(t.length>=1){const e=parseFloat(t[0]);return 2===t.length&&"db"===t[1]?{dB:e,ratio:o(e)}:{dB:s(e),ratio:e}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),i=/^[\w-©][\w-\x000-3]/;t.FourCcToken={len:4,get:(e,r)=>{const a=e.toString("binary",r,r+t.FourCcToken.len);if(!a.match(i))throw new Error(`FourCC contains invalid characters: ${n.default.a2hex(a)}`);return a},put:(t,r,n)=>{const i=e.from(n,"binary");if(4!==i.length)throw new Error("Invalid length");return i.copy(t,r)}}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";(function(t){var n=r(196);function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i=0;u--)if(l[u]!==d[u])return!1;for(u=l.length-1;u>=0;u--)if(o=l[u],!w(e[o],t[o],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function T(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function v(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function I(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&b(i,r,"Missing expected exception"+n);var a="string"==typeof n,o=!e&&i&&!r;if((!e&&s.isError(i)&&a&&v(i,r)||o)&&b(i,r,"Got unwanted exception"+n),e&&i&&r&&!v(i,r)||!e&&i)throw i}f.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return m(g(e.actual),128)+" "+e.operator+" "+m(g(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||b;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=h(t),a=n.indexOf("\n"+i);if(a>=0){var s=n.indexOf("\n",a+1);n=n.substring(s+1)}this.stack=n}}},s.inherits(f.AssertionError,Error),f.fail=b,f.ok=y,f.equal=function(e,t,r){e!=t&&b(e,t,r,"==",f.equal)},f.notEqual=function(e,t,r){e==t&&b(e,t,r,"!=",f.notEqual)},f.deepEqual=function(e,t,r){w(e,t,!1)||b(e,t,r,"deepEqual",f.deepEqual)},f.deepStrictEqual=function(e,t,r){w(e,t,!0)||b(e,t,r,"deepStrictEqual",f.deepStrictEqual)},f.notDeepEqual=function(e,t,r){w(e,t,!1)&&b(e,t,r,"notDeepEqual",f.notDeepEqual)},f.notDeepStrictEqual=function e(t,r,n){w(t,r,!0)&&b(t,r,n,"notDeepStrictEqual",e)},f.strictEqual=function(e,t,r){e!==t&&b(e,t,r,"===",f.strictEqual)},f.notStrictEqual=function(e,t,r){e===t&&b(e,t,r,"!==",f.notStrictEqual)},f.throws=function(e,t,r){I(!0,e,t,r)},f.doesNotThrow=function(e,t,r){I(!1,e,t,r)},f.ifError=function(e){if(e)throw e},f.strict=n(function e(t,r){t||b(t,!0,r,"==",e)},f,{equal:f.strictEqual,deepEqual:f.deepStrictEqual,notEqual:f.notStrictEqual,notDeepEqual:f.notDeepStrictEqual}),f.strict.strict=f.strict;var k=Object.keys||function(e){var t=[];for(var r in e)o.call(e,r)&&t.push(r);return t}}).call(this,r(12))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.BasicParser=class{constructor(){this.warnings=[]}init(e,t,r){return this.metadata=e,this.tokenizer=t,this.options=r,this}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(25);class i{constructor(e,t){this.tagTypes=e,this.tagMap=t}static parseGenre(e){const t=e.trim().split(/\((.*?)\)/g).filter(e=>""!==e),r=[];for(let e of t)/^\d+$/.test(e)&&!isNaN(parseInt(e,10))&&(e=n.Genres[e]),r.push(e);return r.filter(e=>void 0!==e).join("/")}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase()){case"image/jpg":return"image/jpeg"}return e}static toIntOrNull(e){const t=parseInt(e,10);return isNaN(t)?null:t}static normalizeTrack(e){const t=e.toString().split("/");return{no:parseInt(t[0],10)||null,of:parseInt(t[1],10)||null}}mapGenericTag(e){e={id:e.id,value:e.value},this.postMap(e);const t=this.getCommonName(e.id);return t?{id:t,value:e.value}:null}getCommonName(e){return this.tagMap[e]}postMap(e){}}i.maxRatingScore=1,t.CommonTagMapper=i},function(e,t){var r,n,i=e.exports={};function a(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function o(e){if(r===setTimeout)return setTimeout(e,0);if((r===a||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:a}catch(e){r=a}try{n="function"==typeof clearTimeout?clearTimeout:s}catch(e){n=s}}();var c,u=[],l=!1,d=-1;function f(){l&&c&&(l=!1,c.length?u=c.concat(u):d=-1,u.length&&p())}function p(){if(!l){var e=o(f);l=!0;for(var t=u.length;t;){for(c=u,u=[];++d1)for(var r=1;r0?this.parseExtendedHeaderData(t,e.size):this.parseId3Data(this.id3Header.size-e.size)}async parseExtendedHeaderData(t,r){const n=e.alloc(t);return await this.tokenizer.readBuffer(n,0,t),this.parseId3Data(this.id3Header.size-r)}async parseId3Data(t){const r=e.alloc(t);await this.tokenizer.readBuffer(r,0,t);for(const e of this.parseMetadata(r))if("TXXX"===e.id)for(const t of e.value.text)this.addTag(o.makeDescriptionTagName(e.id,e.value.description),t);else if("COM"===e.id)for(const t of e.value)this.addTag(o.makeDescriptionTagName(e.id,t.description),t.text);else if(Array.isArray(e.value))for(const t of e.value)this.addTag(e.id,t);else this.addTag(e.id,e.value)}addTag(e,t){this.metadata.addTag(this.headerType,e,t)}parseMetadata(e){let t=0;const r=[];for(;t!==e.length;){const n=o.getFrameHeaderLength(this.id3Header.version.major);if(t+n>e.length)break;const i=e.slice(t,t+=n),a=o.readFrameHeader(i,this.id3Header.version.major);if(""===a.id||"\0\0\0\0"===a.id||-1==="ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(a.id[0]))break;const s=e.slice(t,t+=a.length),c=o.readFrameData(s,a,this.id3Header.version.major,!this.options.skipCovers);r.push({id:a.id,value:c})}return r}}t.ID3v2Parser=o}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);!function(e){e[e.Other=0]="Other",e[e["32x32 pixels 'file icon' (PNG only)"]=1]="32x32 pixels 'file icon' (PNG only)",e[e["Other file icon"]=2]="Other file icon",e[e["Cover (front)"]=3]="Cover (front)",e[e["Cover (back)"]=4]="Cover (back)",e[e["Leaflet page"]=5]="Leaflet page",e[e["Media (e.g. label side of CD)"]=6]="Media (e.g. label side of CD)",e[e["Lead artist/lead performer/soloist"]=7]="Lead artist/lead performer/soloist",e[e["Artist/performer"]=8]="Artist/performer",e[e.Conductor=9]="Conductor",e[e["Band/Orchestra"]=10]="Band/Orchestra",e[e.Composer=11]="Composer",e[e["Lyricist/text writer"]=12]="Lyricist/text writer",e[e["Recording Location"]=13]="Recording Location",e[e["During recording"]=14]="During recording",e[e["During performance"]=15]="During performance",e[e["Movie/video screen capture"]=16]="Movie/video screen capture",e[e["A bright coloured fish"]=17]="A bright coloured fish",e[e.Illustration=18]="Illustration",e[e["Band/artist logotype"]=19]="Band/artist logotype",e[e["Publisher/Studio logotype"]=20]="Publisher/Studio logotype"}(t.AttachedPictureType||(t.AttachedPictureType={})),t.UINT32SYNCSAFE={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},t.ID3v2Header={len:10,get:(e,r)=>({fileIdentifier:new n.StringType(3,"ascii").get(e,r),version:{major:n.INT8.get(e,r+3),revision:n.INT8.get(e,r+4)},flags:{raw:n.INT8.get(e,r+4),unsynchronisation:i.default.strtokBITSET.get(e,r+5,7),isExtendedHeader:i.default.strtokBITSET.get(e,r+5,6),expIndicator:i.default.strtokBITSET.get(e,r+5,5),footer:i.default.strtokBITSET.get(e,r+5,4)},size:t.UINT32SYNCSAFE.get(e,r+6)})},t.ExtendedHeader={len:10,get:(e,t)=>({size:n.UINT32_BE.get(e,t),extendedFlags:n.UINT16_BE.get(e,t+4),sizeOfPadding:n.UINT32_BE.get(e,t+6),crcDataPresent:i.default.strtokBITSET.get(e,t+4,31)})},t.TextEncodingToken={len:1,get:(e,t)=>{switch(e.readUInt8(t)){case 0:return{encoding:"iso-8859-1"};case 1:return{encoding:"utf16",bom:!0};case 2:return{encoding:"utf16",bom:!1};case 3:default:return{encoding:"utf8",bom:!1}}}}},function(e,t,r){(function(e){function r(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===r(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===r(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===r(e)},t.isError=function(e){return"[object Error]"===r(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=e.isBuffer}).call(this,r(3).Buffer)},,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(193),i=r(203);t.fromStream=function(e,t){return new n.ReadStreamTokenizer(e,t)},t.fromBuffer=function(e){return new i.BufferTokenizer(e)}},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var a,s,o=arguments.length;switch(o){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick(function(){e.call(null,r)});case 3:return t.nextTick(function(){e.call(null,r,n)});case 4:return t.nextTick(function(){e.call(null,r,n,i)});default:for(a=new Array(o-1),s=0;s1?e.blocksPerFrame*(e.totalFrames-1):0;return(t+=e.finalFrameBlocks)/e.sampleRate}static async parseTagHeader(t,r,n){if(r.fileSize&&r.fileSize-r.position0?this.parseDescriptorExpansion(t):this.parseHeader());return await this.tokenizer.readToken(new a.IgnoreType(r.forwardBytes)),p.parseTagHeader(this.metadata,this.tokenizer,this.options)}async parseDescriptorExpansion(e){return await this.tokenizer.readToken(new a.IgnoreType(e)),this.parseHeader()}async parseHeader(){const e=await this.tokenizer.readToken(u.Header);return this.metadata.setFormat("lossless",!0),this.metadata.setFormat("container","Monkey's Audio"),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("sampleRate",e.sampleRate),this.metadata.setFormat("numberOfChannels",e.channel),this.metadata.setFormat("duration",p.calculateDuration(e)),{forwardBytes:this.ape.descriptor.seekTableBytes+this.ape.descriptor.headerDataBytes+this.ape.descriptor.apeFrameDataBytes+this.ape.descriptor.terminatingDataBytes}}}t.APEv2Parser=p}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(18),a=r(17),s=r(25),o=r(2),c=r(7),u=o("music-metadata:parser:ID3");t.AbstractID3Parser=class extends c.BasicParser{constructor(){super(...arguments),this.id3parser=new a.ID3v2Parser}static async startsWithID3v2Header(e){return"ID3"===(await e.peekToken(i.ID3v2Header)).fileIdentifier}parse(){return this.parseID3v2().catch(e=>{if(e.message!==n.endOfFile)throw e})}finalize(){}async parseID3v2(){if(await this.tryReadId3v2Headers(),u("End of ID3v2 header, go to MPEG-parser: pos=%s",this.tokenizer.position),await this._parse(),this.options.skipPostHeaders&&this.metadata.hasAny())this.finalize();else{const e=new s.ID3v1Parser;await e.init(this.metadata,this.tokenizer,this.options).parse(),this.finalize()}}async tryReadId3v2Headers(){if("ID3"===(await this.tokenizer.peekToken(i.ID3v2Header)).fileIdentifier)return u("Found ID3v2 header, pos=%s",this.tokenizer.position),await this.id3parser.parse(this.metadata,this.tokenizer,this.options),this.tryReadId3v2Headers()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(4),a=r(1),s=r(7),o=n("music-metadata:parser:ID3v1");t.Genres=["Blues","Classic Rock","Country","Dance","Disco","Funk","Grunge","Hip-Hop","Jazz","Metal","New Age","Oldies","Other","Pop","R&B","Rap","Reggae","Rock","Techno","Industrial","Alternative","Ska","Death Metal","Pranks","Soundtrack","Euro-Techno","Ambient","Trip-Hop","Vocal","Jazz+Funk","Fusion","Trance","Classical","Instrumental","Acid","House","Game","Sound Clip","Gospel","Noise","Alt. Rock","Bass","Soul","Punk","Space","Meditative","Instrumental Pop","Instrumental Rock","Ethnic","Gothic","Darkwave","Techno-Industrial","Electronic","Pop-Folk","Eurodance","Dream","Southern Rock","Comedy","Cult","Gangsta Rap","Top 40","Christian Rap","Pop/Funk","Jungle","Native American","Cabaret","New Wave","Psychedelic","Rave","Showtunes","Trailer","Lo-Fi","Tribal","Acid Punk","Acid Jazz","Polka","Retro","Musical","Rock & Roll","Hard Rock","Folk","Folk/Rock","National Folk","Swing","Fast-Fusion","Bebob","Latin","Revival","Celtic","Bluegrass","Avantgarde","Gothic Rock","Progressive Rock","Psychedelic Rock","Symphonic Rock","Slow Rock","Big Band","Chorus","Easy Listening","Acoustic","Humour","Speech","Chanson","Opera","Chamber Music","Sonata","Symphony","Booty Bass","Primus","Porn Groove","Satire","Slow Jam","Club","Tango","Samba","Folklore","Ballad","Power Ballad","Rhythmic Soul","Freestyle","Duet","Punk Rock","Drum Solo","A Cappella","Euro-House","Dance Hall","Goa","Drum & Bass","Club-House","Hardcore","Terror","Indie","BritPop","Negerpunk","Polsk Punk","Beat","Christian Gangsta Rap","Heavy Metal","Black Metal","Crossover","Contemporary Christian","Christian Rock","Merengue","Salsa","Thrash Metal","Anime","JPop","Synthpop","Abstract","Art Rock","Baroque","Bhangra","Big Beat","Breakbeat","Chillout","Downtempo","Dub","EBM","Eclectic","Electro","Electroclash","Emo","Experimental","Garage","Global","IDM","Illbient","Industro-Goth","Jam Band","Krautrock","Leftfield","Lounge","Math Rock","New Romantic","Nu-Breakz","Post-Punk","Post-Rock","Psytrance","Shoegaze","Space Rock","Trop Rock","World Music","Neoclassical","Audiobook","Audio Theatre","Neue Deutsche Welle","Podcast","Indie Rock","G-Funk","Dubstep","Garage Rock","Psybient"];const c={len:128,get:(e,t)=>{const r=new u(3).get(e,t);return"TAG"===r?{header:r,title:new u(30).get(e,t+3),artist:new u(30).get(e,t+33),album:new u(30).get(e,t+63),year:new u(4).get(e,t+93),comment:new u(28).get(e,t+97),zeroByte:a.UINT8.get(e,t+127),track:a.UINT8.get(e,t+126),genre:a.UINT8.get(e,t+127)}:null}};class u extends a.StringType{constructor(e){super(e,"binary")}get(e,t){let r=super.get(e,t);return(r=(r=i.default.trimRightNull(r)).trim()).length>0?r:void 0}}class l extends s.BasicParser{static getGenre(e){if(ee)return void o("Already consumed the last 128 bytes");const t=await this.tokenizer.readToken(c,e);if(t){o("ID3v1 header found at: pos=%s",this.tokenizer.fileSize-c.len);for(const e of["title","artist","album","comment","track","year"])t[e]&&""!==t[e]&&this.addTag(e,t[e]);const e=l.getGenre(t.genre);e&&this.addTag("genre",e)}else o("ID3v1 header not found at: pos=%s",this.tokenizer.fileSize-c.len)}addTag(e,t){this.metadata.addTag("ID3v1",e,t)}}t.ID3v1Parser=l},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(36);t.ID3Stream=class extends n.Readable{constructor(e){super(),this.buf=e}_read(){this.push(this.buf),this.push(null)}}},function(e,t,r){"use strict";var n,i="object"==typeof Reflect?Reflect:null,a=i&&"function"==typeof i.apply?i.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};n=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var s=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var c=10;function u(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function l(e,t,r,n){var i,a,s,o;if("function"!=typeof r)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof r);if(void 0===(a=e._events)?(a=e._events=Object.create(null),e._eventsCount=0):(void 0!==a.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),s=a[t]),void 0===s)s=a[t]=r,++e._eventsCount;else if("function"==typeof s?s=a[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=u(e))>0&&s.length>i&&!s.warned){s.warned=!0;var c=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");c.name="MaxListenersExceededWarning",c.emitter=e,c.type=t,c.count=s.length,o=c,console&&console.warn&&console.warn(o)}return e}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=function(){for(var e=[],t=0;t0&&(s=t[0]),s instanceof Error)throw s;var o=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw o.context=s,o}var c=i[e];if(void 0===c)return!1;if("function"==typeof c)a(c,this,t);else{var u=c.length,l=h(c,u);for(r=0;r=0;a--)if(r[a]===t||r[a].listener===t){s=r[a].listener,i=a;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return f(this,e,!0)},o.prototype.rawListeners=function(e){return f(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e,t,r){(t=e.exports=r(37)).Stream=t,t.Readable=t,t.Writable=r(30),t.Duplex=r(13),t.Transform=r(41),t.PassThrough=r(234)},function(e,t,r){var n=r(3),i=n.Buffer;function a(e,t){for(var r in e)t[r]=e[r]}function s(e,t,r){return i(e,t,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=n:(a(n,t),t.Buffer=s),a(i,s),s.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return i(e,t,r)},s.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=i(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},s.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return i(e)},s.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t,n,i){var a=r(22);function s(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=y;var o,c=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:a.nextTick;y.WritableState=b;var u=r(19);u.inherits=r(16);var l={deprecate:r(232)},d=r(38),f=r(29).Buffer,p=i.Uint8Array||function(){};var h,m=r(39);function g(){}function b(e,t){o=o||r(13),e=e||{};var n=t instanceof o;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,u=e.writableHighWaterMark,l=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(u||0===u)?u:l,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var d=!1===e.decodeStrings;this.decodeStrings=!d,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(a.nextTick(i,n),a.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var s=I(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||v(e,r),n?c(T,e,r,s,i):T(e,r,s,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new s(this)}function y(e){if(o=o||r(13),!(h.call(y,this)||this instanceof o))return new y(e);this._writableState=new b(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),d.call(this)}function w(e,t,r,n,i,a,s){t.writelen=n,t.writecb=s,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,a,t.onwrite),t.sync=!1}function T(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function v(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),a=t.corkedRequestsFree;a.entry=r;for(var o=0,c=!0;r;)i[o]=r,r.isBuf||(c=!1),r=r.next,o+=1;i.allBuffers=c,w(e,t,!0,t.length,i,"",a.finish),t.pendingcb++,t.lastBufferedRequest=null,a.next?(t.corkedRequestsFree=a.next,a.next=null):t.corkedRequestsFree=new s(t),t.bufferedRequestCount=0}else{for(;r;){var u=r.chunk,l=r.encoding,d=r.callback;if(w(e,t,!1,t.objectMode?1:u.length,u,l,d),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function I(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function k(e,t){e._final(function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)})}function S(e,t){var r=I(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,a.nextTick(k,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}u.inherits(y,d),b.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(b.prototype,"buffer",{get:l.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(h=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!h.call(this,e)||this===y&&(e&&e._writableState instanceof b)}})):h=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,r){var n,i=this._writableState,s=!1,o=!i.objectMode&&(n=e,f.isBuffer(n)||n instanceof p);return o&&!f.isBuffer(e)&&(e=function(e){return f.from(e)}(e)),"function"==typeof t&&(r=t,t=null),o?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=g),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),a.nextTick(t,r)}(this,r):(o||function(e,t,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(e.emit("error",s),a.nextTick(n,s),i=!1),i}(this,i,e,r))&&(i.pendingcb++,s=function(e,t,r,n,i,a){if(!r){var s=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=f.from(t,r));return t}(t,n,i);n!==s&&(r=!0,i="buffer",n=s)}var o=t.objectMode?1:n.length;t.length+=o;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?a.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=m.destroy,y.prototype._undestroy=m.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(9),r(230).setImmediate,r(12))},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(43),s=i("music-metadata:parser:ogg:vorbis1");t.VorbisParser=class{constructor(e,t){this.metadata=e,this.options=t,this.codecName="Vorbis I",this.pageSegments=[]}parsePage(t,r){if(t.headerType.firstPage)this.parseFirstPage(t,r);else{if(t.headerType.continued){if(0===this.pageSegments.length)throw new Error("Cannot continue on previous page");this.pageSegments.push(r)}if(t.headerType.lastPage||!t.headerType.continued){if(this.pageSegments.length>0){const t=e.concat(this.pageSegments);this.parseFullPage(t)}this.pageSegments=t.headerType.lastPage?[]:[r]}}t.headerType.lastPage&&this.calculateDuration(t)}flush(){this.parseFullPage(e.concat(this.pageSegments))}parseFirstPage(e,t){this.metadata.setFormat("codec","Vorbis I"),s("Parse first page");const r=a.CommonHeader.get(t,0);if("vorbis"!==r.vorbis)throw new Error("Metadata does not look like Vorbis");if(1!==r.packetType)throw new Error("First Ogg page should be type 1: the identification header");{const e=a.IdentificationHeader.get(t,a.CommonHeader.len);this.metadata.setFormat("sampleRate",e.sampleRate),this.metadata.setFormat("bitrate",e.bitrateNominal),this.metadata.setFormat("numberOfChannels",e.channelMode),s("sample-rate=%s[hz], bitrate=%s[b/s], channel-mode=%s",e.sampleRate,e.bitrateNominal,e.channelMode)}}parseFullPage(e){const t=a.CommonHeader.get(e,0);switch(s("Parse full page: type=%s, byteLength=%s",t.packetType,e.byteLength),t.packetType){case 3:return this.parseUserCommentList(e,a.CommonHeader.len)}}calculateDuration(e){this.metadata.format.sampleRate&&e.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",e.absoluteGranulePosition),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate))}parseUserCommentList(e,t){const r=n.UINT32_LE.get(e,t);t+=4,new n.StringType(r,"utf-8").get(e,t),t+=r;let i=n.UINT32_LE.get(e,t);for(t+=4;i-- >0;)t+=this.parseUserComment(e,t)}parseUserComment(e,t){const r=n.UINT32_LE.get(e,t),i=new n.StringType(r,"utf-8").get(e,t+4),o=i.indexOf("="),c=i.slice(0,o).toUpperCase();let u=i.slice(o+1);return"METADATA_BLOCK_PICTURE"===c&&(u=this.options.skipCovers?null:a.VorbisPictureToken.fromBase64(u)),null!==u&&(s("Push tag: id=%s, value=%s",c,u),this.metadata.addTag("vorbis",c,u)),n.UINT32_LE.len+r}}}).call(this,r(3).Buffer)},,,function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(module,exports,__webpack_require__){"use strict";(function(Buffer){const{multiByteIndexOf:multiByteIndexOf,stringToBytes:stringToBytes,readUInt64LE:readUInt64LE,tarHeaderChecksumMatches:tarHeaderChecksumMatches,uint8ArrayUtf8ByteString:uint8ArrayUtf8ByteString}=__webpack_require__(205),supported=__webpack_require__(206),xpiZipFilename=stringToBytes("META-INF/mozilla.rsa"),oxmlContentTypes=stringToBytes("[Content_Types].xml"),oxmlRels=stringToBytes("_rels/.rels"),fileType=e=>{if(!(e instanceof Uint8Array||e instanceof ArrayBuffer||Buffer.isBuffer(e)))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`Buffer\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);if(!(t&&t.length>1))return;const r=(e,r)=>{r={offset:0,...r};for(let n=0;nr(stringToBytes(e),t);if(r([255,216,255]))return{ext:"jpg",mime:"image/jpeg"};if(r([137,80,78,71,13,10,26,10])){const e=33,r=t.findIndex((r,n)=>n>=e&&73===t[n]&&68===t[n+1]&&65===t[n+2]&&84===t[n+3]),n=t.subarray(e,r);return n.findIndex((e,t)=>97===n[t]&&99===n[t+1]&&84===n[t+2]&&76===n[t+3])>=0?{ext:"apng",mime:"image/apng"}:{ext:"png",mime:"image/png"}}if(r([71,73,70]))return{ext:"gif",mime:"image/gif"};if(r([87,69,66,80],{offset:8}))return{ext:"webp",mime:"image/webp"};if(r([70,76,73,70]))return{ext:"flif",mime:"image/flif"};if((r([73,73,42,0])||r([77,77,0,42]))&&r([67,82],{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(r([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(r([73,73,42,0])&&(r([16,251,134,1],{offset:4})||r([8,0,0,0,19,0],{offset:4})||r([8,0,0,0,18,0],{offset:4})))return{ext:"arw",mime:"image/x-sony-arw"};if(r([73,73,42,0,8,0,0,0])&&(r([45,0,254,0],{offset:8})||r([39,0,254,0],{offset:8})))return{ext:"dng",mime:"image/x-adobe-dng"};if(r([73,73,42,0])&&r([28,0,254,0],{offset:8}))return{ext:"nef",mime:"image/x-nikon-nef"};if(r([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(n("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(r([73,73,42,0])||r([77,77,0,42]))return{ext:"tif",mime:"image/tiff"};if(r([66,77]))return{ext:"bmp",mime:"image/bmp"};if(r([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(r([56,66,80,83]))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};const i=[80,75,3,4];if(r(i)){if(r([109,105,109,101,116,121,112,101,97,112,112,108,105,99,97,116,105,111,110,47,101,112,117,98,43,122,105,112],{offset:30}))return{ext:"epub",mime:"application/epub+zip"};if(r(xpiZipFilename,{offset:30}))return{ext:"xpi",mime:"application/x-xpinstall"};if(n("mimetypeapplication/vnd.oasis.opendocument.text",{offset:30}))return{ext:"odt",mime:"application/vnd.oasis.opendocument.text"};if(n("mimetypeapplication/vnd.oasis.opendocument.spreadsheet",{offset:30}))return{ext:"ods",mime:"application/vnd.oasis.opendocument.spreadsheet"};if(n("mimetypeapplication/vnd.oasis.opendocument.presentation",{offset:30}))return{ext:"odp",mime:"application/vnd.oasis.opendocument.presentation"};let e,a=0,s=!1;do{const o=a+30;if(s||(s=r(oxmlContentTypes,{offset:o})||r(oxmlRels,{offset:o})),e||(n("word/",{offset:o})?e={ext:"docx",mime:"application/vnd.openxmlformats-officedocument.wordprocessingml.document"}:n("ppt/",{offset:o})?e={ext:"pptx",mime:"application/vnd.openxmlformats-officedocument.presentationml.presentation"}:n("xl/",{offset:o})&&(e={ext:"xlsx",mime:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})),s&&e)return e;a=multiByteIndexOf(t,i,o)}while(a>=0);if(e)return e}if(r([80,75])&&(3===t[2]||5===t[2]||7===t[2])&&(4===t[3]||6===t[3]||8===t[3]))return{ext:"zip",mime:"application/zip"};if(r([48,48,48,48,48,48],{offset:148,mask:[248,248,248,248,248,248]})&&tarHeaderChecksumMatches(t))return{ext:"tar",mime:"application/x-tar"};if(r([82,97,114,33,26,7])&&(0===t[6]||1===t[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(r([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(r([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(r([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(r([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(r([102,114,101,101],{offset:4})||r([109,100,97,116],{offset:4})||r([109,111,111,118],{offset:4})||r([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(r([102,116,121,112],{offset:4})&&0!=(96&t[8])&&0!=(96&t[9])&&0!=(96&t[10])&&0!=(96&t[11])){const e=uint8ArrayUtf8ByteString(t,8,12);switch(e){case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt ":return{ext:"mov",mime:"video/quicktime"};case"M4V ":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P ":return{ext:"m4p",mime:"video/mp4"};case"M4B ":return{ext:"m4b",mime:"audio/mp4"};case"M4A ":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V ":return{ext:"f4v",mime:"video/mp4"};case"F4P ":return{ext:"f4p",mime:"video/mp4"};case"F4A ":return{ext:"f4a",mime:"audio/mp4"};case"F4B ":return{ext:"f4b",mime:"audio/mp4"};default:return e.startsWith("3g")?e.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(r([77,84,104,100]))return{ext:"mid",mime:"audio/midi"};if(r([26,69,223,163])){const e=t.subarray(4,4100),r=e.findIndex((e,t,r)=>66===r[t]&&130===r[t+1]);if(-1!==r){const t=r+3,n=r=>[...r].every((r,n)=>e[t+n]===r.charCodeAt(0));if(n("matroska"))return{ext:"mkv",mime:"video/x-matroska"};if(n("webm"))return{ext:"webm",mime:"video/webm"}}}if(r([82,73,70,70])){if(r([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(r([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/vnd.wave"};if(r([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(r([48,38,178,117,142,102,207,17,166,217])){let e=30;do{const n=readUInt64LE(t,e+16);if(r([145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101],{offset:e})){if(r([64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wma",mime:"audio/x-ms-wma"};if(r([192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43],{offset:e+24}))return{ext:"wmv",mime:"video/x-ms-asf"};break}e+=n}while(e+24<=t.length);return{ext:"asf",mime:"application/vnd.ms-asf"}}if(r([0,0,1,186])||r([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};for(let e=0;e<2&&enew Promise((resolve,reject)=>{const stream=eval("require")("stream");readableStream.on("error",reject),readableStream.once("readable",()=>{const e=new stream.PassThrough,t=readableStream.read(module.exports.minimumBytes)||readableStream.read();try{e.fileType=fileType(t)}catch(e){reject(e)}readableStream.unshift(t),stream.pipeline?resolve(stream.pipeline(readableStream,e,()=>{})):resolve(readableStream.pipe(e))})}),Object.defineProperty(fileType,"extensions",{get:()=>new Set(supported.extensions)}),Object.defineProperty(fileType,"mimeTypes",{get:()=>new Set(supported.mimeTypes)})}).call(this,__webpack_require__(3).Buffer)},function(e,t,r){e.exports=i;var n=r(27).EventEmitter;function i(){n.call(this)}r(16)(i,n),i.Readable=r(28),i.Writable=r(235),i.Duplex=r(236),i.Transform=r(237),i.PassThrough=r(238),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function a(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",a),e._isStdio||t&&!1===t.end||(r.on("end",o),r.on("close",c));var s=!1;function o(){s||(s=!0,e.end())}function c(){s||(s=!0,"function"==typeof e.destroy&&e.destroy())}function u(e){if(l(),0===n.listenerCount(this,"error"))throw e}function l(){r.removeListener("data",i),e.removeListener("drain",a),r.removeListener("end",o),r.removeListener("close",c),r.removeListener("error",u),e.removeListener("error",u),r.removeListener("end",l),r.removeListener("close",l),e.removeListener("close",l)}return r.on("error",u),e.on("error",u),r.on("end",l),r.on("close",l),e.on("close",l),e.emit("pipe",r),e}},function(e,t,r){"use strict";(function(t,n){var i=r(22);e.exports=w;var a,s=r(34);w.ReadableState=y;r(27).EventEmitter;var o=function(e,t){return e.listeners(t).length},c=r(38),u=r(29).Buffer,l=t.Uint8Array||function(){};var d=r(19);d.inherits=r(16);var f=r(227),p=void 0;p=f&&f.debuglog?f.debuglog("stream"):function(){};var h,m=r(228),g=r(39);d.inherits(w,c);var b=["error","close","destroy","pause","resume"];function y(e,t){e=e||{};var n=t instanceof(a=a||r(13));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,s=e.readableHighWaterMark,o=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(s||0===s)?s:o,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new m,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(h||(h=r(40).StringDecoder),this.decoder=new h(e.encoding),this.encoding=e.encoding)}function w(e){if(a=a||r(13),!(this instanceof w))return new w(e);this._readableState=new y(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),c.call(this)}function T(e,t,r,n,i){var a,s=e._readableState;null===t?(s.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,S(e)}(e,s)):(i||(a=function(e,t){var r;n=t,u.isBuffer(n)||n instanceof l||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(s,t)),a?e.emit("error",a):s.objectMode||t&&t.length>0?("string"==typeof t||s.objectMode||Object.getPrototypeOf(t)===u.prototype||(t=function(e){return u.from(e)}(t)),n?s.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):v(e,s,t,!0):s.ended?e.emit("error",new Error("stream.push() after EOF")):(s.reading=!1,s.decoder&&!r?(t=s.decoder.write(t),s.objectMode||0!==t.length?v(e,s,t,!1):E(e,s)):v(e,s,t,!1))):n||(s.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=I?e=I:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function S(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(C,e):C(e))}function C(e){p("emit readable"),e.emit("readable"),x(e)}function E(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(_,e,t))}function _(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;ea.length?a.length:e;if(s===a.length?i+=a:i+=a.slice(0,e),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=u.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var a=n.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),0===(e-=s)){s===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(s));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function B(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(M,t,e))}function M(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function D(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?B(this):S(this),null;if(0===(e=k(e,t))&&t.ended)return 0===t.length&&B(this),null;var n,i=t.needReadable;return p("need readable",i),(0===t.length||t.length-e0?P(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&B(this)),null!==n&&this.emit("data",n),n},w.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},w.prototype.pipe=function(e,t){var r=this,a=this._readableState;switch(a.pipesCount){case 0:a.pipes=e;break;case 1:a.pipes=[a.pipes,e];break;default:a.pipes.push(e)}a.pipesCount+=1,p("pipe count=%d opts=%j",a.pipesCount,t);var c=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?l:w;function u(t,n){p("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,p("cleanup"),e.removeListener("close",b),e.removeListener("finish",y),e.removeListener("drain",d),e.removeListener("error",g),e.removeListener("unpipe",u),r.removeListener("end",l),r.removeListener("end",w),r.removeListener("data",m),f=!0,!a.awaitDrain||e._writableState&&!e._writableState.needDrain||d())}function l(){p("onend"),e.end()}a.endEmitted?i.nextTick(c):r.once("end",c),e.on("unpipe",u);var d=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,x(e))}}(r);e.on("drain",d);var f=!1;var h=!1;function m(t){p("ondata"),h=!1,!1!==e.write(t)||h||((1===a.pipesCount&&a.pipes===e||a.pipesCount>1&&-1!==D(a.pipes,e))&&!f&&(p("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,h=!0),r.pause())}function g(t){p("onerror",t),w(),e.removeListener("error",g),0===o(e,"error")&&e.emit("error",t)}function b(){e.removeListener("finish",y),w()}function y(){p("onfinish"),e.removeListener("close",b),w()}function w(){p("unpipe"),r.unpipe(e)}return r.on("data",m),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",g),e.once("close",b),e.once("finish",y),e.emit("pipe",r),a.flowing||(p("pipe resume"),r.resume()),e},w.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r),this);if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var a=0;a>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function o(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function l(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function d(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function f(e){return e.toString(this.encoding)}function p(e){return e&&e.length?this.write(e):""}t.StringDecoder=a,a.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},a.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";e.exports=s;var n=r(13),i=r(19);function a(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(!n)return this.emit("error",new Error("write callback called multiple times"));r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length({packetType:e.readUInt8(t),vorbis:new n.StringType(6,"ascii").get(e,t+1)})},t.IdentificationHeader={len:23,get:(e,t)=>({version:e.readUInt32LE(t+0),channelMode:e.readUInt8(t+4),sampleRate:e.readUInt32LE(t+5),bitrateMax:e.readUInt32LE(t+9),bitrateNominal:e.readUInt32LE(t+13),bitrateMin:e.readUInt32LE(t+17)})}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5),a=r(2)("music-metadata:parser:MP4:atom");t.Header={len:8,get:(e,t)=>{const r=n.UINT32_BE.get(e,t);if(r<0)throw new Error("Invalid atom header length");return{length:r,name:i.FourCcToken.get(e,t+4)}},put:(e,t,r)=>(n.UINT32_BE.put(e,t,r.length),i.FourCcToken.put(e,t+4,r.name))},t.ExtendedSize=n.UINT64_BE,t.ftyp={len:4,get:(e,t)=>({type:new n.StringType(4,"ascii").get(e,t)})},t.mhdr={len:8,get:(e,t)=>({version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),nextItemID:n.UINT32_BE.get(e,t+4)})};class s{constructor(e,t,r){if(this.len=e,et&&a(`Warning: atom ${r} expected to be ${t}, but was actually ${e} bytes long.`)}}t.FixedLengthAtom=s;t.MdhdAtom=class extends s{constructor(e){super(e,24,"mdhd"),this.len=e}get(e,t){return{version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),timeScale:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+16),language:n.UINT16_BE.get(e,t+20),quality:n.UINT16_BE.get(e,t+22)}}};t.MvhdAtom=class extends s{constructor(e){super(e,100,"mvhd"),this.len=e}get(e,t){return{version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),timeScale:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+16),preferredRate:n.UINT32_BE.get(e,t+20),preferredVolume:n.UINT16_BE.get(e,t+24),previewTime:n.UINT32_BE.get(e,t+72),previewDuration:n.UINT32_BE.get(e,t+76),posterTime:n.UINT32_BE.get(e,t+80),selectionTime:n.UINT32_BE.get(e,t+84),selectionDuration:n.UINT32_BE.get(e,t+88),currentTime:n.UINT32_BE.get(e,t+92),nextTrackID:n.UINT32_BE.get(e,t+96)}}};t.DataAtom=class{constructor(e){this.len=e}get(e,t){return{type:{set:n.UINT8.get(e,t+0),type:n.UINT24_BE.get(e,t+1)},locale:n.UINT24_BE.get(e,t+4),value:new n.BufferType(this.len-8).get(e,t+8)}}};t.NameAtom=class{constructor(e){this.len=e}get(e,t){return{version:n.UINT8.get(e,t),flags:n.UINT24_BE.get(e,t+1),name:new n.StringType(this.len-4,"utf-8").get(e,t+4)}}};t.TrackHeaderAtom=class{constructor(e){this.len=e}get(e,t){return{version:n.UINT8.get(e,t),flags:n.UINT24_BE.get(e,t+1),creationTime:n.UINT32_BE.get(e,t+4),modificationTime:n.UINT32_BE.get(e,t+8),trackId:n.UINT32_BE.get(e,t+12),duration:n.UINT32_BE.get(e,t+20),layer:n.UINT16_BE.get(e,t+24),alternateGroup:n.UINT16_BE.get(e,t+26),volume:n.UINT16_BE.get(e,t+28)}}};const o={len:8,get:(e,t)=>({version:n.UINT8.get(e,t+0),flags:n.UINT24_BE.get(e,t+1),numberOfEntries:n.UINT32_BE.get(e,t+4)})};class c{constructor(e){this.len=e}get(e,t){return{dataFormat:i.FourCcToken.get(e,t),dataReferenceIndex:n.UINT16_BE.get(e,t+10),description:new n.BufferType(this.len-12).get(e,t+12)}}}t.StsdAtom=class{constructor(e){this.len=e}get(e,t){const r=o.get(e,t);t+=o.len;const i=[];for(let a=0;a({version:n.INT16_BE.get(e,t),revision:n.INT16_BE.get(e,t+2),vendor:n.INT32_BE.get(e,t+4)})},t.SoundSampleDescriptionV0={len:12,get:(e,t)=>({numAudioChannels:n.INT16_BE.get(e,t+0),sampleSize:n.INT16_BE.get(e,t+2),compressionId:n.INT16_BE.get(e,t+4),packetSize:n.INT16_BE.get(e,t+6),sampleRate:n.UINT16_BE.get(e,t+8)+n.UINT16_BE.get(e,t+10)/1e4})}},,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(189),i=r(192),a=r(270),s=r(271),o=n("music-metadata-browser:main");t.parseNodeStream=i.parseStream,t.parseReadableStream=async function(e,r,n){const i=new a.ReadableWeToNodeStream(e),s=await t.parseNodeStream(i,r,n);return o(`Completed parsing from stream bytesRead=${i.bytesRead} / fileSize=${n&&n.fileSize?n.fileSize:"?"}`),await i.close(),s},t.parseBuffer=i.parseBuffer,t.parseBlob=function(e,t){return function(e){return new Promise((t,r)=>{const n=new FileReader;n.onloadend=e=>{let r=e.target.result;r instanceof ArrayBuffer&&(r=s(new Uint8Array(e.target.result))),t(r)},n.onerror=e=>{r(new Error(e.type))},n.onabort=e=>{r(new Error(e.type))},n.readAsArrayBuffer(e)})}(e).then(r=>i.parseBuffer(r,e.type,t))},t.fetchFromUrl=async function(e,t){const r=await fetch(e),n=r.headers.get("Content-Type"),i=[];if(r.headers.forEach(e=>{i.push(e)}),r.ok){if(r.body){const e=await this.parseReadableStream(r.body,n,t);return o("Closing HTTP-readable-stream..."),r.body.locked||await r.body.cancel(),o("HTTP-readable-stream closed."),e}return this.parseBlob(await r.blob(),t)}throw new Error(`HTTP error status=${r.status}: ${r.statusText}`)},t.parseFromTokenizer=i.parseFromTokenizer,t.orderTags=i.orderTags,t.ratingToStars=i.ratingToStars},function(e,t,r){var i;(function(){var r=!1,a=function(e){return e instanceof a?e:this instanceof a?void(this.EXIFwrapped=e):new a(e)};e.exports&&(t=e.exports=a),t.EXIF=a;var s=a.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},o=a.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},c=a.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},u=a.IFD1Tags={256:"ImageWidth",257:"ImageHeight",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",273:"StripOffsets",274:"Orientation",277:"SamplesPerPixel",278:"RowsPerStrip",279:"StripByteCounts",282:"XResolution",283:"YResolution",284:"PlanarConfiguration",296:"ResolutionUnit",513:"JpegIFOffset",514:"JpegIFByteCount",529:"YCbCrCoefficients",530:"YCbCrSubSampling",531:"YCbCrPositioning",532:"ReferenceBlackWhite"},l=a.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}};function d(e){return!!e.exifdata}function f(e,t){function n(n){var i=p(n);e.exifdata=i||{};var s=function(e){var t=new DataView(e);r&&console.log("Got file of length "+e.byteLength);if(255!=t.getUint8(0)||216!=t.getUint8(1))return r&&console.log("Not a valid JPEG"),!1;var n=2,i=e.byteLength,a=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};for(;n")+8,l=(c=c.substring(c.indexOf("4?p:t+8,s=[],c=0;c4?p:t+8,f-1);case 3:if(1==f)return e.getUint16(t+8,!i);for(a=f>2?p:t+8,s=[],c=0;ce.byteLength)return{};var a=g(e,t,t+i,u,n);if(a.Compression)switch(a.Compression){case 6:if(a.JpegIFOffset&&a.JpegIFByteCount){var s=t+a.JpegIFOffset,o=a.JpegIFByteCount;a.blob=new Blob([new Uint8Array(e.buffer,s,o)],{type:"image/jpeg"})}break;case 1:console.log("Thumbnail image format is TIFF, which is not implemented.");break;default:console.log("Unknown thumbnail image format '%s'",a.Compression)}else 2==a.PhotometricInterpretation&&console.log("Thumbnail image format is RGB, which is not implemented.");return a}(e,p,h,n),i}function T(e){var t={};if(1==e.nodeType){if(e.attributes.length>0){t["@attributes"]={};for(var r=0;r0)for(var r=0;r{if(!t.isBuffer(e))return{};let i={},a=e.indexOf(n);for(;-1!==a;){let t=(a=e.indexOf(n,a+n.byteLength))+n.byteLength,s=t+1,o=s+2,c=e.readUInt8(t),u=e.readUInt16BE(s);if(!r.has(c))continue;if(u>e.length-(o+u))throw new Error("Invalid IPTC directory");let l=r.get(c),d=e.slice(o,o+u).toString();null==i[l]?i[l]=d:Array.isArray(i[l])?i[l].push(d):i[l]=[i[l],d]}return i}}).call(this,r(3).Buffer)},,,,,,,,,function(e,t,r){e.exports=r(186)},function(e,t,r){"use strict";r.r(t),function(e){var t=r(174),n=r(175),i=r.n(n),a=r(176),s=r.n(a);window.mediaCloudReaderCache={readers:[],getFreeReader:function(){return this.readers.length>0?(console.log("Got cached reader."),this.readers.splice(0,1)[0]):new FileReader},cacheReader:function(e){this.readers.push(e)}},window.DirectUploadItem=Backbone.Model.extend({initialize:function(e){this.on("change:progress",this.updateProgress,this)},updateProgress:function(){var e=this.get("attachment"),t=this.get("progress");e.set({percent:t})},startUpload:function(){if("uploadToStorage"in DirectUploadItem.prototype){var e=this.get("file"),t=this.get("faces"),r=this.get("mimeType");this.get("isDirectUpload")?(console.log("Uploading to Cloud Storage"),this.uploadToStorage(e,t,r,this)):this.uploadToWordPress(e,t,this)}else alert("Direct upload is misconfigured.")},uploadToWordPress:function(e,t,r){console.log("Uploading to WordPress");var n=new FormData;n.append("action",_wpPluploadSettings.defaults.multipart_params.action),n.append("_wpnonce",_wpPluploadSettings.defaults.multipart_params._wpnonce),n.append("name",e.name),n.append("async-upload",e),jQuery.ajax({url:_wpPluploadSettings.defaults.url,method:"POST",contentType:!1,processData:!1,data:n,dataType:"json",xhr:function(){var e=jQuery.ajaxSettings.xhr();return e.upload.onprogress=function(e){r.set({progress:e.loaded/e.total*100})}.bind(this),e},success:function(e){e.hasOwnProperty("success")&&e.success?r.wordpressUploadFinished(e,t):r.uploadError()},error:function(e){r.uploadError()}})},finishWordpressUpload:function(e){var t=this.get("attachment");_.each(["file","loaded","size","percent"],function(e){t.unset(e)}),t.set(_.extend(e.data,{uploading:!1})),wp.media.model.Attachment.get(e.data.id,t),this.set({state:"done"}),wp.Uploader.queue.remove(t),wp.Uploader.queue.all(function(e){return!e.get("uploading")})&&wp.Uploader.queue.reset()},wordpressUploadFinished:function(e,t){if(null!=t){var r={action:"ilab_add_face_data",post_id:e.data.id,faces:t};jQuery.post(ajaxurl,r,function(t){this.finishWordpressUpload(e)}.bind(this))}else this.finishWordpressUpload(e)},doUploadFinished:function(e,t,r){var n=this.get("attachment"),i={action:"ilab_upload_import_cloud_file",key:e};null!=r&&(i.metadata=r),console.log("Upload finished"),console.log(i),null!=t&&t.length>0&&(i.faces=t),jQuery.post(ajaxurl,i,function(e){_.each(["file","loaded","size","percent"],function(e){n.unset(e)}),"success"==e.status?(n.set(_.extend(e.attachment,{uploading:!1})),wp.media.model.Attachment.get(e.attachment.id,n),this.set({state:"done"})):this.set({state:"error"}),wp.Uploader.queue.remove(n),wp.Uploader.queue.all(function(e){return!e.get("uploading")})&&wp.Uploader.queue.reset()}.bind(this))},mapID3Meta:function(e,t,r,n){r.hasOwnProperty(e)&&(n[t]=r[e])},mapIndexedID3Meta:function(e,t,r,n){r.hasOwnProperty(e)&&r[e].length>0&&(n[t]=r[e][0])},assignAudioMetadata:function(e,t){if(this.mapID3Meta("album","album",e.common,t),this.mapID3Meta("artist","artist",e.common,t),this.mapIndexedID3Meta("genre","genre",e.common,t),this.mapID3Meta("title","title",e.common,t),e.common.hasOwnProperty("track")&&null!=e.common.track.no&&(t.track_number=e.common.track.no),this.mapID3Meta("year","year",e.common,t),this.mapIndexedID3Meta("composer","composer",e.common,t),this.mapIndexedID3Meta("lyricist","lyricist",e.common,t),this.mapIndexedID3Meta("writer","writer",e.common,t),this.mapIndexedID3Meta("conductor","conductor",e.common,t),this.mapIndexedID3Meta("remixer","remixer",e.common,t),this.mapIndexedID3Meta("arranger","arranger",e.common,t),this.mapIndexedID3Meta("engineer","engineer",e.common,t),this.mapIndexedID3Meta("producer","producer",e.common,t),this.mapIndexedID3Meta("djmixer","dj_mixer",e.common,t),this.mapIndexedID3Meta("mixer","mixer",e.common,t),this.mapIndexedID3Meta("technician","technician",e.common,t),this.mapIndexedID3Meta("label","label",e.common,t),this.mapIndexedID3Meta("subtitle","subtitle",e.common,t),this.mapIndexedID3Meta("compilation","compilation",e.common,t),this.mapID3Meta("bpm","bpm",e.common,t),this.mapID3Meta("mood","mood",e.common,t),this.mapID3Meta("media","media",e.common,t),this.mapID3Meta("tvShow","tv_show",e.common,t),this.mapID3Meta("tvSeason","tv_season",e.common,t),this.mapID3Meta("tvEpisode","tv_episode",e.common,t),this.mapID3Meta("tvNetwork","tv_network",e.common,t),this.mapID3Meta("podcast","podcast",e.common,t),this.mapID3Meta("podcasturl","podcast_url",e.common,t),this.mapID3Meta("releasestatus","release_status",e.common,t),this.mapID3Meta("releasetype","release_type",e.common,t),this.mapID3Meta("releasecountry","release_country",e.common,t),this.mapID3Meta("language","language",e.common,t),this.mapID3Meta("copyright","copyright",e.common,t),this.mapID3Meta("license","license",e.common,t),this.mapID3Meta("encodedby","encoded_by",e.common,t),this.mapID3Meta("encodersettings","encoder_options",e.common,t),this.mapID3Meta("gapless","gapless",e.common,t),this.mapID3Meta("barcode","barcode",e.common,t),this.mapID3Meta("asin","asin",e.common,t),this.mapID3Meta("website","website",e.common,t),this.mapID3Meta("averageLevel","average_level",e.common,t),this.mapID3Meta("peakLevel","peak_level",e.common,t),this.mapID3Meta("bitrate","bitrate",e.format,t),this.mapID3Meta("codec","dataformat",e.format,t),this.mapID3Meta("codecProfile","bitrate_mode",e.format,t),this.mapID3Meta("lossless","lossless",e.format,t),this.mapID3Meta("numberOfChannels","channels",e.format,t),this.mapID3Meta("duration","length",e.format,t),this.mapID3Meta("sampleRate","sample_rate",e.format,t),e.common.hasOwnProperty("picture")&&e.common.picture.length>0){var r=e.common.picture[0];t.thumbnail={mimeType:r.format,data:r.data.toString("base64")},t.image=[{mime:r.format}]}},mapImageMeta:function(e,t,r,n,i){if(t.hasOwnProperty(r)){var a=t[r];if("string"==e){if(!(o="string"==typeof a||a instanceof String))return;n[i]=a.trim()}else if("strings"==e){if(o="string"==typeof a||a instanceof String){a=a.split(",");for(var s=0;s0&&(n[i]=a)}else if("date"==e){var o;if(!(o="string"==typeof a||a instanceof String))return;var c=a.split(" ");if(2!=c.length)return;var u=c[0].split(":");if(3!=u.length)return;var l=u[0],d=u[1],f=u[2],p=new Date("".concat(d,"/").concat(f,"/").concat(l," ").concat(c[1]));n[i]=(p.getTime()/1e3).toFixed(0)}else if("frac"==e){if(o)return;if(!("number"==typeof a||a instanceof Number))return;n[i]=a.numerator/a.denominator}else if("number"==e){if(o)return;if(!("number"==typeof a||a instanceof Number))return;n[i]=a}}},assignImageMetadata:function(e,t,r){console.log(e),console.log(t);var n={};this.mapImageMeta("string",e,"headline",n,"title"),this.mapImageMeta("string",e,"caption",n,"caption"),this.mapImageMeta("string",e,"credit",n,"credit"),this.mapImageMeta("string",e,"copyright",n,"copyright"),this.mapImageMeta("strings",e,"keywords",n,"keywords"),0!=t&&(this.mapImageMeta("string",t,"ImageDescription",n,"title"),n.hasOwnProperty("caption")||this.mapImageMeta("bytes",t,"UserComment",n,"caption"),n.hasOwnProperty("copyright")||this.mapImageMeta("bytes",t,"Copyright",n,"copyright"),this.mapImageMeta("string",t,"Artist",n,"credit"),n.hasOwnProperty("credit")||this.mapImageMeta("string",t,"Author",n,"credit"),this.mapImageMeta("string",t,"Copyright",n,"copyright"),this.mapImageMeta("string",t,"Model",n,"camera"),this.mapImageMeta("string",t,"ISOSpeedRatings",n,"iso"),this.mapImageMeta("number",t,"ISOSpeedRatings",n,"iso"),this.mapImageMeta("date",t,"DateTimeDigitized",n,"created_timestamp"),this.mapImageMeta("frac",t,"FocalLength",n,"focal_length"),this.mapImageMeta("frac",t,"FNumber",n,"aperture"),this.mapImageMeta("frac",t,"ExposureTime",n,"shutter_speed"),this.mapImageMeta("number",t,"Orientation",n,"orientation")),r.image_meta=n},uploadFinished:function(r,n){var a=this.get("attachment").get("file"),o={filesize:a.size},c=this.get("mimeType");if(0===c.indexOf("audio/")){var u=c.split("/")[1];o.fileformat=u,t.parseBlob(a,{duration:!0}).then(function(e){this.assignAudioMetadata(e,o),this.doUploadFinished(r,n,o)}.bind(this)).catch(function(e){this.doUploadFinished(r,n,o)}.bind(this))}else if(0==c.indexOf("image/")){var l=mediaCloudReaderCache.getFreeReader();l.onload=function(t){var a={};try{a=s()(e.from(l.result))}catch(e){console.log("IPTC Error",e)}var c=i.a.readFromBinaryFile(l.result);this.assignImageMetadata(a,c,o),mediaCloudReaderCache.cacheReader(l),this.doUploadFinished(r,n,o)}.bind(this),l.onerror=function(e){mediaCloudReaderCache.cacheReader(l),this.doUploadFinished(r,n,o)}.bind(this),l.readAsArrayBuffer(a)}else this.doUploadFinished(r,n,o)},uploadError:function(){this.set({state:"error"});var e=this.get("attachment");_.each(["file","loaded","size","percent"],function(t){e.unset(t)}),wp.Uploader.queue.remove(e),e.destroy()}}),window.DirectUploader=Backbone.Model.extend({initialize:function(e){this.totalFilesDropped=0,this.totalFilesUploaded=0,this.files=[],this.toBulkProcess=[],this.uploadingFiles=[],this.watchToken=0,this.settings=mediaCloudDirectUploadSettings},queueNext:function(){if(clearTimeout(this.watchToken),this.uploadingFiles.length0){for(var e=this.settings.maxUploads-this.uploadingFiles.length,t=0;t0){var r=this.files.shift();this.uploadingFiles.push(r),r.startUpload()}}else if(0==this.uploadingFiles.length&&this.toBulkProcess.length>0&&this.totalFilesDropped==this.totalFilesUploaded){var n={action:"ilab_upload_process_batch",batch:this.toBulkProcess};this.toBulkProcess=[],this.totalFilesDropped=0,this.totalFilesUploaded=0,jQuery.post(ajaxurl,n,function(e){})}this.watchToken=setTimeout(this.queueNext.bind(this),500)},addFile:function(e){if(console.log("Adding File"),""==e.type)return!1;var t=e.type;"application/x-photoshop"==t&&(t="image/psd");var r=-1!=this.settings.allowedMimes.indexOf(t);console.log("Is Direct Upload?",r);var n=t.split("/"),i=n[0],a=n[1];a="jpg"==a?"jpeg":a,this.totalFilesDropped++;var s={file:e,uploading:!0,date:new Date,filename:e.name,isDirectUpload:r,menuOrder:0,uploadedTo:wp.media.model.settings.post.id,loaded:0,size:e.size,percent:0,type:i,subType:a},o=wp.media.model.Attachment.create(s);wp.Uploader.queue.add(o);var c=new DirectUploadItem({attachment:o,file:e,mimeType:t,isDirectUpload:r,progress:0,driver:this.settings.driver,faces:null,state:"waiting"});c.on("change:state",function(e,t){if("done"==t||"error"==t){this.totalFilesUploaded++,"done"==t&&this.toBulkProcess.push(o.id);var r=this.files.indexOf(c);r>-1&&this.files.splice(r),(r=this.uploadingFiles.indexOf(c))>-1&&this.uploadingFiles.splice(r),this.queueNext()}}.bind(this)),"undefined"!=typeof ILABFaceDetector?ILABFaceDetector(e,function(e){c.set("faces",e),this.files.push(c)}.bind(this)):this.files.push(c)}}),wp.media.view.UploaderWindow.prototype.__ready=wp.media.view.UploaderWindow.prototype.ready,wp.media.view.UploaderWindow.prototype.ready=function(){this.__ready(),this.directUploader=new DirectUploader({}),this.uploader.uploader.unbind("FilesAdded"),this.uploader.uploader.bind("FilesAdded",function(e,t){_.each(t,function(e){this.directUploader.addFile(e.getNative())}.bind(this)),this.directUploader.queueNext()}.bind(this))},wp.media.view.UploaderInline=wp.media.view.UploaderInline.extend({template:wp.template("media-cloud-direct-upload")})}.call(this,r(3).Buffer)},function(e,t,r){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){for(var t,r=u(e),n=r[0],s=r[1],o=new a(function(e,t,r){return 3*(t+r)/4-r}(0,n,s)),c=0,l=s>0?n-4:n,d=0;d>16&255,o[c++]=t>>8&255,o[c++]=255&t;2===s&&(t=i[e.charCodeAt(d)]<<2|i[e.charCodeAt(d+1)]>>4,o[c++]=255&t);1===s&&(t=i[e.charCodeAt(d)]<<10|i[e.charCodeAt(d+1)]<<4|i[e.charCodeAt(d+2)]>>2,o[c++]=t>>8&255,o[c++]=255&t);return o},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,a=[],s=0,o=r-i;so?o:s+16383));1===i?(t=e[r-1],a.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],a.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return a.join("")};for(var n=[],i=[],a="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,c=s.length;o0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function l(e,t,r){for(var i,a,s=[],o=t;o>18&63]+n[a>>12&63]+n[a>>6&63]+n[63&a]);return s.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){t.read=function(e,t,r,n,i){var a,s,o=8*i-n-1,c=(1<>1,l=-7,d=r?i-1:0,f=r?-1:1,p=e[t+d];for(d+=f,a=p&(1<<-l)-1,p>>=-l,l+=o;l>0;a=256*a+e[t+d],d+=f,l-=8);for(s=a&(1<<-l)-1,a>>=-l,l+=n;l>0;s=256*s+e[t+d],d+=f,l-=8);if(0===a)a=1-u;else{if(a===c)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),a-=u}return(p?-1:1)*s*Math.pow(2,a-n)},t.write=function(e,t,r,n,i,a){var s,o,c,u=8*a-i-1,l=(1<>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:a-1,h=n?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=l):(s=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-s))<1&&(s--,c*=2),(t+=s+d>=1?f/c:f*Math.pow(2,1-d))*c>=2&&(s++,c/=2),s+d>=l?(o=0,s=l):s+d>=1?(o=(t*c-1)*Math.pow(2,i),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+p]=255&o,p+=h,o/=256,i-=8);for(s=s<0;e[r+p]=255&s,p+=h,s/=256,u-=8);e[r+p-h]|=128*m}},function(e,t,r){(function(n){t.log=function(...e){return"object"==typeof console&&console.log&&console.log(...e)},t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const r="color: "+this.color;t.splice(1,0,r,"color: inherit");let n=0,i=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(190)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){e.exports=function(e){function t(e){let t=0;for(let r=0;r{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(21),i=r(204);function a(e,t,r){return!e.fileSize&&r.fileSize&&(e.fileSize=r.fileSize),i.ParserFactory.parse(e,t,r)}t.parseStream=function(e,t,r={}){return a(n.fromStream(e),t,r)},t.parseBuffer=function(e,t,r={}){return a(n.fromBuffer(e),t,r)},t.parseFromTokenizer=a,t.orderTags=function(e){const t={};for(const r of e)(t[r.id]=t[r.id]||[]).push(r.value);return t},t.ratingToStars=function(e){return void 0===e?0:1+Math.round(4*e)}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(194),i=r(10),a=r(195),s=r(200)("strtok3:ReadStreamTokenizer");t.ReadStreamTokenizer=class extends n.AbstractTokenizer{constructor(e,t){super(),this.streamReader=new a.StreamReader(e),this.fileSize=t}async readBuffer(e,t=0,r=e.length,n){if(0===r)return 0;if(n){const i=n-this.position;if(i>0)return await this.ignore(n-this.position),this.readBuffer(e,t,r);if(i<0)throw new Error("Cannot read from a negative offset in a stream")}let s;try{s=await this.streamReader.read(e,t,r),this.position+=s}catch(e){throw e.message===a.endOfStream?new Error(i.endOfFile):e}if(s0){const a=e.alloc(n+i);return c=await this.peekBuffer(a,0,i+n,void 0,o),a.copy(t,r,i),c-i}if(i<0)throw new Error("Cannot peek from a negative offset in a stream")}try{c=await this.streamReader.peek(t,r,n)}catch(e){throw e.message===a.endOfStream?new Error(i.endOfFile):e}if(!o&&c{this.reject=t,this.resolve=e})}}t.endOfStream="End-Of-Stream";t.StreamReader=class{constructor(e){if(this.s=e,this.endOfStream=!1,this.peekQueue=[],!e.read||!e.once)throw new Error("Expected an instance of stream.Readable");this.s.once("end",()=>this.reject(new Error(t.endOfStream))),this.s.once("error",e=>this.reject(e)),this.s.once("close",()=>this.reject(new Error("Stream closed")))}async peek(e,t,r){const n=await this.read(e,t,r);return this.peekQueue.push(e.slice(t,t+n)),n}async read(e,r,n){if(0===n)return 0;if(0===this.peekQueue.length&&this.endOfStream)throw new Error(t.endOfStream);let i=n,a=0;for(;this.peekQueue.length>0&&i>0;){const t=this.peekQueue.pop(),n=Math.min(t.length,i);t.copy(e,r+a,0,n),a+=n,i-=n,n0&&!this.endOfStream&&(a+=await this._read(e,r+a,i)),a}async _read(e,t,r){n.ok(!this.request,"Concurrent read operation?");const a=this.s.read(r);return a?(a.copy(e,t),a.length):(this.request={buffer:e,offset:t,length:r,deferred:new i},this.s.once("readable",()=>{this.tryRead()}),this.request.deferred.promise.then(e=>(this.request=null,e)).catch(e=>{throw this.request=null,e}))}tryRead(){const e=this.s.read(this.request.length);e?(e.copy(this.request.buffer,this.request.offset),this.request.deferred.resolve(e.length)):this.s.once("readable",()=>{this.tryRead()})}reject(e){this.endOfStream=!0,this.request&&(this.request.deferred.reject(e),this.request=null)}}},function(e,t,r){"use strict";var n=Object.getOwnPropertySymbols,i=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;function s(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map(function(e){return t[e]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(e){n[e]=e}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,t){for(var r,o,c=s(e),u=1;u=a)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}}),c=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),h(r)?n.showHidden=r:r&&t._extend(n,r),y(n.showHidden)&&(n.showHidden=!1),y(n.depth)&&(n.depth=2),y(n.colors)&&(n.colors=!1),y(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=c),l(n,e,n.depth)}function c(e,t){var r=o.styles[t];return r?"["+o.colors[r][0]+"m"+e+"["+o.colors[r][1]+"m":e}function u(e,t){return e}function l(e,r,n){if(e.customInspect&&r&&k(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return b(i)||(i=l(e,i,n)),i}var a=function(e,t){if(y(t))return e.stylize("undefined","undefined");if(b(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(g(t))return e.stylize(""+t,"number");if(h(t))return e.stylize(""+t,"boolean");if(m(t))return e.stylize("null","null")}(e,r);if(a)return a;var s=Object.keys(r),o=function(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(r)),I(r)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(r);if(0===s.length){if(k(r)){var c=r.name?": "+r.name:"";return e.stylize("[Function"+c+"]","special")}if(w(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(v(r))return e.stylize(Date.prototype.toString.call(r),"date");if(I(r))return d(r)}var u,T="",S=!1,C=["{","}"];(p(r)&&(S=!0,C=["[","]"]),k(r))&&(T=" [Function"+(r.name?": "+r.name:"")+"]");return w(r)&&(T=" "+RegExp.prototype.toString.call(r)),v(r)&&(T=" "+Date.prototype.toUTCString.call(r)),I(r)&&(T=" "+d(r)),0!==s.length||S&&0!=r.length?n<0?w(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),u=S?function(e,t,r,n,i){for(var a=[],s=0,o=t.length;s=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(u,T,C)):C[0]+T+C[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function f(e,t,r,n,i,a){var s,o,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?o=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(o=e.stylize("[Setter]","special")),F(n,i)||(s="["+i+"]"),o||(e.seen.indexOf(c.value)<0?(o=m(r)?l(e,c.value,null):l(e,c.value,r-1)).indexOf("\n")>-1&&(o=a?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),y(s)){if(a&&i.match(/^\d+$/))return o;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+o}function p(e){return Array.isArray(e)}function h(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function b(e){return"string"==typeof e}function y(e){return void 0===e}function w(e){return T(e)&&"[object RegExp]"===S(e)}function T(e){return"object"==typeof e&&null!==e}function v(e){return T(e)&&"[object Date]"===S(e)}function I(e){return T(e)&&("[object Error]"===S(e)||e instanceof Error)}function k(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function C(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(y(a)&&(a=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!s[r])if(new RegExp("\\b"+r+"\\b","i").test(a)){var n=e.pid;s[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else s[r]=function(){};return s[r]},t.inspect=o,o.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},o.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=h,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=b,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=y,t.isRegExp=w,t.isObject=T,t.isDate=v,t.isError=I,t.isFunction=k,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(198);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function _(){var e=new Date,t=[C(e.getHours()),C(e.getMinutes()),C(e.getSeconds())].join(":");return[e.getDate(),E[e.getMonth()],t].join(" ")}function F(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",_(),t.format.apply(t,arguments))},t.inherits=r(199),t._extend=function(e,t){if(!t||!T(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var A="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function x(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(A&&e[A]){var t;if("function"!=typeof(t=e[A]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,A,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise(function(e,n){t=e,r=n}),i=[],a=0;a{"%%"!==e&&(n++,"%c"===e&&(i=n))}),t.splice(i,0,r)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG);return e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],e.exports=r(201)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,r(9))},function(e,t,r){e.exports=function(e){function t(e){let t=0;for(let r=0;r{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10);t.BufferTokenizer=class{constructor(e){this.buffer=e,this.position=0,this.fileSize=e.length}async readBuffer(e,t,r,n){return this.position=n||this.position,this.peekBuffer(e,t,r,this.position).then(e=>(this.position+=e,e))}async peekBuffer(e,t,r,i,a=!1){i=i||this.position,r||(r=e.length);const s=Math.min(this.buffer.length-i,r);if(!a&&s[...e].map(e=>e.charCodeAt(0));const r=(e,t,r)=>String.fromCharCode(...e.slice(t,r));t.readUInt64LE=(e,t=0)=>{let r=e[t],n=1,i=0;for(;++i<8;)n*=256,r+=e[t+i]*n;return r},t.tarHeaderChecksumMatches=e=>{if(e.length<512)return!1;let t=256,n=0;for(let r=0;r<148;r++){const i=e[r];t+=i,n+=128&i}for(let r=156;r<512;r++){const i=e[r];t+=i,n+=128&i}const i=parseInt(r(e,148,154),8);return i===t||i===t-(n<<1)},t.multiByteIndexOf=(t,r,n=0)=>{if(e&&e.isBuffer(t))return t.indexOf(e.from(r),n);const i=(e,t,r)=>{for(let n=1;n=0;){if(i(t,r,a))return a;a=t.indexOf(r[0],a+1)}return-1},t.uint8ArrayUtf8ByteString=r}).call(this,r(3).Buffer)},function(e,t,r){"use strict";e.exports={extensions:["jpg","png","apng","gif","webp","flif","cr2","orf","arw","dng","nef","rw2","raf","tif","bmp","jxr","psd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","wmv","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","msi","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","wmv","wma","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a"],mimeTypes:["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-canon-cr2","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/epub+zip","application/x-xpinstall","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","video/mp4","audio/midi","video/x-matroska","video/webm","video/quicktime","video/vnd.avi","audio/vnd.wave","audio/qcelp","audio/x-ms-wma","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","audio/opus","video/ogg","audio/ogg","application/ogg","audio/x-flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","image/x-icon","video/x-flv","application/postscript","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-msi","application/mxf","video/mp2t","application/x-blender","image/bpg","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/ktx","application/dicom","audio/x-musepack","text/calendar","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a"]}},function(e,t,r){"use strict";var n=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,i=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,a=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,s=/\\([\u000b\u0020-\u00ff])/g,o=/([\\"])/g,c=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function u(e){var t=String(e);if(a.test(t))return t;if(t.length>0&&!i.test(t))throw new TypeError("invalid parameter value");return'"'+t.replace(o,"\\$1")+'"'}function l(e){this.parameters=Object.create(null),this.type=e}t.format=function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,r=e.type;if(!r||!c.test(r))throw new TypeError("invalid type");var n=r;if(t&&"object"==typeof t)for(var i,s=Object.keys(t).sort(),o=0;o{if("%%"===r)return r;o++;const a=n.formatters[i];if("function"==typeof a){const n=e[o];r=a.call(t,n),e.splice(o,1),o--}return r}),n.formatArgs.call(t,e),(t.log||n.log).apply(t,e)}return s.namespace=e,s.enabled=n.enabled(e),s.useColors=n.useColors(),s.color=t(e),s.destroy=i,s.extend=a,"function"==typeof n.init&&n.init(s),n.instances.push(s),s}function i(){const e=n.instances.indexOf(this);return-1!==e&&(n.instances.splice(e,1),!0)}function a(e,t){const r=n(this.namespace+(void 0===t?":":t)+e);return r.log=this.log,r}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return n.debug=n,n.default=n,n.coerce=function(e){return e instanceof Error?e.stack||e.message:e},n.disable=function(){const e=[...n.names.map(s),...n.skips.map(s).map(e=>"-"+e)].join(",");return n.enable(""),e},n.enable=function(e){let t;n.save(e),n.names=[],n.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(t=0;t{n[t]=e[t]}),n.instances=[],n.names=[],n.skips=[],n.formatters={},n.selectColor=t,n.enable(n.load()),n}},function(e,t){var r=1e3,n=60*r,i=60*n,a=24*i,s=7*a,o=365.25*a;function c(e,t,r,n){var i=t>=1.5*r;return Math.round(e/r)+" "+n+(i?"s":"")}e.exports=function(e,t){t=t||{};var u=typeof e;if("string"===u&&e.length>0)return function(e){if((e=String(e)).length>100)return;var t=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!t)return;var c=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*o;case"weeks":case"week":case"w":return c*s;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*i;case"minutes":case"minute":case"mins":case"min":case"m":return c*n;case"seconds":case"second":case"secs":case"sec":case"s":return c*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===u&&isFinite(e))return t.long?function(e){var t=Math.abs(e);if(t>=a)return c(e,t,a,"day");if(t>=i)return c(e,t,i,"hour");if(t>=n)return c(e,t,n,"minute");if(t>=r)return c(e,t,r,"second");return e+" ms"}(e):function(e){var t=Math.abs(e);if(t>=a)return Math.round(e/a)+"d";if(t>=i)return Math.round(e/i)+"h";if(t>=n)return Math.round(e/n)+"m";if(t>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(212),a=r(213),s=r(8),o=r(4),c=n("music-metadata:collector"),u=["APEv2","vorbis","ID3v2.4","ID3v2.3","ID3v2.2","exif","asf","iTunes","ID3v1"];function l(e){return e.length>2?e.slice(0,e.length-1).join(", ")+" & "+e[e.length-1]:e.join(" & ")}t.MetadataCollector=class{constructor(e){this.opts=e,this.format={tagTypes:[]},this.native={},this.common={track:{no:null,of:null},disk:{no:null,of:null}},this.commonOrigin={},this.originPriority={},this.tagMapper=new a.CombinedTagMapper;let t=1;for(const e of u)this.originPriority[e]=t++;this.originPriority.artificial=500,this.originPriority.id3v1=600}hasAny(){for(const e in this.native)return!0;return!1}setFormat(e,t){c(`format: ${e} = ${t}`),this.format[e]=t,this.opts.observer&&this.opts.observer({metadata:this,tag:{type:"format",id:e,value:t}})}addTag(e,t,r){c(`tag ${e}.${t} = ${r}`),this.native[e]||(this.format.tagTypes.push(e),this.native[e]=[]),this.native[e].push({id:t,value:r}),this.toCommon(e,t,r)}getNativeMetadata(){return{format:this.format,native:this.native}}postMap(e,t){switch(t.id){case"artist":if(this.commonOrigin.artist===this.originPriority[e])return this.postMap("artificial",{id:"artists",value:t.value});this.common.artists||this.setGenericTag("artificial",{id:"artists",value:t.value});break;case"artists":if(!(this.common.artist&&this.commonOrigin.artist!==this.originPriority.artificial||this.common.artists&&-1!==this.common.artists.indexOf(t.value))){const e={id:"artist",value:l((this.common.artists||[]).concat([t.value]))};this.setGenericTag("artificial",e)}break;case"genre":t.value=s.CommonTagMapper.parseGenre(t.value);break;case"picture":t.value.format=s.CommonTagMapper.fixPictureMimeType(t.value.format);break;case"totaltracks":return void(this.common.track.of=s.CommonTagMapper.toIntOrNull(t.value));case"totaldiscs":return void(this.common.disk.of=s.CommonTagMapper.toIntOrNull(t.value));case"track":case"disk":const r=this.common[t.id].of;return this.common[t.id]=s.CommonTagMapper.normalizeTrack(t.value),void(this.common[t.id].of=null!=r?r:this.common[t.id].of);case"year":case"originalyear":t.value=parseInt(t.value,10);break;case"date":const n=parseInt(t.value.substr(0,4),10);n&&!isNaN(n)&&(this.common.year=n);break;case"discogs_label_id":case"discogs_release_id":case"discogs_master_release_id":case"discogs_artist_id":case"discogs_votes":t.value="string"==typeof t.value?parseInt(t.value,10):t.value;break;case"replaygain_track_gain":case"replaygain_track_peak":t.value=o.toRatio(t.value);break;case"gapless":t.value="1"===t.value}this.setGenericTag(e,t)}toCommonMetadata(){return{format:this.format,native:this.opts.native?this.native:void 0,common:this.common}}toCommon(e,t,r){const n={id:t,value:r},i=this.tagMapper.mapTag(e,n);i&&this.postMap(e,i)}setGenericTag(e,t){c(`common.${t.id} = ${t.value}`);const r=this.commonOrigin[t.id]||1e3,n=this.originPriority[e];if(i.isSingleton(t.id)){if(!(n<=r))return c(`Ignore native tag (singleton): ${e}.${t.id} = ${t.value}`);this.common[t.id]=t.value,this.commonOrigin[t.id]=n}else if(n===r)i.isUnique(t.id)&&-1!==this.common[t.id].indexOf(t.value)?c(`Ignore duplicate value: ${e}.${t.id} = ${t.value}`):this.common[t.id].push(t.value);else{if(!(n{this.registerTagMapper(e)})}mapTag(e,t){if(this.tagMappers[e])return this.tagMappers[e].mapGenericTag(t);throw new Error("No generic tag mapper defined for tag-format: "+e)}registerTagMapper(e){for(const t of e.tagTypes)this.tagMappers[t]=e}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={title:"title",artist:"artist",album:"album",year:"year",comment:"comment",track:"track",genre:"genre"};t.ID3v1TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v1"],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});class n{static decode(e){let t="";for(const r in e)e.hasOwnProperty(r)&&(t+=n.codePointToString(n.singleByteDecoder(e[r])));return t}static inRange(e,t,r){return t<=e&&e<=r}static codePointToString(e){return e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode(55296+(e>>10),56320+(1023&e)))}static singleByteDecoder(e){if(n.inRange(e,0,127))return e;const t=n.windows1252[e-128];if(null===t)throw Error("invaliding encoding");return t}}n.windows1252=[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],t.Windows1292Decoder=n},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i=r(4),a={TIT2:"title",TPE1:"artist","TXXX:Artists":"artists",TPE2:"albumartist",TALB:"album",TDRV:"date",TORY:"originalyear",TPOS:"disk",TCON:"genre",APIC:"picture",TCOM:"composer","USLT:description":"lyrics",TSOA:"albumsort",TSOT:"titlesort",TOAL:"originalalbum",TSOP:"artistsort",TSO2:"albumartistsort",TSOC:"composersort",TEXT:"lyricist","TXXX:Writer":"writer",TPE3:"conductor",TPE4:"remixer","IPLS:arranger":"arranger","IPLS:engineer":"engineer","IPLS:producer":"producer","IPLS:DJ-mix":"djmixer","IPLS:mix":"mixer",TPUB:"label",TIT1:"grouping",TIT3:"subtitle",TRCK:"track",TCMP:"compilation",POPM:"rating",TBPM:"bpm",TMED:"media","TXXX:CATALOGNUMBER":"catalognumber","TXXX:MusicBrainz Album Status":"releasestatus","TXXX:MusicBrainz Album Type":"releasetype","TXXX:MusicBrainz Album Release Country":"releasecountry","TXXX:RELEASECOUNTRY":"releasecountry","TXXX:SCRIPT":"script",TLAN:"language",TCOP:"copyright",WCOP:"license",TENC:"encodedby",TSSE:"encodersettings","TXXX:BARCODE":"barcode",TSRC:"isrc","TXXX:ASIN":"asin","TXXX:originalyear":"originalyear","UFID:http://musicbrainz.org":"musicbrainz_recordingid","TXXX:MusicBrainz Release Track Id":"musicbrainz_trackid","TXXX:MusicBrainz Album Id":"musicbrainz_albumid","TXXX:MusicBrainz Artist Id":"musicbrainz_artistid","TXXX:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","TXXX:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","TXXX:MusicBrainz Work Id":"musicbrainz_workid","TXXX:MusicBrainz TRM Id":"musicbrainz_trmid","TXXX:MusicBrainz Disc Id":"musicbrainz_discid","TXXX:ACOUSTID_ID":"acoustid_id","TXXX:Acoustid Id":"acoustid_id","TXXX:Acoustid Fingerprint":"acoustid_fingerprint","TXXX:MusicIP PUID":"musicip_puid","TXXX:MusicMagic Fingerprint":"musicip_fingerprint",WOAR:"website",TDRC:"date",TYER:"year",TDOR:"originaldate","TIPL:arranger":"arranger","TIPL:engineer":"engineer","TIPL:producer":"producer","TIPL:DJ-mix":"djmixer","TIPL:mix":"mixer",TMOO:"mood",SYLT:"lyrics",TSST:"discsubtitle",TKEY:"key",COMM:"comment",TOPE:"originalartist","PRIV:AverageLevel":"averageLevel","PRIV:PeakLevel":"peakLevel","TXXX:DISCOGS_ARTIST_ID":"discogs_artist_id","TXXX:DISCOGS_ARTISTS":"artists","TXXX:DISCOGS_ARTIST_NAME":"artists","TXXX:DISCOGS_ALBUM_ARTISTS":"albumartist","TXXX:DISCOGS_CATALOG":"catalognumber","TXXX:DISCOGS_COUNTRY":"releasecountry","TXXX:DISCOGS_DATE":"originaldate","TXXX:DISCOGS_LABEL":"label","TXXX:DISCOGS_LABEL_ID":"discogs_label_id","TXXX:DISCOGS_MASTER_RELEASE_ID":"discogs_master_release_id","TXXX:DISCOGS_RATING":"discogs_rating","TXXX:DISCOGS_RELEASED":"date","TXXX:DISCOGS_RELEASE_ID":"discogs_release_id","TXXX:DISCOGS_VOTES":"discogs_votes","TXXX:CATALOGID":"catalognumber","TXXX:STYLE":"genre","TXXX:replaygain_track_peak":"replaygain_track_peak","TXXX:replaygain_track_gain":"replaygain_track_gain"};class s extends n.CommonTagMapper{static toRating(e){return{source:e.email,rating:e.rating>0?(e.rating-1)/254*n.CommonTagMapper.maxRatingScore:void 0}}constructor(){super(["ID3v2.3","ID3v2.4"],a)}postMap(e){switch(e.id){case"UFID":"http://musicbrainz.org"===e.value.owner_identifier&&(e.id+=":"+e.value.owner_identifier,e.value=i.default.decodeString(e.value.identifier,"iso-8859-1"));break;case"PRIV":switch(e.value.owner_identifier){case"AverageLevel":case"PeakValue":e.id+=":"+e.value.owner_identifier,e.value=4===e.value.data.length?e.value.data.readUInt32LE(0):null}break;case"COMM":e.value=e.value?e.value.text:null;break;case"POPM":e.value=s.toRating(e.value)}}}t.ID3v24TagMapper=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Author:"artist","WM/AlbumArtist":"albumartist","WM/AlbumTitle":"album","WM/Year":"date","WM/OriginalReleaseTime":"originaldate","WM/OriginalReleaseYear":"originalyear",Description:"comment","WM/TrackNumber":"track","WM/PartOfSet":"disk","WM/Genre":"genre","WM/Composer":"composer","WM/Lyrics":"lyrics","WM/AlbumSortOrder":"albumsort","WM/TitleSortOrder":"titlesort","WM/ArtistSortOrder":"artistsort","WM/AlbumArtistSortOrder":"albumartistsort","WM/ComposerSortOrder":"composersort","WM/Writer":"lyricist","WM/Conductor":"conductor","WM/ModifiedBy":"remixer","WM/Engineer":"engineer","WM/Producer":"producer","WM/DJMixer":"djmixer","WM/Mixer":"mixer","WM/Publisher":"label","WM/ContentGroupDescription":"grouping","WM/SubTitle":"subtitle","WM/SetSubTitle":"discsubtitle","WM/IsCompilation":"compilation","WM/SharedUserRating":"rating","WM/BeatsPerMinute":"bpm","WM/Mood":"mood","WM/Media":"media","WM/CatalogNo":"catalognumber","MusicBrainz/Album Status":"releasestatus","MusicBrainz/Album Type":"releasetype","MusicBrainz/Album Release Country":"releasecountry","WM/Script":"script","WM/Language":"language",Copyright:"copyright",LICENSE:"license","WM/EncodedBy":"encodedby","WM/EncodingSettings":"encodersettings","WM/Barcode":"barcode","WM/ISRC":"isrc","MusicBrainz/Track Id":"musicbrainz_recordingid","MusicBrainz/Release Track Id":"musicbrainz_trackid","MusicBrainz/Album Id":"musicbrainz_albumid","MusicBrainz/Artist Id":"musicbrainz_artistid","MusicBrainz/Album Artist Id":"musicbrainz_albumartistid","MusicBrainz/Release Group Id":"musicbrainz_releasegroupid","MusicBrainz/Work Id":"musicbrainz_workid","MusicBrainz/TRM Id":"musicbrainz_trmid","MusicBrainz/Disc Id":"musicbrainz_discid","Acoustid/Id":"acoustid_id","Acoustid/Fingerprint":"acoustid_fingerprint","MusicIP/PUID":"musicip_puid","WM/ARTISTS":"artists","WM/InitialKey":"key",ASIN:"asin","WM/Work":"work","WM/AuthorURL":"website","WM/Picture":"picture"};class a extends n.CommonTagMapper{static toRating(e){return{rating:parseFloat(e+1)/5}}constructor(){super(["asf"],i)}postMap(e){switch(e.id){case"WM/SharedUserRating":const t=e.id.split(":");e.value=a.toRating(e.value),e.id=t[0]}}}t.AsfTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.id3v22TagMap={TT2:"title",TP1:"artist",TP2:"albumartist",TAL:"album",TYE:"year",COM:"comment",TRK:"track",TPA:"disk",TCO:"genre",PIC:"picture",TCM:"composer",TOR:"originaldate",TOT:"work",TXT:"lyricist",TP3:"conductor",TPB:"label",TT1:"grouping",TT3:"subtitle",TLA:"language",TCR:"copyright",WCP:"license",TEN:"encodedby",TSS:"encodersettings",WAR:"website","COM:iTunPGAP":"gapless"};t.ID3v22TagMapper=class extends n.CommonTagMapper{constructor(){super(["ID3v2.2"],t.id3v22TagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={Title:"title",Artist:"artist",Artists:"artists","Album Artist":"albumartist",Album:"album",Year:"date",Originalyear:"originalyear",Originaldate:"originaldate",Comment:"comment",Track:"track",Disc:"disk",DISCNUMBER:"disk",Genre:"genre","Cover Art (Front)":"picture","Cover Art (Back)":"picture",Composer:"composer",Lyrics:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",Lyricist:"lyricist",Writer:"writer",Conductor:"conductor",MixArtist:"remixer",Arranger:"arranger",Engineer:"engineer",Producer:"producer",DJMixer:"djmixer",Mixer:"mixer",Label:"label",Grouping:"grouping",Subtitle:"subtitle",DiscSubtitle:"discsubtitle",Compilation:"compilation",BPM:"bpm",Mood:"mood",Media:"media",CatalogNumber:"catalognumber",MUSICBRAINZ_ALBUMSTATUS:"releasestatus",MUSICBRAINZ_ALBUMTYPE:"releasetype",RELEASECOUNTRY:"releasecountry",Script:"script",Language:"language",Copyright:"copyright",LICENSE:"license",EncodedBy:"encodedby",EncoderSettings:"encodersettings",Barcode:"barcode",ISRC:"isrc",ASIN:"asin",musicbrainz_trackid:"musicbrainz_recordingid",musicbrainz_releasetrackid:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",Acoustid_Id:"acoustid_id",ACOUSTID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",Weblink:"website"};t.APEv2TagMapper=class extends n.CommonTagMapper{constructor(){const e={};for(const t in i)e[t.toUpperCase()]=i[t];super(["APEv2"],e)}getCommonName(e){return this.tagMap[e.toUpperCase()]}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={"©nam":"title","©ART":"artist",aART:"albumartist","----:com.apple.iTunes:Band":"albumartist","©alb":"album","©day":"date","©cmt":"comment",trkn:"track",disk:"disk","©gen":"genre",covr:"picture","©wrt":"composer","©lyr":"lyrics",soal:"albumsort",sonm:"titlesort",soar:"artistsort",soaa:"albumartistsort",soco:"composersort","----:com.apple.iTunes:LYRICIST":"lyricist","----:com.apple.iTunes:CONDUCTOR":"conductor","----:com.apple.iTunes:REMIXER":"remixer","----:com.apple.iTunes:ENGINEER":"engineer","----:com.apple.iTunes:PRODUCER":"producer","----:com.apple.iTunes:DJMIXER":"djmixer","----:com.apple.iTunes:MIXER":"mixer","----:com.apple.iTunes:LABEL":"label","©grp":"grouping","----:com.apple.iTunes:SUBTITLE":"subtitle","----:com.apple.iTunes:DISCSUBTITLE":"discsubtitle",cpil:"compilation",tmpo:"bpm","----:com.apple.iTunes:MOOD":"mood","----:com.apple.iTunes:MEDIA":"media","----:com.apple.iTunes:CATALOGNUMBER":"catalognumber",tvsh:"tvShow",tvsn:"tvSeason",tves:"tvEpisode",sosn:"tvShowSort",tven:"tvEpisodeId",tvnn:"tvNetwork",pcst:"podcast",purl:"podcasturl","----:com.apple.iTunes:MusicBrainz Album Status":"releasestatus","----:com.apple.iTunes:MusicBrainz Album Type":"releasetype","----:com.apple.iTunes:MusicBrainz Album Release Country":"releasecountry","----:com.apple.iTunes:SCRIPT":"script","----:com.apple.iTunes:LANGUAGE":"language",cprt:"copyright","----:com.apple.iTunes:LICENSE":"license","©too":"encodedby",pgap:"gapless","----:com.apple.iTunes:BARCODE":"barcode","----:com.apple.iTunes:ISRC":"isrc","----:com.apple.iTunes:ASIN":"asin","----:com.apple.iTunes:NOTES":"comment","----:com.apple.iTunes:MusicBrainz Track Id":"musicbrainz_recordingid","----:com.apple.iTunes:MusicBrainz Release Track Id":"musicbrainz_trackid","----:com.apple.iTunes:MusicBrainz Album Id":"musicbrainz_albumid","----:com.apple.iTunes:MusicBrainz Artist Id":"musicbrainz_artistid","----:com.apple.iTunes:MusicBrainz Album Artist Id":"musicbrainz_albumartistid","----:com.apple.iTunes:MusicBrainz Release Group Id":"musicbrainz_releasegroupid","----:com.apple.iTunes:MusicBrainz Work Id":"musicbrainz_workid","----:com.apple.iTunes:MusicBrainz TRM Id":"musicbrainz_trmid","----:com.apple.iTunes:MusicBrainz Disc Id":"musicbrainz_discid","----:com.apple.iTunes:Acoustid Id":"acoustid_id","----:com.apple.iTunes:Acoustid Fingerprint":"acoustid_fingerprint","----:com.apple.iTunes:MusicIP PUID":"musicip_puid","----:com.apple.iTunes:fingerprint":"musicip_fingerprint",gnre:"genre","----:com.apple.iTunes:ALBUMARTISTSORT":"albumartistsort","----:com.apple.iTunes:ARTISTS":"artists","----:com.apple.iTunes:ORIGINALDATE":"originaldate","----:com.apple.iTunes:ORIGINALYEAR":"originalyear",desc:"description",ldes:"description"};t.tagType="iTunes";t.MP4TagMapper=class extends n.CommonTagMapper{constructor(){super([t.tagType],i)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i={TITLE:"title",ARTIST:"artist",ARTISTS:"artists",ALBUMARTIST:"albumartist",ALBUM:"album",DATE:"date",ORIGINALDATE:"originaldate",ORIGINALYEAR:"originalyear",COMMENT:"comment",TRACKNUMBER:"track",DISCNUMBER:"disk",GENRE:"genre",METADATA_BLOCK_PICTURE:"picture",COMPOSER:"composer",LYRICS:"lyrics",ALBUMSORT:"albumsort",TITLESORT:"titlesort",WORK:"work",ARTISTSORT:"artistsort",ALBUMARTISTSORT:"albumartistsort",COMPOSERSORT:"composersort",LYRICIST:"lyricist",WRITER:"writer",CONDUCTOR:"conductor",REMIXER:"remixer",ARRANGER:"arranger",ENGINEER:"engineer",PRODUCER:"producer",DJMIXER:"djmixer",MIXER:"mixer",LABEL:"label",GROUPING:"grouping",SUBTITLE:"subtitle",DISCSUBTITLE:"discsubtitle",TRACKTOTAL:"totaltracks",DISCTOTAL:"totaldiscs",COMPILATION:"compilation",RATING:"rating",BPM:"bpm",MOOD:"mood",MEDIA:"media",CATALOGNUMBER:"catalognumber",RELEASESTATUS:"releasestatus",RELEASETYPE:"releasetype",RELEASECOUNTRY:"releasecountry",SCRIPT:"script",LANGUAGE:"language",COPYRIGHT:"copyright",LICENSE:"license",ENCODEDBY:"encodedby",ENCODERSETTINGS:"encodersettings",BARCODE:"barcode",ISRC:"isrc",ASIN:"asin",MUSICBRAINZ_TRACKID:"musicbrainz_recordingid",MUSICBRAINZ_RELEASETRACKID:"musicbrainz_trackid",MUSICBRAINZ_ALBUMID:"musicbrainz_albumid",MUSICBRAINZ_ARTISTID:"musicbrainz_artistid",MUSICBRAINZ_ALBUMARTISTID:"musicbrainz_albumartistid",MUSICBRAINZ_RELEASEGROUPID:"musicbrainz_releasegroupid",MUSICBRAINZ_WORKID:"musicbrainz_workid",MUSICBRAINZ_TRMID:"musicbrainz_trmid",MUSICBRAINZ_DISCID:"musicbrainz_discid",ACOUSTID_ID:"acoustid_id",ACOUSTID_ID_FINGERPRINT:"acoustid_fingerprint",MUSICIP_PUID:"musicip_puid",WEBSITE:"website",NOTES:"notes",TOTALTRACKS:"totaltracks",TOTALDISCS:"totaldiscs",DISCOGS_ARTIST_ID:"discogs_artist_id",DISCOGS_ARTISTS:"artists",DISCOGS_ARTIST_NAME:"artists",DISCOGS_ALBUM_ARTISTS:"albumartist",DISCOGS_CATALOG:"catalognumber",DISCOGS_COUNTRY:"releasecountry",DISCOGS_DATE:"originaldate",DISCOGS_LABEL:"label",DISCOGS_LABEL_ID:"discogs_label_id",DISCOGS_MASTER_RELEASE_ID:"discogs_master_release_id",DISCOGS_RATING:"discogs_rating",DISCOGS_RELEASED:"date",DISCOGS_RELEASE_ID:"discogs_release_id",DISCOGS_VOTES:"discogs_votes",CATALOGID:"catalognumber",STYLE:"genre",REPLAYGAIN_TRACK_GAIN:"replaygain_track_gain",REPLAYGAIN_TRACK_PEAK:"replaygain_track_peak"};class a extends n.CommonTagMapper{static toRating(e,t){return{source:e?e.toLowerCase():e,rating:parseFloat(t)*n.CommonTagMapper.maxRatingScore}}constructor(){super(["vorbis"],i)}postMap(e){if(0===e.id.indexOf("RATING:")){const t=e.id.split(":");e.value=a.toRating(t[1],e.value),e.id=t[0]}}}t.VorbisTagMapper=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(8);t.riffInfoTagMap={IART:"artist",ICRD:"date",INAM:"title",TITL:"title",IPRD:"album",ITRK:"track",COMM:"comment",ICMT:"comment",ICNT:"releasecountry",GNRE:"genre",IWRI:"writer",RATE:"rating",YEAR:"year",ISFT:"encodedby",CODE:"encodedby",TURL:"website",IGNR:"genre",IENG:"engineer",ITCH:"technician",IMED:"media",IRPD:"album"};t.RiffInfoTagMapper=class extends n.CommonTagMapper{constructor(){super(["exif"],t.riffInfoTagMap)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(10),s=r(21),o=r(17),c=r(5),u=r(7),l=r(225),d=r(226),f=r(26),p=i("music-metadata:parser:aiff");t.AIFFParser=class extends u.BasicParser{async parse(){if("FORM"!==(await this.tokenizer.readToken(d.Header)).chunkID)throw new Error("Invalid Chunk-ID, expected 'FORM'");const e=await this.tokenizer.readToken(c.FourCcToken);switch(e){case"AIFF":this.metadata.setFormat("container",e),this.isCompressed=!1;break;case"AIFC":this.metadata.setFormat("container","AIFF-C"),this.isCompressed=!0;break;default:throw Error("Unsupported AIFF type: "+e)}this.metadata.setFormat("lossless",!this.isCompressed);try{for(;;){const e=await this.tokenizer.readToken(d.Header);p(`Chunk id=${e.chunkID}`);const t=2*Math.round(e.chunkSize/2),r=await this.readData(e);await this.tokenizer.ignore(t-r)}}catch(e){if(e.message!==a.endOfFile)throw e}}async readData(e){switch(e.chunkID){case"COMM":const t=await this.tokenizer.readToken(new l.Common(e,this.isCompressed));return this.metadata.setFormat("bitsPerSample",t.sampleSize),this.metadata.setFormat("sampleRate",t.sampleRate),this.metadata.setFormat("numberOfChannels",t.numChannels),this.metadata.setFormat("numberOfSamples",t.numSampleFrames),this.metadata.setFormat("duration",t.numSampleFrames/t.sampleRate),this.metadata.setFormat("codec",t.compressionName),e.chunkSize;case"ID3 ":const r=await this.tokenizer.readToken(new n.BufferType(e.chunkSize)),i=new f.ID3Stream(r),a=s.fromStream(i);return await(new o.ID3v2Parser).parse(this.metadata,a,this.options),e.chunkSize;case"SSND":return this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*e.chunkSize/this.metadata.format.duration),0;default:return 0}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(4),s=r(18),o=n("music-metadata:id3v2:frame-parser"),c="iso-8859-1";class u{static readData(t,r,n,l){const{encoding:d,bom:f}=s.TextEncodingToken.get(t,0),p=t.length;let h=0,m=[];const g=u.getNullTerminatorLength(d);let b;const y={};switch(o(`Parsing tag type=${r}, encoding=${d}, bom=${f}`),"TXXX"!==r&&"T"===r[0]?"T*":r){case"T*":case"IPLS":const w=a.default.decodeString(t.slice(1),d).replace(/\x00+$/,"");switch(r){case"TMCL":case"TIPL":case"IPLS":m=u.splitValue(4,w),m=u.functionList(m);break;case"TRK":case"TRCK":case"TPOS":m=w;break;case"TCOM":case"TEXT":case"TOLY":case"TOPE":case"TPE1":case"TSRC":m=u.splitValue(n,w);break;default:m=n>=4?u.splitValue(n,w):[w]}break;case"TXXX":m={description:(m=u.readIdentifierAndData(t,h+1,p,d)).id,text:u.splitValue(n,a.default.decodeString(m.data,d).replace(/\x00+$/,""))};break;case"PIC":case"APIC":if(l){const r={};switch(h+=1,n){case 2:r.format=a.default.decodeString(t.slice(h,h+3),d),h+=3;break;case 3:case 4:b=a.default.findZero(t,h,p,c),r.format=a.default.decodeString(t.slice(h,b),c),h=b+1;break;default:throw new Error("Warning: unexpected major versionIndex: "+n)}r.format=u.fixPictureMimeType(r.format),r.type=s.AttachedPictureType[t[h]],h+=1,b=a.default.findZero(t,h,p,d),r.description=a.default.decodeString(t.slice(h,b),d),h=b+g,r.data=e.from(t.slice(h,p)),m=r}break;case"CNT":case"PCNT":m=i.UINT32_BE.get(t,0);break;case"SYLT":for(h+=7,m=[];h=5?t.readUInt32BE(h+1):void 0};break;case"GEOB":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d);const r=a.default.decodeString(t.slice(h+1,b),c);h=b+1,b=a.default.findZero(t,h,p-h,d),m={type:e,filename:r,description:a.default.decodeString(t.slice(h+1,b),c),data:t.slice(h+1,p)};break}case"WCOM":case"WCOP":case"WOAF":case"WOAR":case"WOAS":case"WORS":case"WPAY":case"WPUB":m=a.default.decodeString(t.slice(h,b),d);break;case"WXXX":{b=a.default.findZero(t,h+1,p,d);const e=a.default.decodeString(t.slice(h+1,b),c);h=b+1,m={description:e,url:a.default.decodeString(t.slice(h,p-h),d)};break}case"MCDI":m=t.slice(0,p);break;default:o("Warning: unsupported id3v2-tag-type: "+r)}return m}static fixPictureMimeType(e){switch(e=e.toLocaleLowerCase()){case"jpg":return"image/jpeg";case"png":return"image/png"}return e}static functionList(e){const t={};for(let r=0;r+1=4?/\x00/g:/\//g);return u.trimArray(r)}static trimArray(e){for(let t=0;t=r,`COMMON CHUNK size should always be at least ${r}`),this.len=e.chunkSize}get(e,t){const r=e.readUInt16BE(t+8)-16398,i=e.readUInt16BE(t+8+2),s={numChannels:e.readUInt16BE(t),numSampleFrames:e.readUInt32BE(t+2),sampleSize:e.readUInt16BE(t+6),sampleRate:r<0?i>>Math.abs(r):i<22){const r=e.readInt8(t+22);if(23+r+(r+1)%2!==this.len)throw new Error("Illegal pstring length");s.compressionName=new n.StringType(r,"binary").get(e,t+23)}}else s.compressionName="PCM";return s}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(5);t.Header={len:8,get:(e,t)=>({chunkID:n.FourCcToken.get(e,t),chunkSize:e.readUInt32BE(t+4)})}},function(e,t){},function(e,t,r){"use strict";var n=r(29).Buffer,i=r(229);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return n.alloc(0);if(1===this.length)return this.head.data;for(var t,r,i,a=n.allocUnsafe(e>>>0),s=this.head,o=0;s;)t=s.data,r=a,i=o,t.copy(r,i),o+=s.data.length,s=s.next;return a},e}(),i&&i.inspect&&i.inspect.custom&&(e.exports.prototype[i.inspect.custom]=function(){var e=i.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function a(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new a(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new a(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},a.prototype.unref=a.prototype.ref=function(){},a.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout()},t))},r(231),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(12))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,a,s,o,c=1,u={},l=!1,d=e.document,f=Object.getPrototypeOf&&Object.getPrototypeOf(e);f=f&&f.setTimeout?f:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick(function(){h(e)})}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((a=new MessageChannel).port1.onmessage=function(e){h(e.data)},n=function(e){a.port2.postMessage(e)}):d&&"onreadystatechange"in d.createElement("script")?(i=d.documentElement,n=function(e){var t=d.createElement("script");t.onreadystatechange=function(){h(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(h,0,e)}:(s="setImmediate$"+Math.random()+"$",o=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(s)&&h(+t.data.slice(s.length))},e.addEventListener?e.addEventListener("message",o,!1):e.attachEvent("onmessage",o),n=function(t){e.postMessage(s+t,"*")}),f.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r>1}}function s(e,t){return 0!=(e&1<({ID:i.FourCcToken.get(e,t),version:n.UINT32_LE.get(e,t+4)/1e3,descriptorBytes:n.UINT32_LE.get(e,t+8),headerBytes:n.UINT32_LE.get(e,t+12),seekTableBytes:n.UINT32_LE.get(e,t+16),headerDataBytes:n.UINT32_LE.get(e,t+20),apeFrameDataBytes:n.UINT32_LE.get(e,t+24),apeFrameDataBytesHigh:n.UINT32_LE.get(e,t+28),terminatingDataBytes:n.UINT32_LE.get(e,t+32),fileMD5:new n.BufferType(16).get(e,t+36)})},t.Header={len:24,get:(e,t)=>({compressionLevel:n.UINT16_LE.get(e,t),formatFlags:n.UINT16_LE.get(e,t+2),blocksPerFrame:n.UINT32_LE.get(e,t+4),finalFrameBlocks:n.UINT32_LE.get(e,t+8),totalFrames:n.UINT32_LE.get(e,t+12),bitsPerSample:n.UINT16_LE.get(e,t+16),channel:n.UINT16_LE.get(e,t+18),sampleRate:n.UINT32_LE.get(e,t+20)})},t.TagFooter={len:32,get:(e,t)=>({ID:new n.StringType(8,"ascii").get(e,t),version:n.UINT32_LE.get(e,t+8),size:n.UINT32_LE.get(e,t+12),fields:n.UINT32_LE.get(e,t+16),flags:a(n.UINT32_LE.get(e,t+20))})},t.TagItemHeader={len:8,get:(e,t)=>({size:n.UINT32_LE.get(e,t),flags:a(n.UINT32_LE.get(e,t+4))})},t.TagField=e=>new n.BufferType(e.size-t.TagFooter.len),t.parseTagFlags=a,t.isBitSet=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(42),i=r(241),a=r(2),s=r(7),o=a("music-metadata:parser:ASF"),c="asf";t.AsfParser=class extends s.BasicParser{async parse(){const e=await this.tokenizer.readToken(i.TopLevelHeaderObjectToken);if(!e.objectId.equals(n.default.HeaderObject))throw new Error("expected asf header; but was not found; got: "+e.objectId.str);try{await this.parseObjectHeader(e.numberOfHeaderObjects)}catch(e){o("Error while parsing ASF: %s",e)}}async parseObjectHeader(e){let t;do{const e=await this.tokenizer.readToken(i.HeaderObjectToken);switch(o("header GUID=%s",e.objectId.str),e.objectId.str){case i.FilePropertiesObject.guid.str:const r=await this.tokenizer.readToken(new i.FilePropertiesObject(e));this.metadata.setFormat("duration",r.playDuration/1e7),this.metadata.setFormat("bitrate",r.maximumBitrate);break;case i.StreamPropertiesObject.guid.str:const a=await this.tokenizer.readToken(new i.StreamPropertiesObject(e));this.metadata.setFormat("container","ASF/"+a.streamType);break;case i.HeaderExtensionObject.guid.str:const s=await this.tokenizer.readToken(new i.HeaderExtensionObject);await this.parseExtensionObject(s.extensionDataSize);break;case i.ContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ContentDescriptionObjectState(e)),this.addTags(t);break;case i.ExtendedContentDescriptionObjectState.guid.str:t=await this.tokenizer.readToken(new i.ExtendedContentDescriptionObjectState(e)),this.addTags(t);break;case n.default.CodecListObject.str:case n.default.StreamBitratePropertiesObject.str:await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;case n.default.PaddingObject.str:o("Padding: %s bytes",e.objectSize-i.HeaderObjectToken.len),await this.tokenizer.ignore(e.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+e.objectId.str),o("Ignore ASF-Object-GUID: %s",e.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(e))}}while(--e)}addTags(e){e.forEach(e=>{this.metadata.addTag(c,e.id,e.value)})}async parseExtensionObject(e){do{const t=await this.tokenizer.readToken(i.HeaderObjectToken);switch(t.objectId.str){case i.ExtendedStreamPropertiesObjectState.guid.str:await this.tokenizer.readToken(new i.ExtendedStreamPropertiesObjectState(t));break;case i.MetadataObjectState.guid.str:const e=await this.tokenizer.readToken(new i.MetadataObjectState(t));this.addTags(e);break;case i.MetadataLibraryObjectState.guid.str:const r=await this.tokenizer.readToken(new i.MetadataLibraryObjectState(t));this.addTags(r);break;case n.default.PaddingObject.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.CompatibilityObject.str:this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;case n.default.ASF_Index_Placeholder_Object.str:await this.tokenizer.ignore(t.objectSize-i.HeaderObjectToken.len);break;default:this.warnings.push("Ignore ASF-Object-GUID: "+t.objectId.str),await this.tokenizer.readToken(new i.IgnoreObjectState(t))}e-=t.objectSize}while(e>0)}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(4),i=r(1),a=r(42),s=r(242),o=r(18);!function(e){e[e.UnicodeString=0]="UnicodeString",e[e.ByteArray=1]="ByteArray",e[e.Bool=2]="Bool",e[e.DWord=3]="DWord",e[e.QWord=4]="QWord",e[e.Word=5]="Word"}(t.DataType||(t.DataType={})),t.TopLevelHeaderObjectToken={len:30,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16),numberOfHeaderObjects:i.UINT32_LE.get(e,t+24)})},t.HeaderObjectToken={len:24,get:(e,t)=>({objectId:a.default.fromBin(new i.BufferType(16).get(e,t)),objectSize:i.UINT64_LE.get(e,t+16)})};class c{constructor(e){this.len=e.objectSize-t.HeaderObjectToken.len}postProcessTag(e,t,r,n){if("WM/Picture"===t)e.push({id:t,value:b.fromBuffer(n)});else{const i=s.AsfUtil.getParserForAttr(r);if(!i)throw new Error("unexpected value headerType: "+r);e.push({id:t,value:i(n)})}}}t.State=c;t.IgnoreObjectState=class extends c{constructor(e){super(e)}get(e,t){return null}};class u extends c{constructor(e){super(e)}get(e,t){return{fileId:a.default.fromBin(e,t),fileSize:i.UINT64_LE.get(e,t+16),creationDate:i.UINT64_LE.get(e,t+24),dataPacketsCount:i.UINT64_LE.get(e,t+32),playDuration:i.UINT64_LE.get(e,t+40),sendDuration:i.UINT64_LE.get(e,t+48),preroll:i.UINT64_LE.get(e,t+56),flags:{broadcast:n.default.strtokBITSET.get(e,t+64,24),seekable:n.default.strtokBITSET.get(e,t+64,25)},minimumDataPacketSize:i.UINT32_LE.get(e,t+68),maximumDataPacketSize:i.UINT32_LE.get(e,t+72),maximumBitrate:i.UINT32_LE.get(e,t+76)}}}u.guid=a.default.FilePropertiesObject,t.FilePropertiesObject=u;class l extends c{constructor(e){super(e)}get(e,t){return{streamType:a.default.decodeMediaType(a.default.fromBin(e,t)),errorCorrectionType:a.default.fromBin(e,t+8)}}}l.guid=a.default.StreamPropertiesObject,t.StreamPropertiesObject=l;class d{constructor(){this.len=22}get(e,t){return{reserved1:a.default.fromBin(e,t),reserved2:e.readUInt16LE(t+16),extensionDataSize:e.readUInt32LE(t+18)}}}d.guid=a.default.HeaderExtensionObject,t.HeaderExtensionObject=d;class f extends c{constructor(e){super(e)}get(e,t){const r=[];let n=t+10;for(let i=0;i0){const t=f.contentDescTags[i],o=n+a;r.push({id:t,value:s.AsfUtil.parseUnicodeAttr(e.slice(n,o))}),n=o}}return r}}f.guid=a.default.ContentDescriptionObject,f.contentDescTags=["Title","Author","Copyright","Description","Rating"],t.ContentDescriptionObjectState=f;class p extends c{constructor(e){super(e)}get(e,t){const r=[],n=e.readUInt16LE(t);let i=t+2;for(let t=0;t({lastBlock:n.default.strtokBITSET.get(e,t,7),type:n.default.getBitAllignedNumber(e,t,1,7),length:i.UINT24_BE.get(e,t+1)})},d.BlockStreamInfo={len:34,get:(e,t)=>({minimumBlockSize:i.UINT16_BE.get(e,t),maximumBlockSize:i.UINT16_BE.get(e,t+2)/1e3,minimumFrameSize:i.UINT24_BE.get(e,t+4),maximumFrameSize:i.UINT24_BE.get(e,t+7),sampleRate:i.UINT24_BE.get(e,t+10)>>4,channels:n.default.getBitAllignedNumber(e,t+12,4,3)+1,bitsPerSample:n.default.getBitAllignedNumber(e,t+12,7,5)+1,totalSamples:n.default.getBitAllignedNumber(e,t+13,4,36),fileMD5:new i.BufferType(16).get(e,t+18)})};class f{constructor(e){this.data=e,this.offset=0}readInt32(){const e=i.UINT32_LE.get(this.data,this.offset);return this.offset+=4,e}readStringUtf8(){const e=this.readInt32(),t=this.data.toString("utf8",this.offset,this.offset+e);return this.offset+=e,t}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(7),s=r(245),o=r(44),c=r(25),u=n("music-metadata:parser:MP4"),l="iTunes",d={raw:{lossy:!1,format:"raw"},MAC3:{lossy:!0,format:"MACE 3:1"},MAC6:{lossy:!0,format:"MACE 6:1"},ima4:{lossy:!0,format:"IMA 4:1"},ulaw:{lossy:!0,format:"uLaw 2:1"},alaw:{lossy:!0,format:"uLaw 2:1"},Qclp:{lossy:!0,format:"QUALCOMM PureVoice"},".mp3":{lossy:!0,format:"MPEG-1 layer 3"},alac:{lossy:!1,format:"ALAC"},"ac-3":{lossy:!0,format:"AC-3"},mp4a:{lossy:!0,format:"MPEG-4/AAC"},mp4s:{lossy:!0,format:"MP4S"},c608:{lossy:!0,format:"CEA-608"},c708:{lossy:!0,format:"CEA-708"}};function f(e,t,r){return r.indexOf(e)===t}class p extends a.BasicParser{static read_BE_Signed_Integer(e){return i.readIntBE(e,0,e.length)}static read_BE_Unsigned_Integer(e){return i.readUIntBE(e,0,e.length)}async parse(){this.formatList=[];const e=new s.Atom({name:"mp4",length:this.tokenizer.fileSize},!1,null);await e.readAtoms(this.tokenizer,async e=>{if(e.parent)switch(e.parent.header.name){case"ilst":case"":return this.parseMetadataItemData(e);case"stbl":switch(e.header.name){case"stsd":return this.parseAtom_stsd(e.dataLen);default:u(`Ignore: stbl/${e.header.name} atom`)}}switch(e.header.name){case"ftyp":const t=await this.parseAtom_ftyp(e.dataLen);u(`ftyp: ${t.join("/")}`);const r=t.filter(f).join("/");return void this.metadata.setFormat("container",r);case"mdhd":return this.parseAtom_mdhd(e);case"mvhd":return this.parseAtom_mvhd(e);case"mdat":this.audioLengthInBytes=e.dataLen,this.calculateBitRate()}await this.tokenizer.readToken(new i.IgnoreType(e.dataLen)),u(`Ignore atom data: path=${e.atomPath}, payload-len=${e.dataLen}`)},this.tokenizer.fileSize),this.metadata.setFormat("codec",this.formatList.filter(f).join("+"))}calculateBitRate(){this.audioLengthInBytes&&this.metadata.format.duration&&this.metadata.setFormat("bitrate",8*this.audioLengthInBytes/this.metadata.format.duration)}addTag(e,t){this.metadata.addTag(l,e,t)}addWarning(e){u("Warning:"+e),this.warnings.push(e)}parseMetadataItemData(e){let t=e.header.name;return e.readAtoms(this.tokenizer,async e=>{switch(e.header.name){case"data":return this.parseValueAtom(t,e);case"name":const r=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+r.name;break;case"mean":const n=await this.tokenizer.readToken(new o.NameAtom(e.dataLen));t+=":"+n.name;break;default:const a=await this.tokenizer.readToken(new i.BufferType(e.dataLen));this.addWarning("Unsupported meta-item: "+t+"["+e.header.name+"] => value="+a.toString("hex")+" ascii="+a.toString("ascii"))}},e.dataLen)}async parseValueAtom(t,r){const n=await this.tokenizer.readToken(new o.DataAtom(r.header.length-o.Header.len));if(0!==n.type.set)throw new Error("Unsupported type-set != 0: "+n.type.set);switch(n.type.type){case 0:switch(t){case"trkn":case"disk":const e=i.UINT8.get(n.value,3),r=i.UINT8.get(n.value,5);this.addTag(t,e+"/"+r);break;case"gnre":const a=i.UINT8.get(n.value,1),s=c.Genres[a-1];this.addTag(t,s)}break;case 1:case 18:this.addTag(t,n.value.toString("utf-8"));break;case 13:if(this.options.skipCovers)break;this.addTag(t,{format:"image/jpeg",data:e.from(n.value)});break;case 14:if(this.options.skipCovers)break;this.addTag(t,{format:"image/png",data:e.from(n.value)});break;case 21:this.addTag(t,p.read_BE_Signed_Integer(n.value));break;case 22:this.addTag(t,p.read_BE_Unsigned_Integer(n.value));break;case 65:this.addTag(t,n.value.readInt8(0));break;case 66:this.addTag(t,n.value.readInt16BE(0));break;case 67:this.addTag(t,n.value.readInt32BE(0));break;default:this.addWarning(`atom key=${t}, has unknown well-known-type (data-type): ${n.type.type}`)}}async parseAtom_mvhd(e){const t=await this.tokenizer.readToken(new o.MvhdAtom(e.dataLen));this.parse_mxhd(t)}async parseAtom_mdhd(e){const t=await this.tokenizer.readToken(new o.MdhdAtom(e.dataLen));this.parse_mxhd(t)}parse_mxhd(e){if(e.timeScale&&!this.metadata.format.duration){const t=e.duration/e.timeScale;this.metadata.setFormat("duration",t),this.calculateBitRate()}}async parseAtom_ftyp(e){const t=await this.tokenizer.readToken(o.ftyp);if((e-=o.ftyp.len)>0){const r=await this.parseAtom_ftyp(e),n=t.type.replace(/\W/g,"");return n.length>0&&r.push(n),r}return[]}async parseAtom_stsd(e){const t=await this.tokenizer.readToken(new o.StsdAtom(e)),r=[];for(const e of t.table){const t=d[e.dataFormat];t?(this.parseSoundSampleDescription(e),this.metadata.setFormat("lossless",!t.lossy),r.push(t.format)):u(`Warning: data-format '${e.dataFormat}' missing in MP4Parser.encoderDict`)}r.length>0&&this.formatList.push(r.join("/"))}parseSoundSampleDescription(e){let t=0;const r=o.SoundSampleDescriptionVersion.get(e.description,t);if(t+=o.SoundSampleDescriptionVersion.len,0===r.version||1===r.version){const r=o.SoundSampleDescriptionV0.get(e.description,t);this.metadata.setFormat("sampleRate",r.sampleRate),this.metadata.setFormat("bitsPerSample",r.sampleSize),this.metadata.setFormat("numberOfChannels",r.numAudioChannels)}else u(`Warning: sound-sample-description ${r} not implemented`)}}t.MP4Parser=p}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(2),a=r(1),s=r(44),o=i("music-metadata:parser:MP4:Atom");class c{constructor(e,t,r){this.header=e,this.extended=t,this.parent=r,this.children=[],this.atomPath=(this.parent?this.parent.atomPath+"/":"")+this.header.name,this.dataLen=this.header.length-(t?16:8)}async readAtoms(e,t,r){const i=await this.readAtom(e,t);return this.children.push(i),void 0===r?this.readAtoms(e,t,r).catch(e=>{if(e.message!==n.endOfFile)throw e;o("Reached end-of-file")}):(r-=i.header.length)>0?this.readAtoms(e,t,r):void 0}async readAtom(e,t){const r=e.position,n=await e.readToken(s.Header),i=1===n.length;i&&(n.length=await e.readToken(s.ExtendedSize));const a=new c(n,i,this);return o(`parse atom name=${a.atomPath}, extended=${a.extended}, offset=${r}, len=${a.header.length}`),await a.readData(e,t),a}async readData(e,t){switch(this.header.name){case"moov":case"udta":case"trak":case"mdia":case"minf":case"stbl":case"":case"ilst":return this.readAtoms(e,t,this.dataLen);case"meta":return await e.readToken(new a.IgnoreType(4)),this.readAtoms(e,t,this.dataLen-4);case"mdhd":case"mvhd":case"tkhd":case"stsz":case"mdat":default:return t(this)}}}t.Atom=c},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(10),s=r(2),o=r(4),c=r(24),u=r(247),l=s("music-metadata:parser:mpeg"),d=1024,f={AudioObjectTypes:["AAC Main","AAC LC","AAC SSR","AAC LTP"],SamplingFrequencies:[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350,void 0,void 0,-1]},p=[void 0,["front-center"],["front-left","front-right"],["front-center","front-left","front-right"],["front-center","front-left","front-right","back-center"],["front-center","front-left","front-right","back-left","back-right"],["front-center","front-left","front-right","back-left","back-right","LFE-channel"],["front-center","front-left","front-right","side-left","side-right","back-left","back-right","LFE-channel"]];class h{constructor(e,t){this.versionIndex=o.default.getBitAllignedNumber(e,t+1,3,2),this.layer=h.LayerDescription[o.default.getBitAllignedNumber(e,t+1,5,2)],this.versionIndex>1&&0===this.layer?this.parseAdtsHeader(e,t):this.parseMpegHeader(e,t),this.isProtectedByCRC=!o.default.isBitSet(e,t+1,7)}calcDuration(e){return e*this.calcSamplesPerFrame()/this.samplingRate}calcSamplesPerFrame(){return h.samplesInFrameTable[1===this.version?0:1][this.layer]}calculateSideInfoLength(){if(3!==this.layer)return 2;if(3===this.channelModeIndex){if(1===this.version)return 17;if(2===this.version||2.5===this.version)return 9}else{if(1===this.version)return 32;if(2===this.version||2.5===this.version)return 17}}calcSlotSize(){return[null,4,1,1][this.layer]}parseMpegHeader(e,t){this.container="MPEG",this.bitrateIndex=o.default.getBitAllignedNumber(e,t+2,0,4),this.sampRateFreqIndex=o.default.getBitAllignedNumber(e,t+2,4,2),this.padding=o.default.isBitSet(e,t+2,6),this.privateBit=o.default.isBitSet(e,t+2,7),this.channelModeIndex=o.default.getBitAllignedNumber(e,t+3,0,2),this.modeExtension=o.default.getBitAllignedNumber(e,t+3,2,2),this.isCopyrighted=o.default.isBitSet(e,t+3,4),this.isOriginalMedia=o.default.isBitSet(e,t+3,5),this.emphasis=o.default.getBitAllignedNumber(e,t+3,7,2),this.version=h.VersionID[this.versionIndex],this.channelMode=h.ChannelMode[this.channelModeIndex],this.codec="MP"+this.layer;const r=this.calcBitrate();if(!r)throw new Error("Cannot determine bit-rate");if(this.bitrate=1e3*r,this.samplingRate=this.calcSamplingRate(),null==this.samplingRate)throw new Error("Cannot determine sampling-rate")}parseAdtsHeader(e,t){l("layer=0 => ADTS"),this.version=2===this.versionIndex?4:2,this.container="ADTS/MPEG-"+this.version;const r=o.default.getBitAllignedNumber(e,t+2,0,2);this.codec="AAC",this.codecProfile=f.AudioObjectTypes[r],l(`MPEG-4 audio-codec=${this.codec}`);const n=o.default.getBitAllignedNumber(e,t+2,2,4);this.samplingRate=f.SamplingFrequencies[n],l(`sampling-rate=${this.samplingRate}`);const i=o.default.getBitAllignedNumber(e,t+2,7,3);this.mp4ChannelConfig=p[i],l(`channel-config=${this.mp4ChannelConfig.join("+")}`),this.frameLength=o.default.getBitAllignedNumber(e,t+3,6,2)<<11}calcBitrate(){if(0===this.bitrateIndex)return null;if(15===this.bitrateIndex)return null;const e=this.version.toString()+this.layer;return h.bitrate_index[this.bitrateIndex][e]}calcSamplingRate(){return 3===this.sampRateFreqIndex?null:h.sampling_rate_freq_index[this.version][this.sampRateFreqIndex]}}h.SyncByte1=255,h.SyncByte2=224,h.VersionID=[2.5,null,2,1],h.LayerDescription=[0,3,2,1],h.ChannelMode=["stereo","joint_stereo","dual_channel","mono"],h.bitrate_index={1:{11:32,12:32,13:32,21:32,22:8,23:8},2:{11:64,12:48,13:40,21:48,22:16,23:16},3:{11:96,12:56,13:48,21:56,22:24,23:24},4:{11:128,12:64,13:56,21:64,22:32,23:32},5:{11:160,12:80,13:64,21:80,22:40,23:40},6:{11:192,12:96,13:80,21:96,22:48,23:48},7:{11:224,12:112,13:96,21:112,22:56,23:56},8:{11:256,12:128,13:112,21:128,22:64,23:64},9:{11:288,12:160,13:128,21:144,22:80,23:80},10:{11:320,12:192,13:160,21:160,22:96,23:96},11:{11:352,12:224,13:192,21:176,22:112,23:112},12:{11:384,12:256,13:224,21:192,22:128,23:128},13:{11:416,12:320,13:256,21:224,22:144,23:144},14:{11:448,12:384,13:320,21:256,22:160,23:160}},h.sampling_rate_freq_index={1:{0:44100,1:48e3,2:32e3},2:{0:22050,1:24e3,2:16e3},2.5:{0:11025,1:12e3,2:8e3}},h.samplesInFrameTable=[[0,384,1152,1152],[0,384,1152,576]];const m={len:4,get:(e,t)=>new h(e,t)};t.MpegParser=class extends c.AbstractID3Parser{constructor(){super(...arguments),this.frameCount=0,this.syncFrameCount=-1,this.countSkipFrameData=0,this.totalDataLength=0,this.bitrates=[],this.calculateEofDuration=!1,this.buf_frame_header=e.alloc(4),this.syncPeek={buf:e.alloc(d),len:0}}async _parse(){this.metadata.setFormat("lossless",!1);try{let e=!1;for(;!e;)await this.sync(),e=await this.parseCommonMpegHeader()}catch(e){if(e.message!==a.endOfFile)throw e;if(this.calculateEofDuration){const e=this.frameCount*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",e);const t=e/this.metadata.format.sampleRate;l(`Calculate duration at EOF: ${t} sec.`,t),this.metadata.setFormat("duration",t)}}}finalize(){const e=this.metadata.format,t=this.metadata.native.hasOwnProperty("ID3v1");if(e.duration&&this.tokenizer.fileSize){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0);e.codecProfile&&"V"===e.codecProfile[0]&&this.metadata.setFormat("bitrate",8*r/e.duration)}else if(this.tokenizer.fileSize&&"CBR"===e.codecProfile){const r=this.tokenizer.fileSize-this.mpegOffset-(t?128:0),n=Math.round(r/this.frame_size)*this.samplesPerFrame;this.metadata.setFormat("numberOfSamples",n);const i=n/e.sampleRate;l("Calculate CBR duration based on file size: %s",i),this.metadata.setFormat("duration",i)}}async sync(){let e=!1;for(;;){let t=0;if(this.syncPeek.len=await this.tokenizer.peekBuffer(this.syncPeek.buf,0,d,this.tokenizer.position,!0),this.syncPeek.len<=256)throw new Error(a.endOfFile);if(0===this.syncPeek.len)throw new Error(a.endOfFile);for(;;){if(e&&224==(224&this.syncPeek.buf[t]))return this.buf_frame_header[0]=h.SyncByte1,this.buf_frame_header[1]=this.syncPeek.buf[t],await this.tokenizer.ignore(t),l(`Sync at offset=${this.tokenizer.position-1}, frameCount=${this.frameCount}`),this.syncFrameCount===this.frameCount&&(l(`Re-synced MPEG stream, frameCount=${this.frameCount}`),this.frameCount=0,this.frame_size=0),void(this.syncFrameCount=this.frameCount);if(e=!1,-1===(t=this.syncPeek.buf.indexOf(h.SyncByte1,t))){if(this.syncPeek.len=2&&0===e.layer?this.parseAdts(e):this.parseAudioFrameHeader(e)}async parseAudioFrameHeader(e){this.metadata.setFormat("numberOfChannels","mono"===e.channelMode?1:2),this.metadata.setFormat("bitrate",e.bitrate),this.frameCount<2e5&&l("offset=%s MP%s bitrate=%s sample-rate=%s",this.tokenizer.position-4,e.layer,e.bitrate,e.samplingRate);const t=e.calcSlotSize();if(null===t)throw new Error("invalid slot_size");const r=e.calcSamplesPerFrame();l(`samples_per_frame=${r}`);const n=r/8*e.bitrate/e.samplingRate+(e.padding?t:0);if(this.frame_size=Math.floor(n),this.audioFrameHeader=e,this.bitrates.push(e.bitrate),1===this.frameCount)return this.offset=m.len,await this.skipSideInformation(),!1;if(3===this.frameCount){if(this.areAllSame(this.bitrates)){if(this.samplesPerFrame=r,this.metadata.setFormat("codecProfile","CBR"),this.tokenizer.fileSize)return!0}else if(this.metadata.format.duration)return!0;if(!this.options.duration)return!0}return this.options.duration&&4===this.frameCount&&(this.samplesPerFrame=r,this.calculateEofDuration=!0),this.offset=4,e.isProtectedByCRC?(await this.parseCrc(),!1):(await this.skipSideInformation(),!1)}async parseAdts(t){const r=e.alloc(3);await this.tokenizer.readBuffer(r),t.frameLength+=o.default.getBitAllignedNumber(r,0,0,11),this.tokenizer.ignore(t.frameLength-7),this.totalDataLength+=t.frameLength,this.samplesPerFrame=1024;const n=t.samplingRate/this.samplesPerFrame,i=8*(0===this.frameCount?0:this.totalDataLength/this.frameCount)*n+.5;if(this.metadata.setFormat("codecProfile",t.codecProfile),this.metadata.setFormat("bitrate",i),t.mp4ChannelConfig&&this.metadata.setFormat("numberOfChannels",t.mp4ChannelConfig.length),l(`frame-count=${this.frameCount}, size=${t.frameLength} bytes, bit-rate=${i}`),3===this.frameCount){if(!this.options.duration)return!0;this.calculateEofDuration=!0}return!1}async parseCrc(){return this.crc=await this.tokenizer.readNumber(i.INT16_BE),this.offset+=2,this.skipSideInformation()}async skipSideInformation(){const e=this.audioFrameHeader.calculateSideInfoLength();await this.tokenizer.readToken(new i.BufferType(e)),this.offset+=e,await this.readXtraInfoHeader()}async readXtraInfoHeader(){const e=await this.tokenizer.readToken(u.InfoTagHeaderTag);switch(this.offset+=u.InfoTagHeaderTag.len,e){case"Info":return this.metadata.setFormat("codecProfile","CBR"),this.readXingInfoHeader();case"Xing":const t=await this.readXingInfoHeader(),r="V"+(100-t.vbrScale)/10;return this.metadata.setFormat("codecProfile",r),null;case"Xtra":break;case"LAME":const n=await this.tokenizer.readToken(u.LameEncoderVersion);return this.offset+=u.LameEncoderVersion.len,this.metadata.setFormat("tool","LAME "+n),await this.skipFrameData(this.frame_size-this.offset),null}const t=this.frame_size-this.offset;return t<0?this.warnings.push("Frame "+this.frameCount+"corrupt: negative frameDataLeft"):await this.skipFrameData(t),null}async readXingInfoHeader(){const e=await this.tokenizer.readToken(u.XingInfoTag);if(this.offset+=u.XingInfoTag.len,this.metadata.setFormat("tool",o.default.stripNulls(e.codec)),1==(1&e.headerFlags[3])){const t=this.audioFrameHeader.calcDuration(e.numFrames);return this.metadata.setFormat("duration",t),l("Get duration from Xing header: %s",this.metadata.format.duration),e}const t=this.frame_size-this.offset;return await this.skipFrameData(t),e}async skipFrameData(e){n.ok(e>=0,"frame-data-left cannot be negative"),await this.tokenizer.readToken(new i.IgnoreType(e)),this.countSkipFrameData+=e}areAllSame(e){const t=e[0];return e.every(e=>e===t)}}}).call(this,r(3).Buffer)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.InfoTagHeaderTag=new n.StringType(4,"ascii"),t.LameEncoderVersion=new n.StringType(6,"ascii"),t.XingInfoTag={len:136,get:(e,t)=>({headerFlags:new n.BufferType(4).get(e,t),numFrames:n.UINT32_BE.get(e,t+4),streamSize:n.UINT32_BE.get(e,t+8),vbrScale:n.UINT32_BE.get(e,t+112),codec:new n.StringType(9,"ascii").get(e,t+116),infoTagRevision:n.UINT8.get(e,t+125)>>4,vbrMethod:15&n.UINT8.get(e,t+125)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(1),a=r(249),s=r(251),o=r(24),c=n("music-metadata:parser:musepack");t.default=class extends o.AbstractID3Parser{async _parse(){let e;switch(await this.tokenizer.peekToken(new i.StringType(3,"binary"))){case"MP+":c("Musepack stream-version 7"),e=new s.MpcSv7Parser;break;case"MPC":c("Musepack stream-version 8"),e=new a.MpcSv8Parser;break;default:throw new Error("Invalid Musepack signature prefix")}return e.init(this.metadata,this.tokenizer,this.options),e.parse()}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(250),o=r(23),c=r(5),u=n("music-metadata:parser:musepack");t.MpcSv8Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(c.FourCcToken);return i.equal(e,"MPCK","Magic number"),this.metadata.setFormat("container","Musepack, SV8"),this.parsePacket()}async parsePacket(){const e=new s.StreamReader(this.tokenizer);for(;;){const t=await e.readPacketHeader();switch(u(`packet-header key=${t.key}, payloadLength=${t.payloadLength}`),t.key){case"SH":const r=await e.readStreamHeader(t.payloadLength);this.metadata.setFormat("numberOfSamples",r.sampleCount),this.metadata.setFormat("sampleRate",r.sampleFrequency),this.metadata.setFormat("duration",r.sampleCount/r.sampleFrequency),this.metadata.setFormat("numberOfChannels",r.channelCount);break;case"AP":this.audioLength+=t.payloadLength,await this.tokenizer.ignore(t.payloadLength);break;case"RG":case"EI":case"SO":case"ST":case"CT":await this.tokenizer.ignore(t.payloadLength);break;case"SE":return this.metadata.setFormat("bitrate",8*this.audioLength/this.metadata.format.duration),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options);default:throw new Error(`Unexpected header: ${t.key}`)}}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4),a=r(2)("music-metadata:parser:musepack:sv8"),s=new n.StringType(2,"binary"),o={len:5,get:(e,t)=>({crc:n.UINT32_LE.get(e,t),streamVersion:n.UINT8.get(e,t+4)})},c={len:2,get:(e,t)=>({sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t,0,3)],maxUsedBands:i.default.getBitAllignedNumber(e,t,3,5),channelCount:i.default.getBitAllignedNumber(e,t+1,0,4)+1,msUsed:i.default.isBitSet(e,t+1,4),audioBlockFrames:i.default.getBitAllignedNumber(e,t+1,5,3)})};t.StreamReader=class{constructor(e){this.tokenizer=e}async readPacketHeader(){const e=await this.tokenizer.readToken(s),t=await this.readVariableSizeField();return{key:e,payloadLength:t.value-2-t.len}}async readStreamHeader(e){const t={};a(`Reading SH at offset=${this.tokenizer.position}`);const r=await this.tokenizer.readToken(o);e-=o.len,Object.assign(t,r),a(`SH.streamVersion = ${r.streamVersion}`);const n=await this.readVariableSizeField();e-=n.len,t.sampleCount=n.value;const i=await this.readVariableSizeField();e-=i.len,t.beginningOfSilence=i.value;const s=await this.tokenizer.readToken(c);return e-=c.len,Object.assign(t,s),await this.tokenizer.ignore(e),t}async readVariableSizeField(e=1,t=0){let r=await this.tokenizer.readToken(n.UINT8);return 0==(128&r)?{len:e,value:t+r}:(r&=127,r+=t,this.readVariableSizeField(e+1,r<<7))}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(6),a=r(7),s=r(252),o=r(23),c=r(253),u=n("music-metadata:parser:musepack");t.MpcSv7Parser=class extends a.BasicParser{constructor(){super(...arguments),this.audioLength=0}async parse(){const e=await this.tokenizer.readToken(s.Header);i.equal(e.signature,"MP+","Magic number"),u(`stream-version=${e.streamMajorVersion}.${e.streamMinorVersion}`),this.metadata.setFormat("container","Musepack, SV7"),this.metadata.setFormat("sampleRate",e.sampleFrequency);const t=1152*(e.frameCount-1)+e.lastFrameLength;this.metadata.setFormat("numberOfSamples",t),this.duration=t/e.sampleFrequency,this.metadata.setFormat("duration",this.duration),this.bitreader=new c.BitReader(this.tokenizer),this.metadata.setFormat("numberOfChannels",e.midSideStereo||e.intensityStereo?2:1);const r=await this.bitreader.read(8);return this.metadata.setFormat("codec",(r/100).toFixed(2)),await this.skipAudioData(e.frameCount),u(`End of audio stream, switching to APEv2, offset=${this.tokenizer.position}`),o.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async skipAudioData(e){for(;e-- >0;){const e=await this.bitreader.read(20);this.audioLength+=20+e,await this.bitreader.ignore(e)}const t=await this.bitreader.read(11);this.audioLength+=t,this.metadata.setFormat("bitrate",this.audioLength/this.duration)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:24,get:(e,t)=>{const r={signature:e.toString("binary",t,t+3),streamMinorVersion:i.default.getBitAllignedNumber(e,t+3,0,4),streamMajorVersion:i.default.getBitAllignedNumber(e,t+3,4,4),frameCount:n.UINT32_LE.get(e,t+4),maxLevel:n.UINT16_LE.get(e,t+8),sampleFrequency:[44100,48e3,37800,32e3][i.default.getBitAllignedNumber(e,t+10,0,2)],link:i.default.getBitAllignedNumber(e,t+10,2,2),profile:i.default.getBitAllignedNumber(e,t+10,4,4),maxBand:i.default.getBitAllignedNumber(e,t+11,0,6),intensityStereo:i.default.isBitSet(e,t+11,6),midSideStereo:i.default.isBitSet(e,t+11,7),titlePeak:n.UINT16_LE.get(e,t+12),titleGain:n.UINT16_LE.get(e,t+14),albumPeak:n.UINT16_LE.get(e,t+16),albumGain:n.UINT16_LE.get(e,t+18),lastFrameLength:n.UINT32_LE.get(e,t+20)>>>20&2047,trueGapless:i.default.isBitSet(e,t+23,0)};return r.lastFrameLength=r.trueGapless?n.UINT32_LE.get(e,20)>>>20&2047:0,r}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.BitReader=class{constructor(e){this.tokenizer=e,this.pos=0,this.dword=void 0}async read(e){for(;void 0===this.dword;)this.dword=await this.tokenizer.readToken(n.UINT32_LE);let t=this.dword;return this.pos+=e,this.pos<32?(t>>>=32-this.pos)&(1<>>32-this.pos),t&(1<0){const t=32-this.pos;this.dword=void 0,e-=t,this.pos=0}const t=e%32,r=(e-t)/32;return await this.tokenizer.ignore(4*r),this.read(t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(2),a=r(6),s=r(4),o=r(5),c=r(31),u=r(255),l=r(257),d=r(7),f=r(259),p=i("music-metadata:parser:ogg");class h{static sum(e,t,r){let n=0;for(let i=t;i0)return this.warnings.push("Invalid FourCC ID, maybe last OGG-page is not marked with last-page flag"),this.pageConsumer.flush();throw e}}}m.Header={len:27,get:(e,t)=>({capturePattern:o.FourCcToken.get(e,t),version:e.readUInt8(t+4),headerType:{continued:s.default.strtokBITSET.get(e,t+5,0),firstPage:s.default.strtokBITSET.get(e,t+5,1),lastPage:s.default.strtokBITSET.get(e,t+5,2)},absoluteGranulePosition:e.readIntLE(t+6,6),streamSerialNumber:n.UINT32_LE.get(e,t+14),pageSequenceNo:n.UINT32_LE.get(e,t+18),pageChecksum:n.UINT32_LE.get(e,t+22),page_segments:e.readUInt8(t+26)})},t.OggParser=m},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(256),a=r(31);t.OpusParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r,this.lastPos=-1}parseFirstPage(e,t){if(this.metadata.setFormat("codec","Opus"),this.idHeader=new i.IdHeader(t.length).get(t,0),"OpusHead"!==this.idHeader.magicSignature)throw new Error("Illegal ogg/Opus magic-signature");this.metadata.setFormat("sampleRate",this.idHeader.inputSampleRate),this.metadata.setFormat("numberOfChannels",this.idHeader.channelCount)}parseFullPage(e){switch(new n.StringType(8,"ascii").get(e,0)){case"OpusTags":this.parseUserCommentList(e,8),this.lastPos=this.tokenizer.position}}calculateDuration(e){if(this.metadata.format.sampleRate&&e.absoluteGranulePosition>=0&&(this.metadata.setFormat("numberOfSamples",e.absoluteGranulePosition-this.idHeader.preSkip),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.idHeader.inputSampleRate),-1!==this.lastPos&&this.tokenizer.fileSize&&this.metadata.format.duration)){const e=this.tokenizer.fileSize-this.lastPos;this.metadata.setFormat("bitrate",8*e/this.metadata.format.duration)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdHeader=class{constructor(e){if(this.len=e,e<19)throw new Error("ID-header-page 0 should be at least 19 bytes long")}get(e,t){return{magicSignature:new n.StringType(8,"ascii").get(e,t+0),version:e.readUInt8(t+8),channelCount:e.readUInt8(t+9),preSkip:e.readInt16LE(t+10),inputSampleRate:e.readInt32LE(t+12),outputGain:e.readInt16LE(t+16),channelMapping:e.readUInt8(t+18)}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(258),a=r(31),s=n("music-metadata:parser:ogg:speex");t.SpeexParser=class extends a.VorbisParser{constructor(e,t,r){super(e,t),this.tokenizer=r}parseFirstPage(e,t){s("First Ogg/Speex page");const r=i.Header.get(t,0);this.metadata.setFormat("codec",`Speex ${r.version}`),this.metadata.setFormat("numberOfChannels",r.nb_channels),this.metadata.setFormat("sampleRate",r.rate),-1!==r.bitrate&&this.metadata.setFormat("bitrate",r.bitrate)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(4);t.Header={len:80,get:(e,t)=>({speex:new n.StringType(8,"ascii").get(e,t+0),version:i.default.trimRightNull(new n.StringType(20,"ascii").get(e,t+8)),version_id:e.readInt32LE(t+28),header_size:e.readInt32LE(t+32),rate:e.readInt32LE(t+36),mode:e.readInt32LE(t+40),mode_bitstream_version:e.readInt32LE(t+44),nb_channels:e.readInt32LE(t+48),bitrate:e.readInt32LE(t+52),frame_size:e.readInt32LE(t+56),vbr:e.readInt32LE(t+60),frames_per_packet:e.readInt32LE(t+64),extra_headers:e.readInt32LE(t+68),reserved1:e.readInt32LE(t+72),reserved2:e.readInt32LE(t+76)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(2),i=r(260),a=n("music-metadata:parser:ogg:theora");t.TheoraParser=class{constructor(e,t,r){this.metadata=e,this.tokenizer=r}parsePage(e,t){e.headerType.firstPage&&this.parseFirstPage(e,t)}flush(){a("flush")}parseFirstPage(e,t){a("First Ogg/Theora page"),this.metadata.setFormat("codec","Theora");const r=i.IdentificationHeader.get(t,0);this.metadata.setFormat("bitrate",r.nombr)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1);t.IdentificationHeader={len:42,get:(e,t)=>({id:new n.StringType(7,"ascii").get(e,t),vmaj:e.readUInt8(t+7),vmin:e.readUInt8(t+8),vrev:e.readUInt8(t+9),vmbw:e.readUInt16BE(t+10),vmbh:e.readUInt16BE(t+17),nombr:n.UINT24_BE.get(e,t+37),nqual:e.readUInt8(t+40)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(10),i=r(21),a=r(1),s=r(2),o=r(262),c=r(263),u=r(17),l=r(4),d=r(5),f=r(7),p=r(26),h=s("music-metadata:parser:RIFF");t.WaveParser=class extends f.BasicParser{async parse(){const e=await this.tokenizer.readToken(o.Header);if(h(`pos=${this.tokenizer.position}, parse: chunkID=${e.chunkID}`),"RIFF"===e.chunkID)return this.parseRiffChunk().catch(e=>{if(e.message!==n.endOfFile)throw e})}async parseRiffChunk(){const e=await this.tokenizer.readToken(d.FourCcToken);switch(this.metadata.setFormat("container",e),e){case"WAVE":return this.readWaveChunk();default:throw new Error(`Unsupported RIFF format: RIFF/${e}`)}}async readWaveChunk(){for(;;){const e=await this.tokenizer.readToken(o.Header);switch(this.header=e,h(`pos=${this.tokenizer.position}, readChunk: chunkID=RIFF/WAVE/${e.chunkID}`),e.chunkID){case"LIST":await this.parseListTag(e);break;case"fact":this.metadata.setFormat("lossless",!1),this.fact=await this.tokenizer.readToken(new c.FactChunk(e));break;case"fmt ":const t=await this.tokenizer.readToken(new c.Format(e));let r=c.WaveFormat[t.wFormatTag];r||(h("WAVE/non-PCM format="+t.wFormatTag),r="non-PCM ("+t.wFormatTag+")"),this.metadata.setFormat("codec",r),this.metadata.setFormat("bitsPerSample",t.wBitsPerSample),this.metadata.setFormat("sampleRate",t.nSamplesPerSec),this.metadata.setFormat("numberOfChannels",t.nChannels),this.metadata.setFormat("bitrate",t.nBlockAlign*t.nSamplesPerSec*8),this.blockAlign=t.nBlockAlign;break;case"id3 ":case"ID3 ":const n=await this.tokenizer.readToken(new a.BufferType(e.chunkSize)),s=new p.ID3Stream(n),o=i.fromStream(s);await(new u.ID3v2Parser).parse(this.metadata,o,this.options);break;case"data":!1!==this.metadata.format.lossless&&this.metadata.setFormat("lossless",!0);const l=this.fact?this.fact.dwSampleLength:e.chunkSize/this.blockAlign;this.metadata.setFormat("numberOfSamples",l),this.metadata.setFormat("duration",l/this.metadata.format.sampleRate),this.metadata.setFormat("bitrate",this.metadata.format.numberOfChannels*this.blockAlign*this.metadata.format.sampleRate),await this.tokenizer.ignore(e.chunkSize);break;default:h(`Ignore chunk: RIFF/${e.chunkID} of ${e.chunkSize} bytes`),this.warnings.push("Ignore chunk: RIFF/"+e.chunkID),await this.tokenizer.ignore(e.chunkSize)}this.header.chunkSize%2==1&&(h("Read odd padding byte"),await this.tokenizer.ignore(1))}}async parseListTag(e){const t=await this.tokenizer.readToken(d.FourCcToken);switch(h("pos=%s, parseListTag: chunkID=RIFF/WAVE/LIST/%s",this.tokenizer.position,t),t){case"INFO":return this.parseRiffInfoTags(e.chunkSize-4);case"adtl":default:return this.warnings.push("Ignore chunk: RIFF/WAVE/LIST/"+t),h("Ignoring chunkID=RIFF/WAVE/LIST/"+t),this.tokenizer.ignore(e.chunkSize-4)}}async parseRiffInfoTags(e){for(;e>=8;){const t=await this.tokenizer.readToken(o.Header),r=new o.ListInfoTagValue(t),n=await this.tokenizer.readToken(r);this.addTag(t.chunkID,l.default.stripNulls(n)),e-=8+r.len}if(0!==e)throw Error("Illegal remaining size: "+e)}addTag(e,t){this.metadata.addTag("exif",e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.Header={len:8,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:e.readUInt32LE(t+4)})};t.ListInfoTagValue=class{constructor(e){this.tagHeader=e,this.len=e.chunkSize,this.len+=1&this.len}get(e,t){return new n.StringType(this.tagHeader.chunkSize,"ascii").get(e,t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6);!function(e){e[e.PCM=1]="PCM",e[e.ADPCM=2]="ADPCM",e[e.IEEE_FLOAT=3]="IEEE_FLOAT",e[e.MPEG_ADTS_AAC=5632]="MPEG_ADTS_AAC",e[e.MPEG_LOAS=5634]="MPEG_LOAS",e[e.RAW_AAC1=255]="RAW_AAC1",e[e.DOLBY_AC3_SPDIF=146]="DOLBY_AC3_SPDIF",e[e.DVM=8192]="DVM",e[e.RAW_SPORT=576]="RAW_SPORT",e[e.ESST_AC3=577]="ESST_AC3",e[e.DRM=9]="DRM",e[e.DTS2=8193]="DTS2",e[e.MPEG=80]="MPEG"}(t.WaveFormat||(t.WaveFormat={}));t.Format=class{constructor(e){n.ok(e.chunkSize>=16,"16 for PCM."),this.len=e.chunkSize}get(e,t){return{wFormatTag:e.readUInt16LE(t),nChannels:e.readUInt16LE(t+2),nSamplesPerSec:e.readUInt32LE(t+4),nAvgBytesPerSec:e.readUInt32LE(t+8),nBlockAlign:e.readUInt16LE(t+12),wBitsPerSample:e.readUInt16LE(t+14)}}};t.FactChunk=class{constructor(e){n.ok(e.chunkSize>=4,"minimum fact chunk size."),this.len=e.chunkSize}get(e,t){return{dwSampleLength:e.readUInt32LE(t)}}}},function(e,t,r){"use strict";(function(e){Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(6),a=r(23),s=r(5),o=r(7),c=r(265),u=r(2)("music-metadata:parser:WavPack");t.WavPackParser=class extends o.BasicParser{async parse(){return this.audioDataSize=0,await this.parseWavPackBlocks(),a.APEv2Parser.parseTagHeader(this.metadata,this.tokenizer,this.options)}async parseWavPackBlocks(){do{if("wvpk"!==await this.tokenizer.peekToken(s.FourCcToken))break;const e=await this.tokenizer.readToken(c.WavPack.BlockHeaderToken);i.strictEqual(e.BlockID,"wvpk","WavPack Block-ID"),u(`WavPack header blockIndex=${e.blockIndex}, len=${c.WavPack.BlockHeaderToken.len}`),0!==e.blockIndex||this.metadata.format.container||(this.metadata.setFormat("container","WavPack"),this.metadata.setFormat("lossless",!e.flags.isHybrid),this.metadata.setFormat("bitsPerSample",e.flags.bitsPerSample),e.flags.isDSD||(this.metadata.setFormat("sampleRate",e.flags.samplingRate),this.metadata.setFormat("duration",e.totalSamples/e.flags.samplingRate)),this.metadata.setFormat("numberOfChannels",e.flags.isMono?1:2),this.metadata.setFormat("numberOfSamples",e.totalSamples),this.metadata.setFormat("codec",e.flags.isDSD?"DSD":"PCM"));const t=e.blockSize-(c.WavPack.BlockHeaderToken.len-8);0===e.blockIndex?await this.parseMetadataSubBlock(e,t):await this.tokenizer.ignore(t),e.blockSamples>0&&(this.audioDataSize+=e.blockSize)}while(!this.tokenizer.fileSize||this.tokenizer.fileSize-this.tokenizer.position>=c.WavPack.BlockHeaderToken.len);this.metadata.setFormat("bitrate",8*this.audioDataSize/this.metadata.format.duration)}async parseMetadataSubBlock(t,r){for(;r>c.WavPack.MetadataIdToken.len;){const a=await this.tokenizer.readToken(c.WavPack.MetadataIdToken),s=await this.tokenizer.readNumber(a.largeBlock?n.UINT24_LE:n.UINT8),o=e.alloc(2*s-(a.isOddSize?1:0));switch(await this.tokenizer.readBuffer(o,0,o.length),u(`Metadata Sub-Blocks functionId=0x${a.functionId.toString(16)}, id.largeBlock=${a.largeBlock},data-size=${o.length}`),a.functionId){case 0:break;case 14:u("ID_DSD_BLOCK");const e=1<>>t&4294967295>>>32-r}}s.BlockHeaderToken={len:32,get:(e,t)=>{const r=n.UINT32_LE.get(e,t+24),o={BlockID:i.FourCcToken.get(e,t),blockSize:n.UINT32_LE.get(e,t+4),version:n.UINT16_LE.get(e,t+8),totalSamples:(n.UINT8.get(e,t+11)<<32)+n.UINT32_LE.get(e,t+12),blockIndex:(n.UINT8.get(e,t+10)<<32)+n.UINT32_LE.get(e,t+16),blockSamples:n.UINT32_LE.get(e,t+20),flags:{bitsPerSample:8*(1+s.getBitAllignedNumber(r,0,2)),isMono:s.isBitSet(r,2),isHybrid:s.isBitSet(r,3),isJointStereo:s.isBitSet(r,4),crossChannel:s.isBitSet(r,5),hybridNoiseShaping:s.isBitSet(r,6),floatingPoint:s.isBitSet(r,7),samplingRate:a[s.getBitAllignedNumber(r,23,4)],isDSD:s.isBitSet(r,31)},crc:new n.BufferType(4).get(e,t+28)};return o.flags.isDSD&&(o.totalSamples*=8),o}},s.MetadataIdToken={len:1,get:(e,t)=>({functionId:s.getBitAllignedNumber(e[t],0,6),isOptional:s.isBitSet(e[t],5),isOddSize:s.isBitSet(e[t],6),largeBlock:s.isBitSet(e[t],7)})},t.WavPack=s},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(24),i=r(6),a=r(2),s=r(267),o=r(17),c=a("music-metadata:parser:DSF");t.DsfParser=class extends n.AbstractID3Parser{async _parse(){const e=this.tokenizer.position,t=await this.tokenizer.readToken(s.ChunkHeader);i.strictEqual(t.id,"DSD ","Invalid chunk signature"),this.metadata.setFormat("container","DSF"),this.metadata.setFormat("lossless",!0);const r=await this.tokenizer.readToken(s.DsdChunk);if(0!==r.metadataPointer)return c(`expect ID3v2 at offset=${r.metadataPointer}`),await this.parseChunks(r.fileSize-t.size),await this.tokenizer.ignore(r.metadataPointer-this.tokenizer.position-e),(new o.ID3v2Parser).parse(this.metadata,this.tokenizer,this.options);c("No ID3v2 tag present")}async parseChunks(e){for(;e>=s.ChunkHeader.len;){const t=await this.tokenizer.readToken(s.ChunkHeader);switch(c(`Parsing chunk name=${t.id} size=${t.size}`),t.id){case"fmt ":const e=await this.tokenizer.readToken(s.FormatChunk);this.metadata.setFormat("numberOfChannels",e.channelNum),this.metadata.setFormat("sampleRate",e.samplingFrequency),this.metadata.setFormat("bitsPerSample",e.bitsPerSample),this.metadata.setFormat("numberOfSamples",e.sampleCount),this.metadata.setFormat("duration",e.sampleCount/e.samplingFrequency);const r=e.bitsPerSample*e.samplingFrequency*e.channelNum;return void this.metadata.setFormat("bitrate",r);default:this.tokenizer.ignore(t.size-s.ChunkHeader.len)}e-=t.size}}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({id:i.FourCcToken.get(e,t),size:n.UINT64_LE.get(e,t+4)})},t.DsdChunk={len:16,get:(e,t)=>({fileSize:n.INT64_LE.get(e,t),metadataPointer:n.INT64_LE.get(e,t+8)})},function(e){e[e.mono=1]="mono",e[e.stereo=2]="stereo",e[e.channels=3]="channels",e[e.quad=4]="quad",e[e["4 channels"]=5]="4 channels",e[e["5 channels"]=6]="5 channels",e[e["5.1 channels"]=7]="5.1 channels"}(t.ChannelType||(t.ChannelType={})),t.FormatChunk={len:40,get:(e,t)=>({formatVersion:n.INT32_LE.get(e,t),formatID:n.INT32_LE.get(e,t+4),channelType:n.INT32_LE.get(e,t+8),channelNum:n.INT32_LE.get(e,t+12),samplingFrequency:n.INT32_LE.get(e,t+16),bitsPerSample:n.INT32_LE.get(e,t+20),sampleCount:n.INT64_LE.get(e,t+24),blockSizePerChannel:n.INT32_LE.get(e,t+32)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(6),i=r(1),a=r(2),s=r(5),o=r(7),c=r(26),u=r(269),l=r(21),d=r(17),f=a("music-metadata:parser:aiff");t.DsdiffParser=class extends o.BasicParser{async parse(){const e=await this.tokenizer.readToken(u.ChunkHeader);n.strictEqual(e.chunkID,"FRM8");const t=(await this.tokenizer.readToken(s.FourCcToken)).trim();switch(t){case"DSD":return this.metadata.setFormat("container",`DSDIFF/${t}`),this.metadata.setFormat("lossless",!0),this.readFmt8Chunks(e.chunkSize-s.FourCcToken.len);default:throw Error(`Unsupported DSDIFF type: ${t}`)}}async readFmt8Chunks(e){for(;e>=u.ChunkHeader.len;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Chunk id=${t.chunkID}`),await this.readData(t),e-=u.ChunkHeader.len+t.chunkSize}}async readData(e){f(`Reading data of chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);const t=this.tokenizer.position;switch(e.chunkID.trim()){case"FVER":const t=await this.tokenizer.readToken(i.UINT32_LE);f(`DSDIFF version=${t}`);break;case"PROP":const r=await this.tokenizer.readToken(s.FourCcToken);n.strictEqual(r,"SND "),await this.handleSoundPropertyChunks(e.chunkSize-s.FourCcToken.len);break;case"ID3":const a=await this.tokenizer.readToken(new i.BufferType(e.chunkSize)),o=new c.ID3Stream(a),u=l.fromStream(o);await(new d.ID3v2Parser).parse(this.metadata,u,this.options);break;default:f(`Ignore chunk[ID=${e.chunkID}, size=${e.chunkSize}]`);break;case"DSD":this.metadata.setFormat("numberOfSamples",8*e.chunkSize/this.metadata.format.numberOfChannels),this.metadata.setFormat("duration",this.metadata.format.numberOfSamples/this.metadata.format.sampleRate)}const r=e.chunkSize-(this.tokenizer.position-t);r>0&&(f(`After Parsing chunk, remaining ${r} bytes`),await this.tokenizer.ignore(r))}async handleSoundPropertyChunks(e){for(f(`Parsing sound-property-chunks, remainingSize=${e}`);e>0;){const t=await this.tokenizer.readToken(u.ChunkHeader);f(`Sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`);const r=this.tokenizer.position;switch(t.chunkID.trim()){case"FS":const e=await this.tokenizer.readToken(i.UINT32_BE);this.metadata.setFormat("sampleRate",e);break;case"CHNL":const r=await this.tokenizer.readToken(i.UINT16_BE);this.metadata.setFormat("numberOfChannels",r),await this.handleChannelChunks(t.chunkSize-i.UINT16_BE.len);break;case"CMPR":const n=(await this.tokenizer.readToken(s.FourCcToken)).trim(),a=await this.tokenizer.readToken(i.UINT8),o=await this.tokenizer.readToken(new i.StringType(a,"ascii"));"DSD"===n&&(this.metadata.setFormat("lossless",!0),this.metadata.setFormat("bitsPerSample",1)),this.metadata.setFormat("codec",`${n} (${o})`);break;case"ABSS":const c=await this.tokenizer.readToken(i.UINT16_BE),u=await this.tokenizer.readToken(i.UINT8),l=await this.tokenizer.readToken(i.UINT8),d=await this.tokenizer.readToken(i.UINT32_BE);f(`ABSS ${c}:${u}:${l}.${d}`);break;case"LSCO":const p=await this.tokenizer.readToken(i.UINT16_BE);f(`LSCO lsConfig=${p}`);break;case"COMT":default:f(`Unknown sound-property-chunk[ID=${t.chunkID}, size=${t.chunkSize}]`),await this.tokenizer.ignore(t.chunkSize)}const n=t.chunkSize-(this.tokenizer.position-r);n>0&&(f(`After Parsing sound-property-chunk ${t.chunkSize}, remaining ${n} bytes`),await this.tokenizer.ignore(n)),e-=u.ChunkHeader.len+t.chunkSize,f(`Parsing sound-property-chunks, remainingSize=${e}`)}if(this.metadata.format.lossless&&this.metadata.format.sampleRate&&this.metadata.format.numberOfChannels&&this.metadata.format.bitsPerSample){const e=this.metadata.format.sampleRate*this.metadata.format.numberOfChannels*this.metadata.format.bitsPerSample;this.metadata.setFormat("bitrate",e)}}async handleChannelChunks(e){f(`Parsing channel-chunks, remainingSize=${e}`);const t=[];for(;e>=s.FourCcToken.len;){const r=await this.tokenizer.readToken(s.FourCcToken);f(`Channel[ID=${r}]`),t.push(r),e-=s.FourCcToken.len}return f(`Channels: ${t.join(", ")}`),t}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(1),i=r(5);t.ChunkHeader={len:12,get:(e,t)=>({chunkID:i.FourCcToken.get(e,t),chunkSize:n.INT64_BE.get(e,t+4)})}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const n=r(36);t.ReadableWeToNodeStream=class extends n.Readable{constructor(e){super(),this.bytesRead=0,this.released=!1,this.reader=e.getReader()}async _read(){if(this.released)return void this.push(null);this.pendingRead=this.reader.read();const e=await this.pendingRead;delete this.pendingRead,e.done||this.released?this.push(null):(this.bytesRead+=e.value.length,this.push(e.value))}async waitForReadToComplete(){this.pendingRead&&await this.pendingRead}async close(){await this.syncAndRelease()}async syncAndRelease(){this.released=!0,await this.waitForReadToComplete(),await this.reader.releaseLock()}}},function(e,t,r){(function(t){var n=r(272).strict;e.exports=function(e){if(n(e)){var r=t.from(e.buffer);return e.byteLength!==e.buffer.byteLength&&(r=r.slice(e.byteOffset,e.byteOffset+e.byteLength)),r}return t.from(e)}}).call(this,r(3).Buffer)},function(e,t){e.exports=i,i.strict=a,i.loose=s;var r=Object.prototype.toString,n={"[object Int8Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Float32Array]":!0,"[object Float64Array]":!0};function i(e){return a(e)||s(e)}function a(e){return e instanceof Int8Array||e instanceof Int16Array||e instanceof Int32Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Uint16Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array}function s(e){return n[r.call(e)]}}]); \ No newline at end of file diff --git a/public/js/ilab-media-grid.js b/public/js/ilab-media-grid.js index 55656c91..b7865bf5 100755 --- a/public/js/ilab-media-grid.js +++ b/public/js/ilab-media-grid.js @@ -1 +1 @@ -!function(e){var t={};function n(i){if(t[i])return t[i].exports;var o=t[i]={i:i,l:!1,exports:{}};return e[i].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(i,o,function(t){return e[t]}.bind(null,o));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=176)}({176:function(e,t,n){n(177),e.exports=n(319)},177:function(e,t){function n(e,t,n){return t>=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}!function(e){var t=function(){e(".info-panel-tabs").each(function(){var t=e(this),n=null,i=null;t.find("li").each(function(){var t=e(this),o=e("#"+t.data("tab-target"));t.hasClass("active")&&(n=t,i=o),t.on("click",function(e){n!=t&&(n.removeClass("active"),i.css({display:"none"}),t.addClass("active"),o.css({display:""}),n=t,i=o)})})});var t=null;e(".info-file-info-size").each(function(){t||(t=e(this))}),e("#ilab-other-sizes").on("change",function(n){var i=e("#info-size-"+e(this).val());i!=t&&(t.css({display:"none"}),i.css({display:""}),t=i)}),e(".ilab-info-regenerate-thumbnails").on("click",function(t){var n=e(this);return!(n.data("imgix-enabled")&&!confirm("You are currently using Imgix, which makes this function rather unnecessary. Are you sure you want to continue?"))&&(e(document).trigger("ilab-regeneration-started"),t.preventDefault(),n.css({display:"none"}),e("#ilab-info-regenerate-status").css({display:""}),e.post(ajaxurl,{action:"ilab_regenerate_thumbnails_manual",post_id:n.data("post-id")},function(t){n.css({display:""}),e("#ilab-info-regenerate-status").css({display:"none"}),"success"!=t.status&&alert("There was a problem trying to regenerate the thumbnails. Please try again."),e(document).trigger("ilab-regeneration-ended")}),!1)})};t();var i=!0,o=!0,a=e('
'),s=e(''),r=e('
'),l=e('
'),u=e('
'),d=null,c=!1,p=0,f=function(){if(i){var n=e(this),o=n.data("post-id");n.data("mime-type").startsWith("image")?s.removeClass("ilab-popup-document"):s.addClass("ilab-popup-document"),c=!1,e("li.attachment").each(function(){var t=e(this);t.data("id")==o?(t.removeClass("info-unfocused"),t.addClass("info-focused")):(t.removeClass("info-focused"),t.addClass("info-unfocused"))}),r.text(""),r.append(a);var p=this.getBoundingClientRect(),f=document.body.scrollTop+(p.top+p.height/2-s.height()/2);f-=28;var m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),h=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g=document.body.scrollTop+m-40,v=0;f+s.height()>g?(v=f+s.height()-g,f=g-s.height()):f=e.left&&t<=e.right&&n>=e.top&&n<=e.bottom}!function(e){var t=function(){e(".info-panel-tabs").each(function(){var t=e(this),n=null,i=null;t.find("li").each(function(){var t=e(this),o=e("#"+t.data("tab-target"));t.hasClass("active")&&(n=t,i=o),t.on("click",function(e){n!=t&&(n.removeClass("active"),i.css({display:"none"}),t.addClass("active"),o.css({display:""}),n=t,i=o)})})});var t=null;e(".info-file-info-size").each(function(){t||(t=e(this))}),e("#ilab-other-sizes").on("change",function(n){var i=e("#info-size-"+e(this).val());i!=t&&(t.css({display:"none"}),i.css({display:""}),t=i)}),e(".ilab-info-regenerate-thumbnails").on("click",function(t){var n=e(this);return!(n.data("imgix-enabled")&&!confirm("You are currently using Imgix, which makes this function rather unnecessary. Are you sure you want to continue?"))&&(e(document).trigger("ilab-regeneration-started"),t.preventDefault(),n.css({display:"none"}),e("#ilab-info-regenerate-status").css({display:""}),e.post(ajaxurl,{action:"ilab_regenerate_thumbnails_manual",post_id:n.data("post-id")},function(t){n.css({display:""}),e("#ilab-info-regenerate-status").css({display:"none"}),"success"!=t.status&&alert("There was a problem trying to regenerate the thumbnails. Please try again."),e(document).trigger("ilab-regeneration-ended")}),!1)})};t();var i=!0,o=!0,a=e('
'),s=e(''),r=e('
'),l=e('
'),u=e('
'),d=null,c=!1,p=0,f=function(){if(i){var n=e(this),o=n.data("post-id");n.data("mime-type").startsWith("image")?s.removeClass("ilab-popup-document"):s.addClass("ilab-popup-document"),c=!1,e("li.attachment").each(function(){var t=e(this);t.data("id")==o?(t.removeClass("info-unfocused"),t.addClass("info-focused")):(t.removeClass("info-focused"),t.addClass("info-unfocused"))}),r.text(""),r.append(a);var p=this.getBoundingClientRect(),f=document.body.scrollTop+(p.top+p.height/2-s.height()/2);f-=28;var m=Math.max(document.documentElement.clientHeight,window.innerHeight||0),h=Math.max(document.documentElement.clientWidth,window.innerWidth||0),g=document.body.scrollTop+m-40,v=0;f+s.height()>g?(v=f+s.height()-g,f=g-s.height()):f>4&15]+e[15&t]}}}},286:function(t,e,i){t.exports=i(287)},287:function(t,e,i){"use strict";i(288),i(290),jQuery(document).ready(function(t){t("ul#adminmenu a[href$='https://talk.mediacloud.press']").attr("target","_blank"),t("ul#adminmenu a[href$='https://help.mediacloud.press']").attr("target","_blank"),t(".ilab_ajax_admin_item").each(function(){var e=t(this).find("input[name=nonce]").val(),i=t(this).find("input[name=action]").val();t(this).on("click",function(a){a.preventDefault();var n={action:i,nonce:e};return t.post(ajaxurl,n,function(t){t.hasOwnProperty("message")?alert(t.message):document.location.reload()}),!1})})})},288:function(t,e,i){"use strict";i(289),window.ILabCrop=function(t,e){this.settings=e,this.modalContainer=t("#ilabm-container-"+e.modal_id),this.cropper=this.modalContainer.find(".ilabc-cropper"),this.cropperData={},this.modal_id=e.modal_id,this.aspectCheckboxContainer=t("#ilab-crop-aspect-checkbox-container"),this.aspectCheckboxContainer.css({visibility:"hidden"});var i=this;t("#ilab-crop-aspect-checkbox").on("change",function(t){i.settings.isCrop||(this.checked?i.cropper.cropper("setAspectRatio",i.settings.aspect_ratio):i.cropper.cropper("setAspectRatio",Number.NaN))}),this.modalContainer.find(".ilabm-editor-tabs").ilabTabs({currentValue:this.settings.size,tabSelected:function(t){ILabModal.loadURL(t.data("url"),!0,function(t){this.bindUI(t)}.bind(this))}.bind(this)}),this.modalContainer.find(".ilabc-button-crop").on("click",function(t){return t.preventDefault(),this.crop(),!1}.bind(this)),this.modalContainer.find(".ilabc-button-reset-crop").on("click",function(t){return t.preventDefault(),this.resetCrop(),!1}.bind(this)),this.updatePreviewWidth=function(){var t=this.modalContainer.find(".ilab-crop-preview-title").width();this.modalContainer.find(".ilab-crop-preview").css({height:t/this.settings.aspect_ratio+"px",width:t+"px"})}.bind(this),this.bindUI=function(e){if(this.settings=e,e.isCrop?this.aspectCheckboxContainer.css({visibility:"hidden"}):this.aspectCheckboxContainer.css({visibility:"visible"}),this.cropper.cropper("destroy"),this.cropper.off("built.cropper"),e.hasOwnProperty("cropped_src")&&null!==e.cropped_src&&this.modalContainer.find(".ilab-current-crop-img").attr("src",e.cropped_src),e.hasOwnProperty("size_title")&&null!==e.size_title&&this.modalContainer.find(".ilabc-crop-size-title").text("Current "+e.size_title+" ("+e.min_width+" x "+e.min_height+")"),void 0!==e.aspect_ratio){if(this.updatePreviewWidth(),void 0!==e.prev_crop_x&&null!==e.prev_crop_x)this.cropperData={x:e.prev_crop_x,y:e.prev_crop_y,width:e.prev_crop_width,height:e.prev_crop_height};else if(2==e.crop_axis.length){var i=0,a=0;"center"==e.crop_axis[0]?i=e.image_width/2-e.real_crop_width/2:"right"==e.crop_axis[0]&&(i=e.image_width-e.real_crop_width),"center"==e.crop_axis[1]?a=e.image_height/2-e.real_crop_height/2:"right"==e.crop_axis[1]&&(a=e.image_height-e.real_crop_height),this.cropperData={x:i,y:a,width:e.real_crop_width,height:e.real_crop_height}}var n=e.aspect_ratio;e.isCrop||t("#ilab-crop-aspect-checkbox")[0].checked||(n=Number.NaN),this.cropper.on("built.cropper",function(){this.updatePreviewWidth()}.bind(this)).on("crop.cropper",function(t){}).cropper({viewMode:1,dragMode:"none",aspectRatio:n,minWidth:e.min_width,minHeight:e.min_height,modal:!0,movable:!1,cropBoxMovable:!0,zoomable:!1,zoomOnWheel:!1,zoomOnTouch:!1,autoCropArea:1,data:this.cropperData,checkImageOrigin:!1,checkCrossOrigin:!1,responsive:!0,restore:!0,preview:"#ilabm-container-"+this.modal_id+" .ilab-crop-preview"})}}.bind(this),this.crop=function(){this.displayStatus("Saving crop ...");var t=this.cropper.cropper("getData");t.action="ilab_perform_crop",t.post=this.settings.image_id,t.size=this.settings.size,jQuery.post(ajaxurl,t,function(t){var e=this.modalContainer.find(".ilab-current-crop-img");"ok"==t.status?e.attr("src")==t.src?this.hideStatus():(e.one("load",function(){this.hideStatus()}.bind(this)),e.attr("src",t.src),wp.media.model.Attachments.all._byId[this.settings.image_id].get("sizes")[this.settings.size].url=t.src):this.hideStatus()}.bind(this))}.bind(this),this.resetCrop=function(){this.displayStatus("Resetting crop ..."),this.cropper.cropper("reset");var t=this.cropper.cropper("getData");t.action="ilab_reset_crop",t.post=this.settings.image_id,t.size=this.settings.size,jQuery.post(ajaxurl,t,function(t){var e=this.modalContainer.find(".ilab-current-crop-img");"ok"==t.status?e.attr("src")==t.src?this.hideStatus():(e.one("load",function(){this.hideStatus()}.bind(this)),e.attr("src",t.src),wp.media.model.Attachments.all._byId[this.settings.image_id].get("sizes")[this.settings.size].url=t.src):this.hideStatus()}.bind(this))}.bind(this),this.displayStatus=function(t){this.modalContainer.find(".ilabm-status-label").text(t),this.modalContainer.find(".ilabm-status-container").removeClass("is-hidden")}.bind(this),this.hideStatus=function(){this.modalContainer.find(".ilabm-status-container").addClass("is-hidden")}.bind(this),this.bindUI(e)}},289:function(t,e,i){var a,n,o,s;function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function h(t){return(h="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(t){return r(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":r(t)})(t)}s=function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e="undefined"!=typeof window,i=e?window:{},a="cropper-hidden",n=i.PointerEvent?"pointerdown":"touchstart mousedown",o=i.PointerEvent?"pointermove":"touchmove mousemove",s=i.PointerEvent?"pointerup pointercancel":"touchend touchcancel mouseup",r=/^(?:e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/,c=/^data:/,l=/^data:image\/jpeg;base64,/,d=/^(?:img|canvas)$/i,p={viewMode:0,dragMode:"crop",aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},u="function"==typeof Symbol&&"symbol"===h(Symbol.iterator)?function(t){return h(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":h(t)},m=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},f=function(){function t(t,e){for(var i=0;i1?e-1:0),a=1;a0&&i.forEach(function(e){x(e)&&Object.keys(e).forEach(function(i){t[i]=e[i]})}),t},I=/\.\d*(?:0|9){12}\d*$/i;function S(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return I.test(t)?Math.round(t*e)/e:t}var B=/^(?:width|height|left|top|marginLeft|marginTop)$/;function P(t,e){var i=t.style;k(e,function(t,e){B.test(e)&&b(t)&&(t+="px"),i[e]=t})}function O(t,e){if(e)if(b(t.length))k(t,function(t){O(t,e)});else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className=i+" "+e):t.className=e}}function _(t,e){e&&(b(t.length)?k(t,function(t){_(t,e)}):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function T(t,e,i){e&&(b(t.length)?k(t,function(t){T(t,e,i)}):i?O(t,e):_(t,e))}var E=/([a-z\d])([A-Z])/g;function z(t){return t.replace(E,"$1-$2").toLowerCase()}function L(t,e){return x(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-"+z(e))}function W(t,e,i){x(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-"+z(e),i)}function A(t,e){if(x(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-"+z(e))}var N=/\s\s*/,j=function(){var t=!1;if(e){var a=!1,n=function(){},o=Object.defineProperty({},"once",{get:function(){return t=!0,a},set:function(t){a=t}});i.addEventListener("test",n,o),i.removeEventListener("test",n,o)}return t}();function H(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(N).forEach(function(e){if(!j){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)})}function R(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(N).forEach(function(e){if(a.once&&!j){var o=t.listeners,s=void 0===o?{}:o;n=function(){for(var o=arguments.length,r=Array(o),h=0;h1&&void 0!==arguments[1]?arguments[1]:"contain",o=function(t){return K(t)&&t>0};if(o(a)&&o(i)){var s=i*e;"contain"===n&&s>a||"cover"===n&&s=8&&(o=h+l)}}}if(o){var d=e.getUint16(o,a),p=void 0,u=void 0;for(u=0;ut.width?3===i?r=t.height*s:h=t.width/s:3===i?h=t.width/s:r=t.height*s;var c={aspectRatio:s,naturalWidth:n,naturalHeight:o,width:r,height:h};c.left=(t.width-r)/2,c.top=(t.height-h)/2,c.oldLeft=c.left,c.oldTop=c.top,this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),this.initialImageData=D({},e),this.initialCanvasData=D({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,s=i.viewMode,r=n.aspectRatio,h=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;s>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===s&&(l*r>c?c=l*r:l=c/r)):s>0&&(c?c=Math.max(c,h?o.width:0):l?l=Math.max(l,h?o.height:0):h&&(c=o.width,(l=o.height)*r>c?c=l*r:l=c/r));var d=Z({aspectRatio:r,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(s){var p=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,u),h&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===s&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=function(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),s=Math.cos(n),r=e*s+i*o,h=e*o+i*s;return a>90?{width:h,height:r}:{width:r,height:h}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,s=n.height,r=i.width*(o/i.naturalWidth),h=i.height*(s/i.naturalHeight);i.left-=(r-i.width)/2,i.top-=(h-i.height)/2,i.width=r,i.height=h,i.aspectRatio=o/s,i.naturalWidth=o,i.naturalHeight=s,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.widthi.maxHeight||i.heighte.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=D({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,s=this.limited,r=i.aspectRatio;if(t){var h=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=Math.min(a.width,s?n.width:a.width),d=Math.min(a.height,s?n.height:a.height);h=Math.min(h,a.width),c=Math.min(c,a.height),r&&(h&&c?c*r>h?c=h/r:h=c*r:h?c=h/r:c&&(h=c*r),d*r>l?d=l/r:l=d*r),o.minWidth=Math.min(h,l),o.minHeight=Math.min(c,d),o.maxWidth=l,o.maxHeight=d}e&&(s?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.widthi.maxHeight||i.height=e.width&&i.height>=e.height?"move":"all"),P(this.cropBox,D({width:i.width,height:i.height},Q({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),X(this.element,"crop",this.getData())}},at={initPreview:function(){var t=this.crossOrigin,e=this.options.preview,i=t?this.crossOriginUrl:this.url,a=document.createElement("img");if(t&&(a.crossOrigin=t),a.src=i,this.viewBox.appendChild(a),this.viewBoxImage=a,e){var n=e;"string"==typeof e?n=this.element.ownerDocument.querySelectorAll(e):e.querySelector&&(n=[e]),this.previews=n,k(n,function(e){var a=document.createElement("img");W(e,"preview",{width:e.offsetWidth,height:e.offsetHeight,html:e.innerHTML}),t&&(a.crossOrigin=t),a.src=i,a.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',e.innerHTML="",e.appendChild(a)})}},resetPreview:function(){k(this.previews,function(t){var e=L(t,"preview");P(t,{width:e.width,height:e.height}),t.innerHTML=e.html,A(t,"preview")})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,s=t.height,r=i.left-e.left-t.left,h=i.top-e.top-t.top;this.cropped&&!this.disabled&&(P(this.viewBoxImage,D({width:o,height:s},Q(D({translateX:-r,translateY:-h},t)))),k(this.previews,function(e){var i=L(e,"preview"),c=i.width,l=i.height,d=c,p=l,u=1;a&&(p=n*(u=c/a)),n&&p>l&&(d=a*(u=l/n),p=l),P(e,{width:d,height:p}),P(e.getElementsByTagName("img")[0],D({width:o*u,height:s*u},Q(D({translateX:-r*u,translateY:-h*u},t))))}))}},nt={bind:function(){var t=this.element,e=this.options,i=this.cropper;M(e.cropstart)&&R(t,"cropstart",e.cropstart),M(e.cropmove)&&R(t,"cropmove",e.cropmove),M(e.cropend)&&R(t,"cropend",e.cropend),M(e.crop)&&R(t,"crop",e.crop),M(e.zoom)&&R(t,"zoom",e.zoom),R(i,n,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&R(i,"wheel mousewheel DOMMouseScroll",this.onWheel=this.wheel.bind(this)),e.toggleDragModeOnDblclick&&R(i,"dblclick",this.onDblclick=this.dblclick.bind(this)),R(t.ownerDocument,o,this.onCropMove=this.cropMove.bind(this)),R(t.ownerDocument,s,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&R(window,"resize",this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;M(e.cropstart)&&H(t,"cropstart",e.cropstart),M(e.cropmove)&&H(t,"cropmove",e.cropmove),M(e.cropend)&&H(t,"cropend",e.cropend),M(e.crop)&&H(t,"crop",e.crop),M(e.zoom)&&H(t,"zoom",e.zoom),H(i,n,this.onCropStart),e.zoomable&&e.zoomOnWheel&&H(i,"wheel mousewheel DOMMouseScroll",this.onWheel),e.toggleDragModeOnDblclick&&H(i,"dblclick",this.onDblclick),H(t.ownerDocument,o,this.onCropMove),H(t.ownerDocument,s,this.onCropEnd),e.responsive&&H(window,"resize",this.onResize)}},ot={resize:function(){var t=this.options,e=this.container,i=this.containerData,a=Number(t.minContainerWidth)||200,n=Number(t.minContainerHeight)||100;if(!(this.disabled||i.width<=a||i.height<=n)){var o=e.offsetWidth/i.width;if(1!==o||e.offsetHeight!==i.height){var s=void 0,r=void 0;t.restore&&(s=this.getCanvasData(),r=this.getCropBoxData()),this.render(),t.restore&&(this.setCanvasData(k(s,function(t,e){s[e]=t*o})),this.setCropBoxData(k(r,function(t,e){r[e]=t*o})))}}},dblclick:function(){var t,e;this.disabled||"none"===this.options.dragMode||this.setDragMode((t=this.dragBox,e="cropper-crop",(t.classList?t.classList.contains(e):t.className.indexOf(e)>-1)?"move":"crop"))},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){if(!this.disabled){var e=this.options,i=this.pointers,a=void 0;t.changedTouches?k(t.changedTouches,function(t){i[t.identifier]=$(t)}):i[t.pointerId||0]=$(t),a=Object.keys(i).length>1&&e.zoomable&&e.zoomOnTouch?"zoom":L(t.target,"action"),r.test(a)&&!1!==X(this.element,"cropstart",{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,"crop"===a&&(this.cropping=!0,O(this.dragBox,"cropper-modal")))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==X(this.element,"cropmove",{originalEvent:t,action:e})&&(t.changedTouches?k(t.changedTouches,function(t){D(i[t.identifier],$(t,!0))}):D(i[t.pointerId||0],$(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?k(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,T(this.dragBox,"cropper-modal",this.cropped&&this.options.modal)),X(this.element,"cropend",{originalEvent:t,action:e}))}}},st={change:function(t){var e=this.options,i=this.canvasData,n=this.containerData,o=this.cropBoxData,s=this.pointers,r=this.action,h=e.aspectRatio,c=o.left,l=o.top,d=o.width,p=o.height,u=c+d,m=l+p,f=0,g=0,v=n.width,b=n.height,w=!0,x=void 0;!h&&t.shiftKey&&(h=d&&p?d/p:1),this.limited&&(f=o.minLeft,g=o.minTop,v=f+Math.min(n.width,i.width,i.left+i.width),b=g+Math.min(n.height,i.height,i.top+i.height));var y=s[Object.keys(s)[0]],C={x:y.endX-y.startX,y:y.endY-y.startY},M=function(t){switch(t){case"e":u+C.x>v&&(C.x=v-u);break;case"w":c+C.xb&&(C.y=b-m)}};switch(r){case"all":c+=C.x,l+=C.y;break;case"e":if(C.x>=0&&(u>=v||h&&(l<=g||m>=b))){w=!1;break}M("e"),d+=C.x,h&&(p=d/h,l-=C.x/h/2),d<0&&(r="w",d=0);break;case"n":if(C.y<=0&&(l<=g||h&&(c<=f||u>=v))){w=!1;break}M("n"),p-=C.y,l+=C.y,h&&(d=p*h,c+=C.y*h/2),p<0&&(r="s",p=0);break;case"w":if(C.x<=0&&(c<=f||h&&(l<=g||m>=b))){w=!1;break}M("w"),d-=C.x,c+=C.x,h&&(p=d/h,l+=C.x/h/2),d<0&&(r="e",d=0);break;case"s":if(C.y>=0&&(m>=b||h&&(c<=f||u>=v))){w=!1;break}M("s"),p+=C.y,h&&(d=p*h,c-=C.y*h/2),p<0&&(r="n",p=0);break;case"ne":if(h){if(C.y<=0&&(l<=g||u>=v)){w=!1;break}M("n"),p-=C.y,l+=C.y,d=p*h}else M("n"),M("e"),C.x>=0?ug&&(p-=C.y,l+=C.y):(p-=C.y,l+=C.y);d<0&&p<0?(r="sw",p=0,d=0):d<0?(r="nw",d=0):p<0&&(r="se",p=0);break;case"nw":if(h){if(C.y<=0&&(l<=g||c<=f)){w=!1;break}M("n"),p-=C.y,l+=C.y,d=p*h,c+=C.y*h}else M("n"),M("w"),C.x<=0?c>f?(d-=C.x,c+=C.x):C.y<=0&&l<=g&&(w=!1):(d-=C.x,c+=C.x),C.y<=0?l>g&&(p-=C.y,l+=C.y):(p-=C.y,l+=C.y);d<0&&p<0?(r="se",p=0,d=0):d<0?(r="ne",d=0):p<0&&(r="sw",p=0);break;case"sw":if(h){if(C.x<=0&&(c<=f||m>=b)){w=!1;break}M("w"),d-=C.x,c+=C.x,p=d/h}else M("s"),M("w"),C.x<=0?c>f?(d-=C.x,c+=C.x):C.y>=0&&m>=b&&(w=!1):(d-=C.x,c+=C.x),C.y>=0?m=0&&(u>=v||m>=b)){w=!1;break}M("e"),p=(d+=C.x)/h}else M("s"),M("e"),C.x>=0?u=0&&m>=b&&(w=!1):d+=C.x,C.y>=0?m0?r=C.y>0?"se":"ne":C.x<0&&(c-=d,r=C.y>0?"sw":"nw"),C.y<0&&(l-=p),this.cropped||(_(this.cropBox,a),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}w&&(o.width=d,o.height=p,o.left=c,o.top=l,this.action=r,this.renderCropBox()),k(s,function(t){t.startX=t.endX,t.startY=t.endY})}},rt={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&O(this.dragBox,"cropper-modal"),_(this.cropBox,a),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=D({},this.initialImageData),this.canvasData=D({},this.initialCanvasData),this.cropBoxData=D({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(D(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),_(this.dragBox,"cropper-modal"),O(this.cropBox,a)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,k(this.previews,function(e){e.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,_(this.cropper,"cropper-disabled")),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,O(this.cropper,"cropper-disabled")),this},destroy:function(){var t=this.element;return L(t,"cropper")?(this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),A(t,"cropper"),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(w(t)?t:a+Number(t),w(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(b(t)&&(i.left=t,a=!0),b(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,s=n.height,r=n.naturalWidth,h=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var c=r*t,l=h*t;if(!1===X(this.element,"zoom",{originalEvent:i,oldRatio:o/r,ratio:c/r}))return this;if(i){var d=this.pointers,p=Y(this.cropper),u=d&&Object.keys(d).length?function(t){var e=0,i=0,a=0;return k(t,function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1}),{pageX:e/=a,pageY:i/=a}}(d):{pageX:i.pageX,pageY:i.pageY};n.left-=(c-o)*((u.pageX-p.left-n.left)/o),n.top-=(l-s)*((u.pageY-p.top-n.top)/s)}else C(e)&&b(e.x)&&b(e.y)?(n.left-=(c-o)*((e.x-n.left)/o),n.top-=(l-s)*((e.y-n.top)/s)):(n.left-=(c-o)/2,n.top-=(l-s)/2);n.width=c,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return b(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,b(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(b(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(b(t)&&(i.scaleX=t,a=!0),b(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.options,i=this.imageData,a=this.canvasData,n=this.cropBoxData,o=void 0;if(this.ready&&this.cropped){o={x:n.left-a.left,y:n.top-a.top,width:n.width,height:n.height};var s=i.width/i.naturalWidth;k(o,function(e,i){e/=s,o[i]=t?Math.round(e):e})}else o={x:0,y:0,width:0,height:0};return e.rotatable&&(o.rotate=i.rotate||0),e.scalable&&(o.scaleX=i.scaleX||1,o.scaleY=i.scaleY||1),o},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&C(t)){var o=!1;e.rotatable&&b(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(b(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),b(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var s=i.width/i.naturalWidth;b(t.x)&&(n.left=t.x*s+a.left),b(t.y)&&(n.top=t.y*s+a.top),b(t.width)&&(n.width=t.width*s),b(t.height)&&(n.height=t.height*s),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?D({},this.containerData):{}},getImageData:function(){return this.sized?D({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&k(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&C(t)&&(b(t.left)&&(e.left=t.left),b(t.top)&&(e.top=t.top),b(t.width)?(e.width=t.width,e.height=t.width/i):b(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t=this.cropBoxData,e=void 0;return this.ready&&this.cropped&&(e={left:t.left,top:t.top,width:t.width,height:t.height}),e||{}},setCropBoxData:function(t){var e=this.cropBoxData,i=this.options.aspectRatio,a=void 0,n=void 0;return this.ready&&this.cropped&&!this.disabled&&C(t)&&(b(t.left)&&(e.left=t.left),b(t.top)&&(e.top=t.top),b(t.width)&&t.width!==e.width&&(a=!0,e.width=t.width),b(t.height)&&t.height!==e.height&&(n=!0,e.height=t.height),i&&(a?e.height=e.width/i:n&&(e.width=e.height*i)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=J(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(),n=a.x,o=a.y,s=a.width,r=a.height,h=i.width/Math.floor(e.naturalWidth);1!==h&&(n*=h,o*=h,s*=h,r*=h);var c=s/r,l=Z({aspectRatio:c,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),d=Z({aspectRatio:c,width:t.minWidth||0,height:t.minHeight||0},"cover"),p=Z({aspectRatio:c,width:t.width||(1!==h?i.width:s),height:t.height||(1!==h?i.height:r)}),u=p.width,m=p.height;u=Math.min(l.width,Math.max(d.width,u)),m=Math.min(l.height,Math.max(d.height,m));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=S(u),f.height=S(m),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,u,m);var b=t.imageSmoothingEnabled,w=void 0===b||b,x=t.imageSmoothingQuality;v.imageSmoothingEnabled=w,x&&(v.imageSmoothingQuality=x);var y=i.width,C=i.height,M=n,k=o,D=void 0,I=void 0,B=void 0,P=void 0,O=void 0,_=void 0;M<=-s||M>y?(M=0,D=0,B=0,O=0):M<=0?(B=-M,M=0,O=D=Math.min(y,s+M)):M<=y&&(B=0,O=D=Math.min(s,y-M)),D<=0||k<=-r||k>C?(k=0,I=0,P=0,_=0):k<=0?(P=-k,k=0,_=I=Math.min(C,r+k)):k<=C&&(P=0,_=I=Math.min(r,C-k));var T=[M,k,D,I];if(O>0&&_>0){var E=u/s;T.push(B*E,P*E,O*E,_*E)}return v.drawImage.apply(v,[i].concat(g(T.map(function(t){return Math.floor(S(t))})))),f},setAspectRatio:function(t){var e=this.options;return this.disabled||w(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n="crop"===t,o=e.movable&&"move"===t;t=n||o?t:"none",e.dragMode=t,W(i,"action",t),T(i,"cropper-crop",n),T(i,"cropper-move",o),e.cropBoxMovable||(W(a,"action",t),T(a,"cropper-crop",n),T(a,"cropper-move",o))}return this}},ht=i.Cropper,ct=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(m(this,t),!e||!d.test(e.tagName))throw new Error("The first argument is required and must be an or element.");this.element=e,this.options=D({},p,C(i)&&i),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return f(t,[{key:"init",value:function(){var t=this.element,e=t.tagName.toLowerCase(),i=void 0;if(!L(t,"cropper")){if(W(t,"cropper",this),"img"===e){if(this.isImg=!0,i=t.getAttribute("src")||"",this.originalUrl=i,!i)return;i=t.src}else"canvas"===e&&window.HTMLCanvasElement&&(i=t.toDataURL());this.load(i)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.checkOrientation&&window.ArrayBuffer)if(c.test(t))l.test(t)?this.read((n=t.replace(tt,""),o=atob(n),s=new ArrayBuffer(o.length),k(r=new Uint8Array(s),function(t,e){r[e]=o.charCodeAt(e)}),s)):this.clone();else{var n,o,s,r,h=new XMLHttpRequest;this.reloading=!0,this.xhr=h;var d=function(){e.reloading=!1,e.xhr=null};h.ontimeout=d,h.onabort=d,h.onerror=function(){d(),e.clone()},h.onload=function(){d(),e.read(h.response)},a.checkCrossOrigin&&V(t)&&i.crossOrigin&&(t=q(t)),h.open("get",t),h.responseType="arraybuffer",h.withCredentials="use-credentials"===i.crossOrigin,h.send()}else this.clone()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=et(t),n=0,o=1,s=1;if(a>1){this.url=function(t,e){var i=new Uint8Array(t),a="";return k(i,function(t){a+=G(t)}),"data:"+e+";base64,"+btoa(a)}(t,"image/jpeg");var r=function(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}(a);n=r.rotate,o=r.scaleX,s=r.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=s),this.clone()}},{key:"clone",value:function(){var t=this.element,e=this.url,i=void 0,a=void 0;this.options.checkCrossOrigin&&V(e)&&((i=t.crossOrigin)?a=e:(i="anonymous",a=q(e))),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e;var o=this.start.bind(this),s=this.stop.bind(this);this.image=n,this.onStart=o,this.onStop=s,this.isImg?t.complete?this.timeout=setTimeout(o,0):R(t,"load",o,{once:!0}):(n.onload=o,n.onerror=s,O(n,"cropper-hide"),t.parentNode.insertBefore(n,t.nextSibling))}},{key:"start",value:function(t){var e=this,a=this.isImg?this.element:this.image;t&&(a.onload=null,a.onerror=null),this.sizing=!0;var n=i.navigator&&/(Macintosh|iPhone|iPod|iPad).*AppleWebKit/i.test(i.navigator.userAgent),o=function(t,i){D(e.imageData,{naturalWidth:t,naturalHeight:i,aspectRatio:t/i}),e.sizing=!1,e.sized=!0,e.build()};if(!a.naturalWidth||n){var s=document.createElement("img"),r=document.body||document.documentElement;this.sizingImage=s,s.onload=function(){o(s.width,s.height),n||r.removeChild(s)},s.src=a.src,n||(s.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",r.appendChild(s))}else o(a.naturalWidth,a.naturalHeight)}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,n=t.parentNode,o=document.createElement("div");o.innerHTML='
';var s=o.querySelector(".cropper-container"),r=s.querySelector(".cropper-canvas"),h=s.querySelector(".cropper-drag-box"),c=s.querySelector(".cropper-crop-box"),l=c.querySelector(".cropper-face");this.container=n,this.cropper=s,this.canvas=r,this.dragBox=h,this.cropBox=c,this.viewBox=s.querySelector(".cropper-view-box"),this.face=l,r.appendChild(i),O(t,a),n.insertBefore(s,t.nextSibling),this.isImg||_(i,"cropper-hide"),this.initPreview(),this.bind(),e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,O(c,a),e.guides||O(c.getElementsByClassName("cropper-dashed"),a),e.center||O(c.getElementsByClassName("cropper-center"),a),e.background&&O(s,"cropper-bg"),e.highlight||O(l,"cropper-invisible"),e.cropBoxMovable&&(O(l,"cropper-move"),W(l,"action","all")),e.cropBoxResizable||(O(c.getElementsByClassName("cropper-line"),a),O(c.getElementsByClassName("cropper-point"),a)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),M(e.ready)&&R(t,"ready",e.ready,{once:!0}),X(t,"ready")}}},{key:"unbuild",value:function(){this.ready&&(this.ready=!1,this.unbind(),this.resetPreview(),this.cropper.parentNode.removeChild(this.cropper),_(this.element,a))}},{key:"uncreate",value:function(){var t=this.element;this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?this.xhr.abort():this.isImg?t.complete?clearTimeout(this.timeout):H(t,"load",this.onStart):this.image&&this.stop()}}],[{key:"noConflict",value:function(){return window.Cropper=ht,t}},{key:"setDefaults",value:function(t){D(p,C(t)&&t)}}]),t}();if(D(ct.prototype,it,at,nt,ot,st,rt),t.fn){var lt=t.fn.cropper;t.fn.cropper=function(e){for(var i=arguments.length,a=Array(i>1?i-1:0),n=1;n