alchemy_cms 8.3.10 → 8.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +58 -10
- data/app/assets/builds/alchemy/admin/page-select.css +1 -1
- data/app/assets/builds/alchemy/admin/print.css +1 -1
- data/app/assets/builds/alchemy/admin/remote-select.css +1 -0
- data/app/assets/builds/alchemy/admin/tags-autocomplete.css +1 -0
- data/app/assets/builds/alchemy/admin.css +4 -4
- data/app/assets/builds/alchemy/alchemy_admin.min.js +1 -1
- data/app/assets/builds/alchemy/alchemy_admin.min.js.map +1 -1
- data/app/assets/builds/alchemy/dark-theme.css +1 -1
- data/app/assets/builds/alchemy/light-theme.css +1 -1
- data/app/assets/builds/alchemy/preview.min.js +1 -1
- data/app/assets/builds/alchemy/theme.css +1 -1
- data/app/assets/builds/alchemy/welcome.css +1 -1
- data/app/assets/builds/tinymce/skins/content/alchemy/content.min.css +1 -1
- data/app/assets/builds/tinymce/skins/content/alchemy-dark/content.min.css +1 -1
- data/app/assets/builds/tinymce/skins/ui/alchemy/skin.min.css +1 -1
- data/app/assets/builds/tinymce/skins/ui/alchemy-dark/skin.min.css +1 -1
- data/app/assets/images/alchemy/icons-sprite.svg +1 -1
- data/app/components/alchemy/admin/dashboard/widgets/greeting.html.erb +1 -1
- data/app/components/alchemy/admin/dashboard/widgets/news_reader.html.erb +38 -0
- data/app/components/alchemy/admin/dashboard/widgets/news_reader.rb +54 -0
- data/app/components/alchemy/admin/dashboard/widgets/online_users.html.erb +1 -1
- data/app/components/alchemy/admin/dashboard/widgets/recent_pages.html.erb +1 -1
- data/app/components/alchemy/admin/dashboard/widgets/system_info.html.erb +11 -3
- data/app/components/alchemy/admin/dashboard/widgets/system_info.rb +6 -1
- data/app/components/alchemy/admin/element_editor.html.erb +1 -1
- data/app/components/alchemy/admin/element_select.rb +30 -20
- data/app/components/alchemy/admin/element_status_indicators.html.erb +16 -0
- data/app/components/alchemy/admin/element_status_indicators.rb +31 -0
- data/app/components/alchemy/admin/link_dialog/external_tab.rb +2 -1
- data/app/components/alchemy/admin/main_navigation/entry.rb +61 -0
- data/app/components/alchemy/admin/main_navigation/menu.rb +21 -0
- data/app/components/alchemy/admin/main_navigation/sub_navigation.rb +31 -0
- data/app/components/alchemy/admin/page_node.html.erb +1 -1
- data/app/components/alchemy/admin/page_permitted_roles_select.html.erb +11 -0
- data/app/components/alchemy/admin/page_permitted_roles_select.rb +35 -0
- data/app/components/alchemy/admin/page_select.rb +18 -8
- data/app/components/alchemy/admin/preview_time_select.rb +1 -1
- data/app/components/alchemy/admin/toolbar_button.rb +43 -20
- data/app/components/alchemy/admin/uploader_button.rb +66 -0
- data/app/components/alchemy/ingredients/base_editor.rb +10 -1
- data/app/components/alchemy/ingredients/boolean_editor.rb +1 -0
- data/app/components/alchemy/ingredients/color_editor.rb +6 -3
- data/app/components/alchemy/ingredients/datetime_view.rb +1 -1
- data/app/components/alchemy/ingredients/picture_view.rb +2 -4
- data/app/components/alchemy/menubar.html.erb +157 -0
- data/app/components/alchemy/menubar.rb +15 -0
- data/app/controllers/alchemy/admin/attachments_controller.rb +12 -9
- data/app/controllers/alchemy/admin/base_controller.rb +34 -21
- data/app/controllers/alchemy/admin/dashboard_controller.rb +4 -0
- data/app/controllers/alchemy/admin/elements_controller.rb +4 -23
- data/app/controllers/alchemy/admin/languages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/nodes_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
- data/app/controllers/alchemy/admin/pictures_controller.rb +6 -3
- data/app/controllers/alchemy/admin/resources_controller.rb +5 -5
- data/app/controllers/alchemy/admin/sites_controller.rb +1 -1
- data/app/controllers/alchemy/base_controller.rb +24 -16
- data/app/controllers/alchemy/pages_controller.rb +29 -8
- data/app/controllers/alchemy/sitemap_controller.rb +58 -0
- data/app/controllers/concerns/alchemy/admin/csp_protection.rb +43 -0
- data/app/controllers/concerns/alchemy/admin/current_language.rb +1 -1
- data/app/controllers/concerns/alchemy/admin/resource_filter.rb +3 -1
- data/{lib → app/controllers/concerns}/alchemy/controller_actions.rb +13 -0
- data/app/controllers/concerns/alchemy/legacy_page_redirects.rb +4 -4
- data/app/helpers/alchemy/admin/base_helper.rb +4 -1
- data/app/helpers/alchemy/admin/form_helper.rb +0 -2
- data/app/helpers/alchemy/admin/navigation_helper.rb +10 -181
- data/app/helpers/alchemy/elements_block_helper.rb +14 -0
- data/app/helpers/alchemy/resources_helper.rb +15 -1
- data/app/javascript/alchemy_admin/components/attachment_select.js +11 -20
- data/app/javascript/alchemy_admin/components/auto_submit.js +2 -4
- data/app/javascript/alchemy_admin/components/button.js +0 -6
- data/app/javascript/alchemy_admin/components/clear_schedule_button.js +21 -0
- data/app/javascript/alchemy_admin/components/color_select.js +50 -45
- data/app/javascript/alchemy_admin/components/conditional_field.js +50 -0
- data/app/javascript/alchemy_admin/components/dirty_guard.js +77 -0
- data/app/javascript/alchemy_admin/components/dom_id_select.js +17 -10
- data/app/javascript/alchemy_admin/components/element_editor/delete_element_button.js +7 -2
- data/app/javascript/alchemy_admin/components/element_editor.js +29 -56
- data/app/javascript/alchemy_admin/components/element_select.js +26 -66
- data/app/javascript/alchemy_admin/components/icon.js +9 -4
- data/app/javascript/alchemy_admin/{image_cropper.js → components/image_cropper.js} +39 -53
- data/app/javascript/alchemy_admin/components/image_overlay_link.js +14 -0
- data/app/javascript/alchemy_admin/components/index.js +12 -1
- data/app/javascript/alchemy_admin/components/main_navi_entry.js +75 -0
- data/app/javascript/alchemy_admin/components/menu_node.js +73 -0
- data/app/javascript/alchemy_admin/components/news_reader.js +109 -0
- data/app/javascript/alchemy_admin/components/node_folder.js +36 -0
- data/app/javascript/alchemy_admin/components/node_form.js +34 -0
- data/app/javascript/alchemy_admin/components/node_select.js +25 -30
- data/app/javascript/alchemy_admin/components/node_tree.js +56 -0
- data/app/javascript/alchemy_admin/components/page_node.js +2 -1
- data/app/javascript/alchemy_admin/components/page_select.js +16 -34
- data/app/javascript/alchemy_admin/components/picture_archive.js +92 -0
- data/app/javascript/alchemy_admin/components/picture_editor.js +2 -1
- data/app/javascript/alchemy_admin/components/preview_window.js +11 -3
- data/app/javascript/alchemy_admin/components/remote_select.js +461 -81
- data/app/javascript/alchemy_admin/components/select.js +26 -88
- data/app/javascript/alchemy_admin/components/sitemap.js +2 -1
- data/app/javascript/alchemy_admin/components/sortable_elements.js +2 -1
- data/app/javascript/alchemy_admin/components/tags_autocomplete.js +63 -48
- data/app/javascript/alchemy_admin/components/tinymce.js +2 -1
- data/app/javascript/alchemy_admin/components/uploader/file_upload.js +3 -2
- data/app/javascript/alchemy_admin/components/uploader.js +19 -3
- data/app/javascript/alchemy_admin/confirm_dialog.js +7 -1
- data/app/javascript/alchemy_admin/dialog.js +182 -110
- data/app/javascript/alchemy_admin/hotkeys.js +0 -5
- data/app/javascript/alchemy_admin/i18n.js +3 -9
- data/app/javascript/alchemy_admin/image_overlay.js +58 -42
- data/app/javascript/alchemy_admin/initializer.js +2 -2
- data/app/javascript/alchemy_admin/link_dialog.js +15 -2
- data/app/javascript/alchemy_admin/routes.js +18 -0
- data/app/javascript/alchemy_admin/turbo_stream_actions.js +88 -0
- data/app/javascript/alchemy_admin/utils/ajax.js +14 -3
- data/app/javascript/alchemy_admin/utils/events.js +5 -0
- data/app/javascript/alchemy_admin/utils/json_script.js +12 -0
- data/app/javascript/alchemy_admin/utils/tom_select.js +171 -0
- data/app/javascript/alchemy_admin.js +2 -19
- data/app/javascript/preview.js +131 -113
- data/app/jobs/alchemy/invalidate_elements_cache_job.rb +1 -1
- data/app/models/alchemy/admin/content_security_policy.rb +143 -0
- data/app/models/alchemy/admin/filters/base.rb +7 -0
- data/app/models/alchemy/admin/filters/datepicker.rb +1 -1
- data/app/models/alchemy/admin/filters/select.rb +20 -7
- data/app/models/alchemy/attachment.rb +14 -7
- data/app/models/alchemy/cache_control.rb +104 -0
- data/app/models/alchemy/current.rb +1 -1
- data/app/models/alchemy/eager_loading.rb +0 -2
- data/app/models/alchemy/element.rb +23 -8
- data/app/models/alchemy/element_definition.rb +1 -0
- data/app/models/alchemy/elements_repository.rb +11 -0
- data/app/models/alchemy/folded_page.rb +5 -1
- data/app/models/alchemy/ingredient.rb +26 -0
- data/app/models/alchemy/ingredients/datetime.rb +1 -1
- data/app/models/alchemy/ingredients/link.rb +2 -0
- data/app/models/alchemy/ingredients/picture.rb +3 -0
- data/app/models/alchemy/ingredients/text.rb +2 -0
- data/app/models/alchemy/language.rb +19 -7
- data/app/models/alchemy/legacy_page_url.rb +6 -1
- data/app/models/alchemy/node.rb +51 -0
- data/app/models/alchemy/page/page_natures.rb +41 -8
- data/app/models/alchemy/page/page_scopes.rb +23 -0
- data/app/models/alchemy/page/sitemap_cache_key.rb +56 -0
- data/app/models/alchemy/page.rb +88 -32
- data/app/models/alchemy/page_definition.rb +1 -1
- data/app/models/alchemy/page_mutex.rb +16 -0
- data/app/models/alchemy/page_version.rb +24 -1
- data/app/models/alchemy/permissions.rb +6 -5
- data/app/models/alchemy/picture.rb +15 -7
- data/app/models/alchemy/picture_description.rb +22 -0
- data/app/models/alchemy/picture_thumb.rb +18 -0
- data/app/models/alchemy/publishable/timestamp_resolver.rb +70 -0
- data/app/models/alchemy/resource.rb +1 -1
- data/app/models/alchemy/safe_url_validator.rb +34 -0
- data/app/models/alchemy/site.rb +8 -3
- data/app/models/alchemy/storage_adapter/active_storage/preprocessor.rb +7 -3
- data/app/models/alchemy/storage_adapter/active_storage.rb +4 -1
- data/app/models/alchemy/tag.rb +10 -4
- data/{lib → app/models/concerns}/alchemy/filetypes.rb +5 -0
- data/app/models/concerns/alchemy/picture_thumbnails.rb +61 -6
- data/app/models/concerns/alchemy/publishable.rb +14 -29
- data/app/models/concerns/alchemy/taggable.rb +92 -0
- data/app/models/concerns/alchemy/user_methods.rb +95 -0
- data/app/services/alchemy/duplicate_element.rb +5 -2
- data/app/services/alchemy/element_preloader.rb +1 -2
- data/app/stylesheets/alchemy/_custom-properties.scss +1 -0
- data/app/stylesheets/alchemy/_extends.scss +0 -8
- data/app/stylesheets/alchemy/_themes.scss +10 -9
- data/app/stylesheets/alchemy/admin/_empty-state.scss +29 -0
- data/app/stylesheets/alchemy/admin/_help.scss +10 -0
- data/app/stylesheets/alchemy/admin/_tom-select.scss +104 -15
- data/app/stylesheets/alchemy/admin/archive.scss +56 -11
- data/app/stylesheets/alchemy/admin/base.scss +4 -5
- data/app/stylesheets/alchemy/admin/buttons.scss +12 -1
- data/app/stylesheets/alchemy/admin/dashboard.scss +150 -20
- data/app/stylesheets/alchemy/admin/dialogs.scss +27 -36
- data/app/stylesheets/alchemy/admin/element-select.scss +1 -1
- data/app/stylesheets/alchemy/admin/elements.scss +8 -24
- data/app/stylesheets/alchemy/admin/flash.scss +2 -1
- data/app/stylesheets/alchemy/admin/forms.scss +60 -24
- data/app/stylesheets/alchemy/admin/frame.scss +40 -4
- data/app/stylesheets/alchemy/admin/image_library.scss +9 -12
- data/app/stylesheets/alchemy/admin/navigation.scss +17 -14
- data/app/stylesheets/alchemy/admin/node-select.scss +13 -37
- data/app/stylesheets/alchemy/admin/nodes.scss +1 -1
- data/app/stylesheets/alchemy/admin/page-select.scss +6 -97
- data/app/stylesheets/alchemy/admin/print.scss +0 -4
- data/app/stylesheets/alchemy/admin/remote-select.scss +170 -0
- data/app/stylesheets/alchemy/admin/search.scss +2 -3
- data/app/stylesheets/alchemy/admin/selects.scss +1 -294
- data/app/stylesheets/alchemy/admin/sitemap.scss +2 -1
- data/app/stylesheets/alchemy/admin/tables.scss +7 -1
- data/app/stylesheets/alchemy/admin/tags-autocomplete.scss +17 -0
- data/app/stylesheets/alchemy/admin/tags.scss +0 -13
- data/app/stylesheets/alchemy/admin/toolbar.scss +9 -6
- data/app/stylesheets/alchemy/admin/upload.scss +61 -1
- data/app/stylesheets/alchemy/admin.scss +4 -1
- data/app/stylesheets/tinymce/skins/ui/alchemy/skin.scss +19 -0
- data/app/stylesheets/tinymce/skins/ui/alchemy-dark/skin.scss +19 -0
- data/app/types/alchemy/cache_control_type.rb +84 -0
- data/app/views/alchemy/_edit_mode.html.erb +1 -1
- data/app/views/alchemy/_menubar.html.erb +2 -154
- data/app/views/alchemy/_preview_mode_code.html.erb +0 -3
- data/app/views/alchemy/admin/_left_menu.html.erb +18 -5
- data/app/views/alchemy/admin/_top_menu.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +5 -4
- data/app/views/alchemy/admin/attachments/_file_to_assign.html.erb +3 -3
- data/app/views/alchemy/admin/attachments/_files_list.html.erb +71 -83
- data/app/views/alchemy/admin/attachments/assign.turbo_stream.erb +8 -0
- data/app/views/alchemy/admin/attachments/index.html.erb +32 -7
- data/app/views/alchemy/admin/clipboard/insert.turbo_stream.erb +1 -1
- data/app/views/alchemy/admin/crop.html.erb +20 -20
- data/app/views/alchemy/admin/dashboard/_footer.html.erb +0 -3
- data/app/views/alchemy/admin/dashboard/_top.html.erb +1 -0
- data/app/views/alchemy/admin/dashboard/help.html.erb +84 -57
- data/app/views/alchemy/admin/dashboard/license.html.erb +6 -0
- data/app/views/alchemy/admin/elements/_footer.html.erb +0 -1
- data/app/views/alchemy/admin/elements/_form.html.erb +1 -1
- data/app/views/alchemy/admin/elements/_header.html.erb +2 -19
- data/app/views/alchemy/admin/elements/_preview_text_quote.html.erb +3 -0
- data/app/views/alchemy/admin/elements/_schedule.html.erb +7 -7
- data/app/views/alchemy/admin/elements/_toolbar.html.erb +1 -1
- data/app/views/alchemy/admin/elements/create.turbo_stream.erb +1 -1
- data/app/views/alchemy/admin/elements/index.html.erb +1 -1
- data/app/views/alchemy/admin/elements/publish.turbo_stream.erb +2 -2
- data/app/views/alchemy/admin/elements/update.turbo_stream.erb +31 -0
- data/app/views/alchemy/admin/ingredients/update.turbo_stream.erb +6 -3
- data/app/views/alchemy/admin/languages/_table.html.erb +0 -2
- data/app/views/alchemy/admin/languages/index.html.erb +25 -29
- data/app/views/alchemy/admin/layoutpages/_layoutpage.html.erb +1 -3
- data/app/views/alchemy/admin/layoutpages/edit.html.erb +1 -1
- data/app/views/alchemy/admin/layoutpages/index.html.erb +26 -7
- data/app/views/alchemy/admin/nodes/_form.html.erb +3 -21
- data/app/views/alchemy/admin/nodes/_node.html.erb +93 -88
- data/app/views/alchemy/admin/nodes/index.html.erb +15 -23
- data/app/views/alchemy/admin/pages/_create_language_form.html.erb +2 -6
- data/app/views/alchemy/admin/pages/_form.html.erb +2 -1
- data/app/views/alchemy/admin/pages/_publication_fields.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_table.html.erb +2 -4
- data/app/views/alchemy/admin/pages/_toolbar.html.erb +2 -1
- data/app/views/alchemy/admin/pages/edit.html.erb +10 -21
- data/app/views/alchemy/admin/pages/flush.turbo_stream.erb +1 -1
- data/app/views/alchemy/admin/pages/index.html.erb +26 -31
- data/app/views/alchemy/admin/pages/info.html.erb +2 -2
- data/app/views/alchemy/admin/pages/update.turbo_stream.erb +2 -2
- data/app/views/alchemy/admin/partials/_language_tree_select.html.erb +1 -1
- data/app/views/alchemy/admin/partials/_routes.html.erb +24 -48
- data/app/views/alchemy/admin/pictures/_archive.html.erb +3 -17
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +5 -3
- data/app/views/alchemy/admin/pictures/_form.html.erb +0 -1
- data/app/views/alchemy/admin/pictures/_infos.html.erb +5 -1
- data/app/views/alchemy/admin/pictures/_picture.html.erb +1 -1
- data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +3 -4
- data/app/views/alchemy/admin/pictures/assign.turbo_stream.erb +7 -0
- data/app/views/alchemy/admin/pictures/index.html.erb +38 -30
- data/app/views/alchemy/admin/pictures/show.html.erb +41 -41
- data/app/views/alchemy/admin/resources/_empty_state.html.erb +27 -0
- data/app/views/alchemy/admin/resources/_pagination.html.erb +1 -1
- data/app/views/alchemy/admin/resources/_per_page_select.html.erb +1 -1
- data/app/views/alchemy/admin/resources/_resource_table.html.erb +0 -2
- data/app/views/alchemy/admin/resources/_resource_usage_info.html.erb +3 -2
- data/app/views/alchemy/admin/resources/index.html.erb +32 -13
- data/app/views/alchemy/admin/sites/index.html.erb +24 -22
- data/app/views/alchemy/admin/styleguide/index.html.erb +35 -12
- data/app/views/alchemy/admin/tags/index.html.erb +27 -25
- data/app/views/alchemy/admin/tinymce/_setup.html.erb +6 -8
- data/app/views/alchemy/admin/translations/_en.js +3 -0
- data/app/views/alchemy/admin/uploader/_button.html.erb +11 -17
- data/app/views/alchemy/admin/uploader/_setup.html.erb +3 -3
- data/app/views/alchemy/pages/sitemap.xml.erb +2 -0
- data/app/views/kaminari/alchemy/_first_page.html.erb +1 -2
- data/app/views/kaminari/alchemy/_gap.html.erb +0 -1
- data/app/views/kaminari/alchemy/_last_page.html.erb +1 -2
- data/app/views/kaminari/alchemy/_next_page.html.erb +1 -2
- data/app/views/kaminari/alchemy/_page.html.erb +1 -2
- data/app/views/kaminari/alchemy/_paginator.html.erb +0 -1
- data/app/views/kaminari/alchemy/_prev_page.html.erb +1 -2
- data/app/views/layouts/alchemy/admin/dialog.html.erb +3 -0
- data/app/views/layouts/alchemy/admin.html.erb +5 -6
- data/config/brakeman.ignore +23 -1
- data/config/importmap.rb +10 -8
- data/config/initializers/dragonfly.rb +21 -17
- data/config/locales/alchemy.en.yml +53 -12
- data/config/routes.rb +3 -3
- data/db/migrate/20260727120000_add_permitted_roles_to_alchemy_pages.rb +23 -0
- data/db/migrate/20260820120000_add_cached_tag_list_to_taggables.rb +57 -0
- data/lib/alchemy/configuration/number_option.rb +13 -0
- data/lib/alchemy/configuration/proc_option.rb +13 -0
- data/lib/alchemy/configuration.rb +2 -0
- data/lib/alchemy/configurations/admin_components.rb +30 -0
- data/lib/alchemy/configurations/format_matchers.rb +7 -1
- data/lib/alchemy/configurations/main.rb +103 -4
- data/lib/alchemy/configurations/menu.rb +91 -0
- data/lib/alchemy/configurations/menu_item.rb +123 -0
- data/lib/alchemy/configurations/sitemap.rb +1 -0
- data/lib/alchemy/configurations/uploader.rb +15 -1
- data/lib/alchemy/engine.rb +0 -6
- data/lib/alchemy/i18n.rb +26 -0
- data/lib/alchemy/modules.rb +52 -50
- data/lib/alchemy/tasks/generate_thumbnails.rb +99 -0
- data/lib/alchemy/tasks/tidy.rb +1 -1
- data/lib/alchemy/test_support/capybara_helpers.rb +48 -37
- data/lib/alchemy/test_support/current_language_shared_examples.rb +1 -1
- data/lib/alchemy/test_support/factories/dummy_user_factory.rb +4 -1
- data/lib/alchemy/test_support/having_picture_thumbnails_examples.rb +132 -0
- data/lib/alchemy/test_support/shared_ingredient_examples.rb +52 -0
- data/lib/alchemy/test_support/shared_publishable_examples.rb +39 -4
- data/lib/alchemy/upgrader/eight_four.rb +237 -0
- data/lib/alchemy/upgrader/register_module_rewriter.rb +177 -0
- data/lib/alchemy/upgrader.rb +2 -1
- data/lib/alchemy/version.rb +1 -1
- data/lib/alchemy.rb +0 -1
- data/lib/alchemy_cms.rb +0 -13
- data/lib/generators/alchemy/elements/templates/view.html.erb +1 -1
- data/lib/generators/alchemy/elements/templates/view.html.haml +1 -1
- data/lib/generators/alchemy/elements/templates/view.html.slim +1 -1
- data/lib/generators/alchemy/install/install_generator.rb +2 -13
- data/lib/generators/alchemy/install/templates/alchemy.rb.tt +24 -9
- data/lib/generators/alchemy/module/module_generator.rb +1 -0
- data/lib/generators/alchemy/module/templates/ability.rb.tt +1 -1
- data/lib/generators/alchemy/module/templates/module_config.rb.tt +16 -18
- data/lib/generators/alchemy/user_columns_migration/templates/migration.rb.tt +19 -0
- data/lib/generators/alchemy/user_columns_migration/user_columns_migration_generator.rb +30 -0
- data/lib/tasks/alchemy/thumbnails.rake +16 -29
- data/lib/tasks/alchemy/upgrade.rake +45 -3
- data/vendor/javascript/cropperjs.min.js +3 -3
- data/vendor/javascript/floating-ui.min.js +1 -1
- data/vendor/javascript/tinymce.min.js +5 -5
- data/vendor/javascript/tom-select.min.js +1 -1
- metadata +85 -65
- data/app/javascript/alchemy_admin/components/action.js +0 -50
- data/app/javascript/alchemy_admin/dirty.js +0 -55
- data/app/javascript/alchemy_admin/node_tree.js +0 -82
- data/app/javascript/alchemy_admin/picture_selector.js +0 -67
- data/app/javascript/alchemy_admin/templates/compiled.js +0 -1
- data/app/javascript/alchemy_admin/templates/node_folder.hbs +0 -3
- data/app/stylesheets/alchemy/admin/attachment-select.scss +0 -19
- data/app/views/alchemy/admin/_main_navi.html.erb +0 -6
- data/app/views/alchemy/admin/attachments/assign.js.erb +0 -15
- data/app/views/alchemy/admin/pages/_page_layout_filter.html.erb +0 -30
- data/app/views/alchemy/admin/partials/_main_navigation_entry.html.erb +0 -20
- data/app/views/alchemy/admin/partials/_sub_navigation.html.erb +0 -11
- data/app/views/alchemy/admin/pictures/assign.js.erb +0 -13
- data/app/views/alchemy/base/error_notice.js.erb +0 -1
- data/app/views/alchemy/base/permission_denied.js.erb +0 -3
- data/app/views/alchemy/base/redirect.js.erb +0 -11
- data/config/alchemy/config.yml +0 -217
- data/config/alchemy/modules.yml +0 -82
- data/config/initializers/rails_live_reload.rb +0 -13
- data/lib/alchemy/dev_support/live_reload_watcher.rb +0 -5
- data/lib/alchemy/taggable.rb +0 -49
- data/lib/generators/alchemy/install/templates/dragonfly.rb.tt +0 -34
- data/vendor/assets/stylesheets/alchemy_admin/select2.css +0 -1
- data/vendor/javascript/handlebars.min.js +0 -29
- data/vendor/javascript/jquery.min.js +0 -2
- data/vendor/javascript/rails-ujs.min.js +0 -1
- data/vendor/javascript/select2.min.js +0 -23
- /data/{lib → app/controllers/concerns}/alchemy/ability_helper.rb +0 -0
- /data/{lib → app/controllers/concerns}/alchemy/admin/locale.rb +0 -0
- /data/{lib → app/controllers/concerns}/alchemy/admin/preview_time.rb +0 -0
- /data/{lib → app/controllers/concerns}/alchemy/admin/timezone.rb +0 -0
- /data/{lib → app/controllers/concerns}/alchemy/configuration_methods.rb +0 -0
- /data/{lib → app/models}/alchemy/admin/preview_url.rb +0 -0
- /data/{lib → app/models/concerns}/alchemy/hints.rb +0 -0
- /data/{lib → app/models/concerns}/alchemy/name_conversions.rb +0 -0
- /data/{lib → app/services}/alchemy/elements_finder.rb +0 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class AddAlchemyFieldsTo<%= table_name.camelcase %>Table < ActiveRecord::Migration[7.2]
|
|
2
|
+
disable_ddl_transaction! if connection.adapter_name.match?(/postgres/i)
|
|
3
|
+
|
|
4
|
+
def change
|
|
5
|
+
add_column <%= table_name.inspect %>, :alchemy_roles, :text,
|
|
6
|
+
comment: "Space separated list of Alchemy roles this user has",
|
|
7
|
+
if_not_exists: true
|
|
8
|
+
add_column <%= table_name.inspect %>, :updater_id, :integer, if_not_exists: true, comment: "ID of the user that last updated this record"
|
|
9
|
+
add_column <%= table_name.inspect %>, :creator_id, :integer, if_not_exists: true, comment: "ID of the user that created this record"
|
|
10
|
+
add_index <%= table_name.inspect %>, :updater_id, if_not_exists: true, algorithm: algorithm
|
|
11
|
+
add_index <%= table_name.inspect %>, :creator_id, if_not_exists: true, algorithm: algorithm
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def algorithm
|
|
17
|
+
connection.adapter_name.match?(/postgres/i) ? :concurrently : nil
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators/active_record/migration"
|
|
4
|
+
|
|
5
|
+
module Alchemy
|
|
6
|
+
module Generators
|
|
7
|
+
class UserColumnsMigrationGenerator < Rails::Generators::Base
|
|
8
|
+
include ActiveRecord::Generators::Migration
|
|
9
|
+
|
|
10
|
+
desc "Generate migration for columns needed by Alchemy user class"
|
|
11
|
+
|
|
12
|
+
class_option :table_name,
|
|
13
|
+
type: :string,
|
|
14
|
+
desc: "User class table name",
|
|
15
|
+
default: Alchemy.config.user_class.table_name
|
|
16
|
+
|
|
17
|
+
source_root File.expand_path("templates", File.dirname(__FILE__))
|
|
18
|
+
|
|
19
|
+
def generate
|
|
20
|
+
migration_template "migration.rb.tt", "db/migrate/add_alchemy_fields_to_#{table_name}_table.rb"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def table_name
|
|
26
|
+
options[:table_name] || Alchemy.config.user_class.table_name
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require "alchemy/tasks/generate_thumbnails"
|
|
4
|
+
|
|
3
5
|
namespace :alchemy do
|
|
4
6
|
namespace :generate do
|
|
5
7
|
desc "Generates all thumbnails for Alchemy Pictures and Picture Ingredients."
|
|
@@ -8,46 +10,31 @@ namespace :alchemy do
|
|
|
8
10
|
"alchemy:generate:ingredient_picture_thumbnails"
|
|
9
11
|
]
|
|
10
12
|
|
|
11
|
-
desc "Generates thumbnails for Alchemy Pictures."
|
|
13
|
+
desc "Generates thumbnails for Alchemy Pictures (set ASYNC=true to enqueue them as background jobs, active_storage only)."
|
|
12
14
|
task picture_thumbnails: :environment do
|
|
13
|
-
|
|
14
|
-
puts "Please wait..."
|
|
15
|
+
async = ActiveModel::Type::Boolean.new.cast(ENV["ASYNC"]) && Alchemy.storage_adapter.active_storage?
|
|
15
16
|
|
|
16
|
-
Alchemy::Picture.
|
|
17
|
-
next unless picture.has_convertible_format?
|
|
17
|
+
puts "#{async ? "Enqueuing" : "Generating"} thumbnails for #{Alchemy::Picture.count} pictures..."
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
end
|
|
19
|
+
Alchemy::GenerateThumbnails.pictures(async: async) { print "." }
|
|
21
20
|
|
|
22
|
-
puts "
|
|
21
|
+
puts "\nDone!"
|
|
23
22
|
end
|
|
24
23
|
|
|
25
|
-
desc "Generates thumbnails for Alchemy Picture Ingredients (set ELEMENTS=element1,element2 to only generate thumbnails for a subset of elements)."
|
|
24
|
+
desc "Generates thumbnails for Alchemy Picture Ingredients (set ELEMENTS=element1,element2 to only generate thumbnails for a subset of elements, set ASYNC=true to enqueue them as background jobs, active_storage only)."
|
|
26
25
|
task ingredient_picture_thumbnails: :environment do
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
.preload({related_object: :thumbs})
|
|
30
|
-
.merge(Alchemy::Element.published)
|
|
31
|
-
|
|
32
|
-
if ENV["ELEMENTS"].present?
|
|
33
|
-
ingredient_pictures = ingredient_pictures.merge(
|
|
34
|
-
Alchemy::Element.named(ENV["ELEMENTS"].split(","))
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
puts "Regenerate #{ingredient_pictures.count} ingredient picture thumbnails."
|
|
39
|
-
puts "Please wait..."
|
|
26
|
+
element_names = ENV["ELEMENTS"].presence&.split(",")
|
|
27
|
+
async = ActiveModel::Type::Boolean.new.cast(ENV["ASYNC"]) && Alchemy.storage_adapter.active_storage?
|
|
40
28
|
|
|
41
|
-
|
|
42
|
-
puts ingredient_picture.picture_url
|
|
43
|
-
puts ingredient_picture.thumbnail_url
|
|
29
|
+
puts "#{async ? "Enqueuing" : "Generating"} thumbnails for picture ingredients..."
|
|
44
30
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
count = 0
|
|
32
|
+
Alchemy::GenerateThumbnails.ingredients(element_names: element_names, async: async) do
|
|
33
|
+
count += 1
|
|
34
|
+
print "."
|
|
48
35
|
end
|
|
49
36
|
|
|
50
|
-
puts "Done!"
|
|
37
|
+
puts "\n#{async ? "Enqueued" : "Generated"} thumbnails for #{count} picture ingredients. Done!"
|
|
51
38
|
end
|
|
52
39
|
end
|
|
53
40
|
end
|
|
@@ -8,10 +8,11 @@ namespace :alchemy do
|
|
|
8
8
|
task upgrade: [
|
|
9
9
|
"alchemy:upgrade:prepare",
|
|
10
10
|
"alchemy:upgrade:8.0:run",
|
|
11
|
-
"alchemy:upgrade:8.1:run"
|
|
11
|
+
"alchemy:upgrade:8.1:run",
|
|
12
|
+
"alchemy:upgrade:8.4:run"
|
|
12
13
|
] do
|
|
13
|
-
Alchemy::Upgrader["8.
|
|
14
|
-
Alchemy::Upgrader["8.
|
|
14
|
+
Alchemy::Upgrader["8.4"].run_migrations
|
|
15
|
+
Alchemy::Upgrader["8.4"].display_todos
|
|
15
16
|
end
|
|
16
17
|
|
|
17
18
|
namespace :upgrade do
|
|
@@ -55,5 +56,46 @@ namespace :alchemy do
|
|
|
55
56
|
Alchemy::Upgrader["8.1"].migrate_page_metadata
|
|
56
57
|
end
|
|
57
58
|
end
|
|
59
|
+
|
|
60
|
+
namespace "8.4" do
|
|
61
|
+
task "run" => [
|
|
62
|
+
"alchemy:upgrade:8.4:add_dragonfly_gem",
|
|
63
|
+
"alchemy:upgrade:8.4:upgrade_nested_elements_rendering",
|
|
64
|
+
"alchemy:upgrade:8.4:notify_attachment_filetypes_default",
|
|
65
|
+
"alchemy:upgrade:8.4:notify_admin_content_security_policy",
|
|
66
|
+
"alchemy:upgrade:8.4:notify_picture_format_setting",
|
|
67
|
+
"alchemy:upgrade:8.4:upgrade_menu_config"
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
desc "Add dragonfly gem to the Gemfile if the app uses the dragonfly storage adapter"
|
|
71
|
+
task add_dragonfly_gem: [:environment] do
|
|
72
|
+
Alchemy::Upgrader["8.4"].add_dragonfly_gem
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
desc "Rewrite element partials to render nested elements through the block helper"
|
|
76
|
+
task upgrade_nested_elements_rendering: [:environment] do
|
|
77
|
+
Alchemy::Upgrader["8.4"].upgrade_nested_elements_rendering
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
desc "Notify about the new attachment upload allowlist default"
|
|
81
|
+
task notify_attachment_filetypes_default: [:environment] do
|
|
82
|
+
Alchemy::Upgrader["8.4"].notify_attachment_filetypes_default
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
desc "Notify about the opt-in admin Content Security Policy"
|
|
86
|
+
task notify_admin_content_security_policy: [:environment] do
|
|
87
|
+
Alchemy::Upgrader["8.4"].notify_admin_content_security_policy
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
desc "Notify about the new format setting of picture ingredients"
|
|
91
|
+
task notify_picture_format_setting: [:environment] do
|
|
92
|
+
Alchemy::Upgrader["8.4"].notify_picture_format_setting
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
desc "Rewrite register_module calls to the new menu configuration"
|
|
96
|
+
task upgrade_menu_config: [:environment] do
|
|
97
|
+
Alchemy::Upgrader["8.4"].upgrade_menu_config
|
|
98
|
+
end
|
|
99
|
+
end
|
|
58
100
|
end
|
|
59
101
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Cropper.js v1.
|
|
2
|
+
* Cropper.js v1.7.0
|
|
3
3
|
* https://fengyuanchen.github.io/cropperjs
|
|
4
4
|
*
|
|
5
5
|
* Copyright 2015-present Chen Fengyuan
|
|
6
6
|
* Released under the MIT license
|
|
7
7
|
*
|
|
8
|
-
* Date:
|
|
8
|
+
* Date: 2026-10-07T07:21:57.525Z
|
|
9
9
|
*/
|
|
10
|
-
function t(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,a)}return i}function e(e){for(var i=1;i<arguments.length;i++){var a=null!=arguments[i]?arguments[i]:{};i%2?t(Object(a),!0).forEach(function(t){o(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function i(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,e);if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function a(t){return a="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},a(t)}function n(t,e){for(var a=0;a<e.length;a++){var n=e[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,i(n.key),n)}}function o(t,e,a){return(e=i(e))in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function r(t){return function(t){if(Array.isArray(t))return h(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 h(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);"Object"===i&&t.constructor&&(i=t.constructor.name);if("Map"===i||"Set"===i)return Array.from(t);if("Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i))return h(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 h(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=new Array(e);i<e;i++)a[i]=t[i];return a}var s="undefined"!=typeof window&&void 0!==window.document,c=s?window:{},l=!(!s||!c.document.documentElement)&&"ontouchstart"in c.document.documentElement,d=!!s&&"PointerEvent"in c,p="cropper",m="all",u="crop",g="move",f="zoom",v="e",w="w",b="s",y="n",x="ne",M="nw",C="se",D="sw",B="".concat(p,"-crop"),k="".concat(p,"-disabled"),O="".concat(p,"-hidden"),T="".concat(p,"-hide"),E="".concat(p,"-invisible"),W="".concat(p,"-modal"),H="".concat(p,"-move"),N="".concat(p,"Action"),L="".concat(p,"Preview"),z="crop",Y="move",X="none",R="crop",S="cropend",j="cropmove",A="cropstart",P="dblclick",I=d?"pointerdown":l?"touchstart":"mousedown",U=d?"pointermove":l?"touchmove":"mousemove",q=d?"pointerup pointercancel":l?"touchend touchcancel":"mouseup",$="ready",Q="resize",K="wheel",Z="zoom",G="image/jpeg",V=/^e|w|s|n|se|sw|ne|nw|all|crop|move|zoom$/,F=/^data:/,J=/^data:image\/jpeg;base64,/,_=/^img|canvas$/i,tt={viewMode:0,dragMode:z,initialAspectRatio:NaN,aspectRatio:NaN,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxResizable:!0,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},et=Number.isNaN||c.isNaN;function it(t){return"number"==typeof t&&!et(t)}var at=function(t){return t>0&&t<1/0};function nt(t){return void 0===t}function ot(t){return"object"===a(t)&&null!==t}var rt=Object.prototype.hasOwnProperty;function ht(t){if(!ot(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&rt.call(i,"isPrototypeOf")}catch(t){return!1}}function st(t){return"function"==typeof t}var ct=Array.prototype.slice;function lt(t){return Array.from?Array.from(t):ct.call(t)}function dt(t,e){return t&&st(e)&&(Array.isArray(t)||it(t.length)?lt(t).forEach(function(i,a){e.call(t,i,a,t)}):ot(t)&&Object.keys(t).forEach(function(i){e.call(t,t[i],i,t)})),t}var pt=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a<e;a++)i[a-1]=arguments[a];return ot(t)&&i.length>0&&i.forEach(function(e){ot(e)&&Object.keys(e).forEach(function(i){t[i]=e[i]})}),t},mt=/\.\d*(?:0|9){12}\d*$/;function ut(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return mt.test(t)?Math.round(t*e)/e:t}var gt=/^width|height|left|top|marginLeft|marginTop$/;function ft(t,e){var i=t.style;dt(e,function(t,e){gt.test(e)&&it(t)&&(t="".concat(t,"px")),i[e]=t})}function vt(t,e){if(e)if(it(t.length))dt(t,function(t){vt(t,e)});else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function wt(t,e){e&&(it(t.length)?dt(t,function(t){wt(t,e)}):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.replace(e,"")))}function bt(t,e,i){e&&(it(t.length)?dt(t,function(t){bt(t,e,i)}):i?vt(t,e):wt(t,e))}var yt=/([a-z\d])([A-Z])/g;function xt(t){return t.replace(yt,"$1-$2").toLowerCase()}function Mt(t,e){return ot(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(xt(e)))}function Ct(t,e,i){ot(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(xt(e)),i)}var Dt=/\s\s*/,Bt=function(){var t=!1;if(s){var e=!1,i=function(){},a=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});c.addEventListener("test",i,a),c.removeEventListener("test",i,a)}return t}();function kt(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Dt).forEach(function(e){if(!Bt){var o=t.listeners;o&&o[e]&&o[e][i]&&(n=o[e][i],delete o[e][i],0===Object.keys(o[e]).length&&delete o[e],0===Object.keys(o).length&&delete t.listeners)}t.removeEventListener(e,n,a)})}function Ot(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=i;e.trim().split(Dt).forEach(function(e){if(a.once&&!Bt){var o=t.listeners,r=void 0===o?{}:o;n=function(){delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,h=new Array(o),s=0;s<o;s++)h[s]=arguments[s];i.apply(t,h)},r[e]||(r[e]={}),r[e][i]&&t.removeEventListener(e,r[e][i],a),r[e][i]=n,t.listeners=r}t.addEventListener(e,n,a)})}function Tt(t,e,i){var a;return st(Event)&&st(CustomEvent)?a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0}):(a=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i),t.dispatchEvent(a)}function Et(t){var e=t.getBoundingClientRect();return{left:e.left+(window.pageXOffset-document.documentElement.clientLeft),top:e.top+(window.pageYOffset-document.documentElement.clientTop)}}var Wt=c.location,Ht=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function Nt(t){var e=t.match(Ht);return null!==e&&(e[1]!==Wt.protocol||e[2]!==Wt.hostname||e[3]!==Wt.port)}function Lt(t){var e="timestamp=".concat((new Date).getTime());return t+(-1===t.indexOf("?")?"?":"&")+e}function zt(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,o=t.translateY,r=[];it(n)&&0!==n&&r.push("translateX(".concat(n,"px)")),it(o)&&0!==o&&r.push("translateY(".concat(o,"px)")),it(e)&&0!==e&&r.push("rotate(".concat(e,"deg)")),it(i)&&1!==i&&r.push("scaleX(".concat(i,")")),it(a)&&1!==a&&r.push("scaleY(".concat(a,")"));var h=r.length?r.join(" "):"none";return{WebkitTransform:h,msTransform:h,transform:h}}function Yt(t,i){var a=t.pageX,n=t.pageY,o={endX:a,endY:n};return i?o:e({startX:a,startY:n},o)}function Xt(t){var e=t.aspectRatio,i=t.height,a=t.width,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",o=at(a),r=at(i);if(o&&r){var h=i*e;"contain"===n&&h>a||"cover"===n&&h<a?i=a/e:a=i*e}else o?i=a/e:r&&(a=i*e);return{width:a,height:i}}var Rt=String.fromCharCode;var St=/^data:.*,/;function jt(t){var e,i=new DataView(t);try{var a,n,o;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var r=i.byteLength,h=2;h+1<r;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){n=h;break}h+=1}if(n){var s=n+10;if("Exif"===function(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=Rt(t.getUint8(n));return a}(i,n+4,4)){var c=i.getUint16(s);if(((a=18761===c)||19789===c)&&42===i.getUint16(s+2,a)){var l=i.getUint32(s+4,a);l>=8&&(o=s+l)}}}if(o){var d,p,m=i.getUint16(o,a);for(p=0;p<m;p+=1)if(d=o+12*p+2,274===i.getUint16(d,a)){d+=8,e=i.getUint16(d,a),i.setUint16(d,1,a);break}}}catch(t){e=1}return e}var At={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,a=this.cropper,n=Number(e.minContainerWidth),o=Number(e.minContainerHeight);vt(a,O),wt(t,O);var r={width:Math.max(i.offsetWidth,n>=0?n:200),height:Math.max(i.offsetHeight,o>=0?o:100)};this.containerData=r,ft(a,{width:r.width,height:r.height}),vt(t,O),wt(a,O)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180==90,n=a?e.naturalHeight:e.naturalWidth,o=a?e.naturalWidth:e.naturalHeight,r=n/o,h=t.width,s=t.height;t.height*r>t.width?3===i?h=t.height*r:s=t.width/r:3===i?s=t.width/r:h=t.height*r;var c={aspectRatio:r,naturalWidth:n,naturalHeight:o,width:h,height:s};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=pt({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=i.viewMode,h=n.aspectRatio,s=this.cropped&&o;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;r>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===r&&(l*h>c?c=l*h:l=c/h)):r>0&&(c?c=Math.max(c,s?o.width:0):l?l=Math.max(l,s?o.height:0):s&&(c=o.width,(l=o.height)*h>c?c=l*h:l=c/h));var d=Xt({aspectRatio:h,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(r>(s?0:1)){var p=a.width-n.width,m=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,m),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,m),s&&this.limited&&(n.minLeft=Math.min(o.left,o.left+(o.width-n.width)),n.minTop=Math.min(o.top,o.top+(o.height-n.height)),n.maxLeft=o.left,n.maxTop=o.top,2===r&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,m),n.maxTop=Math.max(0,m))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=function(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,o=Math.sin(n),r=Math.cos(n),h=e*r+i*o,s=e*o+i*r;return a>90?{width:s,height:h}:{width:h,height:s}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),o=n.width,r=n.height,h=i.width*(o/i.naturalWidth),s=i.height*(r/i.naturalHeight);i.left-=(h-i.width)/2,i.top-=(s-i.height)/2,i.width=h,i.height=s,i.aspectRatio=o/r,i.naturalWidth=o,i.naturalHeight=r,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,ft(this.canvas,pt({width:i.width,height:i.height},zt({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);pt(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),ft(this.image,pt({width:i.width,height:i.height},zt(pt({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,n={width:e.width,height:e.height};i&&(e.height*i>e.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=pt({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,o=this.cropBoxData,r=this.limited,h=i.aspectRatio;if(t){var s=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=r?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,d=r?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;s=Math.min(s,a.width),c=Math.min(c,a.height),h&&(s&&c?c*h>s?c=s/h:s=c*h:s?c=s/h:c&&(s=c*h),d*h>l?d=l/h:l=d*h),o.minWidth=Math.min(s,l),o.minHeight=Math.min(c,d),o.maxWidth=l,o.maxHeight=d}e&&(r?(o.minLeft=Math.max(0,n.left),o.minTop=Math.max(0,n.top),o.maxLeft=Math.min(a.width,n.left+n.width)-o.width,o.maxTop=Math.min(a.height,n.top+n.height)-o.height):(o.minLeft=0,o.minTop=0,o.maxLeft=a.width-o.width,o.maxTop=a.height-o.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&Ct(this.face,N,i.width>=e.width&&i.height>=e.height?g:m),ft(this.cropBox,pt({width:i.width,height:i.height},zt({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),Tt(this.element,R,this.getData())}},Pt={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",o=document.createElement("img");if(e&&(o.crossOrigin=e),o.src=a,o.alt=n,this.viewBox.appendChild(o),this.viewBoxImage=o,i){var r=i;"string"==typeof i?r=t.ownerDocument.querySelectorAll(i):i.querySelector&&(r=[i]),this.previews=r,dt(r,function(t){var i=document.createElement("img");Ct(t,L,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.style.cssText='display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;"',t.innerHTML="",t.appendChild(i)})}},resetPreview:function(){dt(this.previews,function(t){var e=Mt(t,L);ft(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function(t,e){if(ot(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(xt(e)))}(t,L)})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,o=t.width,r=t.height,h=i.left-e.left-t.left,s=i.top-e.top-t.top;this.cropped&&!this.disabled&&(ft(this.viewBoxImage,pt({width:o,height:r},zt(pt({translateX:-h,translateY:-s},t)))),dt(this.previews,function(e){var i=Mt(e,L),c=i.width,l=i.height,d=c,p=l,m=1;a&&(p=n*(m=c/a)),n&&p>l&&(d=a*(m=l/n),p=l),ft(e,{width:d,height:p}),ft(e.getElementsByTagName("img")[0],pt({width:o*m,height:r*m},zt(pt({translateX:-h*m,translateY:-s*m},t))))}))}},It={bind:function(){var t=this.element,e=this.options,i=this.cropper;st(e.cropstart)&&Ot(t,A,e.cropstart),st(e.cropmove)&&Ot(t,j,e.cropmove),st(e.cropend)&&Ot(t,S,e.cropend),st(e.crop)&&Ot(t,R,e.crop),st(e.zoom)&&Ot(t,Z,e.zoom),Ot(i,I,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&Ot(i,K,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Ot(i,P,this.onDblclick=this.dblclick.bind(this)),Ot(t.ownerDocument,U,this.onCropMove=this.cropMove.bind(this)),Ot(t.ownerDocument,q,this.onCropEnd=this.cropEnd.bind(this)),e.responsive&&Ot(window,Q,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;st(e.cropstart)&&kt(t,A,e.cropstart),st(e.cropmove)&&kt(t,j,e.cropmove),st(e.cropend)&&kt(t,S,e.cropend),st(e.crop)&&kt(t,R,e.crop),st(e.zoom)&&kt(t,Z,e.zoom),kt(i,I,this.onCropStart),e.zoomable&&e.zoomOnWheel&&kt(i,K,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&kt(i,P,this.onDblclick),kt(t.ownerDocument,U,this.onCropMove),kt(t.ownerDocument,q,this.onCropEnd),e.responsive&&kt(window,Q,this.onResize)}},Ut={resize:function(){if(!this.disabled){var t,e,i=this.options,a=this.container,n=this.containerData,o=a.offsetWidth/n.width,r=a.offsetHeight/n.height,h=Math.abs(o-1)>Math.abs(r-1)?o:r;if(1!==h)i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(dt(t,function(e,i){t[i]=e*h})),this.setCropBoxData(dt(e,function(t,i){e[i]=t*h})))}},dblclick:function(){var t,e;this.disabled||this.options.dragMode===X||this.setDragMode((t=this.dragBox,e=B,(t.classList?t.classList.contains(e):t.className.indexOf(e)>-1)?Y:z))},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),this.zoom(-a*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(it(e)&&1!==e||it(i)&&0!==i||t.ctrlKey))){var a,n=this.options,o=this.pointers;t.changedTouches?dt(t.changedTouches,function(t){o[t.identifier]=Yt(t)}):o[t.pointerId||0]=Yt(t),a=Object.keys(o).length>1&&n.zoomable&&n.zoomOnTouch?f:Mt(t.target,N),V.test(a)&&!1!==Tt(this.element,A,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,a===u&&(this.cropping=!0,vt(this.dragBox,W)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==Tt(this.element,j,{originalEvent:t,action:e})&&(t.changedTouches?dt(t.changedTouches,function(t){pt(i[t.identifier]||{},Yt(t,!0))}):pt(i[t.pointerId||0]||{},Yt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.changedTouches?dt(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action=""),this.cropping&&(this.cropping=!1,bt(this.dragBox,W,this.cropped&&this.options.modal)),Tt(this.element,S,{originalEvent:t,action:e}))}}},qt={change:function(t){var i,a=this.options,n=this.canvasData,o=this.containerData,r=this.cropBoxData,h=this.pointers,s=this.action,c=a.aspectRatio,l=r.left,d=r.top,p=r.width,B=r.height,k=l+p,T=d+B,E=0,W=0,H=o.width,N=o.height,L=!0;!c&&t.shiftKey&&(c=p&&B?p/B:1),this.limited&&(E=r.minLeft,W=r.minTop,H=E+Math.min(o.width,n.width,n.left+n.width),N=W+Math.min(o.height,n.height,n.top+n.height));var z=h[Object.keys(h)[0]],Y={x:z.endX-z.startX,y:z.endY-z.startY},X=function(t){switch(t){case v:k+Y.x>H&&(Y.x=H-k);break;case w:l+Y.x<E&&(Y.x=E-l);break;case y:d+Y.y<W&&(Y.y=W-d);break;case b:T+Y.y>N&&(Y.y=N-T)}};switch(s){case m:l+=Y.x,d+=Y.y;break;case v:if(Y.x>=0&&(k>=H||c&&(d<=W||T>=N))){L=!1;break}X(v),(p+=Y.x)<0&&(s=w,l-=p=-p),c&&(B=p/c,d+=(r.height-B)/2);break;case y:if(Y.y<=0&&(d<=W||c&&(l<=E||k>=H))){L=!1;break}X(y),B-=Y.y,d+=Y.y,B<0&&(s=b,d-=B=-B),c&&(p=B*c,l+=(r.width-p)/2);break;case w:if(Y.x<=0&&(l<=E||c&&(d<=W||T>=N))){L=!1;break}X(w),p-=Y.x,l+=Y.x,p<0&&(s=v,l-=p=-p),c&&(B=p/c,d+=(r.height-B)/2);break;case b:if(Y.y>=0&&(T>=N||c&&(l<=E||k>=H))){L=!1;break}X(b),(B+=Y.y)<0&&(s=y,d-=B=-B),c&&(p=B*c,l+=(r.width-p)/2);break;case x:if(c){if(Y.y<=0&&(d<=W||k>=H)){L=!1;break}X(y),B-=Y.y,d+=Y.y,p=B*c}else X(y),X(v),Y.x>=0?k<H?p+=Y.x:Y.y<=0&&d<=W&&(L=!1):p+=Y.x,Y.y<=0?d>W&&(B-=Y.y,d+=Y.y):(B-=Y.y,d+=Y.y);p<0&&B<0?(s=D,d-=B=-B,l-=p=-p):p<0?(s=M,l-=p=-p):B<0&&(s=C,d-=B=-B);break;case M:if(c){if(Y.y<=0&&(d<=W||l<=E)){L=!1;break}X(y),B-=Y.y,d+=Y.y,p=B*c,l+=r.width-p}else X(y),X(w),Y.x<=0?l>E?(p-=Y.x,l+=Y.x):Y.y<=0&&d<=W&&(L=!1):(p-=Y.x,l+=Y.x),Y.y<=0?d>W&&(B-=Y.y,d+=Y.y):(B-=Y.y,d+=Y.y);p<0&&B<0?(s=C,d-=B=-B,l-=p=-p):p<0?(s=x,l-=p=-p):B<0&&(s=D,d-=B=-B);break;case D:if(c){if(Y.x<=0&&(l<=E||T>=N)){L=!1;break}X(w),p-=Y.x,l+=Y.x,B=p/c}else X(b),X(w),Y.x<=0?l>E?(p-=Y.x,l+=Y.x):Y.y>=0&&T>=N&&(L=!1):(p-=Y.x,l+=Y.x),Y.y>=0?T<N&&(B+=Y.y):B+=Y.y;p<0&&B<0?(s=x,d-=B=-B,l-=p=-p):p<0?(s=C,l-=p=-p):B<0&&(s=M,d-=B=-B);break;case C:if(c){if(Y.x>=0&&(k>=H||T>=N)){L=!1;break}X(v),B=(p+=Y.x)/c}else X(b),X(v),Y.x>=0?k<H?p+=Y.x:Y.y>=0&&T>=N&&(L=!1):p+=Y.x,Y.y>=0?T<N&&(B+=Y.y):B+=Y.y;p<0&&B<0?(s=M,d-=B=-B,l-=p=-p):p<0?(s=D,l-=p=-p):B<0&&(s=x,d-=B=-B);break;case g:this.move(Y.x,Y.y),L=!1;break;case f:this.zoom(function(t){var i=e({},t),a=0;return dt(t,function(t,e){delete i[e],dt(i,function(e){var i=Math.abs(t.startX-e.startX),n=Math.abs(t.startY-e.startY),o=Math.abs(t.endX-e.endX),r=Math.abs(t.endY-e.endY),h=Math.sqrt(i*i+n*n),s=(Math.sqrt(o*o+r*r)-h)/h;Math.abs(s)>Math.abs(a)&&(a=s)})}),a}(h),t),L=!1;break;case u:if(!Y.x||!Y.y){L=!1;break}i=Et(this.cropper),l=z.startX-i.left,d=z.startY-i.top,p=r.minWidth,B=r.minHeight,Y.x>0?s=Y.y>0?C:x:Y.x<0&&(l-=p,s=Y.y>0?D:M),Y.y<0&&(d-=B),this.cropped||(wt(this.cropBox,O),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}L&&(r.width=p,r.height=B,r.left=l,r.top=d,this.action=s,this.renderCropBox()),dt(h,function(t){t.startX=t.endX,t.startY=t.endY})}},$t={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&vt(this.dragBox,W),wt(this.cropBox,O),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=pt({},this.initialImageData),this.canvasData=pt({},this.initialCanvasData),this.cropBoxData=pt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(pt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),wt(this.dragBox,W),vt(this.cropBox,O)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,dt(this.previews,function(e){e.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,wt(this.cropper,k)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,vt(this.cropper,k)),this},destroy:function(){var t=this.element;return t[p]?(t[p]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(nt(t)?t:a+Number(t),nt(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(it(t)&&(i.left=t,a=!0),it(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,this.zoomTo(i.width*t/i.naturalWidth,null,e)},zoomTo:function(t,e,i){var a=this.options,n=this.canvasData,o=n.width,r=n.height,h=n.naturalWidth,s=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var c=h*t,l=s*t;if(!1===Tt(this.element,Z,{ratio:t,oldRatio:o/h,originalEvent:i}))return this;if(i){var d=this.pointers,p=Et(this.cropper),m=d&&Object.keys(d).length?function(t){var e=0,i=0,a=0;return dt(t,function(t){var n=t.startX,o=t.startY;e+=n,i+=o,a+=1}),{pageX:e/=a,pageY:i/=a}}(d):{pageX:i.pageX,pageY:i.pageY};n.left-=(c-o)*((m.pageX-p.left-n.left)/o),n.top-=(l-r)*((m.pageY-p.top-n.top)/r)}else ht(e)&&it(e.x)&&it(e.y)?(n.left-=(c-o)*((e.x-n.left)/o),n.top-=(l-r)*((e.y-n.top)/r)):(n.left-=(c-o)/2,n.top-=(l-r)/2);n.width=c,n.height=l,this.renderCanvas(!0)}return this},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return it(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,it(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(it(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(it(t)&&(i.scaleX=t,a=!0),it(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,o=this.cropBoxData;if(this.ready&&this.cropped){t={x:o.left-n.left,y:o.top-n.top,width:o.width,height:o.height};var r=a.width/a.naturalWidth;if(dt(t,function(e,i){t[i]=e/r}),e){var h=Math.round(t.y+t.height),s=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=s-t.x,t.height=h-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&ht(t)){var o=!1;e.rotatable&&it(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,o=!0),e.scalable&&(it(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,o=!0),it(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,o=!0)),o&&this.renderCanvas(!0,!0);var r=i.width/i.naturalWidth;it(t.x)&&(n.left=t.x*r+a.left),it(t.y)&&(n.top=t.y*r+a.top),it(t.width)&&(n.width=t.width*r),it(t.height)&&(n.height=t.height*r),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?pt({},this.containerData):{}},getImageData:function(){return this.sized?pt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&dt(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&ht(t)&&(it(t.left)&&(e.left=t.left),it(t.top)&&(e.top=t.top),it(t.width)?(e.width=t.width,e.height=t.width/i):it(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&ht(t)&&(it(t.left)&&(a.left=t.left),it(t.top)&&(a.top=t.top),it(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),it(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function(t,e,i,a){var n=e.aspectRatio,o=e.naturalWidth,h=e.naturalHeight,s=e.rotate,c=void 0===s?0:s,l=e.scaleX,d=void 0===l?1:l,p=e.scaleY,m=void 0===p?1:p,u=i.aspectRatio,g=i.naturalWidth,f=i.naturalHeight,v=a.fillColor,w=void 0===v?"transparent":v,b=a.imageSmoothingEnabled,y=void 0===b||b,x=a.imageSmoothingQuality,M=void 0===x?"low":x,C=a.maxWidth,D=void 0===C?1/0:C,B=a.maxHeight,k=void 0===B?1/0:B,O=a.minWidth,T=void 0===O?0:O,E=a.minHeight,W=void 0===E?0:E,H=document.createElement("canvas"),N=H.getContext("2d"),L=Xt({aspectRatio:u,width:D,height:k}),z=Xt({aspectRatio:u,width:T,height:W},"cover"),Y=Math.min(L.width,Math.max(z.width,g)),X=Math.min(L.height,Math.max(z.height,f)),R=Xt({aspectRatio:n,width:D,height:k}),S=Xt({aspectRatio:n,width:T,height:W},"cover"),j=Math.min(R.width,Math.max(S.width,o)),A=Math.min(R.height,Math.max(S.height,h)),P=[-j/2,-A/2,j,A];return H.width=ut(Y),H.height=ut(X),N.fillStyle=w,N.fillRect(0,0,Y,X),N.save(),N.translate(Y/2,X/2),N.rotate(c*Math.PI/180),N.scale(d,m),N.imageSmoothingEnabled=y,N.imageSmoothingQuality=M,N.drawImage.apply(N,[t].concat(r(P.map(function(t){return Math.floor(ut(t))})))),N.restore(),H}(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(t.rounded),n=a.x,o=a.y,h=a.width,s=a.height,c=i.width/Math.floor(e.naturalWidth);1!==c&&(n*=c,o*=c,h*=c,s*=c);var l=h/s,d=Xt({aspectRatio:l,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=Xt({aspectRatio:l,width:t.minWidth||0,height:t.minHeight||0},"cover"),m=Xt({aspectRatio:l,width:t.width||(1!==c?i.width:h),height:t.height||(1!==c?i.height:s)}),u=m.width,g=m.height;u=Math.min(d.width,Math.max(p.width,u)),g=Math.min(d.height,Math.max(p.height,g));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=ut(u),f.height=ut(g),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,u,g);var w=t.imageSmoothingEnabled,b=void 0===w||w,y=t.imageSmoothingQuality;v.imageSmoothingEnabled=b,y&&(v.imageSmoothingQuality=y);var x,M,C,D,B,k,O=i.width,T=i.height,E=n,W=o;E<=-h||E>O?(E=0,x=0,C=0,B=0):E<=0?(C=-E,E=0,B=x=Math.min(O,h+E)):E<=O&&(C=0,B=x=Math.min(h,O-E)),x<=0||W<=-s||W>T?(W=0,M=0,D=0,k=0):W<=0?(D=-W,W=0,k=M=Math.min(T,s+W)):W<=T&&(D=0,k=M=Math.min(s,T-W));var H=[E,W,x,M];if(B>0&&k>0){var N=u/h;H.push(C*N,D*N,B*N,k*N)}return v.drawImage.apply(v,[i].concat(r(H.map(function(t){return Math.floor(ut(t))})))),f},setAspectRatio:function(t){var e=this.options;return this.disabled||nt(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=t===z,o=e.movable&&t===Y;t=n||o?t:X,e.dragMode=t,Ct(i,N,t),bt(i,B,n),bt(i,H,o),e.cropBoxMovable||(Ct(a,N,t),bt(a,B,n),bt(a,H,o))}return this}},Qt=c.Cropper,Kt=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!_.test(e.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=e,this.options=pt({},tt,ht(i)&&i),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return e=t,a=[{key:"noConflict",value:function(){return window.Cropper=Qt,t}},{key:"setDefaults",value:function(t){pt(tt,ht(t)&&t)}}],(i=[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[p]){if(e[p]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),a.checkOrientation&&window.ArrayBuffer)if(F.test(t))J.test(t)?this.read((n=t.replace(St,""),o=atob(n),r=new ArrayBuffer(o.length),dt(h=new Uint8Array(r),function(t,e){h[e]=o.charCodeAt(e)}),r)):this.clone();else{var n,o,r,h,s=new XMLHttpRequest,c=this.clone.bind(this);this.reloading=!0,this.xhr=s,s.onabort=c,s.onerror=c,s.ontimeout=c,s.onprogress=function(){s.getResponseHeader("content-type")!==G&&s.abort()},s.onload=function(){e.read(s.response)},s.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&Nt(t)&&i.crossOrigin&&(t=Lt(t)),s.open("GET",t,!0),s.responseType="arraybuffer",s.withCredentials="use-credentials"===i.crossOrigin,s.send()}else this.clone()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=jt(t),n=0,o=1,r=1;if(a>1){this.url=function(t,e){for(var i=[],a=new Uint8Array(t);a.length>0;)i.push(Rt.apply(null,lt(a.subarray(0,8192)))),a=a.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,G);var h=function(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}(a);n=h.rotate,o=h.scaleX,r=h.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=o,i.scaleY=r),this.clone()}},{key:"clone",value:function(){var t=this.element,e=this.url,i=t.crossOrigin,a=e;this.options.checkCrossOrigin&&Nt(e)&&(i||(i="anonymous"),a=Lt(e)),this.crossOrigin=i,this.crossOriginUrl=a;var n=document.createElement("img");i&&(n.crossOrigin=i),n.src=a||e,n.alt=t.alt||"The image to crop",this.image=n,n.onload=this.start.bind(this),n.onerror=this.stop.bind(this),vt(n,T),t.parentNode.insertBefore(n,t.nextSibling)}},{key:"start",value:function(){var t=this,e=this.image;e.onload=null,e.onerror=null,this.sizing=!0;var i=c.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(c.navigator.userAgent),a=function(e,i){pt(t.imageData,{naturalWidth:e,naturalHeight:i,aspectRatio:e/i}),t.initialImageData=pt({},t.imageData),t.sizing=!1,t.sized=!0,t.build()};if(!e.naturalWidth||i){var n=document.createElement("img"),o=document.body||document.documentElement;this.sizingImage=n,n.onload=function(){a(n.width,n.height),i||o.removeChild(n)},n.src=e.src,i||(n.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;position:absolute;top:0;z-index:-1;",o.appendChild(n))}else a(e.naturalWidth,e.naturalHeight)}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,n=document.createElement("div");n.innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var o=n.querySelector(".".concat(p,"-container")),r=o.querySelector(".".concat(p,"-canvas")),h=o.querySelector(".".concat(p,"-drag-box")),s=o.querySelector(".".concat(p,"-crop-box")),c=s.querySelector(".".concat(p,"-face"));this.container=a,this.cropper=o,this.canvas=r,this.dragBox=h,this.cropBox=s,this.viewBox=o.querySelector(".".concat(p,"-view-box")),this.face=c,r.appendChild(i),vt(t,O),a.insertBefore(o,t.nextSibling),wt(i,T),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,vt(s,O),e.guides||vt(s.getElementsByClassName("".concat(p,"-dashed")),O),e.center||vt(s.getElementsByClassName("".concat(p,"-center")),O),e.background&&vt(o,"".concat(p,"-bg")),e.highlight||vt(c,E),e.cropBoxMovable&&(vt(c,H),Ct(c,N,m)),e.cropBoxResizable||(vt(s.getElementsByClassName("".concat(p,"-line")),O),vt(s.getElementsByClassName("".concat(p,"-point")),O)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),st(e.ready)&&Ot(t,$,e.ready,{once:!0}),Tt(t,$)}}},{key:"unbuild",value:function(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),wt(this.element,O)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}])&&n(e.prototype,i),a&&n(e,a),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,i,a}();pt(Kt.prototype,At,Pt,It,Ut,qt,$t);export{Kt as default};
|
|
10
|
+
function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,a=Array(e);i<e;i++)a[i]=t[i];return a}function e(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,h(a.key),a)}}function i(t,e,i){return(e=h(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function a(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),i.push.apply(i,a)}return i}function n(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?a(Object(n),!0).forEach(function(e){i(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function r(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var a,n,r,o,h=[],s=!0,c=!1;try{if(r=(i=i.call(t)).next,0===e);else for(;!(s=(a=r.call(i)).done)&&(h.push(a.value),h.length!==e);s=!0);}catch(t){c=!0,n=t}finally{try{if(!s&&null!=i.return&&(o=i.return(),Object(o)!==o))return}finally{if(c)throw n}}return h}}(t,e)||c(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||c(e)||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 h(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var a=i.call(t,e);if("object"!=typeof a)return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:e+""}function s(t){return s="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},s(t)}function c(e,i){if(e){if("string"==typeof e)return t(e,i);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?t(e,i):void 0}}var l="undefined"!=typeof window&&void 0!==window.document,d=l?window:{},p=!(!l||!d.document.documentElement)&&"ontouchstart"in d.document.documentElement,u=!!l&&"PointerEvent"in d,m="cropper",g="all",f="crop",v="move",w="zoom",b="e",x="w",y="s",M="n",D="ne",C="nw",B="se",T="sw",k="".concat(m,"-crop"),O="".concat(m,"-disabled"),E="".concat(m,"-hidden"),W="".concat(m,"-hide"),H="".concat(m,"-invisible"),L="".concat(m,"-modal"),N="".concat(m,"-move"),S="".concat(m,"Action"),R="".concat(m,"Preview"),z="crop",Y="move",A="none",X="blur",j="crop",P="cropend",I="cropmove",U="cropstart",_="dblclick",q="error",$=u?"pointerdown":p?"touchstart":"mousedown",Q=u?"pointermove":p?"touchmove":"mousemove",F=u?"pointerup pointercancel":p?"touchend touchcancel":"mouseup",K="ready",V="resize",Z="wheel",G="zoom",J="image/jpeg",tt=/^(e|w|s|n|se|sw|ne|nw|all|crop|move|zoom)$/,et=/^data:/,it=/^data:image\/jpeg;base64,/,at=/\s+/,nt=/^(img|canvas)$/i,rt={viewMode:0,dragMode:z,initialAspectRatio:NaN,aspectRatio:NaN,borderRadius:0,data:null,preview:"",responsive:!0,restore:!0,checkCrossOrigin:!0,checkOrientation:!0,modal:!0,guides:!0,center:!0,highlight:!0,background:!0,autoCrop:!0,autoCropArea:.8,movable:!0,rotatable:!0,scalable:!0,zoomable:!0,zoomOnTouch:!0,zoomOnWheel:!0,zoomAroundCenter:!1,wheelZoomRatio:.1,cropBoxMovable:!0,cropBoxMoveMode:"cursor",cropBoxResizable:!0,cropBoxResizeAroundCenter:!1,toggleDragModeOnDblclick:!0,minCanvasWidth:0,minCanvasHeight:0,minCropBoxWidth:0,minCropBoxHeight:0,minContainerWidth:200,minContainerHeight:100,ready:null,error:null,cropstart:null,cropmove:null,cropend:null,crop:null,zoom:null},ot=Number.isNaN||d.isNaN,ht=Number.isFinite||d.isFinite;function st(t){return"number"==typeof t&&!ot(t)}var ct=function(t){return t>0&&t<1/0};function lt(t){return void 0===t}function dt(t){return"object"===s(t)&&null!==t}var pt=Object.prototype.hasOwnProperty;function ut(t){if(!dt(t))return!1;try{var e=t.constructor,i=e.prototype;return e&&i&&pt.call(i,"isPrototypeOf")}catch(t){return!1}}function mt(t){return"function"==typeof t}var gt=Array.prototype.slice;function ft(t){return Array.from?Array.from(t):gt.call(t)}function vt(t,e){return t&&mt(e)&&(Array.isArray(t)||st(t.length)?ft(t).forEach(function(i,a){e.call(t,i,a,t)}):dt(t)&&Object.keys(t).forEach(function(i){e.call(t,t[i],i,t)})),t}var wt=Object.assign||function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),a=1;a<e;a++)i[a-1]=arguments[a];return dt(t)&&i.length>0&&i.forEach(function(e){dt(e)&&Object.keys(e).forEach(function(i){t[i]=e[i]})}),t},bt=/\.\d*(?:0|9){12}\d*$/;function xt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e11;return Math.abs(t)<1/e||bt.test(t)?Math.round(t*e)/e:t}var yt=/^width|height|left|top|marginLeft|marginTop$/;function Mt(t,e){var i=t.style;vt(e,function(t,e){yt.test(e)&&st(t)&&(t="".concat(t,"px")),i[e]=t})}function Dt(t,e){if(e)if(st(t.length))vt(t,function(t){Dt(t,e)});else if(t.classList)t.classList.add(e);else{var i=t.className.trim();i?i.indexOf(e)<0&&(t.className="".concat(i," ").concat(e)):t.className=e}}function Ct(t,e){e&&(st(t.length)?vt(t,function(t){Ct(t,e)}):t.classList?t.classList.remove(e):t.className.indexOf(e)>=0&&(t.className=t.className.split(at).filter(function(t){return t&&t!==e}).join(" ")))}function Bt(t,e,i){e&&(st(t.length)?vt(t,function(t){Bt(t,e,i)}):i?Dt(t,e):Ct(t,e))}var Tt=/([a-z\d])([A-Z])/g;function kt(t){return"string"==typeof t?t.replace(Tt,"$1-$2").toLowerCase():""}function Ot(t,e){return dt(t[e])?t[e]:t.dataset?t.dataset[e]:t.getAttribute("data-".concat(kt(e)))}function Et(t,e,i){dt(i)?t[e]=i:t.dataset?t.dataset[e]=i:t.setAttribute("data-".concat(kt(e)),i)}var Wt=function(){var t=!1;if(l){var e=!1,i=function(){},a=Object.defineProperty({},"once",{get:function(){return t=!0,e},set:function(t){e=t}});d.addEventListener("test",i,a),d.removeEventListener("test",i,a)}return t}();function Ht(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t&&e&&mt(t.removeEventListener)){var n=i;e.trim().split(at).forEach(function(e){if(!Wt){var r=t.__cropperListeners__||{};r[e]&&r[e][i]&&(n=r[e][i],delete r[e][i],0===Object.keys(r[e]).length&&delete r[e],0===Object.keys(r).length&&delete t.__cropperListeners__)}t.removeEventListener(e,n,a)})}}function Lt(t,e,i){var a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(t&&e&&mt(t.addEventListener)&&mt(i)){var n=i;e.trim().split(at).forEach(function(e){if(a.once&&!Wt){var r=t.__cropperListeners__||{};n=function(){r[e]&&r[e][i]&&delete r[e][i],t.removeEventListener(e,n,a);for(var o=arguments.length,h=new Array(o),s=0;s<o;s++)h[s]=arguments[s];i.apply(t,h)},r[e]||(r[e]={}),r[e][i]&&t.removeEventListener(e,r[e][i],a),r[e][i]=n,t.__cropperListeners__=r}t.addEventListener(e,n,a)})}}function Nt(t,e,i){if(!t||!e||!mt(t.dispatchEvent))return!1;var a;if(mt(Event)&&mt(CustomEvent))a=new CustomEvent(e,{detail:i,bubbles:!0,cancelable:!0});else{if(!dt(document)||!mt(document.createEvent))return!1;(a=document.createEvent("CustomEvent")).initCustomEvent(e,!0,!0,i)}return t.dispatchEvent(a)}function St(t){if(!t||!mt(t.getBoundingClientRect))return{left:0,top:0};var e=t.getBoundingClientRect(),i=(document||{}).documentElement,a=void 0===i?{}:i,n=d.pageXOffset||0,r=d.pageYOffset||0;return{left:e.left+(n-(a.clientLeft||0)),top:e.top+(r-(a.clientTop||0))}}var Rt=d.location,zt=/^(\w+:)\/\/([^:/?#]*):?(\d*)/i;function Yt(t){var e=t.match(zt);return null!==e&&(e[1]!==Rt.protocol||e[2]!==Rt.hostname||e[3]!==Rt.port)}function At(t){var e=t.indexOf("#"),i=e>=0?t.slice(e):"",a=e>=0?t.slice(0,e):t,n="timestamp=".concat((new Date).getTime());return"".concat(a).concat(-1===a.indexOf("?")?"?":"&").concat(n).concat(i)}function Xt(t){var e=t.rotate,i=t.scaleX,a=t.scaleY,n=t.translateX,r=t.translateY,o=[];st(n)&&0!==n&&o.push("translateX(".concat(n,"px)")),st(r)&&0!==r&&o.push("translateY(".concat(r,"px)")),st(e)&&0!==e&&o.push("rotate(".concat(e,"deg)")),st(i)&&1!==i&&o.push("scaleX(".concat(i,")")),st(a)&&1!==a&&o.push("scaleY(".concat(a,")"));var h=o.length?o.join(" "):"none";return{WebkitTransform:h,msTransform:h,transform:h}}function jt(t,e){var i=t.pageX,a=t.pageY,r={endX:i,endY:a};return e?r:n({startX:i,startY:a},r)}function Pt(t){var e=t.aspectRatio,i=t.height,a=t.width,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"contain",r=ct(a),o=ct(i);if(r&&o){var h=i*e;"contain"===n&&h>a||"cover"===n&&h<a?i=a/e:a=i*e}else r?i=a/e:o&&(a=i*e);return{width:a,height:i}}var It=String.fromCharCode;var Ut=/^data:.*,/;function _t(t){var e,i=new DataView(t);try{var a,n,r;if(255===i.getUint8(0)&&216===i.getUint8(1))for(var o=i.byteLength,h=2;h+1<o;){if(255===i.getUint8(h)&&225===i.getUint8(h+1)){n=h;break}h+=1}if(n){var s=n+10;if("Exif"===function(t,e,i){var a="";i+=e;for(var n=e;n<i;n+=1)a+=It(t.getUint8(n));return a}(i,n+4,4)){var c=i.getUint16(s);if(((a=18761===c)||19789===c)&&42===i.getUint16(s+2,a)){var l=i.getUint32(s+4,a);l>=8&&(r=s+l)}}}if(r){var d,p,u=i.getUint16(r,a);for(p=0;p<u;p+=1)if(d=r+12*p+2,274===i.getUint16(d,a)){d+=8,e=i.getUint16(d,a),i.setUint16(d,1,a);break}}}catch(t){e=1}return e}var qt={render:function(){this.initContainer(),this.initCanvas(),this.initCropBox(),this.renderCanvas(),this.cropped&&this.renderCropBox()},initContainer:function(){var t=this.element,e=this.options,i=this.container,a=this.cropper,n=Number(e.minContainerWidth),r=Number(e.minContainerHeight);Dt(a,E),Ct(t,E);var o={width:Math.max(i.offsetWidth,n>=0?n:200),height:Math.max(i.offsetHeight,r>=0?r:100)};this.containerData=o,Mt(a,{width:o.width,height:o.height}),Dt(t,E),Ct(a,E)},initCanvas:function(){var t=this.containerData,e=this.imageData,i=this.options.viewMode,a=Math.abs(e.rotate)%180==90,n=a?e.naturalHeight:e.naturalWidth,r=a?e.naturalWidth:e.naturalHeight,o=n/r,h=t.width,s=t.height;t.height*o>t.width?3===i?h=t.height*o:s=t.width/o:3===i?s=t.width/o:h=t.height*o;var c={aspectRatio:o,naturalWidth:n,naturalHeight:r,width:h,height:s};this.canvasData=c,this.limited=1===i||2===i,this.limitCanvas(!0,!0),c.width=Math.min(Math.max(c.width,c.minWidth),c.maxWidth),c.height=Math.min(Math.max(c.height,c.minHeight),c.maxHeight),c.left=(t.width-c.width)/2,c.top=(t.height-c.height)/2,c.oldLeft=c.left,c.oldTop=c.top,this.initialCanvasData=wt({},c)},limitCanvas:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,r=this.cropBoxData,o=i.viewMode,h=n.aspectRatio,s=this.cropped&&r;if(t){var c=Number(i.minCanvasWidth)||0,l=Number(i.minCanvasHeight)||0;o>1?(c=Math.max(c,a.width),l=Math.max(l,a.height),3===o&&(l*h>c?c=l*h:l=c/h)):o>0&&(c?c=Math.max(c,s?r.width:0):l?l=Math.max(l,s?r.height:0):s&&(c=r.width,(l=r.height)*h>c?c=l*h:l=c/h));var d=Pt({aspectRatio:h,width:c,height:l});c=d.width,l=d.height,n.minWidth=c,n.minHeight=l,n.maxWidth=1/0,n.maxHeight=1/0}if(e)if(o>(s?0:1)){var p=a.width-n.width,u=a.height-n.height;n.minLeft=Math.min(0,p),n.minTop=Math.min(0,u),n.maxLeft=Math.max(0,p),n.maxTop=Math.max(0,u),s&&this.limited&&(n.minLeft=Math.min(r.left,r.left+(r.width-n.width)),n.minTop=Math.min(r.top,r.top+(r.height-n.height)),n.maxLeft=r.left,n.maxTop=r.top,2===o&&(n.width>=a.width&&(n.minLeft=Math.min(0,p),n.maxLeft=Math.max(0,p)),n.height>=a.height&&(n.minTop=Math.min(0,u),n.maxTop=Math.max(0,u))))}else n.minLeft=-n.width,n.minTop=-n.height,n.maxLeft=a.width,n.maxTop=a.height},renderCanvas:function(t,e){var i=this.canvasData,a=this.imageData;if(e){var n=function(t){var e=t.width,i=t.height,a=t.degree;if(90==(a=Math.abs(a)%180))return{width:i,height:e};var n=a%90*Math.PI/180,r=Math.sin(n),o=Math.cos(n),h=e*o+i*r,s=e*r+i*o;return a>90?{width:s,height:h}:{width:h,height:s}}({width:a.naturalWidth*Math.abs(a.scaleX||1),height:a.naturalHeight*Math.abs(a.scaleY||1),degree:a.rotate||0}),r=n.width,o=n.height,h=i.width*(r/i.naturalWidth),s=i.height*(o/i.naturalHeight);i.left-=(h-i.width)/2,i.top-=(s-i.height)/2,i.width=h,i.height=s,i.aspectRatio=r/o,i.naturalWidth=r,i.naturalHeight=o,this.limitCanvas(!0,!1)}(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCanvas(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,Mt(this.canvas,wt({width:i.width,height:i.height},Xt({translateX:i.left,translateY:i.top}))),this.renderImage(t),this.cropped&&this.limited&&this.limitCropBox(!0,!0)},renderImage:function(t){var e=this.canvasData,i=this.imageData,a=i.naturalWidth*(e.width/e.naturalWidth),n=i.naturalHeight*(e.height/e.naturalHeight);wt(i,{width:a,height:n,left:(e.width-a)/2,top:(e.height-n)/2}),Mt(this.image,wt({width:i.width,height:i.height},Xt(wt({translateX:i.left,translateY:i.top},i)))),t&&this.output()},initCropBox:function(){var t=this.options,e=this.canvasData,i=t.aspectRatio||t.initialAspectRatio,a=Number(t.autoCropArea)||.8,n={width:e.width,height:e.height};i&&(e.height*i>e.width?n.height=n.width/i:n.width=n.height*i),this.cropBoxData=n,this.limitCropBox(!0,!0),n.width=Math.min(Math.max(n.width,n.minWidth),n.maxWidth),n.height=Math.min(Math.max(n.height,n.minHeight),n.maxHeight),n.width=Math.max(n.minWidth,n.width*a),n.height=Math.max(n.minHeight,n.height*a),n.left=e.left+(e.width-n.width)/2,n.top=e.top+(e.height-n.height)/2,n.oldLeft=n.left,n.oldTop=n.top,this.initialCropBoxData=wt({},n)},limitCropBox:function(t,e){var i=this.options,a=this.containerData,n=this.canvasData,r=this.cropBoxData,o=this.limited,h=i.aspectRatio;if(t){var s=Number(i.minCropBoxWidth)||0,c=Number(i.minCropBoxHeight)||0,l=o?Math.min(a.width,n.width,n.width+n.left,a.width-n.left):a.width,d=o?Math.min(a.height,n.height,n.height+n.top,a.height-n.top):a.height;s=Math.min(s,a.width),c=Math.min(c,a.height),h&&(s&&c?c*h>s?c=s/h:s=c*h:s?c=s/h:c&&(s=c*h),d*h>l?d=l/h:l=d*h),r.minWidth=Math.min(s,l),r.minHeight=Math.min(c,d),r.maxWidth=l,r.maxHeight=d}e&&(o?(r.minLeft=Math.max(0,n.left),r.minTop=Math.max(0,n.top),r.maxLeft=Math.min(a.width,n.left+n.width)-r.width,r.maxTop=Math.min(a.height,n.top+n.height)-r.height):(r.minLeft=0,r.minTop=0,r.maxLeft=a.width-r.width,r.maxTop=a.height-r.height))},renderCropBox:function(){var t=this.options,e=this.containerData,i=this.cropBoxData;(i.width>i.maxWidth||i.width<i.minWidth)&&(i.left=i.oldLeft),(i.height>i.maxHeight||i.height<i.minHeight)&&(i.top=i.oldTop),i.width=Math.min(Math.max(i.width,i.minWidth),i.maxWidth),i.height=Math.min(Math.max(i.height,i.minHeight),i.maxHeight),this.limitCropBox(!1,!0),i.left=Math.min(Math.max(i.left,i.minLeft),i.maxLeft),i.top=Math.min(Math.max(i.top,i.minTop),i.maxTop),i.oldLeft=i.left,i.oldTop=i.top,t.movable&&t.cropBoxMovable&&Et(this.face,S,i.width>=e.width&&i.height>=e.height?v:g),Mt(this.cropBox,wt({width:i.width,height:i.height,borderRadius:t.borderRadius},Xt({translateX:i.left,translateY:i.top}))),this.cropped&&this.limited&&this.limitCanvas(!0,!0),this.disabled||this.output()},output:function(){this.preview(),Nt(this.element,j,this.getData())}},$t={initPreview:function(){var t=this.element,e=this.crossOrigin,i=this.options.preview,a=e?this.crossOriginUrl:this.url,n=t.alt||"The image to preview",r=document.createElement("img");if(e&&(r.crossOrigin=e),r.src=a,r.alt=n,this.viewBox.appendChild(r),this.viewBoxImage=r,i){var o=i;"string"==typeof i?o=t.ownerDocument.querySelectorAll(i):i.querySelector&&(o=[i]),this.previews=o,vt(o,function(t){var i=document.createElement("img");Et(t,R,{width:t.offsetWidth,height:t.offsetHeight,html:t.innerHTML}),e&&(i.crossOrigin=e),i.src=a,i.alt=n,i.style.cssText="display:block;width:100%;height:auto;min-width:0!important;min-height:0!important;max-width:none!important;max-height:none!important;image-orientation:0deg!important;",t.innerHTML="",t.appendChild(i)})}},resetPreview:function(){vt(this.previews,function(t){var e=Ot(t,R);Mt(t,{width:e.width,height:e.height}),t.innerHTML=e.html,function(t,e){if(dt(t[e]))try{delete t[e]}catch(i){t[e]=void 0}else if(t.dataset)try{delete t.dataset[e]}catch(i){t.dataset[e]=void 0}else t.removeAttribute("data-".concat(kt(e)))}(t,R)})},preview:function(){var t=this.imageData,e=this.canvasData,i=this.cropBoxData,a=i.width,n=i.height,r=t.width,o=t.height,h=i.left-e.left-t.left,s=i.top-e.top-t.top;this.cropped&&!this.disabled&&(Mt(this.viewBoxImage,wt({width:r,height:o},Xt(wt({translateX:-h,translateY:-s},t)))),vt(this.previews,function(e){var i=Ot(e,R),c=i.width,l=i.height,d=c,p=l,u=1;a&&(p=n*(u=c/a)),n&&p>l&&(d=a*(u=l/n),p=l),Mt(e,{width:d,height:p}),Mt(e.getElementsByTagName("img")[0],wt({width:r*u,height:o*u},Xt(wt({translateX:-h*u,translateY:-s*u},t))))}))}},Qt={bind:function(){var t=this.element,e=this.options,i=this.cropper;mt(e.cropstart)&&Lt(t,U,e.cropstart),mt(e.cropmove)&&Lt(t,I,e.cropmove),mt(e.cropend)&&Lt(t,P,e.cropend),mt(e.crop)&&Lt(t,j,e.crop),mt(e.zoom)&&Lt(t,G,e.zoom),Lt(i,$,this.onCropStart=this.cropStart.bind(this)),e.zoomable&&e.zoomOnWheel&&Lt(i,Z,this.onWheel=this.wheel.bind(this),{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Lt(i,_,this.onDblclick=this.dblclick.bind(this)),Lt(t.ownerDocument,Q,this.onCropMove=this.cropMove.bind(this)),Lt(t.ownerDocument,F,this.onCropEnd=this.cropEnd.bind(this)),Lt(t.ownerDocument.defaultView,X,this.onCropBlur=this.cropEnd.bind(this)),e.responsive&&Lt(window,V,this.onResize=this.resize.bind(this))},unbind:function(){var t=this.element,e=this.options,i=this.cropper;mt(e.cropstart)&&Ht(t,U,e.cropstart),mt(e.cropmove)&&Ht(t,I,e.cropmove),mt(e.cropend)&&Ht(t,P,e.cropend),mt(e.crop)&&Ht(t,j,e.crop),mt(e.zoom)&&Ht(t,G,e.zoom),Ht(i,$,this.onCropStart),e.zoomable&&e.zoomOnWheel&&Ht(i,Z,this.onWheel,{passive:!1,capture:!0}),e.toggleDragModeOnDblclick&&Ht(i,_,this.onDblclick),Ht(t.ownerDocument,Q,this.onCropMove),Ht(t.ownerDocument,F,this.onCropEnd),Ht(t.ownerDocument.defaultView,X,this.onCropBlur),e.responsive&&Ht(window,V,this.onResize)}};function Ft(t){return 1===t.length?[t[0],t[0],t[0],t[0]]:2===t.length?[t[0],t[1],t[0],t[1]]:3===t.length?[t[0],t[1],t[2],t[1]]:t.slice(0,4)}function Kt(t,e,i){return t.trim().split(/\s+/).map(function(t){var a=Number.parseFloat(t);return t.endsWith("%")?a*e/100:(a||0)*i})}function Vt(t,e,i,a,n){var o=function(t,e,i,a){var n=String(t||0).trim().split("/"),r=Ft(Kt(n[0],e,a)),o=Ft(Kt(n[1]||n[0],i,a)),h=[{x:r[0],y:o[0]},{x:r[1],y:o[1]},{x:r[2],y:o[2]},{x:r[3],y:o[3]}],s=Math.min(1,e/(h[0].x+h[1].x||1),e/(h[3].x+h[2].x||1),i/(h[0].y+h[3].y||1),i/(h[1].y+h[2].y||1));return h.map(function(t){var e=t.x,i=t.y;return{x:e*s,y:i*s}})}(a,e,i,n),h=r(o,4),s=h[0],c=h[1],l=h[2],d=h[3],p=.5522848;t.beginPath(),t.moveTo(s.x,0),t.lineTo(e-c.x,0),t.bezierCurveTo(e-c.x+c.x*p,0,e,c.y-c.y*p,e,c.y),t.lineTo(e,i-l.y),t.bezierCurveTo(e,i-l.y+l.y*p,e-l.x+l.x*p,i,e-l.x,i),t.lineTo(d.x,i),t.bezierCurveTo(d.x-d.x*p,i,0,i-d.y+d.y*p,0,i-d.y),t.lineTo(0,s.y),t.bezierCurveTo(0,s.y-s.y*p,s.x-s.x*p,0,s.x,0),t.closePath(),t.fill()}function Zt(t,e,i){var a=this.options,n=this.canvasData,r=this.containerData,o=n.width,h=n.height,s=n.naturalWidth,c=n.naturalHeight;if((t=Number(t))>=0&&this.ready&&!this.disabled&&a.zoomable){var l=s*t,d=c*t;if(!1===Nt(this.element,G,{ratio:t,oldRatio:o/s,originalEvent:i}))return this;if(ut(e)&&st(e.x)&&st(e.y))n.left-=(l-o)*((e.x-n.left)/o),n.top-=(d-h)*((e.y-n.top)/h);else if(a.zoomAroundCenter){var p=r.width/2,u=r.height/2;n.left-=(l-o)*((p-n.left)/o),n.top-=(d-h)*((u-n.top)/h)}else if(i){var m=this.pointers,g=St(this.cropper),f=m&&Object.keys(m).length?function(t){var e=0,i=0,a=0;return vt(t,function(t){var n=t.startX,r=t.startY;e+=n,i+=r,a+=1}),{pageX:e/=a,pageY:i/=a}}(m):{pageX:i.pageX,pageY:i.pageY};n.left-=(l-o)*((f.pageX-g.left-n.left)/o),n.top-=(d-h)*((f.pageY-g.top-n.top)/h)}else n.left-=(l-o)/2,n.top-=(d-h)/2;n.width=l,n.height=d,this.renderCanvas(!0)}return this}function Gt(t,e){var i=this.canvasData;return t=(t=Number(t))<0?1/(1-t):1+t,Zt.call(this,i.width*t/i.naturalWidth,null,e)}function Jt(t,e){return Gt.call(this,t,e)}var te={crop:function(){return!this.ready||this.cropped||this.disabled||(this.cropped=!0,this.limitCropBox(!0,!0),this.options.modal&&Dt(this.dragBox,L),Ct(this.cropBox,E),this.setCropBoxData(this.initialCropBoxData)),this},reset:function(){return this.ready&&!this.disabled&&(this.imageData=wt({},this.initialImageData),this.canvasData=wt({},this.initialCanvasData),this.cropBoxData=wt({},this.initialCropBoxData),this.renderCanvas(),this.cropped&&this.renderCropBox()),this},clear:function(){return this.cropped&&!this.disabled&&(wt(this.cropBoxData,{left:0,top:0,width:0,height:0}),this.cropped=!1,this.renderCropBox(),this.limitCanvas(!0,!0),this.renderCanvas(),Ct(this.dragBox,L),Dt(this.cropBox,E)),this},replace:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return!this.disabled&&t&&(this.isImg&&(this.element.src=t),e?(this.url=t,this.image.src=t,this.ready&&(this.viewBoxImage.src=t,vt(this.previews,function(e){e.getElementsByTagName("img")[0].src=t}))):(this.isImg&&(this.replaced=!0),this.options.data=null,this.uncreate(),this.load(t))),this},enable:function(){return this.ready&&this.disabled&&(this.disabled=!1,Ct(this.cropper,O)),this},disable:function(){return this.ready&&!this.disabled&&(this.disabled=!0,Dt(this.cropper,O)),this},destroy:function(){var t=this.element;return t[m]?(t[m]=void 0,this.isImg&&this.replaced&&(t.src=this.originalUrl),this.uncreate(),this):this},move:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=i.left,n=i.top;return this.moveTo(lt(t)?t:a+Number(t),lt(e)?e:n+Number(e))},moveTo:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.canvasData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.movable&&(st(t)&&(i.left=t,a=!0),st(e)&&(i.top=e,a=!0),a&&this.renderCanvas(!0)),this},zoom:function(t){return Gt.call(this,t)},zoomTo:function(t,e){return Zt.call(this,t,e)},rotate:function(t){return this.rotateTo((this.imageData.rotate||0)+Number(t))},rotateTo:function(t){return st(t=Number(t))&&this.ready&&!this.disabled&&this.options.rotatable&&(this.imageData.rotate=t%360,this.renderCanvas(!0,!0)),this},scaleX:function(t){var e=this.imageData.scaleY;return this.scale(t,st(e)?e:1)},scaleY:function(t){var e=this.imageData.scaleX;return this.scale(st(e)?e:1,t)},scale:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,i=this.imageData,a=!1;return t=Number(t),e=Number(e),this.ready&&!this.disabled&&this.options.scalable&&(st(t)&&(i.scaleX=t,a=!0),st(e)&&(i.scaleY=e,a=!0),a&&this.renderCanvas(!0,!0)),this},getData:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],i=this.options,a=this.imageData,n=this.canvasData,r=this.cropBoxData;if(this.ready&&this.cropped){t={x:r.left-n.left,y:r.top-n.top,width:r.width,height:r.height};var o=a.width/a.naturalWidth;if(vt(t,function(e,i){t[i]=xt(e/o)}),e){var h=Math.round(t.y+t.height),s=Math.round(t.x+t.width);t.x=Math.round(t.x),t.y=Math.round(t.y),t.width=s-t.x,t.height=h-t.y}}else t={x:0,y:0,width:0,height:0};return i.rotatable&&(t.rotate=a.rotate||0),i.scalable&&(t.scaleX=a.scaleX||1,t.scaleY=a.scaleY||1),t},setData:function(t){var e=this.options,i=this.imageData,a=this.canvasData,n={};if(this.ready&&!this.disabled&&ut(t)){var r=!1;e.rotatable&&st(t.rotate)&&t.rotate!==i.rotate&&(i.rotate=t.rotate,r=!0),e.scalable&&(st(t.scaleX)&&t.scaleX!==i.scaleX&&(i.scaleX=t.scaleX,r=!0),st(t.scaleY)&&t.scaleY!==i.scaleY&&(i.scaleY=t.scaleY,r=!0)),r&&this.renderCanvas(!0,!0);var o=i.width/i.naturalWidth;st(t.x)&&(n.left=t.x*o+a.left),st(t.y)&&(n.top=t.y*o+a.top),st(t.width)&&(n.width=t.width*o),st(t.height)&&(n.height=t.height*o),this.setCropBoxData(n)}return this},getContainerData:function(){return this.ready?wt({},this.containerData):{}},getImageData:function(){return this.sized?wt({},this.imageData):{}},getCanvasData:function(){var t=this.canvasData,e={};return this.ready&&vt(["left","top","width","height","naturalWidth","naturalHeight"],function(i){e[i]=t[i]}),e},setCanvasData:function(t){var e=this.canvasData,i=e.aspectRatio;return this.ready&&!this.disabled&&ut(t)&&(st(t.left)&&(e.left=t.left),st(t.top)&&(e.top=t.top),st(t.width)?(e.width=t.width,e.height=t.width/i):st(t.height)&&(e.height=t.height,e.width=t.height*i),this.renderCanvas(!0)),this},getCropBoxData:function(){var t,e=this.cropBoxData;return this.ready&&this.cropped&&(t={left:e.left,top:e.top,width:e.width,height:e.height}),t||{}},setCropBoxData:function(t){var e,i,a=this.cropBoxData,n=this.options.aspectRatio;return this.ready&&this.cropped&&!this.disabled&&ut(t)&&(st(t.left)&&(a.left=t.left),st(t.top)&&(a.top=t.top),st(t.width)&&t.width!==a.width&&(e=!0,a.width=t.width),st(t.height)&&t.height!==a.height&&(i=!0,a.height=t.height),n&&(e?a.height=a.width/n:i&&(a.width=a.height*n)),this.renderCropBox()),this},getCroppedCanvas:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!this.ready||!window.HTMLCanvasElement)return null;var e=this.canvasData,i=function(t,e,i,a){var n=e.aspectRatio,r=e.naturalWidth,h=e.naturalHeight,s=e.rotate,c=void 0===s?0:s,l=e.scaleX,d=void 0===l?1:l,p=e.scaleY,u=void 0===p?1:p,m=i.aspectRatio,g=i.naturalWidth,f=i.naturalHeight,v=a.fillColor,w=void 0===v?"transparent":v,b=a.imageSmoothingEnabled,x=void 0===b||b,y=a.imageSmoothingQuality,M=void 0===y?"low":y,D=a.maxWidth,C=void 0===D?1/0:D,B=a.maxHeight,T=void 0===B?1/0:B,k=a.minWidth,O=void 0===k?0:k,E=a.minHeight,W=void 0===E?0:E,H=document.createElement("canvas"),L=H.getContext("2d"),N=Pt({aspectRatio:m,width:C,height:T}),S=Pt({aspectRatio:m,width:O,height:W},"cover"),R=Math.min(N.width,Math.max(S.width,g)),z=Math.min(N.height,Math.max(S.height,f)),Y=Pt({aspectRatio:n,width:C,height:T}),A=Pt({aspectRatio:n,width:O,height:W},"cover"),X=Math.min(Y.width,Math.max(A.width,r)),j=Math.min(Y.height,Math.max(A.height,h)),P=[-X/2,-j/2,X,j];return H.width=xt(R),H.height=xt(z),L.fillStyle=w,L.fillRect(0,0,R,z),L.save(),L.translate(R/2,z/2),L.rotate(c*Math.PI/180),L.scale(d,u),L.imageSmoothingEnabled=x,L.imageSmoothingQuality=M,L.drawImage.apply(L,[t].concat(o(P.map(function(t){return Math.floor(xt(t))})))),L.restore(),H}(this.image,this.imageData,e,t);if(!this.cropped)return i;var a=this.getData(t.rounded),n=a.x,r=a.y,h=a.width,s=a.height,c=i.width/Math.floor(e.naturalWidth);1!==c&&(n*=c,r*=c,h*=c,s*=c);var l=h/s,d=Pt({aspectRatio:l,width:t.maxWidth||1/0,height:t.maxHeight||1/0}),p=Pt({aspectRatio:l,width:t.minWidth||0,height:t.minHeight||0},"cover"),u=Pt({aspectRatio:l,width:t.width||(1!==c?i.width:h),height:t.height||(1!==c?i.height:s)}),m=u.width,g=u.height;m=Math.min(d.width,Math.max(p.width,m)),g=Math.min(d.height,Math.max(p.height,g));var f=document.createElement("canvas"),v=f.getContext("2d");f.width=xt(m),f.height=xt(g),v.fillStyle=t.fillColor||"transparent",v.fillRect(0,0,m,g);var w=t.imageSmoothingEnabled,b=void 0===w||w,x=t.imageSmoothingQuality;v.imageSmoothingEnabled=b,x&&(v.imageSmoothingQuality=x),mt(t.beforeDraw)&&t.beforeDraw.call(this,v,f);var y,M,D,C,B,T,k=i.width,O=i.height,E=n,W=r;E<=-h||E>k?(E=0,y=0,D=0,B=0):E<=0?(D=-E,E=0,B=y=Math.min(k,h+E)):E<=k&&(D=0,B=y=Math.min(h,k-E)),y<=0||W<=-s||W>O?(W=0,M=0,C=0,T=0):W<=0?(C=-W,W=0,T=M=Math.min(O,s+W)):W<=O&&(C=0,T=M=Math.min(s,O-W));var H=[E,W,y,M];if(B>0&&T>0){var L=m/h;H.push(D*L,C*L,B*L,T*L)}return v.drawImage.apply(v,[i].concat(o(H.map(function(t){return Math.floor(xt(t))})))),this.options.borderRadius&&(v.globalCompositeOperation="destination-in",v.fillStyle="#000",Vt(v,m,g,this.options.borderRadius,m/this.cropBoxData.width)),f},setAspectRatio:function(t){var e=this.options;return this.disabled||lt(t)||(e.aspectRatio=Math.max(0,t)||NaN,this.ready&&(this.initCropBox(),this.cropped&&this.renderCropBox())),this},setDragMode:function(t){var e=this.options,i=this.dragBox,a=this.face;if(this.ready&&!this.disabled){var n=t===z,r=e.movable&&t===Y;t=n||r?t:A,e.dragMode=t,Et(i,S,t),Bt(i,k,n),Bt(i,N,r),e.cropBoxMovable||(Et(a,S,t),Bt(a,k,n),Bt(a,N,r))}return this}},ee={resize:function(){if(!this.disabled){var t,e,i=this.options,a=this.container,n=this.containerData,r=a.offsetWidth/n.width,o=a.offsetHeight/n.height,h=Math.abs(r-1)>Math.abs(o-1)?r:o;if(1!==h)i.restore&&(t=this.getCanvasData(),e=this.getCropBoxData()),this.render(),i.restore&&(this.setCanvasData(vt(t,function(e,i){t[i]=e*h})),this.setCropBoxData(vt(e,function(t,i){e[i]=t*h})))}},dblclick:function(){var t,e;this.disabled||this.options.dragMode===A||this.setDragMode((t=this.dragBox,e=k,(t.classList?t.classList.contains(e):t.className.split(at).indexOf(e)>-1)?Y:z))},wheel:function(t){var e=this,i=Number(this.options.wheelZoomRatio)||.1,a=1;this.disabled||(t.preventDefault(),this.wheeling||(this.wheeling=!0,setTimeout(function(){e.wheeling=!1},50),t.deltaY?a=t.deltaY>0?1:-1:t.wheelDelta?a=-t.wheelDelta/120:t.detail&&(a=t.detail>0?1:-1),Jt.call(this,-a*i,t)))},cropStart:function(t){var e=t.buttons,i=t.button;if(!(this.disabled||("mousedown"===t.type||"pointerdown"===t.type&&"mouse"===t.pointerType)&&(st(e)&&1!==e||st(i)&&0!==i||t.ctrlKey))){var a,n=this.options,r=this.pointers;t.changedTouches?vt(t.changedTouches,function(t){r[t.identifier]=jt(t)}):r[t.pointerId||0]=jt(t),a=Object.keys(r).length>1&&n.zoomable&&n.zoomOnTouch?w:Ot(t.target,S),tt.test(a)&&!1!==Nt(this.element,U,{originalEvent:t,action:a})&&(t.preventDefault(),this.action=a,this.cropping=!1,this.cropBoxDragStartData=null,this.cropBoxDragStartAction="dragStart"===n.cropBoxMoveMode&&a!==f&&a!==v&&a!==w?a:"",a===f&&(this.cropping=!0,Dt(this.dragBox,L)))}},cropMove:function(t){var e=this.action;if(!this.disabled&&e){var i=this.pointers;t.preventDefault(),!1!==Nt(this.element,I,{originalEvent:t,action:e})&&(t.changedTouches?vt(t.changedTouches,function(t){wt(i[t.identifier]||{},jt(t,!0))}):wt(i[t.pointerId||0]||{},jt(t,!0)),this.change(t))}},cropEnd:function(t){if(!this.disabled){var e=this.action,i=this.pointers;t.type===X?Object.keys(i).forEach(function(t){delete i[t]}):t.changedTouches?vt(t.changedTouches,function(t){delete i[t.identifier]}):delete i[t.pointerId||0],e&&(t.preventDefault(),Object.keys(i).length||(this.action="",this.cropBoxDragStartData=null,this.cropBoxDragStartAction=""),this.cropping&&(this.cropping=!1,Bt(this.dragBox,L,this.cropped&&this.options.modal)),Nt(this.element,P,{originalEvent:t,action:e}))}}};var ie={change:function(t){var e,i=this.options,a=this.canvasData,r=this.containerData,o=this.cropBoxData,h=this.pointers,s=this.action,c=i.aspectRatio,l=o.left,d=o.top,p=o.width,u=o.height,m=l+p,k=d+u,O=0,W=0,H=r.width,L=r.height,N=!0;!c&&t.shiftKey&&(c=p&&u?p/u:1),this.limited&&(O=o.minLeft,W=o.minTop,H=O+Math.min(r.width,a.width,a.left+a.width),L=W+Math.min(r.height,a.height,a.top+a.height));var S=h[Object.keys(h)[0]],R="dragStart"===i.cropBoxMoveMode&&this.cropBoxDragStartAction&&[g,b,M,y,x,D,C,B,T].includes(s);R&&(this.cropBoxDragStartData||(this.cropBoxDragStartData=n({},o)),Object.assign(o,this.cropBoxDragStartData),l=o.left,d=o.top,p=o.width,u=o.height,m=l+p,k=d+u,s=this.cropBoxDragStartAction);var z={x:S.endX-S.startX,y:S.endY-S.startY};if(i.cropBoxResizeAroundCenter&&[b,M,y,x,D,C,B,T].includes(s)){var Y=function(t,e,i,a,n){var r=a.left+a.width/2,o=a.top+a.height/2,h=t===b||t===D||t===B,s=t===y||t===B||t===T,c=t===b||t===x,l=t===M||t===y,d=a.width,p=a.height;i?c||!l&&s?p=(d+=(h?2:-2)*e.x)/i:d=(p+=(s?2:-2)*e.y)*i:(d+=(h?2:-2)*e.x,p+=(s?2:-2)*e.y),d<0&&(d=-d,(!i||c||!l&&s)&&(h=!h)),p<0&&(p=-p,i&&!l&&(l||s)||(s=!s));var u=Math.max(0,2*Math.min(r-n.minLeft,n.maxWidth-r)),m=Math.max(0,2*Math.min(o-n.minTop,n.maxHeight-o)),g=Math.min(a.minWidth,u),f=Math.min(a.minHeight,m);if(i){var v=Math.max(d?g/d:0,p?f/p:0,1),w=Math.min(d?u/d:0,p?m/p:0),k=Math.min(v,w);d*=k,p*=k}else d=Math.min(Math.max(d,g),u),p=Math.min(Math.max(p,f),m);return t=h?s?B:D:s?T:C,c?t=h?b:x:l&&(t=s?y:M),{action:t,left:r-d/2,top:o-p/2,width:d,height:p}}(s,z,c,o,{minLeft:O,minTop:W,maxWidth:H,maxHeight:L});return o.left=Y.left,o.top=Y.top,o.width=Y.width,o.height=Y.height,this.action=Y.action,this.renderCropBox(),void(R||vt(h,function(t){t.startX=t.endX,t.startY=t.endY}))}var A=function(t){switch(t){case b:m+z.x>H&&(z.x=H-m);break;case x:l+z.x<O&&(z.x=O-l);break;case M:d+z.y<W&&(z.y=W-d);break;case y:k+z.y>L&&(z.y=L-k)}};switch(s){case g:l+=z.x,d+=z.y;break;case b:if(z.x>=0&&(m>=H||c&&(d<=W||k>=L))){N=!1;break}A(b),(p+=z.x)<0&&(s=x,l-=p=-p,p<o.minWidth&&(p=o.minWidth,l=o.left-p)),c&&(u=p/c,d+=(o.height-u)/2);break;case M:if(z.y<=0&&(d<=W||c&&(l<=O||m>=H))){N=!1;break}A(M),u-=z.y,d+=z.y,u<0&&(s=y,d-=u=-u,u<o.minHeight&&(u=o.minHeight,d=k)),c&&(p=u*c,l+=(o.width-p)/2);break;case x:if(z.x<=0&&(l<=O||c&&(d<=W||k>=L))){N=!1;break}A(x),p-=z.x,l+=z.x,p<0&&(s=b,l-=p=-p,p<o.minWidth&&(p=o.minWidth,l=m)),c&&(u=p/c,d+=(o.height-u)/2);break;case y:if(z.y>=0&&(k>=L||c&&(l<=O||m>=H))){N=!1;break}A(y),(u+=z.y)<0&&(s=M,d-=u=-u,u<o.minHeight&&(u=o.minHeight,d=o.top-u)),c&&(p=u*c,l+=(o.width-p)/2);break;case D:if(c){if(z.y<=0&&(d<=W||m>=H)){N=!1;break}A(M),u-=z.y,d+=z.y,p=u*c}else A(M),A(b),z.x>=0?m<H?p+=z.x:z.y<=0&&d<=W&&(N=!1):p+=z.x,z.y<=0?d>W&&(u-=z.y,d+=z.y):(u-=z.y,d+=z.y);p<0&&u<0?(s=T,d-=u=-u,l-=p=-p):p<0?(s=C,l-=p=-p):u<0&&(s=B,d-=u=-u);break;case C:if(c){if(z.y<=0&&(d<=W||l<=O)){N=!1;break}A(M),u-=z.y,d+=z.y,p=u*c,l+=o.width-p}else A(M),A(x),z.x<=0?l>O?(p-=z.x,l+=z.x):z.y<=0&&d<=W&&(N=!1):(p-=z.x,l+=z.x),z.y<=0?d>W&&(u-=z.y,d+=z.y):(u-=z.y,d+=z.y);p<0&&u<0?(s=B,d-=u=-u,l-=p=-p):p<0?(s=D,l-=p=-p):u<0&&(s=T,d-=u=-u);break;case T:if(c){if(z.x<=0&&(l<=O||k>=L)){N=!1;break}A(x),p-=z.x,l+=z.x,u=p/c}else A(y),A(x),z.x<=0?l>O?(p-=z.x,l+=z.x):z.y>=0&&k>=L&&(N=!1):(p-=z.x,l+=z.x),z.y>=0?k<L&&(u+=z.y):u+=z.y;p<0&&u<0?(s=D,d-=u=-u,l-=p=-p):p<0?(s=B,l-=p=-p):u<0&&(s=C,d-=u=-u);break;case B:if(c){if(z.x>=0&&(m>=H||k>=L)){N=!1;break}A(b),u=(p+=z.x)/c}else A(y),A(b),z.x>=0?m<H?p+=z.x:z.y>=0&&k>=L&&(N=!1):p+=z.x,z.y>=0?k<L&&(u+=z.y):u+=z.y;p<0&&u<0?(s=C,d-=u=-u,l-=p=-p):p<0?(s=T,l-=p=-p):u<0&&(s=D,d-=u=-u);break;case v:this.move(z.x,z.y),N=!1;break;case w:Jt.call(this,function(t){var e=n({},t),i=0;return vt(t,function(t,a){delete e[a],vt(e,function(e){var a=Math.abs(t.startX-e.startX),n=Math.abs(t.startY-e.startY),r=Math.abs(t.endX-e.endX),o=Math.abs(t.endY-e.endY),h=Math.sqrt(a*a+n*n),s=Math.sqrt(r*r+o*o);if(ht(h)&&ht(s)&&0!==h&&s!==h){var c=(s-h)/h;ht(c)&&Math.abs(c)>Math.abs(i)&&(i=c)}})}),i}(h),t),N=!1;break;case f:if(!z.x||!z.y){N=!1;break}e=St(this.cropper),l=S.startX-e.left,d=S.startY-e.top,c?u=(p=Math.max(Math.abs(z.x),Math.abs(z.y)*c,o.minWidth,o.minHeight*c))/c:(p=Math.max(Math.abs(z.x),o.minWidth),u=Math.max(Math.abs(z.y),o.minHeight)),z.x>0?s=z.y>0?B:D:z.x<0&&(l-=p,s=z.y>0?T:C),z.y<0&&(d-=u),this.cropped||(Ct(this.cropBox,E),this.cropped=!0,this.limited&&this.limitCropBox(!0,!0))}N&&(o.width=p,o.height=u,o.left=l,o.top=d,this.action=s,this.renderCropBox()),vt(h,function(t){s===f||R||(t.startX=t.endX,t.startY=t.endY)})}},ae=d.Cropper,ne=function(){function t(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e||!nt.test(e.tagName))throw new Error("The first argument is required and must be an <img> or <canvas> element.");this.element=e,this.options=wt({},rt,ut(i)&&i),this.cropped=!1,this.disabled=!1,this.pointers={},this.ready=!1,this.reloading=!1,this.replaced=!1,this.sized=!1,this.sizing=!1,this.init()}return i=t,n=[{key:"create",value:function(e,i){return new t(e,i)}},{key:"setDefaults",value:function(t){wt(rt,ut(t)&&t)}},{key:"noConflict",value:function(){return window.Cropper=ae,t}}],(a=[{key:"init",value:function(){var t,e=this.element,i=e.tagName.toLowerCase();if(!e[m]){if(e[m]=this,"img"===i){if(this.isImg=!0,t=e.getAttribute("src")||"",this.originalUrl=t,!t)return;t=e.src}else"canvas"===i&&window.HTMLCanvasElement&&(t=e.toDataURL());this.load(t)}}},{key:"load",value:function(t){var e=this;if(t){this.url=t,this.imageData={};var i=this.element,a=this.options;if(a.rotatable||a.scalable||(a.checkOrientation=!1),a.checkOrientation&&window.ArrayBuffer)if(et.test(t))it.test(t)?this.read((n=t.replace(Ut,""),r=atob(n),o=new ArrayBuffer(r.length),vt(h=new Uint8Array(o),function(t,e){h[e]=r.charCodeAt(e)}),o)):this.clone();else{var n,r,o,h,s=new XMLHttpRequest,c=this.clone.bind(this);this.reloading=!0,this.xhr=s,s.onabort=c,s.onerror=c,s.ontimeout=c,s.onprogress=function(){s.getResponseHeader("content-type")!==J&&s.abort()},s.onload=function(){e.read(s.response)},s.onloadend=function(){e.reloading=!1,e.xhr=null},a.checkCrossOrigin&&Yt(t)&&i.crossOrigin&&(t=At(t)),s.open("GET",t,!0),s.responseType="arraybuffer",s.withCredentials="use-credentials"===i.crossOrigin,s.send()}else this.clone()}}},{key:"read",value:function(t){var e=this.options,i=this.imageData,a=_t(t),n=0,r=1,o=1;if(a>1){this.url=function(t,e){for(var i=[],a=new Uint8Array(t);a.length>0;)i.push(It.apply(null,ft(a.subarray(0,8192)))),a=a.subarray(8192);return"data:".concat(e,";base64,").concat(btoa(i.join("")))}(t,J);var h=function(t){var e=0,i=1,a=1;switch(t){case 2:i=-1;break;case 3:e=-180;break;case 4:a=-1;break;case 5:e=90,a=-1;break;case 6:e=90;break;case 7:e=90,i=-1;break;case 8:e=-90}return{rotate:e,scaleX:i,scaleY:a}}(a);n=h.rotate,r=h.scaleX,o=h.scaleY}e.rotatable&&(i.rotate=n),e.scalable&&(i.scaleX=r,i.scaleY=o),this.clone()}},{key:"clone",value:function(){var t=this,e=this.element,i=this.options,a=this.url,n=e.crossOrigin,r=a;this.options.checkCrossOrigin&&Yt(a)&&(n||(n="anonymous"),r=At(a)),this.crossOrigin=n,this.crossOriginUrl=r;var o=document.createElement("img");n&&(o.crossOrigin=n),o.src=r||a,o.alt=e.alt||"The image to crop",this.image=o,o.onload=this.start.bind(this),mt(i.error)&&Lt(e,q,i.error,{once:!0}),o.onerror=function(i){Nt(e,q,i),t.stop()},Dt(o,W),e.parentNode.insertBefore(o,e.nextSibling)}},{key:"start",value:function(){var t=this,e=this.image;e.onload=null,e.onerror=null,this.sizing=!0;var i=d.navigator&&/(?:iPad|iPhone|iPod).*?AppleWebKit/i.test(d.navigator.userAgent),a=document.createElement("img"),n=document.body||document.documentElement;this.sizingImage=a,a.onload=function(){var e,r;e=a.width,r=a.height,wt(t.imageData,{naturalWidth:e,naturalHeight:r,aspectRatio:e/r}),t.initialImageData=wt({},t.imageData),t.sizing=!1,t.sized=!0,t.build(),i||n.removeChild(a)},a.src=e.src,i||(a.style.cssText="left:0;max-height:none!important;max-width:none!important;min-height:0!important;min-width:0!important;opacity:0;image-orientation:0deg;position:absolute;top:0;z-index:-1;",n.appendChild(a))}},{key:"stop",value:function(){var t=this.image;t.onload=null,t.onerror=null,t.parentNode.removeChild(t),this.image=null}},{key:"build",value:function(){if(this.sized&&!this.ready){var t=this.element,e=this.options,i=this.image,a=t.parentNode,n=document.createElement("div");n.innerHTML='<div class="cropper-container" touch-action="none"><div class="cropper-wrap-box"><div class="cropper-canvas"></div></div><div class="cropper-drag-box"></div><div class="cropper-crop-box"><span class="cropper-view-box"></span><span class="cropper-dashed dashed-h"></span><span class="cropper-dashed dashed-v"></span><span class="cropper-center"></span><span class="cropper-face"></span><span class="cropper-line line-e" data-cropper-action="e"></span><span class="cropper-line line-n" data-cropper-action="n"></span><span class="cropper-line line-w" data-cropper-action="w"></span><span class="cropper-line line-s" data-cropper-action="s"></span><span class="cropper-point point-e" data-cropper-action="e"></span><span class="cropper-point point-n" data-cropper-action="n"></span><span class="cropper-point point-w" data-cropper-action="w"></span><span class="cropper-point point-s" data-cropper-action="s"></span><span class="cropper-point point-ne" data-cropper-action="ne"></span><span class="cropper-point point-nw" data-cropper-action="nw"></span><span class="cropper-point point-sw" data-cropper-action="sw"></span><span class="cropper-point point-se" data-cropper-action="se"></span></div></div>';var r=n.querySelector(".".concat(m,"-container")),o=r.querySelector(".".concat(m,"-canvas")),h=r.querySelector(".".concat(m,"-drag-box")),s=r.querySelector(".".concat(m,"-crop-box")),c=s.querySelector(".".concat(m,"-face"));this.container=a,this.cropper=r,this.canvas=o,this.dragBox=h,this.cropBox=s,this.viewBox=r.querySelector(".".concat(m,"-view-box")),this.face=c,o.appendChild(i),Dt(t,E),a.insertBefore(r,t.nextSibling),Ct(i,W),this.initPreview(),this.bind(),e.initialAspectRatio=Math.max(0,e.initialAspectRatio)||NaN,e.aspectRatio=Math.max(0,e.aspectRatio)||NaN,e.viewMode=Math.max(0,Math.min(3,Math.round(e.viewMode)))||0,Dt(s,E),e.guides||Dt(s.getElementsByClassName("".concat(m,"-dashed")),E),e.center||Dt(s.getElementsByClassName("".concat(m,"-center")),E),e.background&&Dt(r,"".concat(m,"-bg")),e.highlight||Dt(c,H),e.cropBoxMovable&&(Dt(c,N),Et(c,S,g)),e.cropBoxResizable||(Dt(s.getElementsByClassName("".concat(m,"-line")),E),Dt(s.getElementsByClassName("".concat(m,"-point")),E)),this.render(),this.ready=!0,this.setDragMode(e.dragMode),e.autoCrop&&this.crop(),this.setData(e.data),mt(e.ready)&&Lt(t,K,e.ready,{once:!0}),Nt(t,K)}}},{key:"unbuild",value:function(){if(this.ready){this.ready=!1,this.unbind(),this.resetPreview();var t=this.cropper.parentNode;t&&t.removeChild(this.cropper),Ct(this.element,E)}}},{key:"uncreate",value:function(){this.ready?(this.unbuild(),this.ready=!1,this.cropped=!1):this.sizing?(this.sizingImage.onload=null,this.sizing=!1,this.sized=!1):this.reloading?(this.xhr.onabort=null,this.xhr.abort()):this.image&&this.stop()}}])&&e(i.prototype,a),n&&e(i,n),Object.defineProperty(i,"prototype",{writable:!1}),i;var i,a,n}();wt(ne.prototype,qt,$t,Qt,ee,ie,te);export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1]),[]),o=Math.min,i=Math.max,r=Math.round,l=Math.floor,c=t=>({x:t,y:t}),s={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return i(t,o(e,n))}function f(t,e){return"function"==typeof t?t(e):t}function u(t){return t.split("-")[0]}function d(t){return t.split("-")[1]}function h(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function g(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function p(t){return h(g(t))}function y(t,e,n){void 0===n&&(n=!1);const o=d(t),i=p(t),r=m(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=L(l)),[l,L(l)]}function w(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const x=["left","right"],v=["right","left"],b=["top","bottom"],R=["bottom","top"];function A(t,e,n,o){const i=d(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?v:x:e?x:v;case"left":case"right":return e?b:R;default:return[]}}(u(t),"start"===n,o);return i&&(r=r.map(t=>t+"-"+i),e&&(r=r.concat(r.map(w)))),r}function L(t){const e=u(t);return s[e]+t.slice(e.length)}function T(t){return"number"!=typeof t?function(t){return{top:0,right:0,bottom:0,left:0,...t}}(t):{top:t,right:t,bottom:t,left:t}}function O(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function E(t,e,n){let{reference:o,floating:i}=t;const r=g(e),l=p(e),c=m(l),s=u(e),a="y"===r,f=o.x+o.width/2-i.width/2,h=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let w;switch(s){case"top":w={x:f,y:o.y-i.height};break;case"bottom":w={x:f,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:h};break;case"left":w={x:o.x-i.width,y:h};break;default:w={x:o.x,y:o.y}}switch(d(e)){case"start":w[l]-=y*(n&&a?-1:1);break;case"end":w[l]+=y*(n&&a?-1:1)}return w}async function D(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:s}=t,{boundary:a="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:m=0}=f(e,t),g=T(m),p=c[h?"floating"===d?"reference":"floating":d],y=O(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(p)))||n?p:p.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:a,rootBoundary:u,strategy:s})),w="floating"===d?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=O(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:s}):w);return{top:(y.top-b.top+g.top)/v.y,bottom:(b.bottom-y.bottom+g.bottom)/v.y,left:(y.left-b.left+g.left)/v.x,right:(b.right-y.right+g.right)/v.x}}function C(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function S(e){return t.some(t=>e[t]>=0)}function P(t){const e=o(...t.map(t=>t.left)),n=o(...t.map(t=>t.top));return{x:e,y:n,width:i(...t.map(t=>t.right))-e,height:i(...t.map(t=>t.bottom))-n}}const F=new Set(["left","top"]);function H(){return"undefined"!=typeof window}function W(t){return M(t)?(t.nodeName||"").toLowerCase():"#document"}function k(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function B(t){var e;return null==(e=(M(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function M(t){return!!H()&&(t instanceof Node||t instanceof k(t).Node)}function V(t){return!!H()&&(t instanceof Element||t instanceof k(t).Element)}function z(t){return!!H()&&(t instanceof HTMLElement||t instanceof k(t).HTMLElement)}function N(t){return!(!H()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof k(t).ShadowRoot)}function $(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=Q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==i&&"contents"!==i}function I(t){return/^(table|td|th)$/.test(W(t))}function j(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const q=/transform|translate|scale|rotate|perspective|filter/,X=/paint|layout|strict|content/,Y=t=>!!t&&"none"!==t;let _;function G(t){const e=V(t)?Q(t):t;return Y(e.transform)||Y(e.translate)||Y(e.scale)||Y(e.rotate)||Y(e.perspective)||!J()&&(Y(e.backdropFilter)||Y(e.filter))||q.test(e.willChange||"")||X.test(e.contain||"")}function J(){return null==_&&(_="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_}function K(t){return/^(html|body|#document)$/.test(W(t))}function Q(t){return k(t).getComputedStyle(t)}function U(t){return V(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Z(t){if("html"===W(t))return t;const e=t.assignedSlot||t.parentNode||N(t)&&t.host||B(t);return N(e)?e.host:e}function tt(t){const e=Z(t);return K(e)?t.ownerDocument?t.ownerDocument.body:t.body:z(e)&&$(e)?e:tt(e)}function et(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=tt(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=k(i);if(r){const t=nt(l);return e.concat(l,l.visualViewport||[],$(i)?i:[],t&&n?et(t):[])}return e.concat(i,et(i,[],n))}function nt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ot(t){const e=Q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=z(t),l=i?t.offsetWidth:n,c=i?t.offsetHeight:o,s=r(n)!==l||r(o)!==c;return s&&(n=l,o=c),{width:n,height:o,$:s}}function it(t){return V(t)?t:t.contextElement}function rt(t){const e=it(t);if(!z(e))return c(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:l}=ot(e);let s=(l?r(n.width):n.width)/o,a=(l?r(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const lt=c(0);function ct(t){const e=k(t);return J()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:lt}function st(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=it(t);let l=c(1);e&&(o?V(o)&&(l=rt(o)):l=rt(t));const s=function(t,e,n){return void 0===e&&(e=!1),!(!n||e&&n!==k(t))&&e}(r,n,o)?ct(r):c(0);let a=(i.left+s.x)/l.x,f=(i.top+s.y)/l.y,u=i.width/l.x,d=i.height/l.y;if(r){const t=k(r),e=o&&V(o)?k(o):o;let n=t,i=nt(n);for(;i&&o&&e!==n;){const t=rt(i),e=i.getBoundingClientRect(),o=Q(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,d*=t.y,a+=r,f+=l,n=k(i),i=nt(n)}}return O({width:u,height:d,x:a,y:f})}function at(t,e){const n=U(t).scrollLeft;return e?e.left+n:st(B(t)).left+n}function ft(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-at(t,n),y:n.top+e.scrollTop}}function ut(t,e,n){let o;if("viewport"===e)o=function(t,e){const n=k(t),o=B(t),i=n.visualViewport;let r=o.clientWidth,l=o.clientHeight,c=0,s=0;if(i){r=i.width,l=i.height;const t=J();(!t||t&&"fixed"===e)&&(c=i.offsetLeft,s=i.offsetTop)}const a=at(o);if(a<=0){const t=o.ownerDocument,e=t.body,n=getComputedStyle(e),i="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,l=Math.abs(o.clientWidth-e.clientWidth-i);l<=25&&(r-=l)}else a<=25&&(r+=a);return{width:r,height:l,x:c,y:s}}(t,n);else if("document"===e)o=function(t){const e=B(t),n=U(t),o=t.ownerDocument.body,r=i(e.scrollWidth,e.clientWidth,o.scrollWidth,o.clientWidth),l=i(e.scrollHeight,e.clientHeight,o.scrollHeight,o.clientHeight);let c=-n.scrollLeft+at(t);const s=-n.scrollTop;return"rtl"===Q(o).direction&&(c+=i(e.clientWidth,o.clientWidth)-r),{width:r,height:l,x:c,y:s}}(B(t));else if(V(e))o=function(t,e){const n=st(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=z(t)?rt(t):c(1);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=ct(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return O(o)}function dt(t,e){const n=Z(t);return!(n===e||!V(n)||K(n))&&("fixed"===Q(n).position||dt(n,e))}function ht(t,e,n){const o=z(e),i=B(e),r="fixed"===n,l=st(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const a=c(0);function f(){a.x=at(i)}if(o||!o&&!r)if(("body"!==W(e)||$(i))&&(s=U(e)),o){const t=st(e,!0,r,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}else i&&f();r&&!o&&i&&f();const u=!i||o||r?c(0):ft(i,s);return{x:l.left+s.scrollLeft-a.x-u.x,y:l.top+s.scrollTop-a.y-u.y,width:l.width,height:l.height}}function mt(t){return"static"===Q(t).position}function gt(t,e){if(!z(t)||"fixed"===Q(t).position)return null;if(e)return e(t);let n=t.offsetParent;return B(t)===n&&(n=n.ownerDocument.body),n}function pt(t,e){const n=k(t);if(j(t))return n;if(!z(t)){let e=Z(t);for(;e&&!K(e);){if(V(e)&&!mt(e))return e;e=Z(e)}return n}let o=gt(t,e);for(;o&&I(o)&&mt(o);)o=gt(o,e);return o&&K(o)&&mt(o)&&!G(o)?n:o||function(t){let e=Z(t);for(;z(e)&&!K(e);){if(G(e))return e;if(j(e))return null;e=Z(e)}return null}(t)||n}const yt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=B(o),s=!!e&&j(e.floating);if(o===l||s&&r)return n;let a={scrollLeft:0,scrollTop:0},f=c(1);const u=c(0),d=z(o);if((d||!d&&!r)&&(("body"!==W(o)||$(l))&&(a=U(o)),d)){const t=st(o);f=rt(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const h=!l||d||r?c(0):ft(l,a);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-a.scrollTop*f.y+u.y+h.y}},getDocumentElement:B,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:l}=t;const c=[..."clippingAncestors"===n?j(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(t=>V(t)&&"body"!==W(t)),i=null;const r="fixed"===Q(t).position;let l=r?Z(t):t;for(;V(l)&&!K(l);){const e=Q(l),n=G(l);n||"fixed"!==e.position||(i=null),(r?!n&&!i:!n&&"static"===e.position&&i&&("absolute"===i.position||"fixed"===i.position)||$(l)&&!n&&dt(t,l))?o=o.filter(t=>t!==l):i=e,l=Z(l)}return e.set(t,o),o}(e,this._c):[].concat(n),r],s=ut(e,c[0],l);let a=s.top,f=s.right,u=s.bottom,d=s.left;for(let t=1;t<c.length;t++){const n=ut(e,c[t],l);a=i(n.top,a),f=o(n.right,f),u=o(n.bottom,u),d=i(n.left,d)}return{width:f-d,height:u-a,x:d,y:a}},getOffsetParent:pt,getElementRects:async function(t){const e=this.getOffsetParent||pt,n=this.getDimensions,o=await n(t.floating);return{reference:ht(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return Array.from(t.getClientRects())},getDimensions:function(t){const{width:e,height:n}=ot(t);return{width:e,height:n}},getScale:rt,isElement:V,isRTL:function(t){return"rtl"===Q(t).direction}};function wt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function xt(t,e,n,r){void 0===r&&(r={});const{ancestorScroll:c=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:u=!1}=r,d=it(t),h=c||s?[...d?et(d):[],...e?et(e):[]]:[];h.forEach(t=>{c&&t.addEventListener("scroll",n,{passive:!0}),s&&t.addEventListener("resize",n)});const m=d&&f?function(t,e){let n,r=null;const c=B(t);function s(){var t;clearTimeout(n),null==(t=r)||t.disconnect(),r=null}return function a(f,u){void 0===f&&(f=!1),void 0===u&&(u=1),s();const d=t.getBoundingClientRect(),{left:h,top:m,width:g,height:p}=d;if(f||e(),!g||!p)return;const y={rootMargin:-l(m)+"px "+-l(c.clientWidth-(h+g))+"px "+-l(c.clientHeight-(m+p))+"px "+-l(h)+"px",threshold:i(0,o(1,u))||1};let w=!0;function x(e){const o=e[0].intersectionRatio;if(o!==u){if(!w)return a();o?a(!1,o):n=setTimeout(()=>{a(!1,1e-7)},1e3)}1!==o||wt(d,t.getBoundingClientRect())||a(),w=!1}try{r=new IntersectionObserver(x,{...y,root:c.ownerDocument})}catch(t){r=new IntersectionObserver(x,y)}r.observe(t)}(!0),s}(d,n):null;let g,p=-1,y=null;a&&(y=new ResizeObserver(t=>{let[o]=t;o&&o.target===d&&y&&e&&(y.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(e)})),n()}),d&&!u&&y.observe(d),e&&y.observe(e));let w=u?st(t):null;return u&&function e(){const o=st(t);w&&!wt(w,o)&&n();w=o,g=requestAnimationFrame(e)}(),n(),()=>{var t;h.forEach(t=>{c&&t.removeEventListener("scroll",n),s&&t.removeEventListener("resize",n)}),null==m||m(),null==(t=y)||t.disconnect(),y=null,u&&cancelAnimationFrame(g)}}const vt=D,bt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,s=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=u(n),c=d(n),s="y"===g(n),a=F.has(l)?-1:1,h=r&&s?-1:1,m=f(e,t);let{mainAxis:p,crossAxis:y,alignmentAxis:w}="number"==typeof m?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&"number"==typeof w&&(y="end"===c?-1*w:w),s?{x:y*h,y:p*a}:{x:p*a,y:y*h}}(e,t);return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+s.x,y:r+s.y,data:{...s,placement:l}}}}},Rt=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var o,i,r;const{rects:l,middlewareData:c,placement:s,platform:a,elements:h}=e,{crossAxis:m=!1,alignment:g,allowedPlacements:p=n,autoAlignment:x=!0,...v}=f(t,e),b=void 0!==g||p===n?function(t,e,n){return(t?[...n.filter(e=>d(e)===t),...n.filter(e=>d(e)!==t)]:n.filter(t=>u(t)===t)).filter(n=>!t||d(n)===t||!!e&&w(n)!==n)}(g||null,x,p):p,R=await a.detectOverflow(e,v),A=(null==(o=c.autoPlacement)?void 0:o.index)||0,L=b[A];if(null==L)return{};const T=y(L,l,await(null==a.isRTL?void 0:a.isRTL(h.floating)));if(s!==L)return{reset:{placement:b[0]}};const O=[R[u(L)],R[T[0]],R[T[1]]],E=[...(null==(i=c.autoPlacement)?void 0:i.overflows)||[],{placement:L,overflows:O}],D=b[A+1];if(D)return{data:{index:A+1,overflows:E},reset:{placement:D}};const C=E.map(t=>{const e=d(t.placement);return[t.placement,e&&m?t.overflows.slice(0,2).reduce((t,e)=>t+e,0):t.overflows[0],t.overflows]}).sort((t,e)=>t[1]-e[1]),S=(null==(r=C.filter(t=>t[2].slice(0,d(t[0])?2:3).every(t=>t<=0))[0])?void 0:r[0])||C[0][0];return S!==s?{data:{index:A+1,overflows:E},reset:{placement:S}}:{}}}},At=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i,platform:r}=e,{mainAxis:l=!0,crossAxis:c=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...d}=f(t,e),m={x:n,y:o},p=await r.detectOverflow(e,d),y=g(u(i)),w=h(y);let x=m[w],v=m[y];if(l){const t="y"===w?"bottom":"right";x=a(x+p["y"===w?"top":"left"],x,x-p[t])}if(c){const t="y"===y?"bottom":"right";v=a(v+p["y"===y?"top":"left"],v,v-p[t])}const b=s.fn({...e,[w]:x,[y]:v});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[w]:l,[y]:c}}}}}},Lt=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:s,elements:a}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...b}=f(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const R=u(i),T=g(c),O=u(c)===c,E=await(null==s.isRTL?void 0:s.isRTL(a.floating)),D=m||(O||!v?[L(c)]:function(t){const e=L(t);return[w(t),e,w(e)]}(c)),C="none"!==x;!m&&C&&D.push(...A(c,v,x,E));const S=[c,...D],P=await s.detectOverflow(e,b),F=[];let H=(null==(o=r.flip)?void 0:o.overflows)||[];if(d&&F.push(P[R]),h){const t=y(i,l,E);F.push(P[t[0]],P[t[1]])}if(H=[...H,{placement:i,overflows:F}],!F.every(t=>t<=0)){var W,k;const t=((null==(W=r.flip)?void 0:W.index)||0)+1,e=S[t];if(e){if(!("alignment"===h&&T!==g(e))||H.every(t=>g(t.placement)!==T||t.overflows[0]>0))return{data:{index:t,overflows:H},reset:{placement:e}}}let n=null==(k=H.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:k.placement;if(!n)switch(p){case"bestFit":{var B;const t=null==(B=H.filter(t=>{if(C){const e=g(t.placement);return e===T||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:B[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}},Tt=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:l,rects:c,platform:s,elements:a}=e,{apply:h=()=>{},...m}=f(t,e),p=await s.detectOverflow(e,m),y=u(l),w=d(l),x="y"===g(l),{width:v,height:b}=c.floating;let R,A;"top"===y||"bottom"===y?(R=y,A=w===(await(null==s.isRTL?void 0:s.isRTL(a.floating))?"start":"end")?"left":"right"):(A=y,R="end"===w?"top":"bottom");const L=b-p.top-p.bottom,T=v-p.left-p.right,O=o(b-p[R],L),E=o(v-p[A],T),D=!e.middlewareData.shift;let C=O,S=E;if(null!=(n=e.middlewareData.shift)&&n.enabled.x&&(S=T),null!=(r=e.middlewareData.shift)&&r.enabled.y&&(C=L),D&&!w){const t=i(p.left,0),e=i(p.right,0),n=i(p.top,0),o=i(p.bottom,0);x?S=v-2*(0!==t||0!==e?t+e:i(p.left,p.right)):C=b-2*(0!==n||0!==o?n+o:i(p.top,p.bottom))}await h({...e,availableWidth:S,availableHeight:C});const P=await s.getDimensions(a.floating);return v!==P.width||b!==P.height?{reset:{rects:!0}}:{}}}},Ot=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:o}=e,{strategy:i="referenceHidden",...r}=f(t,e);switch(i){case"referenceHidden":{const t=C(await o.detectOverflow(e,{...r,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:S(t)}}}case"escaped":{const t=C(await o.detectOverflow(e,{...r,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:S(t)}}}default:return{}}}}},Et=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:l,platform:c,elements:s,middlewareData:u}=e,{element:h,padding:g=0}=f(t,e)||{};if(null==h)return{};const y=T(g),w={x:n,y:i},x=p(r),v=m(x),b=await c.getDimensions(h),R="y"===x,A=R?"top":"left",L=R?"bottom":"right",O=R?"clientHeight":"clientWidth",E=l.reference[v]+l.reference[x]-w[x]-l.floating[v],D=w[x]-l.reference[x],C=await(null==c.getOffsetParent?void 0:c.getOffsetParent(h));let S=C?C[O]:0;S&&await(null==c.isElement?void 0:c.isElement(C))||(S=s.floating[O]||l.floating[v]);const P=E/2-D/2,F=S/2-b[v]/2-1,H=o(y[A],F),W=o(y[L],F),k=H,B=S-b[v]-W,M=S/2-b[v]/2+P,V=a(k,M,B),z=!u.arrow&&null!=d(r)&&M!==V&&l.reference[v]/2-(M<k?H:W)-b[v]/2<0,N=z?M<k?M-k:M-B:0;return{[x]:w[x]+N,data:{[x]:V,centerOffset:M-V-N,...z&&{alignmentOffset:N}},reset:z}}}),Dt=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:l,platform:c,strategy:s}=e,{padding:a=2,x:d,y:h}=f(t,e),m=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(r.reference))||[]),p=function(t){const e=t.slice().sort((t,e)=>t.y-e.y),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i}return n.map(t=>O(P(t)))}(m),y=O(P(m)),w=T(a);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===p.length&&p[0].left>p[1].right&&null!=d&&null!=h)return p.find(t=>d>t.left-w.left&&d<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)||y;if(p.length>=2){if("y"===g(n)){const t=p[0],e=p[p.length-1],o="top"===u(n),i=t.top,r=e.bottom,l=o?t.left:e.left,c=o?t.right:e.right;return{top:i,bottom:r,left:l,right:c,width:c-l,height:r-i,x:l,y:i}}const t="left"===u(n),e=i(...p.map(t=>t.right)),r=o(...p.map(t=>t.left)),l=p.filter(n=>t?n.left===r:n.right===e),c=l[0].top,s=l[l.length-1].bottom;return{top:c,bottom:s,left:r,right:e,width:e-r,height:s-c,x:r,y:c}}return y}},floating:r.floating,strategy:s});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},Ct=function(t){return void 0===t&&(t={}),{options:t,fn(e){const{x:n,y:o,placement:i,rects:r,middlewareData:l}=e,{offset:c=0,mainAxis:s=!0,crossAxis:a=!0}=f(t,e),d={x:n,y:o},m=g(i),p=h(m);let y=d[p],w=d[m];const x=f(c,e),v="number"==typeof x?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(s){const t="y"===p?"height":"width",e=r.reference[p]-r.floating[t]+v.mainAxis,n=r.reference[p]+r.reference[t]-v.mainAxis;y<e?y=e:y>n&&(y=n)}if(a){var b,R;const t="y"===p?"width":"height",e=F.has(u(i)),n=r.reference[m]-r.floating[t]+(e&&(null==(b=l.offset)?void 0:b[m])||0)+(e?0:v.crossAxis),o=r.reference[m]+r.reference[t]+(e?0:(null==(R=l.offset)?void 0:R[m])||0)-(e?v.crossAxis:0);w<n?w=n:w>o&&(w=o)}return{[p]:y,[m]:w}}}},St=(t,e,n)=>{const o=new Map,i={platform:yt,...n},r={...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:D},s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=E(a,o,s),d=o,h=0;const m={};for(let n=0;n<r.length;n++){const g=r[n];if(!g)continue;const{name:p,fn:y}=g,{x:w,y:x,data:v,reset:b}=await y({x:f,y:u,initialPlacement:o,placement:d,strategy:i,middlewareData:m,rects:a,platform:c,elements:{reference:t,floating:e}});f=null!=w?w:f,u=null!=x?x:u,m[p]={...m[p],...v},b&&h<50&&(h++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(a=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=E(a,d,s))),n=-1)}return{x:f,y:u,placement:d,strategy:i,middlewareData:m}})(t,e,{...i,platform:r})};export{Et as arrow,Rt as autoPlacement,xt as autoUpdate,St as computePosition,vt as detectOverflow,Lt as flip,et as getOverflowAncestors,Ot as hide,Dt as inline,Ct as limitShift,bt as offset,yt as platform,At as shift,Tt as size};
|
|
1
|
+
const t=["top","right","bottom","left"],e=["start","end"],n=t.reduce((t,n)=>t.concat(n,n+"-"+e[0],n+"-"+e[1]),[]),o=Math.min,i=Math.max,r=Math.round,l=Math.floor,c=t=>({x:t,y:t}),s={left:"right",right:"left",bottom:"top",top:"bottom"};function a(t,e,n){return i(t,o(e,n))}function f(t,e){return"function"==typeof t?t(e):t}function u(t){return t.split("-")[0]}function d(t){return t.split("-")[1]}function h(t){return"x"===t?"y":"x"}function m(t){return"y"===t?"height":"width"}function g(t){const e=t[0];return"t"===e||"b"===e?"y":"x"}function p(t){return h(g(t))}function y(t,e,n){void 0===n&&(n=!1);const o=d(t),i=p(t),r=m(i);let l="x"===i?o===(n?"end":"start")?"right":"left":"start"===o?"bottom":"top";return e.reference[r]>e.floating[r]&&(l=L(l)),[l,L(l)]}function w(t){return t.includes("start")?t.replace("start","end"):t.replace("end","start")}const x=["left","right"],v=["right","left"],b=["top","bottom"],R=["bottom","top"];function A(t,e,n,o){const i=d(t);let r=function(t,e,n){switch(t){case"top":case"bottom":return n?e?v:x:e?x:v;case"left":case"right":return e?b:R;default:return[]}}(u(t),"start"===n,o);return i&&(r=r.map(t=>t+"-"+i),e&&(r=r.concat(r.map(w)))),r}function L(t){const e=u(t);return s[e]+t.slice(e.length)}function T(t){return"number"!=typeof t?function(t){var e,n,o,i;return{top:null!=(e=t.top)?e:0,right:null!=(n=t.right)?n:0,bottom:null!=(o=t.bottom)?o:0,left:null!=(i=t.left)?i:0}}(t):{top:t,right:t,bottom:t,left:t}}function E(t){const{x:e,y:n,width:o,height:i}=t;return{width:o,height:i,top:n,left:e,right:e+o,bottom:n+i,x:e,y:n}}function O(t,e,n){let{reference:o,floating:i}=t;const r=g(e),l=p(e),c=m(l),s=u(e),a="y"===r,f=o.x+o.width/2-i.width/2,h=o.y+o.height/2-i.height/2,y=o[c]/2-i[c]/2;let w;switch(s){case"top":w={x:f,y:o.y-i.height};break;case"bottom":w={x:f,y:o.y+o.height};break;case"right":w={x:o.x+o.width,y:h};break;case"left":w={x:o.x-i.width,y:h};break;default:w={x:o.x,y:o.y}}const x=d(e);return x&&(w[l]+=y*("end"===x?1:-1)*(n&&a?-1:1)),w}async function C(t,e){var n;void 0===e&&(e={});const{x:o,y:i,platform:r,rects:l,elements:c,strategy:s}=t,{boundary:a="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:m=0}=f(e,t),g=T(m),p=c[h?"floating"===d?"reference":"floating":d],y=E(await r.getClippingRect({element:null==(n=await(null==r.isElement?void 0:r.isElement(p)))||n?p:p.contextElement||await(null==r.getDocumentElement?void 0:r.getDocumentElement(c.floating)),boundary:a,rootBoundary:u,strategy:s})),w="floating"===d?{x:o,y:i,width:l.floating.width,height:l.floating.height}:l.reference,x=await(null==r.getOffsetParent?void 0:r.getOffsetParent(c.floating)),v=await(null==r.isElement?void 0:r.isElement(x))&&await(null==r.getScale?void 0:r.getScale(x))||{x:1,y:1},b=E(r.convertOffsetParentRelativeRectToViewportRelativeRect?await r.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:w,offsetParent:x,strategy:s}):w);return{top:(y.top-b.top+g.top)/v.y,bottom:(b.bottom-y.bottom+g.bottom)/v.y,left:(y.left-b.left+g.left)/v.x,right:(b.right-y.right+g.right)/v.x}}function D(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function S(e){return t.some(t=>e[t]>=0)}function P(t){const e=o(...t.map(t=>t.left)),n=o(...t.map(t=>t.top));return{x:e,y:n,width:i(...t.map(t=>t.right))-e,height:i(...t.map(t=>t.bottom))-n}}const F=new Set(["left","top"]);function H(){return"undefined"!=typeof window}function W(t){return V(t)?(t.nodeName||"").toLowerCase():"#document"}function B(t){var e;return(null==t||null==(e=t.ownerDocument)?void 0:e.defaultView)||window}function k(t){var e;return null==(e=(V(t)?t.ownerDocument:t.document)||window.document)?void 0:e.documentElement}function V(t){return!!H()&&(t instanceof Node||t instanceof B(t).Node)}function M(t){return!!H()&&(t instanceof Element||t instanceof B(t).Element)}function z(t){return!!H()&&(t instanceof HTMLElement||t instanceof B(t).HTMLElement)}function N(t){return!(!H()||"undefined"==typeof ShadowRoot)&&(t instanceof ShadowRoot||t instanceof B(t).ShadowRoot)}function $(t){const{overflow:e,overflowX:n,overflowY:o,display:i}=Q(t);return/auto|scroll|overlay|hidden|clip/.test(e+o+n)&&"inline"!==i&&"contents"!==i}function I(t){return/^(table|td|th)$/.test(W(t))}function j(t){try{if(t.matches(":popover-open"))return!0}catch(t){}try{return t.matches(":modal")}catch(t){return!1}}const q=/transform|translate|scale|rotate|perspective|filter/,X=/paint|layout|strict|content/,Y=t=>!!t&&"none"!==t;let _;function G(t){const e=M(t)?Q(t):t;return Y(e.transform)||Y(e.translate)||Y(e.scale)||Y(e.rotate)||Y(e.perspective)||!J()&&(Y(e.backdropFilter)||Y(e.filter))||q.test(e.willChange||"")||X.test(e.contain||"")}function J(){return null==_&&(_="undefined"!=typeof CSS&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),_}function K(t){return/^(html|body|#document)$/.test(W(t))}function Q(t){return B(t).getComputedStyle(t)}function U(t){return M(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Z(t){if("html"===W(t))return t;const e=t.assignedSlot||t.parentNode||N(t)&&t.host||k(t);return N(e)?e.host:e}function tt(t){const e=Z(t);return K(e)?(t.ownerDocument||t).body:z(e)&&$(e)?e:tt(e)}function et(t,e,n){var o;void 0===e&&(e=[]),void 0===n&&(n=!0);const i=tt(t),r=i===(null==(o=t.ownerDocument)?void 0:o.body),l=B(i);if(r){const t=nt(l);return e.concat(l,l.visualViewport||[],$(i)?i:[],t&&n?et(t):[])}return e.concat(i,et(i,[],n))}function nt(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function ot(t){const e=Q(t);let n=parseFloat(e.width)||0,o=parseFloat(e.height)||0;const i=z(t),l=i?t.offsetWidth:n,c=i?t.offsetHeight:o,s=r(n)!==l||r(o)!==c;return s&&(n=l,o=c),{width:n,height:o,$:s}}function it(t){return M(t)?t:t.contextElement}function rt(t){const e=it(t);if(!z(e))return c(1);const n=e.getBoundingClientRect(),{width:o,height:i,$:l}=ot(e);let s=(l?r(n.width):n.width)/o,a=(l?r(n.height):n.height)/i;return s&&Number.isFinite(s)||(s=1),a&&Number.isFinite(a)||(a=1),{x:s,y:a}}const lt=c(0);function ct(t){const e=B(t);return J()&&e.visualViewport?{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}:lt}function st(t,e,n,o){void 0===e&&(e=!1),void 0===n&&(n=!1);const i=t.getBoundingClientRect(),r=it(t);let l=c(1);e&&(o?M(o)&&(l=rt(o)):l=rt(t));const s=function(t,e,n){return void 0===e&&(e=!1),!!n&&e&&n===B(t)}(r,n,o)?ct(r):c(0);let a=(i.left+s.x)/l.x,f=(i.top+s.y)/l.y,u=i.width/l.x,d=i.height/l.y;if(r&&o){const t=B(r),e=M(o)?B(o):o;let n=t,i=nt(n);for(;i&&e!==n;){const t=rt(i),e=i.getBoundingClientRect(),o=Q(i),r=e.left+(i.clientLeft+parseFloat(o.paddingLeft))*t.x,l=e.top+(i.clientTop+parseFloat(o.paddingTop))*t.y;a*=t.x,f*=t.y,u*=t.x,d*=t.y,a+=r,f+=l,n=B(i),i=nt(n)}}return E({width:u,height:d,x:a,y:f})}function at(t,e){const n=U(t).scrollLeft;return e?e.left+n:st(k(t)).left+n}function ft(t,e){const n=t.getBoundingClientRect();return{x:n.left+e.scrollLeft-at(t,n),y:n.top+e.scrollTop}}function ut(t,e,n){let o;if("viewport"===e||"layoutViewport"===e)o=function(t,e,n){void 0===n&&(n="viewport");const o="layoutViewport"===n,i=B(t),r=k(t),l=i.visualViewport;let c=r.clientWidth,s=r.clientHeight,a=0,f=0;if(l){const t=!J()||"fixed"===e;o?t||(a=-l.offsetLeft,f=-l.offsetTop):(c=l.width,s=l.height,t&&(a=l.offsetLeft,f=l.offsetTop))}if(at(r)<=0){const t=r.ownerDocument,e=t.body,n=getComputedStyle(e),o="CSS1Compat"===t.compatMode&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,i=Math.abs(r.clientWidth-e.clientWidth-o),l="stable both-edges"===getComputedStyle(r).scrollbarGutter?i/2:i;l<=25&&(c-=l)}return{width:c,height:s,x:a,y:f}}(t,n,e);else if("document"===e)o=function(t){const e=U(t),n=t.ownerDocument.body,o=i(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),r=i(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let l=-e.scrollLeft+at(t);const c=-e.scrollTop;return"rtl"===Q(n).direction&&(l+=i(t.clientWidth,n.clientWidth)-o),{width:o,height:r,x:l,y:c}}(k(t));else if(M(e))o=function(t,e){const n=st(t,!0,"fixed"===e),o=n.top+t.clientTop,i=n.left+t.clientLeft,r=rt(t);return{width:t.clientWidth*r.x,height:t.clientHeight*r.y,x:i*r.x,y:o*r.y}}(e,n);else{const n=ct(t);o={x:e.x-n.x,y:e.y-n.y,width:e.width,height:e.height}}return E(o)}function dt(t,e,n){const o=z(e),i=k(e),r="fixed"===n,l=st(t,!0,r,e);let s={scrollLeft:0,scrollTop:0};const a=c(0);if((o||!r)&&(("body"!==W(e)||$(i))&&(s=U(e)),o)){const t=st(e,!0,r,e);a.x=t.x+e.clientLeft,a.y=t.y+e.clientTop}!o&&i&&(a.x=at(i));const f=!i||o||r?c(0):ft(i,s);return{x:l.left+s.scrollLeft-a.x-f.x,y:l.top+s.scrollTop-a.y-f.y,width:l.width,height:l.height}}function ht(t){return"static"===Q(t).position}function mt(t,e){if(!z(t)||"fixed"===Q(t).position)return null;if(e)return e(t);let n=t.offsetParent;return k(t)===n&&(n=n.ownerDocument.body),n}function gt(t,e){const n=B(t);if(j(t))return n;if(!z(t)){let e=Z(t);for(;e&&!K(e);){if(M(e)&&!ht(e))return e;e=Z(e)}return n}let o=mt(t,e);for(;o&&I(o)&&ht(o);)o=mt(o,e);return o&&K(o)&&ht(o)&&!G(o)?n:o||function(t){let e=Z(t);for(;z(e)&&!K(e);){if(G(e))return e;if(j(e))return null;e=Z(e)}return null}(t)||n}const pt={convertOffsetParentRelativeRectToViewportRelativeRect:function(t){let{elements:e,rect:n,offsetParent:o,strategy:i}=t;const r="fixed"===i,l=k(o),s=!!e&&j(e.floating);if(o===l||s&&r)return n;let a={scrollLeft:0,scrollTop:0},f=c(1);const u=c(0),d=z(o);if((d||!r)&&(("body"!==W(o)||$(l))&&(a=U(o)),d)){const t=st(o);f=rt(o),u.x=t.x+o.clientLeft,u.y=t.y+o.clientTop}const h=!l||d||r?c(0):ft(l,a);return{width:n.width*f.x,height:n.height*f.y,x:n.x*f.x-a.scrollLeft*f.x+u.x+h.x,y:n.y*f.y-a.scrollTop*f.y+u.y+h.y}},getDocumentElement:k,getClippingRect:function(t){let{element:e,boundary:n,rootBoundary:r,strategy:l}=t;const c=[..."clippingAncestors"===n?j(e)?[]:function(t,e){const n=e.get(t);if(n)return n;let o=et(t,[],!1).filter(t=>M(t)&&"body"!==W(t)),i=null;const r="fixed"===Q(t).position;let l=r?Z(t):t;for(;M(l)&&!K(l);){const t=Q(l),e=G(l),n=i?i.position:r?"fixed":"";e||"fixed"!==n&&("absolute"!==n||"static"!==t.position)?i=t:o=o.filter(t=>t!==l),l=Z(l)}return e.set(t,o),o}(e,this._c):[].concat(n),r],s=ut(e,c[0],l);let a=s.top,f=s.right,u=s.bottom,d=s.left;for(let t=1;t<c.length;t++){const n=ut(e,c[t],l);a=i(n.top,a),f=o(n.right,f),u=o(n.bottom,u),d=i(n.left,d)}return{width:f-d,height:u-a,x:d,y:a}},getOffsetParent:gt,getElementRects:async function(t){const e=this.getOffsetParent||gt,n=this.getDimensions,o=await n(t.floating);return{reference:dt(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}},getClientRects:function(t){return t.getClientRects?Array.from(t.getClientRects()):[]},getDimensions:function(t){const{width:e,height:n}=ot(t);return{width:e,height:n}},getScale:rt,isElement:M,isRTL:function(t){return"rtl"===Q(t).direction}};function yt(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function wt(t,e,n,r){void 0===r&&(r={});const{ancestorScroll:c=!0,ancestorResize:s=!0,elementResize:a="function"==typeof ResizeObserver,layoutShift:f="function"==typeof IntersectionObserver,animationFrame:u=!1}=r,d=it(t),h=c||s?[...d?et(d):[],...e?et(e):[]]:[];h.forEach(t=>{c&&t.addEventListener("scroll",n),s&&t.addEventListener("resize",n)});const m=d&&f?function(t,e,n){let r,c=null;const s=k(t);function a(){var t;clearTimeout(r),null==(t=c)||t.disconnect(),c=null}function f(n,u){void 0===n&&(n=!1),void 0===u&&(u=1),a();const d=t.getBoundingClientRect(),{left:h,top:m,width:g,height:p}=d;if(n||e(),!g||!p)return;const y={rootMargin:-l(m)+"px "+-l(s.clientWidth-(h+g))+"px "+-l(s.clientHeight-(m+p))+"px "+-l(h)+"px",threshold:i(0,o(1,u))||1};let w=!0;function x(e){const n=e[0].intersectionRatio;if(!yt(d,t.getBoundingClientRect()))return f();if(n!==u){if(!w)return f();n?f(!1,n):r=setTimeout(()=>{f(!1,1e-7)},1e3)}w=!1}try{c=new IntersectionObserver(x,{...y,root:s.ownerDocument})}catch(t){c=new IntersectionObserver(x,y)}c.observe(t)}const u=B(t),d=()=>f(n);return u.addEventListener("resize",d),f(!0),()=>{u.removeEventListener("resize",d),a()}}(d,n,s):null;let g,p=-1,y=null;a&&(y=new ResizeObserver(t=>{let[o]=t;o&&o.target===d&&y&&e&&(y.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var t;null==(t=y)||t.observe(e)})),n()}),d&&!u&&y.observe(d),e&&y.observe(e));let w=u?st(t):null;return u&&function e(){const o=st(t);w&&!yt(w,o)&&n();w=o,g=requestAnimationFrame(e)}(),n(),()=>{var t;h.forEach(t=>{c&&t.removeEventListener("scroll",n),s&&t.removeEventListener("resize",n)}),null==m||m(),null==(t=y)||t.disconnect(),y=null,u&&cancelAnimationFrame(g)}}const xt=C,vt=function(t){return void 0===t&&(t=0),{name:"offset",options:t,async fn(e){var n,o;const{x:i,y:r,placement:l,middlewareData:c}=e,s=await async function(t,e){const{placement:n,platform:o,elements:i}=t,r=await(null==o.isRTL?void 0:o.isRTL(i.floating)),l=u(n),c=d(n),s="y"===g(n),a=F.has(l)?-1:1,h=r&&s?-1:1,m=f(e,t);let{mainAxis:p,crossAxis:y,alignmentAxis:w}="number"==typeof m?{mainAxis:m,crossAxis:0,alignmentAxis:null}:{mainAxis:m.mainAxis||0,crossAxis:m.crossAxis||0,alignmentAxis:m.alignmentAxis};return c&&"number"==typeof w&&(y="end"===c?-1*w:w),s?{x:y*h,y:p*a}:{x:p*a,y:y*h}}(e,t);return l===(null==(n=c.offset)?void 0:n.placement)&&null!=(o=c.arrow)&&o.alignmentOffset?{}:{x:i+s.x,y:r+s.y,data:{...s,placement:l}}}}},bt=function(t){return void 0===t&&(t={}),{name:"autoPlacement",options:t,async fn(e){var o,i,r;const{rects:l,middlewareData:c,placement:s,platform:a,elements:h}=e,{crossAxis:m=!1,alignment:g,allowedPlacements:p=n,autoAlignment:x=!0,...v}=f(t,e),b=void 0!==g||p===n?function(t,e,n){return(t?[...n.filter(e=>d(e)===t),...n.filter(e=>d(e)!==t)]:n.filter(t=>u(t)===t)).filter(n=>!t||d(n)===t||!!e&&w(n)!==n)}(g||null,x,p):p,R=(null==(o=c.autoPlacement)?void 0:o.index)||0,A=b[R];if(null==A)return{};if(s!==A)return{reset:{placement:b[0]}};const L=await a.detectOverflow(e,v),T=y(A,l,await(null==a.isRTL?void 0:a.isRTL(h.floating))),E=[L[u(A)],L[T[0]],L[T[1]]],O=[...(null==(i=c.autoPlacement)?void 0:i.overflows)||[],{placement:A,overflows:E}],C=b[R+1];if(C)return{data:{index:R+1,overflows:O},reset:{placement:C}};const D=O.map(t=>{const e=d(t.placement);return[t.placement,e&&m?t.overflows.slice(0,2).reduce((t,e)=>t+e,0):t.overflows[0],t.overflows]}).sort((t,e)=>t[1]-e[1]),S=(null==(r=D.filter(t=>t[2].slice(0,d(t[0])?2:3).every(t=>t<=0))[0])?void 0:r[0])||D[0][0];return S!==s?{data:{index:R+1,overflows:O},reset:{placement:S}}:{}}}},Rt=function(t){return void 0===t&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:o,placement:i,platform:r}=e,{mainAxis:l=!0,crossAxis:c=!1,limiter:s={fn:t=>{let{x:e,y:n}=t;return{x:e,y:n}}},...u}=f(t,e),d={x:n,y:o},m=await r.detectOverflow(e,u),p=g(i),y=h(p);let w=d[y],x=d[p];const v=(t,e)=>a(e+m["y"===t?"top":"left"],e,e-m["y"===t?"bottom":"right"]);l&&(w=v(y,w)),c&&(x=v(p,x));const b=s.fn({...e,[y]:w,[p]:x});return{...b,data:{x:b.x-n,y:b.y-o,enabled:{[y]:l,[p]:c}}}}}},At=function(t){return void 0===t&&(t={}),{name:"flip",options:t,async fn(e){var n,o;const{placement:i,middlewareData:r,rects:l,initialPlacement:c,platform:s,elements:a}=e,{mainAxis:d=!0,crossAxis:h=!0,fallbackPlacements:m,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:x="none",flipAlignment:v=!0,...b}=f(t,e);if(null!=(n=r.arrow)&&n.alignmentOffset)return{};const R=u(i),T=g(c),E=u(c)===c,O=await(null==s.isRTL?void 0:s.isRTL(a.floating)),C=m||(E||!v?[L(c)]:function(t){const e=L(t);return[w(t),e,w(e)]}(c)),D="none"!==x;!m&&D&&C.push(...A(c,v,x,O));const S=[c,...C],P=await s.detectOverflow(e,b),F=[];let H=(null==(o=r.flip)?void 0:o.overflows)||[];if(d&&F.push(P[R]),h){const t=y(i,l,O);F.push(P[t[0]],P[t[1]])}if(H=[...H,{placement:i,overflows:F}],!F.every(t=>t<=0)){var W,B;const t=((null==(W=r.flip)?void 0:W.index)||0)+1,e=S[t];if(e){if(!("alignment"===h&&T!==g(e))||H.every(t=>g(t.placement)!==T||t.overflows[0]>0))return{data:{index:t,overflows:H},reset:{placement:e}}}let n=null==(B=H.filter(t=>t.overflows[0]<=0).sort((t,e)=>t.overflows[1]-e.overflows[1])[0])?void 0:B.placement;if(!n)switch(p){case"bestFit":{var k;const t=null==(k=H.filter(t=>{if(D){const e=g(t.placement);return e===T||"y"===e}return!0}).map(t=>[t.placement,t.overflows.filter(t=>t>0).reduce((t,e)=>t+e,0)]).sort((t,e)=>t[1]-e[1])[0])?void 0:k[0];t&&(n=t);break}case"initialPlacement":n=c}if(i!==n)return{reset:{placement:n}}}return{}}}},Lt=function(t){return void 0===t&&(t={}),{name:"size",options:t,async fn(e){const{placement:n,rects:r,platform:l,elements:c}=e,{apply:s=()=>{},...a}=f(t,e),h=await l.detectOverflow(e,a),m=u(n),p=d(n),y="y"===g(n),{width:w,height:x}=r.floating;let v,b;"top"===m||"bottom"===m?(v=m,b=p===(await(null==l.isRTL?void 0:l.isRTL(c.floating))?"start":"end")?"left":"right"):(b=m,v="end"===p?"top":"bottom");const R=x-h.top-h.bottom,A=w-h.left-h.right,L=o(x-h[v],R),T=o(w-h[b],A),E=e.middlewareData.shift,O=!E;let C=L,D=T;null!=E&&E.enabled.x&&(D=A),null!=E&&E.enabled.y&&(C=R),O&&!p&&(y?D=w-2*i(h.left,h.right):C=x-2*i(h.top,h.bottom)),await s({...e,availableWidth:D,availableHeight:C});const S=await l.getDimensions(c.floating);return w!==S.width||x!==S.height?{reset:{rects:!0}}:{}}}},Tt=function(t){return void 0===t&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n,platform:o}=e,{strategy:i="referenceHidden",...r}=f(t,e);switch(i){case"referenceHidden":{const t=D(await o.detectOverflow(e,{...r,elementContext:"reference"}),n.reference);return{data:{referenceHiddenOffsets:t,referenceHidden:S(t)}}}case"escaped":{const t=D(await o.detectOverflow(e,{...r,altBoundary:!0}),n.floating);return{data:{escapedOffsets:t,escaped:S(t)}}}default:return{}}}}},Et=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:i,placement:r,rects:l,platform:c,elements:s,middlewareData:u}=e,{element:h,padding:g=0}=f(t,e)||{};if(null==h)return{};const y=T(g),w={x:n,y:i},x=p(r),v=m(x),b=await c.getDimensions(h),R="y"===x,A=R?"top":"left",L=R?"bottom":"right",E=R?"clientHeight":"clientWidth",O=l.reference[v]+l.reference[x]-w[x]-l.floating[v],C=w[x]-l.reference[x],D=await(null==c.getOffsetParent?void 0:c.getOffsetParent(h));let S=D?D[E]:0;S&&await(null==c.isElement?void 0:c.isElement(D))||(S=s.floating[E]||l.floating[v]);const P=O/2-C/2,F=S/2-b[v]/2-1,H=o(y[A],F),W=o(y[L],F),B=S-b[v]-W,k=S/2-b[v]/2+P,V=a(H,k,B),M=!u.arrow&&null!=d(r)&&k!==V&&l.reference[v]/2-(k<H?H:W)-b[v]/2<0,z=M?k<H?k-H:k-B:0;return{[x]:w[x]+z,data:{[x]:V,centerOffset:k-V-z,...M&&{alignmentOffset:z}},reset:M}}}),Ot=function(t){return void 0===t&&(t={}),{name:"inline",options:t,async fn(e){const{placement:n,elements:r,rects:l,platform:c,strategy:s}=e,{padding:a=2,x:d,y:h}=f(t,e),m=Array.from(await(null==c.getClientRects?void 0:c.getClientRects(r.reference))||[]);if(!m.length)return{};const p=function(t){const e=t.slice().sort((t,e)=>t.y-e.y),n=[];let o=null;for(let t=0;t<e.length;t++){const i=e[t];!o||i.y-o.y>o.height/2?n.push([i]):n[n.length-1].push(i),o=i}return n.map(t=>E(P(t)))}(m),y=E(P(m)),w=T(a);const x=await c.getElementRects({reference:{getBoundingClientRect:function(){if(2===p.length&&(p[0].left>p[1].right||p[1].left>p[0].right)&&null!=d&&null!=h)return p.find(t=>d>t.left-w.left&&d<t.right+w.right&&h>t.top-w.top&&h<t.bottom+w.bottom)||y;if(p.length>=2){if("y"===g(n)){const t=p[0],e=p[p.length-1],o="top"===u(n),i=t.top,r=e.bottom,l=o?t.left:e.left;return E({x:l,y:i,width:(o?t.right:e.right)-l,height:r-i})}const t="left"===u(n),e=i(...p.map(t=>t.right)),r=o(...p.map(t=>t.left)),l=p.filter(n=>t?n.left===r:n.right===e),c=l[0].top,s=l[l.length-1].bottom;return E({x:r,y:c,width:e-r,height:s-c})}return y}},floating:r.floating,strategy:s});return l.reference.x!==x.reference.x||l.reference.y!==x.reference.y||l.reference.width!==x.reference.width||l.reference.height!==x.reference.height?{reset:{rects:x}}:{}}}},Ct=function(t){return void 0===t&&(t={}),{options:t,fn(e){var n,o;const{x:i,y:r,placement:l,rects:c,middlewareData:s}=e,{offset:a=0,mainAxis:d=!0,crossAxis:m=!0}=f(t,e),p={x:i,y:r},y=g(l),w=h(y);let x=p[w],v=p[y];const b=f(a,e),R="number"==typeof b?{mainAxis:b,crossAxis:0}:{mainAxis:null!=(n=b.mainAxis)?n:0,crossAxis:null!=(o=b.crossAxis)?o:0};if(d){const t="y"===w?"height":"width",e=c.reference[w]-c.floating[t]+R.mainAxis,n=c.reference[w]+c.reference[t]-R.mainAxis;x<e?x=e:x>n&&(x=n)}if(m){var A,L;const t="y"===w?"width":"height",e=F.has(u(l)),n=c.reference[y]-c.floating[t]+(e&&(null==(A=s.offset)?void 0:A[y])||0)+(e?0:R.crossAxis),o=c.reference[y]+c.reference[t]+(e?0:(null==(L=s.offset)?void 0:L[y])||0)-(e?R.crossAxis:0);v<n?v=n:v>o&&(v=o)}return{[w]:x,[y]:v}}}},Dt=(t,e,n)=>{const o=new Map,i=null!=n?n:{},r={...pt,...i.platform,_c:o};return(async(t,e,n)=>{const{placement:o="bottom",strategy:i="absolute",middleware:r=[],platform:l}=n,c=l.detectOverflow?l:{...l,detectOverflow:C},s=await(null==l.isRTL?void 0:l.isRTL(e));let a=await l.getElementRects({reference:t,floating:e,strategy:i}),{x:f,y:u}=O(a,o,s),d=o,h=0;const m={};for(let n=0;n<r.length;n++){const g=r[n];if(!g)continue;const{name:p,fn:y}=g,{x:w,y:x,data:v,reset:b}=await y({x:f,y:u,initialPlacement:o,placement:d,strategy:i,middlewareData:m,rects:a,platform:c,elements:{reference:t,floating:e}});f=null!=w?w:f,u=null!=x?x:u,m[p]={...m[p],...v},b&&h<50&&(h++,"object"==typeof b&&(b.placement&&(d=b.placement),b.rects&&(a=!0===b.rects?await l.getElementRects({reference:t,floating:e,strategy:i}):b.rects),({x:f,y:u}=O(a,d,s))),n=-1)}return{x:f,y:u,placement:d,strategy:i,middlewareData:m}})(t,e,{...i,platform:r})};export{Et as arrow,bt as autoPlacement,wt as autoUpdate,Dt as computePosition,xt as detectOverflow,At as flip,et as getOverflowAncestors,Tt as hide,Ot as inline,Ct as limitShift,vt as offset,pt as platform,Rt as shift,Lt as size};
|