├── public ├── app.31d6cfe0.css ├── manifest.json ├── app.6b758fd0.js.LICENSE.txt ├── entrypoints.json └── app.6b758fd0.js ├── assets ├── controllers.json ├── styles │ └── app.css ├── src │ ├── types │ │ ├── index.d.ts │ │ ├── maskfield.ts │ │ └── dependentfield.ts │ └── utils │ │ ├── array.ts │ │ ├── dependentfield.ts │ │ ├── maskfield.ts │ │ └── field.ts ├── app.ts ├── bootstrap.js └── controllers │ ├── mask-field_controller.ts │ └── dependent-field_controller.ts ├── .gitignore ├── docker-compose.yml ├── tsconfig.json ├── src ├── Field │ ├── EnumField.php │ ├── MaskField.php │ ├── DependentField.php │ └── Configurator │ │ └── EnumConfigurator.php ├── Utils │ └── ChoiceUtils.php ├── Asset │ └── AssetPackage.php └── EasyAdminFieldsBundle.php ├── package.json ├── composer.json ├── LICENSE.md ├── docker └── php │ └── Dockerfile ├── webpack.config.js └── README.md /public/app.31d6cfe0.css: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /assets/controllers.json: -------------------------------------------------------------------------------- 1 | { 2 | "controllers": [], 3 | "entrypoints": [] 4 | } -------------------------------------------------------------------------------- /assets/styles/app.css: -------------------------------------------------------------------------------- 1 | /*body {*/ 2 | /* background: red !important;*/ 3 | /*}*/ -------------------------------------------------------------------------------- /assets/src/types/index.d.ts: -------------------------------------------------------------------------------- 1 | export * from "./maskfield"; 2 | export * from "./dependentfield"; 3 | 4 | export as namespace EasyAdminFields; -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "app.css": "/bundles/easyadminfields/app.31d6cfe0.css", 3 | "app.js": "/bundles/easyadminfields/app.6b758fd0.js" 4 | } -------------------------------------------------------------------------------- /assets/src/types/maskfield.ts: -------------------------------------------------------------------------------- 1 | export type MapElement = { 2 | value: any; 3 | fields: string[]; 4 | } 5 | 6 | export type Map = MapElement[] -------------------------------------------------------------------------------- /assets/src/utils/array.ts: -------------------------------------------------------------------------------- 1 | export const removeDuplicates = (array: Array): Array => { 2 | return Array.from(new Set(array)); 3 | } 4 | -------------------------------------------------------------------------------- /public/app.6b758fd0.js.LICENSE.txt: -------------------------------------------------------------------------------- 1 | /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ 2 | -------------------------------------------------------------------------------- /assets/app.ts: -------------------------------------------------------------------------------- 1 | // any CSS you import will output into a single css file (app.css in this case) 2 | import './styles/app.css'; 3 | 4 | // start the Stimulus application 5 | import './bootstrap'; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor/ 2 | /node_modules/ 3 | /.idea/inspectionProfiles/Project_Default.xml 4 | /.idea/.gitignore 5 | /.idea/EasyAdminFieldsBundle-TCM-dev.iml 6 | /.idea/misc.xml 7 | /.idea/modules.xml 8 | /.idea/php.xml 9 | /.idea/vcs.xml 10 | -------------------------------------------------------------------------------- /public/entrypoints.json: -------------------------------------------------------------------------------- 1 | { 2 | "entrypoints": { 3 | "app": { 4 | "css": [ 5 | "/bundles/easyadminfields/app.31d6cfe0.css" 6 | ], 7 | "js": [ 8 | "/bundles/easyadminfields/app.6b758fd0.js" 9 | ] 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /assets/src/types/dependentfield.ts: -------------------------------------------------------------------------------- 1 | export type DependentfieldOptions = { 2 | fetch_on_init: boolean; 3 | callback_url: string; 4 | dependencies: string[]; 5 | } 6 | 7 | export type DependentFieldSelectOption = { 8 | text: string, 9 | value: string 10 | } -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.8' 2 | services: 3 | php: 4 | build: 5 | context: . 6 | dockerfile: docker/php/Dockerfile 7 | volumes: 8 | - './:/usr/src' 9 | # Misc 10 | - '~/.config/composer:/.composer' 11 | restart: on-failure 12 | user: 1000:1000 -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "CommonJS", 4 | "moduleResolution": "node", 5 | "noImplicitAny": true, 6 | "removeComments": true, 7 | "target": "es2015", 8 | "sourceMap": true, 9 | "jsx": "react" 10 | }, 11 | "include": [ 12 | "assets/**/*" 13 | ], 14 | "exclude": [ 15 | "node_modules" 16 | ] 17 | } -------------------------------------------------------------------------------- /assets/bootstrap.js: -------------------------------------------------------------------------------- 1 | import {startStimulusApp} from '@symfony/stimulus-bridge'; 2 | 3 | // Registers Stimulus controllers from controllers.json and in the controllers/ directory 4 | export const app = startStimulusApp(require.context( 5 | '@symfony/stimulus-bridge/lazy-controller-loader!./controllers', 6 | true, 7 | /\.[jt]sx?$/ 8 | )); 9 | 10 | // register any custom, 3rd party controllers here 11 | // app.register('some_controller_name', SomeImportedController); 12 | -------------------------------------------------------------------------------- /src/Field/EnumField.php: -------------------------------------------------------------------------------- 1 | setFieldFqcn(self::class); 14 | } 15 | } -------------------------------------------------------------------------------- /assets/src/utils/dependentfield.ts: -------------------------------------------------------------------------------- 1 | export const getOptions = (input: HTMLSelectElement): EasyAdminFields.DependentfieldOptions => { 2 | const data = input.getAttribute('data-dependent-field-options') 3 | 4 | if (!data) { 5 | return { 6 | callback_url: "", 7 | dependencies: [], 8 | fetch_on_init: false 9 | }; 10 | } 11 | 12 | return JSON.parse(data); 13 | } 14 | 15 | export const getCallbackUrl = (input: HTMLSelectElement): string => { 16 | const data = input.getAttribute('data-dependent-field-callback-url') 17 | 18 | return data; 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "encore dev --watch", 4 | "build": "encore production", 5 | "test": "echo \"Error: no test specified\" && exit 1" 6 | }, 7 | "devDependencies": { 8 | "@babel/core": "^7.17.0", 9 | "@babel/preset-env": "^7.16.0", 10 | "@babel/preset-react": "^7.18.6", 11 | "@hotwired/stimulus": "^3.0.0", 12 | "@symfony/stimulus-bridge": "^3.2.0", 13 | "@symfony/webpack-encore": "^4.0.0", 14 | "core-js": "^3.23.0", 15 | "regenerator-runtime": "^0.13.9", 16 | "tom-select": "^1.7.7", 17 | "ts-loader": "^9.2.6", 18 | "typescript": "^4.4.3", 19 | "webpack": "^5.74.0", 20 | "webpack-cli": "^4.10.0", 21 | "webpack-notifier": "^1.15.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "5.1.0", 3 | "name": "insitaction/easyadmin-fields-bundle", 4 | "description": "Set of easyadmin fields and useful helpers for Insitaction", 5 | "type": "symfony-bundle", 6 | "require": { 7 | "php": ">=8.0", 8 | "symfony/framework-bundle": "^v6.1|^7.0", 9 | "easycorp/easyadmin-bundle": "^4", 10 | "symfony/webpack-encore-bundle": "^1.15|^2" 11 | }, 12 | "require-dev": { 13 | "roave/security-advisories": "dev-latest" 14 | }, 15 | "autoload": { 16 | "psr-4": { 17 | "Insitaction\\EasyAdminFieldsBundle\\": "src/" 18 | } 19 | }, 20 | "license": "MIT", 21 | "authors": [ 22 | { 23 | "name": "Valentin Wojtasinski", 24 | "email": "vwojtasinski@insitaction.com" 25 | } 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /src/Utils/ChoiceUtils.php: -------------------------------------------------------------------------------- 1 | getValue($choice, $keyProperty); 18 | $label = $propertyAccessor->getValue($choice, $labelProperty); 19 | $translatableChoices[$key] = t($label); 20 | } 21 | 22 | return $translatableChoices; 23 | } 24 | } -------------------------------------------------------------------------------- /src/Field/MaskField.php: -------------------------------------------------------------------------------- 1 | setFormTypeOptions([ 17 | 'row_attr' => [ 18 | 'data-controller' => 'mask-field', 19 | 'data-mask-field-map' => self::encodeMap($map) 20 | ], 21 | ]); 22 | } 23 | 24 | public static function encodeMap(array $map) 25 | { 26 | $mapElementArray = []; 27 | 28 | foreach ($map as $key => $fields) { 29 | $mapElementArray[] = [ 30 | 'value' => $key, 31 | 'fields' => $fields 32 | ]; 33 | } 34 | 35 | return json_encode($mapElementArray, JSON_THROW_ON_ERROR); 36 | } 37 | } -------------------------------------------------------------------------------- /assets/src/utils/maskfield.ts: -------------------------------------------------------------------------------- 1 | export const getMap = (input: HTMLInputElement): EasyAdminFields.Map => { 2 | const data = input.getAttribute('data-mask-field-map') 3 | 4 | if (!data) { 5 | return []; 6 | } 7 | 8 | return JSON.parse(data); 9 | } 10 | 11 | export const getMapFields = (map: EasyAdminFields.Map): string[] => { 12 | const fields: string[] = []; 13 | 14 | map.forEach(mapElement => { 15 | const mapElementFields = mapElement.fields 16 | 17 | mapElementFields.forEach(field => { 18 | if (fields.includes(field)) { 19 | return; 20 | } 21 | 22 | fields.push(field); 23 | }) 24 | }) 25 | 26 | return fields; 27 | } 28 | 29 | export const getMapElement = (value: string, map: EasyAdminFields.Map): EasyAdminFields.MapElement | undefined => { 30 | return map.find(mapElement => mapElement.value == value); 31 | } 32 | 33 | export const getMapElements = (values: string[], map: EasyAdminFields.Map): EasyAdminFields.MapElement[] => { 34 | return map.filter(mapElement => values.includes(mapElement.value)); 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Valentin Wojtasinski 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/Asset/AssetPackage.php: -------------------------------------------------------------------------------- 1 | package = new PathPackage( 20 | '/bundles/easyadminfields', 21 | new JsonManifestVersionStrategy(__DIR__ . '/../../public/manifest.json'), 22 | new RequestStackContext($requestStack) 23 | ); 24 | } 25 | 26 | public function getUrl(string $assetPath): string 27 | { 28 | return $this->package->getUrl($assetPath); 29 | } 30 | 31 | public function getVersion(string $assetPath): string 32 | { 33 | return $this->package->getVersion($assetPath); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /docker/php/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1-fpm-alpine 2 | 3 | # Composer install 4 | COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer 5 | 6 | # Install dev dependencies 7 | RUN apk add --no-cache --virtual .build-deps $PHPIZE_DEPS curl-dev imagemagick-dev \ 8 | libtool libxml2-dev postgresql-dev sqlite-dev 9 | 10 | # Install production dependencies 11 | RUN apk add --no-cache bash curl freetype-dev g++ gcc git icu-dev icu-libs imagemagick \ 12 | libc-dev libjpeg-turbo-dev libpng-dev libzip-dev make mysql-client oniguruma-dev \ 13 | postgresql-libs supervisor zlib-dev 14 | 15 | # Install PECL and PEAR extensions 16 | RUN pecl install igbinary redis imagick openswoole 17 | 18 | # Enable PECL and PEAR extensions 19 | RUN docker-php-ext-enable igbinary redis imagick openswoole 20 | 21 | # Install php extensions 22 | RUN docker-php-ext-install bcmath calendar curl exif gd intl mbstring pdo pdo_mysql \ 23 | pdo_pgsql pdo_sqlite pcntl soap xml zip 24 | 25 | # Install Symfony CLI 26 | RUN curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.alpine.sh' | bash 27 | RUN apk add --no-cache symfony-cli 28 | 29 | # Cleanup dev dependencies 30 | RUN apk del -f .build-deps 31 | 32 | # Misc 33 | WORKDIR /usr/src 34 | 35 | # Make every files owned by current user instead of Docker 36 | RUN chown 1000:1000 /usr/src -------------------------------------------------------------------------------- /src/EasyAdminFieldsBundle.php: -------------------------------------------------------------------------------- 1 | services() 20 | ->defaults()->private(); 21 | 22 | $services 23 | ->set(AssetPackage::class) 24 | ->arg(0, service('request_stack')) 25 | ->tag('assets.package', ['package' => AssetPackage::PACKAGE_NAME]); 26 | 27 | $services 28 | ->set(EnumConfigurator::class) 29 | ->arg(0, service('translator')) 30 | ->tag('ea.field_configurator'); 31 | } 32 | 33 | public static function configureAssets(Assets $asset): Assets 34 | { 35 | $jsAsset = Asset::new('app.js')->package(AssetPackage::PACKAGE_NAME); 36 | $cssAsset = Asset::new('app.css')->package(AssetPackage::PACKAGE_NAME); 37 | 38 | return $asset 39 | ->addJsFile($jsAsset) 40 | ->addCssFile($cssAsset); 41 | } 42 | } -------------------------------------------------------------------------------- /assets/controllers/mask-field_controller.ts: -------------------------------------------------------------------------------- 1 | import {Controller} from '@hotwired/stimulus'; 2 | import {getFormGroupField, getValue, hideField, showField} from '../src/utils/field'; 3 | import {getMap, getMapElement, getMapElements, getMapFields} from '../src/utils/maskfield'; 4 | import {removeDuplicates} from "../src/utils/array"; 5 | 6 | export default class extends Controller { 7 | private map: EasyAdminFields.Map; 8 | 9 | connect() { 10 | this.map = getMap(this.element); 11 | this.element.addEventListener('input', this.handleEvent.bind(this)) 12 | const input = getFormGroupField(this.element); 13 | this.handle(input); 14 | } 15 | 16 | disconnect() { 17 | this.element.removeEventListener('input', this.handleEvent.bind(this)) 18 | } 19 | 20 | handleEvent(e: Event) { 21 | const input = e.target as HTMLInputElement; 22 | 23 | this.handle(input); 24 | } 25 | 26 | handle(input: HTMLInputElement) { 27 | const value = getValue(input); 28 | const mapFields = getMapFields(this.map); 29 | 30 | if (Array.isArray(value)) { 31 | const mapElements = getMapElements(value, this.map); 32 | const fields = mapElements.map(mapElement => mapElement.fields).flat(); 33 | 34 | const finalFields = removeDuplicates(fields); 35 | 36 | this.handleFieldsVisibility(mapFields, finalFields) 37 | 38 | return; 39 | } 40 | 41 | const mapElement = getMapElement(value, this.map); 42 | 43 | this.handleFieldsVisibility(mapFields, mapElement?.fields) 44 | } 45 | 46 | /** 47 | - hide every field 48 | - show concerned fields again 49 | */ 50 | handleFieldsVisibility(toHide: string[], toShow: string[]) { 51 | toHide.forEach(hideField) 52 | 53 | if (toShow) { 54 | // make corresponding fields visible 55 | toShow.forEach(showField) 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/Field/DependentField.php: -------------------------------------------------------------------------------- 1 | resolve($options); 18 | 19 | if (!method_exists($field, 'setFormTypeOptions')) { 20 | return $field; 21 | } 22 | 23 | if (!$field instanceof ChoiceField && !$field instanceof AssociationField) { 24 | throw new \InvalidArgumentException(sprintf( 25 | "Adapted DependentField should be an instance of ChoiceField or AssociationField, instance of %s given", 26 | get_class($field) 27 | )); 28 | } 29 | 30 | return $field 31 | ->setFormTypeOptions([ 32 | 'row_attr' => [ 33 | 'data-controller' => 'dependent-field', 34 | 'data-dependent-field-options' => self::encodeOptions($options), 35 | ], 36 | ]); 37 | } 38 | 39 | public static function encodeOptions(array $options) 40 | { 41 | return json_encode($options, JSON_THROW_ON_ERROR); 42 | } 43 | 44 | public static function configureOptions(OptionsResolver $resolver) 45 | { 46 | $resolver->setDefaults([ 47 | 'fetch_on_init' => false, 48 | ]); 49 | 50 | $resolver->setRequired('callback_url'); 51 | $resolver->setRequired('dependencies'); 52 | 53 | $resolver->setAllowedTypes('callback_url', 'string'); 54 | $resolver->setAllowedTypes('dependencies', 'string[]'); 55 | $resolver->setAllowedTypes('fetch_on_init', 'boolean'); 56 | } 57 | } -------------------------------------------------------------------------------- /assets/src/utils/field.ts: -------------------------------------------------------------------------------- 1 | import {TomInput} from "tom-select/src/types/core"; 2 | 3 | export const getValue = (input: HTMLInputElement | TomInput): string | string[] => { 4 | if (isTomSelect(input)) { 5 | return input.tomselect.getValue() 6 | } 7 | 8 | if (input.getAttribute('type') === 'checkbox') { 9 | // we want to return a string value 10 | return input.checked ? "true" : "false"; 11 | } 12 | 13 | return input.value; 14 | } 15 | 16 | export const isTomSelect = (element: HTMLSelectElement | TomInput): element is TomInput => { 17 | return (element as TomInput).tomselect !== undefined; 18 | } 19 | 20 | export const getFieldFormGroup = (field: string): HTMLElement => { 21 | // find corresponding input 22 | const input: HTMLElement = document.querySelector(`[name*="[${field}]"]`); 23 | 24 | if (!input) { 25 | return null; 26 | } 27 | 28 | return getInputClosestFormGroup(input); 29 | } 30 | 31 | export const getFieldFormGroups = (field: string): HTMLElement[] => { 32 | // Check if we can find a form group directly (mainly for collection fields) 33 | const formGroup: HTMLElement = document.querySelector(`[data-prototype*="_${field}__"]`) 34 | 35 | if (formGroup) { 36 | return [formGroup]; 37 | } 38 | 39 | // find corresponding inputs 40 | const inputs: NodeListOf = document.querySelectorAll(`[name*="[${field}]"]`); 41 | 42 | return [...inputs].map(getInputClosestFormGroup); 43 | } 44 | 45 | export const getFormGroupField = (formGroup: HTMLElement): HTMLInputElement => { 46 | return formGroup.querySelector('select, input, textarea'); 47 | } 48 | 49 | export const getFormGroupFields = (formGroup: HTMLElement): NodeListOf => { 50 | return formGroup.querySelectorAll('select, input, textarea'); 51 | } 52 | 53 | export const hideField = (field: string) => { 54 | const formGroups: HTMLElement[] = getFieldFormGroups(field); 55 | 56 | formGroups.forEach(formGroup => { 57 | formGroup.style.display = "none"; 58 | }) 59 | 60 | formGroups.forEach(formGroup => { 61 | const inputs = getFormGroupFields(formGroup); 62 | 63 | [...inputs].forEach(input => { 64 | input.setAttribute('disabled', 'mask'); 65 | }) 66 | }) 67 | } 68 | 69 | export const showField = (field: string) => { 70 | const formGroups: HTMLElement[] = getFieldFormGroups(field); 71 | 72 | formGroups.forEach(formGroup => { 73 | formGroup.style.display = null; 74 | }) 75 | 76 | formGroups.forEach(formGroup => { 77 | const inputs = getFormGroupFields(formGroup); 78 | 79 | [...inputs].forEach(input => { 80 | if(input.getAttribute('disabled') === 'mask') { 81 | input.removeAttribute('disabled'); 82 | } 83 | }) 84 | }) 85 | } 86 | 87 | export const getInputClosestFormGroup = (input: HTMLElement): HTMLElement => { 88 | return input.closest('.js-form-group-override') || input.closest('.form-group'); 89 | } 90 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | // var Encore = require('@symfony/webpack-encore'); 2 | // const WebpackRTLPlugin = require('webpack-rtl-plugin'); 3 | 4 | // Encore 5 | // .setOutputPath('./src/Resources/public/') 6 | // .setPublicPath('./') 7 | // .setManifestKeyPrefix('bundles/easyadmin-fields') 8 | // 9 | // .cleanupOutputBeforeBuild() 10 | // .enableSassLoader() 11 | // .enableSourceMaps(true) 12 | // .enableVersioning(false) 13 | // .disableSingleRuntimeChunk() 14 | // .enableTypeScriptLoader() 15 | // .enableReactPreset() 16 | // 17 | // .addPlugin(new WebpackRTLPlugin()) 18 | // 19 | // .addEntry('main', './assets/main.ts') 20 | // .addEntry('app', './assets/css/app.scss') 21 | // ; 22 | 23 | // module.exports = Encore.getWebpackConfig(); 24 | 25 | const Encore = require('@symfony/webpack-encore'); 26 | 27 | // Manually configure the runtime environment if not already configured yet by the "encore" command. 28 | // It's useful when you use tools that rely on webpack.config.js file. 29 | if (!Encore.isRuntimeEnvironmentConfigured()) { 30 | Encore.configureRuntimeEnvironment(process.env.NODE_ENV || 'dev'); 31 | } 32 | 33 | Encore 34 | // directory where compiled assets will be stored 35 | .setOutputPath('./public/') 36 | // public path used by the web server to access the output path 37 | .setPublicPath('/bundles/easyadminfields') 38 | // only needed for CDN's or sub-directory deploy 39 | .setManifestKeyPrefix('') 40 | // .setManifestKeyPrefix('bundles/easyadmin-fields') 41 | 42 | /* 43 | * ENTRY CONFIG 44 | * 45 | * Each entry will result in one JavaScript file (e.g. app.js) 46 | * and one CSS file (e.g. app.css) if your JavaScript imports CSS. 47 | */ 48 | .addEntry('app', './assets/app.ts') 49 | 50 | // enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js) 51 | .enableStimulusBridge('./assets/controllers.json') 52 | 53 | // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. 54 | // .splitEntryChunks() 55 | 56 | // will require an extra script tag for runtime.js 57 | // but, you probably want this, unless you're building a single-page app 58 | .disableSingleRuntimeChunk() 59 | 60 | /* 61 | * FEATURE CONFIG 62 | * 63 | * Enable & configure other features below. For a full 64 | * list of features, see: 65 | * https://symfony.com/doc/current/frontend.html#adding-more-features 66 | */ 67 | .cleanupOutputBeforeBuild() 68 | .enableBuildNotifications() 69 | .enableSourceMaps(!Encore.isProduction()) 70 | // enables hashed filenames (e.g. app.abc123.css) 71 | .enableVersioning(Encore.isProduction()) 72 | 73 | .configureBabel((config) => { 74 | config.plugins.push('@babel/plugin-proposal-class-properties'); 75 | }) 76 | 77 | // enables @babel/preset-env polyfills 78 | .configureBabelPresetEnv((config) => { 79 | config.useBuiltIns = 'usage'; 80 | config.corejs = 3; 81 | }) 82 | 83 | // enables Sass/SCSS support 84 | //.enableSassLoader() 85 | 86 | // uncomment if you use TypeScript 87 | .enableTypeScriptLoader() 88 | 89 | // uncomment if you use React 90 | .enableReactPreset() 91 | 92 | // uncomment to get integrity="..." attributes on your script & link tags 93 | // requires WebpackEncoreBundle 1.4 or higher 94 | //.enableIntegrityHashes(Encore.isProduction()) 95 | 96 | // uncomment if you're having problems with a jQuery plugin 97 | //.autoProvidejQuery() 98 | ; 99 | 100 | module.exports = Encore.getWebpackConfig(); 101 | -------------------------------------------------------------------------------- /assets/controllers/dependent-field_controller.ts: -------------------------------------------------------------------------------- 1 | import {Controller} from '@hotwired/stimulus'; 2 | import {getFieldFormGroup, getFormGroupField, getValue, hideField, isTomSelect, showField} from '../src/utils/field'; 3 | import {getCallbackUrl, getOptions} from "../src/utils/dependentfield"; 4 | import {TomInput} from "tom-select/src/types/core"; 5 | import {DependentFieldSelectOption} from "../src/types"; 6 | 7 | export default class extends Controller { 8 | private callbackUrl: string; 9 | private dependencies: string[]; 10 | private dependenciesFormGroup: HTMLElement[] = []; 11 | private isTomselect: boolean; 12 | private input: TomInput | HTMLSelectElement; 13 | 14 | connect() { 15 | const options = getOptions(this.element); 16 | this.callbackUrl = options['callback_url']; 17 | 18 | this.dependencies = options['dependencies']; 19 | this.dependencies.forEach(dependency => { 20 | const formGroup = getFieldFormGroup(dependency); 21 | 22 | if (!formGroup) { 23 | return; 24 | } 25 | 26 | formGroup.addEventListener('input', this.handle.bind(this)) 27 | this.dependenciesFormGroup.push(formGroup) 28 | }) 29 | 30 | this.input = getFormGroupField(this.element); 31 | this.isTomselect = Boolean(this.element.querySelector('.tomselected')); 32 | 33 | if (options['fetch_on_init'] || false) { 34 | this.handle(); 35 | } 36 | } 37 | 38 | disconnect() { 39 | this.dependenciesFormGroup.forEach(formGroup => { 40 | formGroup.removeEventListener('input', this.handle.bind(this)) 41 | }) 42 | } 43 | 44 | async handle() { 45 | const input = this.input as HTMLSelectElement; 46 | 47 | const hasEmptyOption = Boolean(Array.from(input.options).find(option => { 48 | return option.value === ""; 49 | })); 50 | 51 | this.clearOptions() 52 | 53 | const newOptions = await this.fetchOptions() 54 | 55 | this.setOptions(newOptions, hasEmptyOption) 56 | } 57 | 58 | async fetchOptions(): Promise { 59 | const params = new URLSearchParams(); 60 | 61 | this.dependencies.forEach(dependency => { 62 | const formGroup = getFieldFormGroup(dependency) 63 | 64 | if (!formGroup) { 65 | return; 66 | } 67 | 68 | const field = getFormGroupField(formGroup) 69 | const value = getValue(field) 70 | 71 | if (Array.isArray(value)) { 72 | value.forEach(singleValue => { 73 | params.append(dependency + "[]", singleValue) 74 | }) 75 | 76 | return; 77 | } 78 | 79 | params.append(dependency, value) 80 | }) 81 | 82 | const queryParams = (new URLSearchParams(params)).toString() 83 | const response = await fetch(`${this.callbackUrl}?${queryParams}`) 84 | 85 | return await response.json() 86 | } 87 | 88 | clearOptions() { 89 | if (!isTomSelect(this.input)) { 90 | while (this.input.options.length > 0) { 91 | this.input.remove(0); 92 | } 93 | 94 | return; 95 | } 96 | 97 | const control = this.input.tomselect; 98 | control.lock(); 99 | control.clear() 100 | control.clearOptions() 101 | } 102 | 103 | setOptions(options: EasyAdminFields.DependentFieldSelectOption[], hasEmptyOption: boolean) { 104 | // Using this.input directly won't work with loop context and typescript type guard 105 | const input = this.input 106 | 107 | if (!isTomSelect(input)) { 108 | if (hasEmptyOption) { 109 | input.options.add(new Option("", "")) 110 | } 111 | 112 | options.forEach(option => { 113 | input.options.add(new Option(option.text, option.value)) 114 | }) 115 | 116 | return; 117 | } 118 | 119 | const control = input.tomselect; 120 | control.addOptions(options) 121 | control.refreshOptions(false) 122 | control.unlock() 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This package is not maintained anymore 2 | 3 | I don't have time for this and I don't work on EasyAdmin backoffice anymore 4 | I strongly encourage anyone who can to make a better bundle for this, many bugs were encountered, the main paint points are to find a correct selector that won't have any side effects, and make everything compatible with the lifecycle of the forms 5 | 6 | # EasyAdminFieldsBundle 7 | 8 | ## Installation 9 | 10 | Run the following command to install EasyAdminFields in your application: 11 | 12 | ```shell 13 | $ composer require insitaction/easyadmin-fields-bundle 14 | ``` 15 | 16 | Use the bundle assets 17 | 18 | ```php 19 | // DashboardController.php 20 | 21 | use Insitaction\EasyAdminFieldsBundle\EasyAdminFieldsBundle; 22 | 23 | public function configureAssets(): Assets 24 | { 25 | $assets = parent::configureAssets(); 26 | 27 | return EasyAdminFieldsBundle::configureAssets($assets); 28 | } 29 | ``` 30 | 31 | Without the helper method 32 | 33 | ```php 34 | // DashboardController.php 35 | 36 | use Insitaction\EasyAdminFieldsBundle\Asset\AssetPackage; 37 | 38 | public function configureAssets(): Assets 39 | { 40 | $jsAsset = Asset::new('app.js')->package(AssetPackage::PACKAGE_NAME); 41 | $cssAsset = Asset::new('app.css')->package(AssetPackage::PACKAGE_NAME); 42 | 43 | return parent::configureAssets() 44 | ->addJsFile($jsAsset) 45 | ->addCssFile($cssAsset); 46 | } 47 | ``` 48 | 49 | ## Fields 50 | 51 | ### Mask field 52 | 53 | The mask field allows you to show or hide other fields depending on one field's value 54 | 55 | #### Usage 56 | 57 | - With the MaskField wrapper 58 | 59 | ```php 60 | MaskField::adapt( 61 | BooleanField::new('hasAuthor'), 62 | [ 63 | "true" => ['author'] 64 | ] 65 | ) 66 | ``` 67 | 68 | - Directly adding form type options to your field 69 | 70 | ```php 71 | BooleanField::new('hasAuthor') 72 | ->setFormTypeOptions([ 73 | 'row_attr' => [ 74 | 'data-controller' => 'mask-field', 75 | 'data-mask-field-map' => MaskField::encodeMap([ 76 | "true" => ['author'] 77 | ]) 78 | ], 79 | ]) 80 | ``` 81 | 82 | #### Configuration 83 | 84 | The map configuration works like this: 85 | 86 | - The key corresponds to an input value 87 | - The value is an array of field names 88 | 89 | With this map configuration : 90 | 91 | ```php 92 | [ 93 | "true" => ['author'] 94 | ] 95 | ``` 96 | 97 | The `author` field is shown only when `true` is the input value, otherwise, the `author` field is masked 98 | 99 | With this map configuration : 100 | 101 | ```php 102 | [ 103 | "A" => ['field1'], 104 | "B" => ['field1', 'field2'], 105 | "C" => ['field2'], 106 | ] 107 | ``` 108 | 109 | The `field1` field is shown when either `A` or `B` is the input value, the `field2` field is shown when either `B` 110 | or `C` is the input value 111 | 112 | ### Dependent field 113 | 114 | The dependent field can wrap ChoiceField or AssociationField to make their available options dynamic If any of the field 115 | dependencies is updated, a request is emitted to retrieve new options for the dependent field 116 | 117 | #### Usage 118 | 119 | - With the DependentField wrapper 120 | 121 | ```php 122 | DependentField::adapt( 123 | AssociationField::new('author'), 124 | [ 125 | 'callback_url' => $this->urlGenerator->generate('authors', [], UrlGeneratorInterface::ABSOLUTE_URL), 126 | 'dependencies' => ['gender'], 127 | 'fetch_on_init' => true 128 | ] 129 | ) 130 | ``` 131 | 132 | #### Configuration 133 | 134 | ##### Dependencies 135 | 136 | The `dependencies` array is an array of string corresponding to other fields name 137 | 138 | With this dependencies configuration, the callback will be called everytime the `gender` field is updated 139 | 140 | ```php 141 | 'dependencies' => ['gender'] 142 | ``` 143 | 144 | ##### Callback Url 145 | 146 | The `callback_url` must be an url that accepts a GET request which returns data of this format: 147 | 148 | ```json 149 | [ 150 | { 151 | "text": "John Doe", 152 | "value": 1 153 | }, 154 | { 155 | "text": "John Snow", 156 | "value": 2 157 | } 158 | ] 159 | ``` 160 | 161 | The following query parameters will be sent with the request (this corresponds to the dependencies array and the 162 | corresponding field value) 163 | 164 | ```json 165 | { 166 | "gender": "Male" 167 | } 168 | ``` 169 | 170 | ##### Fetch on init 171 | 172 | The `fetch_on_init` parameter defines wheter or not the callback should be executed immediatly after the field is 173 | mounted 174 | -------------------------------------------------------------------------------- /src/Field/Configurator/EnumConfigurator.php: -------------------------------------------------------------------------------- 1 | getFieldFqcn(); 28 | } 29 | 30 | public function configure(FieldDto $field, EntityDto $entityDto, AdminContext $context): void 31 | { 32 | $isExpanded = $field->getCustomOption(ChoiceField::OPTION_RENDER_EXPANDED); 33 | $isMultipleChoice = $field->getCustomOption(ChoiceField::OPTION_ALLOW_MULTIPLE_CHOICES); 34 | 35 | $choices = $this->getChoices($field->getCustomOption(ChoiceField::OPTION_CHOICES), $entityDto, $field); 36 | if (empty($choices)) { 37 | if (($enumTypeClass = $field->getDoctrineMetadata()->get('enumType')) && enum_exists($enumTypeClass)) { 38 | $field->setFormType(EnumType::class); 39 | $field->setFormTypeOption('class', $enumTypeClass); 40 | $choices = $enumTypeClass::cases(); 41 | } 42 | } 43 | 44 | $field->setFormTypeOptionIfNotSet('choices', $choices); 45 | $field->setFormTypeOptionIfNotSet('multiple', $isMultipleChoice); 46 | $field->setFormTypeOptionIfNotSet('expanded', $isExpanded); 47 | 48 | if ($isExpanded && ChoiceField::WIDGET_AUTOCOMPLETE === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { 49 | throw new \InvalidArgumentException(sprintf('The "%s" choice field wants to be displayed as an autocomplete widget and as an expanded list of choices at the same time, which is not possible. Use the renderExpanded() and renderAsNativeWidget() methods to change one of those options.', $field->getProperty())); 50 | } 51 | 52 | if (null === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { 53 | $field->setCustomOption(ChoiceField::OPTION_WIDGET, $isExpanded ? ChoiceField::WIDGET_NATIVE : ChoiceField::WIDGET_AUTOCOMPLETE); 54 | } 55 | 56 | if (ChoiceField::WIDGET_AUTOCOMPLETE === $field->getCustomOption(ChoiceField::OPTION_WIDGET)) { 57 | $field->setFormTypeOption('attr.data-ea-widget', 'ea-autocomplete'); 58 | $field->setDefaultColumns($isMultipleChoice ? 'col-md-8 col-xxl-6' : 'col-md-6 col-xxl-5'); 59 | } 60 | 61 | $field->setFormTypeOptionIfNotSet('placeholder', ''); 62 | 63 | // the value of this form option must be a string to properly propagate it as an HTML attribute value 64 | $field->setFormTypeOption('attr.data-ea-autocomplete-render-items-as-html', $field->getCustomOption(ChoiceField::OPTION_ESCAPE_HTML_CONTENTS) ? 'false' : 'true'); 65 | 66 | $fieldValue = $field->getValue(); 67 | $isIndexOrDetail = \in_array($context->getCrud()->getCurrentPage(), [Crud::PAGE_INDEX, Crud::PAGE_DETAIL], true); 68 | if (null === $fieldValue || !$isIndexOrDetail) { 69 | return; 70 | } 71 | 72 | $badgeSelector = $field->getCustomOption(ChoiceField::OPTION_RENDER_AS_BADGES); 73 | $isRenderedAsBadge = null !== $badgeSelector && false !== $badgeSelector; 74 | 75 | $translationParameters = $context->getI18n()->getTranslationParameters(); 76 | $translationDomain = $context->getI18n()->getTranslationDomain(); 77 | $selectedChoices = []; 78 | // $value is a scalar for single selections and an array for multiple selections 79 | foreach ((array)$fieldValue as $selectedValue) { 80 | if($selectedChoice = $enumTypeClass::tryFrom($selectedValue)) { 81 | $choiceValue = $this->translator->trans($selectedChoice->name, $translationParameters, $translationDomain); 82 | $selectedChoices[] = $isRenderedAsBadge 83 | ? sprintf('%s', $this->getBadgeCssClass($badgeSelector, $selectedValue, $field), $choiceValue) 84 | : $choiceValue; 85 | } 86 | } 87 | $field->setFormattedValue(implode($isRenderedAsBadge ? '' : ', ', $selectedChoices)); 88 | } 89 | 90 | private function getChoices($choiceGenerator, EntityDto $entity, FieldDto $field): array 91 | { 92 | if (null === $choiceGenerator) { 93 | return []; 94 | } 95 | 96 | if (\is_array($choiceGenerator)) { 97 | return $choiceGenerator; 98 | } 99 | 100 | return $choiceGenerator($entity->getInstance(), $field); 101 | } 102 | 103 | private function getBadgeCssClass($badgeSelector, $value, FieldDto $field): string 104 | { 105 | $commonBadgeCssClass = 'badge'; 106 | 107 | if (true === $badgeSelector) { 108 | $badgeType = 'badge-secondary'; 109 | } elseif (\is_array($badgeSelector)) { 110 | $badgeType = $badgeSelector[$value] ?? 'badge-secondary'; 111 | } elseif (\is_callable($badgeSelector)) { 112 | $badgeType = $badgeSelector($value, $field); 113 | if (!\in_array($badgeType, ChoiceField::VALID_BADGE_TYPES, true)) { 114 | throw new \RuntimeException(sprintf('The value returned by the callable passed to the "renderAsBadges()" method must be one of the following valid badge types: "%s" ("%s" given).', implode(', ', ChoiceField::VALID_BADGE_TYPES), $badgeType)); 115 | } 116 | } 117 | 118 | $badgeTypeCssClass = empty($badgeType) ? '' : u($badgeType)->ensureStart('badge-')->toString(); 119 | 120 | return $commonBadgeCssClass . ' ' . $badgeTypeCssClass; 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /public/app.6b758fd0.js: -------------------------------------------------------------------------------- 1 | /*! For license information please see app.6b758fd0.js.LICENSE.txt */ 2 | (()=>{var t={4180:(t,e,r)=>{var n={"./dependent-field_controller.ts":345,"./mask-field_controller.ts":8232};function o(t){var e=i(t);return r(e)}function i(t){if(!r.o(n,t)){var e=new Error("Cannot find module '"+t+"'");throw e.code="MODULE_NOT_FOUND",e}return n[t]}o.keys=function(){return Object.keys(n)},o.resolve=i,t.exports=o,o.id=4180},6599:(t,e,r)=>{"use strict";r.r(e),r.d(e,{Application:()=>z,AttributeObserver:()=>v,Context:()=>T,Controller:()=>Z,ElementObserver:()=>d,IndexedMultimap:()=>O,Multimap:()=>w,StringMapObserver:()=>g,TokenListObserver:()=>E,ValueListObserver:()=>S,add:()=>y,defaultSchema:()=>G,del:()=>m,fetch:()=>b,prune:()=>x});class n{constructor(t,e,r){this.eventTarget=t,this.eventName=e,this.eventOptions=r,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(t){this.unorderedBindings.add(t)}bindingDisconnected(t){this.unorderedBindings.delete(t)}handleEvent(t){const e=function(t){if("immediatePropagationStopped"in t)return t;{const{stopImmediatePropagation:e}=t;return Object.assign(t,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}(t);for(const t of this.bindings){if(e.immediatePropagationStopped)break;t.handleEvent(e)}}get bindings(){return Array.from(this.unorderedBindings).sort(((t,e)=>{const r=t.index,n=e.index;return rn?1:0}))}}class o{constructor(t){this.application=t,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach((t=>t.connect())))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach((t=>t.disconnect())))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce(((t,e)=>t.concat(Array.from(e.values()))),[])}bindingConnected(t){this.fetchEventListenerForBinding(t).bindingConnected(t)}bindingDisconnected(t){this.fetchEventListenerForBinding(t).bindingDisconnected(t)}handleError(t,e,r={}){this.application.handleError(t,`Error ${e}`,r)}fetchEventListenerForBinding(t){const{eventTarget:e,eventName:r,eventOptions:n}=t;return this.fetchEventListener(e,r,n)}fetchEventListener(t,e,r){const n=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(e,r);let i=n.get(o);return i||(i=this.createEventListener(t,e,r),n.set(o,i)),i}createEventListener(t,e,r){const o=new n(t,e,r);return this.started&&o.connect(),o}fetchEventListenerMapForEventTarget(t){let e=this.eventListenerMaps.get(t);return e||(e=new Map,this.eventListenerMaps.set(t,e)),e}cacheKey(t,e){const r=[t];return Object.keys(e).sort().forEach((t=>{r.push(`${e[t]?"":"!"}${t}`)})),r.join(":")}}const i=/^((.+?)(@(window|document))?->)?(.+?)(#([^:]+?))(:(.+))?$/;function s(t){return"window"==t?window:"document"==t?document:void 0}function a(t){return t.replace(/(?:[_-])([a-z0-9])/g,((t,e)=>e.toUpperCase()))}function c(t){return t.charAt(0).toUpperCase()+t.slice(1)}function u(t){return t.replace(/([A-Z])/g,((t,e)=>`-${e.toLowerCase()}`))}const l={a:t=>"click",button:t=>"click",form:t=>"submit",details:t=>"toggle",input:t=>"submit"==t.getAttribute("type")?"click":"input",select:t=>"change",textarea:t=>"input"};function h(t){throw new Error(t)}function f(t){try{return JSON.parse(t)}catch(e){return t}}class p{constructor(t,e){this.context=t,this.action=e}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(t){this.willBeInvokedByEvent(t)&&this.shouldBeInvokedPerSelf(t)&&(this.processStopPropagation(t),this.processPreventDefault(t),this.invokeWithEvent(t))}get eventName(){return this.action.eventName}get method(){const t=this.controller[this.methodName];if("function"==typeof t)return t;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}processStopPropagation(t){this.eventOptions.stop&&t.stopPropagation()}processPreventDefault(t){this.eventOptions.prevent&&t.preventDefault()}invokeWithEvent(t){const{target:e,currentTarget:r}=t;try{const{params:n}=this.action,o=Object.assign(t,{params:n});this.method.call(this.controller,o),this.context.logDebugActivity(this.methodName,{event:t,target:e,currentTarget:r,action:this.methodName})}catch(e){const{identifier:r,controller:n,element:o,index:i}=this,s={identifier:r,controller:n,element:o,index:i,event:t};this.context.handleError(e,`invoking action "${this.action}"`,s)}}shouldBeInvokedPerSelf(t){return!0!==this.action.eventOptions.self||this.action.element===t.target}willBeInvokedByEvent(t){const e=t.target;return this.element===e||(e instanceof Element&&this.element.contains(e)?this.scope.containsElement(e):this.scope.containsElement(this.action.element))}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}}class d{constructor(t,e){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=t,this.started=!1,this.delegate=e,this.elements=new Set,this.mutationObserver=new MutationObserver((t=>this.processMutations(t)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(t){this.started&&(this.mutationObserver.disconnect(),this.started=!1),t(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){const t=new Set(this.matchElementsInTree());for(const e of Array.from(this.elements))t.has(e)||this.removeElement(e);for(const e of Array.from(t))this.addElement(e)}}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){"attributes"==t.type?this.processAttributeChange(t.target,t.attributeName):"childList"==t.type&&(this.processRemovedNodes(t.removedNodes),this.processAddedNodes(t.addedNodes))}processAttributeChange(t,e){const r=t;this.elements.has(r)?this.delegate.elementAttributeChanged&&this.matchElement(r)?this.delegate.elementAttributeChanged(r,e):this.removeElement(r):this.matchElement(r)&&this.addElement(r)}processRemovedNodes(t){for(const e of Array.from(t)){const t=this.elementFromNode(e);t&&this.processTree(t,this.removeElement)}}processAddedNodes(t){for(const e of Array.from(t)){const t=this.elementFromNode(e);t&&this.elementIsActive(t)&&this.processTree(t,this.addElement)}}matchElement(t){return this.delegate.matchElement(t)}matchElementsInTree(t=this.element){return this.delegate.matchElementsInTree(t)}processTree(t,e){for(const r of this.matchElementsInTree(t))e.call(this,r)}elementFromNode(t){if(t.nodeType==Node.ELEMENT_NODE)return t}elementIsActive(t){return t.isConnected==this.element.isConnected&&this.element.contains(t)}addElement(t){this.elements.has(t)||this.elementIsActive(t)&&(this.elements.add(t),this.delegate.elementMatched&&this.delegate.elementMatched(t))}removeElement(t){this.elements.has(t)&&(this.elements.delete(t),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(t))}}class v{constructor(t,e,r){this.attributeName=e,this.delegate=r,this.elementObserver=new d(t,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(t){this.elementObserver.pause(t)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(t){return t.hasAttribute(this.attributeName)}matchElementsInTree(t){const e=this.matchElement(t)?[t]:[],r=Array.from(t.querySelectorAll(this.selector));return e.concat(r)}elementMatched(t){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(t,this.attributeName)}elementUnmatched(t){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(t,this.attributeName)}elementAttributeChanged(t,e){this.delegate.elementAttributeValueChanged&&this.attributeName==e&&this.delegate.elementAttributeValueChanged(t,e)}}class g{constructor(t,e){this.element=t,this.delegate=e,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver((t=>this.processMutations(t)))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(const t of this.knownAttributeNames)this.refreshAttribute(t,null)}processMutations(t){if(this.started)for(const e of t)this.processMutation(e)}processMutation(t){const e=t.attributeName;e&&this.refreshAttribute(e,t.oldValue)}refreshAttribute(t,e){const r=this.delegate.getStringMapKeyForAttribute(t);if(null!=r){this.stringMap.has(t)||this.stringMapKeyAdded(r,t);const n=this.element.getAttribute(t);if(this.stringMap.get(t)!=n&&this.stringMapValueChanged(n,r,e),null==n){const e=this.stringMap.get(t);this.stringMap.delete(t),e&&this.stringMapKeyRemoved(r,t,e)}else this.stringMap.set(t,n)}}stringMapKeyAdded(t,e){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(t,e)}stringMapValueChanged(t,e,r){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(t,e,r)}stringMapKeyRemoved(t,e,r){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(t,e,r)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map((t=>t.name))}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}}function y(t,e,r){b(t,e).add(r)}function m(t,e,r){b(t,e).delete(r),x(t,e)}function b(t,e){let r=t.get(e);return r||(r=new Set,t.set(e,r)),r}function x(t,e){const r=t.get(e);null!=r&&0==r.size&&t.delete(e)}class w{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce(((t,e)=>t.concat(Array.from(e))),[])}get size(){return Array.from(this.valuesByKey.values()).reduce(((t,e)=>t+e.size),0)}add(t,e){y(this.valuesByKey,t,e)}delete(t,e){m(this.valuesByKey,t,e)}has(t,e){const r=this.valuesByKey.get(t);return null!=r&&r.has(e)}hasKey(t){return this.valuesByKey.has(t)}hasValue(t){return Array.from(this.valuesByKey.values()).some((e=>e.has(t)))}getValuesForKey(t){const e=this.valuesByKey.get(t);return e?Array.from(e):[]}getKeysForValue(t){return Array.from(this.valuesByKey).filter((([e,r])=>r.has(t))).map((([t,e])=>t))}}class O extends w{constructor(){super(),this.keysByValue=new Map}get values(){return Array.from(this.keysByValue.keys())}add(t,e){super.add(t,e),y(this.keysByValue,e,t)}delete(t,e){super.delete(t,e),m(this.keysByValue,e,t)}hasValue(t){return this.keysByValue.has(t)}getKeysForValue(t){const e=this.keysByValue.get(t);return e?Array.from(e):[]}}class E{constructor(t,e,r){this.attributeObserver=new v(t,e,this),this.delegate=r,this.tokensByElement=new w}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(t){this.attributeObserver.pause(t)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(t){this.tokensMatched(this.readTokensForElement(t))}elementAttributeValueChanged(t){const[e,r]=this.refreshTokensForElement(t);this.tokensUnmatched(e),this.tokensMatched(r)}elementUnmatchedAttribute(t){this.tokensUnmatched(this.tokensByElement.getValuesForKey(t))}tokensMatched(t){t.forEach((t=>this.tokenMatched(t)))}tokensUnmatched(t){t.forEach((t=>this.tokenUnmatched(t)))}tokenMatched(t){this.delegate.tokenMatched(t),this.tokensByElement.add(t.element,t)}tokenUnmatched(t){this.delegate.tokenUnmatched(t),this.tokensByElement.delete(t.element,t)}refreshTokensForElement(t){const e=this.tokensByElement.getValuesForKey(t),r=this.readTokensForElement(t),n=function(t,e){const r=Math.max(t.length,e.length);return Array.from({length:r},((r,n)=>[t[n],e[n]]))}(e,r).findIndex((([t,e])=>{return n=e,!((r=t)&&n&&r.index==n.index&&r.content==n.content);var r,n}));return-1==n?[[],[]]:[e.slice(n),r.slice(n)]}readTokensForElement(t){const e=this.attributeName;return function(t,e,r){return t.trim().split(/\s+/).filter((t=>t.length)).map(((t,n)=>({element:e,attributeName:r,content:t,index:n})))}(t.getAttribute(e)||"",t,e)}}class S{constructor(t,e,r){this.tokenListObserver=new E(t,e,this),this.delegate=r,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(t){const{element:e}=t,{value:r}=this.fetchParseResultForToken(t);r&&(this.fetchValuesByTokenForElement(e).set(t,r),this.delegate.elementMatchedValue(e,r))}tokenUnmatched(t){const{element:e}=t,{value:r}=this.fetchParseResultForToken(t);r&&(this.fetchValuesByTokenForElement(e).delete(t),this.delegate.elementUnmatchedValue(e,r))}fetchParseResultForToken(t){let e=this.parseResultsByToken.get(t);return e||(e=this.parseToken(t),this.parseResultsByToken.set(t,e)),e}fetchValuesByTokenForElement(t){let e=this.valuesByTokenByElement.get(t);return e||(e=new Map,this.valuesByTokenByElement.set(t,e)),e}parseToken(t){try{return{value:this.delegate.parseValueForToken(t)}}catch(t){return{error:t}}}}class A{constructor(t,e){this.context=t,this.delegate=e,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new S(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(t){const e=new p(this.context,t);this.bindingsByAction.set(t,e),this.delegate.bindingConnected(e)}disconnectAction(t){const e=this.bindingsByAction.get(t);e&&(this.bindingsByAction.delete(t),this.delegate.bindingDisconnected(e))}disconnectAllActions(){this.bindings.forEach((t=>this.delegate.bindingDisconnected(t))),this.bindingsByAction.clear()}parseValueForToken(t){const e=class{constructor(t,e,r){this.element=t,this.index=e,this.eventTarget=r.eventTarget||t,this.eventName=r.eventName||function(t){const e=t.tagName.toLowerCase();if(e in l)return l[e](t)}(t)||h("missing event name"),this.eventOptions=r.eventOptions||{},this.identifier=r.identifier||h("missing identifier"),this.methodName=r.methodName||h("missing method name")}static forToken(t){return new this(t.element,t.index,function(t){const e=t.trim().match(i)||[];return{eventTarget:s(e[4]),eventName:e[2],eventOptions:e[9]?(r=e[9],r.split(":").reduce(((t,e)=>Object.assign(t,{[e.replace(/^!/,"")]:!/^!/.test(e)})),{})):{},identifier:e[5],methodName:e[7]};var r}(t.content))}toString(){const t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${t}->${this.identifier}#${this.methodName}`}get params(){const t={},e=new RegExp(`^data-${this.identifier}-(.+)-param$`);for(const{name:r,value:n}of Array.from(this.element.attributes)){const o=r.match(e),i=o&&o[1];i&&(t[a(i)]=f(n))}return t}get eventTargetName(){return(t=this.eventTarget)==window?"window":t==document?"document":void 0;var t}}.forToken(t);if(e.identifier==this.identifier)return e}elementMatchedValue(t,e){this.connectAction(e)}elementUnmatchedValue(t,e){this.disconnectAction(e)}}class k{constructor(t,e){this.context=t,this.receiver=e,this.stringMapObserver=new g(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(t){if(t in this.valueDescriptorMap)return this.valueDescriptorMap[t].name}stringMapKeyAdded(t,e){const r=this.valueDescriptorMap[e];this.hasValue(t)||this.invokeChangedCallback(t,r.writer(this.receiver[t]),r.writer(r.defaultValue))}stringMapValueChanged(t,e,r){const n=this.valueDescriptorNameMap[e];null!==t&&(null===r&&(r=n.writer(n.defaultValue)),this.invokeChangedCallback(e,t,r))}stringMapKeyRemoved(t,e,r){const n=this.valueDescriptorNameMap[t];this.hasValue(t)?this.invokeChangedCallback(t,n.writer(this.receiver[t]),r):this.invokeChangedCallback(t,n.writer(n.defaultValue),r)}invokeChangedCallbacksForDefaultValues(){for(const{key:t,name:e,defaultValue:r,writer:n}of this.valueDescriptors)null==r||this.controller.data.has(t)||this.invokeChangedCallback(e,n(r),void 0)}invokeChangedCallback(t,e,r){const n=`${t}Changed`,o=this.receiver[n];if("function"==typeof o){const n=this.valueDescriptorNameMap[t];try{const t=n.reader(e);let i=r;r&&(i=n.reader(r)),o.call(this.receiver,t,i)}catch(t){if(!(t instanceof TypeError))throw t;throw new TypeError(`Stimulus Value "${this.context.identifier}.${n.name}" - ${t.message}`)}}}get valueDescriptors(){const{valueDescriptorMap:t}=this;return Object.keys(t).map((e=>t[e]))}get valueDescriptorNameMap(){const t={};return Object.keys(this.valueDescriptorMap).forEach((e=>{const r=this.valueDescriptorMap[e];t[r.name]=r})),t}hasValue(t){const e=`has${c(this.valueDescriptorNameMap[t].name)}`;return this.receiver[e]}}class j{constructor(t,e){this.context=t,this.delegate=e,this.targetsByName=new w}start(){this.tokenListObserver||(this.tokenListObserver=new E(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:t,content:e}){this.scope.containsElement(t)&&this.connectTarget(t,e)}tokenUnmatched({element:t,content:e}){this.disconnectTarget(t,e)}connectTarget(t,e){var r;this.targetsByName.has(e,t)||(this.targetsByName.add(e,t),null===(r=this.tokenListObserver)||void 0===r||r.pause((()=>this.delegate.targetConnected(t,e))))}disconnectTarget(t,e){var r;this.targetsByName.has(e,t)&&(this.targetsByName.delete(e,t),null===(r=this.tokenListObserver)||void 0===r||r.pause((()=>this.delegate.targetDisconnected(t,e))))}disconnectAllTargets(){for(const t of this.targetsByName.keys)for(const e of this.targetsByName.getValuesForKey(t))this.disconnectTarget(e,t)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}}class T{constructor(t,e){this.logDebugActivity=(t,e={})=>{const{identifier:r,controller:n,element:o}=this;e=Object.assign({identifier:r,controller:n,element:o},e),this.application.logDebugActivity(this.identifier,t,e)},this.module=t,this.scope=e,this.controller=new t.controllerConstructor(this),this.bindingObserver=new A(this,this.dispatcher),this.valueObserver=new k(this,this.controller),this.targetObserver=new j(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(t){this.handleError(t,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(t){this.handleError(t,"connecting controller")}}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(t){this.handleError(t,"disconnecting controller")}this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(t,e,r={}){const{identifier:n,controller:o,element:i}=this;r=Object.assign({identifier:n,controller:o,element:i},r),this.application.handleError(t,`Error ${e}`,r)}targetConnected(t,e){this.invokeControllerMethod(`${e}TargetConnected`,t)}targetDisconnected(t,e){this.invokeControllerMethod(`${e}TargetDisconnected`,t)}invokeControllerMethod(t,...e){const r=this.controller;"function"==typeof r[t]&&r[t](...e)}}function F(t,e){const r=L(t);return Array.from(r.reduce(((t,r)=>(function(t,e){const r=t[e];return Array.isArray(r)?r:[]}(r,e).forEach((e=>t.add(e))),t)),new Set))}function M(t,e){return L(t).reduce(((t,r)=>(t.push(...function(t,e){const r=t[e];return r?Object.keys(r).map((t=>[t,r[t]])):[]}(r,e)),t)),[])}function L(t){const e=[];for(;t;)e.push(t),t=Object.getPrototypeOf(t);return e.reverse()}function C(t){return function(t,e){const r=N(t),n=function(t,e){return P(e).reduce(((r,n)=>{const o=function(t,e,r){const n=Object.getOwnPropertyDescriptor(t,r);if(!n||!("value"in n)){const t=Object.getOwnPropertyDescriptor(e,r).value;return n&&(t.get=n.get||t.get,t.set=n.set||t.set),t}}(t,e,n);return o&&Object.assign(r,{[n]:o}),r}),{})}(t.prototype,e);return Object.defineProperties(r.prototype,n),r}(t,function(t){return F(t,"blessings").reduce(((e,r)=>{const n=r(t);for(const t in n){const r=e[t]||{};e[t]=Object.assign(r,n[t])}return e}),{})}(t))}const P="function"==typeof Object.getOwnPropertySymbols?t=>[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)]:Object.getOwnPropertyNames,N=(()=>{function t(t){function e(){return Reflect.construct(t,arguments,new.target)}return e.prototype=Object.create(t.prototype,{constructor:{value:e}}),Reflect.setPrototypeOf(e,t),e}try{return function(){const e=t((function(){this.a.call(this)}));e.prototype.a=function(){},new e}(),t}catch(t){return t=>class extends t{}}})();class R{constructor(t,e){this.application=t,this.definition=function(t){return{identifier:t.identifier,controllerConstructor:C(t.controllerConstructor)}}(e),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(t){const e=this.fetchContextForScope(t);this.connectedContexts.add(e),e.connect()}disconnectContextForScope(t){const e=this.contextsByScope.get(t);e&&(this.connectedContexts.delete(e),e.disconnect())}fetchContextForScope(t){let e=this.contextsByScope.get(t);return e||(e=new T(this,t),this.contextsByScope.set(t,e)),e}}class I{constructor(t){this.scope=t}has(t){return this.data.has(this.getDataKey(t))}get(t){return this.getAll(t)[0]}getAll(t){const e=this.data.get(this.getDataKey(t))||"";return e.match(/[^\s]+/g)||[]}getAttributeName(t){return this.data.getAttributeNameForKey(this.getDataKey(t))}getDataKey(t){return`${t}-class`}get data(){return this.scope.data}}class D{constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(t){const e=this.getAttributeNameForKey(t);return this.element.getAttribute(e)}set(t,e){const r=this.getAttributeNameForKey(t);return this.element.setAttribute(r,e),this.get(t)}has(t){const e=this.getAttributeNameForKey(t);return this.element.hasAttribute(e)}delete(t){if(this.has(t)){const e=this.getAttributeNameForKey(t);return this.element.removeAttribute(e),!0}return!1}getAttributeNameForKey(t){return`data-${this.identifier}-${u(t)}`}}class B{constructor(t){this.warnedKeysByObject=new WeakMap,this.logger=t}warn(t,e,r){let n=this.warnedKeysByObject.get(t);n||(n=new Set,this.warnedKeysByObject.set(t,n)),n.has(e)||(n.add(e),this.logger.warn(r,t))}}function _(t,e){return`[${t}~="${e}"]`}class ${constructor(t){this.scope=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(t){return null!=this.find(t)}find(...t){return t.reduce(((t,e)=>t||this.findTarget(e)||this.findLegacyTarget(e)),void 0)}findAll(...t){return t.reduce(((t,e)=>[...t,...this.findAllTargets(e),...this.findAllLegacyTargets(e)]),[])}findTarget(t){const e=this.getSelectorForTargetName(t);return this.scope.findElement(e)}findAllTargets(t){const e=this.getSelectorForTargetName(t);return this.scope.findAllElements(e)}getSelectorForTargetName(t){return _(this.schema.targetAttributeForScope(this.identifier),t)}findLegacyTarget(t){const e=this.getLegacySelectorForTargetName(t);return this.deprecate(this.scope.findElement(e),t)}findAllLegacyTargets(t){const e=this.getLegacySelectorForTargetName(t);return this.scope.findAllElements(e).map((e=>this.deprecate(e,t)))}getLegacySelectorForTargetName(t){const e=`${this.identifier}.${t}`;return _(this.schema.targetAttribute,e)}deprecate(t,e){if(t){const{identifier:r}=this,n=this.schema.targetAttribute,o=this.schema.targetAttributeForScope(r);this.guide.warn(t,`target:${e}`,`Please replace ${n}="${r}.${e}" with ${o}="${e}". The ${n} attribute is deprecated and will be removed in a future version of Stimulus.`)}return t}get guide(){return this.scope.guide}}class V{constructor(t,e,r,n){this.targets=new $(this),this.classes=new I(this),this.data=new D(this),this.containsElement=t=>t.closest(this.controllerSelector)===this.element,this.schema=t,this.element=e,this.identifier=r,this.guide=new B(n)}findElement(t){return this.element.matches(t)?this.element:this.queryElements(t).find(this.containsElement)}findAllElements(t){return[...this.element.matches(t)?[this.element]:[],...this.queryElements(t).filter(this.containsElement)]}queryElements(t){return Array.from(this.element.querySelectorAll(t))}get controllerSelector(){return _(this.schema.controllerAttribute,this.identifier)}}class U{constructor(t,e,r){this.element=t,this.schema=e,this.delegate=r,this.valueListObserver=new S(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(t){const{element:e,content:r}=t,n=this.fetchScopesByIdentifierForElement(e);let o=n.get(r);return o||(o=this.delegate.createScopeForElementAndIdentifier(e,r),n.set(r,o)),o}elementMatchedValue(t,e){const r=(this.scopeReferenceCounts.get(e)||0)+1;this.scopeReferenceCounts.set(e,r),1==r&&this.delegate.scopeConnected(e)}elementUnmatchedValue(t,e){const r=this.scopeReferenceCounts.get(e);r&&(this.scopeReferenceCounts.set(e,r-1),1==r&&this.delegate.scopeDisconnected(e))}fetchScopesByIdentifierForElement(t){let e=this.scopesByIdentifierByElement.get(t);return e||(e=new Map,this.scopesByIdentifierByElement.set(t,e)),e}}class K{constructor(t){this.application=t,this.scopeObserver=new U(this.element,this.schema,this),this.scopesByIdentifier=new w,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce(((t,e)=>t.concat(e.contexts)),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(t){this.unloadIdentifier(t.identifier);const e=new R(this.application,t);this.connectModule(e)}unloadIdentifier(t){const e=this.modulesByIdentifier.get(t);e&&this.disconnectModule(e)}getContextForElementAndIdentifier(t,e){const r=this.modulesByIdentifier.get(e);if(r)return r.contexts.find((e=>e.element==t))}handleError(t,e,r){this.application.handleError(t,e,r)}createScopeForElementAndIdentifier(t,e){return new V(this.schema,t,e,this.logger)}scopeConnected(t){this.scopesByIdentifier.add(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.connectContextForScope(t)}scopeDisconnected(t){this.scopesByIdentifier.delete(t.identifier,t);const e=this.modulesByIdentifier.get(t.identifier);e&&e.disconnectContextForScope(t)}connectModule(t){this.modulesByIdentifier.set(t.identifier,t);this.scopesByIdentifier.getValuesForKey(t.identifier).forEach((e=>t.connectContextForScope(e)))}disconnectModule(t){this.modulesByIdentifier.delete(t.identifier);this.scopesByIdentifier.getValuesForKey(t.identifier).forEach((e=>t.disconnectContextForScope(e)))}}const G={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:t=>`data-${t}-target`};class z{constructor(t=document.documentElement,e=G){this.logger=console,this.debug=!1,this.logDebugActivity=(t,e,r={})=>{this.debug&&this.logFormattedMessage(t,e,r)},this.element=t,this.schema=e,this.dispatcher=new o(this),this.router=new K(this)}static start(t,e){const r=new z(t,e);return r.start(),r}async start(){await new Promise((t=>{"loading"==document.readyState?document.addEventListener("DOMContentLoaded",(()=>t())):t()})),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(t,e){this.load({identifier:t,controllerConstructor:e})}load(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>{t.controllerConstructor.shouldLoad&&this.router.loadDefinition(t)}))}unload(t,...e){(Array.isArray(t)?t:[t,...e]).forEach((t=>this.router.unloadIdentifier(t)))}get controllers(){return this.router.contexts.map((t=>t.controller))}getControllerForElementAndIdentifier(t,e){const r=this.router.getContextForElementAndIdentifier(t,e);return r?r.controller:null}handleError(t,e,r){var n;this.logger.error("%s\n\n%o\n\n%o",e,t,r),null===(n=window.onerror)||void 0===n||n.call(window,e,"",0,0,t)}logFormattedMessage(t,e,r={}){r=Object.assign({application:this},r),this.logger.groupCollapsed(`${t} #${e}`),this.logger.log("details:",Object.assign({},r)),this.logger.groupEnd()}}function q([t,e],r){return function(t){const e=`${u(t.token)}-value`,r=function(t){const e=function(t){const e=W(t.typeObject.type);if(!e)return;const r=J(t.typeObject.default);if(e!==r){const n=t.controller?`${t.controller}.${t.token}`:t.token;throw new Error(`The specified default value for the Stimulus Value "${n}" must match the defined type "${e}". The provided default value of "${t.typeObject.default}" is of type "${r}".`)}return e}({controller:t.controller,token:t.token,typeObject:t.typeDefinition}),r=J(t.typeDefinition),n=W(t.typeDefinition),o=e||r||n;if(o)return o;const i=t.controller?`${t.controller}.${t.typeDefinition}`:t.token;throw new Error(`Unknown value type "${i}" for "${t.token}" value`)}(t);return{type:r,key:e,name:a(e),get defaultValue(){return function(t){const e=W(t);if(e)return H[e];const r=t.default;return void 0!==r?r:t}(t.typeDefinition)},get hasCustomDefaultValue(){return void 0!==J(t.typeDefinition)},reader:Y[r],writer:Q[r]||Q.default}}({controller:r,token:t,typeDefinition:e})}function W(t){switch(t){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function J(t){switch(typeof t){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}return Array.isArray(t)?"array":"[object Object]"===Object.prototype.toString.call(t)?"object":void 0}const H={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Y={array(t){const e=JSON.parse(t);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${t}" of type "${J(e)}"`);return e},boolean:t=>!("0"==t||"false"==String(t).toLowerCase()),number:t=>Number(t),object(t){const e=JSON.parse(t);if(null===e||"object"!=typeof e||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${t}" of type "${J(e)}"`);return e},string:t=>t},Q={default:function(t){return`${t}`},array:X,object:X};function X(t){return JSON.stringify(t)}class Z{constructor(t){this.context=t}static get shouldLoad(){return!0}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(t,{target:e=this.element,detail:r={},prefix:n=this.identifier,bubbles:o=!0,cancelable:i=!0}={}){const s=new CustomEvent(n?`${n}:${t}`:t,{detail:r,bubbles:o,cancelable:i});return e.dispatchEvent(s),s}}Z.blessings=[function(t){return F(t,"classes").reduce(((t,e)=>{return Object.assign(t,{[`${r=e}Class`]:{get(){const{classes:t}=this;if(t.has(r))return t.get(r);{const e=t.getAttributeName(r);throw new Error(`Missing attribute "${e}"`)}}},[`${r}Classes`]:{get(){return this.classes.getAll(r)}},[`has${c(r)}Class`]:{get(){return this.classes.has(r)}}});var r}),{})},function(t){return F(t,"targets").reduce(((t,e)=>{return Object.assign(t,{[`${r=e}Target`]:{get(){const t=this.targets.find(r);if(t)return t;throw new Error(`Missing target element "${r}" for "${this.identifier}" controller`)}},[`${r}Targets`]:{get(){return this.targets.findAll(r)}},[`has${c(r)}Target`]:{get(){return this.targets.has(r)}}});var r}),{})},function(t){const e=M(t,"values"),r={valueDescriptorMap:{get(){return e.reduce(((t,e)=>{const r=q(e,this.identifier),n=this.data.getAttributeNameForKey(r.key);return Object.assign(t,{[n]:r})}),{})}}};return e.reduce(((t,e)=>Object.assign(t,function(t,e){const r=q(t,e),{key:n,name:o,reader:i,writer:s}=r;return{[o]:{get(){const t=this.data.get(n);return null!==t?i(t):r.defaultValue},set(t){void 0===t?this.data.delete(n):this.data.set(n,s(t))}},[`has${c(o)}`]:{get(){return this.data.has(n)||r.hasCustomDefaultValue}}}}(e))),r)}],Z.targets=[],Z.values={}},345:function(t,e,r){"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(){o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},s=i.iterator||"@@iterator",a=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof p?e:p,i=Object.create(o.prototype),s=new A(n||[]);return i._invoke=function(t,e,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return j()}for(r.method=o,r.arg=i;;){var s=r.delegate;if(s){var a=O(s,r);if(a){if(a===f)continue;return a}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(t,r,s),i}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var f={};function p(){}function d(){}function v(){}var g={};u(g,s,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(k([])));m&&m!==e&&r.call(m,s)&&(g=m);var b=v.prototype=p.prototype=Object.create(g);function x(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){function o(i,s,a,c){var u=h(t[i],t,s);if("throw"!==u.type){var l=u.arg,f=l.value;return f&&"object"==n(f)&&r.call(f,"__await")?e.resolve(f.__await).then((function(t){o("next",t,a,c)}),(function(t){o("throw",t,a,c)})):e.resolve(f).then((function(t){l.value=t,a(l)}),(function(t){return o("throw",t,a,c)}))}c(u.arg)}var i;this._invoke=function(t,r){function n(){return new e((function(e,n){o(t,r,e,n)}))}return i=i?i.then(n,n):n()}}function O(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method))return f;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,f;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function A(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n=0;--o){var i=this.tryEntries[o],s=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var a=r.call(i,"catchLoc"),c=r.call(i,"finallyLoc");if(a&&c){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),S(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;S(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:k(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function i(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function s(t,e){for(var r=0;r0;)this.input.remove(0)}},{key:"setOptions",value:function(t,e){var r=this.input;if(!(0,p.isTomSelect)(r))return e&&r.options.add(new Option("","")),void t.forEach((function(t){r.options.add(new Option(t.text,t.value))}));var n=r.tomselect;n.addOptions(t),n.refreshOptions(!1),n.unlock()}}])&&s(e.prototype,r),n&&s(e,n),Object.defineProperty(e,"prototype",{writable:!1}),l}(f.Controller);e.default=v},8232:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function i(t,e){for(var r=0;r{"use strict";r.r(e),r.d(e,{app:()=>s});var n=r(6599);const o={};function i(t){return t.keys().map((e=>function(t,e){const r=function(t){const e=(t.match(/^(?:\.\/)?(.+)(?:[_-]controller\..+?)$/)||[])[1];if(e)return e.replace(/_/g,"-").replace(/\//g,"--")}(e);if(r)return function(t,e){const r=t.default;if("function"==typeof r)return{identifier:e,controllerConstructor:r}}(t(e),r)}(t,e))).filter((t=>t))}var s=function(t){const e=n.Application.start();t&&e.load(i(t));for(const t in o)o.hasOwnProperty(t)&&o[t].then((r=>{e.register(t,r.default)}));return e}(r(4180))},718:(t,e,r)=>{"use strict";r(9070),r(1038),r(8783),r(6992),r(1539),r(189),r(3948),Object.defineProperty(e,"__esModule",{value:!0}),e.removeDuplicates=void 0;e.removeDuplicates=function(t){return Array.from(new Set(t))}},4415:(t,e,r)=>{"use strict";r(9070),Object.defineProperty(e,"__esModule",{value:!0}),e.getCallbackUrl=e.getOptions=void 0;e.getOptions=function(t){var e=t.getAttribute("data-dependent-field-options");return e?JSON.parse(e):{callback_url:"",dependencies:[],fetch_on_init:!1}};e.getCallbackUrl=function(t){return t.getAttribute("data-dependent-field-callback-url")}},6218:(t,e,r)=>{"use strict";function n(t){return function(t){if(Array.isArray(t))return o(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r{"use strict";r(9070),r(9554),r(1539),r(4747),r(6699),r(9826),r(7327),r(2023),Object.defineProperty(e,"__esModule",{value:!0}),e.getMapElements=e.getMapElement=e.getMapFields=e.getMap=void 0;e.getMap=function(t){var e=t.getAttribute("data-mask-field-map");return e?JSON.parse(e):[]};e.getMapFields=function(t){var e=[];return t.forEach((function(t){t.fields.forEach((function(t){e.includes(t)||e.push(t)}))})),e};e.getMapElement=function(t,e){return e.find((function(e){return e.value==t}))};e.getMapElements=function(t,e){return e.filter((function(e){return t.includes(e.value)}))}},9662:(t,e,r)=>{var n=r(614),o=r(6330),i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not a function")}},9483:(t,e,r)=>{var n=r(4411),o=r(6330),i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not a constructor")}},6077:(t,e,r)=>{var n=r(614),o=String,i=TypeError;t.exports=function(t){if("object"==typeof t||n(t))return t;throw i("Can't set "+o(t)+" as a prototype")}},1223:(t,e,r)=>{var n=r(5112),o=r(30),i=r(3070).f,s=n("unscopables"),a=Array.prototype;null==a[s]&&i(a,s,{configurable:!0,value:o(null)}),t.exports=function(t){a[s][t]=!0}},5787:(t,e,r)=>{var n=r(7976),o=TypeError;t.exports=function(t,e){if(n(e,t))return t;throw o("Incorrect invocation")}},9670:(t,e,r)=>{var n=r(111),o=String,i=TypeError;t.exports=function(t){if(n(t))return t;throw i(o(t)+" is not an object")}},7556:(t,e,r)=>{var n=r(7293);t.exports=n((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}))},8533:(t,e,r)=>{"use strict";var n=r(2092).forEach,o=r(9341)("forEach");t.exports=o?[].forEach:function(t){return n(this,t,arguments.length>1?arguments[1]:void 0)}},8457:(t,e,r)=>{"use strict";var n=r(9974),o=r(6916),i=r(7908),s=r(3411),a=r(7659),c=r(4411),u=r(6244),l=r(6135),h=r(4121),f=r(1246),p=Array;t.exports=function(t){var e=i(t),r=c(this),d=arguments.length,v=d>1?arguments[1]:void 0,g=void 0!==v;g&&(v=n(v,d>2?arguments[2]:void 0));var y,m,b,x,w,O,E=f(e),S=0;if(!E||this===p&&a(E))for(y=u(e),m=r?new this(y):p(y);y>S;S++)O=g?v(e[S],S):e[S],l(m,S,O);else for(w=(x=h(e,E)).next,m=r?new this:[];!(b=o(w,x)).done;S++)O=g?s(x,v,[b.value,S],!0):b.value,l(m,S,O);return m.length=S,m}},1318:(t,e,r)=>{var n=r(5656),o=r(1400),i=r(6244),s=function(t){return function(e,r,s){var a,c=n(e),u=i(c),l=o(s,u);if(t&&r!=r){for(;u>l;)if((a=c[l++])!=a)return!0}else for(;u>l;l++)if((t||l in c)&&c[l]===r)return t||l||0;return!t&&-1}};t.exports={includes:s(!0),indexOf:s(!1)}},2092:(t,e,r)=>{var n=r(9974),o=r(1702),i=r(8361),s=r(7908),a=r(6244),c=r(5417),u=o([].push),l=function(t){var e=1==t,r=2==t,o=3==t,l=4==t,h=6==t,f=7==t,p=5==t||h;return function(d,v,g,y){for(var m,b,x=s(d),w=i(x),O=n(v,g),E=a(w),S=0,A=y||c,k=e?A(d,E):r||f?A(d,0):void 0;E>S;S++)if((p||S in w)&&(b=O(m=w[S],S,x),t))if(e)k[S]=b;else if(b)switch(t){case 3:return!0;case 5:return m;case 6:return S;case 2:u(k,m)}else switch(t){case 4:return!1;case 7:u(k,m)}return h?-1:o||l?l:k}};t.exports={forEach:l(0),map:l(1),filter:l(2),some:l(3),every:l(4),find:l(5),findIndex:l(6),filterReject:l(7)}},1194:(t,e,r)=>{var n=r(7293),o=r(5112),i=r(7392),s=o("species");t.exports=function(t){return i>=51||!n((function(){var e=[];return(e.constructor={})[s]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}},9341:(t,e,r)=>{"use strict";var n=r(7293);t.exports=function(t,e){var r=[][t];return!!r&&n((function(){r.call(null,e||function(){return 1},1)}))}},1589:(t,e,r)=>{var n=r(1400),o=r(6244),i=r(6135),s=Array,a=Math.max;t.exports=function(t,e,r){for(var c=o(t),u=n(e,c),l=n(void 0===r?c:r,c),h=s(a(l-u,0)),f=0;u{var n=r(1702);t.exports=n([].slice)},4362:(t,e,r)=>{var n=r(1589),o=Math.floor,i=function(t,e){var r=t.length,c=o(r/2);return r<8?s(t,e):a(t,i(n(t,0,c),e),i(n(t,c),e),e)},s=function(t,e){for(var r,n,o=t.length,i=1;i0;)t[n]=t[--n];n!==i++&&(t[n]=r)}return t},a=function(t,e,r,n){for(var o=e.length,i=r.length,s=0,a=0;s{var n=r(3157),o=r(4411),i=r(111),s=r(5112)("species"),a=Array;t.exports=function(t){var e;return n(t)&&(e=t.constructor,(o(e)&&(e===a||n(e.prototype))||i(e)&&null===(e=e[s]))&&(e=void 0)),void 0===e?a:e}},5417:(t,e,r)=>{var n=r(7475);t.exports=function(t,e){return new(n(t))(0===e?0:e)}},3411:(t,e,r)=>{var n=r(9670),o=r(9212);t.exports=function(t,e,r,i){try{return i?e(n(r)[0],r[1]):e(r)}catch(e){o(t,"throw",e)}}},7072:(t,e,r)=>{var n=r(5112)("iterator"),o=!1;try{var i=0,s={next:function(){return{done:!!i++}},return:function(){o=!0}};s[n]=function(){return this},Array.from(s,(function(){throw 2}))}catch(t){}t.exports=function(t,e){if(!e&&!o)return!1;var r=!1;try{var i={};i[n]=function(){return{next:function(){return{done:r=!0}}}},t(i)}catch(t){}return r}},4326:(t,e,r)=>{var n=r(1702),o=n({}.toString),i=n("".slice);t.exports=function(t){return i(o(t),8,-1)}},648:(t,e,r)=>{var n=r(1694),o=r(614),i=r(4326),s=r(5112)("toStringTag"),a=Object,c="Arguments"==i(function(){return arguments}());t.exports=n?i:function(t){var e,r,n;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(r=function(t,e){try{return t[e]}catch(t){}}(e=a(t),s))?r:c?i(e):"Object"==(n=i(e))&&o(e.callee)?"Arguments":n}},5631:(t,e,r)=>{"use strict";var n=r(3070).f,o=r(30),i=r(9190),s=r(9974),a=r(5787),c=r(8554),u=r(408),l=r(1656),h=r(6178),f=r(6340),p=r(9781),d=r(2423).fastKey,v=r(9909),g=v.set,y=v.getterFor;t.exports={getConstructor:function(t,e,r,l){var h=t((function(t,n){a(t,f),g(t,{type:e,index:o(null),first:void 0,last:void 0,size:0}),p||(t.size=0),c(n)||u(n,t[l],{that:t,AS_ENTRIES:r})})),f=h.prototype,v=y(e),m=function(t,e,r){var n,o,i=v(t),s=b(t,e);return s?s.value=r:(i.last=s={index:o=d(e,!0),key:e,value:r,previous:n=i.last,next:void 0,removed:!1},i.first||(i.first=s),n&&(n.next=s),p?i.size++:t.size++,"F"!==o&&(i.index[o]=s)),t},b=function(t,e){var r,n=v(t),o=d(e);if("F"!==o)return n.index[o];for(r=n.first;r;r=r.next)if(r.key==e)return r};return i(f,{clear:function(){for(var t=v(this),e=t.index,r=t.first;r;)r.removed=!0,r.previous&&(r.previous=r.previous.next=void 0),delete e[r.index],r=r.next;t.first=t.last=void 0,p?t.size=0:this.size=0},delete:function(t){var e=this,r=v(e),n=b(e,t);if(n){var o=n.next,i=n.previous;delete r.index[n.index],n.removed=!0,i&&(i.next=o),o&&(o.previous=i),r.first==n&&(r.first=o),r.last==n&&(r.last=i),p?r.size--:e.size--}return!!n},forEach:function(t){for(var e,r=v(this),n=s(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:r.first;)for(n(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!b(this,t)}}),i(f,r?{get:function(t){var e=b(this,t);return e&&e.value},set:function(t,e){return m(this,0===t?0:t,e)}}:{add:function(t){return m(this,t=0===t?0:t,t)}}),p&&n(f,"size",{get:function(){return v(this).size}}),h},setStrong:function(t,e,r){var n=e+" Iterator",o=y(e),i=y(n);l(t,e,(function(t,e){g(this,{type:n,target:t,state:o(t),kind:e,last:void 0})}),(function(){for(var t=i(this),e=t.kind,r=t.last;r&&r.removed;)r=r.previous;return t.target&&(t.last=r=r?r.next:t.state.first)?h("keys"==e?r.key:"values"==e?r.value:[r.key,r.value],!1):(t.target=void 0,h(void 0,!0))}),r?"entries":"values",!r,!0),f(e)}}},7710:(t,e,r)=>{"use strict";var n=r(2109),o=r(7854),i=r(1702),s=r(4705),a=r(8052),c=r(2423),u=r(408),l=r(5787),h=r(614),f=r(8554),p=r(111),d=r(7293),v=r(7072),g=r(8003),y=r(9587);t.exports=function(t,e,r){var m=-1!==t.indexOf("Map"),b=-1!==t.indexOf("Weak"),x=m?"set":"add",w=o[t],O=w&&w.prototype,E=w,S={},A=function(t){var e=i(O[t]);a(O,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(b&&!p(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return b&&!p(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(b&&!p(t))&&e(this,0===t?0:t)}:function(t,r){return e(this,0===t?0:t,r),this})};if(s(t,!h(w)||!(b||O.forEach&&!d((function(){(new w).entries().next()})))))E=r.getConstructor(e,t,m,x),c.enable();else if(s(t,!0)){var k=new E,j=k[x](b?{}:-0,1)!=k,T=d((function(){k.has(1)})),F=v((function(t){new w(t)})),M=!b&&d((function(){for(var t=new w,e=5;e--;)t[x](e,e);return!t.has(-0)}));F||((E=e((function(t,e){l(t,O);var r=y(new w,t,E);return f(e)||u(e,r[x],{that:r,AS_ENTRIES:m}),r}))).prototype=O,O.constructor=E),(T||M)&&(A("delete"),A("has"),m&&A("get")),(M||j)&&A(x),b&&O.clear&&delete O.clear}return S[t]=E,n({global:!0,constructor:!0,forced:E!=w},S),g(E,t),b||r.setStrong(E,t,m),E}},9920:(t,e,r)=>{var n=r(2597),o=r(3887),i=r(1236),s=r(3070);t.exports=function(t,e,r){for(var a=o(e),c=s.f,u=i.f,l=0;l{var n=r(5112)("match");t.exports=function(t){var e=/./;try{"/./"[t](e)}catch(r){try{return e[n]=!1,"/./"[t](e)}catch(t){}}return!1}},8544:(t,e,r)=>{var n=r(7293);t.exports=!n((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))},6178:t=>{t.exports=function(t,e){return{value:t,done:e}}},8880:(t,e,r)=>{var n=r(9781),o=r(3070),i=r(9114);t.exports=n?function(t,e,r){return o.f(t,e,i(1,r))}:function(t,e,r){return t[e]=r,t}},9114:t=>{t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},6135:(t,e,r)=>{"use strict";var n=r(4948),o=r(3070),i=r(9114);t.exports=function(t,e,r){var s=n(e);s in t?o.f(t,s,i(0,r)):t[s]=r}},8052:(t,e,r)=>{var n=r(614),o=r(3070),i=r(6339),s=r(3072);t.exports=function(t,e,r,a){a||(a={});var c=a.enumerable,u=void 0!==a.name?a.name:e;if(n(r)&&i(r,u,a),a.global)c?t[e]=r:s(e,r);else{try{a.unsafe?t[e]&&(c=!0):delete t[e]}catch(t){}c?t[e]=r:o.f(t,e,{value:r,enumerable:!1,configurable:!a.nonConfigurable,writable:!a.nonWritable})}return t}},9190:(t,e,r)=>{var n=r(8052);t.exports=function(t,e,r){for(var o in e)n(t,o,e[o],r);return t}},3072:(t,e,r)=>{var n=r(7854),o=Object.defineProperty;t.exports=function(t,e){try{o(n,t,{value:e,configurable:!0,writable:!0})}catch(r){n[t]=e}return e}},9781:(t,e,r)=>{var n=r(7293);t.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},4154:t=>{var e="object"==typeof document&&document.all,r=void 0===e&&void 0!==e;t.exports={all:e,IS_HTMLDDA:r}},317:(t,e,r)=>{var n=r(7854),o=r(111),i=n.document,s=o(i)&&o(i.createElement);t.exports=function(t){return s?i.createElement(t):{}}},7207:t=>{var e=TypeError;t.exports=function(t){if(t>9007199254740991)throw e("Maximum allowed index exceeded");return t}},8324:t=>{t.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},8509:(t,e,r)=>{var n=r(317)("span").classList,o=n&&n.constructor&&n.constructor.prototype;t.exports=o===Object.prototype?void 0:o},7871:(t,e,r)=>{var n=r(3823),o=r(5268);t.exports=!n&&!o&&"object"==typeof window&&"object"==typeof document},3823:t=>{t.exports="object"==typeof Deno&&Deno&&"object"==typeof Deno.version},1528:(t,e,r)=>{var n=r(8113),o=r(7854);t.exports=/ipad|iphone|ipod/i.test(n)&&void 0!==o.Pebble},6833:(t,e,r)=>{var n=r(8113);t.exports=/(?:ipad|iphone|ipod).*applewebkit/i.test(n)},5268:(t,e,r)=>{var n=r(4326),o=r(7854);t.exports="process"==n(o.process)},1036:(t,e,r)=>{var n=r(8113);t.exports=/web0s(?!.*chrome)/i.test(n)},8113:(t,e,r)=>{var n=r(5005);t.exports=n("navigator","userAgent")||""},7392:(t,e,r)=>{var n,o,i=r(7854),s=r(8113),a=i.process,c=i.Deno,u=a&&a.versions||c&&c.version,l=u&&u.v8;l&&(o=(n=l.split("."))[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&s&&(!(n=s.match(/Edge\/(\d+)/))||n[1]>=74)&&(n=s.match(/Chrome\/(\d+)/))&&(o=+n[1]),t.exports=o},748:t=>{t.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},2109:(t,e,r)=>{var n=r(7854),o=r(1236).f,i=r(8880),s=r(8052),a=r(3072),c=r(9920),u=r(4705);t.exports=function(t,e){var r,l,h,f,p,d=t.target,v=t.global,g=t.stat;if(r=v?n:g?n[d]||a(d,{}):(n[d]||{}).prototype)for(l in e){if(f=e[l],h=t.dontCallGetSet?(p=o(r,l))&&p.value:r[l],!u(v?l:d+(g?".":"#")+l,t.forced)&&void 0!==h){if(typeof f==typeof h)continue;c(f,h)}(t.sham||h&&h.sham)&&i(f,"sham",!0),s(r,l,f,t)}}},7293:t=>{t.exports=function(t){try{return!!t()}catch(t){return!0}}},6790:(t,e,r)=>{"use strict";var n=r(3157),o=r(6244),i=r(7207),s=r(9974),a=function(t,e,r,c,u,l,h,f){for(var p,d,v=u,g=0,y=!!h&&s(h,f);g0&&n(p)?(d=o(p),v=a(t,e,p,d,v,l-1)-1):(i(v+1),t[v]=p),v++),g++;return v};t.exports=a},6677:(t,e,r)=>{var n=r(7293);t.exports=!n((function(){return Object.isExtensible(Object.preventExtensions({}))}))},2104:(t,e,r)=>{var n=r(4374),o=Function.prototype,i=o.apply,s=o.call;t.exports="object"==typeof Reflect&&Reflect.apply||(n?s.bind(i):function(){return s.apply(i,arguments)})},9974:(t,e,r)=>{var n=r(1702),o=r(9662),i=r(4374),s=n(n.bind);t.exports=function(t,e){return o(t),void 0===e?t:i?s(t,e):function(){return t.apply(e,arguments)}}},4374:(t,e,r)=>{var n=r(7293);t.exports=!n((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))},7065:(t,e,r)=>{"use strict";var n=r(1702),o=r(9662),i=r(111),s=r(2597),a=r(206),c=r(4374),u=Function,l=n([].concat),h=n([].join),f={},p=function(t,e,r){if(!s(f,e)){for(var n=[],o=0;o{var n=r(4374),o=Function.prototype.call;t.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},6530:(t,e,r)=>{var n=r(9781),o=r(2597),i=Function.prototype,s=n&&Object.getOwnPropertyDescriptor,a=o(i,"name"),c=a&&"something"===function(){}.name,u=a&&(!n||n&&s(i,"name").configurable);t.exports={EXISTS:a,PROPER:c,CONFIGURABLE:u}},1702:(t,e,r)=>{var n=r(4374),o=Function.prototype,i=o.bind,s=o.call,a=n&&i.bind(s,s);t.exports=n?function(t){return t&&a(t)}:function(t){return t&&function(){return s.apply(t,arguments)}}},5005:(t,e,r)=>{var n=r(7854),o=r(614),i=function(t){return o(t)?t:void 0};t.exports=function(t,e){return arguments.length<2?i(n[t]):n[t]&&n[t][e]}},1246:(t,e,r)=>{var n=r(648),o=r(8173),i=r(8554),s=r(7497),a=r(5112)("iterator");t.exports=function(t){if(!i(t))return o(t,a)||o(t,"@@iterator")||s[n(t)]}},4121:(t,e,r)=>{var n=r(6916),o=r(9662),i=r(9670),s=r(6330),a=r(1246),c=TypeError;t.exports=function(t,e){var r=arguments.length<2?a(t):e;if(o(r))return i(n(r,t));throw c(s(t)+" is not iterable")}},8173:(t,e,r)=>{var n=r(9662),o=r(8554);t.exports=function(t,e){var r=t[e];return o(r)?void 0:n(r)}},7854:(t,e,r)=>{var n=function(t){return t&&t.Math==Math&&t};t.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof r.g&&r.g)||function(){return this}()||Function("return this")()},2597:(t,e,r)=>{var n=r(1702),o=r(7908),i=n({}.hasOwnProperty);t.exports=Object.hasOwn||function(t,e){return i(o(t),e)}},3501:t=>{t.exports={}},842:(t,e,r)=>{var n=r(7854);t.exports=function(t,e){var r=n.console;r&&r.error&&(1==arguments.length?r.error(t):r.error(t,e))}},490:(t,e,r)=>{var n=r(5005);t.exports=n("document","documentElement")},4664:(t,e,r)=>{var n=r(9781),o=r(7293),i=r(317);t.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:(t,e,r)=>{var n=r(1702),o=r(7293),i=r(4326),s=Object,a=n("".split);t.exports=o((function(){return!s("z").propertyIsEnumerable(0)}))?function(t){return"String"==i(t)?a(t,""):s(t)}:s},9587:(t,e,r)=>{var n=r(614),o=r(111),i=r(7674);t.exports=function(t,e,r){var s,a;return i&&n(s=e.constructor)&&s!==r&&o(a=s.prototype)&&a!==r.prototype&&i(t,a),t}},2788:(t,e,r)=>{var n=r(1702),o=r(614),i=r(5465),s=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(t){return s(t)}),t.exports=i.inspectSource},2423:(t,e,r)=>{var n=r(2109),o=r(1702),i=r(3501),s=r(111),a=r(2597),c=r(3070).f,u=r(8006),l=r(1156),h=r(2050),f=r(9711),p=r(6677),d=!1,v=f("meta"),g=0,y=function(t){c(t,v,{value:{objectID:"O"+g++,weakData:{}}})},m=t.exports={enable:function(){m.enable=function(){},d=!0;var t=u.f,e=o([].splice),r={};r[v]=1,t(r).length&&(u.f=function(r){for(var n=t(r),o=0,i=n.length;o{var n,o,i,s=r(4811),a=r(7854),c=r(1702),u=r(111),l=r(8880),h=r(2597),f=r(5465),p=r(6200),d=r(3501),v="Object already initialized",g=a.TypeError,y=a.WeakMap;if(s||f.state){var m=f.state||(f.state=new y),b=c(m.get),x=c(m.has),w=c(m.set);n=function(t,e){if(x(m,t))throw g(v);return e.facade=t,w(m,t,e),e},o=function(t){return b(m,t)||{}},i=function(t){return x(m,t)}}else{var O=p("state");d[O]=!0,n=function(t,e){if(h(t,O))throw g(v);return e.facade=t,l(t,O,e),e},o=function(t){return h(t,O)?t[O]:{}},i=function(t){return h(t,O)}}t.exports={set:n,get:o,has:i,enforce:function(t){return i(t)?o(t):n(t,{})},getterFor:function(t){return function(e){var r;if(!u(e)||(r=o(e)).type!==t)throw g("Incompatible receiver, "+t+" required");return r}}}},7659:(t,e,r)=>{var n=r(5112),o=r(7497),i=n("iterator"),s=Array.prototype;t.exports=function(t){return void 0!==t&&(o.Array===t||s[i]===t)}},3157:(t,e,r)=>{var n=r(4326);t.exports=Array.isArray||function(t){return"Array"==n(t)}},614:(t,e,r)=>{var n=r(4154),o=n.all;t.exports=n.IS_HTMLDDA?function(t){return"function"==typeof t||t===o}:function(t){return"function"==typeof t}},4411:(t,e,r)=>{var n=r(1702),o=r(7293),i=r(614),s=r(648),a=r(5005),c=r(2788),u=function(){},l=[],h=a("Reflect","construct"),f=/^\s*(?:class|function)\b/,p=n(f.exec),d=!f.exec(u),v=function(t){if(!i(t))return!1;try{return h(u,l,t),!0}catch(t){return!1}},g=function(t){if(!i(t))return!1;switch(s(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return d||!!p(f,c(t))}catch(t){return!0}};g.sham=!0,t.exports=!h||o((function(){var t;return v(v.call)||!v(Object)||!v((function(){t=!0}))||t}))?g:v},4705:(t,e,r)=>{var n=r(7293),o=r(614),i=/#|\.prototype\./,s=function(t,e){var r=c[a(t)];return r==l||r!=u&&(o(e)?n(e):!!e)},a=s.normalize=function(t){return String(t).replace(i,".").toLowerCase()},c=s.data={},u=s.NATIVE="N",l=s.POLYFILL="P";t.exports=s},8554:t=>{t.exports=function(t){return null==t}},111:(t,e,r)=>{var n=r(614),o=r(4154),i=o.all;t.exports=o.IS_HTMLDDA?function(t){return"object"==typeof t?null!==t:n(t)||t===i}:function(t){return"object"==typeof t?null!==t:n(t)}},1913:t=>{t.exports=!1},7850:(t,e,r)=>{var n=r(111),o=r(4326),i=r(5112)("match");t.exports=function(t){var e;return n(t)&&(void 0!==(e=t[i])?!!e:"RegExp"==o(t))}},2190:(t,e,r)=>{var n=r(5005),o=r(614),i=r(7976),s=r(3307),a=Object;t.exports=s?function(t){return"symbol"==typeof t}:function(t){var e=n("Symbol");return o(e)&&i(e.prototype,a(t))}},408:(t,e,r)=>{var n=r(9974),o=r(6916),i=r(9670),s=r(6330),a=r(7659),c=r(6244),u=r(7976),l=r(4121),h=r(1246),f=r(9212),p=TypeError,d=function(t,e){this.stopped=t,this.result=e},v=d.prototype;t.exports=function(t,e,r){var g,y,m,b,x,w,O,E=r&&r.that,S=!(!r||!r.AS_ENTRIES),A=!(!r||!r.IS_RECORD),k=!(!r||!r.IS_ITERATOR),j=!(!r||!r.INTERRUPTED),T=n(e,E),F=function(t){return g&&f(g,"normal",t),new d(!0,t)},M=function(t){return S?(i(t),j?T(t[0],t[1],F):T(t[0],t[1])):j?T(t,F):T(t)};if(A)g=t.iterator;else if(k)g=t;else{if(!(y=h(t)))throw p(s(t)+" is not iterable");if(a(y)){for(m=0,b=c(t);b>m;m++)if((x=M(t[m]))&&u(v,x))return x;return new d(!1)}g=l(t,y)}for(w=A?t.next:g.next;!(O=o(w,g)).done;){try{x=M(O.value)}catch(t){f(g,"throw",t)}if("object"==typeof x&&x&&u(v,x))return x}return new d(!1)}},9212:(t,e,r)=>{var n=r(6916),o=r(9670),i=r(8173);t.exports=function(t,e,r){var s,a;o(t);try{if(!(s=i(t,"return"))){if("throw"===e)throw r;return r}s=n(s,t)}catch(t){a=!0,s=t}if("throw"===e)throw r;if(a)throw s;return o(s),r}},3061:(t,e,r)=>{"use strict";var n=r(3383).IteratorPrototype,o=r(30),i=r(9114),s=r(8003),a=r(7497),c=function(){return this};t.exports=function(t,e,r,u){var l=e+" Iterator";return t.prototype=o(n,{next:i(+!u,r)}),s(t,l,!1,!0),a[l]=c,t}},1656:(t,e,r)=>{"use strict";var n=r(2109),o=r(6916),i=r(1913),s=r(6530),a=r(614),c=r(3061),u=r(9518),l=r(7674),h=r(8003),f=r(8880),p=r(8052),d=r(5112),v=r(7497),g=r(3383),y=s.PROPER,m=s.CONFIGURABLE,b=g.IteratorPrototype,x=g.BUGGY_SAFARI_ITERATORS,w=d("iterator"),O="keys",E="values",S="entries",A=function(){return this};t.exports=function(t,e,r,s,d,g,k){c(r,e,s);var j,T,F,M=function(t){if(t===d&&R)return R;if(!x&&t in P)return P[t];switch(t){case O:case E:case S:return function(){return new r(this,t)}}return function(){return new r(this)}},L=e+" Iterator",C=!1,P=t.prototype,N=P[w]||P["@@iterator"]||d&&P[d],R=!x&&N||M(d),I="Array"==e&&P.entries||N;if(I&&(j=u(I.call(new t)))!==Object.prototype&&j.next&&(i||u(j)===b||(l?l(j,b):a(j[w])||p(j,w,A)),h(j,L,!0,!0),i&&(v[L]=A)),y&&d==E&&N&&N.name!==E&&(!i&&m?f(P,"name",E):(C=!0,R=function(){return o(N,this)})),d)if(T={values:M(E),keys:g?R:M(O),entries:M(S)},k)for(F in T)(x||C||!(F in P))&&p(P,F,T[F]);else n({target:e,proto:!0,forced:x||C},T);return i&&!k||P[w]===R||p(P,w,R,{name:d}),v[e]=R,T}},3383:(t,e,r)=>{"use strict";var n,o,i,s=r(7293),a=r(614),c=r(111),u=r(30),l=r(9518),h=r(8052),f=r(5112),p=r(1913),d=f("iterator"),v=!1;[].keys&&("next"in(i=[].keys())?(o=l(l(i)))!==Object.prototype&&(n=o):v=!0),!c(n)||s((function(){var t={};return n[d].call(t)!==t}))?n={}:p&&(n=u(n)),a(n[d])||h(n,d,(function(){return this})),t.exports={IteratorPrototype:n,BUGGY_SAFARI_ITERATORS:v}},7497:t=>{t.exports={}},6244:(t,e,r)=>{var n=r(7466);t.exports=function(t){return n(t.length)}},6339:(t,e,r)=>{var n=r(7293),o=r(614),i=r(2597),s=r(9781),a=r(6530).CONFIGURABLE,c=r(2788),u=r(9909),l=u.enforce,h=u.get,f=Object.defineProperty,p=s&&!n((function(){return 8!==f((function(){}),"length",{value:8}).length})),d=String(String).split("String"),v=t.exports=function(t,e,r){"Symbol("===String(e).slice(0,7)&&(e="["+String(e).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(e="get "+e),r&&r.setter&&(e="set "+e),(!i(t,"name")||a&&t.name!==e)&&(s?f(t,"name",{value:e,configurable:!0}):t.name=e),p&&r&&i(r,"arity")&&t.length!==r.arity&&f(t,"length",{value:r.arity});try{r&&i(r,"constructor")&&r.constructor?s&&f(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var n=l(t);return i(n,"source")||(n.source=d.join("string"==typeof e?e:"")),t};Function.prototype.toString=v((function(){return o(this)&&h(this).source||c(this)}),"toString")},4758:t=>{var e=Math.ceil,r=Math.floor;t.exports=Math.trunc||function(t){var n=+t;return(n>0?r:e)(n)}},5948:(t,e,r)=>{var n,o,i,s,a,c,u,l,h=r(7854),f=r(9974),p=r(1236).f,d=r(261).set,v=r(6833),g=r(1528),y=r(1036),m=r(5268),b=h.MutationObserver||h.WebKitMutationObserver,x=h.document,w=h.process,O=h.Promise,E=p(h,"queueMicrotask"),S=E&&E.value;S||(n=function(){var t,e;for(m&&(t=w.domain)&&t.exit();o;){e=o.fn,o=o.next;try{e()}catch(t){throw o?s():i=void 0,t}}i=void 0,t&&t.enter()},v||m||y||!b||!x?!g&&O&&O.resolve?((u=O.resolve(void 0)).constructor=O,l=f(u.then,u),s=function(){l(n)}):m?s=function(){w.nextTick(n)}:(d=f(d,h),s=function(){d(n)}):(a=!0,c=x.createTextNode(""),new b(n).observe(c,{characterData:!0}),s=function(){c.data=a=!a})),t.exports=S||function(t){var e={fn:t,next:void 0};i&&(i.next=e),o||(o=e,s()),i=e}},8523:(t,e,r)=>{"use strict";var n=r(9662),o=TypeError,i=function(t){var e,r;this.promise=new t((function(t,n){if(void 0!==e||void 0!==r)throw o("Bad Promise constructor");e=t,r=n})),this.resolve=n(e),this.reject=n(r)};t.exports.f=function(t){return new i(t)}},3929:(t,e,r)=>{var n=r(7850),o=TypeError;t.exports=function(t){if(n(t))throw o("The method doesn't accept regular expressions");return t}},30:(t,e,r)=>{var n,o=r(9670),i=r(6048),s=r(748),a=r(3501),c=r(490),u=r(317),l=r(6200),h=l("IE_PROTO"),f=function(){},p=function(t){return"