diff --git a/.browserslistrc b/.browserslistrc
new file mode 100644
index 0000000..f42fae3
--- /dev/null
+++ b/.browserslistrc
@@ -0,0 +1,5 @@
+# Browsers that we support
+
+last 3 version
+> 0.3%
+not dead # no browsers without security updates
diff --git a/.dockerignore b/.dockerignore
new file mode 100644
index 0000000..fac5ce7
--- /dev/null
+++ b/.dockerignore
@@ -0,0 +1,2 @@
+.git
+*.md
diff --git a/.editorconfig b/.editorconfig
index 6537ca4..2e1b261 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -3,9 +3,9 @@ root = true
[*]
charset = utf-8
end_of_line = lf
-insert_final_newline = true
-indent_style = space
indent_size = 4
+indent_style = space
+insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
@@ -13,3 +13,9 @@ trim_trailing_whitespace = false
[*.{yml,yaml}]
indent_size = 2
+
+[docker-compose.yml]
+indent_size = 4
+
+[*.vue]
+indent_size = 2
diff --git a/.env.example b/.env.example
index a2a3324..d47d429 100644
--- a/.env.example
+++ b/.env.example
@@ -5,20 +5,29 @@ APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
+LOG_DEPRECATIONS_CHANNEL=null
+LOG_LEVEL=debug
DB_CONNECTION=mysql
-DB_HOST=dev-mariadb
+DB_HOST=127.0.0.1
DB_PORT=3306
-DB_DATABASE=
+DB_DATABASE=laravel
DB_USERNAME=root
-DB_PASSWORD=secret
+DB_PASSWORD=
BROADCAST_DRIVER=log
CACHE_DRIVER=file
-QUEUE_CONNECTION=database
+FILESYSTEM_DISK=local
+QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
+MEMCACHED_HOST=127.0.0.1
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
MAIL_MAILER=smtp
MAIL_HOST=dev-mailhog
MAIL_PORT=1025
@@ -29,9 +38,33 @@ MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
MAIL_ADMIN=equipe.web@ldc.fr
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+AWS_USE_PATH_STYLE_ENDPOINT=false
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_HOST=
+PUSHER_PORT=443
+PUSHER_SCHEME=https
+PUSHER_APP_CLUSTER=mt1
+
+VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+VITE_PUSHER_HOST="${PUSHER_HOST}"
+VITE_PUSHER_PORT="${PUSHER_PORT}"
+VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
+VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+# Sentry
+SENTRY_LARAVEL_DSN=
+
# CRM
CRM_ENDPOINT=
CRM_TOKEN=
+CRM_PASSWORD=
# MESBR
MESBR_ENDPOINT=
diff --git a/.eslintrc.json b/.eslintrc.json
new file mode 100644
index 0000000..4acf8d1
--- /dev/null
+++ b/.eslintrc.json
@@ -0,0 +1,61 @@
+{
+ "env": {
+ "browser": true,
+ "es2021": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:vue/vue3-strongly-recommended",
+ "@vue/eslint-config-typescript"
+ ],
+ "overrides": [
+ {
+ "files": ["*.ts", "*.vue"],
+ "rules": {
+ "no-undef": "off"
+ }
+ },
+ {
+ "files": ["*.vue"],
+ "rules": {
+ "indent": "off"
+ }
+ }
+ ],
+ "parser": "vue-eslint-parser",
+ "parserOptions": {
+ "parser": "@typescript-eslint/parser",
+ "ecmaVersion": "latest",
+ "sourceType": "module"
+ },
+ "plugins": ["vue", "@typescript-eslint"],
+ "ignorePatterns": [
+ "**/*.php",
+ "**/*.svg",
+ "**/vendor/*.js",
+ "**/vendor/**/*.js",
+ "**/vendor/**/*.scss"
+ ],
+ "rules": {
+ "indent": ["error", 4, { "SwitchCase": 1 }],
+ "linebreak-style": ["error", "unix"],
+ "quotes": ["error", "double"],
+ "semi": ["error", "always"],
+ "vue/script-indent": ["error", 2, { "baseIndent": 0, "switchCase": 1 }],
+ "vue/one-component-per-file": "off"
+ },
+ "settings": {
+ "import/resolver": {
+ "node": {
+ "extensions": [".js", ".vue", ".ts", ".d.ts"]
+ },
+ "alias": {
+ "extensions": [".vue", ".js", ".ts", ".scss", ".d.ts"],
+ "map": [
+ ["~", "./resources/assets"],
+ ["@", "./node_modules"]
+ ]
+ }
+ }
+ }
+}
diff --git a/.gitattributes b/.gitattributes
index 967315d..fcb21d3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,5 +1,11 @@
-* text=auto
-*.css linguist-vendored
-*.scss linguist-vendored
-*.js linguist-vendored
+* text=auto eol=lf
+
+*.blade.php diff=html
+*.css diff=css
+*.html diff=html
+*.md diff=markdown
+*.php diff=php
+
+/.github export-ignore
CHANGELOG.md export-ignore
+.styleci.yml export-ignore
diff --git a/.gitignore b/.gitignore
index a1ceeb0..b507967 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,32 +1,43 @@
-public/front/*
+.env
+.env.backup
+.env.production
+.phpunit.result.cache
+.stylelintcache
+/.fleet
+/.idea
+/.phpunit.cache
+/.vscode
/node_modules
+/bootstrap
+/public/build
+/public/cache
/public/hot
+/public/sitemap.xml
/public/storage
-/public/fichiers
-/public/images/produits
-/public/images/ranges
-/public/css/*
-/public/js/*
-resources/views/errors/*
-resources/views/front/basic/*
-mix-manifest.json
/storage/*.key
/vendor
-/resources/views/front/basic
-.env
-.env.dev
-.env.prod
-.env.backup
-.phpunit.result.cache
+auth.json
+docker-compose.override.yml
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log
-package-lock.json
-composer.lock
-resources/front
-resources/js/basic.js
-.vscode
+.npmrc
+/resources/theme
+# https://lab.s-web.fr/ldc-web/projets/gen-game-web/-/issues/17
+public/fichiers
storage
-README.txt
-webpack.mix.js
+resources/theme
+
+# Ignore public favicon
+/public/android-chrome-192x192.png
+/public/android-chrome-512x512.png
+/public/apple-touch-icon.png
+/public/browserconfig.xml
+/public/browserconfig.xml
+/public/favicon-16x16.png
+/public/favicon-32x32.png
+/public/favicon.ico
+/public/mstile-150x150.png
+/public/safari-pinned-tab.svg
+/public/site.webmanifest
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 9452827..219a6c1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,46 +1,24 @@
-image: $CI_REGISTRY/service-web-lab/ldc-web-images-docker/ldcweb-qa:php7.3-1.0
+include:
+ - project: 'ldc-web/shared-ci'
+ ref: 'main'
+ file: 'lint/lint.yml'
+ - project: 'ldc-web/shared-ci'
+ ref: 'main'
+ file: 'security/security.yml'
+ - project: 'ldc-web/shared-ci'
+ ref: 'main'
+ file: 'build/build.yml'
+ - project: 'ldc-web/shared-ci'
+ ref: 'main'
+ file: 'test/test.yml'
+ - project: 'ldc-web/shared-ci'
+ ref: 'main'
+ file: 'deploy/deploy.yml'
+
stages:
- - Security
- - CodingStandards
-
-composer-security:
- stage: Security
- script:
- - local-php-security-checker --format=json --path=./composer.lock > composer-security-checker-report.json
- artifacts:
- when: on_failure
- expose_as: 'composer-security-checker'
- paths:
- - composer-security-checker-report.json
- allow_failure: true
-
-npm-security:
- stage: Security
- script:
- - audit-ci -p npm -o json > npm-security-checker-report.json
- artifacts:
- when: on_failure
- expose_as: 'npm-security-checker'
- paths:
- - npm-security-checker-report.json
- allow_failure: true
-
-phpcs:
- stage: CodingStandards
- before_script:
- - composer config gitlab-token.gitlab.com $CI_DEPLOY_USER $CI_DEPLOY_PASSWORD
- - composer install
- cache:
- paths:
- - vendor/
- script:
- - vendor/bin/phpcs --report=junit --report-file=phpcs-report.xml
- artifacts:
- when: on_failure
- expose_as: 'phpcs'
- paths:
- - phpcs-report.xml
- reports:
- junit: phpcs-report.xml
- allow_failure: false
+ - lint
+ - security
+ - build
+ - test
+ - deploy
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..988fea8
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "resources/theme"]
+ path = resources/theme
+ url = ../gen-game-web-themes/theme-merger.git
diff --git a/.styleci.yml b/.styleci.yml
deleted file mode 100644
index 1db61d9..0000000
--- a/.styleci.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-php:
- preset: laravel
- disabled:
- - unused_use
- finder:
- not-name:
- - index.php
- - server.php
-js:
- finder:
- not-name:
- - webpack.mix.js
-css: true
diff --git a/.stylelintrc.json b/.stylelintrc.json
new file mode 100644
index 0000000..94702b9
--- /dev/null
+++ b/.stylelintrc.json
@@ -0,0 +1,45 @@
+{
+ "extends": [
+ "stylelint-config-standard-scss",
+ "stylelint-config-sass-guidelines",
+ "stylelint-config-idiomatic-order"
+ ],
+ "plugins": [
+ "stylelint-scss"
+ ],
+ "files": [
+ "**/*.css",
+ "**/*.scss"
+ ],
+ "ignoreFiles": [
+ "**/vendor/*.css",
+ "**/vendor/**/*.css",
+ "**/vendor/*.scss",
+ "**/vendor/**/*.scss",
+ "**/vendor/*.sass",
+ "**/vendor/**/*.sass",
+ "**/vendor/*.less",
+ "**/vendor/**/*.less"
+ ],
+ "customSyntax": "postcss-scss",
+ "rules": {
+ "declaration-property-value-no-unknown": true,
+ "selector-max-id": null,
+ "color-no-invalid-hex": true,
+ "order/properties-alphabetical-order": null,
+ "max-nesting-depth": 5,
+ "selector-max-compound-selectors": 5,
+ "declaration-colon-newline-after": null,
+ "value-list-comma-newline-after": null,
+ "scss/double-slash-comment-empty-line-before": [
+ "always",
+ {
+ "ignore": [
+ "between-comments",
+ "stylelint-commands",
+ "inside-block"
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..7636f13
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,22 @@
+{
+ "workbench.colorCustomizations": {
+ "activityBar.activeBackground": "#962a40",
+ "activityBar.background": "#962a40",
+ "activityBar.foreground": "#e7e7e7",
+ "activityBar.inactiveForeground": "#e7e7e799",
+ "activityBarBadge.background": "#40952a",
+ "activityBarBadge.foreground": "#e7e7e7",
+ "commandCenter.border": "#e7e7e799",
+ "sash.hoverBorder": "#962a40",
+ "statusBar.background": "#6e1f2f",
+ "statusBar.foreground": "#e7e7e7",
+ "statusBarItem.hoverBackground": "#962a40",
+ "statusBarItem.remoteBackground": "#6e1f2f",
+ "statusBarItem.remoteForeground": "#e7e7e7",
+ "titleBar.activeBackground": "#6e1f2f",
+ "titleBar.activeForeground": "#e7e7e7",
+ "titleBar.inactiveBackground": "#6e1f2f99",
+ "titleBar.inactiveForeground": "#e7e7e799"
+ },
+ "peacock.remoteColor": "#6e1f2f"
+}
diff --git a/README.md b/README.md
index 68d37bd..48884dc 100644
--- a/README.md
+++ b/README.md
@@ -1,23 +1,59 @@
# GEN GAME WEB
+
## Installation
-```
+
+``` Bash
cp .env.example .env
php artisan key:generate /!\ bien sauvegarder la key
-php artisan migrate --seed
+php artisan migrate:fresh --step
+# Seulement pour developper un theme par exemple
+php artisan db:seed --class DevelopmentSeeder
+php artisan uwil:user:create
```
## Création du compte Admin
-```
-php artisan create:admin
+
+``` Bash
+php artisan uwil:user:create
```
-## CRON
-```
-php artisan users:deletenc à mettre 1 fois par jour
+## Ajouter Parametrage du jeu
+
+**Les lots sont à ajouter avant de générer les instants gagants**. En effet les instants gagants sont liés à des lots.
+
+
+## Générer des coupons et les mails
+
+``` Bash
+artisan queue:work
```
-## TODO
-```
-- SH - Soucis de connexion / déconnexion quand le jeu est terminé et que l'adresse du jeu redirige vers une autre adresse : si on se déconnecte et qu'on revient sur le bo, on est toujours connecté
- -> MJ - Pour que le cookie soit delete il ne faut pas renvoyer un 302 juste apres le disconnect
+En cas de manipulation pourrie, penser a vider le cache pour supprimer le lock
+sur le job de generation des codes.
+
+## THEME
+
+### Instalation
+
+Pour installer le theme bien **mettre à jour les submodules avec git**,
+`git submodule update init --recursive`
+
+puis utiliser la commande `php artisan theme:switch NOM_DU_THEME` et `php artisan optimize:clear && php artisan optimize`
+
+Pour mettre a jour la liste des themes :
+
+### Mise à jour
+
+**Note** : cette partie n'est pas encore certaine.
+
+- Mettre à jour `git submodule update --remote --merge resources/theme`
+ Ou
+
+``` Bash
+cd resources/themes;
+git pull origin main;
+cd ../..;
+git add resources/themes
```
+
+Puis commit.
diff --git a/app/Auth/CrmUserProvider.php b/app/Auth/CrmUserProvider.php
new file mode 100644
index 0000000..9eee664
--- /dev/null
+++ b/app/Auth/CrmUserProvider.php
@@ -0,0 +1,179 @@
+getCustomer($credentials['email']);
+
+ if (!$crmCustomer) {
+ // * Customer is not found on CRM.
+ return null;
+ }
+ $model = $this->createLocalCustomer($crmCustomer);
+ }
+
+ return $model;
+ } catch (ApiErrorException $e) {
+ // * Customer is not found.
+ if ($e->getApiError()->equals(ApiError::modelNotFound())) {
+ return null;
+ }
+ report($e);
+ Log::error('Unhandled response ' . $e->getApiError()->label);
+ } catch (CrmException | \Exception $e) {
+ report($e);
+ // Une erreur critique est survenue avec la CRM.
+ return null;
+ } //end try
+ Log::error(__CLASS__ . '::retrieveByCredentials reached end of possibilities.');
+ return null;
+ }
+
+ /**
+ * Validate a user against the given credentials.
+ *
+ * @param UserContract $model
+ * @param array $credentials
+ * @return boolean
+ * @throws \RuntimeException If model provided is not a Customer or connection to server fails.
+ * @throws \LDC\LDCCRM\Exceptions\CrmException On CRM call error.
+ * @throws \Exception On CRM call error.
+ */
+ public function validateCredentials(UserContract $model, array $credentials)
+ {
+ /** @var \Illuminate\Database\Eloquent\Model $model */
+ if (\get_class($model) !== $this->usedModel) {
+ throw new \RuntimeException('Cannot authenticate any thing else than ' . $this->usedModel);
+ }
+
+ try {
+ /** @var \LDC\LDCCRM\CrmApiV2 */
+ $crm = app('crmAPI');
+
+ // * If has trait soft delete and customer trashed, then restore customer.
+ if (
+ \in_array(\Illuminate\Database\Eloquent\SoftDeletes::class, \class_uses_recursive($model)) and
+ $model->trashed()
+ ) {
+ $model->restore();
+ }
+
+ // * Ne devrait pas survenir, $crm->login throws ApiError::authFailed()
+ return $crm->login($credentials['email'], $credentials['password']);
+ } catch (ApiErrorException $e) {
+ if (!$model->hashcode or !CrmCustomer::find($model->hashcode)) {
+ $model->forceDelete();
+ return false;
+ }
+ if ($e->getApiError()->equals(ApiError::authFailed())) {
+ return false;
+ }
+ // ! Assert Authenticable model must be valided (MustValidate trait).
+ if ($e->getApiError()->equals(ApiError::customerNotActivated())) {
+ Session::flash('warning', \trans('Vous devez activer votre compte'));
+ return true;
+ }
+ } catch (CrmException | \Exception $e) {
+ report($e);
+ if (config('app.debug')) {
+ throw $e;
+ }
+ return false;
+ } //end try
+
+ Log::error(__CLASS__ . '::validateCredentials reached end of possibilities.');
+ return null;
+ }
+
+ /**
+ * Create a local customer
+ *
+ * @param \LDC\LDCCRM\Models\Customer $crmCustomer
+ * @return \Illuminate\Database\Eloquent\Model
+ * @throws \Throwable If saving to DB failed.
+ */
+ private function createLocalCustomer(\LDC\LDCCRM\Models\Customer $crmCustomer): Model
+ {
+ /** @var \Illuminate\Database\Eloquent\Model $model */
+ $model = $this->usedModel::firstOrNew([
+ 'email' => $crmCustomer->email
+ ]);
+ $model->hashcode = $crmCustomer->hashcode;
+ $model->email_verified_at = $crmCustomer->status ? now() : null;
+ $model->saveOrFail();
+
+ return $model;
+ }
+
+ /**
+ * Retrieve a trashed customer by the given credentials.
+ *
+ * @param array $credentials
+ * @return \Illuminate\Contracts\Auth\Authenticatable|null
+ * @throws \ErrorException If cannot connect to LDAP.
+ */
+ private function retrieveTrashed(array $credentials): ?Authenticatable
+ {
+ // * Make changes
+ if (empty($credentials)) {
+ return null;
+ }
+
+ // First we will add each credential element to the query as a where clause.
+ // Then we can execute the query and, if we found a customer, return it in a
+ // Eloquent User "model" that will be utilized by the Guard instances.
+ $query = $this->createModel()->newQuery();
+
+ foreach ($credentials as $key => $value) {
+ if (!Str::contains($key, 'password')) {
+ $query->where($key, $value);
+ }
+ }
+
+ /** @var \App\Models\Customer|null $customer */
+ return $query->withTrashed()->first();
+ }
+}
diff --git a/app/Auth/ReactivateCustomerProvider.php b/app/Auth/ReactivateCustomerProvider.php
new file mode 100644
index 0000000..4bfa1df
--- /dev/null
+++ b/app/Auth/ReactivateCustomerProvider.php
@@ -0,0 +1,71 @@
+createModel()->newQuery();
+
+ foreach ($credentials as $key => $value) {
+ if (!Str::contains($key, 'password')) {
+ $query->where($key, $value);
+ }
+ }
+
+ /** @var \App\Models\Customer|null $customer */
+ return $query->withTrashed()->first();
+ }
+
+ /**
+ * Validate a customer against the given credentials.
+ *
+ * @param \Illuminate\Contracts\Auth\Authenticatable $customer
+ * @param array $credentials
+ * @return boolean
+ * @throws \ErrorException If model provided is not a Customer or connection to server fails.
+ */
+ public function validateCredentials(Authenticatable $customer, array $credentials)
+ {
+ /** @var \App\Models\Customer $customer */
+ if ($customer instanceof Customer) {
+ throw new \ErrorException('Cannot authenticate any thing else than ' . Customer::class);
+ }
+
+ $plain = $credentials['password'];
+
+ /** @var \App\Models\Customer $customer */
+ if ($this->hasher->check($plain, $customer->getAuthPassword())) {
+ // * Restore customer
+ return boolval($customer->restore());
+ }
+
+ return false;
+ }
+}
diff --git a/app/Casts/AsArrayOfDiscount.php b/app/Casts/AsArrayOfDiscount.php
new file mode 100644
index 0000000..ca92c0a
--- /dev/null
+++ b/app/Casts/AsArrayOfDiscount.php
@@ -0,0 +1,46 @@
+
+ * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
+ */
+ public function get($model, string $key, $value, array $attributes): array
+ {
+ // phpcs:enable
+ return \collect(\json_decode($value, true))->map(function ($input) use ($model, $key, $attributes) {
+ $inputCast = new AsDiscount();
+ return $inputCast->get($model, $key, \json_encode($input), $attributes);
+ })->all();
+ }
+
+ /**
+ * Prepare the given value for storage.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @param string $key
+ * @param \App\Lib\Discount $value
+ * @param array $attributes
+ * @return string Json encoded array<\App\Lib\Discount>
+ * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
+ */
+ public function set($model, string $key, $value, array $attributes)
+ {
+ // phpcs:enable
+ return \json_encode(\collect($value)->map(function ($input) use ($model, $key, $attributes) {
+ $inputCast = new AsDiscount();
+ return \json_decode($inputCast->set($model, $key, $input, $attributes));
+ })->all());
+ }
+}
diff --git a/app/Casts/AsDiscount.php b/app/Casts/AsDiscount.php
new file mode 100644
index 0000000..3310b58
--- /dev/null
+++ b/app/Casts/AsDiscount.php
@@ -0,0 +1,67 @@
+ $data */
+ $inputData = \json_decode($value, true);
+ return Discount::make(...\array_values($inputData));
+ }
+
+ /**
+ * Prepare the given value for storage.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @param string $key
+ * @param mixed $value
+ * @param array $attributes
+ * @return string Json encoded \App\Lib\Inputs\Definition\Input
+ * @phpcs:disable Squiz.Commenting.FunctionComment.TypeHintMissing
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
+ */
+ public function set($model, string $key, $value, array $attributes)
+ {
+ // phpcs:enable
+ $this->assertIsInput($value);
+ /** @var \App\Lib\Discount $value */
+ return $value->toJson();
+ }
+
+ /**
+ * Assert is instance of \App\Lib\Discount
+ *
+ * @param mixed $value
+ * @return void
+ * @throws \RuntimeException If the value is not an input.
+ */
+ private function assertIsInput(mixed $value): void
+ {
+ if (!\is_object($value) or !($value instanceof Discount)) {
+ $value = \json_encode($value);
+ throw new \RuntimeException(
+ __CLASS__ . ' needs value to be array of \'' . Discount::class . "' given is {$value}"
+ );
+ }
+ }
+}
diff --git a/app/Casts/Ip.php b/app/Casts/Ip.php
new file mode 100644
index 0000000..bef7629
--- /dev/null
+++ b/app/Casts/Ip.php
@@ -0,0 +1,61 @@
+ $attributes
+ * @return \TGet|null
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
+ */
+ public function get(Model $model, string $key, mixed $value, array $attributes)
+ {
+ // phpcs:enable
+ return \IPLib\Factory::parseAddressString($value);
+ }
+
+ /**
+ * Transform the attribute to its underlying model values.
+ *
+ * @param \Illuminate\Database\Eloquent\Model $model
+ * @param string $key
+ * @param \TSet|null $value
+ * @param array $attributes
+ * @return mixed
+ * @throws \RuntimeException If value is not or instance of \IPLib\Address\AddressInterface.
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed
+ * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed
+ */
+ public function set(Model $model, string $key, mixed $value, array $attributes)
+ {
+ // phpcs:enable
+ if (is_null($value)) {
+ return null;
+ }
+ if (is_string($value)) {
+ $value = \IPLib\Factory::parseAddressString($value);
+ }
+ if (!is_object($value) or !($value instanceof \IPLib\Address\AddressInterface)) {
+ throw new \RuntimeException(
+ "{$key} has to be instance of " .
+ \IPLib\Address\AddressInterface::class
+ );
+ }
+ $value->getAddressType();
+ return $value;
+ }
+}
diff --git a/app/Console/Commands/CreateAdmin.php b/app/Console/Commands/CreateAdmin.php
deleted file mode 100644
index 89584dc..0000000
--- a/app/Console/Commands/CreateAdmin.php
+++ /dev/null
@@ -1,57 +0,0 @@
-ask('What is the firstname?', 'Equipe');
- $lastname = $this->ask('What is the lastname?', 'Web');
- $email = $this->ask('What is the email?', 'equipe.web@ldc.fr');
- $pwd = $this->secret('What is the password?');
- $role = $this->ask('Role ?', '1');
-
- $user = new User();
- $user->firstname = $firstname;
- $user->lastname = $lastname;
- $user->birth_date = now();
- $user->email = $email;
- $user->password = Hash::make($pwd);
- $user->address = "-";
- $user->town = "Le Mans";
- $user->postal_code = "72000";
- $user->country = "France";
- $user->email_verify_token = "-";
- $user->email_verified = 1;
- $user->role = $role;
- $user->save();
-
- $this->info('User created.');
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/DeleteNotConfirmedUser.php b/app/Console/Commands/DeleteNotConfirmedUser.php
deleted file mode 100644
index b009a3a..0000000
--- a/app/Console/Commands/DeleteNotConfirmedUser.php
+++ /dev/null
@@ -1,39 +0,0 @@
-subDay()]])->get();
- foreach ($users as $user) {
- $user->delete();
- }
-
- return 0;
- }
-}
diff --git a/app/Console/Commands/ExportCodesUniques.php b/app/Console/Commands/ExportCodesUniques.php
deleted file mode 100644
index b9024b5..0000000
--- a/app/Console/Commands/ExportCodesUniques.php
+++ /dev/null
@@ -1,192 +0,0 @@
-ask("Combien de code doivent être exporté ?");
- while (empty(intval($nbCodeTot)) || !is_int(intval($nbCodeTot))) {
- $this->info("Valeur incorrect, veuillez entrer un nombre entier.");
- $nbCodeTot = $this->ask("Veuillez entrer une nouvelle valeur");
- }
- $nbCodeTot = intval($nbCodeTot);
-
- // Nombre de code par fichier.
- $nbCodeFic = $this->ask("Combien de code par fichier ?");
- while (empty(intval($nbCodeFic)) || !is_int(intval($nbCodeFic))) {
- $this->info("Valeur incorrect, veuillez entrer un nombre entier.");
- $nbCodeFic = $this->ask("Veuillez entrer une nouvelle valeur");
- }
- $nbCodeFic = intval($nbCodeFic);
-
- // Nombre de code par ligne.
- $nbCodeLigne = $this->ask("Combien de code par ligne dans un fichier ?");
- while (empty(intval($nbCodeLigne)) || !is_int(intval($nbCodeLigne))) {
- $this->info("Valeur incorrect, veuillez entrer un nombre entier.");
- $nbCodeLigne = $this->ask("Veuillez entrer une nouvelle valeur");
- }
- $nbCodeLigne = intval($nbCodeLigne);
-
- $totalExportedCodes = 0;
- $currentFilename = 1;
- $currentExportedCodes = 0;
- $currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
-
- $this->info("Traitement en cours, veuillez patienter...");
-
- $this->process(
- $nbCodeFic,
- $nbCodeTot,
- $nbCodeLigne,
- $totalExportedCodes,
- $currentFilename,
- $currentExportedCodes,
- $currentLineCodes
- );
-
- $this->info("Fin du traitement, creation de l'archive...");
-
- // Compression des fichiers.
- $zip = new \ZipArchive();
- if (
- $zip->open(
- storage_path('export_codes_uniques/') . "CodesUniques_" . date('dmY') . ".zip",
- \ZipArchive::CREATE
- ) === true
- ) {
- if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
- while (false !== ($file_to_zip = readdir($handle))) {
- if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
- continue;
- }
- $zip->addFile(storage_path('export_codes_uniques/tmp/') . $file_to_zip, "$file_to_zip");
- }
- closedir($handle);
- }
- $zip->close();
- }
-
- // On vide le dossier temporaire des fichiers csv.
- if ($handle = opendir(storage_path('export_codes_uniques/tmp'))) {
- while (false !== ($file_to_zip = readdir($handle))) {
- if (pathinfo($file_to_zip, PATHINFO_EXTENSION) != 'csv') {
- continue;
- }
- unlink(storage_path('export_codes_uniques/tmp/') . $file_to_zip);
- }
- closedir($handle);
- }
-
- $this->info("L'archive CodesUniques_" . date('dmY') . ".zip a ete creer.");
-
- // Envoi de mail à MAIL_ADMIN avec le nom du ZIP "CodesUniques_". date('dmY') .".zip" .
- Mail::to(config('mail.MAIL_ADMIN'))
- ->send(new MailExportCodesUniques(app(Settings::class)->name, $nbCodeFic, $nbCodeTot, $nbCodeLigne));
-
- return 0;
- }
-
- private function process($nbCodeFic, $nbCodeTot, $nbCodeLigne, $totalExportedCodes, $currentFilename, $currentExportedCodes, $currentLineCodes, $lastExportedCodeId = null)
- {
- $paginate = config('codes.paginate');
-
- if ($nbCodeTot < $paginate) {
- $nbCodeToRetrieve = $nbCodeTot;
- } else {
- if ($totalExportedCodes + $paginate > $nbCodeTot) {
- $nbCodeToRetrieve = $nbCodeTot - $totalExportedCodes;
- } else {
- $nbCodeToRetrieve = $paginate;
- }
- }
-
- if ($lastExportedCodeId === null) {
- $codes = Code::where('code_exported', 0)->take($nbCodeToRetrieve)->get();
- } else {
- $codes = Code::where([
- ['code_exported', '=', 0],
- ['id', '>', $lastExportedCodeId]
- ])->take($nbCodeToRetrieve)->get();
- }
-
- $countCodes = count($codes);
-
- $exportedCodesId = [];
-
- foreach ($codes as $k => $code) {
- if ($currentExportedCodes < $nbCodeTot) {
- if ($currentLineCodes === ($nbCodeLigne === 1 ? 1 : $nbCodeLigne - 1)) {
- file_put_contents(
- storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv",
- $code->code_unique . PHP_EOL,
- FILE_APPEND
- );
- $totalExportedCodes++;
- $currentExportedCodes++;
- $currentLineCodes = ($nbCodeLigne === 1 ? 1 : 0);
- } else {
- file_put_contents(
- storage_path('export_codes_uniques/tmp/') . $currentFilename . ".csv",
- $code->code_unique . ";",
- FILE_APPEND
- );
- $totalExportedCodes++;
- $currentExportedCodes++;
- $currentLineCodes++;
- }
-
- array_push($exportedCodesId, $code->id);
- $lastExportedCodeId = $code->id;
-
- if ($currentExportedCodes === $nbCodeFic) {
- $currentFilename++;
- $currentExportedCodes = 0;
- }
- if ((($k + 1) === $countCodes) && $totalExportedCodes < $nbCodeTot) {
- Code::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
- return $this->process(
- $nbCodeFic,
- $nbCodeTot,
- $nbCodeLigne,
- $totalExportedCodes,
- $currentFilename,
- $currentExportedCodes,
- $currentLineCodes,
- $lastExportedCodeId
- );
- }
- if (($k + 1) === $countCodes) {
- Code::whereIn('id', $exportedCodesId)->update(['code_exported' => 1]);
- }
- } //end if
- }//end foreach
- }
-}
diff --git a/app/Console/Commands/TestMail.php b/app/Console/Commands/TestMail.php
new file mode 100644
index 0000000..176f35a
--- /dev/null
+++ b/app/Console/Commands/TestMail.php
@@ -0,0 +1,35 @@
+to('equipe.web@ldc.fr')->subject('Test Email');
+ });
+ }
+}
diff --git a/app/Console/Commands/Theme/SwitchCommand.php b/app/Console/Commands/Theme/SwitchCommand.php
new file mode 100644
index 0000000..b746674
--- /dev/null
+++ b/app/Console/Commands/Theme/SwitchCommand.php
@@ -0,0 +1,77 @@
+ fn () => search(
+ label: 'Search for a theme:',
+ placeholder: 'default-theme',
+ options: fn (string $value): array => \collect(File::directories(\resource_path('theme')))
+ ->map(fn (string $dir_path) => \pathinfo($dir_path, \PATHINFO_BASENAME))
+ ->filter(fn (string $dir_path) => $value ? Str::of($dir_path)->contains($value) : true)
+ ->filter(fn (string $dir_path) => $dir_path !== 'mounted')
+ ->all()
+ )
+ ];
+ }
+
+ /**
+ * Execute the console command.
+ *
+ * @return void
+ */
+ public function handle(): void
+ {
+ $mount_path = \resource_path('theme/mounted');
+
+ /** @var string */
+ $theme = $this->argument('theme');
+
+ if (File::exists($mount_path)) {
+ \throw_if(
+ empty(ToolboxHelper::runConsoleCommand("readlink {$mount_path}", false)),
+ "{$mount_path} is not a link, cannot remove it"
+ );
+ \throw_if(
+ !File::delete($mount_path),
+ "{$mount_path} Failed to remove file"
+ );
+ }
+
+ File::link(\resource_path("theme/{$theme}"), $mount_path);
+
+ Artisan::call('optimize:clear');
+ }
+}
diff --git a/app/Console/Commands/UserCreate.php b/app/Console/Commands/UserCreate.php
new file mode 100644
index 0000000..01d6ee9
--- /dev/null
+++ b/app/Console/Commands/UserCreate.php
@@ -0,0 +1,231 @@
+first_name = null;
+ $this->addFirstName();
+
+ $this->last_name = null;
+ $this->addLastName();
+
+ $this->email = null;
+ $this->addEmail();
+
+ $this->password = null;
+ $this->addPassword();
+
+ $this->role = null;
+ $this->addRole();
+
+ $user = new User([
+ 'first_name' => $this->first_name,
+ 'last_name' => $this->last_name,
+ 'email' => $this->email,
+ 'password' => $this->password,
+ 'role' => $this->role,
+ 'published' => true,
+ 'published_at' => Carbon::now(),
+ ]);
+ $user->saveOrFail();
+
+ $this->info('User created 👌');
+
+ return 0;
+ }
+
+ /**
+ * Add a first name to the user.
+ *
+ * @return void
+ */
+ private function addFirstName(): void
+ {
+ while (is_null($this->first_name)) {
+ try {
+ $tmp = $this->ask('Type the wanted user first name', 'Admin');
+ $validator = Validator::make(['first_name' => $tmp], [
+ 'first_name' => 'required|min:3|max:255'
+ ]);
+ $validator->validate();
+ $this->first_name = $tmp;
+ } catch (ValidationException $e) {
+ $this->error(sprintf(
+ 'Please provide a valid first name %s',
+ \implode(',', collect($e->errors())->flatten()->all())
+ ));
+ continue;
+ } //end try
+ }; //end while
+ }
+
+ /**
+ * Add a last name to the user.
+ *
+ * @return void
+ */
+ private function addLastName(): void
+ {
+ while (is_null($this->last_name)) {
+ try {
+ $tmp = $this->ask('Type the wanted user last name', 'Saïtama');
+ $validator = Validator::make(['last_name' => $tmp], [
+ 'last_name' => 'required|min:3|max:255'
+ ]);
+ $validator->validate();
+ $this->last_name = $tmp;
+ } catch (ValidationException $e) {
+ $this->error(sprintf(
+ 'Please provide a valid last_name %s',
+ \implode(',', collect($e->errors())->flatten()->all())
+ ));
+ continue;
+ } //end try
+ }; //end while
+ }
+
+ /**
+ * Add an email to the user.
+ *
+ * @return void
+ */
+ private function addEmail(): void
+ {
+ while (is_null($this->email)) {
+ try {
+ $tmp = $this->ask('Type the wanted user email', 'equipe.web@ldc.fr');
+ $validator = Validator::make(['email' => $tmp], [
+ 'email' => 'required|unique:users,email|email:rfc,dns'
+ ]);
+ $validator->validate();
+ $this->email = $tmp;
+ } catch (ValidationException $e) {
+ $this->error(sprintf(
+ 'Please provide a valid email %s',
+ \implode(',', collect($e->errors())->flatten()->all())
+ ));
+ continue;
+ } //end try
+ }; //end while
+ }
+
+ /**
+ * Add a password to the user.
+ *
+ * @return void
+ */
+ private function addPassword(): void
+ {
+ while (
+ ($this->password = $this->secret(
+ (!\is_null($this->password) ? 'Failed to confirm, ' : '') . 'Type the wanted user password'
+ )) !== $this->secret('Confirm the password')
+ ) {
+ continue;
+ }; //end while
+ }
+
+ /**
+ * Add a role to the user.
+ *
+ * @return void
+ */
+ private function addRole(): void
+ {
+ while (is_null($this->role)) {
+ try {
+ $tmp = $this->choice(
+ 'Select his role',
+ [RoleEnum::conceptor->label(), RoleEnum::admin->label(), RoleEnum::marketing->label()],
+ RoleEnum::marketing->label(),
+ $maxAttempts = null,
+ $allowMultipleSelections = false
+ );
+ if ($tmp === RoleEnum::conceptor->label()) {
+ $tmp = RoleEnum::conceptor;
+ }
+ if ($tmp === RoleEnum::admin->label()) {
+ $tmp = RoleEnum::admin;
+ }
+ if ($tmp === RoleEnum::marketing->label()) {
+ $tmp = RoleEnum::marketing;
+ }
+ $validator = Validator::make(['role' => $tmp], [
+ 'role' => 'required'
+ ]);
+ $validator->validate();
+ $this->role = $tmp;
+ } catch (ValidationException $e) {
+ $this->error(sprintf(
+ 'Please choose from the selection',
+ \implode(',', collect($e->errors())->flatten()->all())
+ ));
+ continue;
+ } //end try
+ }; //end while
+ }
+}
diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php
index 687937a..84be6f8 100644
--- a/app/Console/Kernel.php
+++ b/app/Console/Kernel.php
@@ -22,6 +22,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule)
{
+ $schedule->job(DeleteOldCustomers::class)->dailyAt('22:50');
}
/**
diff --git a/app/Enums/ActivityLogs/ActivityLogsEventEnum.php b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php
new file mode 100644
index 0000000..ebb098c
--- /dev/null
+++ b/app/Enums/ActivityLogs/ActivityLogsEventEnum.php
@@ -0,0 +1,46 @@
+name => 'Création',
+ self::updated->name => 'Mise à jour',
+ self::duplicated->name => 'Duplication',
+ self::deleted->name => 'Suppression',
+ ];
+
+
+ /**
+ * Custom added classes definition
+ */
+ private const BOOTSTRAPCLASS = [
+ self::created->name => 'success',
+ self::updated->name => 'warning',
+ self::duplicated->name => 'secondary',
+ self::deleted->name => 'danger',
+ ];
+
+ /**
+ * Get Class
+ *
+ * @return string
+ */
+ public function bootstrapClass(): string
+ {
+ return self::BOOTSTRAPCLASS[$this->name];
+ }
+}
diff --git a/app/Enums/InputType.php b/app/Enums/InputType.php
new file mode 100644
index 0000000..0b59d29
--- /dev/null
+++ b/app/Enums/InputType.php
@@ -0,0 +1,30 @@
+name => 'Mentions légales',
+ self::rules->name => 'Règlement',
+ self::confidentiality->name => 'Charte de confidentialité'
+ ];
+}
diff --git a/app/Enums/Theme/BootstrapThemeEnum.php b/app/Enums/Theme/BootstrapThemeEnum.php
new file mode 100644
index 0000000..f1f3725
--- /dev/null
+++ b/app/Enums/Theme/BootstrapThemeEnum.php
@@ -0,0 +1,21 @@
+name => 'Light',
+ self::dark->name => 'Dark',
+ ];
+}
diff --git a/app/Enums/Users/RoleEnum.php b/app/Enums/Users/RoleEnum.php
new file mode 100644
index 0000000..c6ad62d
--- /dev/null
+++ b/app/Enums/Users/RoleEnum.php
@@ -0,0 +1,23 @@
+name => 'Concepteur',
+ self::admin->name => 'Administrator',
+ self::marketing->name => 'Marketing',
+ ];
+}
diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php
index bf6a0bd..220b3d7 100644
--- a/app/Exceptions/Handler.php
+++ b/app/Exceptions/Handler.php
@@ -2,26 +2,47 @@
namespace App\Exceptions;
-use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
+use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
+use Throwable;
class Handler extends ExceptionHandler
{
/**
- * A list of the exception types that are not reported.
+ * A list of exception types with their corresponding custom log levels.
*
- * @var array
+ * @var array, \Psr\Log\LogLevel::*>
*/
- protected $dontReport = [
- RedirectTo::class
- ];
+ protected $levels = [];
/**
- * A list of the inputs that are never flashed for validation exceptions.
+ * A list of the exception types that are not reported.
*
- * @var array
+ * @var array>
+ */
+ protected $dontReport = [];
+
+ /**
+ * A list of the inputs that are never flashed to the session on validation exceptions.
+ *
+ * @var array
*/
protected $dontFlash = [
+ 'current_password',
'password',
'password_confirmation',
];
+
+ /**
+ * Register the exception handling callbacks for the application.
+ *
+ * @return void
+ */
+ public function register()
+ {
+ $this->reportable(function (Throwable $e) {
+ if (app()->bound('sentry')) {
+ app('sentry')->captureException($e);
+ }
+ });
+ }
}
diff --git a/app/Http/Controllers/Bo/ActivityLogController.php b/app/Http/Controllers/Bo/ActivityLogController.php
new file mode 100644
index 0000000..7f79987
--- /dev/null
+++ b/app/Http/Controllers/Bo/ActivityLogController.php
@@ -0,0 +1,71 @@
+authorize('isConceptor');
+ /** @var \Illuminate\Database\Eloquent\Builder $query */
+ $query = ActivityLog::query()->with('user');
+
+ /** @var string $search Search field */
+ $search = $request->search;
+ if ($search) {
+ $this->searchQuery(
+ $query,
+ $search,
+ null,
+ 'model_class',
+ );
+ }
+ $searchFields = \implode(', ', [
+ trans('validation.custom.target'),
+ ]);
+
+ /** Sort columns with a query */
+ $this->sortQuery($query);
+
+ /** Custom pagination */
+ $activitylogModels = $this->paginate($query);
+
+ return view('back::pages.activity_logs.index', compact('activitylogModels', 'search', 'searchFields'));
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param App\Models\ActivityLog $activity_log
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function show(ActivityLog $activity_log): \Illuminate\Contracts\View\View
+ {
+ $this->authorize('isConceptor');
+ $targetModelClass = $activity_log->model_class;
+ $targetModel = $activity_log->model_class::where(
+ (new $targetModelClass())->getRouteKeyName(),
+ $activity_log->model_id
+ )->first();
+
+ return view('back::pages.activity_logs.show', [
+ 'activitylogModel' => $activity_log,
+ 'targetModel' => $targetModel,
+ ]);
+ }
+}
diff --git a/app/Http/Controllers/Bo/Auth/LoginController.php b/app/Http/Controllers/Bo/Auth/LoginController.php
new file mode 100644
index 0000000..7c9aad3
--- /dev/null
+++ b/app/Http/Controllers/Bo/Auth/LoginController.php
@@ -0,0 +1,72 @@
+middleware('guest:backend')->except('logout');
+ }
+
+ /**
+ * Get the guard to be used during authentication.
+ *
+ * @return \Illuminate\Contracts\Auth\StatefulGuard
+ */
+ protected function guard(): StatefulGuard
+ {
+ return Auth::guard('backend');
+ }
+
+ /**
+ * Show the application's login form.
+ *
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function showLoginForm(): View
+ {
+ return view('back::auth.login');
+ }
+
+ /**
+ * Where to redirect users after login.
+ *
+ * @return string
+ */
+ protected function redirectTo(): string
+ {
+ return response()->redirectToIntended()->getTargetUrl();
+ }
+
+ /**
+ * Attempt to log the user into the application.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return boolean
+ */
+ protected function attemptLogin(Request $request)
+ {
+ $credentials = $this->credentials($request);
+ // * Attempt login only using published users.
+ $credentials['published'] = true;
+ return $this->guard()->attempt(
+ $credentials,
+ $request->boolean('remember')
+ );
+ }
+}
diff --git a/app/Http/Controllers/Bo/Auth/ResetPasswordController.php b/app/Http/Controllers/Bo/Auth/ResetPasswordController.php
new file mode 100644
index 0000000..03340fc
--- /dev/null
+++ b/app/Http/Controllers/Bo/Auth/ResetPasswordController.php
@@ -0,0 +1,33 @@
+authorizeResource(BannedIp::class);
}
- public function saveDatas(Request $request)
+ /**
+ * Display a listing of the resource.
+ *
+ * @param \Illuminate\Http\Request $request
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function index(Request $request): \Illuminate\Contracts\View\View
{
- $ips = $request->ips;
+ /** @var \Illuminate\Database\Eloquent\Builder $bannedipModels */
+ $bannedipModels = BannedIp::query();
- for ($i = 0; $i < count($ips); $i++) {
- if (!empty($ips[$i]["ip"])) {
- $ip = BannedIp::updateOrCreate(['ip' => $ips[$i]["ip"]]);
- } else {
- unset($ips[$i]);
- $i--;
- }
+ /** @var string $search Search field */
+ $search = $request->search;
+ if ($search) {
+ $this->searchQuery(
+ $bannedipModels,
+ $search,
+ null,
+ 'ip',
+ );
}
+ $searchFields = trans('validation.custom.ip');
- return $ips;
+ /** Sort columns with a query */
+ $this->sortQuery($bannedipModels);
+
+ /** Custom pagination */
+ $bannedipModels = $this->paginate($bannedipModels);
+
+ return view('back::pages.banned-ips.index', compact('bannedipModels', 'search', 'searchFields'));
}
- public function destroy(Request $request)
+ /**
+ * Show the form for creating a new resource.
+ *
+ * @param \App\Models\BannedIp $banned_ip
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function create(BannedIp $banned_ip): \Illuminate\Contracts\View\View
{
- $ip = BannedIp::where("ip", $request->ip);
- $ip->delete();
+ return view('back::pages.banned-ips.create', [
+ 'bannedipModel' => $banned_ip,
+ ]);
+ }
- return "Suppression terminée !";
+ /**
+ * Store a newly created resource in storage.
+ *
+ * @param \App\Http\Requests\Bo\BannedIps\StoreBannedIpRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function store(StoreBannedIpRequest $request): \Illuminate\Http\RedirectResponse
+ {
+ return DB::transaction(function () use ($request) {
+ $banned_ip = new BannedIp();
+ $banned_ip->fill($request->validated());
+ if ($banned_ip->saveOrFail()) {
+ return redirect()
+ ->route('bo.banned_ips.edit', $banned_ip)
+ ->with('success', trans(
+ 'crud.messages.has_been_created',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ }
+ return redirect()
+ ->back()
+ ->with('error', trans(
+ 'crud.messages.cannot_be_created',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ });
+ }
+
+ /**
+ * Show the form for editing the specified resource.
+ *
+ * @param \App\Models\BannedIp $banned_ip
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function edit(BannedIp $banned_ip): \Illuminate\Contracts\View\View
+ {
+ return view('back::pages.banned-ips.edit', [
+ 'bannedipModel' => $banned_ip,
+ ]);
+ }
+
+ /**
+ * Update the specified resource in storage.
+ *
+ * @param \App\Http\Requests\Bo\BannedIps\UpdateBannedIpRequest $request
+ * @param \App\Models\BannedIp $banned_ip
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function update(UpdateBannedIpRequest $request, BannedIp $banned_ip): \Illuminate\Http\RedirectResponse
+ {
+ return DB::transaction(function () use ($request, $banned_ip) {
+ $banned_ip->fill($request->validated());
+ if ($banned_ip->saveOrFail()) {
+ return redirect()
+ ->route('bo.banned_ips.edit', $banned_ip)
+ ->with('success', trans(
+ 'crud.messages.has_been_updated',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ }
+ return redirect()
+ ->back()
+ ->with('error', trans(
+ 'crud.messages.cannot_be_updated',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ });
+ }
+
+ /**
+ * Remove the specified resource from storage.
+ *
+ * @param \App\Models\BannedIp $banned_ip
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function destroy(BannedIp $banned_ip): \Illuminate\Http\RedirectResponse
+ {
+ return DB::transaction(function () use ($banned_ip) {
+ if ($banned_ip->deleteOrFail()) {
+ return redirect()
+ ->route('bo.banned_ips.index')
+ ->with('success', __(
+ 'crud.messages.has_been_deleted',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ }
+ return redirect()
+ ->back()
+ ->with('error', __(
+ ':crud.messages.cannot_be_deleted',
+ ['model' => Str::singular(trans('models.classes.banned_ips'))]
+ ));
+ });
}
}
diff --git a/app/Http/Controllers/Bo/CodeController.php b/app/Http/Controllers/Bo/CodeController.php
new file mode 100644
index 0000000..6841b1d
--- /dev/null
+++ b/app/Http/Controllers/Bo/CodeController.php
@@ -0,0 +1,136 @@
+authorize('generate', Code::class);
+ /** @var \App\Models\Settings */
+ $settings = app(Settings::class);
+ $nbCodeBase = Code::query()->count();
+ $nbCodeUsed = Code::query()->whereHas(
+ 'participations',
+ operator: '>',
+ count: $settings->nb_unique_code_use
+ )->count();
+ $nbCodeExported = Code::query()->where('code_exported', true)->count();
+ $nbCodeRemainingToExport = Code::query()->where('code_exported', false)->count();
+ return view('back::pages.codes.index', compact(
+ 'settings',
+ 'nbCodeBase',
+ 'nbCodeUsed',
+ 'nbCodeExported',
+ 'nbCodeRemainingToExport'
+ ));
+ }
+
+ /**
+ * Run generate codes action
+ *
+ * @param \App\Http\Controllers\Bo\Codes\GenerateCodesRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function generate(GenerateCodesRequest $request): \Illuminate\Http\RedirectResponse
+ {
+ $this->authorize('generate', Code::class);
+ Queue::push(
+ new ProcessUniqueCode(
+ intval($request->quantity),
+ config('codes.codeLength')
+ )
+ );
+
+ return back()->with(
+ 'success',
+ trans(
+ // phpcs:ignore Generic.Files.LineLength.TooLong
+ 'La tache de génération à été ajoutée, un mail de notification sera envoyé à l\'adresse :email lorsque le traitement sera terminé.',
+ [
+ 'email' => config('mail.admin')
+ ]
+ )
+ );
+ }
+
+ /**
+ * Run export codes
+ *
+ * @param \App\Http\Requests\Bo\Codes\ExportCodesRequest $request
+ * @return \Illuminate\Http\RedirectResponse
+ */
+ public function export(ExportCodesRequest $request): \Illuminate\Http\RedirectResponse
+ {
+ $this->authorize('export', Code::class);
+ Queue::push(
+ new ProcessExportCodesUniques(
+ intval($request->nb_code_fic),
+ intval($request->nb_code_tot),
+ intval($request->nb_code_ligne)
+ )
+ );
+
+ return back()->with(
+ 'success',
+ // phpcs:ignore Generic.Files.LineLength.TooLong
+ 'L\'export des codes à commencé, un mail de notification sera envoyé à l\'adresse :email lorsque le traitement sera terminé.',
+ [
+ 'email' => config('mail.admin')
+ ]
+ );
+ }
+
+ /**
+ * Search for a specific code.
+ *
+ * @param \App\Http\Requests\Bo\Codes\CodeSearchRequest $request
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function search(CodeSearchRequest $request): \Illuminate\Contracts\View\View
+ {
+ $this->authorize('search', Code::class);
+ $code = null;
+ try {
+ $code = Code::query()->where('id', Code::serialToInt($request->code))->first();
+ } catch (\Throwable $e) {
+ if (\get_class($e) === SerialCasterException::class) {
+ $code = false;
+ }
+ } finally {
+ if ($code === false) {
+ \session()->flash('warning', trans('Code non valide.'));
+ }
+ if ($code === null) {
+ \session()->flash('warning', trans('Code introuvable.'));
+ }
+ }
+
+ $used_counter = null;
+ if ($code) {
+ $used_counter = Participation::query()
+ ->whereHas('code', fn (Builder $q) => $q->where('id', $code->id))
+ ->count();
+ }
+
+ return view('back::pages.codes.search', compact('code', 'used_counter'));
+ }
+}
diff --git a/app/Http/Controllers/Bo/CodesController.php b/app/Http/Controllers/Bo/CodesController.php
deleted file mode 100644
index dfc7b83..0000000
--- a/app/Http/Controllers/Bo/CodesController.php
+++ /dev/null
@@ -1,104 +0,0 @@
-count();
- $nbCodeExported = Code::where('code_exported', 1)->count();
- $nbCodeRemainingToExport = Code::where('code_exported', 0)->count();
- return view('bo.codes.index', compact(
- 'settings',
- 'nbCodeBase',
- 'nbCodeUsed',
- 'nbCodeExported',
- 'nbCodeRemainingToExport'
- ));
- }
-
- /**
- * Run generate codes action
- *
- * @param GenerateCodesRequest $request
- * @return \Illuminate\Http\RedirectResponse
- */
- public function generate(GenerateCodesRequest $request)
- {
- ProcessUniqueCode::dispatch(
- $request->quantity,
- $request->code_length
- );
-
- return back()->with(
- 'success',
- "La génération à commencée, un mail de notification sera envoyé à l'adresse " .
- config('mail.MAIL_ADMIN') . " lorsque le traitement sera terminé."
- );
- }
-
- /**
- * Run export codes
- *
- * @param ExportCodesRequest $request
- * @return \Illuminate\Http\RedirectResponse
- */
- public function export(ExportCodesRequest $request)
- {
- ProcessExportCodesUniques::dispatch(
- intval($request->nb_code_fic),
- intval($request->nb_code_tot),
- intval($request->nb_code_ligne)
- );
-
- return back()->with(
- 'success',
- "L'export des codes à commencé, un mail de notification sera envoyé à l'adresse " .
- config('mail.MAIL_ADMIN') . " lorsque le traitement sera terminé."
- );
- }
-
- /**
- * Search for a specific code.
- *
- * @param CodeSearchRequest $request
- * @return \Illuminate\View\View|\Illuminate\Contracts\View\Factory
- */
- public function search(CodeSearchRequest $request)
- {
- $code = null;
- try {
- $code = Code::whereId(Code::serialToInt($request->code))->first();
- } catch (\Throwable $e) {
- if (\get_class($e) === SerialCasterException::class) {
- $code = false;
- }
- } finally {
- if ($code === false) {
- \session()->flash('warning', trans('Code non valide.'));
- }
- if ($code === null) {
- \session()->flash('warning', trans('Code introuvable.'));
- }
- }
- return view('bo.codes.search', compact('code'));
- }
-}
diff --git a/app/Http/Controllers/Bo/CodesEANController.php b/app/Http/Controllers/Bo/CodesEANController.php
deleted file mode 100644
index 9cb79e9..0000000
--- a/app/Http/Controllers/Bo/CodesEANController.php
+++ /dev/null
@@ -1,49 +0,0 @@
-codes;
-
- for ($i = 0; $i < count($codes); $i++) {
- $codeToInsert = !empty($codes[$i]["code"]) && !empty($codes[$i]["product"]);
- if (isset($codes[$i]["id"]) && $codes[$i]["id"] !== null && $codeToInsert) {
- $c = CodeEan::findOrFail($codes[$i]["id"]);
- $c->code = $codes[$i]["code"];
- $c->product = $codes[$i]["product"];
- $c->save();
- } else {
- if ($codeToInsert) {
- $c = CodeEan::updateOrCreate(['code' => $codes[$i]["code"], 'product' => $codes[$i]["product"]]);
- $codes[$i]["id"] = $c->id;
- } else {
- unset($codes[$i]);
- $i--;
- }
- }
- }
-
- return $codes;
- }
-
- public function destroy(Request $request)
- {
- $code = CodeEan::findOrFail($request->id);
- $code->delete();
-
- return "Suppression terminée !";
- }
-}
diff --git a/app/Http/Controllers/Bo/ContentController.php b/app/Http/Controllers/Bo/ContentController.php
deleted file mode 100644
index 3dcf5d9..0000000
--- a/app/Http/Controllers/Bo/ContentController.php
+++ /dev/null
@@ -1,25 +0,0 @@
-value;
- $content->value = $value;
- $content->save();
-
- return redirect()->route('bo.content', $content->id)->with('success', 'Enregistré !');
- }
-
- return view('bo.content.manage', compact('content'));
- }
-}
diff --git a/app/Http/Controllers/Bo/DashboardController.php b/app/Http/Controllers/Bo/DashboardController.php
index 9e0d5c0..b5f7d99 100644
--- a/app/Http/Controllers/Bo/DashboardController.php
+++ b/app/Http/Controllers/Bo/DashboardController.php
@@ -6,65 +6,75 @@ use App\Http\Controllers\Controller;
use App\Models\Participation;
use App\Models\Settings;
use Carbon\Carbon;
+use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
class DashboardController extends Controller
{
- public function index()
+ /**
+ * Dashboard Page
+ *
+ * @return \Illuminate\Contracts\View\View
+ */
+ public function index(): \Illuminate\Contracts\View\View
{
- // Pour les stats.
- $settings = app(Settings::class);
- $participations = Participation::selectRaw("COUNT(*) AS count, DATE(created_at) AS date")
- ->groupByRaw("DATE(created_at)")->get();
- $participationsUniquePerDay = Participation::selectRaw("DISTINCT user_id AS user, COUNT(*) AS count, DATE(created_at) AS date")
- ->groupByRaw("DATE(created_at), user")->get();
- $statsUnique = [];
- foreach ($participationsUniquePerDay as $participationPerDay) {
- $dateUnique = Carbon::parse($participationPerDay->date)->format('d/m/Y');
- $statsUnique[$dateUnique] = isset($statsUnique[$dateUnique]) ? $statsUnique[$dateUnique] + 1 : 1;
- }
- $participationsUnique = Participation::selectRaw("DISTINCT user_id AS user, COUNT(*) AS count")
- ->groupBy("user")->orderBy("user")->get();
+ // * Pour les stats.
+ /** @var \App\Models\Settings */
+ $settings = app(Settings::class);
+ $avgParticipUser = 0;
+ $participationPeriod = [];
+ $statsUnique = [];
+ $query = DB::table((new Participation())->getTable());
+ $dateFrmtr = function (object $row) {
+ $row->date = Carbon::parse($row->date)->isoFormat('DD/MM/YYYY');
+ return $row;
+ };
- // Données calculées à afficher.
- $totalParticipation = Participation::count();
- if (count($participationsUnique) > 0) {
- $avgParticipUser = round($totalParticipation / count($participationsUnique), 1);
- } else {
- $avgParticipUser = 0;
+ /** @var \Illuminate\Support\Collection */
+ $participationsPerDay = (clone $query)
+ ->selectRaw('COUNT(*) AS count, DATE(created_at) AS date')
+ ->groupByRaw('DATE(created_at)')->get()->map($dateFrmtr)->keyBy('date');
+
+ /** @var \Illuminate\Support\Collection
").replace(/\r?\n/g,"
").replace(/^\s/," ").replace(/\s$/," ").replace(/\s\s/g," ")).includes("
")||s.includes("
"))&&(s=`
${s}
`),r=s),r=this.editor.data.htmlProcessor.toView(r));const a=new e(this,"inputTransformation");this.fire(a,{content:r,dataTransfer:i,targetRanges:n.targetRanges,method:n.method}),a.stop.called&&t.stop(),o.scrollToTheSelection()}),{priority:"low"}),this.listenTo(this,"inputTransformation",((t,e)=>{if(e.content.isEmpty)return;const o=this.editor.data.toModel(e.content,"$clipboardHolder");0!=o.childCount&&(t.stop(),n.change((()=>{this.fire("contentInsertion",{content:o,method:e.method,dataTransfer:e.dataTransfer,targetRanges:e.targetRanges})})))}),{priority:"low"}),this.listenTo(this,"contentInsertion",((t,e)=>{e.resultRange=n.insertContent(e.content)}),{priority:"low"})}_setupCopyCut(){const t=this.editor,e=t.model.document,n=t.editing.view.document;function o(o,i){const r=i.dataTransfer;i.preventDefault();const s=t.data.toView(t.model.getSelectedContent(e.selection));n.fire("clipboardOutput",{dataTransfer:r,content:s,method:o.name})}this.listenTo(n,"copy",o,{priority:"low"}),this.listenTo(n,"cut",((e,n)=>{t.isReadOnly?n.preventDefault():o(e,n)}),{priority:"low"}),this.listenTo(n,"clipboardOutput",((n,o)=>{o.content.isEmpty||(o.dataTransfer.setData("text/html",this.editor.data.htmlProcessor.toData(o.content)),o.dataTransfer.setData("text/plain",Gp(o.content))),"cut"==o.method&&t.model.deleteContent(e.selection)}),{priority:"low"})}}class Zp{constructor(){this._stack=[]}add(t,e){const n=this._stack,o=n[0];this._insertDescriptor(t);const i=n[0];o===i||Yp(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}remove(t,e){const n=this._stack,o=n[0];this._removeDescriptor(t);const i=n[0];o===i||Yp(o,i)||this.fire("change:top",{oldDescriptor:o,newDescriptor:i,writer:e})}_insertDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t.id));if(Yp(t,e[n]))return;n>-1&&e.splice(n,1);let o=0;for(;e[o]&&Kp(e[o],t);)o++;e.splice(o,0,t)}_removeDescriptor(t){const e=this._stack,n=e.findIndex((e=>e.id===t));n>-1&&e.splice(n,1)}}function Yp(t,e){return t&&e&&t.priority==e.priority&&$p(t.classes)==$p(e.classes)}function Kp(t,e){return t.priority>e.priority||!(t.priority$p(e.classes)}function $p(t){return Array.isArray(t)?t.sort().join(","):t}j(Zp,k);const Qp='',Jp="ck-widget_selected";function Xp(t){return!!t.is("element")&&!!t.getCustomProperty("widget")}function tf(t,e,n={}){if(!t.is("containerElement"))throw new l("widget-to-widget-wrong-element-type",null,{element:t});return e.setAttribute("contenteditable","false",t),e.addClass("ck-widget",t),e.setCustomProperty("widget",!0,t),t.getFillerOffset=lf,n.label&&function(t,e,n){n.setCustomProperty("widgetLabel",e,t)}(t,n.label,e),n.hasSelectionHandle&&function(t,e){const n=e.createUIElement("div",{class:"ck ck-widget__selection-handle"},(function(t){const e=this.toDomElement(t),n=new _u;return n.set("content",Qp),n.render(),e.appendChild(n.element),e}));e.insert(e.createPositionAt(t,0),n),e.addClass(["ck-widget_with-selection-handle"],t)}(t,e),of(t,e),t}function ef(t,e,n){if(e.classes&&n.addClass(wo(e.classes),t),e.attributes)for(const o in e.attributes)n.setAttribute(o,e.attributes[o],t)}function nf(t,e,n){if(e.classes&&n.removeClass(wo(e.classes),t),e.attributes)for(const o in e.attributes)n.removeAttribute(o,t)}function of(t,e,n=ef,o=nf){const i=new Zp;i.on("change:top",((e,i)=>{i.oldDescriptor&&o(t,i.oldDescriptor,i.writer),i.newDescriptor&&n(t,i.newDescriptor,i.writer)})),e.setCustomProperty("addHighlight",((t,e,n)=>i.add(e,n)),t),e.setCustomProperty("removeHighlight",((t,e,n)=>i.remove(e,n)),t)}function rf(t){const e=t.getCustomProperty("widgetLabel");return e?"function"==typeof e?e():e:""}function sf(t,e,n={}){return e.addClass(["ck-editor__editable","ck-editor__nested-editable"],t),e.setAttribute("role","textbox",t),n.label&&e.setAttribute("aria-label",n.label,t),e.setAttribute("contenteditable",t.isReadOnly?"false":"true",t),t.on("change:isReadOnly",((n,o,i)=>{e.setAttribute("contenteditable",i?"false":"true",t)})),t.on("change:isFocused",((n,o,i)=>{i?e.addClass("ck-editor__nested-editable_focused",t):e.removeClass("ck-editor__nested-editable_focused",t)})),of(t,e),t}function af(t,e){const n=t.getSelectedElement();if(n){const o=uf(t);if(o)return e.createRange(e.createPositionAt(n,o))}return gd(t,e)}function lf(){return null}const cf="widget-type-around";function df(t,e,n){return t&&Xp(t)&&!n.isInline(e)}function uf(t){return t.getAttribute(cf)}var hf=n(5137),mf={attributes:{"data-cke":!0}};mf.setAttributes=is(),mf.insert=ns().bind(null,"head"),mf.domAPI=ts(),mf.insertStyleElement=ss();Jr()(hf.Z,mf);hf.Z&&hf.Z.locals&&hf.Z.locals;const gf=["before","after"],pf=(new DOMParser).parseFromString('',"image/svg+xml").firstChild,ff="ck-widget__type-around_disabled";class bf extends V{static get pluginName(){return"WidgetTypeAround"}static get requires(){return[yp,Kg]}constructor(t){super(t),this._currentFakeCaretModelElement=null}init(){const t=this.editor,e=t.editing.view;this.on("change:isEnabled",((n,o,i)=>{e.change((t=>{for(const n of e.document.roots)i?t.removeClass(ff,n):t.addClass(ff,n)})),i||t.model.change((t=>{t.removeSelectionAttribute(cf)}))})),this._enableTypeAroundUIInjection(),this._enableInsertingParagraphsOnButtonClick(),this._enableInsertingParagraphsOnEnterKeypress(),this._enableInsertingParagraphsOnTypingKeystroke(),this._enableTypeAroundFakeCaretActivationUsingKeyboardArrows(),this._enableDeleteIntegration(),this._enableInsertContentIntegration(),this._enableInsertObjectIntegration(),this._enableDeleteContentIntegration()}destroy(){this._currentFakeCaretModelElement=null}_insertParagraph(t,e){const n=this.editor,o=n.editing.view,i=n.model.schema.getAttributesWithProperty(t,"copyOnReplace",!0);n.execute("insertParagraph",{position:n.model.createPositionAt(t,e),attributes:i}),o.focus(),o.scrollToTheSelection()}_listenToIfEnabled(t,e,n,o){this.listenTo(t,e,((...t)=>{this.isEnabled&&n(...t)}),o)}_insertParagraphAccordingToFakeCaretPosition(){const t=this.editor.model.document.selection,e=uf(t);if(!e)return!1;const n=t.getSelectedElement();return this._insertParagraph(n,e),!0}_enableTypeAroundUIInjection(){const t=this.editor,e=t.model.schema,n=t.locale.t,o={before:n("Insert paragraph before block"),after:n("Insert paragraph after block")};t.editing.downcastDispatcher.on("insert",((t,n,i)=>{const r=i.mapper.toViewElement(n.item);df(r,n.item,e)&&function(t,e,n){const o=t.createUIElement("div",{class:"ck ck-reset_all ck-widget__type-around"},(function(t){const n=this.toDomElement(t);return function(t,e){for(const n of gf){const o=new Xd({tag:"div",attributes:{class:["ck","ck-widget__type-around__button",`ck-widget__type-around__button_${n}`],title:e[n]},children:[t.ownerDocument.importNode(pf,!0)]});t.appendChild(o.render())}}(n,e),function(t){const e=new Xd({tag:"div",attributes:{class:["ck","ck-widget__type-around__fake-caret"]}});t.appendChild(e.render())}(n),n}));t.insert(t.createPositionAt(n,"end"),o)}(i.writer,o,r)}),{priority:"low"})}_enableTypeAroundFakeCaretActivationUsingKeyboardArrows(){const t=this.editor,e=t.model,n=e.document.selection,o=e.schema,i=t.editing.view;function r(t){return`ck-widget_type-around_show-fake-caret_${t}`}this._listenToIfEnabled(i.document,"arrowKey",((t,e)=>{this._handleArrowKeyPress(t,e)}),{context:[Xp,"$text"],priority:"high"}),this._listenToIfEnabled(n,"change:range",((e,n)=>{n.directChange&&t.model.change((t=>{t.removeSelectionAttribute(cf)}))})),this._listenToIfEnabled(e.document,"change:data",(()=>{const e=n.getSelectedElement();if(e){if(df(t.editing.mapper.toViewElement(e),e,o))return}t.model.change((t=>{t.removeSelectionAttribute(cf)}))})),this._listenToIfEnabled(t.editing.downcastDispatcher,"selection",((t,e,n)=>{const i=n.writer;if(this._currentFakeCaretModelElement){const t=n.mapper.toViewElement(this._currentFakeCaretModelElement);t&&(i.removeClass(gf.map(r),t),this._currentFakeCaretModelElement=null)}const s=e.selection.getSelectedElement();if(!s)return;const a=n.mapper.toViewElement(s);if(!df(a,s,o))return;const l=uf(e.selection);l&&(i.addClass(r(l),a),this._currentFakeCaretModelElement=s)})),this._listenToIfEnabled(t.ui.focusTracker,"change:isFocused",((e,n,o)=>{o||t.model.change((t=>{t.removeSelectionAttribute(cf)}))}))}_handleArrowKeyPress(t,e){const n=this.editor,o=n.model,i=o.document.selection,r=o.schema,s=n.editing.view,a=function(t,e){const n=fr(t,e);return"down"===n||"right"===n}(e.keyCode,n.locale.contentLanguageDirection),l=s.document.selection.getSelectedElement();let c;df(l,n.editing.mapper.toModelElement(l),r)?c=this._handleArrowKeyPressOnSelectedWidget(a):i.isCollapsed?c=this._handleArrowKeyPressWhenSelectionNextToAWidget(a):e.shiftKey||(c=this._handleArrowKeyPressWhenNonCollapsedSelection(a)),c&&(e.preventDefault(),t.stop())}_handleArrowKeyPressOnSelectedWidget(t){const e=this.editor.model,n=uf(e.document.selection);return e.change((e=>{if(!n)return e.setSelectionAttribute(cf,t?"after":"before"),!0;if(!(n===(t?"after":"before")))return e.removeSelectionAttribute(cf),!0;return!1}))}_handleArrowKeyPressWhenSelectionNextToAWidget(t){const e=this.editor,n=e.model,o=n.schema,i=e.plugins.get("Widget"),r=i._getObjectElementNextToSelection(t);return!!df(e.editing.mapper.toViewElement(r),r,o)&&(n.change((e=>{i._setSelectionOverElement(r),e.setSelectionAttribute(cf,t?"before":"after")})),!0)}_handleArrowKeyPressWhenNonCollapsedSelection(t){const e=this.editor,n=e.model,o=n.schema,i=e.editing.mapper,r=n.document.selection,s=t?r.getLastPosition().nodeBefore:r.getFirstPosition().nodeAfter;return!!df(i.toViewElement(s),s,o)&&(n.change((e=>{e.setSelection(s,"on"),e.setSelectionAttribute(cf,t?"after":"before")})),!0)}_enableInsertingParagraphsOnButtonClick(){const t=this.editor,e=t.editing.view;this._listenToIfEnabled(e.document,"mousedown",((n,o)=>{const i=o.domTarget.closest(".ck-widget__type-around__button");if(!i)return;const r=function(t){return t.classList.contains("ck-widget__type-around__button_before")?"before":"after"}(i),s=function(t,e){const n=t.closest(".ck-widget");return e.mapDomToView(n)}(i,e.domConverter),a=t.editing.mapper.toModelElement(s);this._insertParagraph(a,r),o.preventDefault(),n.stop()}))}_enableInsertingParagraphsOnEnterKeypress(){const t=this.editor,e=t.model.document.selection,n=t.editing.view;this._listenToIfEnabled(n.document,"enter",((n,o)=>{if("atTarget"!=n.eventPhase)return;const i=e.getSelectedElement(),r=t.editing.mapper.toViewElement(i),s=t.model.schema;let a;this._insertParagraphAccordingToFakeCaretPosition()?a=!0:df(r,i,s)&&(this._insertParagraph(i,o.isSoft?"before":"after"),a=!0),a&&(o.preventDefault(),n.stop())}),{context:Xp})}_enableInsertingParagraphsOnTypingKeystroke(){const t=this.editor.editing.view,e=[ur.enter,ur.delete,ur.backspace];this._listenToIfEnabled(t.document,"keydown",((t,n)=>{e.includes(n.keyCode)||Hg(n)||this._insertParagraphAccordingToFakeCaretPosition()}),{priority:"high"})}_enableDeleteIntegration(){const t=this.editor,e=t.editing.view,n=t.model,o=n.schema;this._listenToIfEnabled(e.document,"delete",((e,i)=>{if("atTarget"!=e.eventPhase)return;const r=uf(n.document.selection);if(!r)return;const s=i.direction,a=n.document.selection.getSelectedElement(),l="forward"==s;if("before"===r===l)t.execute("delete",{selection:n.createSelection(a,"on")});else{const e=o.getNearestSelectionRange(n.createPositionAt(a,r),s);if(e)if(e.isCollapsed){const i=n.createSelection(e.start);if(n.modifySelection(i,{direction:s}),i.focus.isEqual(e.start)){const t=function(t,e){let n=e;for(const o of e.getAncestors({parentFirst:!0})){if(o.childCount>1||t.isLimit(o))break;n=o}return n}(o,e.start.parent);n.deleteContent(n.createSelection(t,"on"),{doNotAutoparagraph:!0})}else n.change((n=>{n.setSelection(e),t.execute(l?"deleteForward":"delete")}))}else n.change((n=>{n.setSelection(e),t.execute(l?"deleteForward":"delete")}))}i.preventDefault(),e.stop()}),{context:Xp})}_enableInsertContentIntegration(){const t=this.editor,e=this.editor.model,n=e.document.selection;this._listenToIfEnabled(t.model,"insertContent",((t,[o,i])=>{if(i&&!i.is("documentSelection"))return;const r=uf(n);return r?(t.stop(),e.change((t=>{const i=n.getSelectedElement(),s=e.createPositionAt(i,r),a=t.createSelection(s),l=e.insertContent(o,a);return t.setSelection(a),l}))):void 0}),{priority:"high"})}_enableInsertObjectIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"insertObject",((t,n)=>{const[,o,,i={}]=n;if(o&&!o.is("documentSelection"))return;const r=uf(e);r&&(i.findOptimalPosition=r,n[3]=i)}),{priority:"high"})}_enableDeleteContentIntegration(){const t=this.editor,e=this.editor.model.document.selection;this._listenToIfEnabled(t.model,"deleteContent",((t,[n])=>{if(n&&!n.is("documentSelection"))return;uf(e)&&t.stop()}),{priority:"high"})}}function kf(t){const e=t.model;return(n,o)=>{const i=o.keyCode==ur.arrowup,r=o.keyCode==ur.arrowdown,s=o.shiftKey,a=e.document.selection;if(!i&&!r)return;const l=r;if(s&&function(t,e){return!t.isCollapsed&&t.isBackward==e}(a,l))return;const c=function(t,e,n){const o=t.model;if(n){const t=e.isCollapsed?e.focus:e.getLastPosition(),n=wf(o,t,"forward");if(!n)return null;const i=o.createRange(t,n),r=Af(o.schema,i,"backward");return r?o.createRange(t,r):null}{const t=e.isCollapsed?e.focus:e.getFirstPosition(),n=wf(o,t,"backward");if(!n)return null;const i=o.createRange(n,t),r=Af(o.schema,i,"forward");return r?o.createRange(r,t):null}}(t,a,l);if(c){if(c.isCollapsed){if(a.isCollapsed)return;if(s)return}(c.isCollapsed||function(t,e,n){const o=t.model,i=t.view.domConverter;if(n){const t=o.createSelection(e.start);o.modifySelection(t),t.focus.isAtEnd||e.start.isEqual(t.focus)||(e=o.createRange(t.focus,e.end))}const r=t.mapper.toViewRange(e),s=i.viewRangeToDom(r),a=Da.getDomRangeRects(s);let l;for(const t of a)if(void 0!==l){if(Math.round(t.top)>=l)return!1;l=Math.max(l,Math.round(t.bottom))}else l=Math.round(t.bottom);return!0}(t,c,l))&&(e.change((t=>{const n=l?c.end:c.start;if(s){const o=e.createSelection(a.anchor);o.setFocus(n),t.setSelection(o)}else t.setSelection(n)})),n.stop(),o.preventDefault(),o.stopPropagation())}}}function wf(t,e,n){const o=t.schema,i=t.createRangeIn(e.root),r="forward"==n?"elementStart":"elementEnd";for(const{previousPosition:t,item:s,type:a}of i.getWalker({startPosition:e,direction:n})){if(o.isLimit(s)&&!o.isInline(s))return t;if(a==r&&o.isBlock(s))return null}return null}function Af(t,e,n){const o="backward"==n?e.end:e.start;if(t.checkChild(o,"$text"))return o;for(const{nextPosition:o}of e.getWalker({direction:n}))if(t.checkChild(o,"$text"))return o;return null}var Cf=n(6507),_f={attributes:{"data-cke":!0}};_f.setAttributes=is(),_f.insert=ns().bind(null,"head"),_f.domAPI=ts(),_f.insertStyleElement=ss();Jr()(Cf.Z,_f);Cf.Z&&Cf.Z.locals&&Cf.Z.locals;class vf extends V{static get pluginName(){return"Widget"}static get requires(){return[bf,Kg]}init(){const t=this.editor,e=t.editing.view,n=e.document;this._previouslySelected=new Set,this.editor.editing.downcastDispatcher.on("selection",((e,n,o)=>{const i=o.writer,r=n.selection;if(r.isCollapsed)return;const s=r.getSelectedElement();if(!s)return;const a=t.editing.mapper.toViewElement(s);Xp(a)&&o.consumable.consume(r,"selection")&&i.setSelection(i.createRangeOn(a),{fake:!0,label:rf(a)})})),this.editor.editing.downcastDispatcher.on("selection",((t,e,n)=>{this._clearPreviouslySelectedWidgets(n.writer);const o=n.writer,i=o.document.selection;let r=null;for(const t of i.getRanges())for(const e of t){const t=e.item;Xp(t)&&!yf(t,r)&&(o.addClass(Jp,t),this._previouslySelected.add(t),r=t)}}),{priority:"low"}),e.addObserver(zm),this.listenTo(n,"mousedown",((...t)=>this._onMousedown(...t))),this.listenTo(n,"arrowKey",((...t)=>{this._handleSelectionChangeOnArrowKeyPress(...t)}),{context:[Xp,"$text"]}),this.listenTo(n,"arrowKey",((...t)=>{this._preventDefaultOnArrowKeyPress(...t)}),{context:"$root"}),this.listenTo(n,"arrowKey",kf(this.editor.editing),{context:"$text"}),this.listenTo(n,"delete",((t,e)=>{this._handleDelete("forward"==e.direction)&&(e.preventDefault(),t.stop())}),{context:"$root"})}_onMousedown(t,e){const n=this.editor,o=n.editing.view,i=o.document;let r=e.target;if(function(t){for(;t;){if(t.is("editableElement")&&!t.is("rootElement"))return!0;if(Xp(t))return!1;t=t.parent}return!1}(r)){if((ar.isSafari||ar.isGecko)&&e.domEvent.detail>=3){const t=n.editing.mapper,o=r.is("attributeElement")?r.findAncestor((t=>!t.is("attributeElement"))):r,i=t.toModelElement(o);e.preventDefault(),this.editor.model.change((t=>{t.setSelection(i,"in")}))}return}if(!Xp(r)&&(r=r.findAncestor(Xp),!r))return;ar.isAndroid&&e.preventDefault(),i.isFocused||o.focus();const s=n.editing.mapper.toModelElement(r);this._setSelectionOverElement(s)}_handleSelectionChangeOnArrowKeyPress(t,e){const n=e.keyCode,o=this.editor.model,i=o.schema,r=o.document.selection,s=r.getSelectedElement(),a=fr(n,this.editor.locale.contentLanguageDirection),l="down"==a||"right"==a,c="up"==a||"down"==a;if(s&&i.isObject(s)){const n=l?r.getLastPosition():r.getFirstPosition(),s=i.getNearestSelectionRange(n,l?"forward":"backward");return void(s&&(o.change((t=>{t.setSelection(s)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed&&!e.shiftKey){const n=r.getFirstPosition(),s=r.getLastPosition(),a=n.nodeAfter,c=s.nodeBefore;return void((a&&i.isObject(a)||c&&i.isObject(c))&&(o.change((t=>{t.setSelection(l?s:n)})),e.preventDefault(),t.stop()))}if(!r.isCollapsed)return;const d=this._getObjectElementNextToSelection(l);if(d&&i.isObject(d)){if(i.isInline(d)&&c)return;this._setSelectionOverElement(d),e.preventDefault(),t.stop()}}_preventDefaultOnArrowKeyPress(t,e){const n=this.editor.model,o=n.schema,i=n.document.selection.getSelectedElement();i&&o.isObject(i)&&(e.preventDefault(),t.stop())}_handleDelete(t){if(this.editor.isReadOnly)return;const e=this.editor.model.document.selection;if(!e.isCollapsed)return;const n=this._getObjectElementNextToSelection(t);return n?(this.editor.model.change((t=>{let o=e.anchor.parent;for(;o.isEmpty;){const e=o;o=e.parent,t.remove(e)}this._setSelectionOverElement(n)})),!0):void 0}_setSelectionOverElement(t){this.editor.model.change((e=>{e.setSelection(e.createRangeOn(t))}))}_getObjectElementNextToSelection(t){const e=this.editor.model,n=e.schema,o=e.document.selection,i=e.createSelection(o);if(e.modifySelection(i,{direction:t?"forward":"backward"}),i.isEqual(o))return null;const r=t?i.focus.nodeBefore:i.focus.nodeAfter;return r&&n.isObject(r)?r:null}_clearPreviouslySelectedWidgets(t){for(const e of this._previouslySelected)t.removeClass(Jp,e);this._previouslySelected.clear()}}function yf(t,e){return!!e&&Array.from(t.getAncestors()).includes(e)}const xf=function(t,e,n){var o=!0,i=!0;if("function"!=typeof t)throw new TypeError("Expected a function");return E(n)&&(o="leading"in n?!!n.leading:o,i="trailing"in n?!!n.trailing:i),pa(t,e,{leading:o,maxWait:e,trailing:i})};var Ef=n(390),Df={attributes:{"data-cke":!0}};Df.setAttributes=is(),Df.insert=ns().bind(null,"head"),Df.domAPI=ts(),Df.insertStyleElement=ss();Jr()(Ef.Z,Df);Ef.Z&&Ef.Z.locals&&Ef.Z.locals;class Sf extends V{static get pluginName(){return"DragDrop"}static get requires(){return[Wp,vf]}init(){const t=this.editor,e=t.editing.view;this._draggedRange=null,this._draggingUid="",this._draggableElement=null,this._updateDropMarkerThrottled=xf((t=>this._updateDropMarker(t)),40),this._removeDropMarkerDelayed=Mf((()=>this._removeDropMarker()),40),this._clearDraggableAttributesDelayed=Mf((()=>this._clearDraggableAttributes()),40),e.addObserver(Up),e.addObserver(zm),this._setupDragging(),this._setupContentInsertionIntegration(),this._setupClipboardInputIntegration(),this._setupDropMarker(),this._setupDraggableAttributeHandling(),this.listenTo(t,"change:isReadOnly",((t,e,n)=>{n?this.forceDisabled("readOnlyMode"):this.clearForceDisabled("readOnlyMode")})),this.on("change:isEnabled",((t,e,n)=>{n||this._finalizeDragging(!1)})),ar.isAndroid&&this.forceDisabled("noAndroidSupport")}destroy(){return this._draggedRange&&(this._draggedRange.detach(),this._draggedRange=null),this._updateDropMarkerThrottled.cancel(),this._removeDropMarkerDelayed.cancel(),this._clearDraggableAttributesDelayed.cancel(),super.destroy()}_setupDragging(){const t=this.editor,e=t.model,n=e.document,o=t.editing.view,i=o.document;this.listenTo(i,"dragstart",((o,s)=>{const a=n.selection;if(s.target&&s.target.is("editableElement"))return void s.preventDefault();const l=s.target?Bf(s.target):null;if(l){const n=t.editing.mapper.toModelElement(l);this._draggedRange=bl.fromRange(e.createRangeOn(n)),t.plugins.has("WidgetToolbarRepository")&&t.plugins.get("WidgetToolbarRepository").forceDisabled("dragDrop")}else if(!i.selection.isCollapsed){const t=i.selection.getSelectedElement();t&&Xp(t)||(this._draggedRange=bl.fromRange(a.getFirstRange()))}if(!this._draggedRange)return void s.preventDefault();this._draggingUid=r(),s.dataTransfer.effectAllowed=this.isEnabled?"copyMove":"copy",s.dataTransfer.setData("application/ckeditor5-dragging-uid",this._draggingUid);const c=e.createSelection(this._draggedRange.toRange()),d=t.data.toView(e.getSelectedContent(c));i.fire("clipboardOutput",{dataTransfer:s.dataTransfer,content:d,method:o.name}),this.isEnabled||(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="")}),{priority:"low"}),this.listenTo(i,"dragend",((t,e)=>{this._finalizeDragging(!e.dataTransfer.isCanceled&&"move"==e.dataTransfer.dropEffect)}),{priority:"low"}),this.listenTo(i,"dragenter",(()=>{this.isEnabled&&o.focus()})),this.listenTo(i,"dragleave",(()=>{this._removeDropMarkerDelayed()})),this.listenTo(i,"dragging",((e,n)=>{if(!this.isEnabled)return void(n.dataTransfer.dropEffect="none");this._removeDropMarkerDelayed.cancel();const o=If(t,n.targetRanges,n.target);this._draggedRange||(n.dataTransfer.dropEffect="copy"),ar.isGecko||("copy"==n.dataTransfer.effectAllowed?n.dataTransfer.dropEffect="copy":["all","copyMove"].includes(n.dataTransfer.effectAllowed)&&(n.dataTransfer.dropEffect="move")),o&&this._updateDropMarkerThrottled(o)}),{priority:"low"})}_setupClipboardInputIntegration(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"clipboardInput",((e,n)=>{if("drop"!=n.method)return;const o=If(t,n.targetRanges,n.target);if(this._removeDropMarker(),!o)return this._finalizeDragging(!1),void e.stop();this._draggedRange&&this._draggingUid!=n.dataTransfer.getData("application/ckeditor5-dragging-uid")&&(this._draggedRange.detach(),this._draggedRange=null,this._draggingUid="");if("move"==Tf(n.dataTransfer)&&this._draggedRange&&this._draggedRange.containsRange(o,!0))return this._finalizeDragging(!1),void e.stop();n.targetRanges=[t.editing.mapper.toViewRange(o)]}),{priority:"high"})}_setupContentInsertionIntegration(){const t=this.editor.plugins.get(Wp);t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n=e.targetRanges.map((t=>this.editor.editing.mapper.toModelRange(t)));this.editor.model.change((t=>t.setSelection(n)))}),{priority:"high"}),t.on("contentInsertion",((t,e)=>{if(!this.isEnabled||"drop"!==e.method)return;const n="move"==Tf(e.dataTransfer),o=!e.resultRange||!e.resultRange.isCollapsed;this._finalizeDragging(o&&n)}),{priority:"lowest"})}_setupDraggableAttributeHandling(){const t=this.editor,e=t.editing.view,n=e.document;this.listenTo(n,"mousedown",((o,i)=>{if(ar.isAndroid||!i)return;this._clearDraggableAttributesDelayed.cancel();let r=Bf(i.target);if(ar.isBlink&&!t.isReadOnly&&!r&&!n.selection.isCollapsed){const t=n.selection.getSelectedElement();t&&Xp(t)||(r=n.selection.editableElement)}r&&(e.change((t=>{t.setAttribute("draggable","true",r)})),this._draggableElement=t.editing.mapper.toModelElement(r))})),this.listenTo(n,"mouseup",(()=>{ar.isAndroid||this._clearDraggableAttributesDelayed()}))}_clearDraggableAttributes(){const t=this.editor.editing;t.view.change((e=>{this._draggableElement&&"$graveyard"!=this._draggableElement.root.rootName&&e.removeAttribute("draggable",t.mapper.toViewElement(this._draggableElement)),this._draggableElement=null}))}_setupDropMarker(){const t=this.editor;t.conversion.for("editingDowncast").markerToHighlight({model:"drop-target",view:{classes:["ck-clipboard-drop-target-range"]}}),t.conversion.for("editingDowncast").markerToElement({model:"drop-target",view:(e,{writer:n})=>{if(t.model.schema.checkChild(e.markerRange.start,"$text"))return n.createUIElement("span",{class:"ck ck-clipboard-drop-target-position"},(function(t){const e=this.toDomElement(t);return e.innerHTML="⁠⁠",e}))}})}_updateDropMarker(t){const e=this.editor,n=e.model.markers;e.model.change((e=>{n.has("drop-target")?n.get("drop-target").getRange().isEqual(t)||e.updateMarker("drop-target",{range:t}):e.addMarker("drop-target",{range:t,usingOperation:!1,affectsData:!1})}))}_removeDropMarker(){const t=this.editor.model;this._removeDropMarkerDelayed.cancel(),this._updateDropMarkerThrottled.cancel(),t.markers.has("drop-target")&&t.change((t=>{t.removeMarker("drop-target")}))}_finalizeDragging(t){const e=this.editor,n=e.model;this._removeDropMarker(),this._clearDraggableAttributes(),e.plugins.has("WidgetToolbarRepository")&&e.plugins.get("WidgetToolbarRepository").clearForceDisabled("dragDrop"),this._draggingUid="",this._draggedRange&&(t&&this.isEnabled&&n.deleteContent(n.createSelection(this._draggedRange),{doNotAutoparagraph:!0}),this._draggedRange.detach(),this._draggedRange=null)}}function If(t,e,n){const o=t.model,i=t.editing.mapper;let r=null;const s=e?e[0].start:null;if(n.is("uiElement")&&(n=n.parent),r=function(t,e){const n=t.model,o=t.editing.mapper;if(Xp(e))return n.createRangeOn(o.toModelElement(e));if(!e.is("editableElement")){const t=e.findAncestor((t=>Xp(t)||t.is("editableElement")));if(Xp(t))return n.createRangeOn(o.toModelElement(t))}return null}(t,n),r)return r;const a=function(t,e){const n=t.editing.mapper,o=t.editing.view,i=n.toModelElement(e);if(i)return i;const r=o.createPositionBefore(e),s=n.findMappedViewAncestor(r);return n.toModelElement(s)}(t,n),l=s?i.toModelPosition(s):null;return l?(r=function(t,e,n){const o=t.model;if(!o.schema.checkChild(n,"$block"))return null;const i=o.createPositionAt(n,0),r=e.path.slice(0,i.path.length),s=o.createPositionFromPath(e.root,r).nodeAfter;if(s&&o.schema.isObject(s))return o.createRangeOn(s);return null}(t,l,a),r||(r=o.schema.getNearestSelectionRange(l,ar.isGecko?"forward":"backward"),r||function(t,e){const n=t.model;for(;e;){if(n.schema.isObject(e))return n.createRangeOn(e);e=e.parent}}(t,l.parent))):function(t,e){const n=t.model,o=n.schema,i=n.createPositionAt(e,0);return o.getNearestSelectionRange(i,"forward")}(t,a)}function Tf(t){return ar.isGecko?t.dropEffect:["all","copyMove"].includes(t.effectAllowed)?"move":"copy"}function Mf(t,e){let n;function o(...i){o.cancel(),n=setTimeout((()=>t(...i)),e)}return o.cancel=()=>{clearTimeout(n)},o}function Bf(t){if(t.is("editableElement"))return null;if(t.hasClass("ck-widget__selection-handle"))return t.findAncestor(Xp);if(Xp(t))return t;const e=t.findAncestor((t=>Xp(t)||t.is("editableElement")));return Xp(e)?e:null}class Nf extends V{static get pluginName(){return"PastePlainText"}static get requires(){return[Wp]}init(){const t=this.editor,e=t.model,n=t.editing.view,o=n.document,i=e.document.selection;let r=!1;n.addObserver(Up),this.listenTo(o,"keydown",((t,e)=>{r=e.shiftKey})),t.plugins.get(Wp).on("contentInsertion",((t,n)=>{(r||function(t,e){if(t.childCount>1)return!1;const n=t.getChild(0);if(e.isObject(n))return!1;return 0==[...n.getAttributeKeys()].length}(n.content,e.schema))&&e.change((t=>{const o=Array.from(i.getAttributes()).filter((([t])=>e.schema.getAttributeProperties(t).isFormatting));i.isCollapsed||e.deleteContent(i,{doNotAutoparagraph:!0}),o.push(...i.getAttributes());const r=t.createRangeIn(n.content);for(const e of r.getItems())e.is("$textProxy")&&t.setAttributes(o,e)}))}))}}class zf extends V{static get pluginName(){return"Clipboard"}static get requires(){return[Wp,Sf,Nf]}}class Pf extends H{constructor(t){super(t),this.affectsData=!1}execute(){const t=this.editor.model,e=t.document.selection;let n=t.schema.getLimitElement(e);if(e.containsEntireContent(n)||!Lf(t.schema,n))do{if(n=n.parent,!n)return}while(!Lf(t.schema,n));t.change((t=>{t.setSelection(n,"in")}))}}function Lf(t,e){return t.isLimit(e)&&(t.checkChild(e,"$text")||t.checkChild(e,"paragraph"))}const Of=gr("Ctrl+A");class Rf extends V{static get pluginName(){return"SelectAllEditing"}init(){const t=this.editor,e=t.editing.view.document;t.commands.add("selectAll",new Pf(t)),this.listenTo(e,"keydown",((e,n)=>{mr(n)===Of&&(t.execute("selectAll"),n.preventDefault())}))}}class jf extends V{static get pluginName(){return"SelectAllUI"}init(){const t=this.editor;t.ui.componentFactory.add("selectAll",(e=>{const n=t.commands.get("selectAll"),o=new Su(e),i=e.t;return o.set({label:i("Select all"),icon:'',keystroke:"Ctrl+A",tooltip:!0}),o.bind("isOn","isEnabled").to(n,"value","isEnabled"),this.listenTo(o,"execute",(()=>{t.execute("selectAll"),t.editing.view.focus()})),o}))}}class Vf extends V{static get requires(){return[Rf,jf]}static get pluginName(){return"SelectAll"}}class Ff extends H{constructor(t){super(t),this._stack=[],this._createdBatches=new WeakSet,this.refresh(),this.listenTo(t.data,"set",((t,e)=>{e[1]={...e[1]};const n=e[1];n.batchType||(n.batchType={isUndoable:!1})}),{priority:"high"}),this.listenTo(t.data,"set",((t,e)=>{e[1].batchType.isUndoable||this.clearStack()}))}refresh(){this.isEnabled=this._stack.length>0}addBatch(t){const e=this.editor.model.document.selection,n={ranges:e.hasOwnRange?Array.from(e.getRanges()):[],isBackward:e.isBackward};this._stack.push({batch:t,selection:n}),this.refresh()}clearStack(){this._stack=[],this.refresh()}_restoreSelection(t,e,n){const o=this.editor.model,i=o.document,r=[],s=t.map((t=>t.getTransformedByOperations(n))),a=s.flat();for(const t of s){const e=t.filter((t=>t.root!=i.graveyard)).filter((t=>!Uf(t,a)));e.length&&(Hf(e),r.push(e[0]))}r.length&&o.change((t=>{t.setSelection(r,{backward:e})}))}_undo(t,e){const n=this.editor.model,o=n.document;this._createdBatches.add(e);const i=t.operations.slice().filter((t=>t.isDocumentOperation));i.reverse();for(const t of i){const i=t.baseVersion+1,r=Array.from(o.history.getOperations(i)),s=Em([t.getReversed()],r,{useRelations:!0,document:this.editor.model.document,padWithNoOps:!1,forceWeakRemove:!0}).operationsA;for(const i of s)e.addOperation(i),n.applyOperation(i),o.history.setOperationAsUndone(t,i)}}}function Hf(t){t.sort(((t,e)=>t.start.isBefore(e.start)?-1:1));for(let e=1;ee!==t&&e.containsRange(t,!0)))}class qf extends Ff{execute(t=null){const e=t?this._stack.findIndex((e=>e.batch==t)):this._stack.length-1,n=this._stack.splice(e,1)[0],o=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(o,(()=>{this._undo(n.batch,o);const t=this.editor.model.document.history.getOperations(n.batch.baseVersion);this._restoreSelection(n.selection.ranges,n.selection.isBackward,t),this.fire("revert",n.batch,o)})),this.refresh()}}class Gf extends Ff{execute(){const t=this._stack.pop(),e=this.editor.model.createBatch({isUndo:!0});this.editor.model.enqueueChange(e,(()=>{const n=t.batch.operations[t.batch.operations.length-1].baseVersion+1,o=this.editor.model.document.history.getOperations(n);this._restoreSelection(t.selection.ranges,t.selection.isBackward,o),this._undo(t.batch,e)})),this.refresh()}}class Wf extends V{static get pluginName(){return"UndoEditing"}constructor(t){super(t),this._batchRegistry=new WeakSet}init(){const t=this.editor;this._undoCommand=new qf(t),this._redoCommand=new Gf(t),t.commands.add("undo",this._undoCommand),t.commands.add("redo",this._redoCommand),this.listenTo(t.model,"applyOperation",((t,e)=>{const n=e[0];if(!n.isDocumentOperation)return;const o=n.batch,i=this._redoCommand._createdBatches.has(o),r=this._undoCommand._createdBatches.has(o);this._batchRegistry.has(o)||(this._batchRegistry.add(o),o.isUndoable&&(i?this._undoCommand.addBatch(o):r||(this._undoCommand.addBatch(o),this._redoCommand.clearStack())))}),{priority:"highest"}),this.listenTo(this._undoCommand,"revert",((t,e,n)=>{this._redoCommand.addBatch(n)})),t.keystrokes.set("CTRL+Z","undo"),t.keystrokes.set("CTRL+Y","redo"),t.keystrokes.set("CTRL+SHIFT+Z","redo")}}const Zf='',Yf='';class Kf extends V{static get pluginName(){return"UndoUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?Zf:Yf,i="ltr"==e.uiLanguageDirection?Yf:Zf;this._addButton("undo",n("Undo"),"CTRL+Z",o),this._addButton("redo",n("Redo"),"CTRL+Y",i)}_addButton(t,e,n,o){const i=this.editor;i.ui.componentFactory.add(t,(r=>{const s=i.commands.get(t),a=new Su(r);return a.set({label:e,icon:o,keystroke:n,tooltip:!0}),a.bind("isEnabled").to(s,"isEnabled"),this.listenTo(a,"execute",(()=>{i.execute(t),i.editing.view.focus()})),a}))}}class $f extends V{static get requires(){return[Wf,Kf]}static get pluginName(){return"Undo"}}class Qf extends H{constructor(t,e){super(t),this.attributeKey=e}refresh(){const t=this.editor.model,e=t.document;this.value=e.selection.getAttribute(this.attributeKey),this.isEnabled=t.schema.checkAttributeInSelection(e.selection,this.attributeKey)}execute(t={}){const e=this.editor.model,n=e.document.selection,o=t.value;e.change((t=>{if(n.isCollapsed)o?t.setSelectionAttribute(this.attributeKey,o):t.removeSelectionAttribute(this.attributeKey);else{const i=e.schema.getValidRanges(n.getRanges(),this.attributeKey);for(const e of i)o?t.setAttribute(this.attributeKey,o,e):t.removeAttribute(this.attributeKey,e)}}))}}class Jf extends bo{constructor(t){super(t),this.set("isEmpty",!0),this.on("change",(()=>{this.set("isEmpty",0===this.length)}))}add(t,e){this.find((e=>e.color===t.color))||super.add(t,e)}hasColor(t){return!!this.find((e=>e.color===t))}}j(Jf,N);var Xf=n(2585),tb={attributes:{"data-cke":!0}};tb.setAttributes=is(),tb.insert=ns().bind(null,"head"),tb.domAPI=ts(),tb.insertStyleElement=ss();Jr()(Xf.Z,tb);Xf.Z&&Xf.Z.locals&&Xf.Z.locals;class eb extends Jd{constructor(t,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r}){super(t),this.items=this.createCollection(),this.colorDefinitions=e,this.focusTracker=new za,this.keystrokes=new Pa,this.set("selectedColor"),this.removeButtonLabel=o,this.columns=n,this.documentColors=new Jf,this.documentColorsCount=r,this._focusCycler=new Ou({focusables:this.items,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"arrowup",focusNext:"arrowdown"}}),this._documentColorsLabel=i,this.setTemplate({tag:"div",attributes:{class:["ck","ck-color-table"]},children:this.items}),this.items.add(this._removeColorButton())}updateDocumentColors(t,e){const n=t.document,o=this.documentColorsCount;this.documentColors.clear();for(const i of n.getRootNames()){const r=n.getRoot(i),s=t.createRangeIn(r);for(const t of s.getItems())if(t.is("$textProxy")&&t.hasAttribute(e)&&(this._addColorToDocumentColors(t.getAttribute(e)),this.documentColors.length>=o))return}}updateSelectedColors(){const t=this.documentColorsGrid,e=this.staticColorsGrid,n=this.selectedColor;e.selectedColor=n,t&&(t.selectedColor=n)}render(){super.render();for(const t of this.items)this.focusTracker.add(t.element);this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}appendGrids(){if(!this.staticColorsGrid&&(this.staticColorsGrid=this._createStaticColorsGrid(),this.items.add(this.staticColorsGrid),this.documentColorsCount)){const t=Xd.bind(this.documentColors,this.documentColors),e=new Dh(this.locale);e.text=this._documentColorsLabel,e.extendTemplate({attributes:{class:["ck","ck-color-grid__label",t.if("isEmpty","ck-hidden")]}}),this.items.add(e),this.documentColorsGrid=this._createDocumentColorsGrid(),this.items.add(this.documentColorsGrid)}}focus(){this._focusCycler.focusFirst()}focusLast(){this._focusCycler.focusLast()}_removeColorButton(){const t=new Su;return t.set({withText:!0,icon:Gd.eraser,tooltip:!0,label:this.removeButtonLabel}),t.class="ck-color-table__remove-color",t.on("execute",(()=>{this.fire("execute",{value:null})})),t}_createStaticColorsGrid(){const t=new Fu(this.locale,{colorDefinitions:this.colorDefinitions,columns:this.columns});return t.delegate("execute").to(this),t}_createDocumentColorsGrid(){const t=Xd.bind(this.documentColors,this.documentColors),e=new Fu(this.locale,{columns:this.columns});return e.delegate("execute").to(this),e.extendTemplate({attributes:{class:t.if("isEmpty","ck-hidden")}}),e.items.bindTo(this.documentColors).using((t=>{const e=new Pu;return e.set({color:t.color,hasBorder:t.options&&t.options.hasBorder}),t.label&&e.set({label:t.label,tooltip:!0}),e.on("execute",(()=>{this.fire("execute",{value:t.color})})),e})),this.documentColors.on("change:isEmpty",((t,n,o)=>{o&&(e.selectedColor=null)})),e}_addColorToDocumentColors(t){const e=this.colorDefinitions.find((e=>e.color===t));e?this.documentColors.add(Object.assign({},e)):this.documentColors.add({color:t,label:t,options:{hasBorder:!1}})}}const nb="fontSize",ob="fontFamily",ib="fontColor";function rb(t,e){const n={model:{key:t,values:[]},view:{},upcastAlso:{}};for(const t of e)n.model.values.push(t.model),n.view[t.model]=t.view,t.upcastAlso&&(n.upcastAlso[t.model]=t.upcastAlso);return n}function sb(t){return(e,{writer:n})=>n.createAttributeElement("span",{style:`${t}:${e}`},{priority:7})}class ab extends Qf{constructor(t){super(t,ib)}}class lb extends V{static get pluginName(){return"FontColorEditing"}constructor(t){var e;super(t),t.config.define(ib,{colors:[{color:"hsl(0, 0%, 0%)",label:"Black"},{color:"hsl(0, 0%, 30%)",label:"Dim grey"},{color:"hsl(0, 0%, 60%)",label:"Grey"},{color:"hsl(0, 0%, 90%)",label:"Light grey"},{color:"hsl(0, 0%, 100%)",label:"White",hasBorder:!0},{color:"hsl(0, 75%, 60%)",label:"Red"},{color:"hsl(30, 75%, 60%)",label:"Orange"},{color:"hsl(60, 75%, 60%)",label:"Yellow"},{color:"hsl(90, 75%, 60%)",label:"Light green"},{color:"hsl(120, 75%, 60%)",label:"Green"},{color:"hsl(150, 75%, 60%)",label:"Aquamarine"},{color:"hsl(180, 75%, 60%)",label:"Turquoise"},{color:"hsl(210, 75%, 60%)",label:"Light blue"},{color:"hsl(240, 75%, 60%)",label:"Blue"},{color:"hsl(270, 75%, 60%)",label:"Purple"}],columns:5}),t.conversion.for("upcast").elementToAttribute({view:{name:"span",styles:{color:/[\s\S]+/}},model:{key:ib,value:(e="color",t=>t.getStyle(e).replace(/\s/g,""))}}),t.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{color:/^#?\w+$/}},model:{key:ib,value:t=>t.getAttribute("color")}}),t.conversion.for("downcast").attributeToElement({model:ib,view:sb("color")}),t.commands.add(ib,new ab(t)),t.model.schema.extend("$text",{allowAttributes:ib}),t.model.schema.setAttributeProperties(ib,{isFormatting:!0,copyOnEnter:!0})}}class cb extends V{constructor(t,{commandName:e,icon:n,componentName:o,dropdownLabel:i}){super(t),this.commandName=e,this.componentName=o,this.icon=n,this.dropdownLabel=i,this.columns=t.config.get(`${this.componentName}.columns`),this.colorTableView=void 0}init(){const t=this.editor,e=t.locale,n=e.t,o=t.commands.get(this.commandName),i=Bu(e,Nu(t.config.get(this.componentName).colors)),r=t.config.get(`${this.componentName}.documentColors`);t.ui.componentFactory.add(this.componentName,(e=>{const s=kh(e);return this.colorTableView=function({dropdownView:t,colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r}){const s=t.locale,a=new eb(s,{colors:e,columns:n,removeButtonLabel:o,documentColorsLabel:i,documentColorsCount:r});return t.colorTableView=a,t.panelView.children.add(a),a.delegate("execute").to(t,"execute"),a}({dropdownView:s,colors:i.map((t=>({label:t.label,color:t.model,options:{hasBorder:t.hasBorder}}))),columns:this.columns,removeButtonLabel:n("Remove color"),documentColorsLabel:0!==r?n("Document colors"):void 0,documentColorsCount:void 0===r?this.columns:r}),this.colorTableView.bind("selectedColor").to(o,"value"),s.buttonView.set({label:this.dropdownLabel,icon:this.icon,tooltip:!0}),s.extendTemplate({attributes:{class:"ck-color-ui-dropdown"}}),s.bind("isEnabled").to(o),s.on("execute",((e,n)=>{t.execute(this.commandName,n),t.editing.view.focus()})),s.on("change:isOpen",((e,n,o)=>{s.colorTableView.appendGrids(),o&&(0!==r&&this.colorTableView.updateDocumentColors(t.model,this.componentName),this.colorTableView.updateSelectedColors())})),Ch(s,(()=>s.colorTableView.staticColorsGrid.items.find((t=>t.isOn)))),s}))}}class db extends cb{constructor(t){const e=t.locale.t;super(t,{commandName:ib,componentName:ib,icon:'',dropdownLabel:e("Font Color")})}static get pluginName(){return"FontColorUI"}}class ub extends Qf{constructor(t){super(t,ob)}}function hb(t){return t.map(mb).filter((t=>!!t))}function mb(t){return"object"==typeof t?t:"default"===t?{title:"Default",model:void 0}:"string"==typeof t?function(t){const e=t.replace(/"|'/g,"").split(","),n=e[0],o=e.map(gb).join(", ");return{title:n,model:o,view:{name:"span",styles:{"font-family":o},priority:7}}}(t):void 0}function gb(t){return(t=t.trim()).indexOf(" ")>0&&(t=`'${t}'`),t}class pb extends V{static get pluginName(){return"FontFamilyEditing"}constructor(t){super(t),t.config.define(ob,{options:["default","Arial, Helvetica, sans-serif","Courier New, Courier, monospace","Georgia, serif","Lucida Sans Unicode, Lucida Grande, sans-serif","Tahoma, Geneva, sans-serif","Times New Roman, Times, serif","Trebuchet MS, Helvetica, sans-serif","Verdana, Geneva, sans-serif"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:ob}),t.model.schema.setAttributeProperties(ob,{isFormatting:!0,copyOnEnter:!0});const e=hb(t.config.get("fontFamily.options")).filter((t=>t.model)),n=rb(ob,e);t.config.get("fontFamily.supportAllValues")?(this._prepareAnyValueConverters(),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(n),t.commands.add(ob,new ub(t))}_prepareAnyValueConverters(){const t=this.editor;t.conversion.for("downcast").attributeToElement({model:ob,view:(t,{writer:e})=>e.createAttributeElement("span",{style:"font-family:"+t},{priority:7})}),t.conversion.for("upcast").elementToAttribute({model:{key:ob,value:t=>t.getStyle("font-family")},view:{name:"span",styles:{"font-family":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{face:/.*/}},model:{key:ob,value:t=>t.getAttribute("face")}})}}class fb extends V{static get pluginName(){return"FontFamilyUI"}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(ob);t.ui.componentFactory.add(ob,(i=>{const r=kh(i);return Ah(r,function(t,e){const n=new bo;for(const o of t){const t={type:"button",model:new Wh({commandName:ob,commandParam:o.model,label:o.title,withText:!0})};t.model.bind("isOn").to(e,"value",(t=>t===o.model||!(!t||!o.model)&&t.split(",")[0].replace(/'/g,"").toLowerCase()===o.model.toLowerCase())),o.view&&o.view.styles&&t.model.set("labelStyle",`font-family: ${o.view.styles["font-family"]}`),n.add(t)}return n}(n,o)),r.buttonView.set({label:e("Font Family"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:"ck-font-family-dropdown"}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",(e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()})),r}))}_getLocalizedOptions(){const t=this.editor,e=t.t;return hb(t.config.get(ob).options).map((t=>("Default"===t.title&&(t.title=e("Default")),t)))}}class bb extends Qf{constructor(t){super(t,nb)}}function kb(t){return t.map((t=>function(t){if(e=t,"object"==typeof e&&e.title&&e.model&&e.view)return Ab(t);var e;const n=function(t){return wb[t]||wb[t.model]}(t);if(n)return Ab(n);if("default"===t)return{model:void 0,title:"Default"};if(function(t){let e;if("object"==typeof t){if(!t.model)throw new l("font-size-invalid-definition",null,t);e=parseFloat(t.model)}else e=parseFloat(t);return isNaN(e)}(t))return;return function(t){"number"!=typeof t&&"string"!=typeof t||(t={title:String(t),model:`${parseFloat(t)}px`});return t.view={name:"span",styles:{"font-size":t.model}},Ab(t)}(t)}(t))).filter((t=>!!t))}const wb={get tiny(){return{title:"Tiny",model:"tiny",view:{name:"span",classes:"text-tiny",priority:7}}},get small(){return{title:"Small",model:"small",view:{name:"span",classes:"text-small",priority:7}}},get big(){return{title:"Big",model:"big",view:{name:"span",classes:"text-big",priority:7}}},get huge(){return{title:"Huge",model:"huge",view:{name:"span",classes:"text-huge",priority:7}}}};function Ab(t){return t.view.priority||(t.view.priority=7),t}const Cb=["x-small","x-small","small","medium","large","x-large","xx-large","xxx-large"];class _b extends V{static get pluginName(){return"FontSizeEditing"}constructor(t){super(t),t.config.define(nb,{options:["tiny","small","default","big","huge"],supportAllValues:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:nb}),t.model.schema.setAttributeProperties(nb,{isFormatting:!0,copyOnEnter:!0});const e=t.config.get("fontSize.supportAllValues"),n=kb(this.editor.config.get("fontSize.options")).filter((t=>t.model)),o=rb(nb,n);e?(this._prepareAnyValueConverters(o),this._prepareCompatibilityConverter()):t.conversion.attributeToElement(o),t.commands.add(nb,new bb(t))}_prepareAnyValueConverters(t){const e=this.editor,n=t.model.values.filter((t=>!Wm(String(t))&&!Ym(String(t))));if(n.length)throw new l("font-size-invalid-use-of-named-presets",null,{presets:n});e.conversion.for("downcast").attributeToElement({model:nb,view:(t,{writer:e})=>{if(t)return e.createAttributeElement("span",{style:"font-size:"+t},{priority:7})}}),e.conversion.for("upcast").elementToAttribute({model:{key:nb,value:t=>t.getStyle("font-size")},view:{name:"span",styles:{"font-size":/.*/}}})}_prepareCompatibilityConverter(){this.editor.conversion.for("upcast").elementToAttribute({view:{name:"font",attributes:{size:/^[+-]?\d{1,3}$/}},model:{key:nb,value:t=>{const e=t.getAttribute("size"),n="-"===e[0]||"+"===e[0];let o=parseInt(e,10);n&&(o=3+o);const i=Cb.length-1,r=Math.min(Math.max(o,0),i);return Cb[r]}}})}}var vb=n(6203),yb={attributes:{"data-cke":!0}};yb.setAttributes=is(),yb.insert=ns().bind(null,"head"),yb.domAPI=ts(),yb.insertStyleElement=ss();Jr()(vb.Z,yb);vb.Z&&vb.Z.locals&&vb.Z.locals;class xb extends V{static get pluginName(){return"FontSizeUI"}init(){const t=this.editor,e=t.t,n=this._getLocalizedOptions(),o=t.commands.get(nb);t.ui.componentFactory.add(nb,(i=>{const r=kh(i);return Ah(r,function(t,e){const n=new bo;for(const o of t){const t={type:"button",model:new Wh({commandName:nb,commandParam:o.model,label:o.title,class:"ck-fontsize-option",withText:!0})};o.view&&o.view.styles&&t.model.set("labelStyle",`font-size:${o.view.styles["font-size"]}`),o.view&&o.view.classes&&t.model.set("class",`${t.model.class} ${o.view.classes}`),t.model.bind("isOn").to(e,"value",(t=>t===o.model)),n.add(t)}return n}(n,o)),r.buttonView.set({label:e("Font Size"),icon:'',tooltip:!0}),r.extendTemplate({attributes:{class:["ck-font-size-dropdown"]}}),r.bind("isEnabled").to(o),this.listenTo(r,"execute",(e=>{t.execute(e.source.commandName,{value:e.source.commandParam}),t.editing.view.focus()})),r}))}_getLocalizedOptions(){const t=this.editor,e=t.t,n={Default:e("Default"),Tiny:e("Tiny"),Small:e("Small"),Big:e("Big"),Huge:e("Huge")};return kb(t.config.get(nb).options).map((t=>{const e=n[t.title];return e&&e!=t.title&&(t=Object.assign({},t,{title:e})),t}))}}class Eb extends H{refresh(){const t=this.editor.model,e=Ba(t.document.selection.getSelectedBlocks());this.value=!!e&&e.is("element","paragraph"),this.isEnabled=!!e&&Db(e,t.schema)}execute(t={}){const e=this.editor.model,n=e.document;e.change((o=>{const i=(t.selection||n.selection).getSelectedBlocks();for(const t of i)!t.is("element","paragraph")&&Db(t,e.schema)&&o.rename(t,"paragraph")}))}}function Db(t,e){return e.checkChild(t.parent,"paragraph")&&!e.isObject(t)}class Sb extends H{execute(t){const e=this.editor.model,n=t.attributes;let o=t.position;e.change((t=>{const i=t.createElement("paragraph");if(n&&e.schema.setAllowedAttributes(i,n,t),!e.schema.checkChild(o.parent,i)){const n=e.schema.findAllowedParent(o,i);if(!n)return;o=t.split(o,n).position}e.insertContent(i,o),t.setSelection(i,"in")}))}}class Ib extends V{static get pluginName(){return"Paragraph"}init(){const t=this.editor,e=t.model;t.commands.add("paragraph",new Eb(t)),t.commands.add("insertParagraph",new Sb(t)),e.schema.register("paragraph",{inheritAllFrom:"$block"}),t.conversion.elementToElement({model:"paragraph",view:"p"}),t.conversion.for("upcast").elementToElement({model:(t,{writer:e})=>Ib.paragraphLikeElements.has(t.name)?t.isEmpty?null:e.createElement("paragraph"):null,view:/.+/,converterPriority:"low"})}}Ib.paragraphLikeElements=new Set(["blockquote","dd","div","dt","h1","h2","h3","h4","h5","h6","li","p","td","th"]);class Tb extends H{constructor(t,e){super(t),this.modelElements=e}refresh(){const t=Ba(this.editor.model.document.selection.getSelectedBlocks());this.value=!!t&&this.modelElements.includes(t.name)&&t.name,this.isEnabled=!!t&&this.modelElements.some((e=>Mb(t,e,this.editor.model.schema)))}execute(t){const e=this.editor.model,n=e.document,o=t.value;e.change((t=>{const i=Array.from(n.selection.getSelectedBlocks()).filter((t=>Mb(t,o,e.schema)));for(const e of i)e.is("element",o)||t.rename(e,o)}))}}function Mb(t,e,n){return n.checkChild(t.parent,e)&&!n.isObject(t)}const Bb="paragraph";class Nb extends V{static get pluginName(){return"HeadingEditing"}constructor(t){super(t),t.config.define("heading",{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading1",view:"h2",title:"Heading 1",class:"ck-heading_heading1"},{model:"heading2",view:"h3",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h4",title:"Heading 3",class:"ck-heading_heading3"}]})}static get requires(){return[Ib]}init(){const t=this.editor,e=t.config.get("heading.options"),n=[];for(const o of e)o.model!==Bb&&(t.model.schema.register(o.model,{inheritAllFrom:"$block"}),t.conversion.elementToElement(o),n.push(o.model));this._addDefaultH1Conversion(t),t.commands.add("heading",new Tb(t,n))}afterInit(){const t=this.editor,e=t.commands.get("enter"),n=t.config.get("heading.options");e&&this.listenTo(e,"afterExecute",((e,o)=>{const i=t.model.document.selection.getFirstPosition().parent;n.some((t=>i.is("element",t.model)))&&!i.is("element",Bb)&&0===i.childCount&&o.writer.rename(i,Bb)}))}_addDefaultH1Conversion(t){t.conversion.for("upcast").elementToElement({model:"heading1",view:"h1",converterPriority:s.get("low")+1})}}var zb=n(3230),Pb={attributes:{"data-cke":!0}};Pb.setAttributes=is(),Pb.insert=ns().bind(null,"head"),Pb.domAPI=ts(),Pb.insertStyleElement=ss();Jr()(zb.Z,Pb);zb.Z&&zb.Z.locals&&zb.Z.locals;class Lb extends V{static get pluginName(){return"HeadingUI"}init(){const t=this.editor,e=t.t,n=function(t){const e=t.t,n={Paragraph:e("Paragraph"),"Heading 1":e("Heading 1"),"Heading 2":e("Heading 2"),"Heading 3":e("Heading 3"),"Heading 4":e("Heading 4"),"Heading 5":e("Heading 5"),"Heading 6":e("Heading 6")};return t.config.get("heading.options").map((t=>{const e=n[t.title];return e&&e!=t.title&&(t.title=e),t}))}(t),o=e("Choose heading"),i=e("Heading");t.ui.componentFactory.add("heading",(e=>{const r={},s=new bo,a=t.commands.get("heading"),l=t.commands.get("paragraph"),c=[a];for(const t of n){const e={type:"button",model:new Wh({label:t.title,class:t.class,withText:!0})};"paragraph"===t.model?(e.model.bind("isOn").to(l,"value"),e.model.set("commandName","paragraph"),c.push(l)):(e.model.bind("isOn").to(a,"value",(e=>e===t.model)),e.model.set({commandName:"heading",commandValue:t.model})),s.add(e),r[t.model]=t.title}const d=kh(e);return Ah(d,s),d.buttonView.set({isOn:!1,withText:!0,tooltip:i}),d.extendTemplate({attributes:{class:["ck-heading-dropdown"]}}),d.bind("isEnabled").toMany(c,"isEnabled",((...t)=>t.some((t=>t)))),d.buttonView.bind("label").to(a,"value",l,"value",((t,e)=>{const n=t||e&&"paragraph";return r[n]?r[n]:o})),this.listenTo(d,"execute",(e=>{t.execute(e.source.commandName,e.source.commandValue?{value:e.source.commandValue}:void 0),t.editing.view.focus()})),d}))}}class Ob extends V{static get requires(){return[rm]}static get pluginName(){return"WidgetToolbarRepository"}init(){const t=this.editor;if(t.plugins.has("BalloonToolbar")){const e=t.plugins.get("BalloonToolbar");this.listenTo(e,"show",(e=>{(function(t){const e=t.getSelectedElement();return!(!e||!Xp(e))})(t.editing.view.document.selection)&&e.stop()}),{priority:"high"})}this._toolbarDefinitions=new Map,this._balloon=this.editor.plugins.get("ContextualBalloon"),this.on("change:isEnabled",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui,"update",(()=>{this._updateToolbarsVisibility()})),this.listenTo(t.ui.focusTracker,"change:isFocused",(()=>{this._updateToolbarsVisibility()}),{priority:"low"})}destroy(){super.destroy();for(const t of this._toolbarDefinitions.values())t.view.destroy()}register(t,{ariaLabel:e,items:n,getRelatedElement:o,balloonClassName:i="ck-toolbar-container"}){if(!n.length)return void c("widget-toolbar-no-items",{toolbarId:t});const r=this.editor,s=r.t,a=new rh(r.locale);if(a.ariaLabel=e||s("Widget toolbar"),this._toolbarDefinitions.has(t))throw new l("widget-toolbar-duplicated",this,{toolbarId:t});a.fillFromConfig(n,r.ui.componentFactory),this._toolbarDefinitions.set(t,{view:a,getRelatedElement:o,balloonClassName:i})}_updateToolbarsVisibility(){let t=0,e=null,n=null;for(const o of this._toolbarDefinitions.values()){const i=o.getRelatedElement(this.editor.editing.view.document.selection);if(this.isEnabled&&i)if(this.editor.ui.focusTracker.isFocused){const r=i.getAncestors().length;r>t&&(t=r,e=i,n=o)}else this._isToolbarVisible(o)&&this._hideToolbar(o);else this._isToolbarInBalloon(o)&&this._hideToolbar(o)}n&&this._showToolbar(n,e)}_hideToolbar(t){this._balloon.remove(t.view),this.stopListening(this._balloon,"change:visibleView")}_showToolbar(t,e){this._isToolbarVisible(t)?Rb(this.editor,e):this._isToolbarInBalloon(t)||(this._balloon.add({view:t.view,position:jb(this.editor,e),balloonClassName:t.balloonClassName}),this.listenTo(this._balloon,"change:visibleView",(()=>{for(const t of this._toolbarDefinitions.values())if(this._isToolbarVisible(t)){const e=t.getRelatedElement(this.editor.editing.view.document.selection);Rb(this.editor,e)}})))}_isToolbarVisible(t){return this._balloon.visibleView===t.view}_isToolbarInBalloon(t){return this._balloon.hasView(t.view)}}function Rb(t,e){const n=t.plugins.get("ContextualBalloon"),o=jb(t,e);n.updatePosition(o)}function jb(t,e){const n=t.editing.view,o=Jh.defaultPositions;return{target:n.domConverter.mapViewToDom(e),positions:[o.northArrowSouth,o.northArrowSouthWest,o.northArrowSouthEast,o.southArrowNorth,o.southArrowNorthWest,o.southArrowNorthEast,o.viewportStickyNorth]}}class Vb{constructor(t){this.set("activeHandlePosition",null),this.set("proposedWidthPercents",null),this.set("proposedWidth",null),this.set("proposedHeight",null),this.set("proposedHandleHostWidth",null),this.set("proposedHandleHostHeight",null),this._options=t,this._referenceCoordinates=null}begin(t,e,n){const o=new Da(e);this.activeHandlePosition=function(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const n of e)if(t.classList.contains(Fb(n)))return n}(t),this._referenceCoordinates=function(t,e){const n=new Da(t),o=e.split("-"),i={x:"right"==o[1]?n.right:n.left,y:"bottom"==o[0]?n.bottom:n.top};return i.x+=t.ownerDocument.defaultView.scrollX,i.y+=t.ownerDocument.defaultView.scrollY,i}(e,function(t){const e=t.split("-"),n={top:"bottom",bottom:"top",left:"right",right:"left"};return`${n[e[0]]}-${n[e[1]]}`}(this.activeHandlePosition)),this.originalWidth=o.width,this.originalHeight=o.height,this.aspectRatio=o.width/o.height;const i=n.style.width;i&&i.match(/^\d+(\.\d*)?%$/)?this.originalWidthPercents=parseFloat(i):this.originalWidthPercents=function(t,e){const n=t.parentElement,o=parseFloat(n.ownerDocument.defaultView.getComputedStyle(n).width);return e.width/o*100}(n,o)}update(t){this.proposedWidth=t.width,this.proposedHeight=t.height,this.proposedWidthPercents=t.widthPercents,this.proposedHandleHostWidth=t.handleHostWidth,this.proposedHandleHostHeight=t.handleHostHeight}}function Fb(t){return`ck-widget__resizer__handle-${t}`}j(Vb,N);class Hb extends Jd{constructor(){super();const t=this.bindTemplate;this.setTemplate({tag:"div",attributes:{class:["ck","ck-size-view",t.to("_viewPosition",(t=>t?`ck-orientation-${t}`:""))],style:{display:t.if("_isVisible","none",(t=>!t))}},children:[{text:t.to("_label")}]})}_bindToState(t,e){this.bind("_isVisible").to(e,"proposedWidth",e,"proposedHeight",((t,e)=>null!==t&&null!==e)),this.bind("_label").to(e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",e,"proposedWidthPercents",((e,n,o)=>"px"===t.unit?`${e}×${n}`:`${o}%`)),this.bind("_viewPosition").to(e,"activeHandlePosition",e,"proposedHandleHostWidth",e,"proposedHandleHostHeight",((t,e,n)=>e<50||n<50?"above-center":t))}_dismiss(){this.unbind(),this._isVisible=!1}}class Ub{constructor(t){this._options=t,this._viewResizerWrapper=null,this.set("isEnabled",!0),this.decorate("begin"),this.decorate("cancel"),this.decorate("commit"),this.decorate("updateSize"),this.on("commit",(t=>{this.state.proposedWidth||this.state.proposedWidthPercents||(this._cleanup(),t.stop())}),{priority:"high"}),this.on("change:isEnabled",(()=>{this.isEnabled&&this.redraw()}))}attach(){const t=this,e=this._options.viewElement;this._options.editor.editing.view.change((n=>{const o=n.createUIElement("div",{class:"ck ck-reset_all ck-widget__resizer"},(function(e){const n=this.toDomElement(e);return t._appendHandles(n),t._appendSizeUI(n),t.on("change:isEnabled",((t,e,o)=>{n.style.display=o?"":"none"})),n.style.display=t.isEnabled?"":"none",n}));n.insert(n.createPositionAt(e,"end"),o),n.addClass("ck-widget_with-resizer",e),this._viewResizerWrapper=o}))}begin(t){this.state=new Vb(this._options),this._sizeView._bindToState(this._options,this.state),this._initialViewWidth=this._options.viewElement.getStyle("width"),this.state.begin(t,this._getHandleHost(),this._getResizeHost())}updateSize(t){const e=this._proposeNewSize(t);this._options.editor.editing.view.change((t=>{const n=this._options.unit||"%",o=("%"===n?e.widthPercents:e.width)+n;t.setStyle("width",o,this._options.viewElement)}));const n=this._getHandleHost(),o=new Da(n);e.handleHostWidth=Math.round(o.width),e.handleHostHeight=Math.round(o.height);const i=new Da(n);e.width=Math.round(i.width),e.height=Math.round(i.height),this.redraw(o),this.state.update(e)}commit(){const t=this._options.unit||"%",e=("%"===t?this.state.proposedWidthPercents:this.state.proposedWidth)+t;this._options.editor.editing.view.change((()=>{this._cleanup(),this._options.onCommit(e)}))}cancel(){this._cleanup()}destroy(){this.cancel()}redraw(t){const e=this._domResizerWrapper;if(!((n=e)&&n.ownerDocument&&n.ownerDocument.contains(n)))return;var n;const o=e.parentElement,i=this._getHandleHost(),r=this._viewResizerWrapper,s=[r.getStyle("width"),r.getStyle("height"),r.getStyle("left"),r.getStyle("top")];let a;if(o.isSameNode(i)){const e=t||new Da(i);a=[e.width+"px",e.height+"px",void 0,void 0]}else a=[i.offsetWidth+"px",i.offsetHeight+"px",i.offsetLeft+"px",i.offsetTop+"px"];"same"!==Eo(s,a)&&this._options.editor.editing.view.change((t=>{t.setStyle({width:a[0],height:a[1],left:a[2],top:a[3]},r)}))}containsHandle(t){return this._domResizerWrapper.contains(t)}static isResizeHandle(t){return t.classList.contains("ck-widget__resizer__handle")}_cleanup(){this._sizeView._dismiss();this._options.editor.editing.view.change((t=>{t.setStyle("width",this._initialViewWidth,this._options.viewElement)}))}_proposeNewSize(t){const e=this.state,n={x:(o=t).pageX,y:o.pageY};var o;const i=!this._options.isCentered||this._options.isCentered(this),r={x:e._referenceCoordinates.x-(n.x+e.originalWidth),y:n.y-e.originalHeight-e._referenceCoordinates.y};i&&e.activeHandlePosition.endsWith("-right")&&(r.x=n.x-(e._referenceCoordinates.x+e.originalWidth)),i&&(r.x*=2);const s={width:Math.abs(e.originalWidth+r.x),height:Math.abs(e.originalHeight+r.y)};s.dominant=s.width/e.aspectRatio>s.height?"width":"height",s.max=s[s.dominant];const a={width:s.width,height:s.height};return"width"==s.dominant?a.height=a.width/e.aspectRatio:a.width=a.height*e.aspectRatio,{width:Math.round(a.width),height:Math.round(a.height),widthPercents:Math.min(Math.round(e.originalWidthPercents/e.originalWidth*a.width*100)/100,100)}}_getResizeHost(){const t=this._domResizerWrapper.parentElement;return this._options.getResizeHost(t)}_getHandleHost(){const t=this._domResizerWrapper.parentElement;return this._options.getHandleHost(t)}get _domResizerWrapper(){return this._options.editor.editing.view.domConverter.mapViewToDom(this._viewResizerWrapper)}_appendHandles(t){const e=["top-left","top-right","bottom-right","bottom-left"];for(const o of e)t.appendChild(new Xd({tag:"div",attributes:{class:"ck-widget__resizer__handle "+(n=o,`ck-widget__resizer__handle-${n}`)}}).render());var n}_appendSizeUI(t){this._sizeView=new Hb,this._sizeView.render(),t.appendChild(this._sizeView.element)}}j(Ub,N);var qb=n(2263),Gb={attributes:{"data-cke":!0}};Gb.setAttributes=is(),Gb.insert=ns().bind(null,"head"),Gb.domAPI=ts(),Gb.insertStyleElement=ss();Jr()(qb.Z,Gb);qb.Z&&qb.Z.locals&&qb.Z.locals;class Wb extends V{static get pluginName(){return"WidgetResize"}init(){const t=this.editor.editing,e=ms.window.document;this.set("visibleResizer",null),this.set("_activeResizer",null),this._resizers=new Map,t.view.addObserver(zm),this._observer=Object.create(Ss),this.listenTo(t.view.document,"mousedown",this._mouseDownListener.bind(this),{priority:"high"}),this._observer.listenTo(e,"mousemove",this._mouseMoveListener.bind(this)),this._observer.listenTo(e,"mouseup",this._mouseUpListener.bind(this));const n=()=>{this.visibleResizer&&this.visibleResizer.redraw()};this._redrawFocusedResizerThrottled=xf(n,200),this.on("change:visibleResizer",n),this.editor.ui.on("update",this._redrawFocusedResizerThrottled),this.editor.model.document.on("change",(()=>{for(const[t,e]of this._resizers)t.isAttached()||(this._resizers.delete(t),e.destroy())}),{priority:"lowest"}),this._observer.listenTo(ms.window,"resize",this._redrawFocusedResizerThrottled);const o=this.editor.editing.view.document.selection;o.on("change",(()=>{const t=o.getSelectedElement();this.visibleResizer=this.getResizerByViewElement(t)||null}))}destroy(){this._observer.stopListening();for(const t of this._resizers.values())t.destroy();this._redrawFocusedResizerThrottled.cancel()}attachTo(t){const e=new Ub(t),n=this.editor.plugins;if(e.attach(),n.has("WidgetToolbarRepository")){const t=n.get("WidgetToolbarRepository");e.on("begin",(()=>{t.forceDisabled("resize")}),{priority:"lowest"}),e.on("cancel",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"}),e.on("commit",(()=>{t.clearForceDisabled("resize")}),{priority:"highest"})}this._resizers.set(t.viewElement,e);const o=this.editor.editing.view.document.selection.getSelectedElement();return this.getResizerByViewElement(o)==e&&(this.visibleResizer=e),e}getResizerByViewElement(t){return this._resizers.get(t)}_getResizerByHandle(t){for(const e of this._resizers.values())if(e.containsHandle(t))return e}_mouseDownListener(t,e){const n=e.domTarget;Ub.isResizeHandle(n)&&(this._activeResizer=this._getResizerByHandle(n),this._activeResizer&&(this._activeResizer.begin(n),t.stop(),e.preventDefault()))}_mouseMoveListener(t,e){this._activeResizer&&this._activeResizer.updateSize(e)}_mouseUpListener(){this._activeResizer&&(this._activeResizer.commit(),this._activeResizer=null)}}j(Wb,N);class Zb extends H{refresh(){const t=this.editor.model,e=t.schema,n=t.document.selection;this.isEnabled=function(t,e,n){const o=function(t,e){const n=af(t,e).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(t,n);return e.checkChild(o,"horizontalLine")}(n,e,t)}execute(){const t=this.editor.model;t.change((e=>{const n=e.createElement("horizontalLine");t.insertObject(n,null,null,{setSelection:"after"})}))}}var Yb=n(2536),Kb={attributes:{"data-cke":!0}};Kb.setAttributes=is(),Kb.insert=ns().bind(null,"head"),Kb.domAPI=ts(),Kb.insertStyleElement=ss();Jr()(Yb.Z,Kb);Yb.Z&&Yb.Z.locals&&Yb.Z.locals;class $b extends V{static get pluginName(){return"HorizontalLineEditing"}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion;e.register("horizontalLine",{inheritAllFrom:"$blockObject"}),o.for("dataDowncast").elementToElement({model:"horizontalLine",view:(t,{writer:e})=>e.createEmptyElement("hr")}),o.for("editingDowncast").elementToStructure({model:"horizontalLine",view:(t,{writer:e})=>{const o=n("Horizontal line"),i=e.createContainerElement("div",null,e.createEmptyElement("hr"));return e.addClass("ck-horizontal-line",i),e.setCustomProperty("hr",!0,i),function(t,e,n){return e.setCustomProperty("horizontalLine",!0,t),tf(t,e,{label:n})}(i,e,o)}}),o.for("upcast").elementToElement({view:"hr",model:"horizontalLine"}),t.commands.add("horizontalLine",new Zb(t))}}class Qb extends V{static get pluginName(){return"HorizontalLineUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add("horizontalLine",(n=>{const o=t.commands.get("horizontalLine"),i=new Su(n);return i.set({label:e("Horizontal line"),icon:'',tooltip:!0}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{t.execute("horizontalLine"),t.editing.view.focus()})),i}))}}class Jb extends H{refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled&&t.hasAttribute("alt")?this.value=t.getAttribute("alt"):this.value=!1}execute(t){const e=this.editor,n=e.plugins.get("ImageUtils"),o=e.model,i=n.getClosestSelectedImageElement(o.document.selection);o.change((e=>{e.setAttribute("alt",t.newValue,i)}))}}function Xb(t){return t.createContainerElement("figure",{class:"image"},[t.createEmptyElement("img"),t.createSlot()])}function tk(t,e){const n=t.plugins.get("ImageUtils"),o=t.plugins.has("ImageInlineEditing")&&t.plugins.has("ImageBlockEditing");return t=>{if(!n.isInlineImageView(t))return null;if(!o)return i(t);return(t.findAncestor(n.isBlockImageView)?"imageBlock":"imageInline")!==e?null:i(t)};function i(t){const e={name:!0};return t.hasAttribute("src")&&(e.attributes=["src"]),e}}function ek(t,e){const n=Ba(e.getSelectedBlocks());return!n||t.isObject(n)||n.isEmpty&&"listItem"!=n.name?"imageBlock":"imageInline"}class nk extends V{static get pluginName(){return"ImageUtils"}isImage(t){return this.isInlineImage(t)||this.isBlockImage(t)}isInlineImageView(t){return!!t&&t.is("element","img")}isBlockImageView(t){return!!t&&t.is("element","figure")&&t.hasClass("image")}insertImage(t={},e=null,n=null){const o=this.editor,i=o.model,r=i.document.selection;n=ok(o,e||r,n),t={...Object.fromEntries(r.getAttributes()),...t};for(const e in t)i.schema.checkAttribute(n,e)||delete t[e];return i.change((o=>{const r=o.createElement(n,t);return i.insertObject(r,e,null,{setSelection:"on",findOptimalPosition:!e&&"imageInline"!=n}),r.parent?r:null}))}getClosestSelectedImageWidget(t){const e=t.getFirstPosition();if(!e)return null;const n=t.getSelectedElement();if(n&&this.isImageWidget(n))return n;let o=e.parent;for(;o;){if(o.is("element")&&this.isImageWidget(o))return o;o=o.parent}return null}getClosestSelectedImageElement(t){const e=t.getSelectedElement();return this.isImage(e)?e:t.getFirstPosition().findAncestor("imageBlock")}isImageAllowed(){const t=this.editor.model.document.selection;return function(t,e){if("imageBlock"==ok(t,e)){const n=function(t,e){const n=af(t,e).start.parent;if(n.isEmpty&&!n.is("element","$root"))return n.parent;return n}(e,t.model);if(t.model.schema.checkChild(n,"imageBlock"))return!0}else if(t.model.schema.checkChild(e.focus,"imageInline"))return!0;return!1}(this.editor,t)&&function(t){return[...t.focus.getAncestors()].every((t=>!t.is("element","imageBlock")))}(t)}toImageWidget(t,e,n){e.setCustomProperty("image",!0,t);return tf(t,e,{label:()=>{const e=this.findViewImgElement(t).getAttribute("alt");return e?`${e} ${n}`:n}})}isImageWidget(t){return!!t.getCustomProperty("image")&&Xp(t)}isBlockImage(t){return!!t&&t.is("element","imageBlock")}isInlineImage(t){return!!t&&t.is("element","imageInline")}findViewImgElement(t){if(this.isInlineImageView(t))return t;const e=this.editor.editing.view;for(const{item:n}of e.createRangeIn(t))if(this.isInlineImageView(n))return n}}function ok(t,e,n){const o=t.model.schema,i=t.config.get("image.insert.type");return t.plugins.has("ImageBlockEditing")?t.plugins.has("ImageInlineEditing")?n||("inline"===i?"imageInline":"block"===i?"imageBlock":e.is("selection")?ek(o,e):o.checkChild(e,"imageInline")?"imageInline":"imageBlock"):"imageBlock":"imageInline"}class ik extends V{static get requires(){return[nk]}static get pluginName(){return"ImageTextAlternativeEditing"}init(){this.editor.commands.add("imageTextAlternative",new Jb(this.editor))}}var rk=n(6831),sk={attributes:{"data-cke":!0}};sk.setAttributes=is(),sk.insert=ns().bind(null,"head"),sk.domAPI=ts(),sk.insertStyleElement=ss();Jr()(rk.Z,sk);rk.Z&&rk.Z.locals&&rk.Z.locals;var ak=n(1590),lk={attributes:{"data-cke":!0}};lk.setAttributes=is(),lk.insert=ns().bind(null,"head"),lk.domAPI=ts(),lk.insertStyleElement=ss();Jr()(ak.Z,lk);ak.Z&&ak.Z.locals&&ak.Z.locals;class ck extends Jd{constructor(t){super(t);const e=this.locale.t;this.focusTracker=new za,this.keystrokes=new Pa,this.labeledInput=this._createLabeledInputView(),this.saveButtonView=this._createButton(e("Save"),Gd.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(e("Cancel"),Gd.cancel,"ck-button-cancel","cancel"),this._focusables=new Kd,this._focusCycler=new Ou({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"form",attributes:{class:["ck","ck-text-alternative-form","ck-responsive-form"],tabindex:"-1"},children:[this.labeledInput,this.saveButtonView,this.cancelButtonView]}),Zd(this)}render(){super.render(),this.keystrokes.listenTo(this.element),Yd({view:this}),[this.labeledInput,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)}))}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createButton(t,e,n,o){const i=new Su(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createLabeledInputView(){const t=this.locale.t,e=new Fh(this.locale,Hh);return e.label=t("Text alternative"),e}}function dk(t){const e=t.editing.view,n=Jh.defaultPositions,o=t.plugins.get("ImageUtils");return{target:e.domConverter.mapViewToDom(o.getClosestSelectedImageWidget(e.document.selection)),positions:[n.northArrowSouth,n.northArrowSouthWest,n.northArrowSouthEast,n.southArrowNorth,n.southArrowNorthWest,n.southArrowNorthEast,n.viewportStickyNorth]}}class uk extends V{static get requires(){return[rm]}static get pluginName(){return"ImageTextAlternativeUI"}init(){this._createButton(),this._createForm()}destroy(){super.destroy(),this._form.destroy()}_createButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("imageTextAlternative",(n=>{const o=t.commands.get("imageTextAlternative"),i=new Su(n);return i.set({label:e("Change image text alternative"),icon:Gd.lowVision,tooltip:!0}),i.bind("isEnabled").to(o,"isEnabled"),this.listenTo(i,"execute",(()=>{this._showForm()})),i}))}_createForm(){const t=this.editor,e=t.editing.view.document,n=t.plugins.get("ImageUtils");this._balloon=this.editor.plugins.get("ContextualBalloon"),this._form=new ck(t.locale),this._form.render(),this.listenTo(this._form,"submit",(()=>{t.execute("imageTextAlternative",{newValue:this._form.labeledInput.fieldView.element.value}),this._hideForm(!0)})),this.listenTo(this._form,"cancel",(()=>{this._hideForm(!0)})),this._form.keystrokes.set("Esc",((t,e)=>{this._hideForm(!0),e()})),this.listenTo(t.ui,"update",(()=>{n.getClosestSelectedImageWidget(e.selection)?this._isVisible&&function(t){const e=t.plugins.get("ContextualBalloon");if(t.plugins.get("ImageUtils").getClosestSelectedImageWidget(t.editing.view.document.selection)){const n=dk(t);e.updatePosition(n)}}(t):this._hideForm(!0)})),Wd({emitter:this._form,activator:()=>this._isVisible,contextElements:[this._balloon.view.element],callback:()=>this._hideForm()})}_showForm(){if(this._isVisible)return;const t=this.editor,e=t.commands.get("imageTextAlternative"),n=this._form.labeledInput;this._form.disableCssTransitions(),this._isInBalloon||this._balloon.add({view:this._form,position:dk(t)}),n.fieldView.value=n.fieldView.element.value=e.value||"",this._form.labeledInput.fieldView.select(),this._form.enableCssTransitions()}_hideForm(t){this._isInBalloon&&(this._form.focusTracker.isFocused&&this._form.saveButtonView.focus(),this._balloon.remove(this._form),t&&this.editor.editing.view.focus())}get _isVisible(){return this._balloon.visibleView===this._form}get _isInBalloon(){return this._balloon.hasView(this._form)}}class hk extends V{static get requires(){return[ik,uk]}static get pluginName(){return"ImageTextAlternative"}}function mk(t,e){return t=>{t.on(`attribute:srcset:${e}`,n)};function n(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);if(null===n.attributeNewValue){const t=n.attributeOldValue;t.data&&(i.removeAttribute("srcset",s),i.removeAttribute("sizes",s),t.width&&i.removeAttribute("width",s))}else{const t=n.attributeNewValue;t.data&&(i.setAttribute("srcset",t.data,s),i.setAttribute("sizes","100vw",s),t.width&&i.setAttribute("width",t.width,s))}}}function gk(t,e,n){return t=>{t.on(`attribute:${n}:${e}`,o)};function o(e,n,o){if(!o.consumable.consume(n.item,e.name))return;const i=o.writer,r=o.mapper.toViewElement(n.item),s=t.findViewImgElement(r);i.setAttribute(n.attributeKey,n.attributeNewValue||"",s)}}class pk extends Ms{observe(t){this.listenTo(t,"load",((t,e)=>{const n=e.target;this.checkShouldIgnoreEventFromTarget(n)||"IMG"==n.tagName&&this._fireEvents(e)}),{useCapture:!0})}_fireEvents(t){this.isEnabled&&(this.document.fire("layoutChanged"),this.document.fire("imageLoaded",t))}}class fk extends H{constructor(t){super(t);const e=t.config.get("image.insert.type");t.plugins.has("ImageBlockEditing")||"block"===e&&c("image-block-plugin-required"),t.plugins.has("ImageInlineEditing")||"inline"===e&&c("image-inline-plugin-required")}refresh(){this.isEnabled=this.editor.plugins.get("ImageUtils").isImageAllowed()}execute(t){const e=wo(t.source),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if("string"==typeof t&&(t={src:t}),e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);o.insertImage({...t,...i},e)}else o.insertImage({...t,...i})}))}}class bk extends V{static get requires(){return[nk]}static get pluginName(){return"ImageEditing"}init(){const t=this.editor,e=t.conversion;t.editing.view.addObserver(pk),e.for("upcast").attributeToAttribute({view:{name:"img",key:"alt"},model:"alt"}).attributeToAttribute({view:{name:"img",key:"srcset"},model:{key:"srcset",value:t=>{const e={data:t.getAttribute("srcset")};return t.hasAttribute("width")&&(e.width=t.getAttribute("width")),e}}});const n=new fk(t);t.commands.add("insertImage",n),t.commands.add("imageInsert",n)}}class kk extends H{constructor(t,e){super(t),this._modelElementName=e}refresh(){const t=this.editor.plugins.get("ImageUtils"),e=t.getClosestSelectedImageElement(this.editor.model.document.selection);"imageBlock"===this._modelElementName?this.isEnabled=t.isInlineImage(e):this.isEnabled=t.isBlockImage(e)}execute(){const t=this.editor,e=this.editor.model,n=t.plugins.get("ImageUtils"),o=n.getClosestSelectedImageElement(e.document.selection),i=Object.fromEntries(o.getAttributes());return i.src||i.uploadId?e.change((t=>{const r=Array.from(e.markers).filter((t=>t.getRange().containsItem(o))),s=n.insertImage(i,e.createSelection(o,"on"),this._modelElementName);if(!s)return null;const a=t.createRangeOn(s);for(const e of r){const n=e.getRange(),o="$graveyard"!=n.root.rootName?n.getJoined(a,!0):a;t.updateMarker(e,{range:o})}return{oldElement:o,newElement:s}})):null}}class wk extends V{static get requires(){return[bk,nk,Wp]}static get pluginName(){return"ImageBlockEditing"}init(){const t=this.editor;t.model.schema.register("imageBlock",{inheritAllFrom:"$blockObject",allowAttributes:["alt","src","srcset"]}),this._setupConversion(),t.plugins.has("ImageInlineEditing")&&(t.commands.add("imageTypeBlock",new kk(this.editor,"imageBlock")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:e})=>Xb(e)}),n.for("editingDowncast").elementToStructure({model:"imageBlock",view:(t,{writer:n})=>o.toImageWidget(Xb(n),n,e("image widget"))}),n.for("downcast").add(gk(o,"imageBlock","src")).add(gk(o,"imageBlock","alt")).add(mk(o,"imageBlock")),n.for("upcast").elementToElement({view:tk(t,"imageBlock"),model:(t,{writer:e})=>e.createElement("imageBlock",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)}).add(function(t){return t=>{t.on("element:figure",e)};function e(e,n,o){if(!o.consumable.test(n.viewItem,{name:!0,classes:"image"}))return;const i=t.findViewImgElement(n.viewItem);if(!i||!o.consumable.test(i,{name:!0}))return;o.consumable.consume(n.viewItem,{name:!0,classes:"image"});const r=Ba(o.convertItem(i,n.modelCursor).modelRange.getItems());r?(o.convertChildren(n.viewItem,r),o.updateConversionResult(r,n)):o.consumable.revert(n.viewItem,{name:!0,classes:"image"})}}(o))}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isInlineImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const l=e.createSelection(a);if("imageBlock"===ek(e.schema,l)){const t=new Pm(n.document),e=s.map((e=>t.createElement("figure",{class:"image"},e)));r.content=t.createDocumentFragment(e)}}))}}var Ak=n(9048),Ck={attributes:{"data-cke":!0}};Ck.setAttributes=is(),Ck.insert=ns().bind(null,"head"),Ck.domAPI=ts(),Ck.insertStyleElement=ss();Jr()(Ak.Z,Ck);Ak.Z&&Ak.Z.locals&&Ak.Z.locals;class _k extends V{static get requires(){return[wk,vf,hk]}static get pluginName(){return"ImageBlock"}}class vk extends V{static get requires(){return[bk,nk,Wp]}static get pluginName(){return"ImageInlineEditing"}init(){const t=this.editor,e=t.model.schema;e.register("imageInline",{inheritAllFrom:"$inlineObject",allowAttributes:["alt","src","srcset"]}),e.addChildCheck(((t,e)=>{if(t.endsWith("caption")&&"imageInline"===e.name)return!1})),this._setupConversion(),t.plugins.has("ImageBlockEditing")&&(t.commands.add("imageTypeInline",new kk(this.editor,"imageInline")),this._setupClipboardIntegration())}_setupConversion(){const t=this.editor,e=t.t,n=t.conversion,o=t.plugins.get("ImageUtils");n.for("dataDowncast").elementToElement({model:"imageInline",view:(t,{writer:e})=>e.createEmptyElement("img")}),n.for("editingDowncast").elementToStructure({model:"imageInline",view:(t,{writer:n})=>o.toImageWidget(function(t){return t.createContainerElement("span",{class:"image-inline"},t.createEmptyElement("img"))}(n),n,e("image widget"))}),n.for("downcast").add(gk(o,"imageInline","src")).add(gk(o,"imageInline","alt")).add(mk(o,"imageInline")),n.for("upcast").elementToElement({view:tk(t,"imageInline"),model:(t,{writer:e})=>e.createElement("imageInline",t.hasAttribute("src")?{src:t.getAttribute("src")}:null)})}_setupClipboardIntegration(){const t=this.editor,e=t.model,n=t.editing.view,o=t.plugins.get("ImageUtils");this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((i,r)=>{const s=Array.from(r.content.getChildren());let a;if(!s.every(o.isBlockImageView))return;a=r.targetRanges?t.editing.mapper.toModelRange(r.targetRanges[0]):e.document.selection.getFirstRange();const l=e.createSelection(a);if("imageInline"===ek(e.schema,l)){const t=new Pm(n.document),e=s.map((e=>1===e.childCount?(Array.from(e.getAttributes()).forEach((n=>t.setAttribute(...n,o.findViewImgElement(e)))),e.getChild(0)):e));r.content=t.createDocumentFragment(e)}}))}}class yk extends V{static get requires(){return[vk,vf,hk]}static get pluginName(){return"ImageInline"}}class xk extends H{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils").getClosestSelectedImageElement(t.model.document.selection);this.isEnabled=!!e,e&&e.hasAttribute("width")?this.value={width:e.getAttribute("width"),height:null}:this.value=null}execute(t){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils").getClosestSelectedImageElement(n.document.selection);this.value={width:t.width,height:null},o&&n.change((e=>{e.setAttribute("width",t.width,o)}))}}class Ek extends V{static get requires(){return[nk]}static get pluginName(){return"ImageResizeEditing"}constructor(t){super(t),t.config.define("image",{resizeUnit:"%",resizeOptions:[{name:"resizeImage:original",value:null,icon:"original"},{name:"resizeImage:25",value:"25",icon:"small"},{name:"resizeImage:50",value:"50",icon:"medium"},{name:"resizeImage:75",value:"75",icon:"large"}]})}init(){const t=this.editor,e=new xk(t);this._registerSchema(),this._registerConverters("imageBlock"),this._registerConverters("imageInline"),t.commands.add("resizeImage",e),t.commands.add("imageResize",e)}_registerSchema(){this.editor.plugins.has("ImageBlockEditing")&&this.editor.model.schema.extend("imageBlock",{allowAttributes:"width"}),this.editor.plugins.has("ImageInlineEditing")&&this.editor.model.schema.extend("imageInline",{allowAttributes:"width"})}_registerConverters(t){const e=this.editor;e.conversion.for("downcast").add((e=>e.on(`attribute:width:${t}`,((t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=n.writer,i=n.mapper.toViewElement(e.item);null!==e.attributeNewValue?(o.setStyle("width",e.attributeNewValue,i),o.addClass("image_resized",i)):(o.removeStyle("width",i),o.removeClass("image_resized",i))})))),e.conversion.for("upcast").attributeToAttribute({view:{name:"imageBlock"===t?"figure":"img",styles:{width:/.+/}},model:{key:"width",value:t=>t.getStyle("width")}})}}const Dk={small:Gd.objectSizeSmall,medium:Gd.objectSizeMedium,large:Gd.objectSizeLarge,original:Gd.objectSizeFull};class Sk extends V{static get requires(){return[Ek]}static get pluginName(){return"ImageResizeButtons"}constructor(t){super(t),this._resizeUnit=t.config.get("image.resizeUnit")}init(){const t=this.editor,e=t.config.get("image.resizeOptions"),n=t.commands.get("resizeImage");this.bind("isEnabled").to(n);for(const t of e)this._registerImageResizeButton(t);this._registerImageResizeDropdown(e)}_registerImageResizeButton(t){const e=this.editor,{name:n,value:o,icon:i}=t,r=o?o+this._resizeUnit:null;e.ui.componentFactory.add(n,(n=>{const o=new Su(n),s=e.commands.get("resizeImage"),a=this._getOptionLabelValue(t,!0);if(!Dk[i])throw new l("imageresizebuttons-missing-icon",e,t);return o.set({label:a,icon:Dk[i],tooltip:a,isToggleable:!0}),o.bind("isEnabled").to(this),o.bind("isOn").to(s,"value",Ik(r)),this.listenTo(o,"execute",(()=>{e.execute("resizeImage",{width:r})})),o}))}_registerImageResizeDropdown(t){const e=this.editor,n=e.t,o=t.find((t=>!t.value)),i=i=>{const r=e.commands.get("resizeImage"),s=kh(i,Uu),a=s.buttonView;return a.set({tooltip:n("Resize image"),commandValue:o.value,icon:Dk.medium,isToggleable:!0,label:this._getOptionLabelValue(o),withText:!0,class:"ck-resize-image-button"}),a.bind("label").to(r,"value",(t=>t&&t.width?t.width:this._getOptionLabelValue(o))),s.bind("isOn").to(r),s.bind("isEnabled").to(this),Ah(s,this._getResizeDropdownListItemDefinitions(t,r)),s.listView.ariaLabel=n("Image resize list"),this.listenTo(s,"execute",(t=>{e.execute(t.source.commandName,{width:t.source.commandValue}),e.editing.view.focus()})),s};e.ui.componentFactory.add("resizeImage",i),e.ui.componentFactory.add("imageResize",i)}_getOptionLabelValue(t,e){const n=this.editor.t;return t.label?t.label:e?t.value?n("Resize image to %0",t.value+this._resizeUnit):n("Resize image to the original size"):t.value?t.value+this._resizeUnit:n("Original")}_getResizeDropdownListItemDefinitions(t,e){const n=new bo;return t.map((t=>{const o=t.value?t.value+this._resizeUnit:null,i={type:"button",model:new Wh({commandName:"resizeImage",commandValue:o,label:this._getOptionLabelValue(t),withText:!0,icon:null})};i.model.bind("isOn").to(e,"value",Ik(o)),n.add(i)})),n}}function Ik(t){return e=>null===t&&e===t||e&&e.width===t}const Tk=/(image|image-inline)/,Mk="image_resized";class Bk extends V{static get requires(){return[Wb]}static get pluginName(){return"ImageResizeHandles"}init(){const t=this.editor.commands.get("resizeImage");this.bind("isEnabled").to(t),this._setupResizerCreator()}_setupResizerCreator(){const t=this.editor,e=t.editing.view;e.addObserver(pk),this.listenTo(e.document,"imageLoaded",((n,o)=>{if(!o.target.matches("figure.image.ck-widget > img,figure.image.ck-widget > picture > img,figure.image.ck-widget > a > img,figure.image.ck-widget > a > picture > img,span.image-inline.ck-widget > img,span.image-inline.ck-widget > picture > img"))return;const i=t.editing.view.domConverter,r=i.domToView(o.target).findAncestor({classes:Tk});let s=this.editor.plugins.get(Wb).getResizerByViewElement(r);if(s)return void s.redraw();const a=t.editing.mapper,l=a.toModelElement(r);s=t.plugins.get(Wb).attachTo({unit:t.config.get("image.resizeUnit"),modelElement:l,viewElement:r,editor:t,getHandleHost:t=>t.querySelector("img"),getResizeHost:()=>i.mapViewToDom(a.toViewElement(l.parent)),isCentered(){const t=l.getAttribute("imageStyle");return!t||"block"==t||"alignCenter"==t},onCommit(n){e.change((t=>{t.removeClass(Mk,r)})),t.execute("resizeImage",{width:n})}}),s.on("updateSize",(()=>{r.hasClass(Mk)||e.change((t=>{t.addClass(Mk,r)}))})),s.bind("isEnabled").to(this)}))}}var Nk=n(1043),zk={attributes:{"data-cke":!0}};zk.setAttributes=is(),zk.insert=ns().bind(null,"head"),zk.domAPI=ts(),zk.insertStyleElement=ss();Jr()(Nk.Z,zk);Nk.Z&&Nk.Z.locals&&Nk.Z.locals;class Pk extends H{constructor(t,e){super(t),this._defaultStyles={imageBlock:!1,imageInline:!1},this._styles=new Map(e.map((t=>{if(t.isDefault)for(const e of t.modelElements)this._defaultStyles[e]=t.name;return[t.name,t]})))}refresh(){const t=this.editor.plugins.get("ImageUtils").getClosestSelectedImageElement(this.editor.model.document.selection);this.isEnabled=!!t,this.isEnabled?t.hasAttribute("imageStyle")?this.value=t.getAttribute("imageStyle"):this.value=this._defaultStyles[t.name]:this.value=!1}execute(t={}){const e=this.editor,n=e.model,o=e.plugins.get("ImageUtils");n.change((e=>{const i=t.value;let r=o.getClosestSelectedImageElement(n.document.selection);i&&this.shouldConvertImageType(i,r)&&(this.editor.execute(o.isBlockImage(r)?"imageTypeInline":"imageTypeBlock"),r=o.getClosestSelectedImageElement(n.document.selection)),!i||this._styles.get(i).isDefault?e.removeAttribute("imageStyle",r):e.setAttribute("imageStyle",i,r)}))}shouldConvertImageType(t,e){return!this._styles.get(t).modelElements.includes(e.name)}}const{objectFullWidth:Lk,objectInline:Ok,objectLeft:Rk,objectRight:jk,objectCenter:Vk,objectBlockLeft:Fk,objectBlockRight:Hk}=Gd,Uk={get inline(){return{name:"inline",title:"In line",icon:Ok,modelElements:["imageInline"],isDefault:!0}},get alignLeft(){return{name:"alignLeft",title:"Left aligned image",icon:Rk,modelElements:["imageBlock","imageInline"],className:"image-style-align-left"}},get alignBlockLeft(){return{name:"alignBlockLeft",title:"Left aligned image",icon:Fk,modelElements:["imageBlock"],className:"image-style-block-align-left"}},get alignCenter(){return{name:"alignCenter",title:"Centered image",icon:Vk,modelElements:["imageBlock"],className:"image-style-align-center"}},get alignRight(){return{name:"alignRight",title:"Right aligned image",icon:jk,modelElements:["imageBlock","imageInline"],className:"image-style-align-right"}},get alignBlockRight(){return{name:"alignBlockRight",title:"Right aligned image",icon:Hk,modelElements:["imageBlock"],className:"image-style-block-align-right"}},get block(){return{name:"block",title:"Centered image",icon:Vk,modelElements:["imageBlock"],isDefault:!0}},get side(){return{name:"side",title:"Side image",icon:jk,modelElements:["imageBlock"],className:"image-style-side"}}},qk={full:Lk,left:Fk,right:Hk,center:Vk,inlineLeft:Rk,inlineRight:jk,inline:Ok},Gk=[{name:"imageStyle:wrapText",title:"Wrap text",defaultItem:"imageStyle:alignLeft",items:["imageStyle:alignLeft","imageStyle:alignRight"]},{name:"imageStyle:breakText",title:"Break text",defaultItem:"imageStyle:block",items:["imageStyle:alignBlockLeft","imageStyle:block","imageStyle:alignBlockRight"]}];function Wk(t){c("image-style-configuration-definition-invalid",t)}const Zk={normalizeStyles:function(t){const e=(t.configuredStyles.options||[]).map((t=>function(t){t="string"==typeof t?Uk[t]?{...Uk[t]}:{name:t}:function(t,e){const n={...e};for(const o in t)Object.prototype.hasOwnProperty.call(e,o)||(n[o]=t[o]);return n}(Uk[t.name],t);"string"==typeof t.icon&&(t.icon=qk[t.icon]||t.icon);return t}(t))).filter((e=>function(t,{isBlockPluginLoaded:e,isInlinePluginLoaded:n}){const{modelElements:o,name:i}=t;if(!(o&&o.length&&i))return Wk({style:t}),!1;{const i=[e?"imageBlock":null,n?"imageInline":null];if(!o.some((t=>i.includes(t))))return c("image-style-missing-dependency",{style:t,missingPlugins:o.map((t=>"imageBlock"===t?"ImageBlockEditing":"ImageInlineEditing"))}),!1}return!0}(e,t)));return e},getDefaultStylesConfiguration:function(t,e){return t&&e?{options:["inline","alignLeft","alignRight","alignCenter","alignBlockLeft","alignBlockRight","block","side"]}:t?{options:["block","side"]}:e?{options:["inline","alignLeft","alignRight"]}:{}},getDefaultDropdownDefinitions:function(t){return t.has("ImageBlockEditing")&&t.has("ImageInlineEditing")?[...Gk]:[]},warnInvalidStyle:Wk,DEFAULT_OPTIONS:Uk,DEFAULT_ICONS:qk,DEFAULT_DROPDOWN_DEFINITIONS:Gk};function Yk(t,e){for(const n of e)if(n.name===t)return n}class Kk extends V{static get pluginName(){return"ImageStyleEditing"}static get requires(){return[nk]}init(){const{normalizeStyles:t,getDefaultStylesConfiguration:e}=Zk,n=this.editor,o=n.plugins.has("ImageBlockEditing"),i=n.plugins.has("ImageInlineEditing");n.config.define("image.styles",e(o,i)),this.normalizedStyles=t({configuredStyles:n.config.get("image.styles"),isBlockPluginLoaded:o,isInlinePluginLoaded:i}),this._setupConversion(o,i),this._setupPostFixer(),n.commands.add("imageStyle",new Pk(n,this.normalizedStyles))}_setupConversion(t,e){const n=this.editor,o=n.model.schema,i=(r=this.normalizedStyles,(t,e,n)=>{if(!n.consumable.consume(e.item,t.name))return;const o=Yk(e.attributeNewValue,r),i=Yk(e.attributeOldValue,r),s=n.mapper.toViewElement(e.item),a=n.writer;i&&a.removeClass(i.className,s),o&&a.addClass(o.className,s)});var r;const s=function(t){const e={imageInline:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageInline"))),imageBlock:t.filter((t=>!t.isDefault&&t.modelElements.includes("imageBlock")))};return(t,n,o)=>{if(!n.modelRange)return;const i=n.viewItem,r=Ba(n.modelRange.getItems());if(r&&o.schema.checkAttribute(r,"imageStyle"))for(const t of e[r.name])o.consumable.consume(i,{classes:t.className})&&o.writer.setAttribute("imageStyle",t.name,r)}}(this.normalizedStyles);n.editing.downcastDispatcher.on("attribute:imageStyle",i),n.data.downcastDispatcher.on("attribute:imageStyle",i),t&&(o.extend("imageBlock",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:figure",s,{priority:"low"})),e&&(o.extend("imageInline",{allowAttributes:"imageStyle"}),n.data.upcastDispatcher.on("element:img",s,{priority:"low"}))}_setupPostFixer(){const t=this.editor,e=t.model.document,n=t.plugins.get(nk),o=new Map(this.normalizedStyles.map((t=>[t.name,t])));e.registerPostFixer((t=>{let i=!1;for(const r of e.differ.getChanges())if("insert"==r.type||"attribute"==r.type&&"imageStyle"==r.attributeKey){let e="insert"==r.type?r.position.nodeAfter:r.range.start.nodeAfter;if(e&&e.is("element","paragraph")&&e.childCount>0&&(e=e.getChild(0)),!n.isImage(e))continue;const s=e.getAttribute("imageStyle");if(!s)continue;const a=o.get(s);a&&a.modelElements.includes(e.name)||(t.removeAttribute("imageStyle",e),i=!0)}return i}))}}var $k=n(4622),Qk={attributes:{"data-cke":!0}};Qk.setAttributes=is(),Qk.insert=ns().bind(null,"head"),Qk.domAPI=ts(),Qk.insertStyleElement=ss();Jr()($k.Z,Qk);$k.Z&&$k.Z.locals&&$k.Z.locals;class Jk extends V{static get requires(){return[Kk]}static get pluginName(){return"ImageStyleUI"}get localizedDefaultStylesTitles(){const t=this.editor.t;return{"Wrap text":t("Wrap text"),"Break text":t("Break text"),"In line":t("In line"),"Full size image":t("Full size image"),"Side image":t("Side image"),"Left aligned image":t("Left aligned image"),"Centered image":t("Centered image"),"Right aligned image":t("Right aligned image")}}init(){const t=this.editor.plugins,e=this.editor.config.get("image.toolbar")||[],n=Xk(t.get("ImageStyleEditing").normalizedStyles,this.localizedDefaultStylesTitles);for(const t of n)this._createButton(t);const o=Xk([...e.filter(E),...Zk.getDefaultDropdownDefinitions(t)],this.localizedDefaultStylesTitles);for(const t of o)this._createDropdown(t,n)}_createDropdown(t,e){const n=this.editor.ui.componentFactory;n.add(t.name,(o=>{let i;const{defaultItem:r,items:s,title:a}=t,l=s.filter((t=>e.find((({name:e})=>tw(e)===t)))).map((t=>{const e=n.create(t);return t===r&&(i=e),e}));s.length!==l.length&&Zk.warnInvalidStyle({dropdown:t});const c=kh(o,Wu),d=c.buttonView,u=d.arrowView;return wh(c,l,{enableActiveItemFocusOnDropdownOpen:!0}),d.set({label:ew(a,i.label),class:null,tooltip:!0}),u.unbind("label"),u.set({label:a}),d.bind("icon").toMany(l,"isOn",((...t)=>{const e=t.findIndex(hi);return e<0?i.icon:l[e].icon})),d.bind("label").toMany(l,"isOn",((...t)=>{const e=t.findIndex(hi);return ew(a,e<0?i.label:l[e].label)})),d.bind("isOn").toMany(l,"isOn",((...t)=>t.some(hi))),d.bind("class").toMany(l,"isOn",((...t)=>t.some(hi)?"ck-splitbutton_flatten":null)),d.on("execute",(()=>{l.some((({isOn:t})=>t))?c.isOpen=!c.isOpen:i.fire("execute")})),c.bind("isEnabled").toMany(l,"isEnabled",((...t)=>t.some(hi))),this.listenTo(c,"execute",(()=>{this.editor.editing.view.focus()})),c}))}_createButton(t){const e=t.name;this.editor.ui.componentFactory.add(tw(e),(n=>{const o=this.editor.commands.get("imageStyle"),i=new Su(n);return i.set({label:t.title,icon:t.icon,tooltip:!0,isToggleable:!0}),i.bind("isEnabled").to(o,"isEnabled"),i.bind("isOn").to(o,"value",(t=>t===e)),i.on("execute",this._executeCommand.bind(this,e)),i}))}_executeCommand(t){this.editor.execute("imageStyle",{value:t}),this.editor.editing.view.focus()}}function Xk(t,e){for(const n of t)e[n.title]&&(n.title=e[n.title]);return t}function tw(t){return`imageStyle:${t}`}function ew(t,e){return(t?t+": ":"")+e}class nw{constructor(){const t=new window.FileReader;this._reader=t,this._data=void 0,this.set("loaded",0),t.onprogress=t=>{this.loaded=t.loaded}}get error(){return this._reader.error}get data(){return this._data}read(t){const e=this._reader;return this.total=t.size,new Promise(((n,o)=>{e.onload=()=>{const t=e.result;this._data=t,n(t)},e.onerror=()=>{o("error")},e.onabort=()=>{o("aborted")},this._reader.readAsDataURL(t)}))}abort(){this._reader.abort()}}j(nw,N);class ow extends V{static get pluginName(){return"FileRepository"}static get requires(){return[Hd]}init(){this.loaders=new bo,this.loaders.on("add",(()=>this._updatePendingAction())),this.loaders.on("remove",(()=>this._updatePendingAction())),this._loadersMap=new Map,this._pendingAction=null,this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0))}getLoader(t){return this._loadersMap.get(t)||null}createLoader(t){if(!this.createUploadAdapter)return c("filerepository-no-upload-adapter"),null;const e=new iw(Promise.resolve(t),this.createUploadAdapter);return this.loaders.add(e),this._loadersMap.set(t,e),t instanceof Promise&&e.file.then((t=>{this._loadersMap.set(t,e)})).catch((()=>{})),e.on("change:uploaded",(()=>{let t=0;for(const e of this.loaders)t+=e.uploaded;this.uploaded=t})),e.on("change:uploadTotal",(()=>{let t=0;for(const e of this.loaders)e.uploadTotal&&(t+=e.uploadTotal);this.uploadTotal=t})),e}destroyLoader(t){const e=t instanceof iw?t:this.getLoader(t);e._destroy(),this.loaders.remove(e),this._loadersMap.forEach(((t,n)=>{t===e&&this._loadersMap.delete(n)}))}_updatePendingAction(){const t=this.editor.plugins.get(Hd);if(this.loaders.length){if(!this._pendingAction){const e=this.editor.t,n=t=>`${e("Upload in progress")} ${parseInt(t)}%.`;this._pendingAction=t.add(n(this.uploadedPercent)),this._pendingAction.bind("message").to(this,"uploadedPercent",n)}}else t.remove(this._pendingAction),this._pendingAction=null}}j(ow,N);class iw{constructor(t,e){this.id=r(),this._filePromiseWrapper=this._createFilePromiseWrapper(t),this._adapter=e(this),this._reader=new nw,this.set("status","idle"),this.set("uploaded",0),this.set("uploadTotal",null),this.bind("uploadedPercent").to(this,"uploaded",this,"uploadTotal",((t,e)=>e?t/e*100:0)),this.set("uploadResponse",null)}get file(){return this._filePromiseWrapper?this._filePromiseWrapper.promise.then((t=>this._filePromiseWrapper?t:null)):Promise.resolve(null)}get data(){return this._reader.data}read(){if("idle"!=this.status)throw new l("filerepository-read-wrong-status",this);return this.status="reading",this.file.then((t=>this._reader.read(t))).then((t=>{if("reading"!==this.status)throw this.status;return this.status="idle",t})).catch((t=>{if("aborted"===t)throw this.status="aborted","aborted";throw this.status="error",this._reader.error?this._reader.error:t}))}upload(){if("idle"!=this.status)throw new l("filerepository-upload-wrong-status",this);return this.status="uploading",this.file.then((()=>this._adapter.upload())).then((t=>(this.uploadResponse=t,this.status="idle",t))).catch((t=>{if("aborted"===this.status)throw"aborted";throw this.status="error",t}))}abort(){const t=this.status;this.status="aborted",this._filePromiseWrapper.isFulfilled?"reading"==t?this._reader.abort():"uploading"==t&&this._adapter.abort&&this._adapter.abort():(this._filePromiseWrapper.promise.catch((()=>{})),this._filePromiseWrapper.rejecter("aborted")),this._destroy()}_destroy(){this._filePromiseWrapper=void 0,this._reader=void 0,this._adapter=void 0,this.uploadResponse=void 0}_createFilePromiseWrapper(t){const e={};return e.promise=new Promise(((n,o)=>{e.rejecter=o,e.isFulfilled=!1,t.then((t=>{e.isFulfilled=!0,n(t)})).catch((t=>{e.isFulfilled=!0,o(t)}))})),e}}j(iw,N);class rw extends Jd{constructor(t){super(t),this.buttonView=new Su(t),this._fileInputView=new sw(t),this._fileInputView.bind("acceptedType").to(this),this._fileInputView.bind("allowMultipleFiles").to(this),this._fileInputView.delegate("done").to(this),this.setTemplate({tag:"span",attributes:{class:"ck-file-dialog-button"},children:[this.buttonView,this._fileInputView]}),this.buttonView.on("execute",(()=>{this._fileInputView.open()}))}focus(){this.buttonView.focus()}}class sw extends Jd{constructor(t){super(t),this.set("acceptedType"),this.set("allowMultipleFiles",!1);const e=this.bindTemplate;this.setTemplate({tag:"input",attributes:{class:["ck-hidden"],type:"file",tabindex:"-1",accept:e.to("acceptedType"),multiple:e.to("allowMultipleFiles")},on:{change:e.to((()=>{this.element&&this.element.files&&this.element.files.length&&this.fire("done",this.element.files),this.element.value=""}))}})}open(){this.element.click()}}class aw{constructor(t,e){this.loader=t,this.options=e}upload(){return this.loader.file.then((t=>new Promise(((e,n)=>{this._initRequest(),this._initListeners(e,n,t),this._sendRequest(t)}))))}abort(){this.xhr&&this.xhr.abort()}_initRequest(){const t=this.xhr=new XMLHttpRequest;t.open("POST",this.options.uploadUrl,!0),t.responseType="json"}_initListeners(t,e,n){const o=this.xhr,i=this.loader,r=`Couldn't upload file: ${n.name}.`;o.addEventListener("error",(()=>e(r))),o.addEventListener("abort",(()=>e())),o.addEventListener("load",(()=>{const n=o.response;if(!n||n.error)return e(n&&n.error&&n.error.message?n.error.message:r);const i=n.url?{default:n.url}:n.urls;t({...n,urls:i})})),o.upload&&o.upload.addEventListener("progress",(t=>{t.lengthComputable&&(i.uploadTotal=t.total,i.uploaded=t.loaded)}))}_sendRequest(t){const e=this.options.headers||{},n=this.options.withCredentials||!1;for(const t of Object.keys(e))this.xhr.setRequestHeader(t,e[t]);this.xhr.withCredentials=n;const o=new FormData;o.append("upload",t),this.xhr.send(o)}}function lw(t){const e=t.map((t=>t.replace("+","\\+")));return new RegExp(`^image\\/(${e.join("|")})$`)}function cw(t){return new Promise(((e,n)=>{const o=t.getAttribute("src");fetch(o).then((t=>t.blob())).then((t=>{const n=dw(t,o),i=n.replace("image/",""),r=new File([t],`image.${i}`,{type:n});e(r)})).catch((t=>t&&"TypeError"===t.name?function(t){return function(t){return new Promise(((e,n)=>{const o=ms.document.createElement("img");o.addEventListener("load",(()=>{const t=ms.document.createElement("canvas");t.width=o.width,t.height=o.height;t.getContext("2d").drawImage(o,0,0),t.toBlob((t=>t?e(t):n()))})),o.addEventListener("error",(()=>n())),o.src=t}))}(t).then((e=>{const n=dw(e,t),o=n.replace("image/","");return new File([e],`image.${o}`,{type:n})}))}(o).then(e).catch(n):n(t)))}))}function dw(t,e){return t.type?t.type:e.match(/data:(image\/\w+);base64/)?e.match(/data:(image\/\w+);base64/)[1].toLowerCase():"image/jpeg"}class uw extends V{static get pluginName(){return"ImageUploadUI"}init(){const t=this.editor,e=t.t,n=n=>{const o=new rw(n),i=t.commands.get("uploadImage"),r=t.config.get("image.upload.types"),s=lw(r);return o.set({acceptedType:r.map((t=>`image/${t}`)).join(","),allowMultipleFiles:!0}),o.buttonView.set({label:e("Insert image"),icon:Gd.image,tooltip:!0}),o.buttonView.bind("isEnabled").to(i),o.on("done",((e,n)=>{const o=Array.from(n).filter((t=>s.test(t.type)));o.length&&t.execute("uploadImage",{file:o})})),o};t.ui.componentFactory.add("uploadImage",n),t.ui.componentFactory.add("imageUpload",n)}}var hw=n(5870),mw={attributes:{"data-cke":!0}};mw.setAttributes=is(),mw.insert=ns().bind(null,"head"),mw.domAPI=ts(),mw.insertStyleElement=ss();Jr()(hw.Z,mw);hw.Z&&hw.Z.locals&&hw.Z.locals;var gw=n(9899),pw={attributes:{"data-cke":!0}};pw.setAttributes=is(),pw.insert=ns().bind(null,"head"),pw.domAPI=ts(),pw.insertStyleElement=ss();Jr()(gw.Z,pw);gw.Z&&gw.Z.locals&&gw.Z.locals;var fw=n(9825),bw={attributes:{"data-cke":!0}};bw.setAttributes=is(),bw.insert=ns().bind(null,"head"),bw.domAPI=ts(),bw.insertStyleElement=ss();Jr()(fw.Z,bw);fw.Z&&fw.Z.locals&&fw.Z.locals;class kw extends V{static get pluginName(){return"ImageUploadProgress"}constructor(t){super(t),this.placeholder="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="}init(){const t=this.editor;t.plugins.has("ImageBlockEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageBlock",((...t)=>this.uploadStatusChange(...t))),t.plugins.has("ImageInlineEditing")&&t.editing.downcastDispatcher.on("attribute:uploadStatus:imageInline",((...t)=>this.uploadStatusChange(...t)))}uploadStatusChange(t,e,n){const o=this.editor,i=e.item,r=i.getAttribute("uploadId");if(!n.consumable.consume(e.item,t.name))return;const s=o.plugins.get("ImageUtils"),a=o.plugins.get(ow),l=r?e.attributeNewValue:null,c=this.placeholder,d=o.editing.mapper.toViewElement(i),u=n.writer;if("reading"==l)return ww(d,u),void Aw(s,c,d,u);if("uploading"==l){const t=a.loaders.get(r);return ww(d,u),void(t?(Cw(d,u),function(t,e,n,o){const i=function(t){const e=t.createUIElement("div",{class:"ck-progress-bar"});return t.setCustomProperty("progressBar",!0,e),e}(e);e.insert(e.createPositionAt(t,"end"),i),n.on("change:uploadedPercent",((t,e,n)=>{o.change((t=>{t.setStyle("width",n+"%",i)}))}))}(d,u,t,o.editing.view),function(t,e,n,o){if(o.data){const i=t.findViewImgElement(e);n.setAttribute("src",o.data,i)}}(s,d,u,t)):Aw(s,c,d,u))}"complete"==l&&a.loaders.get(r)&&function(t,e,n){const o=e.createUIElement("div",{class:"ck-image-upload-complete-icon"});e.insert(e.createPositionAt(t,"end"),o),setTimeout((()=>{n.change((t=>t.remove(t.createRangeOn(o))))}),3e3)}(d,u,o.editing.view),function(t,e){vw(t,e,"progressBar")}(d,u),Cw(d,u),function(t,e){e.removeClass("ck-appear",t)}(d,u)}}function ww(t,e){t.hasClass("ck-appear")||e.addClass("ck-appear",t)}function Aw(t,e,n,o){n.hasClass("ck-image-upload-placeholder")||o.addClass("ck-image-upload-placeholder",n);const i=t.findViewImgElement(n);i.getAttribute("src")!==e&&o.setAttribute("src",e,i),_w(n,"placeholder")||o.insert(o.createPositionAfter(i),function(t){const e=t.createUIElement("div",{class:"ck-upload-placeholder-loader"});return t.setCustomProperty("placeholder",!0,e),e}(o))}function Cw(t,e){t.hasClass("ck-image-upload-placeholder")&&e.removeClass("ck-image-upload-placeholder",t),vw(t,e,"placeholder")}function _w(t,e){for(const n of t.getChildren())if(n.getCustomProperty(e))return n}function vw(t,e,n){const o=_w(t,n);o&&e.remove(e.createRangeOn(o))}class yw extends H{refresh(){const t=this.editor,e=t.plugins.get("ImageUtils"),n=t.model.document.selection.getSelectedElement();this.isEnabled=e.isImageAllowed()||e.isImage(n)}execute(t){const e=wo(t.file),n=this.editor.model.document.selection,o=this.editor.plugins.get("ImageUtils"),i=Object.fromEntries(n.getAttributes());e.forEach(((t,e)=>{const r=n.getSelectedElement();if(e&&r&&o.isImage(r)){const e=this.editor.model.createPositionAfter(r);this._uploadImage(t,i,e)}else this._uploadImage(t,i)}))}_uploadImage(t,e,n){const o=this.editor,i=o.plugins.get(ow).createLoader(t),r=o.plugins.get("ImageUtils");i&&r.insertImage({...e,uploadId:i.id},n)}}class xw extends V{static get requires(){return[ow,Gh,Wp,nk]}static get pluginName(){return"ImageUploadEditing"}constructor(t){super(t),t.config.define("image",{upload:{types:["jpeg","png","gif","bmp","webp","tiff"]}}),this._uploadImageElements=new Map}init(){const t=this.editor,e=t.model.document,n=t.conversion,o=t.plugins.get(ow),i=t.plugins.get("ImageUtils"),r=lw(t.config.get("image.upload.types")),s=new yw(t);t.commands.add("uploadImage",s),t.commands.add("imageUpload",s),n.for("upcast").attributeToAttribute({view:{name:"img",key:"uploadId"},model:"uploadId"}),this.listenTo(t.editing.view.document,"clipboardInput",((e,n)=>{if(o=n.dataTransfer,Array.from(o.types).includes("text/html")&&""!==o.getData("text/html"))return;var o;const i=Array.from(n.dataTransfer.files).filter((t=>!!t&&r.test(t.type)));i.length&&(e.stop(),t.model.change((e=>{n.targetRanges&&e.setSelection(n.targetRanges.map((e=>t.editing.mapper.toModelRange(e)))),t.model.enqueueChange((()=>{t.execute("uploadImage",{file:i})}))})))})),this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",((e,n)=>{const r=Array.from(t.editing.view.createRangeIn(n.content)).filter((t=>function(t,e){return!(!t.isInlineImageView(e)||!e.getAttribute("src"))&&(e.getAttribute("src").match(/^data:image\/\w+;base64,/g)||e.getAttribute("src").match(/^blob:/g))}(i,t.item)&&!t.item.getAttribute("uploadProcessed"))).map((t=>({promise:cw(t.item),imageElement:t.item})));if(!r.length)return;const s=new Pm(t.editing.view.document);for(const t of r){s.setAttribute("uploadProcessed",!0,t.imageElement);const e=o.createLoader(t.promise);e&&(s.setAttribute("src","",t.imageElement),s.setAttribute("uploadId",e.id,t.imageElement))}})),t.editing.view.document.on("dragover",((t,e)=>{e.preventDefault()})),e.on("change",(()=>{const n=e.differ.getChanges({includeChangesInGraveyard:!0}).reverse(),i=new Set;for(const e of n)if("insert"==e.type&&"$text"!=e.name){const n=e.position.nodeAfter,r="$graveyard"==e.position.root.rootName;for(const e of Ew(t,n)){const t=e.getAttribute("uploadId");if(!t)continue;const n=o.loaders.get(t);n&&(r?i.has(t)||n.abort():(i.add(t),this._uploadImageElements.set(t,e),"idle"==n.status&&this._readAndUpload(n)))}}})),this.on("uploadComplete",((t,{imageElement:e,data:n})=>{const o=n.urls?n.urls:n;this.editor.model.change((t=>{t.setAttribute("src",o.default,e),this._parseAndSetSrcsetAttributeOnImage(o,e,t)}))}),{priority:"low"})}afterInit(){const t=this.editor.model.schema;this.editor.plugins.has("ImageBlockEditing")&&t.extend("imageBlock",{allowAttributes:["uploadId","uploadStatus"]}),this.editor.plugins.has("ImageInlineEditing")&&t.extend("imageInline",{allowAttributes:["uploadId","uploadStatus"]})}_readAndUpload(t){const e=this.editor,n=e.model,o=e.locale.t,i=e.plugins.get(ow),r=e.plugins.get(Gh),s=e.plugins.get("ImageUtils"),a=this._uploadImageElements;return n.enqueueChange({isUndoable:!1},(e=>{e.setAttribute("uploadStatus","reading",a.get(t.id))})),t.read().then((()=>{const o=t.upload(),i=a.get(t.id);if(ar.isSafari){const t=e.editing.mapper.toViewElement(i),n=s.findViewImgElement(t);e.editing.view.once("render",(()=>{if(!n.parent)return;const t=e.editing.view.domConverter.mapViewToDom(n.parent);if(!t)return;const o=t.style.display;t.style.display="none",t._ckHack=t.offsetHeight,t.style.display=o}))}return n.enqueueChange({isUndoable:!1},(t=>{t.setAttribute("uploadStatus","uploading",i)})),o})).then((e=>{n.enqueueChange({isUndoable:!1},(n=>{const o=a.get(t.id);n.setAttribute("uploadStatus","complete",o),this.fire("uploadComplete",{data:e,imageElement:o})})),l()})).catch((e=>{if("error"!==t.status&&"aborted"!==t.status)throw e;"error"==t.status&&e&&r.showWarning(e,{title:o("Upload failed"),namespace:"upload"}),n.enqueueChange({isUndoable:!1},(e=>{e.remove(a.get(t.id))})),l()}));function l(){n.enqueueChange({isUndoable:!1},(e=>{const n=a.get(t.id);e.removeAttribute("uploadId",n),e.removeAttribute("uploadStatus",n),a.delete(t.id)})),i.destroyLoader(t)}}_parseAndSetSrcsetAttributeOnImage(t,e,n){let o=0;const i=Object.keys(t).filter((t=>{const e=parseInt(t,10);if(!isNaN(e))return o=Math.max(o,e),!0})).map((e=>`${t[e]} ${e}w`)).join(", ");""!=i&&n.setAttribute("srcset",{data:i,width:o},e)}}function Ew(t,e){const n=t.plugins.get("ImageUtils");return Array.from(t.model.createRangeOn(e)).filter((t=>n.isImage(t.item))).map((t=>t.item))}class Dw extends V{static get pluginName(){return"IndentEditing"}init(){const t=this.editor;t.commands.add("indent",new q(t)),t.commands.add("outdent",new q(t))}}const Sw='',Iw='';class Tw extends V{static get pluginName(){return"IndentUI"}init(){const t=this.editor,e=t.locale,n=t.t,o="ltr"==e.uiLanguageDirection?Sw:Iw,i="ltr"==e.uiLanguageDirection?Iw:Sw;this._defineButton("indent",n("Increase indent"),o),this._defineButton("outdent",n("Decrease indent"),i)}_defineButton(t,e,n){const o=this.editor;o.ui.componentFactory.add(t,(i=>{const r=o.commands.get(t),s=new Su(i);return s.set({label:e,icon:n,tooltip:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),this.listenTo(s,"execute",(()=>{o.execute(t),o.editing.view.focus()})),s}))}}class Mw extends H{constructor(t,e){super(t),this._indentBehavior=e}refresh(){const t=this.editor.model,e=Ba(t.document.selection.getSelectedBlocks());e&&t.schema.checkAttribute(e,"blockIndent")?this.isEnabled=this._indentBehavior.checkEnabled(e.getAttribute("blockIndent")):this.isEnabled=!1}execute(){const t=this.editor.model,e=function(t){const e=t.document.selection,n=t.schema;return Array.from(e.getSelectedBlocks()).filter((t=>n.checkAttribute(t,"blockIndent")))}(t);t.change((t=>{for(const n of e){const e=n.getAttribute("blockIndent"),o=this._indentBehavior.getNextIndent(e);o?t.setAttribute("blockIndent",o,n):t.removeAttribute("blockIndent",n)}}))}}class Bw{constructor(t){this.isForward="forward"===t.direction,this.offset=t.offset,this.unit=t.unit}checkEnabled(t){const e=parseFloat(t||0);return this.isForward||e>0}getNextIndent(t){const e=parseFloat(t||0);if(!(!t||t.endsWith(this.unit)))return this.isForward?this.offset+this.unit:void 0;const n=e+(this.isForward?this.offset:-this.offset);return n>0?n+this.unit:void 0}}class Nw{constructor(t){this.isForward="forward"===t.direction,this.classes=t.classes}checkEnabled(t){const e=this.classes.indexOf(t);return this.isForward?e=0}getNextIndent(t){const e=this.classes.indexOf(t),n=this.isForward?1:-1;return this.classes[e+n]}}const zw=["paragraph","heading1","heading2","heading3","heading4","heading5","heading6"];const Pw="italic";class Lw extends V{static get pluginName(){return"ItalicEditing"}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:Pw}),t.model.schema.setAttributeProperties(Pw,{isFormatting:!0,copyOnEnter:!0}),t.conversion.attributeToElement({model:Pw,view:"i",upcastAlso:["em",{styles:{"font-style":"italic"}}]}),t.commands.add(Pw,new Op(t,Pw)),t.keystrokes.set("CTRL+I",Pw)}}const Ow="italic";class Rw extends V{static get pluginName(){return"ItalicUI"}init(){const t=this.editor,e=t.t;t.ui.componentFactory.add(Ow,(n=>{const o=t.commands.get(Ow),i=new Su(n);return i.set({label:e("Italic"),icon:'',keystroke:"CTRL+I",tooltip:!0,isToggleable:!0}),i.bind("isOn","isEnabled").to(o,"value","isEnabled"),this.listenTo(i,"execute",(()=>{t.execute(Ow),t.editing.view.focus()})),i}))}}class jw{constructor(){this._definitions=new Set}get length(){return this._definitions.size}add(t){Array.isArray(t)?t.forEach((t=>this._definitions.add(t))):this._definitions.add(t)}getDispatcher(){return t=>{t.on("attribute:linkHref",((t,e,n)=>{if(!n.consumable.test(e.item,"attribute:linkHref"))return;if(!e.item.is("selection")&&!n.schema.isInline(e.item))return;const o=n.writer,i=o.document.selection;for(const t of this._definitions){const r=o.createAttributeElement("a",t.attributes,{priority:5});t.classes&&o.addClass(t.classes,r);for(const e in t.styles)o.setStyle(e,t.styles[e],r);o.setCustomProperty("link",!0,r),t.callback(e.attributeNewValue)?e.item.is("selection")?o.wrap(i.getFirstRange(),r):o.wrap(n.mapper.toViewRange(e.range),r):o.unwrap(n.mapper.toViewRange(e.range),r)}}),{priority:"high"})}}getDispatcherForLinkedImage(){return t=>{t.on("attribute:linkHref:imageBlock",((t,e,{writer:n,mapper:o})=>{const i=o.toViewElement(e.item),r=Array.from(i.getChildren()).find((t=>"a"===t.name));for(const t of this._definitions){const o=Mo(t.attributes);if(t.callback(e.attributeNewValue)){for(const[t,e]of o)"class"===t?n.addClass(e,r):n.setAttribute(t,e,r);t.classes&&n.addClass(t.classes,r);for(const e in t.styles)n.setStyle(e,t.styles[e],r)}else{for(const[t,e]of o)"class"===t?n.removeClass(e,r):n.removeAttribute(t,r);t.classes&&n.removeClass(t.classes,r);for(const e in t.styles)n.removeStyle(e,r)}}}))}}}const Vw=function(t,e,n){var o=t.length;return n=void 0===n?o:n,!e&&n>=o?t:ti(t,e,n)};var Fw=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const Hw=function(t){return Fw.test(t)};const Uw=function(t){return t.split("")};var qw="[\\ud800-\\udfff]",Gw="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Ww="\\ud83c[\\udffb-\\udfff]",Zw="[^\\ud800-\\udfff]",Yw="(?:\\ud83c[\\udde6-\\uddff]){2}",Kw="[\\ud800-\\udbff][\\udc00-\\udfff]",$w="(?:"+Gw+"|"+Ww+")"+"?",Qw="[\\ufe0e\\ufe0f]?",Jw=Qw+$w+("(?:\\u200d(?:"+[Zw,Yw,Kw].join("|")+")"+Qw+$w+")*"),Xw="(?:"+[Zw+Gw+"?",Gw,Yw,Kw,qw].join("|")+")",tA=RegExp(Ww+"(?="+Ww+")|"+Xw+Jw,"g");const eA=function(t){return t.match(tA)||[]};const nA=function(t){return Hw(t)?eA(t):Uw(t)};const oA=function(t){return function(e){e=Ko(e);var n=Hw(e)?nA(e):void 0,o=n?n[0]:e.charAt(0),i=n?Vw(n,1).join(""):e.slice(1);return o[t]()+i}}("toUpperCase"),iA=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205f\u3000]/g,rA=/^(?:(?:https?|ftps?|mailto):|[^a-z]|[a-z+.-]+(?:[^a-z+.:-]|$))/i,sA=/^[\S]+@((?![-_])(?:[-\w\u00a1-\uffff]{0,63}[^-_]\.))+(?:[a-z\u00a1-\uffff]{2,})$/i,aA=/^((\w+:(\/{2,})?)|(\W))/i,lA="Ctrl+K";function cA(t,{writer:e}){const n=e.createAttributeElement("a",{href:t},{priority:5});return e.setCustomProperty("link",!0,n),n}function dA(t){return function(t){return t.replace(iA,"").match(rA)}(t=String(t))?t:"#"}function uA(t,e){return!!t&&e.checkAttribute(t.name,"linkHref")}function hA(t,e){const n=(o=t,sA.test(o)?"mailto:":e);var o;const i=!!n&&!aA.test(t);return t&&i?n+t:t}function mA(t){window.open(t,"_blank","noopener")}class gA extends H{constructor(t){super(t),this.manualDecorators=new bo,this.automaticDecorators=new jw}restoreManualDecoratorStates(){for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement()||Ba(e.getSelectedBlocks());uA(n,t.schema)?(this.value=n.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttribute(n,"linkHref")):(this.value=e.getAttribute("linkHref"),this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref"));for(const t of this.manualDecorators)t.value=this._getDecoratorStateFromModel(t.id)}execute(t,e={}){const n=this.editor.model,o=n.document.selection,i=[],r=[];for(const t in e)e[t]?i.push(t):r.push(t);n.change((e=>{if(o.isCollapsed){const s=o.getFirstPosition();if(o.hasAttribute("linkHref")){const a=gp(s,"linkHref",o.getAttribute("linkHref"),n);e.setAttribute("linkHref",t,a),i.forEach((t=>{e.setAttribute(t,!0,a)})),r.forEach((t=>{e.removeAttribute(t,a)})),e.setSelection(e.createPositionAfter(a.end.nodeBefore))}else if(""!==t){const r=Mo(o.getAttributes());r.set("linkHref",t),i.forEach((t=>{r.set(t,!0)}));const{end:a}=n.insertContent(e.createText(t,r),s);e.setSelection(a)}["linkHref",...i,...r].forEach((t=>{e.removeSelectionAttribute(t)}))}else{const s=n.schema.getValidRanges(o.getRanges(),"linkHref"),a=[];for(const t of o.getSelectedBlocks())n.schema.checkAttribute(t,"linkHref")&&a.push(e.createRangeOn(t));const l=a.slice();for(const t of s)this._isRangeToUpdate(t,a)&&l.push(t);for(const n of l)e.setAttribute("linkHref",t,n),i.forEach((t=>{e.setAttribute(t,!0,n)})),r.forEach((t=>{e.removeAttribute(t,n)}))}}))}_getDecoratorStateFromModel(t){const e=this.editor.model,n=e.document.selection,o=n.getSelectedElement();return uA(o,e.schema)?o.getAttribute(t):n.getAttribute(t)}_isRangeToUpdate(t,e){for(const n of e)if(n.containsRange(t))return!1;return!0}}class pA extends H{refresh(){const t=this.editor.model,e=t.document.selection,n=e.getSelectedElement();uA(n,t.schema)?this.isEnabled=t.schema.checkAttribute(n,"linkHref"):this.isEnabled=t.schema.checkAttributeInSelection(e,"linkHref")}execute(){const t=this.editor,e=this.editor.model,n=e.document.selection,o=t.commands.get("link");e.change((t=>{const i=n.isCollapsed?[gp(n.getFirstPosition(),"linkHref",n.getAttribute("linkHref"),e)]:e.schema.getValidRanges(n.getRanges(),"linkHref");for(const e of i)if(t.removeAttribute("linkHref",e),o)for(const n of o.manualDecorators)t.removeAttribute(n.id,e)}))}}class fA{constructor({id:t,label:e,attributes:n,classes:o,styles:i,defaultValue:r}){this.id=t,this.set("value"),this.defaultValue=r,this.label=e,this.attributes=n,this.classes=o,this.styles=i}_createPattern(){return{attributes:this.attributes,classes:this.classes,styles:this.styles}}}j(fA,N);var bA=n(399),kA={attributes:{"data-cke":!0}};kA.setAttributes=is(),kA.insert=ns().bind(null,"head"),kA.domAPI=ts(),kA.insertStyleElement=ss();Jr()(bA.Z,kA);bA.Z&&bA.Z.locals&&bA.Z.locals;const wA="automatic",AA=/^(https?:)?\/\//;class CA extends V{static get pluginName(){return"LinkEditing"}static get requires(){return[Xg,Wg,Wp]}constructor(t){super(t),t.config.define("link",{addTargetToExternalLinks:!1})}init(){const t=this.editor;t.model.schema.extend("$text",{allowAttributes:"linkHref"}),t.conversion.for("dataDowncast").attributeToElement({model:"linkHref",view:cA}),t.conversion.for("editingDowncast").attributeToElement({model:"linkHref",view:(t,e)=>cA(dA(t),e)}),t.conversion.for("upcast").elementToAttribute({view:{name:"a",attributes:{href:!0}},model:{key:"linkHref",value:t=>t.getAttribute("href")}}),t.commands.add("link",new gA(t)),t.commands.add("unlink",new pA(t));const e=function(t,e){const n={"Open in a new tab":t("Open in a new tab"),Downloadable:t("Downloadable")};return e.forEach((t=>(t.label&&n[t.label]&&(t.label=n[t.label]),t))),e}(t.t,function(t){const e=[];if(t)for(const[n,o]of Object.entries(t)){const t=Object.assign({},o,{id:`link${oA(n)}`});e.push(t)}return e}(t.config.get("link.decorators")));this._enableAutomaticDecorators(e.filter((t=>t.mode===wA))),this._enableManualDecorators(e.filter((t=>"manual"===t.mode)));t.plugins.get(Xg).registerAttribute("linkHref"),function(t,e,n,o){const i=t.editing.view,r=new Set;i.document.registerPostFixer((i=>{const s=t.model.document.selection;let a=!1;if(s.hasAttribute(e)){const l=gp(s.getFirstPosition(),e,s.getAttribute(e),t.model),c=t.editing.mapper.toViewRange(l);for(const t of c.getItems())t.is("element",n)&&!t.hasClass(o)&&(i.addClass(o,t),r.add(t),a=!0)}return a})),t.conversion.for("editingDowncast").add((t=>{function e(){i.change((t=>{for(const e of r.values())t.removeClass(o,e),r.delete(e)}))}t.on("insert",e,{priority:"highest"}),t.on("remove",e,{priority:"highest"}),t.on("attribute",e,{priority:"highest"}),t.on("selection",e,{priority:"highest"})}))}(t,"linkHref","a","ck-link_selected"),this._enableLinkOpen(),this._enableInsertContentSelectionAttributesFixer(),this._enableClickingAfterLink(),this._enableTypingOverLink(),this._handleDeleteContentAfterLink()}_enableAutomaticDecorators(t){const e=this.editor,n=e.commands.get("link").automaticDecorators;e.config.get("link.addTargetToExternalLinks")&&n.add({id:"linkIsExternal",mode:wA,callback:t=>AA.test(t),attributes:{target:"_blank",rel:"noopener noreferrer"}}),n.add(t),n.length&&e.conversion.for("downcast").add(n.getDispatcher())}_enableManualDecorators(t){if(!t.length)return;const e=this.editor,n=e.commands.get("link").manualDecorators;t.forEach((t=>{e.model.schema.extend("$text",{allowAttributes:t.id}),t=new fA(t),n.add(t),e.conversion.for("downcast").attributeToElement({model:t.id,view:(e,{writer:n,schema:o},{item:i})=>{if((i.is("selection")||o.isInline(i))&&e){const e=n.createAttributeElement("a",t.attributes,{priority:5});t.classes&&n.addClass(t.classes,e);for(const o in t.styles)n.setStyle(o,t.styles[o],e);return n.setCustomProperty("link",!0,e),e}}}),e.conversion.for("upcast").elementToAttribute({view:{name:"a",...t._createPattern()},model:{key:t.id}})}))}_enableLinkOpen(){const t=this.editor,e=t.editing.view.document,n=t.model.document;this.listenTo(e,"click",((t,e)=>{if(!(ar.isMac?e.domEvent.metaKey:e.domEvent.ctrlKey))return;let n=e.domTarget;if("a"!=n.tagName.toLowerCase()&&(n=n.closest("a")),!n)return;const o=n.getAttribute("href");o&&(t.stop(),e.preventDefault(),mA(o))}),{context:"$capture"}),this.listenTo(e,"enter",((t,e)=>{const o=n.selection,i=o.getSelectedElement(),r=i?i.getAttribute("linkHref"):o.getAttribute("linkHref");r&&e.domEvent.altKey&&(t.stop(),mA(r))}),{context:"a"})}_enableInsertContentSelectionAttributesFixer(){const t=this.editor.model,e=t.document.selection;this.listenTo(t,"insertContent",(()=>{const n=e.anchor.nodeBefore,o=e.anchor.nodeAfter;e.hasAttribute("linkHref")&&n&&n.hasAttribute("linkHref")&&(o&&o.hasAttribute("linkHref")||t.change((e=>{_A(e,yA(t.schema))})))}),{priority:"low"})}_enableClickingAfterLink(){const t=this.editor,e=t.model;t.editing.view.addObserver(zm);let n=!1;this.listenTo(t.editing.view.document,"mousedown",(()=>{n=!0})),this.listenTo(t.editing.view.document,"selectionChange",(()=>{if(!n)return;n=!1;const t=e.document.selection;if(!t.isCollapsed)return;if(!t.hasAttribute("linkHref"))return;const o=t.getFirstPosition(),i=gp(o,"linkHref",t.getAttribute("linkHref"),e);(o.isTouching(i.start)||o.isTouching(i.end))&&e.change((t=>{_A(t,yA(e.schema))}))}))}_enableTypingOverLink(){const t=this.editor,e=t.editing.view;let n,o;this.listenTo(e.document,"delete",(()=>{o=!0}),{priority:"high"}),this.listenTo(t.model,"deleteContent",(()=>{const e=t.model.document.selection;e.isCollapsed||(o?o=!1:vA(t)&&function(t){const e=t.document.selection,n=e.getFirstPosition(),o=e.getLastPosition(),i=n.nodeAfter;if(!i)return!1;if(!i.is("$text"))return!1;if(!i.hasAttribute("linkHref"))return!1;const r=o.textNode||o.nodeBefore;if(i===r)return!0;return gp(n,"linkHref",i.getAttribute("linkHref"),t).containsRange(t.createRange(n,o),!0)}(t.model)&&(n=e.getAttributes()))}),{priority:"high"}),this.listenTo(t.model,"insertContent",((e,[i])=>{o=!1,vA(t)&&n&&(t.model.change((t=>{for(const[e,o]of n)t.setAttribute(e,o,i)})),n=null)}),{priority:"high"})}_handleDeleteContentAfterLink(){const t=this.editor,e=t.model,n=e.document.selection,o=t.editing.view;let i=!1,r=!1;this.listenTo(o.document,"delete",((t,e)=>{r=e.domEvent.keyCode===ur.backspace}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{i=!1;const t=n.getFirstPosition(),o=n.getAttribute("linkHref");if(!o)return;const r=gp(t,"linkHref",o,e);i=r.containsPosition(t)||r.end.isEqual(t)}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{r&&(r=!1,i||t.model.enqueueChange((t=>{_A(t,yA(e.schema))})))}),{priority:"low"})}}function _A(t,e){t.removeSelectionAttribute("linkHref");for(const n of e)t.removeSelectionAttribute(n)}function vA(t){return t.model.change((t=>t.batch)).isTyping}function yA(t){return t.getDefinition("$text").allowAttributes.filter((t=>t.startsWith("link")))}var xA=n(4827),EA={attributes:{"data-cke":!0}};EA.setAttributes=is(),EA.insert=ns().bind(null,"head"),EA.domAPI=ts(),EA.insertStyleElement=ss();Jr()(xA.Z,EA);xA.Z&&xA.Z.locals&&xA.Z.locals;class DA extends Jd{constructor(t,e){super(t);const n=t.t;this.focusTracker=new za,this.keystrokes=new Pa,this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Gd.check,"ck-button-save"),this.saveButtonView.type="submit",this.cancelButtonView=this._createButton(n("Cancel"),Gd.cancel,"ck-button-cancel","cancel"),this._manualDecoratorSwitches=this._createManualDecoratorSwitches(e),this.children=this._createFormChildren(e.manualDecorators),this._focusables=new Kd,this._focusCycler=new Ou({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}});const o=["ck","ck-link-form","ck-responsive-form"];e.manualDecorators.length&&o.push("ck-link-form_layout-vertical","ck-vertical-form"),this.setTemplate({tag:"form",attributes:{class:o,tabindex:"-1"},children:this.children}),Zd(this)}getDecoratorSwitchesState(){return Array.from(this._manualDecoratorSwitches).reduce(((t,e)=>(t[e.name]=e.isOn,t)),{})}render(){super.render(),Yd({view:this});[this.urlInputView,...this._manualDecoratorSwitches,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createUrlInput(){const t=this.locale.t,e=new Fh(this.locale,Hh);return e.label=t("Link URL"),e}_createButton(t,e,n,o){const i=new Su(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}_createManualDecoratorSwitches(t){const e=this.createCollection();for(const n of t.manualDecorators){const o=new Mu(this.locale);o.set({name:n.id,label:n.label,withText:!0}),o.bind("isOn").toMany([n,t],"value",((t,e)=>void 0===e&&void 0===t?n.defaultValue:t)),o.on("execute",(()=>{n.set("value",!o.isOn)})),e.add(o)}return e}_createFormChildren(t){const e=this.createCollection();if(e.add(this.urlInputView),t.length){const t=new Jd;t.setTemplate({tag:"ul",children:this._manualDecoratorSwitches.map((t=>({tag:"li",children:[t],attributes:{class:["ck","ck-list__item"]}}))),attributes:{class:["ck","ck-reset","ck-list"]}}),e.add(t)}return e.add(this.saveButtonView),e.add(this.cancelButtonView),e}}var SA=n(9465),IA={attributes:{"data-cke":!0}};IA.setAttributes=is(),IA.insert=ns().bind(null,"head"),IA.domAPI=ts(),IA.insertStyleElement=ss();Jr()(SA.Z,IA);SA.Z&&SA.Z.locals&&SA.Z.locals;class TA extends Jd{constructor(t){super(t);const e=t.t;this.focusTracker=new za,this.keystrokes=new Pa,this.previewButtonView=this._createPreviewButton(),this.unlinkButtonView=this._createButton(e("Unlink"),'',"unlink"),this.editButtonView=this._createButton(e("Edit link"),Gd.pencil,"edit"),this.set("href"),this._focusables=new Kd,this._focusCycler=new Ou({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this.setTemplate({tag:"div",attributes:{class:["ck","ck-link-actions","ck-responsive-form"],tabindex:"-1"},children:[this.previewButtonView,this.editButtonView,this.unlinkButtonView]})}render(){super.render();[this.previewButtonView,this.editButtonView,this.unlinkButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element)}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}_createButton(t,e,n){const o=new Su(this.locale);return o.set({label:t,icon:e,tooltip:!0}),o.delegate("execute").to(this,n),o}_createPreviewButton(){const t=new Su(this.locale),e=this.bindTemplate,n=this.t;return t.set({withText:!0,tooltip:n("Open link in new tab")}),t.extendTemplate({attributes:{class:["ck","ck-link-actions__preview"],href:e.to("href",(t=>t&&dA(t))),target:"_blank",rel:"noopener noreferrer"}}),t.bind("label").to(this,"href",(t=>t||n("This link has no URL"))),t.bind("isEnabled").to(this,"href",(t=>!!t)),t.template.tag="a",t.template.eventListeners={},t}}const MA='',BA="link-ui";class NA extends V{static get requires(){return[rm]}static get pluginName(){return"LinkUI"}init(){const t=this.editor;t.editing.view.addObserver(Nm),this.actionsView=this._createActionsView(),this.formView=this._createFormView(),this._balloon=t.plugins.get(rm),this._createToolbarLinkButton(),this._enableUserBalloonInteractions(),t.conversion.for("editingDowncast").markerToHighlight({model:BA,view:{classes:["ck-fake-link-selection"]}}),t.conversion.for("editingDowncast").markerToElement({model:BA,view:{name:"span",classes:["ck-fake-link-selection","ck-fake-link-selection_collapsed"]}})}destroy(){super.destroy(),this.formView.destroy()}_createActionsView(){const t=this.editor,e=new TA(t.locale),n=t.commands.get("link"),o=t.commands.get("unlink");return e.bind("href").to(n,"value"),e.editButtonView.bind("isEnabled").to(n),e.unlinkButtonView.bind("isEnabled").to(o),this.listenTo(e,"edit",(()=>{this._addFormView()})),this.listenTo(e,"unlink",(()=>{t.execute("unlink"),this._hideUI()})),e.keystrokes.set("Esc",((t,e)=>{this._hideUI(),e()})),e.keystrokes.set(lA,((t,e)=>{this._addFormView(),e()})),e}_createFormView(){const t=this.editor,e=t.commands.get("link"),n=t.config.get("link.defaultProtocol"),o=new DA(t.locale,e);return o.urlInputView.fieldView.bind("value").to(e,"value"),o.urlInputView.bind("isReadOnly").to(e,"isEnabled",(t=>!t)),o.saveButtonView.bind("isEnabled").to(e),this.listenTo(o,"submit",(()=>{const{value:e}=o.urlInputView.fieldView.element,i=hA(e,n);t.execute("link",i,o.getDecoratorSwitchesState()),this._closeFormView()})),this.listenTo(o,"cancel",(()=>{this._closeFormView()})),o.keystrokes.set("Esc",((t,e)=>{this._closeFormView(),e()})),o}_createToolbarLinkButton(){const t=this.editor,e=t.commands.get("link"),n=t.t;t.keystrokes.set(lA,((t,n)=>{n(),e.isEnabled&&this._showUI(!0)})),t.ui.componentFactory.add("link",(t=>{const o=new Su(t);return o.isEnabled=!0,o.label=n("Link"),o.icon=MA,o.keystroke=lA,o.tooltip=!0,o.isToggleable=!0,o.bind("isEnabled").to(e,"isEnabled"),o.bind("isOn").to(e,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>this._showUI(!0))),o}))}_enableUserBalloonInteractions(){const t=this.editor.editing.view.document;this.listenTo(t,"click",(()=>{this._getSelectedLinkElement()&&this._showUI()})),this.editor.keystrokes.set("Tab",((t,e)=>{this._areActionsVisible&&!this.actionsView.focusTracker.isFocused&&(this.actionsView.focus(),e())}),{priority:"high"}),this.editor.keystrokes.set("Esc",((t,e)=>{this._isUIVisible&&(this._hideUI(),e())})),Wd({emitter:this.formView,activator:()=>this._isUIInPanel,contextElements:[this._balloon.view.element],callback:()=>this._hideUI()})}_addActionsView(){this._areActionsInPanel||this._balloon.add({view:this.actionsView,position:this._getBalloonPositionData()})}_addFormView(){if(this._isFormInPanel)return;const t=this.editor.commands.get("link");this.formView.disableCssTransitions(),this._balloon.add({view:this.formView,position:this._getBalloonPositionData()}),this._balloon.visibleView===this.formView&&this.formView.urlInputView.fieldView.select(),this.formView.enableCssTransitions(),this.formView.urlInputView.fieldView.element.value=t.value||""}_closeFormView(){const t=this.editor.commands.get("link");t.restoreManualDecoratorStates(),void 0!==t.value?this._removeFormView():this._hideUI()}_removeFormView(){this._isFormInPanel&&(this.formView.saveButtonView.focus(),this._balloon.remove(this.formView),this.editor.editing.view.focus(),this._hideFakeVisualSelection())}_showUI(t=!1){this._getSelectedLinkElement()?(this._areActionsVisible?this._addFormView():this._addActionsView(),t&&this._balloon.showStack("main")):(this._showFakeVisualSelection(),this._addActionsView(),t&&this._balloon.showStack("main"),this._addFormView()),this._startUpdatingUI()}_hideUI(){if(!this._isUIInPanel)return;const t=this.editor;this.stopListening(t.ui,"update"),this.stopListening(this._balloon,"change:visibleView"),t.editing.view.focus(),this._removeFormView(),this._balloon.remove(this.actionsView),this._hideFakeVisualSelection()}_startUpdatingUI(){const t=this.editor,e=t.editing.view.document;let n=this._getSelectedLinkElement(),o=r();const i=()=>{const t=this._getSelectedLinkElement(),e=r();n&&!t||!n&&e!==o?this._hideUI():this._isUIVisible&&this._balloon.updatePosition(this._getBalloonPositionData()),n=t,o=e};function r(){return e.selection.focus.getAncestors().reverse().find((t=>t.is("element")))}this.listenTo(t.ui,"update",i),this.listenTo(this._balloon,"change:visibleView",i)}get _isFormInPanel(){return this._balloon.hasView(this.formView)}get _areActionsInPanel(){return this._balloon.hasView(this.actionsView)}get _areActionsVisible(){return this._balloon.visibleView===this.actionsView}get _isUIInPanel(){return this._isFormInPanel||this._areActionsInPanel}get _isUIVisible(){return this._balloon.visibleView==this.formView||this._areActionsVisible}_getBalloonPositionData(){const t=this.editor.editing.view,e=this.editor.model,n=t.document;let o=null;if(e.markers.has(BA)){const e=Array.from(this.editor.editing.mapper.markerNameToElements(BA)),n=t.createRange(t.createPositionBefore(e[0]),t.createPositionAfter(e[e.length-1]));o=t.domConverter.viewRangeToDom(n)}else o=()=>{const e=this._getSelectedLinkElement();return e?t.domConverter.mapViewToDom(e):t.domConverter.viewRangeToDom(n.selection.getFirstRange())};return{target:o}}_getSelectedLinkElement(){const t=this.editor.editing.view,e=t.document.selection,n=e.getSelectedElement();if(e.isCollapsed||n&&Xp(n))return zA(e.getFirstPosition());{const n=e.getFirstRange().getTrimmed(),o=zA(n.start),i=zA(n.end);return o&&o==i&&t.createRangeIn(o).getTrimmed().isEqual(n)?o:null}}_showFakeVisualSelection(){const t=this.editor.model;t.change((e=>{const n=t.document.selection.getFirstRange();if(t.markers.has(BA))e.updateMarker(BA,{range:n});else if(n.start.isAtEnd){const o=n.start.getLastMatchingPosition((({item:e})=>!t.schema.isContent(e)),{boundaries:n});e.addMarker(BA,{usingOperation:!1,affectsData:!1,range:e.createRange(o,n.end)})}else e.addMarker(BA,{usingOperation:!1,affectsData:!1,range:n})}))}_hideFakeVisualSelection(){const t=this.editor.model;t.markers.has(BA)&&t.change((t=>{t.removeMarker(BA)}))}}function zA(t){return t.getAncestors().find((t=>{return(e=t).is("attributeElement")&&!!e.getCustomProperty("link");var e}))}const PA=new RegExp("(^|\\s)(((?:(?:(?:https?|ftp):)?\\/\\/)(?:\\S+(?::\\S*)?@)?(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(((?!www\\.)|(www\\.))(?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.)+(?:[a-z\\u00a1-\\uffff]{2,63})))(?::\\d{2,5})?(?:[/?#]\\S*)?)|((www.|(\\S+@))((?![-_])(?:[-_a-z0-9\\u00a1-\\uffff]{1,63}\\.))+(?:[a-z\\u00a1-\\uffff]{2,63})))$","i");class LA extends V{static get requires(){return[Kg]}static get pluginName(){return"AutoLink"}init(){const t=this.editor.model.document.selection;t.on("change:range",(()=>{this.isEnabled=!t.anchor.parent.is("element","codeBlock")})),this._enableTypingHandling()}afterInit(){this._enableEnterHandling(),this._enableShiftEnterHandling()}_enableTypingHandling(){const t=this.editor,e=new Jg(t.model,(t=>{if(!function(t){return t.length>4&&" "===t[t.length-1]&&" "!==t[t.length-2]}(t))return;const e=OA(t.substr(0,t.length-1));return e?{url:e}:void 0}));e.on("matched:data",((e,n)=>{const{batch:o,range:i,url:r}=n;if(!o.isTyping)return;const s=i.end.getShiftedBy(-1),a=s.getShiftedBy(-r.length),l=t.model.createRange(a,s);this._applyAutoLink(r,l)})),e.bind("isEnabled").to(this)}_enableEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("enter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition();if(!t.parent.previousSibling)return;const n=e.createRangeIn(t.parent.previousSibling);this._checkAndApplyAutoLinkOnRange(n)}))}_enableShiftEnterHandling(){const t=this.editor,e=t.model,n=t.commands.get("shiftEnter");n&&n.on("execute",(()=>{const t=e.document.selection.getFirstPosition(),n=e.createRange(e.createPositionAt(t.parent,0),t.getShiftedBy(-1));this._checkAndApplyAutoLinkOnRange(n)}))}_checkAndApplyAutoLinkOnRange(t){const e=this.editor.model,{text:n,range:o}=Qg(t,e),i=OA(n);if(i){const t=e.createRange(o.end.getShiftedBy(-i.length),o.end);this._applyAutoLink(i,t)}}_applyAutoLink(t,e){const n=this.editor.model,o=this.editor.plugins.get("Delete");this.isEnabled&&function(t,e){return e.schema.checkAttributeInSelection(e.createSelection(t),"linkHref")}(e,n)&&n.enqueueChange((i=>{const r=this.editor.config.get("link.defaultProtocol"),s=hA(t,r);i.setAttribute("linkHref",s,e),n.enqueueChange((()=>{o.requestUndoOnBackspace()}))}))}}function OA(t){const e=PA.exec(t);return e?e[2]:null}class RA extends V{static get requires(){return["ImageEditing","ImageUtils",CA]}static get pluginName(){return"LinkImageEditing"}init(){const t=this.editor,e=t.model.schema;t.plugins.has("ImageBlockEditing")&&e.extend("imageBlock",{allowAttributes:["linkHref"]}),t.conversion.for("upcast").add(function(t){const e=t.plugins.has("ImageInlineEditing"),n=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,o,i)=>{const r=o.viewItem,s=n.findViewImgElement(r);if(!s)return;const a=s.findAncestor((t=>n.isBlockImageView(t)));if(e&&!a)return;const l={attributes:["href"]};if(!i.consumable.consume(r,l))return;const c=r.getAttribute("href");if(!c)return;let d=o.modelCursor.parent;if(!d.is("element","imageBlock")){const t=i.convertItem(s,o.modelCursor);o.modelRange=t.modelRange,o.modelCursor=t.modelCursor,d=o.modelCursor.nodeBefore}d&&d.is("element","imageBlock")&&i.writer.setAttribute("linkHref",c,d)}),{priority:"high"})}}(t)),t.conversion.for("downcast").add(function(t){const e=t.plugins.get("ImageUtils");return t=>{t.on("attribute:linkHref:imageBlock",((t,n,o)=>{if(!o.consumable.consume(n.item,t.name))return;const i=o.mapper.toViewElement(n.item),r=o.writer,s=Array.from(i.getChildren()).find((t=>"a"===t.name)),a=e.findViewImgElement(i),l=a.parent.is("element","picture")?a.parent:a;if(s)n.attributeNewValue?r.setAttribute("href",n.attributeNewValue,s):(r.move(r.createRangeOn(l),r.createPositionAt(i,0)),r.remove(s));else{const t=r.createContainerElement("a",{href:n.attributeNewValue});r.insert(r.createPositionAt(i,0),t),r.move(r.createRangeOn(l),r.createPositionAt(t,0))}}),{priority:"high"})}}(t)),this._enableAutomaticDecorators(),this._enableManualDecorators()}_enableAutomaticDecorators(){const t=this.editor,e=t.commands.get("link").automaticDecorators;e.length&&t.conversion.for("downcast").add(e.getDispatcherForLinkedImage())}_enableManualDecorators(){const t=this.editor,e=t.commands.get("link");for(const n of e.manualDecorators)t.plugins.has("ImageBlockEditing")&&t.model.schema.extend("imageBlock",{allowAttributes:n.id}),t.plugins.has("ImageInlineEditing")&&t.model.schema.extend("imageInline",{allowAttributes:n.id}),t.conversion.for("downcast").add(jA(n)),t.conversion.for("upcast").add(VA(t,n))}}function jA(t){return e=>{e.on(`attribute:${t.id}:imageBlock`,((e,n,o)=>{const i=o.mapper.toViewElement(n.item),r=Array.from(i.getChildren()).find((t=>"a"===t.name));if(r){for(const[e,n]of Mo(t.attributes))o.writer.setAttribute(e,n,r);t.classes&&o.writer.addClass(t.classes,r);for(const e in t.styles)o.writer.setStyle(e,t.styles[e],r)}}))}}function VA(t,e){const n=t.plugins.has("ImageInlineEditing"),o=t.plugins.get("ImageUtils");return t=>{t.on("element:a",((t,i,r)=>{const s=i.viewItem,a=o.findViewImgElement(s);if(!a)return;const l=a.findAncestor((t=>o.isBlockImageView(t)));if(n&&!l)return;const c=new Bo(e._createPattern()).match(s);if(!c)return;if(!r.consumable.consume(s,c.match))return;const d=i.modelCursor.nodeBefore||i.modelCursor.parent;r.writer.setAttribute(e.id,!0,d)}),{priority:"high"})}}class FA extends V{static get requires(){return[CA,NA,"ImageBlockEditing"]}static get pluginName(){return"LinkImageUI"}init(){const t=this.editor,e=t.editing.view.document;this.listenTo(e,"click",((e,n)=>{this._isSelectedLinkedImage(t.model.document.selection)&&(n.preventDefault(),e.stop())}),{priority:"high"}),this._createToolbarLinkImageButton()}_createToolbarLinkImageButton(){const t=this.editor,e=t.t;t.ui.componentFactory.add("linkImage",(n=>{const o=new Su(n),i=t.plugins.get("LinkUI"),r=t.commands.get("link");return o.set({isEnabled:!0,label:e("Link image"),icon:MA,keystroke:lA,tooltip:!0,isToggleable:!0}),o.bind("isEnabled").to(r,"isEnabled"),o.bind("isOn").to(r,"value",(t=>!!t)),this.listenTo(o,"execute",(()=>{this._isSelectedLinkedImage(t.model.document.selection)?i._addActionsView():i._showUI(!0)})),o}))}_isSelectedLinkedImage(t){const e=t.getSelectedElement();return this.editor.plugins.get("ImageUtils").isImage(e)&&e.hasAttribute("linkHref")}}var HA=n(3858),UA={attributes:{"data-cke":!0}};UA.setAttributes=is(),UA.insert=ns().bind(null,"head"),UA.domAPI=ts(),UA.insertStyleElement=ss();Jr()(HA.Z,UA);HA.Z&&HA.Z.locals&&HA.Z.locals;class qA extends H{constructor(t,e){super(t),this.type=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){const e=this.editor.model,n=e.document,o=Array.from(n.selection.getSelectedBlocks()).filter((t=>WA(t,e.schema))),i=void 0!==t.forceValue?!t.forceValue:this.value;e.change((t=>{if(i){let e=o[o.length-1].nextSibling,n=Number.POSITIVE_INFINITY,i=[];for(;e&&"listItem"==e.name&&0!==e.getAttribute("listIndent");){const t=e.getAttribute("listIndent");t=n;)r>i.getAttribute("listIndent")&&(r=i.getAttribute("listIndent")),i.getAttribute("listIndent")==r&&t[e?"unshift":"push"](i),i=i[e?"previousSibling":"nextSibling"]}}function WA(t,e){return e.checkChild(t.parent,"listItem")&&!e.isObject(t)}class ZA extends H{constructor(t,e){super(t),this._indentBy="forward"==e?1:-1}refresh(){this.isEnabled=this._checkEnabled()}execute(){const t=this.editor.model,e=t.document;let n=Array.from(e.selection.getSelectedBlocks());t.change((t=>{const e=n[n.length-1];let o=e.nextSibling;for(;o&&"listItem"==o.name&&o.getAttribute("listIndent")>e.getAttribute("listIndent");)n.push(o),o=o.nextSibling;this._indentBy<0&&(n=n.reverse());for(const e of n){const n=e.getAttribute("listIndent")+this._indentBy;n<0?t.rename(e,"paragraph"):t.setAttribute("listIndent",n,e)}this.fire("_executeCleanup",n)}))}_checkEnabled(){const t=Ba(this.editor.model.document.selection.getSelectedBlocks());if(!t||!t.is("element","listItem"))return!1;if(this._indentBy>0){const e=t.getAttribute("listIndent"),n=t.getAttribute("listType");let o=t.previousSibling;for(;o&&o.is("element","listItem")&&o.getAttribute("listIndent")>=e;){if(o.getAttribute("listIndent")==e)return o.getAttribute("listType")==n;o=o.previousSibling}return!1}return!0}}function YA(t,e){const n=e.mapper,o=e.writer,i="numbered"==t.getAttribute("listType")?"ol":"ul",r=function(t){const e=t.createContainerElement("li");return e.getFillerOffset=iC,e}(o),s=o.createContainerElement(i,null);return o.insert(o.createPositionAt(s,0),r),n.bindElements(t,r),r}function KA(t,e,n,o){const i=e.parent,r=n.mapper,s=n.writer;let a=r.toViewPosition(o.createPositionBefore(t));const l=JA(t.previousSibling,{sameIndent:!0,smallerIndent:!0,listIndent:t.getAttribute("listIndent")}),c=t.previousSibling;if(l&&l.getAttribute("listIndent")==t.getAttribute("listIndent")){const t=r.toViewElement(l);a=s.breakContainer(s.createPositionAfter(t))}else if(c&&"listItem"==c.name){a=r.toViewPosition(o.createPositionAt(c,"end"));const t=r.findMappedViewAncestor(a),e=function(t){for(const e of t.getChildren())if("ul"==e.name||"ol"==e.name)return e;return null}(t);a=e?s.createPositionBefore(e):s.createPositionAt(t,"end")}else a=r.toViewPosition(o.createPositionBefore(t));if(a=QA(a),s.insert(a,i),c&&"listItem"==c.name){const t=r.toViewElement(c),n=s.createRange(s.createPositionAt(t,0),a).getWalker({ignoreElementEnd:!0});for(const t of n)if(t.item.is("element","li")){const o=s.breakContainer(s.createPositionBefore(t.item)),i=t.item.parent,r=s.createPositionAt(e,"end");$A(s,r.nodeBefore,r.nodeAfter),s.move(s.createRangeOn(i),r),n.position=o}}else{const n=i.nextSibling;if(n&&(n.is("element","ul")||n.is("element","ol"))){let o=null;for(const e of n.getChildren()){const n=r.toModelElement(e);if(!(n&&n.getAttribute("listIndent")>t.getAttribute("listIndent")))break;o=e}o&&(s.breakContainer(s.createPositionAfter(o)),s.move(s.createRangeOn(o.parent),s.createPositionAt(e,"end")))}}$A(s,i,i.nextSibling),$A(s,i.previousSibling,i)}function $A(t,e,n){return!e||!n||"ul"!=e.name&&"ol"!=e.name||e.name!=n.name||e.getAttribute("class")!==n.getAttribute("class")?null:t.mergeContainers(t.createPositionAfter(e))}function QA(t){return t.getLastMatchingPosition((t=>t.item.is("uiElement")))}function JA(t,e){const n=!!e.sameIndent,o=!!e.smallerIndent,i=e.listIndent;let r=t;for(;r&&"listItem"==r.name;){const t=r.getAttribute("listIndent");if(n&&i==t||o&&i>t)return r;r="forward"===e.direction?r.nextSibling:r.previousSibling}return null}function XA(t,e,n,o){t.ui.componentFactory.add(e,(i=>{const r=t.commands.get(e),s=new Su(i);return s.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),s.bind("isOn","isEnabled").to(r,"value","isEnabled"),s.on("execute",(()=>{t.execute(e),t.editing.view.focus()})),s}))}function tC(t,e){const n=[],o=t.parent,i={ignoreElementEnd:!0,startPosition:t,shallow:!0,direction:e},r=o.getAttribute("listIndent"),s=[...new Xa(i)].filter((t=>t.item.is("element"))).map((t=>t.item));for(const t of s){if(!t.is("element","listItem"))break;if(t.getAttribute("listIndent")r)){if(t.getAttribute("listType")!==o.getAttribute("listType"))break;if(t.getAttribute("listStyle")!==o.getAttribute("listStyle"))break;if(t.getAttribute("listReversed")!==o.getAttribute("listReversed"))break;if(t.getAttribute("listStart")!==o.getAttribute("listStart"))break;"backward"===e?n.unshift(t):n.push(t)}}return n}function eC(t){let e=[...t.document.selection.getSelectedBlocks()].filter((t=>t.is("element","listItem"))).map((e=>{const n=t.change((t=>t.createPositionAt(e,0)));return[...tC(n,"backward"),...tC(n,"forward")]})).flat();return e=[...new Set(e)],e}const nC=["disc","circle","square"],oC=["decimal","decimal-leading-zero","lower-roman","upper-roman","lower-latin","upper-latin"];function iC(){const t=!this.isEmpty&&("ul"==this.getChild(0).name||"ol"==this.getChild(0).name);return this.isEmpty||t?0:zi.call(this)}function rC(t){return(e,n,o)=>{const i=o.consumable;if(!i.test(n.item,"insert")||!i.test(n.item,"attribute:listType")||!i.test(n.item,"attribute:listIndent"))return;i.consume(n.item,"insert"),i.consume(n.item,"attribute:listType"),i.consume(n.item,"attribute:listIndent");const r=n.item;KA(r,YA(r,o),o,t)}}function sC(t,e,n){if(!n.consumable.test(e.item,t.name))return;const o=n.mapper.toViewElement(e.item),i=n.writer;i.breakContainer(i.createPositionBefore(o)),i.breakContainer(i.createPositionAfter(o));const r=o.parent,s="numbered"==e.attributeNewValue?"ol":"ul";i.rename(s,r)}function aC(t,e,n){n.consumable.consume(e.item,t.name);const o=n.mapper.toViewElement(e.item).parent,i=n.writer;$A(i,o,o.nextSibling),$A(i,o.previousSibling,o)}function lC(t,e,n){if(n.consumable.test(e.item,t.name)&&"listItem"!=e.item.name){let t=n.mapper.toViewPosition(e.range.start);const o=n.writer,i=[];for(;("ul"==t.parent.name||"ol"==t.parent.name)&&(t=o.breakContainer(t),"li"==t.parent.name);){const e=t,n=o.createPositionAt(t.parent,"end");if(!e.isEqual(n)){const t=o.remove(o.createRange(e,n));i.push(t)}t=o.createPositionAfter(t.parent)}if(i.length>0){for(let e=0;e0){const e=$A(o,n,n.nextSibling);e&&e.parent==n&&t.offset--}}$A(o,t.nodeBefore,t.nodeAfter)}}}function cC(t,e,n){const o=n.mapper.toViewPosition(e.position),i=o.nodeBefore,r=o.nodeAfter;$A(n.writer,i,r)}function dC(t,e,n){if(n.consumable.consume(e.viewItem,{name:!0})){const t=n.writer,o=t.createElement("listItem"),i=function(t){let e=0,n=t.parent;for(;n;){if(n.is("element","li"))e++;else{const t=n.previousSibling;t&&t.is("element","li")&&e++}n=n.parent}return e}(e.viewItem);t.setAttribute("listIndent",i,o);const r=e.viewItem.parent&&"ol"==e.viewItem.parent.name?"numbered":"bulleted";if(t.setAttribute("listType",r,o),!n.safeInsert(o,e.modelCursor))return;const s=function(t,e,n){const{writer:o,schema:i}=n;let r=o.createPositionAfter(t);for(const s of e)if("ul"==s.name||"ol"==s.name)r=n.convertItem(s,r).modelCursor;else{const e=n.convertItem(s,o.createPositionAt(t,"end")),a=e.modelRange.start.nodeAfter;a&&a.is("element")&&!i.checkChild(t,a.name)&&(t=e.modelCursor.parent.is("element","listItem")?e.modelCursor.parent:pC(e.modelCursor),r=o.createPositionAfter(t))}return r}(o,e.viewItem.getChildren(),n);e.modelRange=t.createRange(e.modelCursor,s),n.updateConversionResult(o,e)}}function uC(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){const t=Array.from(e.viewItem.getChildren());for(const e of t){!(e.is("element","li")||bC(e))&&e._remove()}}}function hC(t,e,n){if(n.consumable.test(e.viewItem,{name:!0})){if(0===e.viewItem.childCount)return;const t=[...e.viewItem.getChildren()];let n=!1;for(const e of t)n&&!bC(e)&&e._remove(),bC(e)&&(n=!0)}}function mC(t){return(e,n)=>{if(n.isPhantom)return;const o=n.modelPosition.nodeBefore;if(o&&o.is("element","listItem")){const e=n.mapper.toViewElement(o),i=e.getAncestors().find(bC),r=t.createPositionAt(e,0).getWalker();for(const t of r){if("elementStart"==t.type&&t.item.is("element","li")){n.viewPosition=t.previousPosition;break}if("elementEnd"==t.type&&t.item==i){n.viewPosition=t.nextPosition;break}}}}}function gC(t,[e,n]){let o,i=e.is("documentFragment")?e.getChild(0):e;if(o=n?this.createSelection(n):this.document.selection,i&&i.is("element","listItem")){const t=o.getFirstPosition();let e=null;if(t.parent.is("element","listItem")?e=t.parent:t.nodeBefore&&t.nodeBefore.is("element","listItem")&&(e=t.nodeBefore),e){const t=e.getAttribute("listIndent");if(t>0)for(;i&&i.is("element","listItem");)i._setAttribute("listIndent",i.getAttribute("listIndent")+t),i=i.nextSibling}}}function pC(t){const e=new Xa({startPosition:t});let n;do{n=e.next()}while(!n.value.item.is("element","listItem"));return n.value.item}function fC(t,e,n,o,i,r){const s=JA(e.nodeBefore,{sameIndent:!0,smallerIndent:!0,listIndent:t,foo:"b"}),a=i.mapper,l=i.writer,c=s?s.getAttribute("listIndent"):null;let d;if(s)if(c==t){const t=a.toViewElement(s).parent;d=l.createPositionAfter(t)}else{const t=r.createPositionAt(s,"end");d=a.toViewPosition(t)}else d=n;d=QA(d);for(const t of[...o.getChildren()])bC(t)&&(d=l.move(l.createRangeOn(t),d).end,$A(l,t,t.nextSibling),$A(l,t.previousSibling,t))}function bC(t){return t.is("element","ol")||t.is("element","ul")}class kC extends V{static get pluginName(){return"ListEditing"}static get requires(){return[yp,Kg]}init(){const t=this.editor;t.model.schema.register("listItem",{inheritAllFrom:"$block",allowAttributes:["listType","listIndent"]});const e=t.data,n=t.editing;var o;t.model.document.registerPostFixer((e=>function(t,e){const n=t.document.differ.getChanges(),o=new Map;let i=!1;for(const o of n)if("insert"==o.type&&"listItem"==o.name)r(o.position);else if("insert"==o.type&&"listItem"!=o.name){if("$text"!=o.name){const n=o.position.nodeAfter;n.hasAttribute("listIndent")&&(e.removeAttribute("listIndent",n),i=!0),n.hasAttribute("listType")&&(e.removeAttribute("listType",n),i=!0),n.hasAttribute("listStyle")&&(e.removeAttribute("listStyle",n),i=!0),n.hasAttribute("listReversed")&&(e.removeAttribute("listReversed",n),i=!0),n.hasAttribute("listStart")&&(e.removeAttribute("listStart",n),i=!0);for(const e of Array.from(t.createRangeIn(n)).filter((t=>t.item.is("element","listItem"))))r(e.previousPosition)}r(o.position.getShiftedBy(o.length))}else"remove"==o.type&&"listItem"==o.name?r(o.position):("attribute"==o.type&&"listIndent"==o.attributeKey||"attribute"==o.type&&"listType"==o.attributeKey)&&r(o.range.start);for(const t of o.values())s(t),a(t);return i;function r(t){const e=t.nodeBefore;if(e&&e.is("element","listItem")){let t=e;if(o.has(t))return;for(let e=t.previousSibling;e&&e.is("element","listItem");e=t.previousSibling)if(t=e,o.has(t))return;o.set(e,t)}else{const e=t.nodeAfter;e&&e.is("element","listItem")&&o.set(e,e)}}function s(t){let n=0,o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(r>n){let s;null===o?(o=r-n,s=n):(o>r&&(o=r),s=r-o),e.setAttribute("listIndent",s,t),i=!0}else o=null,n=t.getAttribute("listIndent")+1;t=t.nextSibling}}function a(t){let n=[],o=null;for(;t&&t.is("element","listItem");){const r=t.getAttribute("listIndent");if(o&&o.getAttribute("listIndent")>r&&(n=n.slice(0,r+1)),0!=r)if(n[r]){const o=n[r];t.getAttribute("listType")!=o&&(e.setAttribute("listType",o,t),i=!0)}else n[r]=t.getAttribute("listType");o=t,t=t.nextSibling}}}(t.model,e))),n.mapper.registerViewToModelLength("li",wC),e.mapper.registerViewToModelLength("li",wC),n.mapper.on("modelToViewPosition",mC(n.view)),n.mapper.on("viewToModelPosition",(o=t.model,(t,e)=>{const n=e.viewPosition,i=n.parent,r=e.mapper;if("ul"==i.name||"ol"==i.name){if(n.isAtEnd){const t=r.toModelElement(n.nodeBefore),i=r.getModelLength(n.nodeBefore);e.modelPosition=o.createPositionBefore(t).getShiftedBy(i)}else{const t=r.toModelElement(n.nodeAfter);e.modelPosition=o.createPositionBefore(t)}t.stop()}else if("li"==i.name&&n.nodeBefore&&("ul"==n.nodeBefore.name||"ol"==n.nodeBefore.name)){const s=r.toModelElement(i);let a=1,l=n.nodeBefore;for(;l&&bC(l);)a+=r.getModelLength(l),l=l.previousSibling;e.modelPosition=o.createPositionBefore(s).getShiftedBy(a),t.stop()}})),e.mapper.on("modelToViewPosition",mC(n.view)),t.conversion.for("editingDowncast").add((e=>{e.on("insert",lC,{priority:"high"}),e.on("insert:listItem",rC(t.model)),e.on("attribute:listType:listItem",sC,{priority:"high"}),e.on("attribute:listType:listItem",aC,{priority:"low"}),e.on("attribute:listIndent:listItem",function(t){return(e,n,o)=>{if(!o.consumable.consume(n.item,"attribute:listIndent"))return;const i=o.mapper.toViewElement(n.item),r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,l=r.createRangeOn(s);r.remove(l),a&&a.nextSibling&&$A(r,a,a.nextSibling),fC(n.attributeOldValue+1,n.range.start,l.start,i,o,t),KA(n.item,i,o,t);for(const t of n.item.getChildren())o.consumable.consume(t,"insert")}}(t.model)),e.on("remove:listItem",function(t){return(e,n,o)=>{const i=o.mapper.toViewPosition(n.position).getLastMatchingPosition((t=>!t.item.is("element","li"))).nodeAfter,r=o.writer;r.breakContainer(r.createPositionBefore(i)),r.breakContainer(r.createPositionAfter(i));const s=i.parent,a=s.previousSibling,l=r.createRangeOn(s),c=r.remove(l);a&&a.nextSibling&&$A(r,a,a.nextSibling),fC(o.mapper.toModelElement(i).getAttribute("listIndent")+1,n.position,l.start,i,o,t);for(const t of r.createRangeIn(c).getItems())o.mapper.unbindViewElement(t);e.stop()}}(t.model)),e.on("remove",cC,{priority:"low"})})),t.conversion.for("dataDowncast").add((e=>{e.on("insert",lC,{priority:"high"}),e.on("insert:listItem",rC(t.model))})),t.conversion.for("upcast").add((t=>{t.on("element:ul",uC,{priority:"high"}),t.on("element:ol",uC,{priority:"high"}),t.on("element:li",hC,{priority:"high"}),t.on("element:li",dC)})),t.model.on("insertContent",gC,{priority:"high"}),t.commands.add("numberedList",new qA(t,"numbered")),t.commands.add("bulletedList",new qA(t,"bulleted")),t.commands.add("indentList",new ZA(t,"forward")),t.commands.add("outdentList",new ZA(t,"backward"));const i=n.view.document;this.listenTo(i,"enter",((t,e)=>{const n=this.editor.model.document,o=n.selection.getLastPosition().parent;n.selection.isCollapsed&&"listItem"==o.name&&o.isEmpty&&(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"}),this.listenTo(i,"delete",((t,e)=>{if("backward"!==e.direction)return;const n=this.editor.model.document.selection;if(!n.isCollapsed)return;const o=n.getFirstPosition();if(!o.isAtStart)return;const i=o.parent;if("listItem"!==i.name)return;i.previousSibling&&"listItem"===i.previousSibling.name||(this.editor.execute("outdentList"),e.preventDefault(),t.stop())}),{context:"li"}),this.listenTo(t.editing.view.document,"tab",((e,n)=>{const o=n.shiftKey?"outdentList":"indentList";this.editor.commands.get(o).isEnabled&&(t.execute(o),n.stopPropagation(),n.preventDefault(),e.stop())}),{context:"li"})}afterInit(){const t=this.editor.commands,e=t.get("indent"),n=t.get("outdent");e&&e.registerChildCommand(t.get("indentList")),n&&n.registerChildCommand(t.get("outdentList"))}}function wC(t){let e=1;for(const n of t.getChildren())if("ul"==n.name||"ol"==n.name)for(const t of n.getChildren())e+=wC(t);return e}const AC='',CC='';class _C extends V{static get pluginName(){return"ListUI"}init(){const t=this.editor.t;XA(this.editor,"numberedList",t("Numbered List"),AC),XA(this.editor,"bulletedList",t("Bulleted List"),CC)}}class vC extends H{constructor(t,e){super(t),this._defaultType=e}refresh(){this.value=this._getValue(),this.isEnabled=this._checkEnabled()}execute(t={}){this._tryToConvertItemsToList(t);const e=this.editor.model,n=eC(e);n.length&&e.change((e=>{for(const o of n)e.setAttribute("listStyle",t.type||this._defaultType,o)}))}_getValue(){const t=this.editor.model.document.selection.getFirstPosition().parent;return t&&t.is("element","listItem")?t.getAttribute("listStyle"):null}_checkEnabled(){const t=this.editor,e=t.commands.get("numberedList"),n=t.commands.get("bulletedList");return e.isEnabled||n.isEnabled}_tryToConvertItemsToList(t){if(!t.type)return;const e=(n=t.type,nC.includes(n)?"bulleted":oC.includes(n)?"numbered":null);var n;if(!e)return;const o=this.editor,i=e+"List";o.commands.get(i).value||o.execute(i)}}class yC extends H{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute(t={}){const e=this.editor.model,n=eC(e).filter((t=>"numbered"==t.getAttribute("listType")));e.change((e=>{for(const o of n)e.setAttribute("listReversed",!!t.reversed,o)}))}_getValue(){const t=this.editor.model.document.selection.getFirstPosition().parent;return t&&t.is("element","listItem")&&"numbered"==t.getAttribute("listType")?t.getAttribute("listReversed"):null}}class xC extends H{refresh(){const t=this._getValue();this.value=t,this.isEnabled=null!=t}execute(t={}){const e=this.editor.model,n=eC(e).filter((t=>"numbered"==t.getAttribute("listType")));e.change((e=>{for(const o of n)e.setAttribute("listStart",t.startIndex||1,o)}))}_getValue(){const t=this.editor.model.document.selection.getFirstPosition().parent;return t&&t.is("element","listItem")&&"numbered"==t.getAttribute("listType")?t.getAttribute("listStart"):null}}const EC="default";class DC extends V{static get requires(){return[kC]}static get pluginName(){return"ListPropertiesEditing"}constructor(t){super(t),t.config.define("list",{properties:{styles:!0,startIndex:!1,reversed:!1}})}init(){const t=this.editor,e=t.model,n=function(t){const e=[];t.styles&&e.push({attributeName:"listStyle",defaultValue:EC,addCommand(t){t.commands.add("listStyle",new vC(t,EC))},appliesToListItem:()=>!0,setAttributeOnDowncast(t,e,n){e&&e!==EC?t.setStyle("list-style-type",e,n):t.removeStyle("list-style-type",n)},getAttributeOnUpcast:t=>t.getStyle("list-style-type")||EC});t.reversed&&e.push({attributeName:"listReversed",defaultValue:!1,addCommand(t){t.commands.add("listReversed",new yC(t))},appliesToListItem:t=>"numbered"==t.getAttribute("listType"),setAttributeOnDowncast(t,e,n){e?t.setAttribute("reversed","reversed",n):t.removeAttribute("reversed",n)},getAttributeOnUpcast:t=>t.hasAttribute("reversed")});t.startIndex&&e.push({attributeName:"listStart",defaultValue:1,addCommand(t){t.commands.add("listStart",new xC(t))},appliesToListItem:t=>"numbered"==t.getAttribute("listType"),setAttributeOnDowncast(t,e,n){1!=e?t.setAttribute("start",e,n):t.removeAttribute("start",n)},getAttributeOnUpcast:t=>t.getAttribute("start")||1});return e}(t.config.get("list.properties"));e.schema.extend("listItem",{allowAttributes:n.map((t=>t.attributeName))});for(const e of n)e.addCommand(t);var o;this.listenTo(t.commands.get("indentList"),"_executeCleanup",function(t,e){return(n,o)=>{const i=o[0],r=i.getAttribute("listIndent"),s=o.filter((t=>t.getAttribute("listIndent")===r));let a=null;i.previousSibling.getAttribute("listIndent")+1!==r&&(a=JA(i.previousSibling,{sameIndent:!0,direction:"backward",listIndent:r})),t.model.change((t=>{for(const n of s)for(const o of e)if(o.appliesToListItem(n)){const e=null==a?o.defaultValue:a.getAttribute(o.attributeName);t.setAttribute(o.attributeName,e,n)}}))}}(t,n)),this.listenTo(t.commands.get("outdentList"),"_executeCleanup",function(t,e){return(n,o)=>{if(!(o=o.reverse().filter((t=>t.is("element","listItem")))).length)return;const i=o[0].getAttribute("listIndent"),r=o[0].getAttribute("listType");let s=o[0].previousSibling;if(s.is("element","listItem"))for(;s.getAttribute("listIndent")!==i;)s=s.previousSibling;else s=null;s||(s=o[o.length-1].nextSibling),s&&s.is("element","listItem")&&s.getAttribute("listType")===r&&t.model.change((t=>{const n=o.filter((t=>t.getAttribute("listIndent")===i));for(const o of n)for(const n of e)if(n.appliesToListItem(o)){const e=n.attributeName,i=s.getAttribute(e);t.setAttribute(e,i,o)}}))}}(t,n)),this.listenTo(t.commands.get("bulletedList"),"_executeCleanup",TC(t)),this.listenTo(t.commands.get("numberedList"),"_executeCleanup",TC(t)),e.document.registerPostFixer(function(t,e){return n=>{let o=!1;const i=MC(t.model.document.differ.getChanges()).filter((t=>"todo"!==t.getAttribute("listType")));if(!i.length)return o;let r=i[i.length-1].nextSibling;if((!r||!r.is("element","listItem"))&&(r=i[0].previousSibling,r)){const t=i[0].getAttribute("listIndent");for(;r.is("element","listItem")&&r.getAttribute("listIndent")!==t&&(r=r.previousSibling,r););}for(const t of e){const e=t.attributeName;for(const s of i)if(t.appliesToListItem(s))if(s.hasAttribute(e)){const i=s.previousSibling;IC(i,s,t.attributeName)&&(n.setAttribute(e,i.getAttribute(e),s),o=!0)}else SC(r,s,t)?n.setAttribute(e,r.getAttribute(e),s):n.setAttribute(e,t.defaultValue,s),o=!0;else n.removeAttribute(e,s)}return o}}(t,n)),t.conversion.for("upcast").add((o=n,t=>{t.on("element:li",((t,e,n)=>{const i=e.viewItem.parent;if(!i)return;const r=e.modelRange.start.nodeAfter||e.modelRange.end.nodeBefore;for(const t of o)if(t.appliesToListItem(r)){const e=t.getAttributeOnUpcast(i);n.writer.setAttribute(t.attributeName,e,r)}}),{priority:"low"})})),t.conversion.for("downcast").add(function(t){return n=>{for(const o of t)n.on(`attribute:${o.attributeName}:listItem`,((t,n,i)=>{const r=i.writer,s=n.item,a=JA(s.previousSibling,{sameIndent:!0,listIndent:s.getAttribute("listIndent"),direction:"backward"}),l=i.mapper.toViewElement(s);e(s,a)||r.breakContainer(r.createPositionBefore(l)),o.setAttributeOnDowncast(r,n.attributeNewValue,l.parent)}),{priority:"low"})};function e(t,e){return e&&t.getAttribute("listType")===e.getAttribute("listType")&&t.getAttribute("listIndent")===e.getAttribute("listIndent")&&t.getAttribute("listStyle")===e.getAttribute("listStyle")&&t.getAttribute("listReversed")===e.getAttribute("listReversed")&&t.getAttribute("listStart")===e.getAttribute("listStart")}}(n)),this._mergeListAttributesWhileMergingLists(n)}afterInit(){const t=this.editor;t.commands.get("todoList")&&t.model.document.registerPostFixer(function(t){return e=>{const n=MC(t.model.document.differ.getChanges()).filter((t=>"todo"===t.getAttribute("listType")&&(t.hasAttribute("listStyle")||t.hasAttribute("listReversed")||t.hasAttribute("listStart"))));if(!n.length)return!1;for(const t of n)e.removeAttribute("listStyle",t),e.removeAttribute("listReversed",t),e.removeAttribute("listStart",t);return!0}}(t))}_mergeListAttributesWhileMergingLists(t){const e=this.editor.model;let n;this.listenTo(e,"deleteContent",((t,[e])=>{const o=e.getFirstPosition(),i=e.getLastPosition();if(o.parent===i.parent)return;if(!o.parent.is("element","listItem"))return;const r=i.parent.nextSibling;if(!r||!r.is("element","listItem"))return;const s=JA(o.parent,{sameIndent:!0,listIndent:r.getAttribute("listIndent")});s&&s.getAttribute("listType")===r.getAttribute("listType")&&(n=s)}),{priority:"high"}),this.listenTo(e,"deleteContent",(()=>{n&&(e.change((e=>{const o=JA(n.nextSibling,{sameIndent:!0,listIndent:n.getAttribute("listIndent"),direction:"forward"});if(!o)return void(n=null);const i=[o,...tC(e.createPositionAt(o,0),"forward")];for(const o of i)for(const i of t)if(i.appliesToListItem(o)){const t=i.attributeName,r=n.getAttribute(t);e.setAttribute(t,r,o)}})),n=null)}),{priority:"low"})}}function SC(t,e,n){if(!t)return!1;const o=t.getAttribute(n.attributeName);return!!o&&(o!=n.defaultValue&&t.getAttribute("listType")===e.getAttribute("listType"))}function IC(t,e,n){if(!t||!t.is("element","listItem"))return!1;if(e.getAttribute("listType")!==t.getAttribute("listType"))return!1;const o=t.getAttribute("listIndent");if(o<1||o!==e.getAttribute("listIndent"))return!1;const i=t.getAttribute(n);return!(!i||i===e.getAttribute(n))}function TC(t){return(e,n)=>{n=n.filter((t=>t.is("element","listItem"))),t.model.change((t=>{for(const e of n)t.removeAttribute("listStyle",e)}))}}function MC(t){const e=[];for(const n of t){const t=BC(n);t&&t.is("element","listItem")&&e.push(t)}return e}function BC(t){return"attribute"===t.type?t.range.start.nodeAfter:"insert"===t.type?t.position.nodeAfter:null}var NC=n(3195),zC={attributes:{"data-cke":!0}};zC.setAttributes=is(),zC.insert=ns().bind(null,"head"),zC.domAPI=ts(),zC.insertStyleElement=ss();Jr()(NC.Z,zC);NC.Z&&NC.Z.locals&&NC.Z.locals;class PC extends Jd{constructor(t,e){super(t);const n=this.bindTemplate;this.set("isCollapsed",!1),this.set("label",""),this.buttonView=this._createButtonView(),this.children=this.createCollection(),this.set("_collapsibleAriaLabelUid"),e&&this.children.addMany(e),this.setTemplate({tag:"div",attributes:{class:["ck","ck-collapsible",n.if("isCollapsed","ck-collapsible_collapsed")]},children:[this.buttonView,{tag:"div",attributes:{class:["ck","ck-collapsible__children"],role:"region",hidden:n.if("isCollapsed","hidden"),"aria-labelledby":n.to("_collapsibleAriaLabelUid")},children:this.children}]})}render(){super.render(),this._collapsibleAriaLabelUid=this.buttonView.labelView.element.id}_createButtonView(){const t=new Su(this.locale),e=t.bindTemplate;return t.set({withText:!0,icon:Hu}),t.extendTemplate({attributes:{"aria-expanded":e.to("isOn",(t=>String(t)))}}),t.bind("label").to(this),t.bind("isOn").to(this,"isCollapsed",(t=>!t)),t.on("execute",(()=>{this.isCollapsed=!this.isCollapsed})),t}}var LC=n(7133),OC={attributes:{"data-cke":!0}};OC.setAttributes=is(),OC.insert=ns().bind(null,"head"),OC.domAPI=ts(),OC.insertStyleElement=ss();Jr()(LC.Z,OC);LC.Z&&LC.Z.locals&&LC.Z.locals;class RC extends Jd{constructor(t,{enabledProperties:e,styleButtonViews:n,styleGridAriaLabel:o}){super(t);const i=["ck","ck-list-properties"];this.children=this.createCollection(),this.stylesView=null,this.additionalPropertiesCollapsibleView=null,this.startIndexFieldView=null,this.reversedSwitchButtonView=null,this.focusTracker=new za,this.keystrokes=new Pa,this.focusables=new Kd,this.focusCycler=new Ou({focusables:this.focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),e.styles?(this.stylesView=this._createStylesView(n,o),this.children.add(this.stylesView)):i.push("ck-list-properties_without-styles"),(e.startIndex||e.reversed)&&(this._addNumberedListPropertyViews(e,n),i.push("ck-list-properties_with-numbered-properties")),this.setTemplate({tag:"div",attributes:{class:i},children:this.children})}render(){if(super.render(),this.stylesView){for(const t of this.stylesView.children)this.focusables.add(t),this.focusTracker.add(t.element);(this.startIndexFieldView||this.reversedSwitchButtonView)&&(this.focusables.add(this.children.last.buttonView),this.focusTracker.add(this.children.last.buttonView.element))}if(this.startIndexFieldView){this.focusables.add(this.startIndexFieldView),this.focusTracker.add(this.startIndexFieldView.element),this.listenTo(this.startIndexFieldView.element,"selectstart",((t,e)=>{e.stopPropagation()}),{priority:"high"});const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t)}this.reversedSwitchButtonView&&(this.focusables.add(this.reversedSwitchButtonView),this.focusTracker.add(this.reversedSwitchButtonView.element)),this.keystrokes.listenTo(this.element)}focus(){this.focusCycler.focusFirst()}focusLast(){this.focusCycler.focusLast()}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}_createStylesView(t,e){const n=new Jd(this.locale);return n.children=n.createCollection(this.locale),n.children.addMany(t),n.setTemplate({tag:"div",attributes:{"aria-label":e,class:["ck","ck-list-styles-list"]},children:n.children}),n.children.delegate("execute").to(this),n}_addNumberedListPropertyViews(t){const e=this.locale.t,n=[];t.startIndex&&(this.startIndexFieldView=this._createStartIndexField(),n.push(this.startIndexFieldView)),t.reversed&&(this.reversedSwitchButtonView=this._createReversedSwitchButton(),n.push(this.reversedSwitchButtonView)),t.styles?(this.additionalPropertiesCollapsibleView=new PC(this.locale,n),this.additionalPropertiesCollapsibleView.set({label:e("List properties"),isCollapsed:!0}),this.additionalPropertiesCollapsibleView.buttonView.bind("isEnabled").toMany(n,"isEnabled",((...t)=>t.some((t=>t)))),this.additionalPropertiesCollapsibleView.buttonView.on("change:isEnabled",((t,e,n)=>{n||(this.additionalPropertiesCollapsibleView.isCollapsed=!0)})),this.children.add(this.additionalPropertiesCollapsibleView)):this.children.addMany(n)}_createStartIndexField(){const t=this.locale.t,e=new Fh(this.locale,Uh);return e.set({label:t("Start at"),class:"ck-numbered-list-properties__start-index"}),e.fieldView.set({min:1,step:1,value:1,inputMode:"numeric"}),e.fieldView.on("input",(()=>{const n=e.fieldView.element,o=n.valueAsNumber;Number.isNaN(o)||(n.checkValidity()?this.fire("listStart",{startIndex:o}):e.errorText=t("Start index must be greater than 0."))})),e}_createReversedSwitchButton(){const t=this.locale.t,e=new Mu(this.locale);return e.set({withText:!0,label:t("Reversed order"),class:"ck-numbered-list-properties__reversed-order"}),e.delegate("execute").to(this,"listReversed"),e}}var jC=n(4553),VC={attributes:{"data-cke":!0}};VC.setAttributes=is(),VC.insert=ns().bind(null,"head"),VC.domAPI=ts(),VC.insertStyleElement=ss();Jr()(jC.Z,VC);jC.Z&&jC.Z.locals&&jC.Z.locals;class FC extends V{static get pluginName(){return"ListPropertiesUI"}init(){const t=this.editor,e=t.locale.t,n=t.config.get("list.properties");n.styles&&t.ui.componentFactory.add("bulletedList",HC({editor:t,parentCommandName:"bulletedList",buttonLabel:e("Bulleted List"),buttonIcon:CC,styleGridAriaLabel:e("Bulleted list styles toolbar"),styleDefinitions:[{label:e("Toggle the disc list style"),tooltip:e("Disc"),type:"disc",icon:''},{label:e("Toggle the circle list style"),tooltip:e("Circle"),type:"circle",icon:''},{label:e("Toggle the square list style"),tooltip:e("Square"),type:"square",icon:''}]})),(n.styles||n.startIndex||n.reversed)&&t.ui.componentFactory.add("numberedList",HC({editor:t,parentCommandName:"numberedList",buttonLabel:e("Numbered List"),buttonIcon:AC,styleGridAriaLabel:e("Numbered list styles toolbar"),styleDefinitions:[{label:e("Toggle the decimal list style"),tooltip:e("Decimal"),type:"decimal",icon:''},{label:e("Toggle the decimal with leading zero list style"),tooltip:e("Decimal with leading zero"),type:"decimal-leading-zero",icon:''},{label:e("Toggle the lower–roman list style"),tooltip:e("Lower–roman"),type:"lower-roman",icon:''},{label:e("Toggle the upper–roman list style"),tooltip:e("Upper-roman"),type:"upper-roman",icon:''},{label:e("Toggle the lower–latin list style"),tooltip:e("Lower-latin"),type:"lower-latin",icon:''},{label:e("Toggle the upper–latin list style"),tooltip:e("Upper-latin"),type:"upper-latin",icon:''}]}))}}function HC({editor:t,parentCommandName:e,buttonLabel:n,buttonIcon:o,styleGridAriaLabel:i,styleDefinitions:r}){const s=t.commands.get(e);return a=>{const l=kh(a,Wu),c=l.buttonView;l.bind("isEnabled").to(s),l.class="ck-list-styles-dropdown",c.on("execute",(()=>{t.execute(e),t.editing.view.focus()})),c.set({label:n,icon:o,tooltip:!0,isToggleable:!0}),c.bind("isOn").to(s,"value",(t=>!!t));const d=function({editor:t,dropdownView:e,parentCommandName:n,styleDefinitions:o,styleGridAriaLabel:i}){const r=t.locale,s=t.config.get("list.properties");let a;"numberedList"!=n&&(s.startIndex=!1,s.reversed=!1);if(s.styles){const e=t.commands.get("listStyle"),i=function({editor:t,listStyleCommand:e,parentCommandName:n}){const o=t.locale,i=t.commands.get(n);return({label:n,type:r,icon:s,tooltip:a})=>{const l=new Su(o);return l.set({label:n,icon:s,tooltip:a}),e.on("change:value",(()=>{l.isOn=e.value===r})),l.on("execute",(()=>{i.value?e.value!==r?t.execute("listStyle",{type:r}):t.execute("listStyle",{type:e._defaultType}):t.model.change((()=>{t.execute("listStyle",{type:r})}))})),l}}({editor:t,parentCommandName:n,listStyleCommand:e}),r="function"==typeof e.isStyleTypeSupported?t=>e.isStyleTypeSupported(t.type):()=>!0;a=o.filter(r).map(i)}const l=new RC(r,{styleGridAriaLabel:i,enabledProperties:s,styleButtonViews:a});if(s.startIndex){const e=t.commands.get("listStart");l.startIndexFieldView.bind("isEnabled").to(e),l.startIndexFieldView.fieldView.bind("value").to(e),l.on("listStart",((e,n)=>t.execute("listStart",n)))}if(s.reversed){const e=t.commands.get("listReversed");l.reversedSwitchButtonView.bind("isEnabled").to(e),l.reversedSwitchButtonView.bind("isOn").to(e,"value"),l.on("listReversed",(()=>{const n=e.value;t.execute("listReversed",{reversed:!n})}))}return l.delegate("execute").to(e),l}({editor:t,dropdownView:l,parentCommandName:e,styleGridAriaLabel:i,styleDefinitions:r});return l.panelView.children.add(d),Ch(l,(()=>d.stylesView.children.find((t=>t.isOn)))),l.on("execute",(()=>{t.editing.view.focus()})),l}}function UC(t,e){return t=>{t.on("attribute:url:media",n)};function n(n,o,i){if(!i.consumable.consume(o.item,n.name))return;const r=o.attributeNewValue,s=i.writer,a=i.mapper.toViewElement(o.item),l=[...a.getChildren()].find((t=>t.getCustomProperty("media-content")));s.remove(l);const c=t.getMediaViewElement(s,r,e);s.insert(s.createPositionAt(a,0),c)}}function qC(t,e,n,o){return t.createContainerElement("figure",{class:"media"},[e.getMediaViewElement(t,n,o),t.createSlot()])}function GC(t){const e=t.getSelectedElement();return e&&e.is("element","media")?e:null}function WC(t,e,n,o){t.change((i=>{const r=i.createElement("media",{url:e});t.insertObject(r,n,null,{setSelection:"on",findOptimalPosition:o})}))}class ZC extends H{refresh(){const t=this.editor.model,e=t.document.selection,n=GC(e);this.value=n?n.getAttribute("url"):null,this.isEnabled=function(t){const e=t.getSelectedElement();return!!e&&"media"===e.name}(e)||function(t,e){let n=af(t,e).start.parent;n.isEmpty&&!e.schema.isLimit(n)&&(n=n.parent);return e.schema.checkChild(n,"media")}(e,t)}execute(t){const e=this.editor.model,n=e.document.selection,o=GC(n);o?e.change((e=>{e.setAttribute("url",t,o)})):WC(e,t,n,!0)}}class YC{constructor(t,e){const n=e.providers,o=e.extraProviders||[],i=new Set(e.removeProviders),r=n.concat(o).filter((t=>{const e=t.name;return e?!i.has(e):(c("media-embed-no-provider-name",{provider:t}),!1)}));this.locale=t,this.providerDefinitions=r}hasMedia(t){return!!this._getMedia(t)}getMediaViewElement(t,e,n){return this._getMedia(e).getViewElement(t,n)}_getMedia(t){if(!t)return new KC(this.locale);t=t.trim();for(const e of this.providerDefinitions){const n=e.html,o=wo(e.url);for(const e of o){const o=this._getUrlMatches(t,e);if(o)return new KC(this.locale,t,o,n)}}return null}_getUrlMatches(t,e){let n=t.match(e);if(n)return n;let o=t.replace(/^https?:\/\//,"");return n=o.match(e),n||(o=o.replace(/^www\./,""),n=o.match(e),n||null)}}class KC{constructor(t,e,n,o){this.url=this._getValidUrl(e),this._t=t.t,this._match=n,this._previewRenderer=o}getViewElement(t,e){const n={};let o;if(e.renderForEditingView||e.renderMediaPreview&&this.url&&this._previewRenderer){this.url&&(n["data-oembed-url"]=this.url),e.renderForEditingView&&(n.class="ck-media__wrapper");const i=this._getPreviewHtml(e);o=t.createRawElement("div",n,((t,e)=>{e.setContentOf(t,i)}))}else this.url&&(n.url=this.url),o=t.createEmptyElement(e.elementName,n);return t.setCustomProperty("media-content",!0,o),o}_getPreviewHtml(t){return this._previewRenderer?this._previewRenderer(this._match):this.url&&t.renderForEditingView?this._getPlaceholderHtml():""}_getPlaceholderHtml(){const t=new xu,e=new _u;t.text=this._t("Open media in new tab"),e.content='',e.viewBox="0 0 64 42";return new Xd({tag:"div",attributes:{class:"ck ck-reset_all ck-media__placeholder"},children:[{tag:"div",attributes:{class:"ck-media__placeholder__icon"},children:[e]},{tag:"a",attributes:{class:"ck-media__placeholder__url",target:"_blank",rel:"noopener noreferrer",href:this.url},children:[{tag:"span",attributes:{class:"ck-media__placeholder__url__text"},children:[this.url]},t]}]}).render().outerHTML}_getValidUrl(t){return t?t.match(/^https?/)?t:"https://"+t:null}}var $C=n(952),QC={attributes:{"data-cke":!0}};QC.setAttributes=is(),QC.insert=ns().bind(null,"head"),QC.domAPI=ts(),QC.insertStyleElement=ss();Jr()($C.Z,QC);$C.Z&&$C.Z.locals&&$C.Z.locals;class JC extends V{static get pluginName(){return"MediaEmbedEditing"}constructor(t){super(t),t.config.define("mediaEmbed",{elementName:"oembed",providers:[{name:"dailymotion",url:/^dailymotion\.com\/video\/(\w+)/,html:t=>``},{name:"spotify",url:[/^open\.spotify\.com\/(artist\/\w+)/,/^open\.spotify\.com\/(album\/\w+)/,/^open\.spotify\.com\/(track\/\w+)/],html:t=>``},{name:"youtube",url:[/^(?:m\.)?youtube\.com\/watch\?v=([\w-]+)(?:&t=(\d+))?/,/^(?:m\.)?youtube\.com\/v\/([\w-]+)(?:\?t=(\d+))?/,/^youtube\.com\/embed\/([\w-]+)(?:\?start=(\d+))?/,/^youtu\.be\/([\w-]+)(?:\?t=(\d+))?/],html:t=>{const e=t[1],n=t[2];return``}},{name:"vimeo",url:[/^vimeo\.com\/(\d+)/,/^vimeo\.com\/[^/]+\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/album\/[^/]+\/video\/(\d+)/,/^vimeo\.com\/channels\/[^/]+\/(\d+)/,/^vimeo\.com\/groups\/[^/]+\/videos\/(\d+)/,/^vimeo\.com\/ondemand\/[^/]+\/(\d+)/,/^player\.vimeo\.com\/video\/(\d+)/],html:t=>``},{name:"instagram",url:/^instagram\.com\/p\/(\w+)/},{name:"twitter",url:/^twitter\.com/},{name:"googleMaps",url:[/^google\.com\/maps/,/^goo\.gl\/maps/,/^maps\.google\.com/,/^maps\.app\.goo\.gl/]},{name:"flickr",url:/^flickr\.com/},{name:"facebook",url:/^facebook\.com/}]}),this.registry=new YC(t.locale,t.config.get("mediaEmbed"))}init(){const t=this.editor,e=t.model.schema,n=t.t,o=t.conversion,i=t.config.get("mediaEmbed.previewsInData"),r=t.config.get("mediaEmbed.elementName"),s=this.registry;t.commands.add("mediaEmbed",new ZC(t)),e.register("media",{inheritAllFrom:"$blockObject",allowAttributes:["url"]}),o.for("dataDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const n=t.getAttribute("url");return qC(e,s,n,{elementName:r,renderMediaPreview:n&&i})}}),o.for("dataDowncast").add(UC(s,{elementName:r,renderMediaPreview:i})),o.for("editingDowncast").elementToStructure({model:"media",view:(t,{writer:e})=>{const o=t.getAttribute("url");return function(t,e,n){return e.setCustomProperty("media",!0,t),tf(t,e,{label:n})}(qC(e,s,o,{elementName:r,renderForEditingView:!0}),e,n("media widget"))}}),o.for("editingDowncast").add(UC(s,{elementName:r,renderForEditingView:!0})),o.for("upcast").elementToElement({view:t=>["oembed",r].includes(t.name)&&t.getAttribute("url")?{name:!0}:null,model:(t,{writer:e})=>{const n=t.getAttribute("url");if(s.hasMedia(n))return e.createElement("media",{url:n})}}).elementToElement({view:{name:"div",attributes:{"data-oembed-url":!0}},model:(t,{writer:e})=>{const n=t.getAttribute("data-oembed-url");if(s.hasMedia(n))return e.createElement("media",{url:n})}}).add((t=>{t.on("element:figure",(function(t,e,n){if(!n.consumable.consume(e.viewItem,{name:!0,classes:"media"}))return;const{modelRange:o,modelCursor:i}=n.convertChildren(e.viewItem,e.modelCursor);e.modelRange=o,e.modelCursor=i;Ba(o.getItems())||n.consumable.revert(e.viewItem,{name:!0,classes:"media"})}))}))}}const XC=/^(?:http(s)?:\/\/)?[\w-]+\.[\w-.~:/?#[\]@!$&'()*+,;=%]+$/;class t_ extends V{static get requires(){return[zf,Kg,$f]}static get pluginName(){return"AutoMediaEmbed"}constructor(t){super(t),this._timeoutId=null,this._positionToInsert=null}init(){const t=this.editor,e=t.model.document;this.listenTo(t.plugins.get("ClipboardPipeline"),"inputTransformation",(()=>{const t=e.selection.getFirstRange(),n=dd.fromPosition(t.start);n.stickiness="toPrevious";const o=dd.fromPosition(t.end);o.stickiness="toNext",e.once("change:data",(()=>{this._embedMediaBetweenPositions(n,o),n.detach(),o.detach()}),{priority:"high"})})),t.commands.get("undo").on("execute",(()=>{this._timeoutId&&(ms.window.clearTimeout(this._timeoutId),this._positionToInsert.detach(),this._timeoutId=null,this._positionToInsert=null)}),{priority:"high"})}_embedMediaBetweenPositions(t,e){const n=this.editor,o=n.plugins.get(JC).registry,i=new bl(t,e),r=i.getWalker({ignoreElementEnd:!0});let s="";for(const t of r)t.item.is("$textProxy")&&(s+=t.item.data);if(s=s.trim(),!s.match(XC))return void i.detach();if(!o.hasMedia(s))return void i.detach();n.commands.get("mediaEmbed").isEnabled?(this._positionToInsert=dd.fromPosition(t),this._timeoutId=ms.window.setTimeout((()=>{n.model.change((t=>{let e;this._timeoutId=null,t.remove(i),i.detach(),"$graveyard"!==this._positionToInsert.root.rootName&&(e=this._positionToInsert),WC(n.model,s,e,!1),this._positionToInsert.detach(),this._positionToInsert=null})),n.plugins.get("Delete").requestUndoOnBackspace()}),100)):i.detach()}}var e_=n(3525),n_={attributes:{"data-cke":!0}};n_.setAttributes=is(),n_.insert=ns().bind(null,"head"),n_.domAPI=ts(),n_.insertStyleElement=ss();Jr()(e_.Z,n_);e_.Z&&e_.Z.locals&&e_.Z.locals;class o_ extends Jd{constructor(t,e){super(e);const n=e.t;this.focusTracker=new za,this.keystrokes=new Pa,this.set("mediaURLInputValue",""),this.urlInputView=this._createUrlInput(),this.saveButtonView=this._createButton(n("Save"),Gd.check,"ck-button-save"),this.saveButtonView.type="submit",this.saveButtonView.bind("isEnabled").to(this,"mediaURLInputValue",(t=>!!t)),this.cancelButtonView=this._createButton(n("Cancel"),Gd.cancel,"ck-button-cancel","cancel"),this._focusables=new Kd,this._focusCycler=new Ou({focusables:this._focusables,focusTracker:this.focusTracker,keystrokeHandler:this.keystrokes,actions:{focusPrevious:"shift + tab",focusNext:"tab"}}),this._validators=t,this.setTemplate({tag:"form",attributes:{class:["ck","ck-media-form","ck-responsive-form"],tabindex:"-1"},children:[this.urlInputView,this.saveButtonView,this.cancelButtonView]}),Zd(this)}render(){super.render(),Yd({view:this});[this.urlInputView,this.saveButtonView,this.cancelButtonView].forEach((t=>{this._focusables.add(t),this.focusTracker.add(t.element)})),this.keystrokes.listenTo(this.element);const t=t=>t.stopPropagation();this.keystrokes.set("arrowright",t),this.keystrokes.set("arrowleft",t),this.keystrokes.set("arrowup",t),this.keystrokes.set("arrowdown",t),this.listenTo(this.urlInputView.element,"selectstart",((t,e)=>{e.stopPropagation()}),{priority:"high"})}destroy(){super.destroy(),this.focusTracker.destroy(),this.keystrokes.destroy()}focus(){this._focusCycler.focusFirst()}get url(){return this.urlInputView.fieldView.element.value.trim()}set url(t){this.urlInputView.fieldView.element.value=t.trim()}isValid(){this.resetFormStatus();for(const t of this._validators){const e=t(this);if(e)return this.urlInputView.errorText=e,!1}return!0}resetFormStatus(){this.urlInputView.errorText=null,this.urlInputView.infoText=this._urlInputViewInfoDefault}_createUrlInput(){const t=this.locale.t,e=new Fh(this.locale,Hh),n=e.fieldView;return this._urlInputViewInfoDefault=t("Paste the media URL in the input."),this._urlInputViewInfoTip=t("Tip: Paste the URL into the content to embed faster."),e.label=t("Media URL"),e.infoText=this._urlInputViewInfoDefault,n.on("input",(()=>{e.infoText=n.element.value?this._urlInputViewInfoTip:this._urlInputViewInfoDefault,this.mediaURLInputValue=n.element.value.trim()})),e}_createButton(t,e,n,o){const i=new Su(this.locale);return i.set({label:t,icon:e,tooltip:!0}),i.extendTemplate({attributes:{class:n}}),o&&i.delegate("execute").to(this,o),i}}class i_ extends V{static get requires(){return[JC]}static get pluginName(){return"MediaEmbedUI"}init(){const t=this.editor,e=t.commands.get("mediaEmbed"),n=t.plugins.get(JC).registry;t.ui.componentFactory.add("mediaEmbed",(o=>{const i=kh(o),r=new o_(function(t,e){return[e=>{if(!e.url.length)return t("The URL must not be empty.")},n=>{if(!e.hasMedia(n.url))return t("This media URL is not supported.")}]}(t.t,n),t.locale);return this._setUpDropdown(i,r,e,t),this._setUpForm(i,r,e),i}))}_setUpDropdown(t,e,n){const o=this.editor,i=o.t,r=t.buttonView;function s(){o.editing.view.focus(),t.isOpen=!1}t.bind("isEnabled").to(n),t.panelView.children.add(e),r.set({label:i("Insert media"),icon:'',tooltip:!0}),r.on("open",(()=>{e.disableCssTransitions(),e.url=n.value||"",e.urlInputView.fieldView.select(),e.enableCssTransitions()}),{priority:"low"}),t.on("submit",(()=>{e.isValid()&&(o.execute("mediaEmbed",e.url),s())})),t.on("change:isOpen",(()=>e.resetFormStatus())),t.on("cancel",(()=>s()))}_setUpForm(t,e,n){e.delegate("submit","cancel").to(t),e.urlInputView.bind("value").to(n,"value"),e.urlInputView.bind("isReadOnly").to(n,"isEnabled",(t=>!t))}}var r_=n(5777),s_={attributes:{"data-cke":!0}};s_.setAttributes=is(),s_.insert=ns().bind(null,"head"),s_.domAPI=ts(),s_.insertStyleElement=ss();Jr()(r_.Z,s_);r_.Z&&r_.Z.locals&&r_.Z.locals;function a_(t,e){if(!t.childCount)return;const n=new Pm(t.document),o=function(t,e){const n=e.createRangeIn(t),o=new Bo({name:/^p|h\d+$/,styles:{"mso-list":/.*/}}),i=[];for(const t of n)if("elementStart"===t.type&&o.match(t.item)){const e=d_(t.item);i.push({element:t.item,id:e.id,order:e.order,indent:e.indent})}return i}(t,n);if(!o.length)return;let i=null,r=1;o.forEach(((t,s)=>{const a=function(t,e){if(!t)return!0;if(t.id!==e.id)return e.indent-t.indent!=1;const n=e.element.previousSibling;if(!n)return!0;return o=n,!(o.is("element","ol")||o.is("element","ul"));var o}(o[s-1],t),l=a?null:o[s-1],c=(u=t,(d=l)?u.indent-d.indent:u.indent-1);var d,u;if(a&&(i=null,r=1),!i||0!==c){const o=function(t,e){const n=new RegExp(`@list l${t.id}:level${t.indent}\\s*({[^}]*)`,"gi"),o=/mso-level-number-format:([^;]{0,100});/gi,i=/mso-level-start-at:\s{0,100}([0-9]{0,10})\s{0,100};/gi,r=n.exec(e);let s="decimal",a="ol",l=null;if(r&&r[1]){const e=o.exec(r[1]);if(e&&e[1]&&(s=e[1].trim(),a="bullet"!==s&&"image"!==s?"ol":"ul"),"bullet"===s){const e=function(t){const e=function(t){if(t.getChild(0).is("$text"))return null;for(const e of t.getChildren()){if(!e.is("element","span"))continue;const t=e.getChild(0);return t.is("$text")?t:t.getChild(0)}}(t);if(!e)return null;const n=e._data;if("o"===n)return"circle";if("·"===n)return"disc";if("§"===n)return"square";return null}(t.element);e&&(s=e)}else{const t=i.exec(r[1]);t&&t[1]&&(l=parseInt(t[1]))}}return{type:a,startIndex:l,style:l_(s)}}(t,e);if(i){if(t.indent>r){const t=i.getChild(i.childCount-1),e=t.getChild(t.childCount-1);i=c_(o,e,n),r+=1}else if(t.indent1&&n.setAttribute("start",t.startIndex,i),i}function d_(t){const e={},n=t.getStyle("mso-list");if(n){const t=n.match(/(^|\s{1,100})l(\d+)/i),o=n.match(/\s{0,100}lfo(\d+)/i),i=n.match(/\s{0,100}level(\d+)/i);t&&o&&i&&(e.id=t[2],e.order=o[1],e.indent=i[1])}return e}const u_=/id=("|')docs-internal-guid-[-0-9a-f]+("|')/i;class h_{constructor(t){this.document=t}isActive(t){return u_.test(t)}execute(t){const e=new Pm(this.document),{body:n}=t._parsedData;!function(t,e){for(const n of t.getChildren())if(n.is("element","b")&&"normal"===n.getStyle("font-weight")){const o=t.getChildIndex(n);e.remove(n),e.insertChild(o,n.getChildren(),t)}}(n,e),function(t,e){for(const n of e.createRangeIn(t)){const t=n.item;if(t.is("element","li")){const n=t.getChild(0);n&&n.is("element","p")&&e.unwrapElement(n)}}}(n,e),t.content=n}}function m_(t,e){if(!t.childCount)return;const n=new Pm,o=function(t,e){const n=e.createRangeIn(t),o=new Bo({name:/v:(.+)/}),i=[];for(const t of n){if("elementStart"!=t.type)continue;const e=t.item,n=e.previousSibling&&e.previousSibling.name||null;o.match(e)&&e.getAttribute("o:gfxdata")&&"v:shapetype"!==n&&i.push(t.item.getAttribute("id"))}return i}(t,n);!function(t,e,n){const o=n.createRangeIn(e),i=new Bo({name:"img"}),r=[];for(const e of o)if(i.match(e.item)){const n=e.item,o=n.getAttribute("v:shapes")?n.getAttribute("v:shapes").split(" "):[];o.length&&o.every((e=>t.indexOf(e)>-1))?r.push(n):n.getAttribute("src")||r.push(n)}for(const t of r)n.remove(t)}(o,t,n),function(t,e){const n=e.createRangeIn(t),o=new Bo({name:/v:(.+)/}),i=[];for(const t of n)"elementStart"==t.type&&o.match(t.item)&&i.push(t.item);for(const t of i)e.remove(t)}(t,n);const i=function(t,e){const n=e.createRangeIn(t),o=new Bo({name:"img"}),i=[];for(const t of n)o.match(t.item)&&t.item.getAttribute("src").startsWith("file://")&&i.push(t.item);return i}(t,n);i.length&&function(t,e,n){if(t.length===e.length)for(let o=0;oString.fromCharCode(parseInt(t,16)))).join(""))}const p_=//i,f_=/xmlns:o="urn:schemas-microsoft-com/i;class b_{constructor(t){this.document=t}isActive(t){return p_.test(t)||f_.test(t)}execute(t){const{body:e,stylesString:n}=t._parsedData;a_(e,n),m_(e,t.dataTransfer.getData("text/rtf")),t.content=e}}function k_(t){return t.replace(/(\s+)<\/span>/g,((t,e)=>1===e.length?" ":Array(e.length+1).join(" ").substr(0,e.length)))}function w_(t,e){const n=new DOMParser,o=function(t){return k_(k_(t)).replace(/([^\S\r\n]*?)[\r\n]+([^\S\r\n]*<\/span>)/g,"$1$2").replace(/<\/span>/g,"").replace(/ <\//g," ").replace(/ <\/o:p>/g," ").replace(/( |\u00A0)<\/o:p>/g,"").replace(/>([^\S\r\n]*[\r\n]\s*)<")}(function(t){const e="",n="