From a8ae566f0e149f93c24c03e4dbad0478076213e1 Mon Sep 17 00:00:00 2001 From: Mattias Bodlund Date: Thu, 19 Mar 2026 15:12:46 +0100 Subject: [PATCH] na --- .DS_Store | Bin 6148 -> 8196 bytes .gitignore | 2 + Gemfile | 51 +- Gemfile.lock | 492 +++++++++++++----- README DB.txt | 24 +- README.txt | 6 +- app/controllers/answers_controller.rb | 42 -- .../concerns/quiz_helper_methods.rb | 5 +- app/controllers/languages_controller.rb | 15 +- app/controllers/players_controller.rb | 42 -- app/controllers/questions_controller.rb | 94 ---- app/controllers/site_controller.rb | 11 +- app/helpers/answers_helper.rb | 2 - app/helpers/players_helper.rb | 2 - app/helpers/questions_helper.rb | 99 ---- .../controllers/select_controller.js | 2 +- app/models/answer.rb | 11 - app/models/player.rb | 28 - app/models/quiz_result.rb | 15 - app/views/languages/index.html.erb | 15 +- app/views/layouts/application.html.erb | 17 +- app/views/players/new.html.erb | 39 -- app/views/questions/answer.html.erb | 45 -- app/views/questions/result.html.erb | 41 -- app/views/questions/shared_result.html.erb | 41 -- app/views/questions/show.html.erb | 57 -- bin/ci | 6 + bin/rubocop | 2 +- bin/setup | 1 + bin/thrust | 5 + config/application.rb | 9 +- config/cable.yml | 2 +- config/ci.rb | 22 + config/importmap.rb | 12 +- .../initializers/content_security_policy.rb | 4 + .../new_framework_defaults_7_2.rb | 70 --- .../new_framework_defaults_8_0.rb | 30 -- config/nginx.conf | 92 ++-- db/migrate/20250429085114_create_players.rb | 14 - db/migrate/20250429121602_create_answers.rb | 14 - .../20250522111116_add_score_to_players.rb | 6 - .../20250527114853_create_quiz_results.rb | 15 - db/schema.rb | 92 ++-- db/seeds.rb | 2 +- lib/tasks/quiz_stats.rake | 81 +++ mise.toml | 2 +- public/icon.png | Bin 0 -> 4166 bytes public/icon.svg | 3 + vendor/javascript/@rails--activestorage.js | 4 +- vendor/javascript/@rails--request.js.js | 4 +- vendor/javascript/sortablejs.js | 48 +- vendor/javascript/trix.js | 6 +- 52 files changed, 658 insertions(+), 1086 deletions(-) delete mode 100644 app/controllers/answers_controller.rb delete mode 100644 app/controllers/players_controller.rb delete mode 100644 app/controllers/questions_controller.rb delete mode 100644 app/helpers/answers_helper.rb delete mode 100644 app/helpers/players_helper.rb delete mode 100644 app/helpers/questions_helper.rb delete mode 100644 app/models/answer.rb delete mode 100644 app/models/player.rb delete mode 100644 app/models/quiz_result.rb delete mode 100644 app/views/players/new.html.erb delete mode 100644 app/views/questions/answer.html.erb delete mode 100644 app/views/questions/result.html.erb delete mode 100644 app/views/questions/shared_result.html.erb delete mode 100644 app/views/questions/show.html.erb create mode 100755 bin/ci create mode 100755 bin/thrust create mode 100644 config/ci.rb delete mode 100644 config/initializers/new_framework_defaults_7_2.rb delete mode 100644 config/initializers/new_framework_defaults_8_0.rb delete mode 100644 db/migrate/20250429085114_create_players.rb delete mode 100644 db/migrate/20250429121602_create_answers.rb delete mode 100644 db/migrate/20250522111116_add_score_to_players.rb delete mode 100644 db/migrate/20250527114853_create_quiz_results.rb create mode 100644 lib/tasks/quiz_stats.rake create mode 100644 public/icon.png create mode 100644 public/icon.svg diff --git a/.DS_Store b/.DS_Store index 185b8991e36a342e8d21e7379c6da5f9f112bb3a..fa5256251024b860ba7d162ca80b3ef0537b8823 100644 GIT binary patch literal 8196 zcmeHMJ!n%=6h1GBuMr&#R4sz=20^4ytUpV!7;7BtAZmv~rC`&vu{6mGwJj7K0&XrY zIw{z#4uas&#X&*TNs-n;>>#++AB<6#g5Y<5l6UTVdEjQzd*QwFxZgSFJNMkb+#4ct z2IdOAL|sIb#v|m8ZFsdQ0vAuDBy>$5qyu}R0+nc@RO}rZ_aoZ2!e+o`z-GW^z-GW^ zU^8R@d$uU)n0;TN_H8p@Gw@$#K&%fQ9wD<@)|8Y>2VU|B0GUFyEcnJbK-zd(X0@y- zDNW&1ogN%*>gXeeqs)POLLD-zWlc$CPL47sM>9M6gyKkc*m+W&oUD@eZ8Kmq5Y2!% zyLV6z#HN{&rY<{D*S;~^^&+PXtK%Kn?gKA znxa{Clc2FHuO5P-^A6rQ}zNs1b`>5`8g66(b7DGy;T2ac=EH{mA?0qUGAI z><3XqQ6mbf!HirQCm(%33D%;)>g+um#yR)LtILf;iretPBZ$*6;z&LbaU?MM@&-R0 zJKn74yd&HDzvvMsZ8%>TGk6>i?l3|MG>x{FO|JA|j&Z)bnX&a-pJh+CY&mB;+~6h2 zo5bDNRJes(H^8b9&iVM!>(OB~t6FH#uTj+Gle0+J`DTwMIuAV6d_Xwg`Q0zej8CEg zUliqhiOz#?ig8rM8j_c-95-{j^fruh?t1y1yErIkui=B|I8KMhL2B>spvyFimd{`| z7n`?{Y7NQ!xb^^%gfw_8cXobTxcyzur-)XNk9aK}Pi8~rCFCbG+f#^jLPTt4tg8oc zwlE%HeQBjRG8i7j)(+=UkyD3jjJa7Vn`@oxR&NFf=iJ}lz3W1AG)g<(H&K-HrT0lb zm*&weDDb3ba)(YauGDPunZ*Ccb7Q-pNhZ# zXBPI;X253PU(0}#$_?cP&?@osvt1EqZ4b{yJfaA_nv&84FL@k?l*e(%)*puW_Mj?k pvRc-ZL=DPcxCjXC$b7en-`V+o6R*X09J~LE{Pimi3|k{ z1v%-4!O8i#1wdsC46%s`ll26HnNkHNHw)^^3vdI)m>H57G8yu6^Icq$a`KaaA{^Un zSo6YP9-VwqP@EmcelIA=7%-VrNRFA|=l{uCLNe?(WZr8{e{*!QuaGR9T__|kw*Y7a z0}De5Ln=ctLkWug3<5tVFAxn R3``I|g1pVJIi6<@GXQMrKD+<` diff --git a/.gitignore b/.gitignore index e17c36b..41d2701 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,8 @@ !/tmp/pids/ !/tmp/pids/.keep +.rubocop.yml + # Ignore storage (uploaded files in development and any SQLite databases). /storage/* !/storage/.keep diff --git a/Gemfile b/Gemfile index 1b008ad..4c49ace 100644 --- a/Gemfile +++ b/Gemfile @@ -1,49 +1,50 @@ source "https://rubygems.org" -ruby "3.4.1" +ruby "3.4.9" -gem 'dotenv-rails' +gem "dotenv-rails" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" -gem "rails", "~> 8.0.2" +gem "rails", "~> 8.1.2" gem "openssl" # The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] # gem "sprockets-rails" -gem 'turbo-rails' -gem 'stimulus-rails' +gem "turbo-rails" +gem "stimulus-rails" gem "propshaft" gem "importmap-rails" # Use postgresql as the database for Active Record gem "pg", "~> 1.1" -gem 'pg_search' +gem "pg_search" # Use the Puma web server [https://github.com/puma/puma] -gem "puma", ">= 5.0" -gem 'sidekiq' +gem "puma" +gem "sidekiq" gem "redis", ">= 4.0.1" # Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" -gem 'mobility', '~> 1.3.0.rc1' -gem 'kaminari' -gem 'ancestry' -gem 'acts_as_list' - -gem 'date_validator' - -gem 'premailer-rails' -gem 'dkim' +gem "mobility", "~> 1.3.0.rc1" +gem "kaminari" +gem "ancestry" +gem "acts_as_list" +gem "date_validator" +gem "premailer-rails" +gem "dkim" # Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] # gem "kredis" +# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/] +gem "thruster", require: false + # Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] gem "bcrypt", "~> 3.1.7" @@ -53,24 +54,10 @@ gem "bootsnap", require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] gem "image_processing", "~> 1.2" -# group :development, :test do -# # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem -# gem "debug", platforms: %i[ mri windows ] -# end group :development do # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" + gem "rubocop-rails-omakase", require: false end - -# group :test do -# # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] -# gem "capybara" -# gem "selenium-webdriver" -# end diff --git a/Gemfile.lock b/Gemfile.lock index 08395c0..79db072 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,29 +1,31 @@ GEM remote: https://rubygems.org/ specs: - actioncable (8.0.3) - actionpack (= 8.0.3) - activesupport (= 8.0.3) + action_text-trix (2.1.17) + railties + actioncable (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) zeitwerk (~> 2.6) - actionmailbox (8.0.3) - actionpack (= 8.0.3) - activejob (= 8.0.3) - activerecord (= 8.0.3) - activestorage (= 8.0.3) - activesupport (= 8.0.3) + actionmailbox (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) - actionmailer (8.0.3) - actionpack (= 8.0.3) - actionview (= 8.0.3) - activejob (= 8.0.3) - activesupport (= 8.0.3) + actionmailer (8.1.2) + actionpack (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activesupport (= 8.1.2) mail (>= 2.8.0) rails-dom-testing (~> 2.2) - actionpack (8.0.3) - actionview (= 8.0.3) - activesupport (= 8.0.3) + actionpack (8.1.2) + actionview (= 8.1.2) + activesupport (= 8.1.2) nokogiri (>= 1.8.5) rack (>= 2.2.4) rack-session (>= 1.0.1) @@ -31,106 +33,114 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.0.3) - actionpack (= 8.0.3) - activerecord (= 8.0.3) - activestorage (= 8.0.3) - activesupport (= 8.0.3) + actiontext (8.1.2) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (8.0.3) - activesupport (= 8.0.3) + actionview (8.1.2) + activesupport (= 8.1.2) builder (~> 3.1) erubi (~> 1.11) rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) - activejob (8.0.3) - activesupport (= 8.0.3) + activejob (8.1.2) + activesupport (= 8.1.2) globalid (>= 0.3.6) - activemodel (8.0.3) - activesupport (= 8.0.3) - activerecord (8.0.3) - activemodel (= 8.0.3) - activesupport (= 8.0.3) + activemodel (8.1.2) + activesupport (= 8.1.2) + activerecord (8.1.2) + activemodel (= 8.1.2) + activesupport (= 8.1.2) timeout (>= 0.4.0) - activestorage (8.0.3) - actionpack (= 8.0.3) - activejob (= 8.0.3) - activerecord (= 8.0.3) - activesupport (= 8.0.3) + activestorage (8.1.2) + actionpack (= 8.1.2) + activejob (= 8.1.2) + activerecord (= 8.1.2) + activesupport (= 8.1.2) marcel (~> 1.0) - activesupport (8.0.3) + activesupport (8.1.2) base64 - benchmark (>= 0.3) bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) connection_pool (>= 2.2.5) drb i18n (>= 1.6, < 2) + json logger (>= 1.4.2) minitest (>= 5.1) securerandom (>= 0.3) tzinfo (~> 2.0, >= 2.0.5) uri (>= 0.13.1) - acts_as_list (1.2.4) + acts_as_list (1.2.6) activerecord (>= 6.1) activesupport (>= 6.1) - addressable (2.8.7) - public_suffix (>= 2.0.2, < 7.0) - ancestry (4.3.3) + addressable (2.8.9) + public_suffix (>= 2.0.2, < 8.0) + ancestry (5.1.0) activerecord (>= 5.2.6) + logger + ast (2.4.3) base64 (0.3.0) - bcrypt (3.1.20) - benchmark (0.4.1) - bigdecimal (3.3.1) + bcrypt (3.1.22) + bigdecimal (4.0.1) bindex (0.8.1) - bootsnap (1.18.6) + bootsnap (1.23.0) msgpack (~> 1.2) builder (3.3.0) - concurrent-ruby (1.3.5) - connection_pool (2.5.4) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) crass (1.0.6) - css_parser (1.21.1) + css_parser (2.0.0) addressable - date (3.4.1) + date (3.5.1) date_validator (0.12.0) activemodel (>= 3) activesupport (>= 3) dkim (1.1.0) - dotenv (3.1.8) - dotenv-rails (3.1.8) - dotenv (= 3.1.8) + dotenv (3.2.0) + dotenv-rails (3.2.0) + dotenv (= 3.2.0) railties (>= 6.1) drb (2.2.3) - erb (5.1.1) + erb (6.0.2) erubi (1.13.1) - ffi (1.17.2-aarch64-linux-gnu) - ffi (1.17.2-arm-linux-gnu) - ffi (1.17.2-arm64-darwin) - ffi (1.17.2-x86-linux-gnu) - ffi (1.17.2-x86_64-darwin) - ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.3-aarch64-linux-gnu) + ffi (1.17.3-aarch64-linux-musl) + ffi (1.17.3-arm-linux-gnu) + ffi (1.17.3-arm-linux-musl) + ffi (1.17.3-arm64-darwin) + ffi (1.17.3-x86_64-darwin) + ffi (1.17.3-x86_64-linux-gnu) + ffi (1.17.3-x86_64-linux-musl) globalid (1.3.0) activesupport (>= 6.1) - htmlentities (4.3.4) - i18n (1.14.7) + htmlentities (4.4.2) + i18n (1.14.8) concurrent-ruby (~> 1.0) image_processing (1.14.0) mini_magick (>= 4.9.5, < 6) ruby-vips (>= 2.0.17, < 3) - importmap-rails (2.2.2) + importmap-rails (2.2.3) actionpack (>= 6.0.0) activesupport (>= 6.0.0) railties (>= 6.0.0) - io-console (0.8.1) - irb (1.15.2) + io-console (0.8.2) + irb (1.17.0) pp (>= 0.6.0) + prism (>= 1.3.0) rdoc (>= 4.0.0) reline (>= 0.4.2) jbuilder (2.14.1) actionview (>= 7.0.0) activesupport (>= 7.0.0) - json (2.15.1) + json (2.19.2) + json-schema (6.2.0) + addressable (~> 2.8) + bigdecimal (>= 3.1, < 5) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -143,26 +153,32 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) logger (1.7.0) - loofah (2.24.1) + loofah (2.25.1) crass (~> 1.0.2) nokogiri (>= 1.12.0) - mail (2.8.1) + mail (2.9.0) + logger mini_mime (>= 0.1.1) net-imap net-pop net-smtp marcel (1.1.0) + mcp (0.8.0) + json-schema (>= 4.1) mini_magick (5.3.1) logger mini_mime (1.1.5) - mini_portile2 (2.8.9) - minitest (5.26.0) + minitest (6.0.2) + drb (~> 2.0) + prism (~> 1.5) mobility (1.3.2) i18n (>= 0.6.10, < 2) request_store (~> 1.0) msgpack (1.8.0) - net-imap (0.5.12) + net-imap (0.6.3) date net-protocol net-pop (0.1.2) @@ -171,32 +187,41 @@ GEM timeout net-smtp (0.5.1) net-protocol - nio4r (2.7.4) - nokogiri (1.18.10) - mini_portile2 (~> 2.8.2) + nio4r (2.7.5) + nokogiri (1.19.1-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.1-aarch64-linux-musl) racc (~> 1.4) - nokogiri (1.18.10-aarch64-linux-gnu) + nokogiri (1.19.1-arm-linux-gnu) racc (~> 1.4) - nokogiri (1.18.10-arm-linux-gnu) + nokogiri (1.19.1-arm-linux-musl) racc (~> 1.4) - nokogiri (1.18.10-arm64-darwin) + nokogiri (1.19.1-arm64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-darwin) + nokogiri (1.19.1-x86_64-darwin) racc (~> 1.4) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.19.1-x86_64-linux-gnu) racc (~> 1.4) - openssl (3.3.1) - pg (1.6.2) - pg (1.6.2-aarch64-linux) - pg (1.6.2-arm64-darwin) - pg (1.6.2-x86_64-darwin) - pg (1.6.2-x86_64-linux) + nokogiri (1.19.1-x86_64-linux-musl) + racc (~> 1.4) + openssl (4.0.1) + parallel (1.27.0) + parser (3.3.10.2) + ast (~> 2.4.1) + racc + pg (1.6.3) + pg (1.6.3-aarch64-linux) + pg (1.6.3-aarch64-linux-musl) + pg (1.6.3-arm64-darwin) + pg (1.6.3-x86_64-darwin) + pg (1.6.3-x86_64-linux) + pg (1.6.3-x86_64-linux-musl) pg_search (2.3.7) activerecord (>= 6.1) activesupport (>= 6.1) pp (0.6.3) prettyprint - premailer (1.27.0) + premailer (1.29.0) addressable css_parser (>= 1.19.0) htmlentities (>= 4.0.0) @@ -205,109 +230,153 @@ GEM net-smtp premailer (~> 1.7, >= 1.7.9) prettyprint (0.2.0) + prism (1.9.0) propshaft (1.3.1) actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack - psych (5.2.6) + psych (5.3.1) date stringio - public_suffix (6.0.2) - puma (7.0.4) + public_suffix (7.0.5) + puma (7.2.0) nio4r (~> 2.0) racc (1.8.1) - rack (3.2.3) + rack (3.2.5) rack-session (2.1.1) base64 (>= 0.1.0) rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rackup (2.2.1) + rackup (2.3.1) rack (>= 3) - rails (8.0.3) - actioncable (= 8.0.3) - actionmailbox (= 8.0.3) - actionmailer (= 8.0.3) - actionpack (= 8.0.3) - actiontext (= 8.0.3) - actionview (= 8.0.3) - activejob (= 8.0.3) - activemodel (= 8.0.3) - activerecord (= 8.0.3) - activestorage (= 8.0.3) - activesupport (= 8.0.3) + rails (8.1.2) + actioncable (= 8.1.2) + actionmailbox (= 8.1.2) + actionmailer (= 8.1.2) + actionpack (= 8.1.2) + actiontext (= 8.1.2) + actionview (= 8.1.2) + activejob (= 8.1.2) + activemodel (= 8.1.2) + activerecord (= 8.1.2) + activestorage (= 8.1.2) + activesupport (= 8.1.2) bundler (>= 1.15.0) - railties (= 8.0.3) + railties (= 8.1.2) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.6.2) - loofah (~> 2.21) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) - railties (8.0.3) - actionpack (= 8.0.3) - activesupport (= 8.0.3) + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) thor (~> 1.0, >= 1.2.2) tsort (>= 0.2) zeitwerk (~> 2.6) - rake (13.3.0) - rdoc (6.15.0) + rainbow (3.1.1) + rake (13.3.1) + rdoc (7.2.0) erb psych (>= 4.0.0) tsort redis (5.4.1) redis-client (>= 0.22.0) - redis-client (0.26.1) + redis-client (0.28.0) connection_pool - reline (0.6.2) + regexp_parser (2.11.3) + reline (0.6.3) io-console (~> 0.5) request_store (1.7.0) rack (>= 1.4) - ruby-vips (2.2.5) + rubocop (1.85.1) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + mcp (~> 0.6) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.1) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rails (2.34.3) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails-omakase (1.1.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.30) + ruby-progressbar (1.13.0) + ruby-vips (2.3.0) ffi (~> 1.12) logger securerandom (0.4.1) - sidekiq (8.0.8) - connection_pool (>= 2.5.0) - json (>= 2.9.0) - logger (>= 1.6.2) - rack (>= 3.1.0) - redis-client (>= 0.23.2) + sidekiq (8.1.1) + connection_pool (>= 3.0.0) + json (>= 2.16.0) + logger (>= 1.7.0) + rack (>= 3.2.0) + redis-client (>= 0.26.0) stimulus-rails (1.3.4) railties (>= 6.0.0) - stringio (3.1.7) - thor (1.4.0) - timeout (0.4.3) + stringio (3.2.0) + thor (1.5.0) + thruster (0.1.19) + thruster (0.1.19-aarch64-linux) + thruster (0.1.19-arm64-darwin) + thruster (0.1.19-x86_64-darwin) + thruster (0.1.19-x86_64-linux) + timeout (0.6.1) tsort (0.2.0) - turbo-rails (2.0.17) + turbo-rails (2.0.23) actionpack (>= 7.1.0) railties (>= 7.1.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uri (1.0.4) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + uri (1.1.1) useragent (0.16.11) - web-console (4.2.1) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) + web-console (4.3.0) + actionview (>= 8.0.0) bindex (>= 0.4.0) - railties (>= 6.0.0) + railties (>= 8.0.0) websocket-driver (0.8.0) base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - zeitwerk (2.7.3) + zeitwerk (2.7.5) PLATFORMS aarch64-linux - arm-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl arm64-darwin - x86-linux x86_64-darwin x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES acts_as_list @@ -327,16 +396,167 @@ DEPENDENCIES pg_search premailer-rails propshaft - puma (>= 5.0) - rails (~> 8.0.2) + puma + rails (~> 8.1.2) redis (>= 4.0.1) + rubocop-rails-omakase sidekiq stimulus-rails + thruster turbo-rails web-console +CHECKSUMS + action_text-trix (2.1.17) sha256=b44691639d77e67169dc054ceacd1edc04d44dc3e4c6a427aa155a2beb4cc951 + actioncable (8.1.2) sha256=dc31efc34cca9cdefc5c691ddb8b4b214c0ea5cd1372108cbc1377767fb91969 + actionmailbox (8.1.2) sha256=058b2fb1980e5d5a894f675475fcfa45c62631103d5a2596d9610ec81581889b + actionmailer (8.1.2) sha256=f4c1d2060f653bfe908aa7fdc5a61c0e5279670de992146582f2e36f8b9175e9 + actionpack (8.1.2) sha256=ced74147a1f0daafaa4bab7f677513fd4d3add574c7839958f7b4f1de44f8423 + actiontext (8.1.2) sha256=0bf57da22a9c19d970779c3ce24a56be31b51c7640f2763ec64aa72e358d2d2d + actionview (8.1.2) sha256=80455b2588911c9b72cec22d240edacb7c150e800ef2234821269b2b2c3e2e5b + activejob (8.1.2) sha256=908dab3713b101859536375819f4156b07bdf4c232cc645e7538adb9e302f825 + activemodel (8.1.2) sha256=e21358c11ce68aed3f9838b7e464977bc007b4446c6e4059781e1d5c03bcf33e + activerecord (8.1.2) sha256=acfbe0cadfcc50fa208011fe6f4eb01cae682ebae0ef57145ba45380c74bcc44 + activestorage (8.1.2) sha256=8a63a48c3999caeee26a59441f813f94681fc35cc41aba7ce1f836add04fba76 + activesupport (8.1.2) sha256=88842578ccd0d40f658289b0e8c842acfe9af751afee2e0744a7873f50b6fdae + acts_as_list (1.2.6) sha256=8345380900b7bee620c07ad00991ccee59af3d8c9e8574f426e321da2865fdc8 + addressable (2.8.9) sha256=cc154fcbe689711808a43601dee7b980238ce54368d23e127421753e46895485 + ancestry (5.1.0) sha256=8a073cf6f7e306eeed36af72595abd19602ef4a197bf4beda2f31cf8f55de27b + ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032 + bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7 + bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e + bootsnap (1.23.0) sha256=c1254f458d58558b58be0f8eb8f6eec2821456785b7cdd1e16248e2020d3f214 + builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f + concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab + connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d + css_parser (2.0.0) sha256=af5c759a127b125b635006a6c6c2e05b96a1ebdeec21b3c415fd5f09ec714a0a + date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0 + date_validator (0.12.0) sha256=68c9834da240347b9c17441c553a183572508617ebfbe8c020020f3192ce3058 + dkim (1.1.0) sha256=74f2e3075c89cd2967995f3ee293da9dccccffee21ee593715a068ab39a717f8 + dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d + dotenv-rails (3.2.0) sha256=657e25554ba622ffc95d8c4f1670286510f47f2edda9f68293c3f661b303beab + drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 + erb (6.0.2) sha256=9fe6264d44f79422c87490a1558479bd0e7dad4dd0e317656e67ea3077b5242b + erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 + ffi (1.17.3-aarch64-linux-gnu) sha256=28ad573df26560f0aedd8a90c3371279a0b2bd0b4e834b16a2baa10bd7a97068 + ffi (1.17.3-aarch64-linux-musl) sha256=020b33b76775b1abacc3b7d86b287cef3251f66d747092deec592c7f5df764b2 + ffi (1.17.3-arm-linux-gnu) sha256=5bd4cea83b68b5ec0037f99c57d5ce2dd5aa438f35decc5ef68a7d085c785668 + ffi (1.17.3-arm-linux-musl) sha256=0d7626bb96265f9af78afa33e267d71cfef9d9a8eb8f5525344f8da6c7d76053 + ffi (1.17.3-arm64-darwin) sha256=0c690555d4cee17a7f07c04d59df39b2fba74ec440b19da1f685c6579bb0717f + ffi (1.17.3-x86_64-darwin) sha256=1f211811eb5cfaa25998322cdd92ab104bfbd26d1c4c08471599c511f2c00bb5 + ffi (1.17.3-x86_64-linux-gnu) sha256=3746b01f677aae7b16dc1acb7cb3cc17b3e35bdae7676a3f568153fb0e2c887f + ffi (1.17.3-x86_64-linux-musl) sha256=086b221c3a68320b7564066f46fed23449a44f7a1935f1fe5a245bd89d9aea56 + globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11 + htmlentities (4.4.2) sha256=bbafbdf69f2eca9262be4efef7e43e6a1de54c95eb600f26984f71d2fe96c5c3 + i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 + image_processing (1.14.0) sha256=754cc169c9c262980889bec6bfd325ed1dafad34f85242b5a07b60af004742fb + importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a + io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc + irb (1.17.0) sha256=168c4ddb93d8a361a045c41d92b2952c7a118fa73f23fe14e55609eb7a863aae + jbuilder (2.14.1) sha256=4eb26376ff60ef100cb4fd6fd7533cd271f9998327e86adf20fd8c0e69fabb42 + json (2.19.2) sha256=e7e1bd318b2c37c4ceee2444841c86539bc462e81f40d134cf97826cb14e83cf + json-schema (6.2.0) sha256=e8bff46ed845a22c1ab2bd0d7eccf831c01fe23bb3920caa4c74db4306813666 + kaminari (1.2.2) sha256=c4076ff9adccc6109408333f87b5c4abbda5e39dc464bd4c66d06d9f73442a3e + kaminari-actionview (1.2.2) sha256=1330f6fc8b59a4a4ef6a549ff8a224797289ebf7a3a503e8c1652535287cc909 + kaminari-activerecord (1.2.2) sha256=0dd3a67bab356a356f36b3b7236bcb81cef313095365befe8e98057dd2472430 + kaminari-core (1.2.2) sha256=3bd26fec7370645af40ca73b9426a448d09b8a8ba7afa9ba3c3e0d39cdbb83ff + language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc + lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 + logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 + loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04 + mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941 + marcel (1.1.0) sha256=fdcfcfa33cc52e93c4308d40e4090a5d4ea279e160a7f6af988260fa970e0bee + mcp (0.8.0) sha256=ae8bd146bb8e168852866fd26f805f52744f6326afb3211e073f78a95e0c34fb + mini_magick (5.3.1) sha256=29395dfd76badcabb6403ee5aff6f681e867074f8f28ce08d78661e9e4a351c4 + mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef + minitest (6.0.2) sha256=db6e57956f6ecc6134683b4c87467d6dd792323c7f0eea7b93f66bd284adbc3d + mobility (1.3.2) sha256=32fbbb0e53118ef42de20daa6ac94dbb758c628874092eba311b968a1e1d757b + msgpack (1.8.0) sha256=e64ce0212000d016809f5048b48eb3a65ffb169db22238fb4b72472fecb2d732 + net-imap (0.6.3) sha256=9bab75f876596d09ee7bf911a291da478e0cd6badc54dfb82874855ccc82f2ad + net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 + net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 + net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 + nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 + nokogiri (1.19.1-aarch64-linux-gnu) sha256=cfdb0eafd9a554a88f12ebcc688d2b9005f9fce42b00b970e3dc199587b27f32 + nokogiri (1.19.1-aarch64-linux-musl) sha256=1e2150ab43c3b373aba76cd1190af7b9e92103564063e48c474f7600923620b5 + nokogiri (1.19.1-arm-linux-gnu) sha256=0a39ed59abe3bf279fab9dd4c6db6fe8af01af0608f6e1f08b8ffa4e5d407fa3 + nokogiri (1.19.1-arm-linux-musl) sha256=3a18e559ee499b064aac6562d98daab3d39ba6cbb4074a1542781b2f556db47d + nokogiri (1.19.1-arm64-darwin) sha256=dfe2d337e6700eac47290407c289d56bcf85805d128c1b5a6434ddb79731cb9e + nokogiri (1.19.1-x86_64-darwin) sha256=7093896778cc03efb74b85f915a775862730e887f2e58d6921e3fa3d981e68bf + nokogiri (1.19.1-x86_64-linux-gnu) sha256=1a4902842a186b4f901078e692d12257678e6133858d0566152fe29cdb98456a + nokogiri (1.19.1-x86_64-linux-musl) sha256=4267f38ad4fc7e52a2e7ee28ed494e8f9d8eb4f4b3320901d55981c7b995fc23 + openssl (4.0.1) sha256=e27974136b7b02894a1bce46c5397ee889afafe704a839446b54dc81cb9c5f7d + parallel (1.27.0) sha256=4ac151e1806b755fb4e2dc2332cbf0e54f2e24ba821ff2d3dcf86bf6dc4ae130 + parser (3.3.10.2) sha256=6f60c84aa4bdcedb6d1a2434b738fe8a8136807b6adc8f7f53b97da9bc4e9357 + pg (1.6.3) sha256=1388d0563e13d2758c1089e35e973a3249e955c659592d10e5b77c468f628a99 + pg (1.6.3-aarch64-linux) sha256=0698ad563e02383c27510b76bf7d4cd2de19cd1d16a5013f375dd473e4be72ea + pg (1.6.3-aarch64-linux-musl) sha256=06a75f4ea04b05140146f2a10550b8e0d9f006a79cdaf8b5b130cde40e3ecc2c + pg (1.6.3-arm64-darwin) sha256=7240330b572e6355d7c75a7de535edb5dfcbd6295d9c7777df4d9dddfb8c0e5f + pg (1.6.3-x86_64-darwin) sha256=ee2e04a17c0627225054ffeb43e31a95be9d7e93abda2737ea3ce4a62f2729d6 + pg (1.6.3-x86_64-linux) sha256=5d9e188c8f7a0295d162b7b88a768d8452a899977d44f3274d1946d67920ae8d + pg (1.6.3-x86_64-linux-musl) sha256=9c9c90d98c72f78eb04c0f55e9618fe55d1512128e411035fe229ff427864009 + pg_search (2.3.7) sha256=27868941844961e593526b835da20e48995e9b846515e91856084c5bd9ab4f35 + pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 + premailer (1.29.0) sha256=015f30c520701f3d47fd898886a3eaf4e5171efcc5fd239b872efd1ba61d3da0 + premailer-rails (1.12.0) sha256=c13815d161b9bc7f7d3d81396b0bb0a61a90fa9bd89931548bf4e537c7710400 + prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 + prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + propshaft (1.3.1) sha256=9acc664ef67e819ffa3d95bd7ad4c3623ea799110c5f4dee67fa7e583e74c392 + psych (5.3.1) sha256=eb7a57cef10c9d70173ff74e739d843ac3b2c019a003de48447b2963d81b1974 + public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623 + puma (7.2.0) sha256=bf8ef4ab514a4e6d4554cb4326b2004eba5036ae05cf765cfe51aba9706a72a8 + racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f + rack (3.2.5) sha256=4cbd0974c0b79f7a139b4812004a62e4c60b145cba76422e288ee670601ed6d3 + rack-session (2.1.1) sha256=0b6dc07dea7e4b583f58a48e8b806d4c9f1c6c9214ebc202ec94562cbea2e4e9 + rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463 + rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868 + rails (8.1.2) sha256=5069061b23dfa8706b9f0159ae8b9d35727359103178a26962b868a680ba7d95 + rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d + rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89 + railties (8.1.2) sha256=1289ece76b4f7668fc46d07e55cc992b5b8751f2ad85548b7da351b8c59f8055 + rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a + rake (13.3.1) sha256=8c9e89d09f66a26a01264e7e3480ec0607f0c497a861ef16063604b1b08eb19c + rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 + redis (5.4.1) sha256=b5e675b57ad22b15c9bcc765d5ac26f60b675408af916d31527af9bd5a81faae + redis-client (0.28.0) sha256=888892f9cd8787a41c0ece00bdf5f556dfff7770326ce40bb2bc11f1bfec824b + regexp_parser (2.11.3) sha256=ca13f381a173b7a93450e53459075c9b76a10433caadcb2f1180f2c741fc55a4 + reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835 + request_store (1.7.0) sha256=e1b75d5346a315f452242a68c937ef8e48b215b9453a77a6c0acdca2934c88cb + rubocop (1.85.1) sha256=3dbcf9e961baa4c376eeeb2a03913dca5e3987033b04d38fa538aa1e7406cc77 + rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 + rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 + rubocop-rails (2.34.3) sha256=10d37989024865ecda8199f311f3faca990143fbac967de943f88aca11eb9ad2 + rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d + ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 + ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 + securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 + sidekiq (8.1.1) sha256=afdf2736883e1e80c1c9b7c47afe0387e1a4997c87170978a45560d35d429151 + stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 + stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 + thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 + thruster (0.1.19) sha256=3246eb6ea6fe699e89d6eecc4edda856452e4ebeb9d5999791f0e88832369527 + thruster (0.1.19-aarch64-linux) sha256=cfabff204f655359675c3f0e3e3940c6d1f110b765d0d48f5281077b8bb65325 + thruster (0.1.19-arm64-darwin) sha256=2e1994341ad1076cea438a5a86b0dc126dc6e66f5a67f2dc077779b73e9fb6e3 + thruster (0.1.19-x86_64-darwin) sha256=f026e833dc67048843919ce31a8b12b97b532df41a749d66b72f282efd2a0693 + thruster (0.1.19-x86_64-linux) sha256=7cddc1bd0c4fb2e26cc4878dc1f4eb7e883a45932e8d1cacda71b1aba1a645b6 + timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb + tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f + turbo-rails (2.0.23) sha256=ee0d90733aafff056cf51ff11e803d65e43cae258cc55f6492020ec1f9f9315f + tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b + unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42 + unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f + uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 + useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 + web-console (4.3.0) sha256=e13b71301cdfc2093f155b5aa3a622db80b4672d1f2f713119cc7ec7ac6a6da4 + websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 + websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 + zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd + RUBY VERSION - ruby 3.4.1p0 + ruby 3.4.9 BUNDLED WITH - 2.5.17 + 4.0.8 diff --git a/README DB.txt b/README DB.txt index 7801a4e..3d67ea2 100644 --- a/README DB.txt +++ b/README DB.txt @@ -2,27 +2,27 @@ Development -------------------- Local -dropdb -U mattias ikea_foundtation_week_2025 -createdb ikea_foundtation_week_2025 -pg_restore -Fc --create --dbname=ikea_foundtation_week_2025 --username=mattias db20150901.bak +dropdb -U mattias ikea_foundtation_week_2026 +createdb ikea_foundtation_week_2026 +pg_restore -Fc --create --dbname=ikea_foundtation_week_2026 --username=mattias db20150901.bak DB ------------------- -sudo -u postgres createuser --interactive ikea_foundation_2025 -sudo -u postgres createdb -O ikea_foundation_2025 ikea_foundtation_week_2025 +sudo -u postgres createuser --interactive ikea_foundation_2026 +sudo -u postgres createdb -O ikea_foundation_2026 ikea_foundtation_week_2026 -dropdb -U ikea_foundation ikea_foundtation_week_2025 +dropdb -U ikea_foundation ikea_foundtation_week_2026 RAILS_ENV=production rails db:migrate rake db:create:all CREATE EXTENSION hstore; -sudo -u postgres psql -d ikea_foundtation_week_2025 +sudo -u postgres psql -d ikea_foundtation_week_2026 -pg_dump -U ikea_foundation -Fc ikea_foundtation_week_2025 > db20140909.bak +pg_dump -U ikea_foundation_2026 -Fc ikea_foundtation_week_2026 > db20140909.dump sudo -i -u postgres @@ -30,8 +30,8 @@ psql Dump DEV ------------------- -pg_dump -U mattias -Fc ikea_foundtation_week_2025 > db20140909.bak -pg_dump -U mattias ikea_foundtation_week_2025 > db20140909.sql +pg_dump -U mattias -Fc ikea_foundtation_week_2026 > db20140909.bak +pg_dump -U mattias ikea_foundtation_week_2026 > db20140909.sql -pg_restore -Fc --dbname=ikea_foundtation_week_2025 --username=ikea_foundation dumps/db20230209.bak -pg_restore -Fc --create --dbname=ikea_foundtation_week_2025 --username=ikea_foundation db20150901.bak \ No newline at end of file +pg_restore -Fc --dbname=ikea_foundtation_week_2026 --username=ikea_foundation dumps/db20230209.bak +pg_restore -Fc --create --dbname=ikea_foundtation_week_2026 --username=ikea_foundation db20150901.bak \ No newline at end of file diff --git a/README.txt b/README.txt index 022a33a..c3d129c 100644 --- a/README.txt +++ b/README.txt @@ -4,9 +4,9 @@ RAILS_ENV=production bundle exec rake assets:precompile RAILS_ENV=production bundle exec rake assets:clean -git clone https://git.oncotype.dk/ikea-foundation/week_2024.git week_2025 +git clone https://mattias:zibxa7-qozsej-qoksaM@git.oncotype.dk/ikea-foundation/week_2024.git week_2026 -rails new --skip-docker --skip-action-mailbox --skip-action-text --skip-action-cable --database=postgresql week_2025 +rails new --skip-docker --skip-action-mailbox --skip-action-text --skip-action-cable --database=postgresql week_2026 Credentials @@ -16,7 +16,7 @@ EDITOR=vi rails credentials:edit SSL ------------------- -sudo certbot certonly --webroot -w /home/ikea_foundation/week_2025/public -d ikea-foundation-week-2025.onc.dk +sudo certbot certonly --webroot -w /home/ikea_foundation/week_2026/public -d ikea-foundation-week-2026.onc.dk Gem diff --git a/app/controllers/answers_controller.rb b/app/controllers/answers_controller.rb deleted file mode 100644 index 2388810..0000000 --- a/app/controllers/answers_controller.rb +++ /dev/null @@ -1,42 +0,0 @@ -class AnswersController < ApplicationController - - include QuizHelperMethods - - # POST /q/:id/answer - def create - not_found unless question - - @answer = Answer.find_or_initialize_by(player_id: current_player.id, node_id: question.id) - @answer.update(answer_params) - - respond_to do |format| - if @answer.save - current_player.update_answer_cache - format.html { redirect_to url_for(controller: 'questions', action: 'answer', id: params[:id]) } - else - format.html { render 'questions/show', status: :unprocessable_entity } - end - end - end - - - def update - create - end - - -private - - # Only allow a list of trusted parameters through. - def answer_params - params.require(:answer).permit( - :value - ) - - rescue ActionController::ParameterMissing - {} - end - - - -end diff --git a/app/controllers/concerns/quiz_helper_methods.rb b/app/controllers/concerns/quiz_helper_methods.rb index 5116e7e..ba72499 100644 --- a/app/controllers/concerns/quiz_helper_methods.rb +++ b/app/controllers/concerns/quiz_helper_methods.rb @@ -12,7 +12,6 @@ module QuizHelperMethods :question_index, :player_question_answer, :result_node - end @@ -50,7 +49,7 @@ private def require_player! unless player_present? - redirect_to url_for(controller: 'players', action: 'new') + redirect_to url_for(controller: "players", action: "new") end end @@ -68,6 +67,4 @@ private def player_present? current_player.present? end - - end diff --git a/app/controllers/languages_controller.rb b/app/controllers/languages_controller.rb index f6586ad..c8d05e8 100644 --- a/app/controllers/languages_controller.rb +++ b/app/controllers/languages_controller.rb @@ -1,5 +1,4 @@ class LanguagesController < ApplicationController - before_action :set_locale_to_default, only: :index before_action :set_locale, only: :show before_action :set_node @@ -7,7 +6,6 @@ class LanguagesController < ApplicationController helper_method :accept_language def index - not_found unless @node end @@ -42,17 +40,17 @@ private def first_matching_language - accept_languages = request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').map { |l| - lang, q_factor = l.split(';q=') - [lang, (q_factor || '1').to_f] + accept_languages = request.env["HTTP_ACCEPT_LANGUAGE"].to_s.split(",").map { |l| + lang, q_factor = l.split(";q=") + [ lang, (q_factor || "1").to_f ] }.sort_by { |_, q| -q }.map(&:first) - available_languages = I18n.t('languages').keys.map(&:to_s) + available_languages = I18n.t("languages").keys.map(&:to_s) accept_languages.each do |lang| return lang if available_languages.include?(lang) - lang_part = lang.split('-').first + lang_part = lang.split("-").first if available_languages.include?(lang_part) return lang_part else @@ -60,12 +58,11 @@ private return wildcard_match if wildcard_match end end - 'en' + "en" end def set_locale_to_default I18n.locale = I18n.default_locale end - end diff --git a/app/controllers/players_controller.rb b/app/controllers/players_controller.rb deleted file mode 100644 index c70c418..0000000 --- a/app/controllers/players_controller.rb +++ /dev/null @@ -1,42 +0,0 @@ -class PlayersController < ApplicationController - - include QuizHelperMethods - - skip_before_action :require_player! - - # GET /player - def new - reset_session - Current.player = nil - - @player = Player.new - end - - - # POST /player - def create - @player = Player.new(player_params.merge(locale: I18n.locale)) - - - respond_to do |format| - if @player.save - session[:player_id] = @player.id - format.html { redirect_to url_for(controller: 'questions', action: 'show', id: 1) } - else - format.html { render :new, status: :unprocessable_entity } - end - end - end - - -private - - - # Only allow a list of trusted parameters through. - def player_params - params.require(:player).permit( - :name - ) - end - -end diff --git a/app/controllers/questions_controller.rb b/app/controllers/questions_controller.rb deleted file mode 100644 index 41688e1..0000000 --- a/app/controllers/questions_controller.rb +++ /dev/null @@ -1,94 +0,0 @@ -class QuestionsController < ApplicationController - - include QuizHelperMethods - - - def show - not_found unless question - - @answer = Answer.find_or_initialize_by(player_id: current_player.id, node_id: question.id) - end - - - def answer - @answer = Answer.find_by(node_id: question.id, player_id: current_player.id) - @question_answer = question.attachments.with_text.each_slice(2).to_a[@answer.value] - end - - - def score - - not_found if result_node.blank? or current_player.answers.count < questions.size - - planet_score = 0 - - current_player.answers.ordered.each_with_index do |answer, i| - case i - when 0, 3 - planet_score += 1 if answer.value == 0 - else - planet_score += 1 if answer.value == 1 - end - end - - current_player.update(score: planet_score) - - quiz_result = QuizResult.create!( - player_name: current_player.name, - score: planet_score, - stats: current_player.stats, - locale: I18n.locale - ) - - redirect_to url_for(action: 'result', sid: quiz_result.share_id) - - end - - - - def result - not_found if result_node.blank? or current_player.score.blank? - - people_score = questions.count - current_player.score - score_diff = people_score - current_player.score - - attachment_index = case - when score_diff >= 2 - 0 # People - when score_diff <= -2 - 1 # Planet - else - 2 # Balanced - end - - @result_attachment = result_node.attachments.offset(attachment_index).first - @stats_attachment = result_node.attachments.offset(3).first - - end - - - def shared_result - - @quiz_result = QuizResult.find_by!(share_id: params[:id]) - - people_score = questions.count - @quiz_result.score - score_diff = people_score - @quiz_result.score - - attachment_index = case - when score_diff >= 2 - 0 # People - when score_diff <= -2 - 1 # Planet - else - 2 # Balanced - end - - @result_attachment = result_node.attachments.offset(attachment_index).first - @stats_attachment = result_node.attachments.offset(3).first - - end - - - - -end diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index ca20385..9f9ddd0 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -1,5 +1,4 @@ class SiteController < ApplicationController - before_action :set_locale @@ -15,7 +14,7 @@ class SiteController < ApplicationController def page @node = Node.find_by!("url->>'#{I18n.locale}' = ?", url_from_param) - not_found and return unless (@node and @node.viewable?) + not_found and return unless @node and @node.viewable? # Redirect to first child if index? redirect_to @node.children.viewable.ordered.first.url and return if @node.index? and @node.children.viewable.any? @@ -31,13 +30,9 @@ private def url_from_param - return '' unless params[:url] + return "" unless params[:url] # return File.join('', params[:url]) if I18n.default_locale == I18n.locale - File.join('', I18n.locale.to_s, params[:url]) + File.join("", I18n.locale.to_s, params[:url]) end - - - - end diff --git a/app/helpers/answers_helper.rb b/app/helpers/answers_helper.rb deleted file mode 100644 index b7cdb29..0000000 --- a/app/helpers/answers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module AnswersHelper -end diff --git a/app/helpers/players_helper.rb b/app/helpers/players_helper.rb deleted file mode 100644 index e8f775c..0000000 --- a/app/helpers/players_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module PlayersHelper -end diff --git a/app/helpers/questions_helper.rb b/app/helpers/questions_helper.rb deleted file mode 100644 index 332a5fd..0000000 --- a/app/helpers/questions_helper.rb +++ /dev/null @@ -1,99 +0,0 @@ -module QuestionsHelper - - def decorate_divs_for_typewriting_effect(html) - doc = Nokogiri::HTML.fragment(html, 'utf-8') - - doc.xpath('./*[position() > last()-2]').each do |div| - div['class'] = 'typewriter-text' - end - - doc.to_html.html_safe - end - - def image_orientation(file_attachment) - return nil unless file_attachment&.attached? - - metadata = file_attachment.blob.metadata - width = metadata[:width] || 0 - height = metadata[:height] || 0 - - if width > height - :landscape - elsif height > width - :portrait - else - :square - end - end - - def responsive_picture_tag_for_question(question) - # assets = question.assets.includes(file_attachment: :blob).to_a - assets = question.assets.includes(file_attachment: :blob).select{ |asset| asset.file.image? }.to_a - - # Find one landscape and one portrait image - landscape_asset = assets.find { |asset| image_orientation(asset.file) == :landscape } - portrait_asset = assets.find { |asset| image_orientation(asset.file) == :portrait } - - # Fall back to any image if specific orientation not found - landscape_asset ||= portrait_asset - portrait_asset ||= landscape_asset - - # If we have at least one image - if landscape_asset || portrait_asset - primary_asset = landscape_asset || portrait_asset - - # If we have both orientations, create a responsive picture tag - if landscape_asset && portrait_asset && landscape_asset != portrait_asset - render_responsive_picture(landscape_asset, portrait_asset) - else - # Just one orientation available, create a simple picture tag - render_simple_picture(primary_asset) - end - else - # No images available - - content_tag(:div, "No images available", class: "no-images") - end - end - -private - - def render_responsive_picture(landscape_asset, portrait_asset) - content_tag(:picture) do - concat( - content_tag(:source, "", - media: "(orientation: portrait)", - srcset: rails_storage_proxy_path(portrait_asset.file.variant(resize_to_limit: [800, nil])) + " 800w, " + - rails_storage_proxy_path(portrait_asset.file.variant(resize_to_limit: [1600, nil])) + " 1600w, " + - rails_storage_proxy_path(portrait_asset.file.variant(resize_to_limit: [2400, nil])) + " 2400w", - sizes: "100vw" - ) - ) - - concat( - image_tag( - rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [800, nil])), - srcset: rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [800, nil])) + " 800w, " + - rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [1600, nil])) + " 1600w, " + - rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [2400, nil])) + " 2400w", - sizes: "100vw", - 'data-controller': "image" - ) - ) - end - end - - def render_simple_picture(asset) - content_tag(:picture) do - image_tag( - rails_storage_proxy_path(asset.file.variant(resize_to_limit: [800, nil])), - srcset: rails_storage_proxy_path(asset.file.variant(resize_to_limit: [800, nil])) + " 800w, " + - rails_storage_proxy_path(asset.file.variant(resize_to_limit: [1600, nil])) + " 1600w, " + - rails_storage_proxy_path(asset.file.variant(resize_to_limit: [2400, nil])) + " 2400w", - sizes: "100vw", - 'data-controller': "image" - ) - end - end - -end diff --git a/app/javascript/controllers/select_controller.js b/app/javascript/controllers/select_controller.js index ef8b77d..a0914eb 100644 --- a/app/javascript/controllers/select_controller.js +++ b/app/javascript/controllers/select_controller.js @@ -1,5 +1,5 @@ import { Controller } from "@hotwired/stimulus" -import TomSelect from "tom-select"; +import TomSelect from "tom-select/dist/js/tom-select.base.min.js"; export default class extends Controller { diff --git a/app/models/answer.rb b/app/models/answer.rb deleted file mode 100644 index 6daf68a..0000000 --- a/app/models/answer.rb +++ /dev/null @@ -1,11 +0,0 @@ -class Answer < ApplicationRecord - - belongs_to :player - belongs_to :node - - validates :value, presence: true - validates :value, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 1 } - - scope :ordered, -> { joins(:node).order('nodes.position ASC, nodes.ancestry ASC') } - -end diff --git a/app/models/player.rb b/app/models/player.rb deleted file mode 100644 index 0cbfad1..0000000 --- a/app/models/player.rb +++ /dev/null @@ -1,28 +0,0 @@ -class Player < ApplicationRecord - - validates_presence_of :name, message: ->(object, data) { I18n.t('please_type_your_name_to_continue') } - - has_many :answers, dependent: :destroy - - - def update_answer_cache - self.update_column(:answer_cache, self.answers.ordered.pluck(:value)) - end - - - def stats - total_players_with_score = Player.where.not(score: nil).count - n_players_with_matching_score = Player.where(score: self.score).count - - # Calculate percentage - if total_players_with_score > 0 - percentage = (n_players_with_matching_score.to_f / total_players_with_score) * 100 - percentage_string = percentage.round.to_s - else - percentage_string = "0" - end - - percentage_string - end - -end diff --git a/app/models/quiz_result.rb b/app/models/quiz_result.rb deleted file mode 100644 index ee13b1f..0000000 --- a/app/models/quiz_result.rb +++ /dev/null @@ -1,15 +0,0 @@ -class QuizResult < ApplicationRecord - validates :share_id, presence: true, uniqueness: true - validates :player_name, :stats, :score, presence: true - - before_validation :generate_share_id, on: :create - -private - - def generate_share_id - self.share_id = SecureRandom.urlsafe_base64(8) if share_id.blank? - # Ensure uniqueness (very unlikely collision but good practice) - generate_share_id if QuizResult.exists?(share_id: share_id) - end - -end diff --git a/app/views/languages/index.html.erb b/app/views/languages/index.html.erb index 8605cf4..9551649 100644 --- a/app/views/languages/index.html.erb +++ b/app/views/languages/index.html.erb @@ -1,20 +1,7 @@ <%- content_for :title, t('project_name') - assets = @node.assets.includes(file_attachment: :blob).select{ |asset| asset.file.image? }.to_a - - # Find one landscape and one portrait image - landscape_asset = assets.find { |asset| image_orientation(asset.file) == :landscape } - portrait_asset = assets.find { |asset| image_orientation(asset.file) == :portrait } - - landscape_asset ||= portrait_asset - portrait_asset ||= landscape_asset - - body_styles = [] - body_styles << "--bg-landscape: url(#{rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [2400, nil]))});" - body_styles << "--bg-portrait: url(#{rails_storage_proxy_path(portrait_asset.file.variant(resize_to_limit: [1600, nil]))});" - - content_for :body_style, body_styles.join(' ') + %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index beaccb8..094a560 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -22,21 +22,10 @@ <%= stylesheet_link_tag "application" %> - <%= javascript_include_tag 'gsap/gsap.min.js' %> - <%= frontend_javascript_importmap_tags %w'application @hotwired/turbo-rails @hotwired/stimulus locale_controller image_controller quiz_preloader plausible_controller' %> - - - + - <% if content_for? :body_style %> - - <% else %> - - <% end %> +
<%= link_to svg('ikea-foundation-203x22'), url_for(controller: 'languages', action: (I18n.default_locale == I18n.locale ? 'index' : 'show')) %> @@ -46,6 +35,6 @@ <%= yield %> -
© Inter IKEA Systems B.V. 2025
+
© Inter IKEA Systems B.V. 2026
diff --git a/app/views/players/new.html.erb b/app/views/players/new.html.erb deleted file mode 100644 index 10adb9e..0000000 --- a/app/views/players/new.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%- - content_for :title, t('what_is_your_name') -%> - - -<%= form_with model: @player, url: url_for(controller: 'players', action: 'create') do |form| %> - -
- -
-
-
<%= t 'what_is_your_name' %>
-
-
- - <% if form.object.errors.any? %> -
-
- <% form.object.errors.messages.each do |k, v| %> - <%= v.join(', ') %> - <% end %> -
-
- <% end %> - -
- <%= form.label :name, class: "question-answer" do %> - <%= form.text_field :name, placeholder: t('write_your_name'), autofocus: true, autocomplete: 'off' %> - <% end %> -
- -
- <%= form.button tag.span(t('submit')), - class: form.object.errors.any? ? 'button__base wiggle' : 'button__base' %> -
- -
- -<% end %> \ No newline at end of file diff --git a/app/views/questions/answer.html.erb b/app/views/questions/answer.html.erb deleted file mode 100644 index 3d7aafd..0000000 --- a/app/views/questions/answer.html.erb +++ /dev/null @@ -1,45 +0,0 @@ -<%- - content_for :title, question.page_title.blank? ? question.title : question.page_title - content_for :meta_description, question.page_description -%> - - -
- -
-
-
<%= question_index %>/<%= questions_size %>
-
-
- -
-
- <% question.answer_percentages.each do |k,v| %> - <%= tag.div data: { value: v, answered: (k == player_question_answer ? 1 : nil) }, class: 'answer-distribution' do %> - <%= tag.div v, class: 'percentage' %> - <%= tag.div t('of_people_worldwide_think_just_lik_you'), class: 'explanation' if k == player_question_answer %> - <% end %> - <% end %> -
-
- -
-
- <%= @question_answer.last.body.html_safe %> -
-
- -
- <% if question == questions.last %> - <%= button_to tag.span(t('see_results')), - url_for(controller: 'questions', action: 'score'), - class: 'button__base' %> - <%# link_to t('see_results'), url_for(controller: 'questions', action: 'result') %> - <% else %> - <%= link_to tag.span(t('next_question')), - url_for(controller: 'questions', action: 'show', id: question_index.next), - class: 'button__base' %> - <% end %> -
- -
\ No newline at end of file diff --git a/app/views/questions/result.html.erb b/app/views/questions/result.html.erb deleted file mode 100644 index e3c3244..0000000 --- a/app/views/questions/result.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<%- - content_for :title, result_node.page_title.blank? ? result_node.title : result_node.page_title - content_for :meta_description, result_node.page_description -%> - - -
- -
-
-
<%= t 'results' %>
-
-
- -
-
- <%= decorate_divs_for_typewriting_effect @result_attachment&.body&.sub("<name>", html_escape(current_player.name)).html_safe %> -
-
- -
-
- <%= @stats_attachment&.body&.sub("<score>", current_player.stats).html_safe %> -
-
- -
-
- <%= link_to tag.span(t('read_more')), t('read_more_link'), class: 'button__base', target: '_blank' %> - <%= button_tag tag.span(t('share_on_story')), - data: { - share_title: t('share_title'), - share_text: t('share_text'), - share_url: url_for(controller: 'questions', action: 'shared_result', id: params[:sid], only_path: false) - }, - type: 'button', - class: 'button__base' %> -
-
- -
\ No newline at end of file diff --git a/app/views/questions/shared_result.html.erb b/app/views/questions/shared_result.html.erb deleted file mode 100644 index 4a6f824..0000000 --- a/app/views/questions/shared_result.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<%- - content_for :title, result_node.page_title.blank? ? result_node.title : result_node.page_title - content_for :meta_description, result_node.page_description -%> - - -
- -
-
-
<%= t 'results' %>
-
-
- -
-
- <%= decorate_divs_for_typewriting_effect @result_attachment&.body&.sub("<name>", html_escape(@quiz_result.player_name)).html_safe %> -
-
- -
-
- <%= @stats_attachment&.body&.sub("<score>", @quiz_result.stats).html_safe %> -
-
- -
-
- <%= link_to tag.span(t('read_more')), "#", class: 'button__base' %> - <%# button_tag tag.span(t('share_on_story')), - data: { - share_title: '', - share_text: '', - share_url: url_for(controller: 'questions', action: 'shared_result', id: params[:sid]) - }, - type: 'button', - class: 'button__base' %> -
-
- -
\ No newline at end of file diff --git a/app/views/questions/show.html.erb b/app/views/questions/show.html.erb deleted file mode 100644 index 87a31a7..0000000 --- a/app/views/questions/show.html.erb +++ /dev/null @@ -1,57 +0,0 @@ -<%- - content_for :title, question.page_title.blank? ? question.title : question.page_title - content_for :meta_description, question.page_description - - assets = question.assets.includes(file_attachment: :blob).select{ |asset| asset.file.image? }.to_a - - if assets.any? - # Find one landscape and one portrait image - landscape_asset = assets.find { |asset| image_orientation(asset.file) == :landscape } - portrait_asset = assets.find { |asset| image_orientation(asset.file) == :portrait } - - landscape_asset ||= portrait_asset - portrait_asset ||= landscape_asset - - body_styles = [] - body_styles << "--bg-landscape: url(#{rails_storage_proxy_path(landscape_asset.file.variant(resize_to_limit: [2400, nil]))});" - body_styles << "--bg-portrait: url(#{rails_storage_proxy_path(portrait_asset.file.variant(resize_to_limit: [1600, nil]))});" - - content_for :body_style, body_styles.join(' ') - end -%> - - - -<%= form_with model: @answer, url: url_for(controller: 'answers', action: 'create'), id: 'questionForm' do |form| %> - -
- -
-
-
<%= question_index %>/<%= questions_size %>
-
-
- -
-
-
<%= question.title %>
-
-
- -
- <% question.attachments.with_text.each_slice(2).each_with_index do |answer_option, i| %> -
- <%= form.label :value, for: nil do %> - <%= tag.div tag.span(sanitize(answer_option.first.body.html_safe, tags: %w"em strong")) %> - <%= form.radio_button :value, i %> - <%- end -%> -
- <% end %> -
- -
- <%= form.button tag.span(t('submit')), class: 'button__base', id: 'questionSubmitButton' %> -
-
- -<% end %> \ No newline at end of file diff --git a/bin/ci b/bin/ci new file mode 100755 index 0000000..4137ad5 --- /dev/null +++ b/bin/ci @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "active_support/continuous_integration" + +CI = ActiveSupport::ContinuousIntegration +require_relative "../config/ci.rb" diff --git a/bin/rubocop b/bin/rubocop index 40330c0..5a20504 100755 --- a/bin/rubocop +++ b/bin/rubocop @@ -2,7 +2,7 @@ require "rubygems" require "bundler/setup" -# explicit rubocop config increases performance slightly while avoiding config confusion. +# Explicit RuboCop config increases performance slightly while avoiding config confusion. ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup index be3db3c..81be011 100755 --- a/bin/setup +++ b/bin/setup @@ -22,6 +22,7 @@ FileUtils.chdir APP_ROOT do puts "\n== Preparing database ==" system! "bin/rails db:prepare" + system! "bin/rails db:reset" if ARGV.include?("--reset") puts "\n== Removing old logs and tempfiles ==" system! "bin/rails log:clear tmp:clear" diff --git a/bin/thrust b/bin/thrust new file mode 100755 index 0000000..36bde2d --- /dev/null +++ b/bin/thrust @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("thruster", "thrust") diff --git a/config/application.rb b/config/application.rb index 4b5314a..6f232a4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -18,17 +18,17 @@ require "rails/test_unit/railtie" # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -module Week2025 +module Week2026 class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 8.0 + config.load_defaults 8.1 # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. config.autoload_lib(ignore: %w[assets tasks]) - config.autoload_lib(ignore: %w(assets tasks)) + config.autoload_lib(ignore: %w[assets tasks]) config.time_zone = "Copenhagen" @@ -36,7 +36,8 @@ module Week2025 config.i18n.available_locales = [:en, :zh, :hr, :cs, :da, :nl, :fi, :fr, :'fr-CA', :de, :hu, :it, :ja, :ko, :nb, :pl, :pt, :ro, :sr, :sk, :sl, :es, :sv, :uk] config.i18n.fallbacks = true - config.active_storage.routes_prefix = 'storage' #change /rails/active_storage to /storage + # change /rails/active_storage to /storage + config.active_storage.routes_prefix = "storage" # Configuration for the application, engines, and railties goes here. # diff --git a/config/cable.yml b/config/cable.yml index 1844b21..0dce173 100644 --- a/config/cable.yml +++ b/config/cable.yml @@ -7,4 +7,4 @@ test: production: adapter: redis url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: week2025_production + channel_prefix: week2026_production diff --git a/config/ci.rb b/config/ci.rb new file mode 100644 index 0000000..7e3f04c --- /dev/null +++ b/config/ci.rb @@ -0,0 +1,22 @@ +# Run using bin/ci + +CI.run do + step "Setup", "bin/setup --skip-server" + + step "Style: Ruby", "bin/rubocop" + + step "Security: Importmap vulnerability audit", "bin/importmap audit" + step "Tests: Rails", "bin/rails test" + step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant" + + # Optional: Run system tests + # step "Tests: System", "bin/rails test:system" + + # Optional: set a green GitHub commit status to unblock PR merge. + # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`. + # if success? + # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff" + # else + # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again." + # end +end diff --git a/config/importmap.rb b/config/importmap.rb index 9b2a1e0..b821247 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -5,16 +5,16 @@ pin "@hotwired/stimulus", to: "@hotwired--stimulus.js" # @3.2.2 pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" pin_all_from "app/javascript/controllers", under: "controllers" -pin "sortablejs" # @1.15.6 +pin "sortablejs" # @1.15.7 pin "stimulus-use" # @0.52.3 -pin "@rails/request.js", to: "@rails--request.js.js" # @0.0.12 -pin "@rails/activestorage", to: "@rails--activestorage.js" # @8.0.300 -pin "tom-select", to: "tom-select--dist--js--tom-select.base.min.js.js" # @2.4.3 -pin "trix" # @2.1.15 +pin "@rails/request.js", to: "@rails--request.js.js" # @0.0.13 +pin "@rails/activestorage", to: "@rails--activestorage.js" # @8.1.200 +pin "trix" # @2.1.16 +pin "tom-select/dist/js/tom-select.base.min.js", to: "tom-select--dist--js--tom-select.base.min.js.js" # @2.4.3 # site_helper pin "application", preload: false pin "locale_controller", preload: false pin "image_controller", preload: false pin "quiz_preloader", preload: false -pin 'plausible_controller', preload: false +pin "plausible_controller", preload: false diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index b3076b3..d51d713 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -20,6 +20,10 @@ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } # config.content_security_policy_nonce_directives = %w(script-src style-src) # +# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag` +# # if the corresponding directives are specified in `content_security_policy_nonce_directives`. +# # config.content_security_policy_nonce_auto = true +# # # Report violations without enforcing the policy. # # config.content_security_policy_report_only = true # end diff --git a/config/initializers/new_framework_defaults_7_2.rb b/config/initializers/new_framework_defaults_7_2.rb deleted file mode 100644 index b549c4a..0000000 --- a/config/initializers/new_framework_defaults_7_2.rb +++ /dev/null @@ -1,70 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 7.2 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `7.2`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Controls whether Active Job's `#perform_later` and similar methods automatically defer -# the job queuing to after the current Active Record transaction is committed. -# -# Example: -# Topic.transaction do -# topic = Topic.create(...) -# NewTopicNotificationJob.perform_later(topic) -# end -# -# In this example, if the configuration is set to `:never`, the job will -# be enqueued immediately, even though the `Topic` hasn't been committed yet. -# Because of this, if the job is picked up almost immediately, or if the -# transaction doesn't succeed for some reason, the job will fail to find this -# topic in the database. -# -# If `enqueue_after_transaction_commit` is set to `:default`, the queue adapter -# will define the behaviour. -# -# Note: Active Job backends can disable this feature. This is generally done by -# backends that use the same database as Active Record as a queue, hence they -# don't need this feature. -#++ -# Rails.application.config.active_job.enqueue_after_transaction_commit = :default - -### -# Adds image/webp to the list of content types Active Storage considers as an image -# Prevents automatic conversion to a fallback PNG, and assumes clients support WebP, as they support gif, jpeg, and png. -# This is possible due to broad browser support for WebP, but older browsers and email clients may still not support -# WebP. Requires imagemagick/libvips built with WebP support. -#++ -# Rails.application.config.active_storage.web_image_content_types = %w[image/png image/jpeg image/gif image/webp] - -### -# Enable validation of migration timestamps. When set, an ActiveRecord::InvalidMigrationTimestampError -# will be raised if the timestamp prefix for a migration is more than a day ahead of the timestamp -# associated with the current time. This is done to prevent forward-dating of migration files, which can -# impact migration generation and other migration commands. -# -# Applications with existing timestamped migrations that do not adhere to the -# expected format can disable validation by setting this config to `false`. -#++ -# Rails.application.config.active_record.validate_migration_timestamps = true - -### -# Controls whether the PostgresqlAdapter should decode dates automatically with manual queries. -# -# Example: -# ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.select_value("select '2024-01-01'::date") #=> Date -# -# This query used to return a `String`. -#++ -# Rails.application.config.active_record.postgresql_adapter_decode_dates = true - -### -# Enables YJIT as of Ruby 3.3, to bring sizeable performance improvements. If you are -# deploying to a memory constrained environment you may want to set this to `false`. -#++ -# Rails.application.config.yjit = true diff --git a/config/initializers/new_framework_defaults_8_0.rb b/config/initializers/new_framework_defaults_8_0.rb deleted file mode 100644 index 92efa95..0000000 --- a/config/initializers/new_framework_defaults_8_0.rb +++ /dev/null @@ -1,30 +0,0 @@ -# Be sure to restart your server when you modify this file. -# -# This file eases your Rails 8.0 framework defaults upgrade. -# -# Uncomment each configuration one by one to switch to the new default. -# Once your application is ready to run with all new defaults, you can remove -# this file and set the `config.load_defaults` to `8.0`. -# -# Read the Guide for Upgrading Ruby on Rails for more info on each option. -# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html - -### -# Specifies whether `to_time` methods preserve the UTC offset of their receivers or preserves the timezone. -# If set to `:zone`, `to_time` methods will use the timezone of their receivers. -# If set to `:offset`, `to_time` methods will use the UTC offset. -# If `false`, `to_time` methods will convert to the local system UTC offset instead. -#++ -# Rails.application.config.active_support.to_time_preserves_timezone = :zone - -### -# When both `If-Modified-Since` and `If-None-Match` are provided by the client -# only consider `If-None-Match` as specified by RFC 7232 Section 6. -# If set to `false` both conditions need to be satisfied. -#++ -# Rails.application.config.action_dispatch.strict_freshness = true - -### -# Set `Regexp.timeout` to `1`s by default to improve security over Regexp Denial-of-Service attacks. -#++ -# Regexp.timeout = 1 diff --git a/config/nginx.conf b/config/nginx.conf index cef7a85..7be1d44 100644 --- a/config/nginx.conf +++ b/config/nginx.conf @@ -1,61 +1,46 @@ # http > https server { listen 80; - server_name completesentences.ikeafoundation.org ikea-foundation-week-2025.onc.dk; + server_name ikea-foundation-week-2026.onc.dk; - root /home/ikea_foundation_2025/week_2025/public; + root /home/ikea_foundation_2026/week_2026/public; # Lets encrypt location ~ /.well-known { allow all; } - location / { - return 301 https://completesentences.ikeafoundation.org$request_uri; + location / { + return 301 https://ikea-foundation-week-2026.onc.dk$request_uri; } } -# # https -server { - listen 443 ssl; - http2 on; - - server_name ikea-foundation-week-2025.onc.dk; - - # keepalive_timeout 300; - keepalive_timeout 5; - client_max_body_size 4G; - - ssl_certificate /etc/letsencrypt/live/ikea-foundation-week-2025.onc.dk/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/ikea-foundation-week-2025.onc.dk/privkey.pem; # managed by Certbot - include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot - ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot - - location / { - return 301 https://completesentences.ikeafoundation.org$request_uri; - } -} - -# # http > https +# # # https # server { -# listen 80; -# server_name spotlinks.ikeafoundation.org; -# -# root /home/ikea_foundation_2025/week_2025/public; +# listen 443 ssl; +# http2 on; +# +# server_name ikea-foundation-week-2026.onc.dk; +# +# # keepalive_timeout 300; +# keepalive_timeout 5; +# client_max_body_size 4G; # -# # Lets encrypt -# location ~ /.well-known { -# allow all; -# } +# ssl_certificate /etc/letsencrypt/live/ikea-foundation-week-2026.onc.dk/fullchain.pem; # managed by Certbot +# ssl_certificate_key /etc/letsencrypt/live/ikea-foundation-week-2026.onc.dk/privkey.pem; # managed by Certbot +# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot +# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot # # location / { -# return 301 https://spotlinks.ikeafoundation.org$request_uri; -# } +# return 301 https://completesentences.ikeafoundation.org$request_uri; +# } # } + + # Puma -upstream puma_ikea_25 { - server unix:///home/ikea_foundation_2025/week_2025/tmp/pids/puma.sock fail_timeout=0; +upstream puma_ikea_26 { + server unix:///home/ikea_foundation_2026/week_2026/tmp/pids/puma.sock fail_timeout=0; } @@ -64,40 +49,37 @@ upstream puma_ikea_25 { server { listen 443 ssl; http2 on; - - # server_name spotlinks.ikeafoundation.org; - server_name completesentences.ikeafoundation.org; + + server_name ikea-foundation-week-2026.onc.dk; # keepalive_timeout 300; keepalive_timeout 5; client_max_body_size 4G; - # ssl_certificate /etc/letsencrypt/live/spotlinks.ikeafoundation.org/fullchain.pem; # managed by Certbot - # ssl_certificate_key /etc/letsencrypt/live/spotlinks.ikeafoundation.org/privkey.pem; # managed by Certbot - - ssl_certificate /etc/letsencrypt/live/completesentences.ikeafoundation.org/fullchain.pem; # managed by Certbot - ssl_certificate_key /etc/letsencrypt/live/completesentences.ikeafoundation.org/privkey.pem; # managed by Certbot + + ssl_certificate /etc/letsencrypt/live/ikea-foundation-week-2026.onc.dk/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/ikea-foundation-week-2026.onc.dk/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot - access_log /home/ikea_foundation_2025/week_2025/log/httpd-access.log; - error_log /home/ikea_foundation_2025/week_2025/log/httpd-errors.log; + access_log /home/ikea_foundation_2026/week_2026/log/httpd-access.log; + error_log /home/ikea_foundation_2026/week_2026/log/httpd-errors.log; - root /home/ikea_foundation_2025/week_2025/public; + root /home/ikea_foundation_2026/week_2026/public; # App server - location @puma_ikea_25 { + location @puma_ikea_26 { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded_Proto $scheme; proxy_redirect off; - proxy_pass http://puma_ikea_25; + proxy_pass http://puma_ikea_26; } # Serve static (compiled) assets directly if they exist (for rails production) location ~ ^/(assets|packs|static)/ { - try_files $uri @puma_ikea_25; + try_files $uri @puma_ikea_26; access_log off; gzip_static on; @@ -114,7 +96,7 @@ server { } # location /cable { - # proxy_pass http://puma_ikea_25; + # proxy_pass http://puma_ikea_26; # proxy_http_version 1.1; # proxy_set_header Upgrade $http_upgrade; # proxy_set_header Connection 'upgrade'; @@ -122,13 +104,13 @@ server { # Send non-static file requests to the app server location / { - try_files $uri @puma_ikea_25; + try_files $uri @puma_ikea_26; } # You can override error pages by redirecting the requests to a file in your # application's public folder, if you so desire: error_page 500 502 503 504 /500.html; location = /500.html { - root /home/ikea_foundation_2025/week_2025/public; + root /home/ikea_foundation_2026/week_2026/public; } } \ No newline at end of file diff --git a/db/migrate/20250429085114_create_players.rb b/db/migrate/20250429085114_create_players.rb deleted file mode 100644 index eee8105..0000000 --- a/db/migrate/20250429085114_create_players.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreatePlayers < ActiveRecord::Migration[8.0] - def change - create_table :players do |t| - - t.text :name - t.text :locale - t.integer :answer_cache, array: true, default: [] - - t.timestamps - t.index :answer_cache, using: :gin - end - - end -end diff --git a/db/migrate/20250429121602_create_answers.rb b/db/migrate/20250429121602_create_answers.rb deleted file mode 100644 index db4263f..0000000 --- a/db/migrate/20250429121602_create_answers.rb +++ /dev/null @@ -1,14 +0,0 @@ -class CreateAnswers < ActiveRecord::Migration[8.0] - def change - create_table :answers do |t| - - t.references :player - t.references :node - t.integer :value, default: nil, index: true - - t.timestamps - end - - - end -end diff --git a/db/migrate/20250522111116_add_score_to_players.rb b/db/migrate/20250522111116_add_score_to_players.rb deleted file mode 100644 index 667c667..0000000 --- a/db/migrate/20250522111116_add_score_to_players.rb +++ /dev/null @@ -1,6 +0,0 @@ -class AddScoreToPlayers < ActiveRecord::Migration[8.0] - def change - add_column :players, :score, :integer, default: nil - add_index :players, :score - end -end diff --git a/db/migrate/20250527114853_create_quiz_results.rb b/db/migrate/20250527114853_create_quiz_results.rb deleted file mode 100644 index 1c603bc..0000000 --- a/db/migrate/20250527114853_create_quiz_results.rb +++ /dev/null @@ -1,15 +0,0 @@ -class CreateQuizResults < ActiveRecord::Migration[8.0] - def change - create_table :quiz_results do |t| - t.string :share_id, null: false - t.string :player_name, null: false - t.string :stats, null: false - t.string :locale, null: false - t.integer :score, null: false - - t.timestamps - end - - add_index :quiz_results, :share_id, unique: true - end -end diff --git a/db/schema.rb b/db/schema.rb index b8a2c4e..7790712 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2025_05_27_114853) do +ActiveRecord::Schema[8.1].define(version: 2025_05_27_114853) do # These are extensions that must be enabled in order to support this database enable_extension "pg_catalog.plpgsql" @@ -19,24 +19,24 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_27_114853) do create_enum "user_roles", ["user", "admin"] create_table "active_storage_attachments", force: :cascade do |t| - t.string "name", null: false - t.string "record_type", null: false - t.bigint "record_id", null: false t.bigint "blob_id", null: false t.datetime "created_at", null: false + t.string "name", null: false + t.bigint "record_id", null: false + t.string "record_type", null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end create_table "active_storage_blobs", force: :cascade do |t| - t.string "key", null: false - t.string "filename", null: false - t.string "content_type" - t.text "metadata" - t.string "service_name", null: false t.bigint "byte_size", null: false t.string "checksum" + t.string "content_type" t.datetime "created_at", null: false + t.string "filename", null: false + t.string "key", null: false + t.text "metadata" + t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end @@ -47,21 +47,21 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_27_114853) do end create_table "answers", force: :cascade do |t| - t.bigint "player_id" - t.bigint "node_id" - t.integer "value" t.datetime "created_at", null: false + t.bigint "node_id" + t.bigint "player_id" t.datetime "updated_at", null: false + t.integer "value" t.index ["node_id"], name: "index_answers_on_node_id" t.index ["player_id"], name: "index_answers_on_player_id" t.index ["value"], name: "index_answers_on_value" end create_table "assets", force: :cascade do |t| - t.text "title" t.datetime "created_at", null: false - t.datetime "updated_at", null: false t.text "tags", default: [], array: true + t.text "title" + t.datetime "updated_at", null: false t.index ["tags"], name: "index_assets_on_tags", using: :gin end @@ -70,37 +70,37 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_27_114853) do t.integer "attachable_for_id" t.text "attachable_for_type" t.jsonb "body", default: {} - t.jsonb "url", default: {} - t.jsonb "props", default: {} + t.datetime "created_at", null: false t.boolean "is_favorite", default: false, null: false t.integer "position" - t.datetime "created_at", null: false + t.jsonb "props", default: {} t.datetime "updated_at", null: false + t.jsonb "url", default: {} t.index ["asset_id"], name: "index_attachments_on_asset_id" t.index ["attachable_for_id", "attachable_for_type"], name: "attachable_for" t.index ["is_favorite"], name: "index_attachments_on_is_favorite" end create_table "nodes", force: :cascade do |t| - t.integer "position" - t.integer "status", default: 0 - t.integer "template", default: 0 - t.integer "ancestry_depth", default: 0 t.string "ancestry", null: false, collation: "C" - t.jsonb "slug", default: {} - t.jsonb "url", default: {} - t.jsonb "title", default: {} - t.jsonb "page_title", default: {} - t.jsonb "page_description", default: {} - t.jsonb "href", default: {} - t.jsonb "tags", default: {} - t.text "settings", default: [], array: true + t.integer "ancestry_depth", default: 0 + t.datetime "created_at", null: false t.text "excluded_locales", default: [], array: true + t.datetime "expires_at" + t.jsonb "href", default: {} t.boolean "is_allowlist", default: false + t.jsonb "page_description", default: {} + t.jsonb "page_title", default: {} + t.integer "position" t.datetime "published_at" - t.datetime "expires_at" - t.datetime "created_at", null: false + t.text "settings", default: [], array: true + t.jsonb "slug", default: {} + t.integer "status", default: 0 + t.jsonb "tags", default: {} + t.integer "template", default: 0 + t.jsonb "title", default: {} t.datetime "updated_at", null: false + t.jsonb "url", default: {} t.index ["ancestry"], name: "index_nodes_on_ancestry" t.index ["ancestry_depth"], name: "index_nodes_on_ancestry_depth" t.index ["excluded_locales"], name: "index_nodes_on_excluded_locales", using: :gin @@ -115,48 +115,48 @@ ActiveRecord::Schema[8.0].define(version: 2025_05_27_114853) do end create_table "players", force: :cascade do |t| - t.text "name" - t.text "locale" t.integer "answer_cache", default: [], array: true t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.text "locale" + t.text "name" t.integer "score" + t.datetime "updated_at", null: false t.index ["answer_cache"], name: "index_players_on_answer_cache", using: :gin t.index ["score"], name: "index_players_on_score" end create_table "quiz_results", force: :cascade do |t| - t.string "share_id", null: false - t.string "player_name", null: false - t.string "stats", null: false + t.datetime "created_at", null: false t.string "locale", null: false + t.string "player_name", null: false t.integer "score", null: false - t.datetime "created_at", null: false + t.string "share_id", null: false + t.string "stats", null: false t.datetime "updated_at", null: false t.index ["share_id"], name: "index_quiz_results_on_share_id", unique: true end create_table "users", force: :cascade do |t| + t.datetime "created_at", null: false + t.text "description" t.text "email" - t.text "password_digest" + t.datetime "enabled_at" t.text "firstname" + t.datetime "last_logon_at" t.text "lastname" - t.text "title" + t.text "password_digest" t.text "phone" - t.text "description" t.enum "role", default: "user", enum_type: "user_roles" - t.datetime "enabled_at" - t.datetime "last_logon_at" - t.datetime "created_at", null: false + t.text "title" t.datetime "updated_at", null: false t.index ["email"], name: "index_users_on_email" end create_table "verification_codes", force: :cascade do |t| - t.bigint "user_id" - t.text "token" t.datetime "created_at", null: false + t.text "token" t.datetime "updated_at", null: false + t.bigint "user_id" t.index ["token"], name: "index_verification_codes_on_token" t.index ["user_id"], name: "index_verification_codes_on_user_id" end diff --git a/db/seeds.rb b/db/seeds.rb index 4803433..d5b7374 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -11,4 +11,4 @@ User.create( ) -Node.create title: 'Week 2025', slug: '', published_at: Time.now, ancestry: '/' +Node.create title: 'Week 2026', slug: '', published_at: Time.now, ancestry: '/' diff --git a/lib/tasks/quiz_stats.rake b/lib/tasks/quiz_stats.rake new file mode 100644 index 0000000..e9c282d --- /dev/null +++ b/lib/tasks/quiz_stats.rake @@ -0,0 +1,81 @@ +# lib/tasks/quiz_stats.rake +namespace :quiz do + desc "Show quiz statistics from Oct 17, 2025" + task stats: :environment do + results = QuizResult.where("created_at >= ?", Date.new(2025, 10, 17)) + + total = results.count + by_locale = results.group(:locale).count + scores = results.group(:score).count + avg_score = results.average(:score) + + # Calculate result categories + questions = Node.at_depth(1).tmpl_article.viewable.ordered.to_a + questions_count = questions.count + result_categories = { "People" => 0, "Planet" => 0, "Balanced" => 0 } + + results.each do |qr| + people_score = questions_count - qr.score + score_diff = people_score - qr.score + + category = case + when score_diff >= 2 + "People" + when score_diff <= -2 + "Planet" + else + "Balanced" + end + result_categories[category] += 1 + end + + puts "Quiz Results from Oct 17, 2025" + puts "=" * 40 + puts "Total: #{total}" + + puts "\nBy locale:" + by_locale.sort.each do |locale, count| + locale_name = I18n.t(locale, scope: 'languages') + puts " #{locale_name}: #{count}" + end + + puts "\nScore distribution:" + scores.sort.each do |score, count| + puts " Score #{score}: #{count}" + end + + puts "\nAverage score: #{avg_score&.round(2)}" + + puts "\nResult categories:" + result_categories.each do |category, count| + percentage = total > 0 ? (count.to_f / total * 100).round(1) : 0 + puts " #{category}: #{count} (#{percentage}%)" + end + + # Question by question breakdown + + puts "\n\nQuestion breakdown:" + puts "=" * 40 + questions.each_with_index do |question, i| + answers = Answer.where(node_id: question.id).where("created_at >= ?", Date.new(2025, 10, 17)) + answer_counts = answers.group(:value).count + + planet_answer = (i == 0 || i == 3) ? 0 : 1 + people_answer = (i == 0 || i == 3) ? 1 : 0 + + planet_count = answer_counts[planet_answer] || 0 + people_count = answer_counts[people_answer] || 0 + total_answers = planet_count + people_count + + puts "\nQ#{i + 1}: #{question.title}" + if total_answers > 0 + planet_pct = (planet_count.to_f / total_answers * 100).round(1) + people_pct = (people_count.to_f / total_answers * 100).round(1) + puts " Planet: #{planet_count} (#{planet_pct}%)" + puts " People: #{people_count} (#{people_pct}%)" + else + puts " No answers" + end + end + end +end diff --git a/mise.toml b/mise.toml index 264168f..c502692 100644 --- a/mise.toml +++ b/mise.toml @@ -1,2 +1,2 @@ [tools] -ruby = "3.4.1" +ruby = "3.4.9" diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..c4c9dbfbbd2f7c1421ffd5727188146213abbcef GIT binary patch literal 4166 zcmd6qU;WFw?|v@m)Sk^&NvB8tcujdV-r1b=i(NJxn&7{KTb zX$3(M+3TP2o^#KAo{#tIjl&t~(8D-k004kqPglzn0HFG(Q~(I*AKsD#M*g7!XK0T7 zN6P7j>HcT8rZgKl$v!xr806dyN19Bd4C0x_R*I-a?#zsTvb_89cyhuC&T**i|Rc zq5b8M;+{8KvoJ~uj9`u~d_f6`V&3+&ZX9x5pc8s)d175;@pjm(?dapmBcm0&vl9+W zx1ZD2o^nuyUHWj|^A8r>lUorO`wFF;>9XL-Jy!P}UXC{(z!FO%SH~8k`#|9;Q|eue zqWL0^Bp(fg_+Pkm!fDKRSY;+^@BF?AJE zCUWpXPst~hi_~u)SzYBDZroR+Z4xeHIlm_3Yc_9nZ(o_gg!jDgVa=E}Y8uDgem9`b zf=mfJ_@(BXSkW53B)F2s!&?_R4ptb1fYXlF++@vPhd=marQgEGRZS@B4g1Mu?euknL= z67P~tZ?*>-Hmi7GwlisNHHJDku-dSm7g@!=a}9cSL6Pa^w^2?&?$Oi8ibrr>w)xqx zOH_EMU@m05)9kuNR>>4@H%|){U$^yvVQ(YgOlh;5oU_-vivG-p4=LrN-k7D?*?u1u zsWly%tfAzKd6Fb=`eU2un_uaTXmcT#tlOL+aRS=kZZf}A7qT8lvcTx~7j` z*b>=z)mwg7%B2_!D0!1IZ?Nq{^Y$uI4Qx*6T!E2Col&2{k?ImCO=dD~A&9f9diXy^$x{6CwkBimn|1E09 zAMSezYtiL?O6hS37KpvDM?22&d{l)7h-!F)C-d3j8Z`c@($?mfd{R82)H>Qe`h{~G z!I}(2j(|49{LR?w4Jspl_i!(4T{31|dqCOpI52r5NhxYV+cDAu(xp*4iqZ2e-$YP= zoFOPmm|u*7C?S{Fp43y+V;>~@FFR76bCl@pTtyB93vNWy5yf;HKr8^0d7&GVIslYm zo3Tgt@M!`8B6IW&lK{Xk>%zp41G%`(DR&^u z5^pwD4>E6-w<8Kl2DzJ%a@~QDE$(e87lNhy?-Qgep!$b?5f7+&EM7$e>|WrX+=zCb z=!f5P>MxFyy;mIRxjc(H*}mceXw5a*IpC0PEYJ8Y3{JdoIW)@t97{wcUB@u+$FCCO z;s2Qe(d~oJC^`m$7DE-dsha`glrtu&v&93IZadvl_yjp!c89>zo;Krk+d&DEG4?x$ zufC1n+c1XD7dolX1q|7}uelR$`pT0Z)1jun<39$Sn2V5g&|(j~Z!wOddfYiZo7)A< z!dK`aBHOOk+-E_xbWCA3VR-+o$i5eO9`rMI#p_0xQ}rjEpGW;U!&&PKnivOcG(|m9 z!C8?WC6nCXw25WVa*eew)zQ=h45k8jSIPbq&?VE{oG%?4>9rwEeB4&qe#?-y_es4c|7ufw%+H5EY#oCgv!Lzv291#-oNlX~X+Jl5(riC~r z=0M|wMOP)Tt8@hNg&%V@Z9@J|Q#K*hE>sr6@oguas9&6^-=~$*2Gs%h#GF@h)i=Im z^iKk~ipWJg1VrvKS;_2lgs3n1zvNvxb27nGM=NXE!D4C!U`f*K2B@^^&ij9y}DTLB*FI zEnBL6y{jc?JqXWbkIZd7I16hA>(f9T!iwbIxJj~bKPfrO;>%*5nk&Lf?G@c2wvGrY&41$W{7HM9+b@&XY@>NZM5s|EK_Dp zQX60CBuantx>|d#DsaZ*8MW(we|#KTYZ=vNa#d*DJQe6hr~J6{_rI#?wi@s|&O}FR zG$kfPxheXh1?IZ{bDT-CWB4FTvO-k5scW^mi8?iY5Q`f8JcnnCxiy@m@D-%lO;y0pTLhh6i6l@x52j=#^$5_U^os}OFg zzdHbo(QI`%9#o*r8GCW~T3UdV`szO#~)^&X_(VW>o~umY9-ns9-V4lf~j z`QBD~pJ4a#b`*6bJ^3RS5y?RAgF7K5$ll97Y8#WZduZ`j?IEY~H(s^doZg>7-tk*t z4_QE1%%bb^p~4F5SB$t2i1>DBG1cIo;2(xTaj*Y~hlM{tSDHojL-QPg%Mo%6^7FrpB*{ z4G0@T{-77Por4DCMF zB_5Y~Phv%EQ64W8^GS6h?x6xh;w2{z3$rhC;m+;uD&pR74j+i22P5DS-tE8ABvH(U~indEbBUTAAAXfHZg5QpB@TgV9eI<)JrAkOI z8!TSOgfAJiWAXeM&vR4Glh;VxH}WG&V$bVb`a`g}GSpwggti*&)taV1@Ak|{WrV|5 zmNYx)Ans=S{c52qv@+jmGQ&vd6>6yX6IKq9O$3r&0xUTdZ!m1!irzn`SY+F23Rl6# zFRxws&gV-kM1NX(3(gnKpGi0Q)Dxi~#?nyzOR9!en;Ij>YJZVFAL*=R%7y%Mz9hU% zs>+ZB?qRmZ)nISx7wxY)y#cd$iaC~{k0avD>BjyF1q^mNQ1QcwsxiTySe<6C&cC6P zE`vwO9^k-d`9hZ!+r@Jnr+MF*2;2l8WjZ}DrwDUHzSF{WoG zucbSWguA!3KgB3MU%HH`R;XqVv0CcaGq?+;v_A5A2kpmk5V%qZE3yzQ7R5XWhq=eR zyUezH=@V)y>L9T-M-?tW(PQYTRBKZSVb_!$^H-Pn%ea;!vS_?M<~Tm>_rWIW43sPW z=!lY&fWc1g7+r?R)0p8(%zp&vl+FK4HRkns%BW+Up&wK8!lQ2~bja|9bD12WrKn#M zK)Yl9*8$SI7MAwSK$%)dMd>o+1UD<2&aQMhyjS5R{-vV+M;Q4bzl~Z~=4HFj_#2V9 zB)Gfzx3ncy@uzx?yzi}6>d%-?WE}h7v*w)Jr_gBl!2P&F3DX>j_1#--yjpL%<;JMR z*b70Gr)MMIBWDo~#<5F^Q0$VKI;SBIRneuR7)yVsN~A9I@gZTXe)E?iVII+X5h0~H zx^c(fP&4>!*q>fb6dAOC?MI>Cz3kld#J*;uik+Ps49cwm1B4 zZc1|ZxYyTv;{Z!?qS=D)sgRKx^1AYf%;y_V&VgZglfU>d+Ufk5&LV$sKv}Hoj+s; xK3FZRYdhbXT_@RW*ff3@`D1#ps#~H)p+y&j#(J|vk^lW{fF9OJt5(B-_&*Xgn9~3N literal 0 HcmV?d00001 diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 0000000..04b34bf --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/vendor/javascript/@rails--activestorage.js b/vendor/javascript/@rails--activestorage.js index bf0e547..d6e480c 100644 --- a/vendor/javascript/@rails--activestorage.js +++ b/vendor/javascript/@rails--activestorage.js @@ -1,4 +1,4 @@ -// @rails/activestorage@8.0.300 downloaded from https://ga.jspm.io/npm:@rails/activestorage@8.0.300/app/assets/javascripts/activestorage.esm.js +// @rails/activestorage@8.1.200 downloaded from https://ga.jspm.io/npm:@rails/activestorage@8.1.200/app/assets/javascripts/activestorage.esm.js -var t={exports:{}};(function(t){(function(e){t.exports=e()})((function(t){var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function r(t,e){var r=t[0],i=t[1],s=t[2],n=t[3];r+=(i&s|~i&n)+e[0]-680876936|0;r=(r<<7|r>>>25)+i|0;n+=(r&i|~r&s)+e[1]-389564586|0;n=(n<<12|n>>>20)+r|0;s+=(n&r|~n&i)+e[2]+606105819|0;s=(s<<17|s>>>15)+n|0;i+=(s&n|~s&r)+e[3]-1044525330|0;i=(i<<22|i>>>10)+s|0;r+=(i&s|~i&n)+e[4]-176418897|0;r=(r<<7|r>>>25)+i|0;n+=(r&i|~r&s)+e[5]+1200080426|0;n=(n<<12|n>>>20)+r|0;s+=(n&r|~n&i)+e[6]-1473231341|0;s=(s<<17|s>>>15)+n|0;i+=(s&n|~s&r)+e[7]-45705983|0;i=(i<<22|i>>>10)+s|0;r+=(i&s|~i&n)+e[8]+1770035416|0;r=(r<<7|r>>>25)+i|0;n+=(r&i|~r&s)+e[9]-1958414417|0;n=(n<<12|n>>>20)+r|0;s+=(n&r|~n&i)+e[10]-42063|0;s=(s<<17|s>>>15)+n|0;i+=(s&n|~s&r)+e[11]-1990404162|0;i=(i<<22|i>>>10)+s|0;r+=(i&s|~i&n)+e[12]+1804603682|0;r=(r<<7|r>>>25)+i|0;n+=(r&i|~r&s)+e[13]-40341101|0;n=(n<<12|n>>>20)+r|0;s+=(n&r|~n&i)+e[14]-1502002290|0;s=(s<<17|s>>>15)+n|0;i+=(s&n|~s&r)+e[15]+1236535329|0;i=(i<<22|i>>>10)+s|0;r+=(i&n|s&~n)+e[1]-165796510|0;r=(r<<5|r>>>27)+i|0;n+=(r&s|i&~s)+e[6]-1069501632|0;n=(n<<9|n>>>23)+r|0;s+=(n&i|r&~i)+e[11]+643717713|0;s=(s<<14|s>>>18)+n|0;i+=(s&r|n&~r)+e[0]-373897302|0;i=(i<<20|i>>>12)+s|0;r+=(i&n|s&~n)+e[5]-701558691|0;r=(r<<5|r>>>27)+i|0;n+=(r&s|i&~s)+e[10]+38016083|0;n=(n<<9|n>>>23)+r|0;s+=(n&i|r&~i)+e[15]-660478335|0;s=(s<<14|s>>>18)+n|0;i+=(s&r|n&~r)+e[4]-405537848|0;i=(i<<20|i>>>12)+s|0;r+=(i&n|s&~n)+e[9]+568446438|0;r=(r<<5|r>>>27)+i|0;n+=(r&s|i&~s)+e[14]-1019803690|0;n=(n<<9|n>>>23)+r|0;s+=(n&i|r&~i)+e[3]-187363961|0;s=(s<<14|s>>>18)+n|0;i+=(s&r|n&~r)+e[8]+1163531501|0;i=(i<<20|i>>>12)+s|0;r+=(i&n|s&~n)+e[13]-1444681467|0;r=(r<<5|r>>>27)+i|0;n+=(r&s|i&~s)+e[2]-51403784|0;n=(n<<9|n>>>23)+r|0;s+=(n&i|r&~i)+e[7]+1735328473|0;s=(s<<14|s>>>18)+n|0;i+=(s&r|n&~r)+e[12]-1926607734|0;i=(i<<20|i>>>12)+s|0;r+=(i^s^n)+e[5]-378558|0;r=(r<<4|r>>>28)+i|0;n+=(r^i^s)+e[8]-2022574463|0;n=(n<<11|n>>>21)+r|0;s+=(n^r^i)+e[11]+1839030562|0;s=(s<<16|s>>>16)+n|0;i+=(s^n^r)+e[14]-35309556|0;i=(i<<23|i>>>9)+s|0;r+=(i^s^n)+e[1]-1530992060|0;r=(r<<4|r>>>28)+i|0;n+=(r^i^s)+e[4]+1272893353|0;n=(n<<11|n>>>21)+r|0;s+=(n^r^i)+e[7]-155497632|0;s=(s<<16|s>>>16)+n|0;i+=(s^n^r)+e[10]-1094730640|0;i=(i<<23|i>>>9)+s|0;r+=(i^s^n)+e[13]+681279174|0;r=(r<<4|r>>>28)+i|0;n+=(r^i^s)+e[0]-358537222|0;n=(n<<11|n>>>21)+r|0;s+=(n^r^i)+e[3]-722521979|0;s=(s<<16|s>>>16)+n|0;i+=(s^n^r)+e[6]+76029189|0;i=(i<<23|i>>>9)+s|0;r+=(i^s^n)+e[9]-640364487|0;r=(r<<4|r>>>28)+i|0;n+=(r^i^s)+e[12]-421815835|0;n=(n<<11|n>>>21)+r|0;s+=(n^r^i)+e[15]+530742520|0;s=(s<<16|s>>>16)+n|0;i+=(s^n^r)+e[2]-995338651|0;i=(i<<23|i>>>9)+s|0;r+=(s^(i|~n))+e[0]-198630844|0;r=(r<<6|r>>>26)+i|0;n+=(i^(r|~s))+e[7]+1126891415|0;n=(n<<10|n>>>22)+r|0;s+=(r^(n|~i))+e[14]-1416354905|0;s=(s<<15|s>>>17)+n|0;i+=(n^(s|~r))+e[5]-57434055|0;i=(i<<21|i>>>11)+s|0;r+=(s^(i|~n))+e[12]+1700485571|0;r=(r<<6|r>>>26)+i|0;n+=(i^(r|~s))+e[3]-1894986606|0;n=(n<<10|n>>>22)+r|0;s+=(r^(n|~i))+e[10]-1051523|0;s=(s<<15|s>>>17)+n|0;i+=(n^(s|~r))+e[1]-2054922799|0;i=(i<<21|i>>>11)+s|0;r+=(s^(i|~n))+e[8]+1873313359|0;r=(r<<6|r>>>26)+i|0;n+=(i^(r|~s))+e[15]-30611744|0;n=(n<<10|n>>>22)+r|0;s+=(r^(n|~i))+e[6]-1560198380|0;s=(s<<15|s>>>17)+n|0;i+=(n^(s|~r))+e[13]+1309151649|0;i=(i<<21|i>>>11)+s|0;r+=(s^(i|~n))+e[4]-145523070|0;r=(r<<6|r>>>26)+i|0;n+=(i^(r|~s))+e[11]-1120210379|0;n=(n<<10|n>>>22)+r|0;s+=(r^(n|~i))+e[2]+718787259|0;s=(s<<15|s>>>17)+n|0;i+=(n^(s|~r))+e[9]-343485551|0;i=(i<<21|i>>>11)+s|0;t[0]=r+t[0]|0;t[1]=i+t[1]|0;t[2]=s+t[2]|0;t[3]=n+t[3]|0}function i(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function s(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function n(t){var e,s,n,o,a,h,u=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=u;e+=64)r(c,i(t.substring(e-64,e)));t=t.substring(e-64);s=t.length;n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);n[e>>2]|=128<<(e%4<<3);if(e>55){r(c,n);for(e=0;e<16;e+=1)n[e]=0}o=u*8;o=o.toString(16).match(/(.*?)(.{0,8})$/);a=parseInt(o[2],16);h=parseInt(o[1],16)||0;n[14]=a;n[15]=h;r(c,n);return c}function o(t){var e,i,n,o,a,h,u=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=u;e+=64)r(c,s(t.subarray(e-64,e)));t=e-64>2]|=t[e]<<(e%4<<3);n[e>>2]|=128<<(e%4<<3);if(e>55){r(c,n);for(e=0;e<16;e+=1)n[e]=0}o=u*8;o=o.toString(16).match(/(.*?)(.{0,8})$/);a=parseInt(o[2],16);h=parseInt(o[1],16)||0;n[14]=a;n[15]=h;r(c,n);return c}function a(t){var r,i="";for(r=0;r<4;r+=1)i+=e[t>>r*8+4&15]+e[t>>r*8&15];return i}function h(t){var e;for(e=0;ec)return new ArrayBuffer(0);s=c-u;n=new ArrayBuffer(s);o=new Uint8Array(n);a=new Uint8Array(this,u,s);o.set(a);return n}}();function u(t){/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t)));return t}function c(t,e){var r,i=t.length,s=new ArrayBuffer(i),n=new Uint8Array(s);for(r=0;r>2]|=i.charCodeAt(e)<<(e%4<<3);this._finish(n,s);r=h(this._hash);t&&(r=d(r));this.reset();return r};p.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}};p.prototype.setState=function(t){this._buff=t.buff;this._length=t.length;this._hash=t.hash;return this};p.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};p.prototype._finish=function(t,e){var i,s,n,o=e;t[o>>2]|=128<<(o%4<<3);if(o>55){r(this._hash,t);for(o=0;o<16;o+=1)t[o]=0}i=this._length*8;i=i.toString(16).match(/(.*?)(.{0,8})$/);s=parseInt(i[2],16);n=parseInt(i[1],16)||0;t[14]=s;t[15]=n;r(this._hash,t)};p.hash=function(t,e){return p.hashBinary(u(t),e)};p.hashBinary=function(t,e){var r=n(t),i=h(r);return e?d(i):i};p.ArrayBuffer=function(){this.reset()};p.ArrayBuffer.prototype.append=function(t){var e,i=f(this._buff.buffer,t,true),n=i.length;this._length+=t.byteLength;for(e=64;e<=n;e+=64)r(this._hash,s(i.subarray(e-64,e)));this._buff=e-64>2]|=i[e]<<(e%4<<3);this._finish(n,s);r=h(this._hash);t&&(r=d(r));this.reset();return r};p.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};p.ArrayBuffer.prototype.getState=function(){var t=p.prototype.getState.call(this);t.buff=l(t.buff);return t};p.ArrayBuffer.prototype.setState=function(t){t.buff=c(t.buff,true);return p.prototype.setState.call(this,t)};p.ArrayBuffer.prototype.destroy=p.prototype.destroy;p.ArrayBuffer.prototype._finish=p.prototype._finish;p.ArrayBuffer.hash=function(t,e){var r=o(new Uint8Array(t)),i=h(r);return e?d(i):i};return p}))})(t);var e=t.exports;const r=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;class FileChecksum{static create(t,e){const r=new FileChecksum(t);r.create(e)}constructor(t){this.file=t;this.chunkSize=2097152;this.chunkCount=Math.ceil(this.file.size/this.chunkSize);this.chunkIndex=0}create(t){this.callback=t;this.md5Buffer=new e.ArrayBuffer;this.fileReader=new FileReader;this.fileReader.addEventListener("load",(t=>this.fileReaderDidLoad(t)));this.fileReader.addEventListener("error",(t=>this.fileReaderDidError(t)));this.readNextChunk()}fileReaderDidLoad(t){this.md5Buffer.append(t.target.result);if(!this.readNextChunk()){const t=this.md5Buffer.end(true);const e=btoa(t);this.callback(null,e)}}fileReaderDidError(t){this.callback(`Error reading ${this.file.name}`)}readNextChunk(){if(this.chunkIndex{this.xhr.setRequestHeader(t,s[t])}));const n=i("csrf-token");n!=void 0&&this.xhr.setRequestHeader("X-CSRF-Token",n);this.xhr.addEventListener("load",(t=>this.requestDidLoad(t)));this.xhr.addEventListener("error",(t=>this.requestDidError(t)))}get status(){return this.xhr.status}get response(){const{responseType:t,response:e}=this.xhr;return t=="json"?e:JSON.parse(e)}create(t){this.callback=t;this.xhr.send(JSON.stringify({blob:this.attributes}))}requestDidLoad(t){if(this.status>=200&&this.status<300){const{response:t}=this;const{direct_upload:e}=t;delete t.direct_upload;this.attributes=t;this.directUploadData=e;this.callback(null,this.toJSON())}else this.requestDidError(t)}requestDidError(t){this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)}toJSON(){const t={};for(const e in this.attributes)t[e]=this.attributes[e];return t}}class BlobUpload{constructor(t){this.blob=t;this.file=t.file;const{url:e,headers:r}=t.directUploadData;this.xhr=new XMLHttpRequest;this.xhr.open("PUT",e,true);this.xhr.responseType="text";for(const t in r)this.xhr.setRequestHeader(t,r[t]);this.xhr.addEventListener("load",(t=>this.requestDidLoad(t)));this.xhr.addEventListener("error",(t=>this.requestDidError(t)))}create(t){this.callback=t;this.xhr.send(this.file.slice())}requestDidLoad(t){const{status:e,response:r}=this.xhr;e>=200&&e<300?this.callback(null,r):this.requestDidError(t)}requestDidError(t){this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`)}}let h=0;class DirectUpload{constructor(t,e,r,i={}){this.id=++h;this.file=t;this.url=e;this.delegate=r;this.customHeaders=i}create(t){FileChecksum.create(this.file,((e,r)=>{if(e){t(e);return}const i=new BlobRecord(this.file,r,this.url,this.customHeaders);u(this.delegate,"directUploadWillCreateBlobWithXHR",i.xhr);i.create((e=>{if(e)t(e);else{const e=new BlobUpload(i);u(this.delegate,"directUploadWillStoreFileWithXHR",e.xhr);e.create((e=>{e?t(e):t(null,i.toJSON())}))}}))}))}}function u(t,e,...r){if(t&&typeof t[e]=="function")return t[e](...r)}class DirectUploadController{constructor(t,e){this.input=t;this.file=e;this.directUpload=new DirectUpload(this.file,this.url,this);this.dispatch("initialize")}start(t){const e=document.createElement("input");e.type="hidden";e.name=this.input.name;this.input.insertAdjacentElement("beforebegin",e);this.dispatch("start");this.directUpload.create(((r,i)=>{if(r){e.parentNode.removeChild(e);this.dispatchError(r)}else e.value=i.signed_id;this.dispatch("end");t(r)}))}uploadRequestDidProgress(t){const e=t.loaded/t.total*100;e&&this.dispatch("progress",{progress:e})}get url(){return this.input.getAttribute("data-direct-upload-url")}dispatch(t,e={}){e.file=this.file;e.id=this.directUpload.id;return o(this.input,`direct-upload:${t}`,{detail:e})}dispatchError(t){const e=this.dispatch("error",{error:t});e.defaultPrevented||alert(t)}directUploadWillCreateBlobWithXHR(t){this.dispatch("before-blob-request",{xhr:t})}directUploadWillStoreFileWithXHR(t){this.dispatch("before-storage-request",{xhr:t});t.upload.addEventListener("progress",(t=>this.uploadRequestDidProgress(t)))}}const c="input[type=file][data-direct-upload-url]:not([disabled])";class DirectUploadsController{constructor(t){this.form=t;this.inputs=s(t,c).filter((t=>t.files.length))}start(t){const e=this.createDirectUploadControllers();const r=()=>{const i=e.shift();if(i)i.start((e=>{if(e){t(e);this.dispatch("end")}else r()}));else{t();this.dispatch("end")}};this.dispatch("start");r()}createDirectUploadControllers(){const t=[];this.inputs.forEach((e=>{a(e.files).forEach((r=>{const i=new DirectUploadController(e,r);t.push(i)}))}));return t}dispatch(t,e={}){return o(this.form,`direct-uploads:${t}`,{detail:e})}}const l="data-direct-uploads-processing";const f=new WeakMap;let d=false;function p(){if(!d){d=true;document.addEventListener("click",b,true);document.addEventListener("submit",y,true);document.addEventListener("ajax:before",g)}}function b(t){const e=t.target.closest("button, input");e&&e.type==="submit"&&e.form&&f.set(e.form,e)}function y(t){m(t)}function g(t){t.target.tagName=="FORM"&&m(t)}function m(t){const e=t.target;if(e.hasAttribute(l)){t.preventDefault();return}const r=new DirectUploadsController(e);const{inputs:i}=r;if(i.length){t.preventDefault();e.setAttribute(l,"");i.forEach(v);r.start((t=>{e.removeAttribute(l);t?i.forEach(_):A(e)}))}}function A(t){let e=f.get(t)||n(t,"input[type=submit], button[type=submit]");if(e){const{disabled:t}=e;e.disabled=false;e.focus();e.click();e.disabled=t}else{e=document.createElement("input");e.type="submit";e.style.display="none";t.appendChild(e);e.click();t.removeChild(e)}f.delete(t)}function v(t){t.disabled=true}function _(t){t.disabled=false}function x(){window.ActiveStorage&&p()}setTimeout(x,1);export{DirectUpload,DirectUploadController,DirectUploadsController,o as dispatchEvent,p as start}; +var t={exports:{}};(function(t){(function(e){t.exports=e()})((function(t){var e=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function r(t,e){var r=t[0],s=t[1],i=t[2],n=t[3];r+=(s&i|~s&n)+e[0]-680876936|0;r=(r<<7|r>>>25)+s|0;n+=(r&s|~r&i)+e[1]-389564586|0;n=(n<<12|n>>>20)+r|0;i+=(n&r|~n&s)+e[2]+606105819|0;i=(i<<17|i>>>15)+n|0;s+=(i&n|~i&r)+e[3]-1044525330|0;s=(s<<22|s>>>10)+i|0;r+=(s&i|~s&n)+e[4]-176418897|0;r=(r<<7|r>>>25)+s|0;n+=(r&s|~r&i)+e[5]+1200080426|0;n=(n<<12|n>>>20)+r|0;i+=(n&r|~n&s)+e[6]-1473231341|0;i=(i<<17|i>>>15)+n|0;s+=(i&n|~i&r)+e[7]-45705983|0;s=(s<<22|s>>>10)+i|0;r+=(s&i|~s&n)+e[8]+1770035416|0;r=(r<<7|r>>>25)+s|0;n+=(r&s|~r&i)+e[9]-1958414417|0;n=(n<<12|n>>>20)+r|0;i+=(n&r|~n&s)+e[10]-42063|0;i=(i<<17|i>>>15)+n|0;s+=(i&n|~i&r)+e[11]-1990404162|0;s=(s<<22|s>>>10)+i|0;r+=(s&i|~s&n)+e[12]+1804603682|0;r=(r<<7|r>>>25)+s|0;n+=(r&s|~r&i)+e[13]-40341101|0;n=(n<<12|n>>>20)+r|0;i+=(n&r|~n&s)+e[14]-1502002290|0;i=(i<<17|i>>>15)+n|0;s+=(i&n|~i&r)+e[15]+1236535329|0;s=(s<<22|s>>>10)+i|0;r+=(s&n|i&~n)+e[1]-165796510|0;r=(r<<5|r>>>27)+s|0;n+=(r&i|s&~i)+e[6]-1069501632|0;n=(n<<9|n>>>23)+r|0;i+=(n&s|r&~s)+e[11]+643717713|0;i=(i<<14|i>>>18)+n|0;s+=(i&r|n&~r)+e[0]-373897302|0;s=(s<<20|s>>>12)+i|0;r+=(s&n|i&~n)+e[5]-701558691|0;r=(r<<5|r>>>27)+s|0;n+=(r&i|s&~i)+e[10]+38016083|0;n=(n<<9|n>>>23)+r|0;i+=(n&s|r&~s)+e[15]-660478335|0;i=(i<<14|i>>>18)+n|0;s+=(i&r|n&~r)+e[4]-405537848|0;s=(s<<20|s>>>12)+i|0;r+=(s&n|i&~n)+e[9]+568446438|0;r=(r<<5|r>>>27)+s|0;n+=(r&i|s&~i)+e[14]-1019803690|0;n=(n<<9|n>>>23)+r|0;i+=(n&s|r&~s)+e[3]-187363961|0;i=(i<<14|i>>>18)+n|0;s+=(i&r|n&~r)+e[8]+1163531501|0;s=(s<<20|s>>>12)+i|0;r+=(s&n|i&~n)+e[13]-1444681467|0;r=(r<<5|r>>>27)+s|0;n+=(r&i|s&~i)+e[2]-51403784|0;n=(n<<9|n>>>23)+r|0;i+=(n&s|r&~s)+e[7]+1735328473|0;i=(i<<14|i>>>18)+n|0;s+=(i&r|n&~r)+e[12]-1926607734|0;s=(s<<20|s>>>12)+i|0;r+=(s^i^n)+e[5]-378558|0;r=(r<<4|r>>>28)+s|0;n+=(r^s^i)+e[8]-2022574463|0;n=(n<<11|n>>>21)+r|0;i+=(n^r^s)+e[11]+1839030562|0;i=(i<<16|i>>>16)+n|0;s+=(i^n^r)+e[14]-35309556|0;s=(s<<23|s>>>9)+i|0;r+=(s^i^n)+e[1]-1530992060|0;r=(r<<4|r>>>28)+s|0;n+=(r^s^i)+e[4]+1272893353|0;n=(n<<11|n>>>21)+r|0;i+=(n^r^s)+e[7]-155497632|0;i=(i<<16|i>>>16)+n|0;s+=(i^n^r)+e[10]-1094730640|0;s=(s<<23|s>>>9)+i|0;r+=(s^i^n)+e[13]+681279174|0;r=(r<<4|r>>>28)+s|0;n+=(r^s^i)+e[0]-358537222|0;n=(n<<11|n>>>21)+r|0;i+=(n^r^s)+e[3]-722521979|0;i=(i<<16|i>>>16)+n|0;s+=(i^n^r)+e[6]+76029189|0;s=(s<<23|s>>>9)+i|0;r+=(s^i^n)+e[9]-640364487|0;r=(r<<4|r>>>28)+s|0;n+=(r^s^i)+e[12]-421815835|0;n=(n<<11|n>>>21)+r|0;i+=(n^r^s)+e[15]+530742520|0;i=(i<<16|i>>>16)+n|0;s+=(i^n^r)+e[2]-995338651|0;s=(s<<23|s>>>9)+i|0;r+=(i^(s|~n))+e[0]-198630844|0;r=(r<<6|r>>>26)+s|0;n+=(s^(r|~i))+e[7]+1126891415|0;n=(n<<10|n>>>22)+r|0;i+=(r^(n|~s))+e[14]-1416354905|0;i=(i<<15|i>>>17)+n|0;s+=(n^(i|~r))+e[5]-57434055|0;s=(s<<21|s>>>11)+i|0;r+=(i^(s|~n))+e[12]+1700485571|0;r=(r<<6|r>>>26)+s|0;n+=(s^(r|~i))+e[3]-1894986606|0;n=(n<<10|n>>>22)+r|0;i+=(r^(n|~s))+e[10]-1051523|0;i=(i<<15|i>>>17)+n|0;s+=(n^(i|~r))+e[1]-2054922799|0;s=(s<<21|s>>>11)+i|0;r+=(i^(s|~n))+e[8]+1873313359|0;r=(r<<6|r>>>26)+s|0;n+=(s^(r|~i))+e[15]-30611744|0;n=(n<<10|n>>>22)+r|0;i+=(r^(n|~s))+e[6]-1560198380|0;i=(i<<15|i>>>17)+n|0;s+=(n^(i|~r))+e[13]+1309151649|0;s=(s<<21|s>>>11)+i|0;r+=(i^(s|~n))+e[4]-145523070|0;r=(r<<6|r>>>26)+s|0;n+=(s^(r|~i))+e[11]-1120210379|0;n=(n<<10|n>>>22)+r|0;i+=(r^(n|~s))+e[2]+718787259|0;i=(i<<15|i>>>17)+n|0;s+=(n^(i|~r))+e[9]-343485551|0;s=(s<<21|s>>>11)+i|0;t[0]=r+t[0]|0;t[1]=s+t[1]|0;t[2]=i+t[2]|0;t[3]=n+t[3]|0}function s(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t.charCodeAt(e)+(t.charCodeAt(e+1)<<8)+(t.charCodeAt(e+2)<<16)+(t.charCodeAt(e+3)<<24);return r}function i(t){var e,r=[];for(e=0;e<64;e+=4)r[e>>2]=t[e]+(t[e+1]<<8)+(t[e+2]<<16)+(t[e+3]<<24);return r}function n(t){var e,i,n,o,a,h,u=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=u;e+=64)r(c,s(t.substring(e-64,e)));t=t.substring(e-64);i=t.length;n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];for(e=0;e>2]|=t.charCodeAt(e)<<(e%4<<3);n[e>>2]|=128<<(e%4<<3);if(e>55){r(c,n);for(e=0;e<16;e+=1)n[e]=0}o=u*8;o=o.toString(16).match(/(.*?)(.{0,8})$/);a=parseInt(o[2],16);h=parseInt(o[1],16)||0;n[14]=a;n[15]=h;r(c,n);return c}function o(t){var e,s,n,o,a,h,u=t.length,c=[1732584193,-271733879,-1732584194,271733878];for(e=64;e<=u;e+=64)r(c,i(t.subarray(e-64,e)));t=e-64>2]|=t[e]<<(e%4<<3);n[e>>2]|=128<<(e%4<<3);if(e>55){r(c,n);for(e=0;e<16;e+=1)n[e]=0}o=u*8;o=o.toString(16).match(/(.*?)(.{0,8})$/);a=parseInt(o[2],16);h=parseInt(o[1],16)||0;n[14]=a;n[15]=h;r(c,n);return c}function a(t){var r,s="";for(r=0;r<4;r+=1)s+=e[t>>r*8+4&15]+e[t>>r*8&15];return s}function h(t){var e;for(e=0;ec)return new ArrayBuffer(0);i=c-u;n=new ArrayBuffer(i);o=new Uint8Array(n);a=new Uint8Array(this,u,i);o.set(a);return n}}();function u(t){/[\u0080-\uFFFF]/.test(t)&&(t=unescape(encodeURIComponent(t)));return t}function c(t,e){var r,s=t.length,i=new ArrayBuffer(s),n=new Uint8Array(i);for(r=0;r>2]|=s.charCodeAt(e)<<(e%4<<3);this._finish(n,i);r=h(this._hash);t&&(r=d(r));this.reset();return r};p.prototype.reset=function(){this._buff="";this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};p.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}};p.prototype.setState=function(t){this._buff=t.buff;this._length=t.length;this._hash=t.hash;return this};p.prototype.destroy=function(){delete this._hash;delete this._buff;delete this._length};p.prototype._finish=function(t,e){var s,i,n,o=e;t[o>>2]|=128<<(o%4<<3);if(o>55){r(this._hash,t);for(o=0;o<16;o+=1)t[o]=0}s=this._length*8;s=s.toString(16).match(/(.*?)(.{0,8})$/);i=parseInt(s[2],16);n=parseInt(s[1],16)||0;t[14]=i;t[15]=n;r(this._hash,t)};p.hash=function(t,e){return p.hashBinary(u(t),e)};p.hashBinary=function(t,e){var r=n(t),s=h(r);return e?d(s):s};p.ArrayBuffer=function(){this.reset()};p.ArrayBuffer.prototype.append=function(t){var e,s=f(this._buff.buffer,t,true),n=s.length;this._length+=t.byteLength;for(e=64;e<=n;e+=64)r(this._hash,i(s.subarray(e-64,e)));this._buff=e-64>2]|=s[e]<<(e%4<<3);this._finish(n,i);r=h(this._hash);t&&(r=d(r));this.reset();return r};p.ArrayBuffer.prototype.reset=function(){this._buff=new Uint8Array(0);this._length=0;this._hash=[1732584193,-271733879,-1732584194,271733878];return this};p.ArrayBuffer.prototype.getState=function(){var t=p.prototype.getState.call(this);t.buff=l(t.buff);return t};p.ArrayBuffer.prototype.setState=function(t){t.buff=c(t.buff,true);return p.prototype.setState.call(this,t)};p.ArrayBuffer.prototype.destroy=p.prototype.destroy;p.ArrayBuffer.prototype._finish=p.prototype._finish;p.ArrayBuffer.hash=function(t,e){var r=o(new Uint8Array(t)),s=h(r);return e?d(s):s};return p}))})(t);var e=t.exports;const r=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice;class FileChecksum{static create(t,e){const r=new FileChecksum(t);r.create(e)}constructor(t){this.file=t;this.chunkSize=2097152;this.chunkCount=Math.ceil(this.file.size/this.chunkSize);this.chunkIndex=0}create(t){this.callback=t;this.md5Buffer=new e.ArrayBuffer;this.fileReader=new FileReader;this.fileReader.addEventListener("load",(t=>this.fileReaderDidLoad(t)));this.fileReader.addEventListener("error",(t=>this.fileReaderDidError(t)));this.readNextChunk()}fileReaderDidLoad(t){this.md5Buffer.append(t.target.result);if(!this.readNextChunk()){const t=this.md5Buffer.end(true);const e=btoa(t);this.callback(null,e)}}fileReaderDidError(t){this.callback(`Error reading ${this.file.name}`)}readNextChunk(){if(this.chunkIndex{this.xhr.setRequestHeader(t,i[t])}));const n=s("csrf-token");n!=void 0&&this.xhr.setRequestHeader("X-CSRF-Token",n);this.xhr.addEventListener("load",(t=>this.requestDidLoad(t)));this.xhr.addEventListener("error",(t=>this.requestDidError(t)))}get status(){return this.xhr.status}get response(){const{responseType:t,response:e}=this.xhr;return t=="json"?e:JSON.parse(e)}create(t){this.callback=t;this.xhr.send(JSON.stringify({blob:this.attributes}))}requestDidLoad(t){if(this.status>=200&&this.status<300){const{response:t}=this;const{direct_upload:e}=t;delete t.direct_upload;this.attributes=t;this.directUploadData=e;this.callback(null,this.toJSON())}else this.requestDidError(t)}requestDidError(t){this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)}toJSON(){const t={};for(const e in this.attributes)t[e]=this.attributes[e];return t}}class BlobUpload{constructor(t){this.blob=t;this.file=t.file;const{url:e,headers:r}=t.directUploadData;this.xhr=new XMLHttpRequest;this.xhr.open("PUT",e,true);this.xhr.responseType="text";for(const t in r)this.xhr.setRequestHeader(t,r[t]);this.xhr.addEventListener("load",(t=>this.requestDidLoad(t)));this.xhr.addEventListener("error",(t=>this.requestDidError(t)))}create(t){this.callback=t;this.xhr.send(this.file.slice())}requestDidLoad(t){const{status:e,response:r}=this.xhr;e>=200&&e<300?this.callback(null,r):this.requestDidError(t)}requestDidError(t){this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`)}}let h=0;class DirectUpload{constructor(t,e,r,s={}){this.id=++h;this.file=t;this.url=e;this.delegate=r;this.customHeaders=s}create(t){FileChecksum.create(this.file,((e,r)=>{if(e){t(e);return}const s=new BlobRecord(this.file,r,this.url,this.customHeaders);u(this.delegate,"directUploadWillCreateBlobWithXHR",s.xhr);s.create((e=>{if(e)t(e);else{const e=new BlobUpload(s);u(this.delegate,"directUploadWillStoreFileWithXHR",e.xhr);e.create((e=>{e?t(e):t(null,s.toJSON())}))}}))}))}}function u(t,e,...r){if(t&&typeof t[e]=="function")return t[e](...r)}class DirectUploadController{constructor(t,e){this.input=t;this.file=e;this.directUpload=new DirectUpload(this.file,this.url,this);this.dispatch("initialize")}start(t){const e=document.createElement("input");e.type="hidden";e.name=this.input.name;this.input.insertAdjacentElement("beforebegin",e);this.dispatch("start");this.directUpload.create(((r,s)=>{if(r){e.parentNode.removeChild(e);this.dispatchError(r)}else e.value=s.signed_id;this.dispatch("end");t(r)}))}uploadRequestDidProgress(t){const e=t.loaded/t.total*90;e&&this.dispatch("progress",{progress:e})}get url(){return this.input.getAttribute("data-direct-upload-url")}dispatch(t,e={}){e.file=this.file;e.id=this.directUpload.id;return o(this.input,`direct-upload:${t}`,{detail:e})}dispatchError(t){const e=this.dispatch("error",{error:t});e.defaultPrevented||alert(t)}directUploadWillCreateBlobWithXHR(t){this.dispatch("before-blob-request",{xhr:t})}directUploadWillStoreFileWithXHR(t){this.dispatch("before-storage-request",{xhr:t});t.upload.addEventListener("progress",(t=>this.uploadRequestDidProgress(t)));t.upload.addEventListener("loadend",(()=>{this.simulateResponseProgress(t)}))}simulateResponseProgress(t){let e=90;const r=Date.now();const s=()=>{const i=Date.now()-r;const n=this.estimateResponseTime();const o=Math.min(i/n,1);e=90+o*9;this.dispatch("progress",{progress:e});t.readyState!==XMLHttpRequest.DONE&&e<99&&requestAnimationFrame(s)};t.addEventListener("loadend",(()=>{this.dispatch("progress",{progress:100})}));requestAnimationFrame(s)}estimateResponseTime(){const t=this.file.size;const e=1048576;return tt.files.length))}start(t){const e=this.createDirectUploadControllers();const r=()=>{const s=e.shift();if(s)s.start((e=>{if(e){t(e);this.dispatch("end")}else r()}));else{t();this.dispatch("end")}};this.dispatch("start");r()}createDirectUploadControllers(){const t=[];this.inputs.forEach((e=>{a(e.files).forEach((r=>{const s=new DirectUploadController(e,r);t.push(s)}))}));return t}dispatch(t,e={}){return o(this.form,`direct-uploads:${t}`,{detail:e})}}const l="data-direct-uploads-processing";const f=new WeakMap;let d=false;function p(){if(!d){d=true;document.addEventListener("click",b,true);document.addEventListener("submit",y,true);document.addEventListener("ajax:before",g)}}function b(t){const e=t.target.closest("button, input");e&&e.type==="submit"&&e.form&&f.set(e.form,e)}function y(t){m(t)}function g(t){t.target.tagName=="FORM"&&m(t)}function m(t){const e=t.target;if(e.hasAttribute(l)){t.preventDefault();return}const r=new DirectUploadsController(e);const{inputs:s}=r;if(s.length){t.preventDefault();e.setAttribute(l,"");s.forEach(v);r.start((t=>{e.removeAttribute(l);t?s.forEach(_):A(e)}))}}function A(t){let e=f.get(t)||n(t,"input[type=submit], button[type=submit]");if(e){const{disabled:t}=e;e.disabled=false;e.focus();e.click();e.disabled=t}else{e=document.createElement("input");e.type="submit";e.style.display="none";t.appendChild(e);e.click();t.removeChild(e)}f.delete(t)}function v(t){t.disabled=true}function _(t){t.disabled=false}function x(){window.ActiveStorage&&p()}setTimeout(x,1);export{DirectUpload,DirectUploadController,DirectUploadsController,o as dispatchEvent,p as start}; diff --git a/vendor/javascript/@rails--request.js.js b/vendor/javascript/@rails--request.js.js index 4c5dfd1..1aa2eae 100644 --- a/vendor/javascript/@rails--request.js.js +++ b/vendor/javascript/@rails--request.js.js @@ -1,4 +1,4 @@ -// @rails/request.js@0.0.12 downloaded from https://ga.jspm.io/npm:@rails/request.js@0.0.12/src/index.js +// @rails/request.js@0.0.13 downloaded from https://ga.jspm.io/npm:@rails/request.js@0.0.13/src/index.js -class FetchResponse{constructor(t){this.response=t}get statusCode(){return this.response.status}get redirected(){return this.response.redirected}get ok(){return this.response.ok}get unauthenticated(){return this.statusCode===401}get unprocessableEntity(){return this.statusCode===422}get authenticationURL(){return this.response.headers.get("WWW-Authenticate")}get contentType(){const t=this.response.headers.get("Content-Type")||"";return t.replace(/;.*$/,"")}get headers(){return this.response.headers}get html(){return this.contentType.match(/^(application|text)\/(html|xhtml\+xml)$/)?this.text:Promise.reject(new Error(`Expected an HTML response but got "${this.contentType}" instead`))}get json(){return this.contentType.match(/^application\/.*json$/)?this.responseJson||(this.responseJson=this.response.json()):Promise.reject(new Error(`Expected a JSON response but got "${this.contentType}" instead`))}get text(){return this.responseText||(this.responseText=this.response.text())}get isTurboStream(){return this.contentType.match(/^text\/vnd\.turbo-stream\.html/)}get isScript(){return this.contentType.match(/\b(?:java|ecma)script\b/)}async renderTurboStream(){if(!this.isTurboStream)return Promise.reject(new Error(`Expected a Turbo Stream response but got "${this.contentType}" instead`));window.Turbo?await window.Turbo.renderStreamMessage(await this.text):console.warn("You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js")}async activeScript(){if(!this.isScript)return Promise.reject(new Error(`Expected a Script response but got "${this.contentType}" instead`));{const t=document.createElement("script");const e=document.querySelector("meta[name=csp-nonce]");if(e){const n=e.nonce===""?e.content:e.nonce;n&&t.setAttribute("nonce",n)}t.innerHTML=await this.text;document.body.appendChild(t)}}}class RequestInterceptor{static register(t){this.interceptor=t}static get(){return this.interceptor}static reset(){this.interceptor=void 0}}function t(t){const e=document.cookie?document.cookie.split("; "):[];const n=`${encodeURIComponent(t)}=`;const s=e.find((t=>t.startsWith(n)));if(s){const t=s.split("=").slice(1).join("=");if(t)return decodeURIComponent(t)}}function e(t){const e={};for(const n in t){const s=t[n];s!==void 0&&(e[n]=s)}return e}function n(t){const e=document.head.querySelector(`meta[name="${t}"]`);return e&&e.content}function s(t){return[...t].reduce(((t,[e,n])=>t.concat(typeof n==="string"?[[e,n]]:[])),[])}function r(t,e){for(const[n,s]of e)if(!(s instanceof window.File))if(t.has(n)&&!n.includes("[]")){t.delete(n);t.set(n,s)}else t.append(n,s)}class FetchRequest{constructor(t,e,n={}){this.method=t;this.options=n;this.originalUrl=e.toString()}async perform(){try{const t=RequestInterceptor.get();t&&await t(this)}catch(t){console.error(t)}const t=this.responseKind==="turbo-stream"&&window.Turbo?window.Turbo.fetch:window.fetch;const e=new FetchResponse(await t(this.url,this.fetchOptions));if(e.unauthenticated&&e.authenticationURL)return Promise.reject(window.location.href=e.authenticationURL);e.isScript&&await e.activeScript();const n=e.ok||e.unprocessableEntity;n&&e.isTurboStream&&await e.renderTurboStream();return e}addHeader(t,e){const n=this.additionalHeaders;n[t]=e;this.options.headers=n}sameHostname(){if(!this.originalUrl.startsWith("http:")&&!this.originalUrl.startsWith("https:"))return true;try{return new URL(this.originalUrl).hostname===window.location.hostname}catch(t){return true}}get fetchOptions(){return{method:this.method.toUpperCase(),headers:this.headers,body:this.formattedBody,signal:this.signal,credentials:this.credentials,redirect:this.redirect,keepalive:this.keepalive}}get headers(){const t={"X-Requested-With":"XMLHttpRequest","Content-Type":this.contentType,Accept:this.accept};this.sameHostname()&&(t["X-CSRF-Token"]=this.csrfToken);return e(Object.assign(t,this.additionalHeaders))}get csrfToken(){return t(n("csrf-param"))||n("csrf-token")}get contentType(){return this.options.contentType?this.options.contentType:this.body==null||this.body instanceof window.FormData?void 0:this.body instanceof window.File?this.body.type:"application/json"}get accept(){switch(this.responseKind){case"html":return"text/html, application/xhtml+xml";case"turbo-stream":return"text/vnd.turbo-stream.html, text/html, application/xhtml+xml";case"json":return"application/json, application/vnd.api+json";case"script":return"text/javascript, application/javascript";default:return"*/*"}}get body(){return this.options.body}get query(){const t=(this.originalUrl.split("?")[1]||"").split("#")[0];const e=new URLSearchParams(t);let n=this.options.query;n=n instanceof window.FormData?s(n):n instanceof window.URLSearchParams?n.entries():Object.entries(n||{});r(e,n);const o=e.toString();return o.length>0?`?${o}`:""}get url(){return this.originalUrl.split("?")[0].split("#")[0]+this.query}get responseKind(){return this.options.responseKind||"html"}get signal(){return this.options.signal}get redirect(){return this.options.redirect||"follow"}get credentials(){return this.options.credentials||"same-origin"}get keepalive(){return this.options.keepalive||false}get additionalHeaders(){return this.options.headers||{}}get formattedBody(){const t=Object.prototype.toString.call(this.body)==="[object String]";const e=this.headers["Content-Type"]==="application/json";return e&&!t?JSON.stringify(this.body):this.body}}async function o(t,e){const n=new FetchRequest("get",t,e);return n.perform()}async function i(t,e){const n=new FetchRequest("post",t,e);return n.perform()}async function c(t,e){const n=new FetchRequest("put",t,e);return n.perform()}async function a(t,e){const n=new FetchRequest("patch",t,e);return n.perform()}async function h(t,e){const n=new FetchRequest("delete",t,e);return n.perform()}export{FetchRequest,FetchResponse,RequestInterceptor,h as destroy,o as get,a as patch,i as post,c as put}; +class FetchResponse{constructor(t){this.response=t}get statusCode(){return this.response.status}get redirected(){return this.response.redirected}get ok(){return this.response.ok}get unauthenticated(){return this.statusCode===401}get unprocessableEntity(){return this.statusCode===422}get authenticationURL(){return this.response.headers.get("WWW-Authenticate")}get contentType(){const t=this.response.headers.get("Content-Type")||"";return t.replace(/;.*$/,"")}get headers(){return this.response.headers}get html(){return this.contentType.match(/^(application|text)\/(html|xhtml\+xml)$/)?this.text:Promise.reject(new Error(`Expected an HTML response but got "${this.contentType}" instead`))}get json(){return this.contentType.match(/^application\/.*json$/)?this.responseJson||(this.responseJson=this.response.json()):Promise.reject(new Error(`Expected a JSON response but got "${this.contentType}" instead`))}get text(){return this.responseText||(this.responseText=this.response.text())}get isTurboStream(){return this.contentType.match(/^text\/vnd\.turbo-stream\.html/)}get isScript(){return this.contentType.match(/\b(?:java|ecma)script\b/)}async renderTurboStream(){if(!this.isTurboStream)return Promise.reject(new Error(`Expected a Turbo Stream response but got "${this.contentType}" instead`));window.Turbo?await window.Turbo.renderStreamMessage(await this.text):console.warn("You must set `window.Turbo = Turbo` to automatically process Turbo Stream events with request.js")}async activeScript(){if(!this.isScript)return Promise.reject(new Error(`Expected a Script response but got "${this.contentType}" instead`));{const t=document.createElement("script");const e=document.querySelector("meta[name=csp-nonce]");if(e){const n=e.nonce===""?e.content:e.nonce;n&&t.setAttribute("nonce",n)}t.innerHTML=await this.text;document.body.appendChild(t)}}}class RequestInterceptor{static register(t){this.interceptor=t}static get(){return this.interceptor}static reset(){this.interceptor=void 0}}function t(t){const e=document.cookie?document.cookie.split("; "):[];const n=`${encodeURIComponent(t)}=`;const s=e.find((t=>t.startsWith(n)));if(s){const t=s.split("=").slice(1).join("=");if(t)return decodeURIComponent(t)}}function e(t){const e={};for(const n in t){const s=t[n];s!==void 0&&(e[n]=s)}return e}function n(t){const e=document.head.querySelector(`meta[name="${t}"]`);return e&&e.content}function s(t){return[...t].reduce(((t,[e,n])=>t.concat(typeof n==="string"?[[e,n]]:[])),[])}function r(t,e){for(const[n,s]of e)if(!(s instanceof window.File))if(t.has(n)&&!n.includes("[]")){t.delete(n);t.set(n,s)}else t.append(n,s)}class FetchRequest{constructor(t,e,n={}){this.method=t;this.options=n;this.originalUrl=e.toString()}async perform(){try{const t=RequestInterceptor.get();t&&await t(this)}catch(t){console.error(t)}const t=window.Turbo?window.Turbo.fetch:window.fetch;const e=new FetchResponse(await t(this.url,this.fetchOptions));if(e.unauthenticated&&e.authenticationURL)return Promise.reject(window.location.href=e.authenticationURL);e.isScript&&await e.activeScript();const n=e.ok||e.unprocessableEntity;n&&e.isTurboStream&&await e.renderTurboStream();return e}addHeader(t,e){const n=this.additionalHeaders;n[t]=e;this.options.headers=n}sameHostname(){if(!this.originalUrl.startsWith("http:")&&!this.originalUrl.startsWith("https:"))return true;try{return new URL(this.originalUrl).hostname===window.location.hostname}catch(t){return true}}get fetchOptions(){return{method:this.method.toUpperCase(),headers:this.headers,body:this.formattedBody,signal:this.signal,credentials:this.credentials,redirect:this.redirect,keepalive:this.keepalive}}get headers(){const t={"X-Requested-With":"XMLHttpRequest","Content-Type":this.contentType,Accept:this.accept};this.sameHostname()&&(t["X-CSRF-Token"]=this.csrfToken);return e(Object.assign(t,this.additionalHeaders))}get csrfToken(){return t(n("csrf-param"))||n("csrf-token")}get contentType(){return this.options.contentType?this.options.contentType:this.body==null||this.body instanceof window.FormData?void 0:this.body instanceof window.File?this.body.type:"application/json"}get accept(){switch(this.responseKind){case"html":return"text/html, application/xhtml+xml";case"turbo-stream":return"text/vnd.turbo-stream.html, text/html, application/xhtml+xml";case"json":return"application/json, application/vnd.api+json";case"script":return"text/javascript, application/javascript";default:return"*/*"}}get body(){return this.options.body}get query(){const t=(this.originalUrl.split("?")[1]||"").split("#")[0];const e=new URLSearchParams(t);let n=this.options.query;n=n instanceof window.FormData?s(n):n instanceof window.URLSearchParams?n.entries():Object.entries(n||{});r(e,n);const o=e.toString();return o.length>0?`?${o}`:""}get url(){return this.originalUrl.split("?")[0].split("#")[0]+this.query}get responseKind(){return this.options.responseKind||"html"}get signal(){return this.options.signal}get redirect(){return this.options.redirect||"follow"}get credentials(){return this.options.credentials||"same-origin"}get keepalive(){return this.options.keepalive||false}get additionalHeaders(){return this.options.headers||{}}get formattedBody(){const t=Object.prototype.toString.call(this.body)==="[object String]";const e=this.headers["Content-Type"]==="application/json";return e&&!t?JSON.stringify(this.body):this.body}}async function o(t,e){const n=new FetchRequest("get",t,e);return n.perform()}async function i(t,e){const n=new FetchRequest("post",t,e);return n.perform()}async function c(t,e){const n=new FetchRequest("put",t,e);return n.perform()}async function a(t,e){const n=new FetchRequest("patch",t,e);return n.perform()}async function h(t,e){const n=new FetchRequest("delete",t,e);return n.perform()}export{FetchRequest,FetchResponse,RequestInterceptor,h as destroy,o as get,a as patch,i as post,c as put}; diff --git a/vendor/javascript/sortablejs.js b/vendor/javascript/sortablejs.js index 9e85945..0b0d451 100644 --- a/vendor/javascript/sortablejs.js +++ b/vendor/javascript/sortablejs.js @@ -1,12 +1,12 @@ -// sortablejs@1.15.6 downloaded from https://ga.jspm.io/npm:sortablejs@1.15.6/modular/sortable.esm.js +// sortablejs@1.15.7 downloaded from https://ga.jspm.io/npm:sortablejs@1.15.7/modular/sortable.esm.js /**! - * Sortable 1.15.6 + * Sortable 1.15.7 * @author RubaXa * @author owenm * @license MIT */ -function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})));n.push.apply(n,o)}return n}function _objectSpread2(e){for(var t=1;t=0||(n[r]=e[r])}return n}function _objectWithoutProperties(e,t){if(e==null)return{};var n=_objectWithoutPropertiesLoose(e,t);var o,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}}return n}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _iterableToArray(e){if(typeof Symbol!=="undefined"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if(typeof e==="string")return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);n==="Object"&&e.constructor&&(n=e.constructor.name);return n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}function _arrayLikeToArray(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n"&&(t=t.substring(1));if(e)try{if(e.matches)return e.matches(t);if(e.msMatchesSelector)return e.msMatchesSelector(t);if(e.webkitMatchesSelector)return e.webkitMatchesSelector(t)}catch(e){return false}return false}}function getParentOrHost(e){return e.host&&e!==document&&e.host.nodeType?e.host:e.parentNode}function closest(e,t,n,o){if(e){n=n||document;do{if(t!=null&&(t[0]===">"?e.parentNode===n&&matches(e,t):matches(e,t))||o&&e===n)return e;if(e===n)break}while(e=getParentOrHost(e))}return null}var s=/\s+/g;function toggleClass(e,t,n){if(e&&t)if(e.classList)e.classList[n?"add":"remove"](t);else{var o=(" "+e.className+" ").replace(s," ").replace(" "+t+" "," ");e.className=(o+(n?" "+t:"")).replace(s," ")}}function css(e,t,n){var o=e&&e.style;if(o){if(n===void 0){document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(e,""):e.currentStyle&&(n=e.currentStyle);return t===void 0?n:n[t]}t in o||t.indexOf("webkit")!==-1||(t="-webkit-"+t);o[t]=n+(typeof n==="string"?"":"px")}}function matrix(e,t){var n="";if(typeof e==="string")n=e;else do{var o=css(e,"transform");o&&o!=="none"&&(n=o+" "+n)}while(!t&&(e=e.parentNode));var r=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return r&&new r(n)}function find(e,t,n){if(e){var o=e.getElementsByTagName(t),r=0,i=o.length;if(n)for(;rt.length)&&(e=t.length);for(var n=0,o=Array(e);n"&&(e=e.substring(1));if(t)try{if(t.matches)return t.matches(e);if(t.msMatchesSelector)return t.msMatchesSelector(e);if(t.webkitMatchesSelector)return t.webkitMatchesSelector(e)}catch(t){return false}return false}}function x(t){return t.host&&t!==document&&t.host.nodeType&&t.host!==t?t.host:t.parentNode}function M(t,e,n,o){if(t){n=n||document;do{if(e!=null&&(e[0]===">"?t.parentNode===n&&T(t,e):T(t,e))||o&&t===n)return t;if(t===n)break}while(t=x(t))}return null}var O=/\s+/g;function A(t,e,n){if(t&&e)if(t.classList)t.classList[n?"add":"remove"](e);else{var o=(" "+t.className+" ").replace(O," ").replace(" "+e+" "," ");t.className=(o+(n?" "+e:"")).replace(O," ")}}function N(t,e,n){var o=t&&t.style;if(o){if(n===void 0){document.defaultView&&document.defaultView.getComputedStyle?n=document.defaultView.getComputedStyle(t,""):t.currentStyle&&(n=t.currentStyle);return e===void 0?n:n[e]}e in o||e.indexOf("webkit")!==-1||(e="-webkit-"+e);o[e]=n+(typeof n==="string"?"":"px")}}function I(t,e){var n="";if(typeof t==="string")n=t;else do{var o=N(t,"transform");o&&o!=="none"&&(n=o+" "+n)}while(!e&&(t=t.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(n)}function P(t,e,n){if(t){var o=t.getElementsByTagName(e),i=0,r=o.length;if(n)for(;i=i:r<=i;if(!a)return o;if(o===getWindowScrollingElement())break;o=getParentAutoScrollElement(o,false)}return false} + */function X(t,e,n){var o=L(t,true),i=R(t)[e];while(o){var r=R(o)[n],a=void 0;a=n==="top"||n==="left"?i>=r:i<=r;if(!a)return o;if(o===k())break;o=L(o,false)}return false} /** * Gets nth child of el, ignoring hidden children, sortable's elements (does not ignore clone if it's visible) * and non-draggable elements @@ -30,107 +30,107 @@ function ownKeys(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var * @param {Number} childNum The index of the child * @param {Object} options Parent Sortable's options * @return {HTMLElement} The child at index childNum, or null if not found - */function getChild(e,t,n,o){var r=0,i=0,a=e.children;while(i2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,r=_objectWithoutProperties(n,g);h.pluginEvent.bind(Sortable)(e,t,_objectSpread2({dragEl:v,parentEl:m,ghostEl:b,rootEl:S,nextEl:_,lastDownEl:y,cloneEl:E,cloneHidden:w,dragStarted:j,putSortable:O,activeSortable:Sortable.active,originalEvent:o,oldIndex:D,oldDraggableIndex:x,newIndex:C,newDraggableIndex:A,hideGhostForTarget:re,unhideGhostForTarget:ie,cloneNowHidden:function cloneNowHidden(){w=true},cloneNowShown:function cloneNowShown(){w=false},dispatchSortableEvent:function dispatchSortableEvent(e){_dispatchEvent({sortable:t,name:e,originalEvent:o})}},r))};function _dispatchEvent(e){dispatchEvent(_objectSpread2({putSortable:O,cloneEl:E,targetEl:v,rootEl:S,oldIndex:D,oldDraggableIndex:x,newIndex:C,newDraggableIndex:A},e))}var v,m,b,S,_,y,E,w,D,C,x,A,T,O,M,I,P,R,N,k,j,F,X,Y,B,W=false,H=false,L=[],K=false,G=false,z=[],U=false,q=[];var V=typeof document!=="undefined",$=i,Z=n||t?"cssFloat":"float",Q=V&&!a&&!i&&"draggable"in document.createElement("div"),J=function(){if(V){if(t)return false;var e=document.createElement("x");e.style.cssText="pointer-events:auto";return e.style.pointerEvents==="auto"}}(),ee=function _detectDirection(e,t){var n=css(e),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),r=getChild(e,0,t),i=getChild(e,1,t),a=r&&css(r),l=i&&css(i),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+getRect(r).width,c=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+getRect(i).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(r&&a.float&&a.float!=="none"){var u=a.float==="left"?"left":"right";return!i||l.clear!=="both"&&l.clear!==u?"horizontal":"vertical"}return r&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||s>=o&&n[Z]==="none"||i&&n[Z]==="none"&&s+c>o)?"vertical":"horizontal"},te=function _dragElInRowColumn(e,t,n){var o=n?e.left:e.top,r=n?e.right:e.bottom,i=n?e.width:e.height,a=n?t.left:t.top,l=n?t.right:t.bottom,s=n?t.width:t.height;return o===a||r===l||o+i/2===a+s/2}, + */function j(t,e){for(var n in t)if(t.hasOwnProperty(n))for(var o in e)if(e.hasOwnProperty(o)&&e[o]===t[n][o])return Number(n);return-1}function L(t,e){if(!t||!t.getBoundingClientRect)return k();var n=t;var o=false;do{if(n.clientWidth2&&arguments[2]!==void 0?arguments[2]:{},o=n.evt,i=s(n,lt);rt.pluginEvent.bind(ne)(t,e,l({dragEl:ct,parentEl:ft,ghostEl:dt,rootEl:ht,nextEl:pt,lastDownEl:gt,cloneEl:vt,cloneHidden:mt,dragStarted:At,putSortable:St,activeSortable:ne.active,originalEvent:o,oldIndex:bt,oldDraggableIndex:wt,newIndex:yt,newDraggableIndex:Dt,hideGhostForTarget:Qt,unhideGhostForTarget:Jt,cloneNowHidden:function(){mt=true},cloneNowShown:function(){mt=false},dispatchSortableEvent:function(t){ut({sortable:e,name:t,originalEvent:o})}},i))};function ut(t){at(l({putSortable:St,cloneEl:vt,targetEl:ct,rootEl:ht,oldIndex:bt,oldDraggableIndex:wt,newIndex:yt,newDraggableIndex:Dt},t))}var ct,ft,dt,ht,pt,gt,vt,mt,bt,yt,wt,Dt,Et,St,_t,Ct,Tt,xt,Mt,Ot,At,Nt,It,Pt,kt,Rt=false,Xt=false,Yt=[],Bt=false,Ft=false,Ht=[],jt=false,Lt=[];var Kt=typeof document!=="undefined",Wt=D,zt=b||m?"cssFloat":"float",Gt=Kt&&!E&&!D&&"draggable"in document.createElement("div"),Ut=function(){if(Kt){if(m)return false;var t=document.createElement("x");t.style.cssText="pointer-events:auto";return t.style.pointerEvents==="auto"}}(),qt=function(t,e){var n=N(t),o=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),i=Y(t,0,e),r=Y(t,1,e),a=i&&N(i),l=r&&N(r),s=a&&parseInt(a.marginLeft)+parseInt(a.marginRight)+R(i).width,u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+R(r).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(i&&a.float&&a.float!=="none"){var c=a.float==="left"?"left":"right";return!r||l.clear!=="both"&&l.clear!==c?"horizontal":"vertical"}return i&&(a.display==="block"||a.display==="flex"||a.display==="table"||a.display==="grid"||s>=o&&n[zt]==="none"||r&&n[zt]==="none"&&s+u>o)?"vertical":"horizontal"},Vt=function(t,e,n){var o=n?t.left:t.top,i=n?t.right:t.bottom,r=n?t.width:t.height,a=n?e.left:e.top,l=n?e.right:e.bottom,s=n?e.width:e.height;return o===a||i===l||o+r/2===a+s/2}, /** * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold. * @param {Number} x X position * @param {Number} y Y position * @return {HTMLElement} Element of the first found nearest Sortable */ -ne=function _detectNearestEmptySortable(e,t){var n;L.some((function(o){var r=o[u].options.emptyInsertThreshold;if(r&&!lastChild(o)){var i=getRect(o),a=e>=i.left-r&&e<=i.right+r,l=t>=i.top-r&&t<=i.bottom+r;return a&&l?n=o:void 0}}));return n},oe=function _prepareGroup(e){function toFn(e,t){return function(n,o,r,i){var a=n.options.group.name&&o.options.group.name&&n.options.group.name===o.options.group.name;if(e==null&&(t||a))return true;if(e==null||e===false)return false;if(t&&e==="clone")return e;if(typeof e==="function")return toFn(e(n,o,r,i),t)(n,o,r,i);var l=(t?n:o).options.group.name;return e===true||typeof e==="string"&&e===l||e.join&&e.indexOf(l)>-1}}var t={};var n=e.group;n&&_typeof(n)=="object"||(n={name:n});t.name=n.name;t.checkPull=toFn(n.pull,true);t.checkPut=toFn(n.put);t.revertClone=n.revertClone;e.group=t},re=function _hideGhostForTarget(){!J&&b&&css(b,"display","none")},ie=function _unhideGhostForTarget(){!J&&b&&css(b,"display","")};V&&!a&&document.addEventListener("click",(function(e){if(H){e.preventDefault();e.stopPropagation&&e.stopPropagation();e.stopImmediatePropagation&&e.stopImmediatePropagation();H=false;return false}}),true);var ae=function nearestEmptyInsertDetectEvent(e){if(v){e=e.touches?e.touches[0]:e;var t=ne(e.clientX,e.clientY);if(t){var n={};for(var o in e)e.hasOwnProperty(o)&&(n[o]=e[o]);n.target=n.rootEl=t;n.preventDefault=void 0;n.stopPropagation=void 0;t[u]._onDragOver(n)}}};var le=function _checkOutsideTargetEl(e){v&&v.parentNode[u]._isOutsideThisEl(e.target)}; +Zt=function(t,e){var n;Yt.some((function(o){var i=o[J].options.emptyInsertThreshold;if(i&&!B(o)){var r=R(o),a=t>=r.left-i&&t<=r.right+i,l=e>=r.top-i&&e<=r.bottom+i;return a&&l?n=o:void 0}}));return n},$t=function(t){function e(t,n){return function(o,i,r,a){var l=o.options.group.name&&i.options.group.name&&o.options.group.name===i.options.group.name;if(t==null&&(n||l))return true;if(t==null||t===false)return false;if(n&&t==="clone")return t;if(typeof t==="function")return e(t(o,i,r,a),n)(o,i,r,a);var s=(n?o:i).options.group.name;return t===true||typeof t==="string"&&t===s||t.join&&t.indexOf(s)>-1}}var n={};var o=t.group;o&&h(o)=="object"||(o={name:o});n.name=o.name;n.checkPull=e(o.pull,true);n.checkPut=e(o.put);n.revertClone=o.revertClone;t.group=n},Qt=function(){!Ut&&dt&&N(dt,"display","none")},Jt=function(){!Ut&&dt&&N(dt,"display","")};Kt&&!E&&document.addEventListener("click",(function(t){if(Xt){t.preventDefault();t.stopPropagation&&t.stopPropagation();t.stopImmediatePropagation&&t.stopImmediatePropagation();Xt=false;return false}}),true);var te=function(t){if(ct){t=t.touches?t.touches[0]:t;var e=Zt(t.clientX,t.clientY);if(e){var n={};for(var o in t)t.hasOwnProperty(o)&&(n[o]=t[o]);n.target=n.rootEl=e;n.preventDefault=void 0;n.stopPropagation=void 0;e[J]._onDragOver(n)}}};var ee=function(t){ct&&ct.parentNode[J]._isOutsideThisEl(t.target)}; /** * @class Sortable * @param {HTMLElement} el * @param {Object} [options] - */function Sortable(e,t){if(!(e&&e.nodeType&&e.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));this.el=e;this.options=t=_extends({},t);e[u]=this;var n={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(e.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function direction(){return ee(e,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function setData(e,t){e.setData("Text",t.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:Sortable.supportPointer!==false&&"PointerEvent"in window&&(!r||i),emptyInsertThreshold:5};h.initializePlugins(this,e,n);for(var o in n)!(o in t)&&(t[o]=n[o]);oe(t);for(var a in this)a.charAt(0)==="_"&&typeof this[a]==="function"&&(this[a]=this[a].bind(this));this.nativeDraggable=!t.forceFallback&&Q;this.nativeDraggable&&(this.options.touchStartThreshold=1);if(t.supportPointer)on(e,"pointerdown",this._onTapStart);else{on(e,"mousedown",this._onTapStart);on(e,"touchstart",this._onTapStart)}if(this.nativeDraggable){on(e,"dragover",this);on(e,"dragenter",this)}L.push(this.el);t.store&&t.store.get&&this.sort(t.store.get(this)||[]);_extends(this,AnimationStateManager())}Sortable.prototype={constructor:Sortable,_isOutsideThisEl:function _isOutsideThisEl(e){this.el.contains(e)||e===this.el||(F=null)},_getDirection:function _getDirection(e,t){return typeof this.options.direction==="function"?this.options.direction.call(this,e,t,v):this.options.direction},_onTapStart:function _onTapStart(e){if(e.cancelable){var t=this,n=this.el,o=this.options,i=o.preventOnFilter,a=e.type,l=e.touches&&e.touches[0]||e.pointerType&&e.pointerType==="touch"&&e,s=(l||e).target,c=e.target.shadowRoot&&(e.path&&e.path[0]||e.composedPath&&e.composedPath()[0])||s,u=o.filter;_saveInputCheckedState(n);if(!v&&!(/mousedown|pointerdown/.test(a)&&e.button!==0||o.disabled)&&!c.isContentEditable&&(this.nativeDraggable||!r||!s||s.tagName.toUpperCase()!=="SELECT")){s=closest(s,o.draggable,n,false);if((!s||!s.animated)&&y!==s){D=index(s);x=index(s,o.draggable);if(typeof u==="function"){if(u.call(this,e,s,this)){_dispatchEvent({sortable:t,rootEl:c,name:"filter",targetEl:s,toEl:n,fromEl:n});p("filter",t,{evt:e});i&&e.preventDefault();return}}else if(u){u=u.split(",").some((function(o){o=closest(c,o.trim(),n,false);if(o){_dispatchEvent({sortable:t,rootEl:o,name:"filter",targetEl:s,fromEl:n,toEl:n});p("filter",t,{evt:e});return true}}));if(u){i&&e.preventDefault();return}}o.handle&&!closest(c,o.handle,n,false)||this._prepareDragStart(e,l,s)}}}},_prepareDragStart:function _prepareDragStart(e,r,i){var a,l=this,s=l.el,c=l.options,u=s.ownerDocument;if(i&&!v&&i.parentNode===s){var d=getRect(i);S=s;v=i;m=v.parentNode;_=v.nextSibling;y=i;T=c.group;Sortable.dragged=v;M={target:v,clientX:(r||e).clientX,clientY:(r||e).clientY};N=M.clientX-d.left;k=M.clientY-d.top;this._lastX=(r||e).clientX;this._lastY=(r||e).clientY;v.style["will-change"]="all";a=function dragStartFn(){p("delayEnded",l,{evt:e});if(Sortable.eventCanceled)l._onDrop();else{l._disableDelayedDragEvents();!o&&l.nativeDraggable&&(v.draggable=true);l._triggerDragStart(e,r);_dispatchEvent({sortable:l,name:"choose",originalEvent:e});toggleClass(v,c.chosenClass,true)}};c.ignore.split(",").forEach((function(e){find(v,e.trim(),_disableDraggable)}));on(u,"dragover",ae);on(u,"mousemove",ae);on(u,"touchmove",ae);if(c.supportPointer){on(u,"pointerup",l._onDrop);!this.nativeDraggable&&on(u,"pointercancel",l._onDrop)}else{on(u,"mouseup",l._onDrop);on(u,"touchend",l._onDrop);on(u,"touchcancel",l._onDrop)}if(o&&this.nativeDraggable){this.options.touchStartThreshold=4;v.draggable=true}p("delayStart",this,{evt:e});if(!c.delay||c.delayOnTouchOnly&&!r||this.nativeDraggable&&(n||t))a();else{if(Sortable.eventCanceled){this._onDrop();return}if(c.supportPointer){on(u,"pointerup",l._disableDelayedDrag);on(u,"pointercancel",l._disableDelayedDrag)}else{on(u,"mouseup",l._disableDelayedDrag);on(u,"touchend",l._disableDelayedDrag);on(u,"touchcancel",l._disableDelayedDrag)}on(u,"mousemove",l._delayedDragTouchMoveHandler);on(u,"touchmove",l._delayedDragTouchMoveHandler);c.supportPointer&&on(u,"pointermove",l._delayedDragTouchMoveHandler);l._dragStartTimer=setTimeout(a,c.delay)}}},_delayedDragTouchMoveHandler:function _delayedDragTouchMoveHandler(e){var t=e.touches?e.touches[0]:e;Math.max(Math.abs(t.clientX-this._lastX),Math.abs(t.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function _disableDelayedDrag(){v&&_disableDraggable(v);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function _disableDelayedDragEvents(){var e=this.el.ownerDocument;off(e,"mouseup",this._disableDelayedDrag);off(e,"touchend",this._disableDelayedDrag);off(e,"touchcancel",this._disableDelayedDrag);off(e,"pointerup",this._disableDelayedDrag);off(e,"pointercancel",this._disableDelayedDrag);off(e,"mousemove",this._delayedDragTouchMoveHandler);off(e,"touchmove",this._delayedDragTouchMoveHandler);off(e,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function _triggerDragStart(e,t){t=t||e.pointerType=="touch"&&e;if(!this.nativeDraggable||t)this.options.supportPointer?on(document,"pointermove",this._onTouchMove):on(document,t?"touchmove":"mousemove",this._onTouchMove);else{on(v,"dragend",this);on(S,"dragstart",this._onDragStart)}try{document.selection?_nextTick((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(e){}},_dragStarted:function _dragStarted(e,t){W=false;if(S&&v){p("dragStarted",this,{evt:t});this.nativeDraggable&&on(document,"dragover",le);var n=this.options;!e&&toggleClass(v,n.dragClass,false);toggleClass(v,n.ghostClass,true);Sortable.active=this;e&&this._appendGhost();_dispatchEvent({sortable:this,name:"start",originalEvent:t})}else this._nulling()},_emulateDragOver:function _emulateDragOver(){if(I){this._lastX=I.clientX;this._lastY=I.clientY;re();var e=document.elementFromPoint(I.clientX,I.clientY);var t=e;while(e&&e.shadowRoot){e=e.shadowRoot.elementFromPoint(I.clientX,I.clientY);if(e===t)break;t=e}v.parentNode[u]._isOutsideThisEl(e);if(t)do{if(t[u]){var n=void 0;n=t[u]._onDragOver({clientX:I.clientX,clientY:I.clientY,target:e,rootEl:t});if(n&&!this.options.dragoverBubble)break}e=t}while(t=getParentOrHost(t));ie()}},_onTouchMove:function _onTouchMove(e){if(M){var t=this.options,n=t.fallbackTolerance,o=t.fallbackOffset,r=e.touches?e.touches[0]:e,i=b&&matrix(b,true),a=b&&i&&i.a,l=b&&i&&i.d,s=$&&B&&getRelativeScrollOffset(B),c=(r.clientX-M.clientX+o.x)/(a||1)+(s?s[0]-z[0]:0)/(a||1),u=(r.clientY-M.clientY+o.y)/(l||1)+(s?s[1]-z[1]:0)/(l||1);if(!Sortable.active&&!W){if(n&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))=0){_dispatchEvent({rootEl:m,name:"add",toEl:m,fromEl:S,originalEvent:e});_dispatchEvent({sortable:this,name:"remove",toEl:m,originalEvent:e});_dispatchEvent({rootEl:m,name:"sort",toEl:m,fromEl:S,originalEvent:e});_dispatchEvent({sortable:this,name:"sort",toEl:m,originalEvent:e})}O&&O.save()}else if(C!==D&&C>=0){_dispatchEvent({sortable:this,name:"update",toEl:m,originalEvent:e});_dispatchEvent({sortable:this,name:"sort",toEl:m,originalEvent:e})}if(Sortable.active){if(C==null||C===-1){C=D;A=x}_dispatchEvent({sortable:this,name:"end",toEl:m,originalEvent:e});this.save()}}}this._nulling()}},_nulling:function _nulling(){p("nulling",this);S=v=m=b=_=E=y=w=M=I=j=C=A=D=x=F=X=O=T=Sortable.dragged=Sortable.ghost=Sortable.clone=Sortable.active=null;q.forEach((function(e){e.checked=true}));q.length=P=R=0},handleEvent:function handleEvent(e){switch(e.type){case"drop":case"dragend":this._onDrop(e);break;case"dragenter":case"dragover":if(v){this._onDragOver(e);_globalDragOver(e)}break;case"selectstart":e.preventDefault();break}}, + */function ne(t,e){if(!(t&&t.nodeType&&t.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(t));this.el=t;this.options=e=o({},e);t[J]=this;var n={group:null,sort:true,disabled:false,store:null,handle:null,draggable:/^[uo]l$/i.test(t.nodeName)?">li":">*",swapThreshold:1,invertSwap:false,invertedSwapThreshold:null,removeCloneOnHide:true,direction:function(){return qt(t,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:true,animation:0,easing:null,setData:function(t,e){t.setData("Text",e.textContent)},dropBubble:false,dragoverBubble:false,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:false,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:false,fallbackClass:"sortable-fallback",fallbackOnBody:false,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:ne.supportPointer!==false&&"PointerEvent"in window&&(!w||D),emptyInsertThreshold:5};rt.initializePlugins(this,t,n);for(var i in n)!(i in e)&&(e[i]=n[i]);$t(e);for(var r in this)r.charAt(0)==="_"&&typeof this[r]==="function"&&(this[r]=this[r].bind(this));this.nativeDraggable=!e.forceFallback&≫this.nativeDraggable&&(this.options.touchStartThreshold=1);if(e.supportPointer)_(t,"pointerdown",this._onTapStart);else{_(t,"mousedown",this._onTapStart);_(t,"touchstart",this._onTapStart)}if(this.nativeDraggable){_(t,"dragover",this);_(t,"dragenter",this)}Yt.push(this.el);e.store&&e.store.get&&this.sort(e.store.get(this)||[]);o(this,tt())}ne.prototype={constructor:ne,_isOutsideThisEl:function(t){this.el.contains(t)||t===this.el||(Nt=null)},_getDirection:function(t,e){return typeof this.options.direction==="function"?this.options.direction.call(this,t,e,ct):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,o=this.options,i=o.preventOnFilter,r=t.type,a=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,l=(a||t).target,s=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||l,u=o.filter;de(n);if(!ct&&!(/mousedown|pointerdown/.test(r)&&t.button!==0||o.disabled)&&!s.isContentEditable&&(this.nativeDraggable||!w||!l||l.tagName.toUpperCase()!=="SELECT")){l=M(l,o.draggable,n,false);if((!l||!l.animated)&>!==l){bt=F(l);wt=F(l,o.draggable);if(typeof u==="function"){if(u.call(this,t,l,this)){ut({sortable:e,rootEl:s,name:"filter",targetEl:l,toEl:n,fromEl:n});st("filter",e,{evt:t});i&&t.preventDefault();return}}else if(u){u=u.split(",").some((function(o){o=M(s,o.trim(),n,false);if(o){ut({sortable:e,rootEl:o,name:"filter",targetEl:l,fromEl:n,toEl:n});st("filter",e,{evt:t});return true}}));if(u){i&&t.preventDefault();return}}o.handle&&!M(s,o.handle,n,false)||this._prepareDragStart(t,a,l)}}}},_prepareDragStart:function(t,e,n){var o,i=this,r=i.el,a=i.options,l=r.ownerDocument;if(n&&!ct&&n.parentNode===r){var s=R(n);ht=r;ct=n;ft=ct.parentNode;pt=ct.nextSibling;gt=n;Et=a.group;ne.dragged=ct;_t={target:ct,clientX:(e||t).clientX,clientY:(e||t).clientY};Mt=_t.clientX-s.left;Ot=_t.clientY-s.top;this._lastX=(e||t).clientX;this._lastY=(e||t).clientY;ct.style["will-change"]="all";o=function(){st("delayEnded",i,{evt:t});if(ne.eventCanceled)i._onDrop();else{i._disableDelayedDragEvents();!y&&i.nativeDraggable&&(ct.draggable=true);i._triggerDragStart(t,e);ut({sortable:i,name:"choose",originalEvent:t});A(ct,a.chosenClass,true)}};a.ignore.split(",").forEach((function(t){P(ct,t.trim(),re)}));_(l,"dragover",te);_(l,"mousemove",te);_(l,"touchmove",te);if(a.supportPointer){_(l,"pointerup",i._onDrop);!this.nativeDraggable&&_(l,"pointercancel",i._onDrop)}else{_(l,"mouseup",i._onDrop);_(l,"touchend",i._onDrop);_(l,"touchcancel",i._onDrop)}if(y&&this.nativeDraggable){this.options.touchStartThreshold=4;ct.draggable=true}st("delayStart",this,{evt:t});if(!a.delay||a.delayOnTouchOnly&&!e||this.nativeDraggable&&(b||m))o();else{if(ne.eventCanceled){this._onDrop();return}if(a.supportPointer){_(l,"pointerup",i._disableDelayedDrag);_(l,"pointercancel",i._disableDelayedDrag)}else{_(l,"mouseup",i._disableDelayedDrag);_(l,"touchend",i._disableDelayedDrag);_(l,"touchcancel",i._disableDelayedDrag)}_(l,"mousemove",i._delayedDragTouchMoveHandler);_(l,"touchmove",i._delayedDragTouchMoveHandler);a.supportPointer&&_(l,"pointermove",i._delayedDragTouchMoveHandler);i._dragStartTimer=setTimeout(o,a.delay)}}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){ct&&re(ct);clearTimeout(this._dragStartTimer);this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;C(t,"mouseup",this._disableDelayedDrag);C(t,"touchend",this._disableDelayedDrag);C(t,"touchcancel",this._disableDelayedDrag);C(t,"pointerup",this._disableDelayedDrag);C(t,"pointercancel",this._disableDelayedDrag);C(t,"mousemove",this._delayedDragTouchMoveHandler);C(t,"touchmove",this._delayedDragTouchMoveHandler);C(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t;if(!this.nativeDraggable||e)this.options.supportPointer?_(document,"pointermove",this._onTouchMove):_(document,e?"touchmove":"mousemove",this._onTouchMove);else{_(ct,"dragend",this);_(ht,"dragstart",this._onDragStart)}try{document.selection?he((function(){document.selection.empty()})):window.getSelection().removeAllRanges()}catch(t){}},_dragStarted:function(t,e){Rt=false;if(ht&&ct){st("dragStarted",this,{evt:e});this.nativeDraggable&&_(document,"dragover",ee);var n=this.options;!t&&A(ct,n.dragClass,false);A(ct,n.ghostClass,true);ne.active=this;t&&this._appendGhost();ut({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(Ct){this._lastX=Ct.clientX;this._lastY=Ct.clientY;Qt();var t=document.elementFromPoint(Ct.clientX,Ct.clientY);var e=t;while(t&&t.shadowRoot){t=t.shadowRoot.elementFromPoint(Ct.clientX,Ct.clientY);if(t===e)break;e=t}ct.parentNode[J]._isOutsideThisEl(t);if(e)do{if(e[J]){var n=void 0;n=e[J]._onDragOver({clientX:Ct.clientX,clientY:Ct.clientY,target:t,rootEl:e});if(n&&!this.options.dragoverBubble)break}t=e}while(e=x(e));Jt()}},_onTouchMove:function(t){if(_t){var e=this.options,n=e.fallbackTolerance,o=e.fallbackOffset,i=t.touches?t.touches[0]:t,r=dt&&I(dt,true),a=dt&&r&&r.a,l=dt&&r&&r.d,s=Wt&&kt&&H(kt),u=(i.clientX-_t.clientX+o.x)/(a||1)+(s?s[0]-Ht[0]:0)/(a||1),c=(i.clientY-_t.clientY+o.y)/(l||1)+(s?s[1]-Ht[1]:0)/(l||1);if(!ne.active&&!Rt){if(n&&Math.max(Math.abs(i.clientX-this._lastX),Math.abs(i.clientY-this._lastY))=0){ut({rootEl:ft,name:"add",toEl:ft,fromEl:ht,originalEvent:t});ut({sortable:this,name:"remove",toEl:ft,originalEvent:t});ut({rootEl:ft,name:"sort",toEl:ft,fromEl:ht,originalEvent:t});ut({sortable:this,name:"sort",toEl:ft,originalEvent:t})}St&&St.save()}else if(yt!==bt&&yt>=0){ut({sortable:this,name:"update",toEl:ft,originalEvent:t});ut({sortable:this,name:"sort",toEl:ft,originalEvent:t})}if(ne.active){if(yt==null||yt===-1){yt=bt;Dt=wt}ut({sortable:this,name:"end",toEl:ft,originalEvent:t});this.save()}}}this._nulling()}},_nulling:function(){st("nulling",this);ht=ct=ft=dt=pt=vt=gt=mt=_t=Ct=At=yt=Dt=bt=wt=Nt=It=St=Et=ne.dragged=ne.ghost=ne.clone=ne.active=null;var t=this.el;Lt.forEach((function(e){t.contains(e)&&(e.checked=true)}));Lt.length=Tt=xt=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":if(ct){this._onDragOver(t);oe(t)}break;case"selectstart":t.preventDefault();break}}, /** * Serializes the item into an array of string. * @returns {String[]} */ -toArray:function toArray(){var e,t=[],n=this.el.children,o=0,r=n.length,i=this.options;for(;or.right+i||e.clientY>o.bottom&&e.clientX>o.left:e.clientY>r.bottom+i||e.clientX>o.right&&e.clientY>o.top}function _getSwapDirection(e,t,n,o,r,i,a,l){var s=o?e.clientY:e.clientX,c=o?n.height:n.width,u=o?n.top:n.left,d=o?n.bottom:n.right,f=false;if(!a)if(l&&Yu+c*i/2:sd-Y)return-X}else if(s>u+c*(1-r)/2&&sd-c*i/2)?s>u+c/2?1:-1:0} +option:function(t,e){var n=this.options;if(e===void 0)return n[t];var o=rt.modifyOption(this,t,e);n[t]=typeof o!=="undefined"?o:e;t==="group"&&$t(n)},destroy:function(){st("destroy",this);var t=this.el;t[J]=null;C(t,"mousedown",this._onTapStart);C(t,"touchstart",this._onTapStart);C(t,"pointerdown",this._onTapStart);if(this.nativeDraggable){C(t,"dragover",this);C(t,"dragenter",this)}Array.prototype.forEach.call(t.querySelectorAll("[draggable]"),(function(t){t.removeAttribute("draggable")}));this._onDrop();this._disableDelayedDragEvents();Yt.splice(Yt.indexOf(this.el),1);this.el=t=null},_hideClone:function(){if(!mt){st("hideClone",this);if(ne.eventCanceled)return;N(vt,"display","none");this.options.removeCloneOnHide&&vt.parentNode&&vt.parentNode.removeChild(vt);mt=true}},_showClone:function(t){if(t.lastPutMode==="clone"){if(mt){st("showClone",this);if(ne.eventCanceled)return;ct.parentNode!=ht||this.options.group.revertClone?pt?ht.insertBefore(vt,pt):ht.appendChild(vt):ht.insertBefore(vt,ct);this.options.group.revertClone&&this.animate(ct,vt);N(vt,"display","");mt=false}}else this._hideClone()}};function oe(t){t.dataTransfer&&(t.dataTransfer.dropEffect="move");t.cancelable&&t.preventDefault()}function ie(t,e,n,o,i,r,a,l){var s,u,c=t[J],f=c.options.onMove;if(!window.CustomEvent||m||b){s=document.createEvent("Event");s.initEvent("move",true,true)}else s=new CustomEvent("move",{bubbles:true,cancelable:true});s.to=e;s.from=t;s.dragged=n;s.draggedRect=o;s.related=i||e;s.relatedRect=r||R(e);s.willInsertAfter=l;s.originalEvent=a;t.dispatchEvent(s);f&&(u=f.call(c,s,a));return u}function re(t){t.draggable=false}function ae(){jt=false}function le(t,e,n){var o=R(Y(n.el,0,n.options,true));var i=Q(n.el,n.options,dt);var r=10;return e?t.clientXi.right+r||t.clientY>o.bottom&&t.clientX>o.left:t.clientY>i.bottom+r||t.clientX>o.right&&t.clientY>o.top}function ue(t,e,n,o,i,r,a,l){var s=o?t.clientY:t.clientX,u=o?n.height:n.width,c=o?n.top:n.left,f=o?n.bottom:n.right,d=false;if(!a)if(l&&Ptc+u*r/2:sf-Pt)return-It}else if(s>c+u*(1-i)/2&&sf-u*r/2)?s>c+u/2?1:-1:0} /** * Gets the direction dragEl must be swapped relative to target in order to make it * seem that dragEl has been "inserted" into that element's position * @param {HTMLElement} target The target whose position dragEl is being inserted at * @return {Number} Direction dragEl must be swapped - */function _getInsertDirection(e){return index(v)1){De.forEach((function(e){o.addAnimationState({target:e,rect:Ae?getRect(e):r});unsetRect(e);e.fromRect=r;t.removeAnimationState(e)}));Ae=false;insertMultiDragElements(!this.options.removeCloneOnHide,n)}},dragOverCompleted:function dragOverCompleted(e){var t=e.sortable,n=e.isOwner,o=e.insertion,r=e.activeSortable,i=e.parentEl,a=e.putSortable;var l=this.options;if(o){n&&r._hideClone();xe=false;if(l.animation&&De.length>1&&(Ae||!n&&!r.options.sort&&!a)){var s=getRect(ye,false,true,true);De.forEach((function(e){if(e!==ye){setRect(e,s);i.appendChild(e)}}));Ae=true}if(!n){Ae||removeMultiDragElements();if(De.length>1){var c=we;r._showClone(t);r.options.animation&&!we&&c&&Ce.forEach((function(e){r.addAnimationState({target:e,rect:Ee});e.fromRect=Ee;e.thisAnimationDuration=null}))}else r._showClone(t)}}},dragOverAnimationCapture:function dragOverAnimationCapture(e){var t=e.dragRect,n=e.isOwner,o=e.activeSortable;De.forEach((function(e){e.thisAnimationDuration=null}));if(o.options.animation&&!n&&o.multiDrag.isMultiDrag){Ee=_extends({},t);var r=matrix(ye,true);Ee.top-=r.f;Ee.left-=r.e}},dragOverAnimationComplete:function dragOverAnimationComplete(){if(Ae){Ae=false;removeMultiDragElements()}},drop:function drop(e){var t=e.originalEvent,n=e.rootEl,o=e.parentEl,r=e.sortable,i=e.dispatchSortableEvent,a=e.oldIndex,l=e.putSortable;var s=l||this.sortable;if(t){var c=this.options,d=o.children;if(!Te){c.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag();toggleClass(ye,c.selectedClass,!~De.indexOf(ye));if(~De.indexOf(ye)){De.splice(De.indexOf(ye),1);Se=null;dispatchEvent({sortable:r,rootEl:n,name:"deselect",targetEl:ye,originalEvent:t})}else{De.push(ye);dispatchEvent({sortable:r,rootEl:n,name:"select",targetEl:ye,originalEvent:t});if(t.shiftKey&&Se&&r.el.contains(Se)){var f=index(Se),h=index(ye);~f&&~h&&f!==h&&function(){var e,i;if(h>f){i=f;e=h}else{i=h;e=f+1}var a=c.filter;for(;i1){var g=getRect(ye),p=index(ye,":not(."+this.options.selectedClass+")");!xe&&c.animation&&(ye.thisAnimationDuration=null);s.captureAnimationState();if(!xe){if(c.animation){ye.fromRect=g;De.forEach((function(e){e.thisAnimationDuration=null;if(e!==ye){var t=Ae?getRect(e):g;e.fromRect=t;s.addAnimationState({target:e,rect:t})}}))}removeMultiDragElements();De.forEach((function(e){d[p]?o.insertBefore(e,d[p]):o.appendChild(e);p++}));if(a===index(ye)){var v=false;De.forEach((function(e){e.sortableIndex===index(e)||(v=true)}));if(v){i("update");i("sort")}}}De.forEach((function(e){unsetRect(e)}));s.animateAll()}_e=s}(n===o||l&&l.lastPutMode!=="clone")&&Ce.forEach((function(e){e.parentNode&&e.parentNode.removeChild(e)}))}},nullingGlobal:function nullingGlobal(){this.isMultiDrag=Te=false;Ce.length=0},destroyGlobal:function destroyGlobal(){this._deselectMultiDrag();off(document,"pointerup",this._deselectMultiDrag);off(document,"mouseup",this._deselectMultiDrag);off(document,"touchend",this._deselectMultiDrag);off(document,"keydown",this._checkKeyDown);off(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function _deselectMultiDrag(e){if((typeof Te==="undefined"||!Te)&&_e===this.sortable&&(!e||!closest(e.target,this.options.draggable,this.sortable.el,false))&&(!e||e.button===0))while(De.length){var t=De[0];toggleClass(t,this.options.selectedClass,false);De.shift();dispatchEvent({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:t,originalEvent:e})}},_checkKeyDown:function _checkKeyDown(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=true)},_checkKeyUp:function _checkKeyUp(e){e.key===this.options.multiDragKey&&(this.multiDragKeyDown=false)}};return _extends(MultiDrag,{pluginName:"multiDrag",utils:{ + */ne.create=function(t,e){return new ne(t,e)};ne.version=g;var ge,ve,me,be,ye,we,De=[],Ee=false;function Se(){function t(){this.defaults={scroll:true,forceAutoScrollFallback:false,scrollSensitivity:30,scrollSpeed:10,bubbleScroll:true};for(var t in this)t.charAt(0)==="_"&&typeof this[t]==="function"&&(this[t]=this[t].bind(this))}t.prototype={dragStarted:function(t){var e=t.originalEvent;this.sortable.nativeDraggable?_(document,"dragover",this._handleAutoScroll):this.options.supportPointer?_(document,"pointermove",this._handleFallbackAutoScroll):e.touches?_(document,"touchmove",this._handleFallbackAutoScroll):_(document,"mousemove",this._handleFallbackAutoScroll)},dragOverCompleted:function(t){var e=t.originalEvent;this.options.dragOverBubble||e.rootEl||this._handleAutoScroll(e)},drop:function(){if(this.sortable.nativeDraggable)C(document,"dragover",this._handleAutoScroll);else{C(document,"pointermove",this._handleFallbackAutoScroll);C(document,"touchmove",this._handleFallbackAutoScroll);C(document,"mousemove",this._handleFallbackAutoScroll)}Ce();_e();U()},nulling:function(){ye=ve=ge=Ee=we=me=be=null;De.length=0},_handleFallbackAutoScroll:function(t){this._handleAutoScroll(t,true)},_handleAutoScroll:function(t,e){var n=this;var o=(t.touches?t.touches[0]:t).clientX,i=(t.touches?t.touches[0]:t).clientY,r=document.elementFromPoint(o,i);ye=t;if(e||this.options.forceAutoScrollFallback||b||m||w){Te(t,this.options,r,e);var a=L(r,true);if(Ee&&(!we||o!==me||i!==be)){we&&Ce();we=setInterval((function(){var r=L(document.elementFromPoint(o,i),true);if(r!==a){a=r;_e()}Te(t,n.options,r,e)}),10);me=o;be=i}}else{if(!this.options.bubbleScroll||L(r,true)===k()){_e();return}Te(t,this.options,L(r,false),false)}}};return o(t,{pluginName:"scroll",initializeByDefault:true})}function _e(){De.forEach((function(t){clearInterval(t.pid)}));De=[]}function Ce(){clearInterval(we)}var Te=G((function(t,e,n,o){if(e.scroll){var i=(t.touches?t.touches[0]:t).clientX,r=(t.touches?t.touches[0]:t).clientY,a=e.scrollSensitivity,l=e.scrollSpeed,s=k();var u,c=false;if(ve!==n){ve=n;_e();ge=e.scroll;u=e.scrollFn;ge===true&&(ge=L(n,true))}var f=0;var d=ge;do{var h=d,p=R(h),g=p.top,v=p.bottom,m=p.left,b=p.right,y=p.width,w=p.height,D=void 0,E=void 0,S=h.scrollWidth,_=h.scrollHeight,C=N(h),T=h.scrollLeft,x=h.scrollTop;if(h===s){D=y1){Be.forEach((function(t){o.addAnimationState({target:t,rect:je?R(t):i});$(t);t.fromRect=i;e.removeAnimationState(t)}));je=false;We(!this.options.removeCloneOnHide,n)}},dragOverCompleted:function(t){var e=t.sortable,n=t.isOwner,o=t.insertion,i=t.activeSortable,r=t.parentEl,a=t.putSortable;var l=this.options;if(o){n&&i._hideClone();He=false;if(l.animation&&Be.length>1&&(je||!n&&!i.options.sort&&!a)){var s=R(Re,false,true,true);Be.forEach((function(t){if(t!==Re){Z(t,s);r.appendChild(t)}}));je=true}if(!n){je||Ge();if(Be.length>1){var u=Ye;i._showClone(e);i.options.animation&&!Ye&&u&&Fe.forEach((function(t){i.addAnimationState({target:t,rect:Xe});t.fromRect=Xe;t.thisAnimationDuration=null}))}else i._showClone(e)}}},dragOverAnimationCapture:function(t){var e=t.dragRect,n=t.isOwner,i=t.activeSortable;Be.forEach((function(t){t.thisAnimationDuration=null}));if(i.options.animation&&!n&&i.multiDrag.isMultiDrag){Xe=o({},e);var r=I(Re,true);Xe.top-=r.f;Xe.left-=r.e}},dragOverAnimationComplete:function(){if(je){je=false;Ge()}},drop:function(t){var e=t.originalEvent,n=t.rootEl,o=t.parentEl,i=t.sortable,r=t.dispatchSortableEvent,a=t.oldIndex,l=t.putSortable;var s=l||this.sortable;if(e){var u=this.options,c=o.children;if(!Le){u.multiDragKey&&!this.multiDragKeyDown&&this._deselectMultiDrag();A(Re,u.selectedClass,!~Be.indexOf(Re));if(~Be.indexOf(Re)){Be.splice(Be.indexOf(Re),1);Pe=null;at({sortable:i,rootEl:n,name:"deselect",targetEl:Re,originalEvent:e})}else{Be.push(Re);at({sortable:i,rootEl:n,name:"select",targetEl:Re,originalEvent:e});if(e.shiftKey&&Pe&&i.el.contains(Pe)){var f=F(Pe),d=F(Re);~f&&~d&&f!==d&&function(){var t,r;if(d>f){r=f;t=d}else{r=d;t=f+1}var a=u.filter;for(;r1){var h=R(Re),p=F(Re,":not(."+this.options.selectedClass+")");!He&&u.animation&&(Re.thisAnimationDuration=null);s.captureAnimationState();if(!He){if(u.animation){Re.fromRect=h;Be.forEach((function(t){t.thisAnimationDuration=null;if(t!==Re){var e=je?R(t):h;t.fromRect=e;s.addAnimationState({target:t,rect:e})}}))}Ge();Be.forEach((function(t){c[p]?o.insertBefore(t,c[p]):o.appendChild(t);p++}));if(a===F(Re)){var g=false;Be.forEach((function(t){t.sortableIndex===F(t)||(g=true)}));if(g){r("update");r("sort")}}}Be.forEach((function(t){$(t)}));s.animateAll()}ke=s}(n===o||l&&l.lastPutMode!=="clone")&&Fe.forEach((function(t){t.parentNode&&t.parentNode.removeChild(t)}))}},nullingGlobal:function(){this.isMultiDrag=Le=false;Fe.length=0},destroyGlobal:function(){this._deselectMultiDrag();C(document,"pointerup",this._deselectMultiDrag);C(document,"mouseup",this._deselectMultiDrag);C(document,"touchend",this._deselectMultiDrag);C(document,"keydown",this._checkKeyDown);C(document,"keyup",this._checkKeyUp)},_deselectMultiDrag:function(t){if((typeof Le==="undefined"||!Le)&&ke===this.sortable&&(!t||!M(t.target,this.options.draggable,this.sortable.el,false))&&(!t||t.button===0))while(Be.length){var e=Be[0];A(e,this.options.selectedClass,false);Be.shift();at({sortable:this.sortable,rootEl:this.sortable.el,name:"deselect",targetEl:e,originalEvent:t})}},_checkKeyDown:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=true)},_checkKeyUp:function(t){t.key===this.options.multiDragKey&&(this.multiDragKeyDown=false)}};return o(t,{pluginName:"multiDrag",utils:{ /** * Selects the provided multi-drag item * @param {HTMLElement} el The element to be selected */ -select:function select(e){var t=e.parentNode[u];if(t&&t.options.multiDrag&&!~De.indexOf(e)){if(_e&&_e!==t){_e.multiDrag._deselectMultiDrag();_e=t}toggleClass(e,t.options.selectedClass,true);De.push(e)}}, +select:function(t){var e=t.parentNode[J];if(e&&e.options.multiDrag&&!~Be.indexOf(t)){if(ke&&ke!==e){ke.multiDrag._deselectMultiDrag();ke=e}A(t,e.options.selectedClass,true);Be.push(t)}}, /** * Deselects the provided multi-drag item * @param {HTMLElement} el The element to be deselected */ -deselect:function deselect(e){var t=e.parentNode[u],n=De.indexOf(e);if(t&&t.options.multiDrag&&~n){toggleClass(e,t.options.selectedClass,false);De.splice(n,1)}}},eventProperties:function eventProperties(){var e=this;var t=[],n=[];De.forEach((function(o){t.push({multiDragElement:o,index:o.sortableIndex});var r;r=Ae&&o!==ye?-1:Ae?index(o,":not(."+e.options.selectedClass+")"):index(o);n.push({multiDragElement:o,index:r})}));return{items:_toConsumableArray(De),clones:[].concat(Ce),oldIndicies:t,newIndicies:n}},optionListeners:{multiDragKey:function multiDragKey(e){e=e.toLowerCase();e==="ctrl"?e="Control":e.length>1&&(e=e.charAt(0).toUpperCase()+e.substr(1));return e}}})}function insertMultiDragElements(e,t){De.forEach((function(n,o){var r=t.children[n.sortableIndex+(e?Number(o):0)];r?t.insertBefore(n,r):t.appendChild(n)}))} +deselect:function(t){var e=t.parentNode[J],n=Be.indexOf(t);if(e&&e.options.multiDrag&&~n){A(t,e.options.selectedClass,false);Be.splice(n,1)}}},eventProperties:function(){var t=this;var e=[],n=[];Be.forEach((function(o){e.push({multiDragElement:o,index:o.sortableIndex});var i;i=je&&o!==Re?-1:je?F(o,":not(."+t.options.selectedClass+")"):F(o);n.push({multiDragElement:o,index:i})}));return{items:c(Be),clones:[].concat(Fe),oldIndicies:e,newIndicies:n}},optionListeners:{multiDragKey:function(t){t=t.toLowerCase();t==="ctrl"?t="Control":t.length>1&&(t=t.charAt(0).toUpperCase()+t.substr(1));return t}}})}function We(t,e){Be.forEach((function(n,o){var i=e.children[n.sortableIndex+(t?Number(o):0)];i?e.insertBefore(n,i):e.appendChild(n)}))} /** * Insert multi-drag clones * @param {[Boolean]} elementsInserted Whether the multi-drag elements are inserted * @param {HTMLElement} rootEl - */function insertMultiDragClones(e,t){Ce.forEach((function(n,o){var r=t.children[n.sortableIndex+(e?Number(o):0)];r?t.insertBefore(n,r):t.appendChild(n)}))}function removeMultiDragElements(){De.forEach((function(e){e!==ye&&e.parentNode&&e.parentNode.removeChild(e)}))}Sortable.mount(new AutoScrollPlugin);Sortable.mount(Remove,Revert);export{MultiDragPlugin as MultiDrag,Sortable,SwapPlugin as Swap,Sortable as default}; + */function ze(t,e){Fe.forEach((function(n,o){var i=e.children[n.sortableIndex+(t?Number(o):0)];i?e.insertBefore(n,i):e.appendChild(n)}))}function Ge(){Be.forEach((function(t){t!==Re&&t.parentNode&&t.parentNode.removeChild(t)}))}ne.mount(new Se);ne.mount(Oe,Me);export{Ke as MultiDrag,ne as Sortable,Ne as Swap,ne as default}; diff --git a/vendor/javascript/trix.js b/vendor/javascript/trix.js index 5809a45..1a7d05f 100644 --- a/vendor/javascript/trix.js +++ b/vendor/javascript/trix.js @@ -1,5 +1,5 @@ -// trix@2.1.15 downloaded from https://ga.jspm.io/npm:trix@2.1.15/dist/trix.esm.min.js +// trix@2.1.16 downloaded from https://ga.jspm.io/npm:trix@2.1.16/dist/trix.esm.min.js -var t="2.1.15";const e="[data-trix-attachment]",i={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},n={default:{tagName:"div",parse:!1},quote:{tagName:"blockquote",nestable:!0},heading1:{tagName:"h1",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:"pre",terminal:!0,htmlAttributes:["language"],text:{plaintext:!0}},bulletList:{tagName:"ul",parse:!1},bullet:{tagName:"li",listAttribute:"bulletList",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},r=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},o=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),s=o&&parseInt(o[1]);var a={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:s&&s>12,samsungAndroid:s&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:"undefined"!=typeof InputEvent&&["data","getTargetRanges","inputType"].every((t=>t in InputEvent.prototype))},l={ADD_ATTR:["language"],SAFE_FOR_XML:!1,RETURN_DOM:!0},c={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets",byte:"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption…",code:"Code",heading1:"Heading",indent:"Increase Level",italic:"Italic",link:"Link",numbers:"Numbers",outdent:"Decrease Level",quote:"Quote",redo:"Redo",remove:"Remove",strike:"Strikethrough",undo:"Undo",unlink:"Unlink",url:"URL",urlPlaceholder:"Enter a URL…",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"};const u=[c.bytes,c.KB,c.MB,c.GB,c.TB,c.PB];var h={prefix:"IEC",precision:2,formatter(t){switch(t){case 0:return"0 ".concat(c.bytes);case 1:return"1 ".concat(c.byte);default:let e;"SI"===this.prefix?e=1e3:"IEC"===this.prefix&&(e=1024);const i=Math.floor(Math.log(t)/Math.log(e)),n=(t/Math.pow(e,i)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(n," ").concat(u[i])}}};const d="\ufeff",g=" ",m=function(t){for(const e in t){const i=t[e];this[e]=i}return this},p=document.documentElement,f=p.matches,b=function(t){let{onElement:e,matchingSelector:i,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e||p,l=i,c="capturing"===r,u=function(t){null!=s&&0==--s&&u.destroy();const e=y(t.target,{matchingSelector:l});null!=e&&(null==n||n.call(e,t,e),o&&t.preventDefault())};return u.destroy=()=>a.removeEventListener(t,u,c),a.addEventListener(t,u,c),u},v=function(t){let{onElement:e,bubbles:i,cancelable:n,attributes:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!=e?e:p;i=!1!==i,n=!1!==n;const s=document.createEvent("Events");return s.initEvent(t,i,n),null!=r&&m.call(s,r),o.dispatchEvent(s)},A=function(t,e){if(1===(null==t?void 0:t.nodeType))return f.call(t,e)},y=function(t){let{matchingSelector:e,untilNode:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==e)return t;if(t.closest&&null==i)return t.closest(e);for(;t&&t!==i;){if(A(t,e))return t;t=t.parentNode}}},x=t=>document.activeElement!==t&&C(t,document.activeElement),C=function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},E=function(t){var e;if(null===(e=t)||void 0===e||!e.parentNode)return;let i=0;for(t=t.previousSibling;t;)i++,t=t.previousSibling;return i},S=t=>{var e;return null==t||null===(e=t.parentNode)||void 0===e?void 0:e.removeChild(t)},R=function(t){let{onlyNodesOfType:e,usingFilter:i,expandEntityReferences:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(()=>{switch(e){case"element":return NodeFilter.SHOW_ELEMENT;case"text":return NodeFilter.SHOW_TEXT;case"comment":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,r,null!=i?i:null,!0===n)},k=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},T=function(t){let e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"object"==typeof t?(n=t,t=n.tagName):n={attributes:n};const r=document.createElement(t);if(null!=n.editable&&(null==n.attributes&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(e in n.attributes)i=n.attributes[e],r.setAttribute(e,i);if(n.style)for(e in n.style)i=n.style[e],r.style[e]=i;if(n.data)for(e in n.data)i=n.data[e],r.dataset[e]=i;return n.className&&n.className.split(" ").forEach((t=>{r.classList.add(t)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((t=>{r.appendChild(t)})),r};let w;const L=function(){if(null!=w)return w;w=[];for(const t in n){const e=n[t];e.tagName&&w.push(e.tagName)}return w},D=t=>I(null==t?void 0:t.firstChild),N=function(t){let{strict:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return e?I(t):I(t)||!I(t.firstChild)&&function(t){return L().includes(k(t))&&!L().includes(k(t.firstChild))}(t)},I=t=>O(t)&&"block"===(null==t?void 0:t.data),O=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,F=function(t){let{name:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return B(t)?t.data===d?!e||t.parentNode.dataset.trixCursorTarget===e:void 0:F(t.firstChild)},P=t=>A(t,e),M=t=>B(t)&&""===(null==t?void 0:t.data),B=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,_={level2Enabled:!0,getLevel(){return this.level2Enabled&&a.supportsInputEvents?2:0},pickFiles(t){const e=T("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId});e.addEventListener("change",(()=>{t(e.files),S(e)})),S(document.getElementById(this.fileInputId)),document.body.appendChild(e),e.click()}};var j={removeBlankTableCells:!1,tableCellSeparator:" | ",tableRowSeparator:"\n"},W={bold:{tagName:"strong",inheritable:!0,parser(t){const e=window.getComputedStyle(t);return"bold"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser:t=>"italic"===window.getComputedStyle(t).fontStyle},href:{groupTagName:"a",parser(t){const i="a:not(".concat(e,")"),n=t.closest(i);if(n)return n.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},U={getDefaultHTML:()=>'
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n\n \n \n \n \n
\n\n
\n \n
')};const V={interval:5e3};var H=Object.freeze({__proto__:null,attachments:i,blockAttributes:n,browser:a,css:{attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"},dompurify:l,fileSize:h,input:_,keyNames:{8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"},lang:c,parser:j,textAttributes:W,toolbar:U,undo:V});class q{static proxyMethod(t){const{name:e,toMethod:i,toProperty:n,optional:r}=z(t);this.prototype[e]=function(){let t,o;var s,a;i?o=r?null===(s=this[i])||void 0===s?void 0:s.call(this):this[i]():n&&(o=this[n]);return r?(t=null===(a=o)||void 0===a?void 0:a[e],t?J.call(t,o,arguments):void 0):(t=o[e],J.call(t,o,arguments))}}}const z=function(t){const e=t.match(K);if(!e)throw new Error("can't parse @proxyMethod expression: ".concat(t));const i={name:e[4]};return null!=e[2]?i.toMethod=e[1]:i.toProperty=e[1],null!=e[3]&&(i.optional=!0),i},{apply:J}=Function.prototype,K=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$");var G,Y,X;class $ extends q{static box(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t instanceof this?t:this.fromUCS2String(null==t?void 0:t.toString())}static fromUCS2String(t){return new this(t,et(t))}static fromCodepoints(t){return new this(it(t),t)}constructor(t,e){super(...arguments),this.ucs2String=t,this.codepoints=e,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}offsetToUCS2Offset(t){return it(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return et(this.ucs2String.slice(0,Math.max(0,t))).length}slice(){return this.constructor.fromCodepoints(this.codepoints.slice(...arguments))}charAt(t){return this.slice(t,t+1)}isEqualTo(t){return this.constructor.box(t).ucs2String===this.ucs2String}toJSON(){return this.ucs2String}getCacheKey(){return this.ucs2String}toString(){return this.ucs2String}}const Z=1===(null===(G=Array.from)||void 0===G?void 0:G.call(Array,"👼").length),Q=null!=(null===(Y=" ".codePointAt)||void 0===Y?void 0:Y.call(" ",0)),tt=" 👼"===(null===(X=String.fromCodePoint)||void 0===X?void 0:X.call(String,32,128124));let et,it;et=Z&&Q?t=>Array.from(t).map((t=>t.codePointAt(0))):function(t){const e=[];let i=0;const{length:n}=t;for(;iString.fromCodePoint(...Array.from(t||[])):function(t){return(()=>{const e=[];return Array.from(t).forEach((t=>{let i="";t>65535&&(t-=65536,i+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e.push(i+String.fromCharCode(t))})),e})().join("")};let nt=0;class rt extends q{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++nt}hasSameConstructorAs(t){return this.constructor===(null==t?void 0:t.constructor)}isEqualTo(t){return this===t}inspect(){const t=[],e=this.contentsForInspection()||{};for(const i in e){const n=e[i];t.push("".concat(i,"=").concat(n))}return"#<".concat(this.constructor.name,":").concat(this.id).concat(t.length?" ".concat(t.join(", ")):"",">")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return $.box(this)}getCacheKey(){return this.id.toString()}}const ot=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;for(let i=0;i1?i-1:0),r=1;r(ct||(ct=bt().concat(pt())),ct),mt=t=>n[t],pt=()=>(ut||(ut=Object.keys(n)),ut),ft=t=>W[t],bt=()=>(ht||(ht=Object.keys(W)),ht),vt=function(t,e){At(t).textContent=e.replace(/%t/g,t)},At=function(t){const e=document.createElement("style");e.setAttribute("type","text/css"),e.setAttribute("data-tag-name",t.toLowerCase());const i=yt();return i&&e.setAttribute("nonce",i),document.head.insertBefore(e,document.head.firstChild),e},yt=function(){const t=xt("trix-csp-nonce")||xt("csp-nonce");if(t){const{nonce:e,content:i}=t;return""==e?i:e}},xt=t=>document.head.querySelector("meta[name=".concat(t,"]")),Ct={"application/x-trix-feature-detection":"test"},Et=function(t){const e=t.getData("text/plain"),i=t.getData("text/html");if(!e||!i)return null==e?void 0:e.length;{const{body:t}=(new DOMParser).parseFromString(i,"text/html");if(t.textContent===e)return!t.querySelector("*")}},St=/Mac|^iP/.test(navigator.platform)?t=>t.metaKey:t=>t.ctrlKey;const Rt=t=>setTimeout(t,1),kt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={};for(const i in t){const n=t[i];e[i]=n}return e},Tt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(t[i]!==e[i])return!1;return!0},wt=function(t){if(null!=t)return Array.isArray(t)||(t=[t,t]),[Nt(t[0]),Nt(null!=t[1]?t[1]:t[0])]},Lt=function(t){if(null==t)return;const[e,i]=wt(t);return It(e,i)},Dt=function(t,e){if(null==t||null==e)return;const[i,n]=wt(t),[r,o]=wt(e);return It(i,r)&&It(n,o)},Nt=function(t){return"number"==typeof t?t:kt(t)},It=function(t,e){return"number"==typeof t?t===e:Tt(t,e)};class Ot extends q{constructor(){super(...arguments),this.update=this.update.bind(this),this.selectionManagers=[]}start(){this.started||(this.started=!0,document.addEventListener("selectionchange",this.update,!0))}stop(){if(this.started)return this.started=!1,document.removeEventListener("selectionchange",this.update,!0)}registerSelectionManager(t){if(!this.selectionManagers.includes(t))return this.selectionManagers.push(t),this.start()}unregisterSelectionManager(t){if(this.selectionManagers=this.selectionManagers.filter((e=>e!==t)),0===this.selectionManagers.length)return this.stop()}notifySelectionManagersOfSelectionChange(){return this.selectionManagers.map((t=>t.selectionDidChange()))}update(){this.notifySelectionManagersOfSelectionChange()}reset(){this.update()}}const Ft=new Ot,Pt=function(){const t=window.getSelection();if(t.rangeCount>0)return t},Mt=function(){var t;const e=null===(t=Pt())||void 0===t?void 0:t.getRangeAt(0);if(e&&!_t(e))return e},Bt=function(t){const e=window.getSelection();return e.removeAllRanges(),e.addRange(t),Ft.update()},_t=t=>jt(t.startContainer)||jt(t.endContainer),jt=t=>!Object.getPrototypeOf(t),Wt=t=>t.replace(new RegExp("".concat(d),"g"),"").replace(new RegExp("".concat(g),"g")," "),Ut=new RegExp("[^\\S".concat(g,"]")),Vt=t=>t.replace(new RegExp("".concat(Ut.source),"g")," ").replace(/\ {2,}/g," "),qt=function(t,e){if(t.isEqualTo(e))return["",""];const i=zt(t,e),{length:n}=i.utf16String;let r;if(n){const{offset:o}=i,s=t.codepoints.slice(0,o).concat(t.codepoints.slice(o+n));r=zt(e,$.fromCodepoints(s))}else r=zt(e,t);return[i.utf16String.toString(),r.utf16String.toString()]},zt=function(t,e){let i=0,n=t.length,r=e.length;for(;ii+1&&t.charAt(n-1).isEqualTo(e.charAt(r-1));)n--,r--;return{utf16String:t.slice(i,n),offset:i}};class Ht extends rt{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t.length)return new this;let e=Yt(t[0]),i=e.getKeys();return t.slice(1).forEach((t=>{i=e.getKeysCommonToHash(Yt(t)),e=e.slice(i)})),e}static box(t){return Yt(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(...arguments),this.values=Gt(t)}add(t,e){return this.merge(Jt(t,e))}remove(t){return new Ht(Gt(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new Ht(Kt(this.values,Xt(t)))}slice(t){const e={};return Array.from(t).forEach((t=>{this.has(t)&&(e[t]=this.values[t])})),new Ht(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=Yt(t),this.getKeys().filter((e=>this.values[e]===t.values[e]))}isEqualTo(t){return ot(this.toArray(),Yt(t).toArray())}isEmpty(){return 0===this.getKeys().length}toArray(){if(!this.array){const t=[];for(const e in this.values){const i=this.values[e];t.push(t.push(e,i))}this.array=t.slice(0)}return this.array}toObject(){return Gt(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}}const Jt=function(t,e){const i={};return i[t]=e,i},Kt=function(t,e){const i=Gt(t);for(const t in e){const n=e[t];i[t]=n}return i},Gt=function(t,e){const i={};return Object.keys(t).sort().forEach((n=>{n!==e&&(i[n]=t[n])})),i},Yt=function(t){return t instanceof Ht?t:new Ht(t)},Xt=function(t){return t instanceof Ht?t.values:t};class $t{static groupObjects(){let t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:i,asTree:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n&&null==i&&(i=0);const r=[];return Array.from(e).forEach((e=>{var o;if(t){var s,a,l;if(null!==(s=e.canBeGrouped)&&void 0!==s&&s.call(e,i)&&null!==(a=(l=t[t.length-1]).canBeGroupedWith)&&void 0!==a&&a.call(l,e,i))return void t.push(e);r.push(new this(t,{depth:i,asTree:n})),t=null}null!==(o=e.canBeGrouped)&&void 0!==o&&o.call(e,i)?t=[e]:r.push(e)})),t&&r.push(new this(t,{depth:i,asTree:n})),r}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:e,asTree:i}=arguments.length>1?arguments[1]:void 0;this.objects=t,i&&(this.depth=e,this.objects=this.constructor.groupObjects(this.objects,{asTree:i,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){const t=["objectGroup"];return Array.from(this.getObjects()).forEach((e=>{t.push(e.getCacheKey())})),t.join("/")}}class Zt extends q{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach((t=>{const e=JSON.stringify(t);null==this.objects[e]&&(this.objects[e]=t)}))}find(t){const e=JSON.stringify(t);return this.objects[e]}}class Qt{constructor(t){this.reset(t)}add(t){const e=te(t);this.elements[e]=t}remove(t){const e=te(t),i=this.elements[e];if(i)return delete this.elements[e],i}reset(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.elements={},Array.from(t).forEach((t=>{this.add(t)})),t}}const te=t=>t.dataset.trixStoreKey;class ee extends q{isPerforming(){return!0===this.performing}hasPerformed(){return!0===this.performed}hasSucceeded(){return this.performed&&this.succeeded}hasFailed(){return this.performed&&!this.succeeded}getPromise(){return this.promise||(this.promise=new Promise(((t,e)=>(this.performing=!0,this.perform(((i,n)=>{this.succeeded=i,this.performing=!1,this.performed=!0,this.succeeded?t(n):e(n)})))))),this.promise}perform(t){return t(!1)}release(){var t,e;null===(t=this.promise)||void 0===t||null===(e=t.cancel)||void 0===e||e.call(t),this.promise=null,this.performing=null,this.performed=null,this.succeeded=null}}ee.proxyMethod("getPromise().then"),ee.proxyMethod("getPromise().catch");class ie extends q{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.object=t,this.options=e,this.childViews=[],this.rootView=this}getNodes(){return this.nodes||(this.nodes=this.createNodes()),this.nodes.map((t=>t.cloneNode(!0)))}invalidate(){var t;return this.nodes=null,this.childViews=[],null===(t=this.parentView)||void 0===t?void 0:t.invalidate()}invalidateViewForObject(t){var e;return null===(e=this.findViewForObject(t))||void 0===e?void 0:e.invalidate()}findOrCreateCachedChildView(t,e,i){let n=this.getCachedViewForObject(e);return n?this.recordChildView(n):(n=this.createChildView(...arguments),this.cacheViewForObject(n,e)),n}createChildView(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e instanceof $t&&(i.viewClass=t,t=ne);const n=new t(e,i);return this.recordChildView(n)}recordChildView(t){return t.parentView=this,t.rootView=this.rootView,this.childViews.push(t),t}getAllChildViews(){let t=[];return this.childViews.forEach((e=>{t.push(e),t=t.concat(e.getAllChildViews())})),t}findElement(){return this.findElementForObject(this.object)}findElementForObject(t){const e=null==t?void 0:t.id;if(e)return this.rootView.element.querySelector("[data-trix-id='".concat(e,"']"))}findViewForObject(t){for(const e of this.getAllChildViews())if(e.object===t)return e}getViewCache(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?(this.viewCache||(this.viewCache={}),this.viewCache):void 0}isViewCachingEnabled(){return!1!==this.shouldCacheViews}enableViewCaching(){this.shouldCacheViews=!0}disableViewCaching(){this.shouldCacheViews=!1}getCachedViewForObject(t){var e;return null===(e=this.getViewCache())||void 0===e?void 0:e[t.getCacheKey()]}cacheViewForObject(t,e){const i=this.getViewCache();i&&(i[e.getCacheKey()]=t)}garbageCollectCachedViews(){const t=this.getViewCache();if(t){const e=this.getAllChildViews().concat(this).map((t=>t.object.getCacheKey()));for(const i in t)e.includes(i)||delete t[i]}}}class ne extends ie{constructor(){super(...arguments),this.objectGroup=this.object,this.viewClass=this.options.viewClass,delete this.options.viewClass}getChildViews(){return this.childViews.length||Array.from(this.objectGroup.getObjects()).forEach((t=>{this.findOrCreateCachedChildView(this.viewClass,t,this.options)})),this.childViews}createNodes(){const t=this.createContainerElement();return this.getChildViews().forEach((e=>{Array.from(e.getNodes()).forEach((e=>{t.appendChild(e)}))})),[t]}createContainerElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.objectGroup.getDepth();return this.getChildViews()[0].createContainerElement(t)}} -/*! @license DOMPurify 3.2.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.5/LICENSE */const{entries:re,setPrototypeOf:oe,isFrozen:se,getPrototypeOf:ae,getOwnPropertyDescriptor:le}=Object;let{freeze:ce,seal:ue,create:he}=Object,{apply:de,construct:ge}="undefined"!=typeof Reflect&&Reflect;ce||(ce=function(t){return t}),ue||(ue=function(t){return t}),de||(de=function(t,e,i){return t.apply(e,i)}),ge||(ge=function(t,e){return new t(...e)});const me=Le(Array.prototype.forEach),pe=Le(Array.prototype.lastIndexOf),fe=Le(Array.prototype.pop),be=Le(Array.prototype.push),ve=Le(Array.prototype.splice),Ae=Le(String.prototype.toLowerCase),ye=Le(String.prototype.toString),xe=Le(String.prototype.match),Ce=Le(String.prototype.replace),Ee=Le(String.prototype.indexOf),Se=Le(String.prototype.trim),Re=Le(Object.prototype.hasOwnProperty),ke=Le(RegExp.prototype.test),Te=(we=TypeError,function(){for(var t=arguments.length,e=new Array(t),i=0;i1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:Ae;oe&&oe(t,null);let n=e.length;for(;n--;){let r=e[n];if("string"==typeof r){const t=i(r);t!==r&&(se(e)||(e[n]=t),r=t)}t[r]=!0}return t}function Ne(t){for(let e=0;e/gm),Ke=ue(/\$\{[\w\W]*/gm),Ge=ue(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ye=ue(/^aria-[\-\w]+$/),$e=ue(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Xe=ue(/^(?:\w+script|data):/i),Ze=ue(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Qe=ue(/^html$/i),ti=ue(/^[a-z][.\w]*(-[.\w]+)+$/i);var ei=Object.freeze({__proto__:null,ARIA_ATTR:Ye,ATTR_WHITESPACE:Ze,CUSTOM_ELEMENT:ti,DATA_ATTR:Ge,DOCTYPE_NAME:Qe,ERB_EXPR:Je,IS_ALLOWED_URI:$e,IS_SCRIPT_OR_DATA:Xe,MUSTACHE_EXPR:ze,TMPLIT_EXPR:Ke});const ii=1,ni=3,ri=7,oi=8,si=9,ai=function(){return"undefined"==typeof window?null:window};var li=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:ai();const i=e=>t(e);if(i.version="3.2.5",i.removed=[],!e||!e.document||e.document.nodeType!==si||!e.Element)return i.isSupported=!1,i;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:a,Node:l,Element:c,NodeFilter:u,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:g,trustedTypes:m}=e,p=c.prototype,f=Oe(p,"cloneNode"),b=Oe(p,"remove"),v=Oe(p,"nextSibling"),A=Oe(p,"childNodes"),y=Oe(p,"parentNode");if("function"==typeof a){const t=n.createElement("template");t.content&&t.content.ownerDocument&&(n=t.content.ownerDocument)}let x,C="";const{implementation:E,createNodeIterator:S,createDocumentFragment:R,getElementsByTagName:k}=n,{importNode:T}=r;let w={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof re&&"function"==typeof y&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:L,ERB_EXPR:D,TMPLIT_EXPR:N,DATA_ATTR:I,ARIA_ATTR:O,IS_SCRIPT_OR_DATA:F,ATTR_WHITESPACE:P,CUSTOM_ELEMENT:M}=ei;let{IS_ALLOWED_URI:B}=ei,_=null;const j=De({},[...Fe,...Pe,...Me,..._e,...We]);let W=null;const U=De({},[...Ue,...Ve,...qe,...He]);let V=Object.seal(he(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),H=null,z=null,J=!0,K=!0,G=!1,Y=!0,X=!1,Z=!0,Q=!1,tt=!1,et=!1,it=!1,nt=!1,ot=!1,st=!0,at=!1,lt=!0,ct=!1,ut={},ht=null;const dt=De({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let gt=null;const mt=De({},["audio","video","img","source","image","track"]);let pt=null;const ft=De({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),bt="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",At="http://www.w3.org/1999/xhtml";let yt=At,xt=!1,Ct=null;const Et=De({},[bt,vt,At],ye);let St=De({},["mi","mo","mn","ms","mtext"]),Rt=De({},["annotation-xml"]);const kt=De({},["title","style","font","a","script"]);let Tt=null;const wt=["application/xhtml+xml","text/html"];let Lt=null,Dt=null;const Nt=n.createElement("form"),It=function(t){return t instanceof RegExp||t instanceof Function},Ft=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Dt||Dt!==t){if(t&&"object"==typeof t||(t={}),t=Ie(t),Tt=-1===wt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Lt="application/xhtml+xml"===Tt?ye:Ae,_=Re(t,"ALLOWED_TAGS")?De({},t.ALLOWED_TAGS,Lt):j,W=Re(t,"ALLOWED_ATTR")?De({},t.ALLOWED_ATTR,Lt):U,Ct=Re(t,"ALLOWED_NAMESPACES")?De({},t.ALLOWED_NAMESPACES,ye):Et,pt=Re(t,"ADD_URI_SAFE_ATTR")?De(Ie(ft),t.ADD_URI_SAFE_ATTR,Lt):ft,gt=Re(t,"ADD_DATA_URI_TAGS")?De(Ie(mt),t.ADD_DATA_URI_TAGS,Lt):mt,ht=Re(t,"FORBID_CONTENTS")?De({},t.FORBID_CONTENTS,Lt):dt,H=Re(t,"FORBID_TAGS")?De({},t.FORBID_TAGS,Lt):{},z=Re(t,"FORBID_ATTR")?De({},t.FORBID_ATTR,Lt):{},ut=!!Re(t,"USE_PROFILES")&&t.USE_PROFILES,J=!1!==t.ALLOW_ARIA_ATTR,K=!1!==t.ALLOW_DATA_ATTR,G=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Y=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,X=t.SAFE_FOR_TEMPLATES||!1,Z=!1!==t.SAFE_FOR_XML,Q=t.WHOLE_DOCUMENT||!1,it=t.RETURN_DOM||!1,nt=t.RETURN_DOM_FRAGMENT||!1,ot=t.RETURN_TRUSTED_TYPE||!1,et=t.FORCE_BODY||!1,st=!1!==t.SANITIZE_DOM,at=t.SANITIZE_NAMED_PROPS||!1,lt=!1!==t.KEEP_CONTENT,ct=t.IN_PLACE||!1,B=t.ALLOWED_URI_REGEXP||$e,yt=t.NAMESPACE||At,St=t.MATHML_TEXT_INTEGRATION_POINTS||St,Rt=t.HTML_INTEGRATION_POINTS||Rt,V=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&It(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(V.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&It(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(V.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(V.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),X&&(K=!1),nt&&(it=!0),ut&&(_=De({},We),W=[],!0===ut.html&&(De(_,Fe),De(W,Ue)),!0===ut.svg&&(De(_,Pe),De(W,Ve),De(W,He)),!0===ut.svgFilters&&(De(_,Me),De(W,Ve),De(W,He)),!0===ut.mathMl&&(De(_,_e),De(W,qe),De(W,He))),t.ADD_TAGS&&(_===j&&(_=Ie(_)),De(_,t.ADD_TAGS,Lt)),t.ADD_ATTR&&(W===U&&(W=Ie(W)),De(W,t.ADD_ATTR,Lt)),t.ADD_URI_SAFE_ATTR&&De(pt,t.ADD_URI_SAFE_ATTR,Lt),t.FORBID_CONTENTS&&(ht===dt&&(ht=Ie(ht)),De(ht,t.FORBID_CONTENTS,Lt)),lt&&(_["#text"]=!0),Q&&De(_,["html","head","body"]),_.table&&(De(_,["tbody"]),delete H.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw Te('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw Te('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=t.TRUSTED_TYPES_POLICY,C=x.createHTML("")}else void 0===x&&(x=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(i=e.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(m,o)),null!==x&&"string"==typeof C&&(C=x.createHTML(""));ce&&ce(t),Dt=t}},Pt=De({},[...Pe,...Me,...Be]),Mt=De({},[..._e,...je]),Bt=function(t){be(i.removed,{element:t});try{y(t).removeChild(t)}catch(e){b(t)}},_t=function(t,e){try{be(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){be(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(it||nt)try{Bt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},jt=function(t){let e=null,i=null;if(et)t=""+t;else{const e=xe(t,/^[\r\n\t ]+/);i=e&&e[0]}"application/xhtml+xml"===Tt&&yt===At&&(t=''+t+"");const r=x?x.createHTML(t):t;if(yt===At)try{e=(new g).parseFromString(r,Tt)}catch(t){}if(!e||!e.documentElement){e=E.createDocument(yt,"template",null);try{e.documentElement.innerHTML=xt?C:r}catch(t){}}const o=e.body||e.documentElement;return t&&i&&o.insertBefore(n.createTextNode(i),o.childNodes[0]||null),yt===At?k.call(e,Q?"html":"body")[0]:Q?e.documentElement:o},Wt=function(t){return S.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ut=function(t){return t instanceof d&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof h)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Vt=function(t){return"function"==typeof l&&t instanceof l};function qt(t,e,n){me(t,(t=>{t.call(i,e,n,Dt)}))}const zt=function(t){let e=null;if(qt(w.beforeSanitizeElements,t,null),Ut(t))return Bt(t),!0;const n=Lt(t.nodeName);if(qt(w.uponSanitizeElement,t,{tagName:n,allowedTags:_}),t.hasChildNodes()&&!Vt(t.firstElementChild)&&ke(/<[/\w!]/g,t.innerHTML)&&ke(/<[/\w!]/g,t.textContent))return Bt(t),!0;if(t.nodeType===ri)return Bt(t),!0;if(Z&&t.nodeType===oi&&ke(/<[/\w]/g,t.data))return Bt(t),!0;if(!_[n]||H[n]){if(!H[n]&&Kt(n)){if(V.tagNameCheck instanceof RegExp&&ke(V.tagNameCheck,n))return!1;if(V.tagNameCheck instanceof Function&&V.tagNameCheck(n))return!1}if(lt&&!ht[n]){const e=y(t)||t.parentNode,i=A(t)||t.childNodes;if(i&&e)for(let n=i.length-1;n>=0;--n){const r=f(i[n],!0);r.__removalCount=(t.__removalCount||0)+1,e.insertBefore(r,v(t))}}return Bt(t),!0}return t instanceof c&&!function(t){let e=y(t);e&&e.tagName||(e={namespaceURI:yt,tagName:"template"});const i=Ae(t.tagName),n=Ae(e.tagName);return!!Ct[t.namespaceURI]&&(t.namespaceURI===vt?e.namespaceURI===At?"svg"===i:e.namespaceURI===bt?"svg"===i&&("annotation-xml"===n||St[n]):Boolean(Pt[i]):t.namespaceURI===bt?e.namespaceURI===At?"math"===i:e.namespaceURI===vt?"math"===i&&Rt[n]:Boolean(Mt[i]):t.namespaceURI===At?!(e.namespaceURI===vt&&!Rt[n])&&!(e.namespaceURI===bt&&!St[n])&&!Mt[i]&&(kt[i]||!Pt[i]):!("application/xhtml+xml"!==Tt||!Ct[t.namespaceURI]))}(t)?(Bt(t),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!ke(/<\/no(script|embed|frames)/i,t.innerHTML)?(X&&t.nodeType===ni&&(e=t.textContent,me([L,D,N],(t=>{e=Ce(e,t," ")})),t.textContent!==e&&(be(i.removed,{element:t.cloneNode()}),t.textContent=e)),qt(w.afterSanitizeElements,t,null),!1):(Bt(t),!0)},Jt=function(t,e,i){if(st&&("id"===e||"name"===e)&&(i in n||i in Nt))return!1;if(K&&!z[e]&&ke(I,e));else if(J&&ke(O,e));else if(!W[e]||z[e]){if(!(Kt(t)&&(V.tagNameCheck instanceof RegExp&&ke(V.tagNameCheck,t)||V.tagNameCheck instanceof Function&&V.tagNameCheck(t))&&(V.attributeNameCheck instanceof RegExp&&ke(V.attributeNameCheck,e)||V.attributeNameCheck instanceof Function&&V.attributeNameCheck(e))||"is"===e&&V.allowCustomizedBuiltInElements&&(V.tagNameCheck instanceof RegExp&&ke(V.tagNameCheck,i)||V.tagNameCheck instanceof Function&&V.tagNameCheck(i))))return!1}else if(pt[e]);else if(ke(B,Ce(i,P,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Ee(i,"data:")||!gt[t])if(G&&!ke(F,Ce(i,P,"")));else if(i)return!1;return!0},Kt=function(t){return"annotation-xml"!==t&&xe(t,M)},Gt=function(t){qt(w.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||Ut(t))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let r=e.length;for(;r--;){const o=e[r],{name:s,namespaceURI:a,value:l}=o,c=Lt(s);let u="value"===s?l:Se(l);if(n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,qt(w.uponSanitizeAttribute,t,n),u=n.attrValue,!at||"id"!==c&&"name"!==c||(_t(s,t),u="user-content-"+u),Z&&ke(/((--!?|])>)|<\/(style|title)/i,u)){_t(s,t);continue}if(n.forceKeepAttr)continue;if(_t(s,t),!n.keepAttr)continue;if(!Y&&ke(/\/>/i,u)){_t(s,t);continue}X&&me([L,D,N],(t=>{u=Ce(u,t," ")}));const h=Lt(t.nodeName);if(Jt(h,c,u)){if(x&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(a);else switch(m.getAttributeType(h,c)){case"TrustedHTML":u=x.createHTML(u);break;case"TrustedScriptURL":u=x.createScriptURL(u)}try{a?t.setAttributeNS(a,s,u):t.setAttribute(s,u),Ut(t)?Bt(t):fe(i.removed)}catch(t){}}}qt(w.afterSanitizeAttributes,t,null)},Yt=function t(e){let i=null;const n=Wt(e);for(qt(w.beforeSanitizeShadowDOM,e,null);i=n.nextNode();)qt(w.uponSanitizeShadowNode,i,null),zt(i),Gt(i),i.content instanceof s&&t(i.content);qt(w.afterSanitizeShadowDOM,e,null)};return i.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,o=null,a=null,c=null;if(xt=!t,xt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Vt(t)){if("function"!=typeof t.toString)throw Te("toString is not a function");if("string"!=typeof(t=t.toString()))throw Te("dirty is not a string, aborting")}if(!i.isSupported)return t;if(tt||Ft(e),i.removed=[],"string"==typeof t&&(ct=!1),ct){if(t.nodeName){const e=Lt(t.nodeName);if(!_[e]||H[e])throw Te("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)n=jt("\x3c!----\x3e"),o=n.ownerDocument.importNode(t,!0),o.nodeType===ii&&"BODY"===o.nodeName||"HTML"===o.nodeName?n=o:n.appendChild(o);else{if(!it&&!X&&!Q&&-1===t.indexOf("<"))return x&&ot?x.createHTML(t):t;if(n=jt(t),!n)return it?null:ot?C:""}n&&et&&Bt(n.firstChild);const u=Wt(ct?t:n);for(;a=u.nextNode();)zt(a),Gt(a),a.content instanceof s&&Yt(a.content);if(ct)return t;if(it){if(nt)for(c=R.call(n.ownerDocument);n.firstChild;)c.appendChild(n.firstChild);else c=n;return(W.shadowroot||W.shadowrootmode)&&(c=T.call(r,c,!0)),c}let h=Q?n.outerHTML:n.innerHTML;return Q&&_["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&ke(Qe,n.ownerDocument.doctype.name)&&(h="\n"+h),X&&me([L,D,N],(t=>{h=Ce(h,t," ")})),x&&ot?x.createHTML(h):h},i.setConfig=function(){Ft(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),tt=!0},i.clearConfig=function(){Dt=null,tt=!1},i.isValidAttribute=function(t,e,i){Dt||Ft({});const n=Lt(t),r=Lt(e);return Jt(n,r,i)},i.addHook=function(t,e){"function"==typeof e&&be(w[t],e)},i.removeHook=function(t,e){if(void 0!==e){const i=pe(w[t],e);return-1===i?void 0:ve(w[t],i,1)[0]}return fe(w[t])},i.removeHooks=function(t){w[t]=[]},i.removeAllHooks=function(){w={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();li.addHook("uponSanitizeAttribute",(function(t,e){/^data-trix-/.test(e.attrName)&&(e.forceKeepAttr=!0)}));const ci="style href src width height language class".split(" "),ui="javascript:".split(" "),hi="script iframe form noscript".split(" ");class di extends q{static setHTML(t,e,i){const n=new this(e,i).sanitize(),r=n.getHTML?n.getHTML():n.outerHTML;t.innerHTML=r}static sanitize(t,e){const i=new this(t,e);return i.sanitize(),i}constructor(t){let{allowedAttributes:e,forbiddenProtocols:i,forbiddenElements:n,purifyOptions:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.allowedAttributes=e||ci,this.forbiddenProtocols=i||ui,this.forbiddenElements=n||hi,this.purifyOptions=r||{},this.body=gi(t)}sanitize(){this.sanitizeElements(),this.normalizeListElementNesting();const t=Object.assign({},l,this.purifyOptions);return li.setConfig(t),this.body=li.sanitize(this.body),this.body}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){const t=R(this.body),e=[];for(;t.nextNode();){const i=t.currentNode;switch(i.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(i)?e.push(i):this.sanitizeElement(i);break;case Node.COMMENT_NODE:e.push(i)}}return e.forEach((t=>S(t))),this.body}sanitizeElement(t){return t.hasAttribute("href")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute("href"),Array.from(t.attributes).forEach((e=>{let{name:i}=e;this.allowedAttributes.includes(i)||0===i.indexOf("data-trix")||t.removeAttribute(i)})),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t=>{const e=t.previousElementSibling;e&&"li"===k(e)&&e.appendChild(t)})),this.body}elementIsRemovable(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(k(t))}elementIsntSerializable(t){return"false"===t.getAttribute("data-trix-serialize")&&!P(t)}}const gi=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace(/<\/html[^>]*>[^]*$/i,"");const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=t,Array.from(e.head.querySelectorAll("style")).forEach((t=>{e.body.appendChild(t)})),e.body},{css:mi}=H;class pi extends ie{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t;const e=t=T({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),i=this.getHref();return i&&(t=T({tagName:"a",editable:!1,attributes:{href:i,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?di.setHTML(t,this.attachment.getContent()):this.createContentNodes().forEach((e=>{t.appendChild(e)})),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=T({tagName:"progress",attributes:{class:mi.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[fi("left"),e,fi("right")]}createCaptionElement(){const t=T({tagName:"figcaption",className:mi.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add("".concat(mi.attachmentCaption,"--edited")),t.textContent=e;else{let e,i;const n=this.getCaptionConfig();if(n.name&&(e=this.attachment.getFilename()),n.size&&(i=this.attachment.getFormattedFilesize()),e){const i=T({tagName:"span",className:mi.attachmentName,textContent:e});t.appendChild(i)}if(i){e&&t.appendChild(document.createTextNode(" "));const n=T({tagName:"span",className:mi.attachmentSize,textContent:i});t.appendChild(n)}}return t}getClassName(){const t=[mi.attachment,"".concat(mi.attachment,"--").concat(this.attachment.getType())],e=this.attachment.getExtension();return e&&t.push("".concat(mi.attachment,"--").concat(e)),t.join(" ")}getData(){const t={trixAttachment:JSON.stringify(this.attachment),trixContentType:this.attachment.getContentType(),trixId:this.attachment.id},{attributes:e}=this.attachmentPiece;return e.isEmpty()||(t.trixAttributes=JSON.stringify(e)),this.attachment.isPending()&&(t.trixSerialize=!1),t}getHref(){if(!bi(this.attachment.getContent(),"a"))return this.attachment.getHref()}getCaptionConfig(){var t;const e=this.attachment.getType(),n=kt(null===(t=i[e])||void 0===t?void 0:t.caption);return"file"===e&&(n.name=!0),n}findProgressElement(){var t;return null===(t=this.findElement())||void 0===t?void 0:t.querySelector("progress")}attachmentDidChangeUploadProgress(){const t=this.attachment.getUploadProgress(),e=this.findProgressElement();e&&(e.value=t)}}const fi=t=>T({tagName:"span",textContent:d,data:{trixCursorTarget:t,trixSerialize:!1}}),bi=function(t,e){const i=T("div");return di.setHTML(i,t||""),i.querySelector(e)};class vi extends pi{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=T({tagName:"img",attributes:{src:""},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]}createCaptionElement(){const t=super.createCaptionElement(...arguments);return t.textContent||t.setAttribute("data-trix-placeholder",c.captionPlaceholder),t}refresh(t){var e;t||(t=null===(e=this.findElement())||void 0===e?void 0:e.querySelector("img"));if(t)return this.updateAttributesForImage(t)}updateAttributesForImage(t){const e=this.attachment.getURL(),i=this.attachment.getPreviewURL();if(t.src=i||e,i===e)t.removeAttribute("data-trix-serialized-attributes");else{const i=JSON.stringify({src:e});t.setAttribute("data-trix-serialized-attributes",i)}const n=this.attachment.getWidth(),r=this.attachment.getHeight();null!=n&&(t.width=n),null!=r&&(t.height=r);const o=["imageElement",this.attachment.id,t.src,t.width,t.height].join("/");t.dataset.trixStoreKey=o}attachmentDidChangeAttributes(){return this.refresh(this.image),this.refresh()}}class Ai extends ie{constructor(){super(...arguments),this.piece=this.object,this.attributes=this.piece.getAttributes(),this.textConfig=this.options.textConfig,this.context=this.options.context,this.piece.attachment?this.attachment=this.piece.attachment:this.string=this.piece.toString()}createNodes(){let t=this.attachment?this.createAttachmentNodes():this.createStringNodes();const e=this.createElement();if(e){const i=function(t){for(;null!==(e=t)&&void 0!==e&&e.firstElementChild;){var e;t=t.firstElementChild}return t}(e);Array.from(t).forEach((t=>{i.appendChild(t)})),t=[e]}return t}createAttachmentNodes(){const t=this.attachment.isPreviewable()?vi:pi;return this.createChildView(t,this.piece.attachment,{piece:this.piece}).getNodes()}createStringNodes(){var t;if(null!==(t=this.textConfig)&&void 0!==t&&t.plaintext)return[document.createTextNode(this.string)];{const t=[],e=this.string.split("\n");for(let i=0;i0){const e=T("br");t.push(e)}if(n.length){const e=document.createTextNode(this.preserveSpaces(n));t.push(e)}}return t}}createElement(){let t,e,i;const n={};for(e in this.attributes){i=this.attributes[e];const o=ft(e);if(o){if(o.tagName){var r;const e=T(o.tagName);r?(r.appendChild(e),r=e):t=r=e}if(o.styleProperty&&(n[o.styleProperty]=i),o.style)for(e in o.style)i=o.style[e],n[e]=i}}if(Object.keys(n).length)for(e in t||(t=T("span")),n)i=n[e],t.style[e]=i;return t}createContainerElement(){for(const t in this.attributes){const e=this.attributes[t],i=ft(t);if(i&&i.groupTagName){const n={};return n[t]=e,T(i.groupTagName,n)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,g)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(g," $2")).replace(/\ {2}/g,"".concat(g," ")).replace(/\ {2}/g," ".concat(g)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,g)),t}}class yi extends ie{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){const t=[],e=$t.groupObjects(this.getPieces()),i=e.length-1;for(let r=0;r!t.hasAttribute("blockBreak")))}}const xi=t=>/\s$/.test(null==t?void 0:t.toString()),{css:Ci}=H;class Ei extends ie{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){const t=[document.createComment("block")];if(this.block.isEmpty())t.push(T("br"));else{var e;const i=null===(e=mt(this.block.getLastAttribute()))||void 0===e?void 0:e.text,n=this.findOrCreateCachedChildView(yi,this.block.text,{textConfig:i});t.push(...Array.from(n.getNodes()||[])),this.shouldAddExtraNewlineElement()&&t.push(T("br"))}if(this.attributes.length)return t;{let e;const{tagName:i}=n.default;this.block.isRTL()&&(e={dir:"rtl"});const r=T({tagName:i,attributes:e});return t.forEach((t=>r.appendChild(t))),[r]}}createContainerElement(t){const e={};let i;const n=this.attributes[t],{tagName:r,htmlAttributes:o=[]}=mt(n);if(0===t&&this.block.isRTL()&&Object.assign(e,{dir:"rtl"}),"attachmentGallery"===n){const t=this.block.getBlockBreakPosition();i="".concat(Ci.attachmentGallery," ").concat(Ci.attachmentGallery,"--").concat(t)}return Object.entries(this.block.htmlAttributes).forEach((t=>{let[i,n]=t;o.includes(i)&&(e[i]=n)})),T({tagName:r,className:i,attributes:e})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}}class Si extends ie{static render(t){const e=T("div"),i=new this(t,{element:e});return i.render(),i.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new Qt,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=T("div"),!this.document.isEmpty()){const t=$t.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach((t=>{const e=this.findOrCreateCachedChildView(Ei,t);Array.from(e.getNodes()).map((t=>this.shadowElement.appendChild(t)))}))}}isSynced(){return ki(this.shadowElement,this.element)}sync(){const t=this.createDocumentFragmentForSync();for(;this.element.lastChild;)this.element.removeChild(this.element.lastChild);return this.element.appendChild(t),this.didSync()}didSync(){return this.elementStore.reset(Ri(this.element)),Rt((()=>this.garbageCollectCachedViews()))}createDocumentFragmentForSync(){const t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach((e=>{t.appendChild(e.cloneNode(!0))})),Array.from(Ri(t)).forEach((t=>{const e=this.elementStore.remove(t);e&&t.parentNode.replaceChild(e,t)})),t}}const Ri=t=>t.querySelectorAll("[data-trix-store-key]"),ki=(t,e)=>Ti(t.innerHTML)===Ti(e.innerHTML),Ti=t=>t.replace(/ /g," ");function wi(t){var e,i;function n(e,i){try{var o=t[e](i),s=o.value,a=s instanceof Li;Promise.resolve(a?s.v:s).then((function(i){if(a){var l="return"===e?"return":"next";if(!s.k||i.done)return n(l,i);i=t[l](i).value}r(o.done?"return":"normal",i)}),(function(t){n("throw",t)}))}catch(t){r("throw",t)}}function r(t,r){switch(t){case"return":e.resolve({value:r,done:!0});break;case"throw":e.reject(r);break;default:e.resolve({value:r,done:!1})}(e=e.next)?n(e.key,e.arg):i=null}this._invoke=function(t,r){return new Promise((function(o,s){var a={key:t,arg:r,resolve:o,reject:s,next:null};i?i=i.next=a:(e=i=a,n(t,r))}))},"function"!=typeof t.return&&(this.return=void 0)}function Li(t,e){this.v=t,this.k=e}function Di(t,e,i){return(e=Ni(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function Ni(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}wi.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},wi.prototype.next=function(t){return this._invoke("next",t)},wi.prototype.throw=function(t){return this._invoke("throw",t)},wi.prototype.return=function(t){return this._invoke("return",t)};function Ii(t,e){return Pi(t,Fi(t,e,"get"))}function Oi(t,e,i){return Mi(t,Fi(t,e,"set"),i),i}function Fi(t,e,i){if(!e.has(t))throw new TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}function Pi(t,e){return e.get?e.get.call(t):e.value}function Mi(t,e,i){if(e.set)e.set.call(t,i);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=i}}function Bi(t,e,i){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return i}function _i(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function ji(t,e,i){_i(t,e),e.set(t,i)}class Wi extends rt{static registerType(t,e){e.type=t,this.types[t]=e}static fromJSON(t){const e=this.types[t.type];if(e)return e.fromJSON(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.attributes=Ht.box(e)}copyWithAttributes(t){return new this.constructor(this.getValue(),t)}copyWithAdditionalAttributes(t){return this.copyWithAttributes(this.attributes.merge(t))}copyWithoutAttribute(t){return this.copyWithAttributes(this.attributes.remove(t))}copy(){return this.copyWithAttributes(this.attributes)}getAttribute(t){return this.attributes.get(t)}getAttributesHash(){return this.attributes}getAttributes(){return this.attributes.toObject()}hasAttribute(t){return this.attributes.has(t)}hasSameStringValueAsPiece(t){return t&&this.toString()===t.toString()}hasSameAttributesAsPiece(t){return t&&(this.attributes===t.attributes||this.attributes.isEqualTo(t.attributes))}isBlockBreak(){return!1}isEqualTo(t){return super.isEqualTo(...arguments)||this.hasSameConstructorAs(t)&&this.hasSameStringValueAsPiece(t)&&this.hasSameAttributesAsPiece(t)}isEmpty(){return 0===this.length}isSerializable(){return!0}toJSON(){return{type:this.constructor.type,attributes:this.getAttributes()}}contentsForInspection(){return{type:this.constructor.type,attributes:this.attributes.inspect()}}canBeGrouped(){return this.hasAttribute("href")}canBeGroupedWith(t){return this.getAttribute("href")===t.getAttribute("href")}getLength(){return this.length}canBeConsolidatedWith(t){return!1}}Di(Wi,"types",{});class Ui extends ee{constructor(t){super(...arguments),this.url=t}perform(t){const e=new Image;e.onload=()=>(e.width=this.width=e.naturalWidth,e.height=this.height=e.naturalHeight,t(!0,e)),e.onerror=()=>t(!1),e.src=this.url}}class Vi extends rt{static attachmentForFile(t){const e=new this(this.attributesForFile(t));return e.setFile(t),e}static attributesForFile(t){return new Ht({filename:t.name,filesize:t.size,contentType:t.type})}static fromJSON(t){return new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.releaseFile=this.releaseFile.bind(this),this.attributes=Ht.box(t),this.didChangeAttributes()}getAttribute(t){return this.attributes.get(t)}hasAttribute(t){return this.attributes.has(t)}getAttributes(){return this.attributes.toObject()}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.attributes.merge(t);var i,n,r,o;if(!this.attributes.isEqualTo(e))return this.attributes=e,this.didChangeAttributes(),null===(i=this.previewDelegate)||void 0===i||null===(n=i.attachmentDidChangeAttributes)||void 0===n||n.call(i,this),null===(r=this.delegate)||void 0===r||null===(o=r.attachmentDidChangeAttributes)||void 0===o?void 0:o.call(r,this)}didChangeAttributes(){if(this.isPreviewable())return this.preloadURL()}isPending(){return null!=this.file&&!(this.getURL()||this.getHref())}isPreviewable(){return this.attributes.has("previewable")?this.attributes.get("previewable"):Vi.previewablePattern.test(this.getContentType())}getType(){return this.hasContent()?"content":this.isPreviewable()?"preview":"file"}getURL(){return this.attributes.get("url")}getHref(){return this.attributes.get("href")}getFilename(){return this.attributes.get("filename")||""}getFilesize(){return this.attributes.get("filesize")}getFormattedFilesize(){const t=this.attributes.get("filesize");return"number"==typeof t?h.formatter(t):""}getExtension(){var t;return null===(t=this.getFilename().match(/\.(\w+)$/))||void 0===t?void 0:t[1].toLowerCase()}getContentType(){return this.attributes.get("contentType")}hasContent(){return this.attributes.has("content")}getContent(){return this.attributes.get("content")}getWidth(){return this.attributes.get("width")}getHeight(){return this.attributes.get("height")}getFile(){return this.file}setFile(t){if(this.file=t,this.isPreviewable())return this.preloadFile()}releaseFile(){this.releasePreloadedFile(),this.file=null}getUploadProgress(){return null!=this.uploadProgress?this.uploadProgress:0}setUploadProgress(t){var e,i;if(this.uploadProgress!==t)return this.uploadProgress=t,null===(e=this.uploadProgressDelegate)||void 0===e||null===(i=e.attachmentDidChangeUploadProgress)||void 0===i?void 0:i.call(e,this)}toJSON(){return this.getAttributes()}getCacheKey(){return[super.getCacheKey(...arguments),this.attributes.getCacheKey(),this.getPreviewURL()].join("/")}getPreviewURL(){return this.previewURL||this.preloadingURL}setPreviewURL(t){var e,i,n,r;if(t!==this.getPreviewURL())return this.previewURL=t,null===(e=this.previewDelegate)||void 0===e||null===(i=e.attachmentDidChangeAttributes)||void 0===i||i.call(e,this),null===(n=this.delegate)||void 0===n||null===(r=n.attachmentDidChangePreviewURL)||void 0===r?void 0:r.call(n,this)}preloadURL(){return this.preload(this.getURL(),this.releaseFile)}preloadFile(){if(this.file)return this.fileObjectURL=URL.createObjectURL(this.file),this.preload(this.fileObjectURL)}releasePreloadedFile(){this.fileObjectURL&&(URL.revokeObjectURL(this.fileObjectURL),this.fileObjectURL=null)}preload(t,e){if(t&&t!==this.getPreviewURL()){this.preloadingURL=t;return new Ui(t).then((i=>{let{width:n,height:r}=i;return this.getWidth()&&this.getHeight()||this.setAttributes({width:n,height:r}),this.preloadingURL=null,this.setPreviewURL(t),null==e?void 0:e()})).catch((()=>(this.preloadingURL=null,null==e?void 0:e())))}}}Di(Vi,"previewablePattern",/^image(\/(gif|png|webp|jpe?g)|$)/);class zi extends Wi{static fromJSON(t){return new this(Vi.fromJSON(t.attachment),t.attributes)}constructor(t){super(...arguments),this.attachment=t,this.length=1,this.ensureAttachmentExclusivelyHasAttribute("href"),this.attachment.hasContent()||this.removeProhibitedAttributes()}ensureAttachmentExclusivelyHasAttribute(t){this.hasAttribute(t)&&(this.attachment.hasAttribute(t)||this.attachment.setAttributes(this.attributes.slice([t])),this.attributes=this.attributes.remove(t))}removeProhibitedAttributes(){const t=this.attributes.slice(zi.permittedAttributes);t.isEqualTo(this.attributes)||(this.attributes=t)}getValue(){return this.attachment}isSerializable(){return!this.attachment.isPending()}getCaption(){return this.attributes.get("caption")||""}isEqualTo(t){var e;return super.isEqualTo(t)&&this.attachment.id===(null==t||null===(e=t.attachment)||void 0===e?void 0:e.id)}toString(){return""}toJSON(){const t=super.toJSON(...arguments);return t.attachment=this.attachment,t}getCacheKey(){return[super.getCacheKey(...arguments),this.attachment.getCacheKey()].join("/")}toConsole(){return JSON.stringify(this.toString())}}Di(zi,"permittedAttributes",["caption","presentation"]),Wi.registerType("attachment",zi);class qi extends Wi{static fromJSON(t){return new this(t.string,t.attributes)}constructor(t){super(...arguments),this.string=(t=>t.replace(/\r\n?/g,"\n"))(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return"\n"===this.toString()&&!0===this.getAttribute("blockBreak")}toJSON(){const t=super.toJSON(...arguments);return t.string=this.string,t}canBeConsolidatedWith(t){return t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)}consolidateWith(t){return new this.constructor(this.toString()+t.toString(),this.attributes)}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.length?(e=this,i=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),i=new this.constructor(this.string.slice(t),this.attributes)),[e,i]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+"…"),JSON.stringify(t.toString())}}Wi.registerType("string",qi);class Hi extends rt{static box(t){return t instanceof this?t:new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects=t.slice(0),this.length=this.objects.length}indexOf(t){return this.objects.indexOf(t)}splice(){for(var t=arguments.length,e=new Array(t),i=0;it(e,i)))}insertObjectAtIndex(t,e){return this.splice(e,0,t)}insertSplittableListAtIndex(t,e){return this.splice(e,0,...t.objects)}insertSplittableListAtPosition(t,e){const[i,n]=this.splitObjectAtPosition(e);return new this.constructor(i).insertSplittableListAtIndex(t,n)}editObjectAtIndex(t,e){return this.replaceObjectAtIndex(e(this.objects[t]),t)}replaceObjectAtIndex(t,e){return this.splice(e,1,t)}removeObjectAtIndex(t){return this.splice(t,1)}getObjectAtIndex(t){return this.objects[t]}getSplittableListInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e.slice(i,n+1))}selectSplittableList(t){const e=this.objects.filter((e=>t(e)));return new this.constructor(e)}removeObjectsInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e).splice(i,n-i+1)}transformObjectsInRange(t,e){const[i,n,r]=this.splitObjectsAtRange(t),o=i.map(((t,i)=>n<=i&&i<=r?e(t):t));return new this.constructor(o)}splitObjectsAtRange(t){let e,[i,n,r]=this.splitObjectAtPosition(Ki(t));return[i,e]=new this.constructor(i).splitObjectAtPosition(Gi(t)+r),[i,n,e-1]}getObjectAtPosition(t){const{index:e}=this.findIndexAndOffsetAtPosition(t);return this.objects[e]}splitObjectAtPosition(t){let e,i;const{index:n,offset:r}=this.findIndexAndOffsetAtPosition(t),o=this.objects.slice(0);if(null!=n)if(0===r)e=n,i=0;else{const t=this.getObjectAtIndex(n),[s,a]=t.splitAtOffset(r);o.splice(n,1,s,a),e=n+1,i=s.getLength()-r}else e=o.length,i=0;return[o,e,i]}consolidate(){const t=[];let e=this.objects[0];return this.objects.slice(1).forEach((i=>{var n,r;null!==(n=(r=e).canBeConsolidatedWith)&&void 0!==n&&n.call(r,i)?e=e.consolidateWith(i):(t.push(e),e=i)})),e&&t.push(e),new this.constructor(t)}consolidateFromIndexToIndex(t,e){const i=this.objects.slice(0).slice(t,e+1),n=new this.constructor(i).consolidate().toArray();return this.splice(t,i.length,...n)}findIndexAndOffsetAtPosition(t){let e,i=0;for(e=0;ethis.endPosition+=t.getLength()))),this.endPosition}toString(){return this.objects.join("")}toArray(){return this.objects.slice(0)}toJSON(){return this.toArray()}isEqualTo(t){return super.isEqualTo(...arguments)||Ji(this.objects,null==t?void 0:t.objects)}contentsForInspection(){return{objects:"[".concat(this.objects.map((t=>t.inspect())).join(", "),"]")}}}const Ji=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;let i=!0;for(let n=0;nt[0],Gi=t=>t[1];class Yi extends rt{static textForAttachmentWithAttributes(t,e){return new this([new zi(t,e)])}static textForStringWithAttributes(t,e){return new this([new qi(t,e)])}static fromJSON(t){return new this(Array.from(t).map((t=>Wi.fromJSON(t))))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments);const e=t.filter((t=>!t.isEmpty()));this.pieceList=new Hi(e)}copy(){return this.copyWithPieceList(this.pieceList)}copyWithPieceList(t){return new this.constructor(t.consolidate().toArray())}copyUsingObjectMap(t){const e=this.getPieces().map((e=>t.find(e)||e));return new this.constructor(e)}appendText(t){return this.insertTextAtPosition(t,this.getLength())}insertTextAtPosition(t,e){return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList,e))}removeTextAtRange(t){return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t))}replaceTextAtRange(t,e){return this.removeTextAtRange(e).insertTextAtPosition(t,e[0])}moveTextFromRangeToPosition(t,e){if(t[0]<=e&&e<=t[1])return;const i=this.getTextAtRange(t),n=i.getLength();return t[0]e.copyWithAdditionalAttributes(t))))}removeAttributeAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithoutAttribute(t))))}setAttributesAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithAttributes(t))))}getAttributesAtPosition(t){var e;return(null===(e=this.pieceList.getObjectAtPosition(t))||void 0===e?void 0:e.getAttributes())||{}}getCommonAttributes(){const t=Array.from(this.pieceList.toArray()).map((t=>t.getAttributes()));return Ht.fromCommonAttributesOfObjects(t).toObject()}getCommonAttributesAtRange(t){return this.getTextAtRange(t).getCommonAttributes()||{}}getExpandedRangeForAttributeAtOffset(t,e){let i,n=i=e;const r=this.getLength();for(;n>0&&this.getCommonAttributesAtRange([n-1,i])[t];)n--;for(;i!!t.attachment))}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getAttachmentAndPositionById(t){let e=0;for(const n of this.pieceList.toArray()){var i;if((null===(i=n.attachment)||void 0===i?void 0:i.id)===t)return{attachment:n.attachment,position:e};e+=n.length}return{attachment:null,position:null}}getAttachmentById(t){const{attachment:e}=this.getAttachmentAndPositionById(t);return e}getRangeOfAttachment(t){const e=this.getAttachmentAndPositionById(t.id),i=e.position;if(t=e.attachment)return[i,i+1]}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e);return i?this.addAttributesAtRange(t,i):this}getLength(){return this.pieceList.getEndPosition()}isEmpty(){return 0===this.getLength()}isEqualTo(t){var e;return super.isEqualTo(t)||(null==t||null===(e=t.pieceList)||void 0===e?void 0:e.isEqualTo(this.pieceList))}isBlockBreak(){return 1===this.getLength()&&this.pieceList.getObjectAtIndex(0).isBlockBreak()}eachPiece(t){return this.pieceList.eachObject(t)}getPieces(){return this.pieceList.toArray()}getPieceAtPosition(t){return this.pieceList.getObjectAtPosition(t)}contentsForInspection(){return{pieceList:this.pieceList.inspect()}}toSerializableText(){const t=this.pieceList.selectSplittableList((t=>t.isSerializable()));return this.copyWithPieceList(t)}toString(){return this.pieceList.toString()}toJSON(){return this.pieceList.toJSON()}toConsole(){return JSON.stringify(this.pieceList.toArray().map((t=>JSON.parse(t.toConsole()))))}getDirection(){return lt(this.toString())}isRTL(){return"rtl"===this.getDirection()}}class Xi extends rt{static fromJSON(t){return new this(Yi.fromJSON(t.text),t.attributes,t.htmlAttributes)}constructor(t,e,i){super(...arguments),this.text=$i(t||new Yi),this.attributes=e||[],this.htmlAttributes=i||{}}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return!!super.isEqualTo(t)||this.text.isEqualTo(null==t?void 0:t.text)&&ot(this.attributes,null==t?void 0:t.attributes)&&Tt(this.htmlAttributes,null==t?void 0:t.htmlAttributes)}copyWithText(t){return new Xi(t,this.attributes,this.htmlAttributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new Xi(this.text,t,this.htmlAttributes)}copyWithoutAttributes(){return this.copyWithAttributes(null)}copyUsingObjectMap(t){const e=t.find(this.text);return e?this.copyWithText(e):this.copyWithText(this.text.copyUsingObjectMap(t))}addAttribute(t){const e=this.attributes.concat(rn(t));return this.copyWithAttributes(e)}addHTMLAttribute(t,e){const i=Object.assign({},this.htmlAttributes,{[t]:e});return new Xi(this.text,this.attributes,i)}removeAttribute(t){const{listAttribute:e}=mt(t),i=sn(sn(this.attributes,t),e);return this.copyWithAttributes(i)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return on(this.attributes)}getAttributes(){return this.attributes.slice(0)}getAttributeLevel(){return this.attributes.length}getAttributeAtLevel(t){return this.attributes[t-1]}hasAttribute(t){return this.attributes.includes(t)}hasAttributes(){return this.getAttributeLevel()>0}getLastNestableAttribute(){return on(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter((t=>mt(t).nestable))}getNestingLevel(){return this.getNestableAttributes().length}decreaseNestingLevel(){const t=this.getLastNestableAttribute();return t?this.removeAttribute(t):this}increaseNestingLevel(){const t=this.getLastNestableAttribute();if(t){const e=this.attributes.lastIndexOf(t),i=st(this.attributes,e+1,0,...rn(t));return this.copyWithAttributes(i)}return this}getListItemAttributes(){return this.attributes.filter((t=>mt(t).listAttribute))}isListItem(){var t;return null===(t=mt(this.getLastAttribute()))||void 0===t?void 0:t.listAttribute}isTerminalBlock(){var t;return null===(t=mt(this.getLastAttribute()))||void 0===t?void 0:t.terminal}breaksOnReturn(){var t;return null===(t=mt(this.getLastAttribute()))||void 0===t?void 0:t.breakOnReturn}findLineBreakInDirectionFromPosition(t,e){const i=this.toString();let n;switch(t){case"forward":n=i.indexOf("\n",e);break;case"backward":n=i.slice(0,e).lastIndexOf("\n")}if(-1!==n)return n}contentsForInspection(){return{text:this.text.inspect(),attributes:this.attributes}}toString(){return this.text.toString()}toJSON(){return{text:this.text,attributes:this.attributes,htmlAttributes:this.htmlAttributes}}getDirection(){return this.text.getDirection()}isRTL(){return this.text.isRTL()}getLength(){return this.text.getLength()}canBeConsolidatedWith(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()}consolidateWith(t){const e=Yi.textForStringWithAttributes("\n"),i=this.getTextWithoutBlockBreak().appendText(e);return this.copyWithText(i.appendText(t.text))}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.getLength()?(e=this,i=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),i=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,i]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return en(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,e){const i=t.getAttributes(),r=i[e],o=this.attributes[e];return o===r&&!(!1===mt(o).group&&!(()=>{if(!dt){dt=[];for(const t in n){const{listAttribute:e}=n[t];null!=e&&dt.push(e)}}return dt})().includes(i[e+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}}const $i=function(t){return t=Zi(t),tn(t)},Zi=function(t){let e=!1;const i=t.getPieces();let n=i.slice(0,i.length-1);const r=i[i.length-1];return r?(n=n.map((t=>t.isBlockBreak()?(e=!0,nn(t)):t)),e?new Yi([...n,r]):t):t},Qi=Yi.textForStringWithAttributes("\n",{blockBreak:!0}),tn=function(t){return en(t)?t:t.appendText(Qi)},en=function(t){const e=t.getLength();return 0!==e&&t.getTextAtRange([e-1,e]).isBlockBreak()},nn=t=>t.copyWithoutAttribute("blockBreak"),rn=function(t){const{listAttribute:e}=mt(t);return e?[e,t]:[t]},on=t=>t.slice(-1)[0],sn=function(t,e){const i=t.lastIndexOf(e);return-1===i?t:st(t,i,1)};class an extends rt{static fromJSON(t){return new this(Array.from(t).map((t=>Xi.fromJSON(t))))}static fromString(t,e){const i=Yi.textForStringWithAttributes(t,e);return new this([new Xi(i)])}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),0===t.length&&(t=[new Xi]),this.blockList=Hi.box(t)}isEmpty(){const t=this.getBlockAtIndex(0);return 1===this.blockList.length&&t.isEmpty()&&!t.hasAttributes()}copy(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(t)}copyUsingObjectsFromDocument(t){const e=new Zt(t.getObjects());return this.copyUsingObjectMap(e)}copyUsingObjectMap(t){const e=this.getBlocks().map((e=>t.find(e)||e.copyUsingObjectMap(t)));return new this.constructor(e)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.getBlocks().map((e=>{const i=t.concat(e.getAttributes());return e.copyWithAttributes(i)}));return new this.constructor(e)}replaceBlock(t,e){const i=this.blockList.indexOf(t);return-1===i?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,i))}insertDocumentAtRange(t,e){const{blockList:i}=t;e=wt(e);let[n]=e;const{index:r,offset:o}=this.locationFromPosition(n);let s=this;const a=this.getBlockAtPosition(n);return Lt(e)&&a.isEmpty()&&!a.hasAttributes()?s=new this.constructor(s.blockList.removeObjectAtIndex(r)):a.getBlockBreakPosition()===o&&n++,s=s.removeTextAtRange(e),new this.constructor(s.blockList.insertSplittableListAtPosition(i,n))}mergeDocumentAtRange(t,e){let i,n;e=wt(e);const[r]=e,o=this.locationFromPosition(r),s=this.getBlockAtIndex(o.index).getAttributes(),a=t.getBaseBlockAttributes(),l=s.slice(-a.length);if(ot(a,l)){const e=s.slice(0,-a.length);i=t.copyWithBaseBlockAttributes(e)}else i=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(s);const c=i.getBlockCount(),u=i.getBlockAtIndex(0);if(ot(s,u.getAttributes())){const t=u.getTextWithoutBlockBreak();if(n=this.insertTextAtRange(t,e),c>1){i=new this.constructor(i.getBlocks().slice(1));const e=r+t.getLength();n=n.insertDocumentAtRange(i,e)}}else n=this.insertDocumentAtRange(i,e);return n}insertTextAtRange(t,e){e=wt(e);const[i]=e,{index:n,offset:r}=this.locationFromPosition(i),o=this.removeTextAtRange(e);return new this.constructor(o.blockList.editObjectAtIndex(n,(e=>e.copyWithText(e.text.insertTextAtPosition(t,r)))))}removeTextAtRange(t){let e;t=wt(t);const[i,n]=t;if(Lt(t))return this;const[r,o]=Array.from(this.locationRangeFromRange(t)),s=r.index,a=r.offset,l=this.getBlockAtIndex(s),c=o.index,u=o.offset,h=this.getBlockAtIndex(c);if(n-i==1&&l.getBlockBreakPosition()===a&&h.getBlockBreakPosition()!==u&&"\n"===h.text.getStringAtPosition(u))e=this.blockList.editObjectAtIndex(c,(t=>t.copyWithText(t.text.removeTextAtRange([u,u+1]))));else{let t;const i=l.text.getTextAtRange([0,a]),n=h.text.getTextAtRange([u,h.getLength()]),r=i.appendText(n);t=s!==c&&0===a&&l.getAttributeLevel()>=h.getAttributeLevel()?h.copyWithText(r):l.copyWithText(r);const o=c+1-s;e=this.blockList.splice(s,o,t)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let i;t=wt(t);const[n,r]=t;if(n<=e&&e<=r)return this;let o=this.getDocumentAtRange(t),s=this.removeTextAtRange(t);const a=nn=n.editObjectAtIndex(o,(function(){return mt(t)?i.addAttribute(t,e):r[0]===r[1]?i:i.copyWithText(i.text.addAttributeAtRange(t,e,r))})))),new this.constructor(n)}addAttribute(t,e){let{blockList:i}=this;return this.eachBlock(((n,r)=>i=i.editObjectAtIndex(r,(()=>n.addAttribute(t,e))))),new this.constructor(i)}removeAttributeAtRange(t,e){let{blockList:i}=this;return this.eachBlockAtRange(e,(function(e,n,r){mt(t)?i=i.editObjectAtIndex(r,(()=>e.removeAttribute(t))):n[0]!==n[1]&&(i=i.editObjectAtIndex(r,(()=>e.copyWithText(e.text.removeAttributeAtRange(t,n)))))})),new this.constructor(i)}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e),[n]=Array.from(i),{index:r}=this.locationFromPosition(n),o=this.getTextAtIndex(r);return new this.constructor(this.blockList.editObjectAtIndex(r,(i=>i.copyWithText(o.updateAttributesForAttachment(t,e)))))}removeAttributeForAttachment(t,e){const i=this.getRangeOfAttachment(e);return this.removeAttributeAtRange(t,i)}setHTMLAttributeAtPosition(t,e,i){const n=this.getBlockAtPosition(t),r=n.addHTMLAttribute(e,i);return this.replaceBlock(n,r)}insertBlockBreakAtRange(t){let e;t=wt(t);const[i]=t,{offset:n}=this.locationFromPosition(i),r=this.removeTextAtRange(t);return 0===n&&(e=[new Xi]),new this.constructor(r.blockList.insertSplittableListAtPosition(new Hi(e),i))}applyBlockAttributeAtRange(t,e,i){const n=this.expandRangeToLineBreaksAndSplitBlocks(i);let r=n.document;i=n.range;const o=mt(t);if(o.listAttribute){r=r.removeLastListAttributeAtRange(i,{exceptAttributeName:t});const e=r.convertLineBreaksToBlockBreaksInRange(i);r=e.document,i=e.range}else r=o.exclusive?r.removeBlockAttributesAtRange(i):o.terminal?r.removeLastTerminalAttributeAtRange(i):r.consolidateBlocksAtRange(i);return r.addAttributeAtRange(t,e,i)}removeLastListAttributeAtRange(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{blockList:i}=this;return this.eachBlockAtRange(t,(function(t,n,r){const o=t.getLastAttribute();o&&mt(o).listAttribute&&o!==e.exceptAttributeName&&(i=i.editObjectAtIndex(r,(()=>t.removeAttribute(o))))})),new this.constructor(i)}removeLastTerminalAttributeAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){const r=t.getLastAttribute();r&&mt(r).terminal&&(e=e.editObjectAtIndex(n,(()=>t.removeAttribute(r))))})),new this.constructor(e)}removeBlockAttributesAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){t.hasAttributes()&&(e=e.editObjectAtIndex(n,(()=>t.copyWithoutAttributes())))})),new this.constructor(e)}expandRangeToLineBreaksAndSplitBlocks(t){let e;t=wt(t);let[i,n]=t;const r=this.locationFromPosition(i),o=this.locationFromPosition(n);let s=this;const a=s.getBlockAtIndex(r.index);if(r.offset=a.findLineBreakInDirectionFromPosition("backward",r.offset),null!=r.offset&&(e=s.positionFromLocation(r),s=s.insertBlockBreakAtRange([e,e+1]),o.index+=1,o.offset-=s.getBlockAtIndex(r.index).getLength(),r.index+=1),r.offset=0,0===o.offset&&o.index>r.index)o.index-=1,o.offset=s.getBlockAtIndex(o.index).getBlockBreakPosition();else{const t=s.getBlockAtIndex(o.index);"\n"===t.text.getStringAtRange([o.offset-1,o.offset])?o.offset-=1:o.offset=t.findLineBreakInDirectionFromPosition("forward",o.offset),o.offset!==t.getBlockBreakPosition()&&(e=s.positionFromLocation(o),s=s.insertBlockBreakAtRange([e,e+1]))}return i=s.positionFromLocation(r),n=s.positionFromLocation(o),{document:s,range:t=wt([i,n])}}convertLineBreaksToBlockBreaksInRange(t){t=wt(t);let[e]=t;const i=this.getStringAtRange(t).slice(0,-1);let n=this;return i.replace(/.*?\n/g,(function(t){e+=t.length,n=n.insertBlockBreakAtRange([e-1,e])})),{document:n,range:t}}consolidateBlocksAtRange(t){t=wt(t);const[e,i]=t,n=this.locationFromPosition(e).index,r=this.locationFromPosition(i).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(n,r))}getDocumentAtRange(t){t=wt(t);const e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e;const i=t=wt(t);return i[i.length-1]!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getBlockAtIndex(e)}getTextAtIndex(t){var e;return null===(e=this.getBlockAtIndex(t))||void 0===e?void 0:e.text}getTextAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getTextAtIndex(e)}getPieceAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getPieceAtPosition(i)}getCharacterAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getStringAtRange([i,i+1])}getLength(){return this.blockList.getEndPosition()}getBlocks(){return this.blockList.toArray()}getBlockCount(){return this.blockList.length}getEditCount(){return this.editCount}eachBlock(t){return this.blockList.eachObject(t)}eachBlockAtRange(t,e){let i,n;t=wt(t);const[r,o]=t,s=this.locationFromPosition(r),a=this.locationFromPosition(o);if(s.index===a.index)return i=this.getBlockAtIndex(s.index),n=[s.offset,a.offset],e(i,n,s.index);for(let t=s.index;t<=a.index;t++)if(i=this.getBlockAtIndex(t),i){switch(t){case s.index:n=[s.offset,i.text.getLength()];break;case a.index:n=[0,a.offset];break;default:n=[0,i.text.getLength()]}e(i,n,t)}}getCommonAttributesAtRange(t){t=wt(t);const[e]=t;if(Lt(t))return this.getCommonAttributesAtPosition(e);{const e=[],i=[];return this.eachBlockAtRange(t,(function(t,n){if(n[0]!==n[1])return e.push(t.text.getCommonAttributesAtRange(n)),i.push(ln(t))})),Ht.fromCommonAttributesOfObjects(e).merge(Ht.fromCommonAttributesOfObjects(i)).toObject()}}getCommonAttributesAtPosition(t){let e,i;const{index:n,offset:r}=this.locationFromPosition(t),o=this.getBlockAtIndex(n);if(!o)return{};const s=ln(o),a=o.text.getAttributesAtPosition(r),l=o.text.getAttributesAtPosition(r-1),c=Object.keys(W).filter((t=>W[t].inheritable));for(e in l)i=l[e],(i===a[e]||c.includes(e))&&(s[e]=i);return s}getRangeOfCommonAttributeAtPosition(t,e){const{index:i,offset:n}=this.locationFromPosition(e),r=this.getTextAtIndex(i),[o,s]=Array.from(r.getExpandedRangeForAttributeAtOffset(t,n)),a=this.positionFromLocation({index:i,offset:o}),l=this.positionFromLocation({index:i,offset:s});return wt([a,l])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e{const e=[];for(let r=0;r{let{text:i}=e;return t=t.concat(i.getAttachmentPieces())})),t}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getRangeOfAttachment(t){let e=0;const i=this.blockList.toArray();for(let n=0;n{const r=n.getLength();n.hasAttribute(t)&&i.push([e,e+r]),e+=r})),i}findRangesForTextAttribute(t){let{withValue:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=0,n=[];const r=[];return this.getPieces().forEach((o=>{const s=o.getLength();(function(i){return e?i.getAttribute(t)===e:i.hasAttribute(t)})(o)&&(n[1]===i?n[1]=i+s:r.push(n=[i,i+s])),i+=s})),r}locationFromPosition(t){const e=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t));if(null!=e.index)return e;{const t=this.getBlocks();return{index:t.length-1,offset:t[t.length-1].getLength()}}}positionFromLocation(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)}locationRangeFromPosition(t){return wt(this.locationFromPosition(t))}locationRangeFromRange(t){if(!(t=wt(t)))return;const[e,i]=Array.from(t),n=this.locationFromPosition(e),r=this.locationFromPosition(i);return wt([n,r])}rangeFromLocationRange(t){let e;t=wt(t);const i=this.positionFromLocation(t[0]);return Lt(t)||(e=this.positionFromLocation(t[1])),wt([i,e])}isEqualTo(t){return this.blockList.isEqualTo(null==t?void 0:t.blockList)}getTexts(){return this.getBlocks().map((t=>t.text))}getPieces(){const t=[];return Array.from(this.getTexts()).forEach((e=>{t.push(...Array.from(e.getPieces()||[]))})),t}getObjects(){return this.getBlocks().concat(this.getTexts()).concat(this.getPieces())}toSerializableDocument(){const t=[];return this.blockList.eachObject((e=>t.push(e.copyWithText(e.text.toSerializableText())))),new this.constructor(t)}toString(){return this.blockList.toString()}toJSON(){return this.blockList.toJSON()}toConsole(){return JSON.stringify(this.blockList.toArray().map((t=>JSON.parse(t.text.toConsole()))))}}const ln=function(t){const e={},i=t.getLastAttribute();return i&&(e[i]=!0),e},cn=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{string:t=Wt(t),attributes:e,type:"string"}},un=(t,e)=>{try{return JSON.parse(t.getAttribute("data-trix-".concat(e)))}catch(t){return{}}};class hn extends q{static parse(t,e){const i=new this(t,e);return i.parse(),i}constructor(t){let{referenceElement:e,purifyOptions:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.html=t,this.referenceElement=e,this.purifyOptions=i,this.blocks=[],this.blockElements=[],this.processedElements=[]}getDocument(){return an.fromJSON(this.blocks)}parse(){try{this.createHiddenContainer(),di.setHTML(this.containerElement,this.html,{purifyOptions:this.purifyOptions});const t=R(this.containerElement,{usingFilter:pn});for(;t.nextNode();)this.processNode(t.currentNode);return this.translateBlockElementMarginsToNewlines()}finally{this.removeHiddenContainer()}}createHiddenContainer(){return this.referenceElement?(this.containerElement=this.referenceElement.cloneNode(!1),this.containerElement.removeAttribute("id"),this.containerElement.setAttribute("data-trix-internal",""),this.containerElement.style.display="none",this.referenceElement.parentNode.insertBefore(this.containerElement,this.referenceElement.nextSibling)):(this.containerElement=T({tagName:"div",style:{display:"none"}}),document.body.appendChild(this.containerElement))}removeHiddenContainer(){return S(this.containerElement)}processNode(t){switch(t.nodeType){case Node.TEXT_NODE:if(!this.isInsignificantTextNode(t))return this.appendBlockForTextNode(t),this.processTextNode(t);break;case Node.ELEMENT_NODE:return this.appendBlockForElement(t),this.processElement(t)}}appendBlockForTextNode(t){const e=t.parentNode;if(e===this.currentBlockElement&&this.isBlockElement(t.previousSibling))return this.appendStringWithAttributes("\n");if(e===this.containerElement||this.isBlockElement(e)){var i;const t=this.getBlockAttributes(e),n=this.getBlockHTMLAttributes(e);ot(t,null===(i=this.currentBlock)||void 0===i?void 0:i.attributes)||(this.currentBlock=this.appendBlockForAttributesWithElement(t,e,n),this.currentBlockElement=e)}}appendBlockForElement(t){const e=this.isBlockElement(t),i=C(this.currentBlockElement,t);if(e&&!this.isBlockElement(t.firstChild)){if(!this.isInsignificantTextNode(t.firstChild)||!this.isBlockElement(t.firstElementChild)){const e=this.getBlockAttributes(t),n=this.getBlockHTMLAttributes(t);if(t.firstChild){if(i&&ot(e,this.currentBlock.attributes))return this.appendStringWithAttributes("\n");this.currentBlock=this.appendBlockForAttributesWithElement(e,t,n),this.currentBlockElement=t}}}else if(this.currentBlockElement&&!i&&!e){const e=this.findParentBlockElement(t);if(e)return this.appendBlockForElement(e);this.currentBlock=this.appendEmptyBlock(),this.currentBlockElement=null}}findParentBlockElement(t){let{parentElement:e}=t;for(;e&&e!==this.containerElement;){if(this.isBlockElement(e)&&this.blockElements.includes(e))return e;e=e.parentElement}return null}processTextNode(t){let e=t.data;var i;dn(t.parentNode)||(e=Vt(e),vn(null===(i=t.previousSibling)||void 0===i?void 0:i.textContent)&&(e=fn(e)));return this.appendStringWithAttributes(e,this.getTextAttributes(t.parentNode))}processElement(t){let e;if(P(t)){if(e=un(t,"attachment"),Object.keys(e).length){const i=this.getTextAttributes(t);this.appendAttachmentWithAttributes(e,i),t.innerHTML=""}return this.processedElements.push(t)}switch(k(t)){case"br":return this.isExtraBR(t)||this.isBlockElement(t.nextSibling)||this.appendStringWithAttributes("\n",this.getTextAttributes(t)),this.processedElements.push(t);case"img":e={url:t.getAttribute("src"),contentType:"image"};const i=(t=>{const e=t.getAttribute("width"),i=t.getAttribute("height"),n={};return e&&(n.width=parseInt(e,10)),i&&(n.height=parseInt(i,10)),n})(t);for(const t in i){const n=i[t];e[t]=n}return this.appendAttachmentWithAttributes(e,this.getTextAttributes(t)),this.processedElements.push(t);case"tr":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(j.tableRowSeparator);break;case"td":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(j.tableCellSeparator)}}appendBlockForAttributesWithElement(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.blockElements.push(e);const n=function(){return{text:[],attributes:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},htmlAttributes:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}}}(t,i);return this.blocks.push(n),n}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,e){return this.appendPiece(cn(t,e))}appendAttachmentWithAttributes(t,e){return this.appendPiece(function(t){return{attachment:t,attributes:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},type:"attachment"}}(t,e))}appendPiece(t){return 0===this.blocks.length&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,e){const{text:i}=this.blocks[e],n=i[i.length-1];if("string"!==(null==n?void 0:n.type))return i.push(cn(t));n.string+=t}prependStringToTextAtIndex(t,e){const{text:i}=this.blocks[e],n=i[0];if("string"!==(null==n?void 0:n.type))return i.unshift(cn(t));n.string=t+n.string}getTextAttributes(t){let e;const i={};for(const n in W){const r=W[n];if(r.tagName&&y(t,{matchingSelector:r.tagName,untilNode:this.containerElement}))i[n]=!0;else if(r.parser){if(e=r.parser(t),e){let o=!1;for(const i of this.findBlockElementAncestors(t))if(r.parser(i)===e){o=!0;break}o||(i[n]=e)}}else r.styleProperty&&(e=t.style[r.styleProperty],e&&(i[n]=e))}if(P(t)){const n=un(t,"attributes");for(const t in n)e=n[t],i[t]=e}return i}getBlockAttributes(t){const e=[];for(;t&&t!==this.containerElement;){for(const r in n){const o=n[r];var i;!1!==o.parse&&k(t)===o.tagName&&(null!==(i=o.test)&&void 0!==i&&i.call(o,t)||!o.test)&&(e.push(r),o.listAttribute&&e.push(o.listAttribute))}t=t.parentNode}return e.reverse()}getBlockHTMLAttributes(t){const e={},i=Object.values(n).find((e=>e.tagName===k(t)));return((null==i?void 0:i.htmlAttributes)||[]).forEach((i=>{t.hasAttribute(i)&&(e[i]=t.getAttribute(i))})),e}findBlockElementAncestors(t){const e=[];for(;t&&t!==this.containerElement;){const i=k(t);L().includes(i)&&e.push(t),t=t.parentNode}return e}isBlockElement(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE&&!P(t)&&!y(t,{matchingSelector:"td",untilNode:this.containerElement}))return L().includes(k(t))||"block"===window.getComputedStyle(t).display}isInsignificantTextNode(t){if((null==t?void 0:t.nodeType)!==Node.TEXT_NODE)return;if(!bn(t.data))return;const{parentNode:e,previousSibling:i,nextSibling:n}=t;return gn(e.previousSibling)&&!this.isBlockElement(e.previousSibling)||dn(e)?void 0:!i||this.isBlockElement(i)||!n||this.isBlockElement(n)}isExtraBR(t){return"br"===k(t)&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if(j.removeBlankTableCells){var e;const i=null===(e=t.previousSibling)||void 0===e?void 0:e.textContent;return i&&/\S/.test(i)}return t.previousSibling}translateBlockElementMarginsToNewlines(){const t=this.getMarginOfDefaultBlockElement();for(let e=0;e2*t.top&&this.prependStringToTextAtIndex("\n",e),i.bottom>2*t.bottom&&this.appendStringToTextAtIndex("\n",e))}}getMarginOfBlockElementAtIndex(t){const e=this.blockElements[t];if(e&&e.textContent&&!L().includes(k(e))&&!this.processedElements.includes(e))return mn(e)}getMarginOfDefaultBlockElement(){const t=T(n.default.tagName);return this.containerElement.appendChild(t),mn(t)}}const dn=function(t){const{whiteSpace:e}=window.getComputedStyle(t);return["pre","pre-wrap","pre-line"].includes(e)},gn=t=>t&&!vn(t.textContent),mn=function(t){const e=window.getComputedStyle(t);if("block"===e.display)return{top:parseInt(e.marginTop),bottom:parseInt(e.marginBottom)}},pn=function(t){return"style"===k(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},fn=t=>t.replace(new RegExp("^".concat(Ut.source,"+")),""),bn=t=>new RegExp("^".concat(Ut.source,"*$")).test(t),vn=t=>/\s$/.test(t),An=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],yn="data-trix-serialized-attributes",xn="[".concat(yn,"]"),Cn=new RegExp("\x3c!--block--\x3e","g"),En={"application/json":function(t){let e;if(t instanceof an)e=t;else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");e=hn.parse(t.innerHTML).getDocument()}return e.toSerializableDocument().toJSONString()},"text/html":function(t){let e;if(t instanceof an)e=Si.render(t);else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");e=t.cloneNode(!0)}return Array.from(e.querySelectorAll("[data-trix-serialize=false]")).forEach((t=>{S(t)})),An.forEach((t=>{Array.from(e.querySelectorAll("[".concat(t,"]"))).forEach((e=>{e.removeAttribute(t)}))})),Array.from(e.querySelectorAll(xn)).forEach((t=>{try{const e=JSON.parse(t.getAttribute(yn));t.removeAttribute(yn);for(const i in e){const n=e[i];t.setAttribute(i,n)}}catch(t){}})),e.innerHTML.replace(Cn,"")}};var Sn=Object.freeze({__proto__:null});class Rn extends q{constructor(t,e){super(...arguments),this.attachmentManager=t,this.attachment=e,this.id=this.attachment.id,this.file=this.attachment.file}remove(){return this.attachmentManager.requestRemovalOfAttachment(this.attachment)}}Rn.proxyMethod("attachment.getAttribute"),Rn.proxyMethod("attachment.hasAttribute"),Rn.proxyMethod("attachment.setAttribute"),Rn.proxyMethod("attachment.getAttributes"),Rn.proxyMethod("attachment.setAttributes"),Rn.proxyMethod("attachment.isPending"),Rn.proxyMethod("attachment.isPreviewable"),Rn.proxyMethod("attachment.getURL"),Rn.proxyMethod("attachment.getHref"),Rn.proxyMethod("attachment.getFilename"),Rn.proxyMethod("attachment.getFilesize"),Rn.proxyMethod("attachment.getFormattedFilesize"),Rn.proxyMethod("attachment.getExtension"),Rn.proxyMethod("attachment.getContentType"),Rn.proxyMethod("attachment.getFile"),Rn.proxyMethod("attachment.setFile"),Rn.proxyMethod("attachment.releaseFile"),Rn.proxyMethod("attachment.getUploadProgress"),Rn.proxyMethod("attachment.setUploadProgress");class kn extends q{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.managedAttachments={},Array.from(t).forEach((t=>{this.manageAttachment(t)}))}getAttachments(){const t=[];for(const e in this.managedAttachments){const i=this.managedAttachments[e];t.push(i)}return t}manageAttachment(t){return this.managedAttachments[t.id]||(this.managedAttachments[t.id]=new Rn(this,t)),this.managedAttachments[t.id]}attachmentIsManaged(t){return t.id in this.managedAttachments}requestRemovalOfAttachment(t){var e,i;if(this.attachmentIsManaged(t))return null===(e=this.delegate)||void 0===e||null===(i=e.attachmentManagerDidRequestRemovalOfAttachment)||void 0===i?void 0:i.call(e,t)}unmanageAttachment(t){const e=this.managedAttachments[t.id];return delete this.managedAttachments[t.id],e}}class Tn{constructor(t){this.composition=t,this.document=this.composition.document;const e=this.composition.getSelectedRange();this.startPosition=e[0],this.endPosition=e[1],this.startLocation=this.document.locationFromPosition(this.startPosition),this.endLocation=this.document.locationFromPosition(this.endPosition),this.block=this.document.getBlockAtIndex(this.endLocation.index),this.breaksOnReturn=this.block.breaksOnReturn(),this.previousCharacter=this.block.text.getStringAtPosition(this.endLocation.offset-1),this.nextCharacter=this.block.text.getStringAtPosition(this.endLocation.offset)}shouldInsertBlockBreak(){return this.block.hasAttributes()&&this.block.isListItem()&&!this.block.isEmpty()?0!==this.startLocation.offset:this.breaksOnReturn&&"\n"!==this.nextCharacter}shouldBreakFormattedBlock(){return this.block.hasAttributes()&&!this.block.isListItem()&&(this.breaksOnReturn&&"\n"===this.nextCharacter||"\n"===this.previousCharacter)}shouldDecreaseListLevel(){return this.block.hasAttributes()&&this.block.isListItem()&&this.block.isEmpty()}shouldPrependListItem(){return this.block.isListItem()&&0===this.startLocation.offset&&!this.block.isEmpty()}shouldRemoveLastBlockAttribute(){return this.block.hasAttributes()&&!this.block.isListItem()&&this.block.isEmpty()}}class wn extends q{constructor(){super(...arguments),this.document=new an,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){var e,i;if(!t.isEqualTo(this.document))return this.document=t,this.refreshAttachments(),this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidChangeDocument)||void 0===i?void 0:i.call(e,t)}getSnapshot(){return{document:this.document,selectedRange:this.getSelectedRange()}}loadSnapshot(t){var e,i,n,r;let{document:o,selectedRange:s}=t;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionWillLoadSnapshot)||void 0===i||i.call(e),this.setDocument(null!=o?o:new an),this.setSelection(null!=s?s:[0,0]),null===(n=this.delegate)||void 0===n||null===(r=n.compositionDidLoadSnapshot)||void 0===r?void 0:r.call(n)}insertText(t){let{updatePosition:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{updatePosition:!0};const i=this.getSelectedRange();this.setDocument(this.document.insertTextAtRange(t,i));const n=i[0],r=n+t.getLength();return e&&this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}insertBlock(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Xi;const e=new an([t]);return this.insertDocument(e)}insertDocument(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new an;const e=this.getSelectedRange();this.setDocument(this.document.insertDocumentAtRange(t,e));const i=e[0],n=i+t.getLength();return this.setSelection(n),this.notifyDelegateOfInsertionAtRange([i,n])}insertString(t,e){const i=this.getCurrentTextAttributes(),n=Yi.textForStringWithAttributes(t,i);return this.insertText(n,e)}insertBlockBreak(){const t=this.getSelectedRange();this.setDocument(this.document.insertBlockBreakAtRange(t));const e=t[0],i=e+1;return this.setSelection(i),this.notifyDelegateOfInsertionAtRange([e,i])}insertLineBreak(){const t=new Tn(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){const e=new an([t.block.copyWithoutText()]);return this.insertDocument(e)}return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString("\n")}insertHTML(t){const e=hn.parse(t,{purifyOptions:{SAFE_FOR_XML:!0}}).getDocument(),i=this.getSelectedRange();this.setDocument(this.document.mergeDocumentAtRange(e,i));const n=i[0],r=n+e.getLength()-1;return this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}replaceHTML(t){const e=hn.parse(t).getDocument().copyUsingObjectsFromDocument(this.document),i=this.getLocationRange({strict:!1}),n=this.document.rangeFromLocationRange(i);return this.setDocument(e),this.setSelection(n)}insertFile(t){return this.insertFiles([t])}insertFiles(t){const e=[];return Array.from(t).forEach((t=>{var i;if(null!==(i=this.delegate)&&void 0!==i&&i.compositionShouldAcceptFile(t)){const i=Vi.attachmentForFile(t);e.push(i)}})),this.insertAttachments(e)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let e=new Yi;return Array.from(t).forEach((t=>{var n;const r=t.getType(),o=null===(n=i[r])||void 0===n?void 0:n.presentation,s=this.getCurrentTextAttributes();o&&(s.presentation=o);const a=Yi.textForAttachmentWithAttributes(t,s);e=e.appendText(a)})),this.insertText(e)}shouldManageDeletingInDirection(t){const e=this.getLocationRange();if(Lt(e)){if("backward"===t&&0===e[0].offset)return!0;if(this.shouldManageMovingCursorInDirection(t))return!0}else if(e[0].index!==e[1].index)return!0;return!1}deleteInDirection(t){let e,i,n,{length:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=this.getLocationRange();let s=this.getSelectedRange();const a=Lt(s);if(a?i="backward"===t&&0===o[0].offset:n=o[0].index!==o[1].index,i&&this.canDecreaseBlockAttributeLevel()){const t=this.getBlock();if(t.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(s[0]),t.isEmpty())return!1}return a&&(s=this.getExpandedRangeInDirection(t,{length:r}),"backward"===t&&(e=this.getAttachmentAtRange(s))),e?(this.editAttachment(e),!1):(this.setDocument(this.document.removeTextAtRange(s)),this.setSelection(s[0]),!i&&!n&&void 0)}moveTextFromRange(t){const[e]=Array.from(this.getSelectedRange());return this.setDocument(this.document.moveTextFromRangeToPosition(t,e)),this.setSelection(e)}removeAttachment(t){const e=this.document.getRangeOfAttachment(t);if(e)return this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(e)),this.setSelection(e[0])}removeLastBlockAttribute(){const[t,e]=Array.from(this.getSelectedRange()),i=this.document.getBlockAtPosition(e);return this.removeCurrentAttribute(i.getLastAttribute()),this.setSelection(t)}insertPlaceholder(){return this.placeholderPosition=this.getPosition(),this.insertString(" ")}selectPlaceholder(){if(null!=this.placeholderPosition)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+1]),this.getSelectedRange()}forgetPlaceholder(){this.placeholderPosition=null}hasCurrentAttribute(t){const e=this.currentAttributes[t];return null!=e&&!1!==e}toggleCurrentAttribute(t){const e=!this.currentAttributes[t];return e?this.setCurrentAttribute(t,e):this.removeCurrentAttribute(t)}canSetCurrentAttribute(t){return mt(t)?this.canSetCurrentBlockAttribute(t):this.canSetCurrentTextAttribute(t)}canSetCurrentTextAttribute(t){const e=this.getSelectedDocument();if(e){for(const t of Array.from(e.getAttachments()))if(!t.hasContent())return!1;return!0}}canSetCurrentBlockAttribute(t){const e=this.getBlock();if(e)return!e.isTerminalBlock()}setCurrentAttribute(t,e){return mt(t)?this.setBlockAttribute(t,e):(this.setTextAttribute(t,e),this.currentAttributes[t]=e,this.notifyDelegateOfCurrentAttributesChange())}setHTMLAtributeAtPosition(t,e,i){var n;const r=this.document.getBlockAtPosition(t),o=null===(n=mt(r.getLastAttribute()))||void 0===n?void 0:n.htmlAttributes;if(r&&null!=o&&o.includes(e)){const n=this.document.setHTMLAttributeAtPosition(t,e,i);this.setDocument(n)}}setTextAttribute(t,e){const i=this.getSelectedRange();if(!i)return;const[n,r]=Array.from(i);if(n!==r)return this.setDocument(this.document.addAttributeAtRange(t,e,i));if("href"===t){const t=Yi.textForStringWithAttributes(e,{href:e});return this.insertText(t)}}setBlockAttribute(t,e){const i=this.getSelectedRange();if(this.canSetCurrentAttribute(t))return this.setDocument(this.document.applyBlockAttributeAtRange(t,e,i)),this.setSelection(i)}removeCurrentAttribute(t){return mt(t)?(this.removeBlockAttribute(t),this.updateCurrentAttributes()):(this.removeTextAttribute(t),delete this.currentAttributes[t],this.notifyDelegateOfCurrentAttributesChange())}removeTextAttribute(t){const e=this.getSelectedRange();if(e)return this.setDocument(this.document.removeAttributeAtRange(t,e))}removeBlockAttribute(t){const e=this.getSelectedRange();if(e)return this.setDocument(this.document.removeAttributeAtRange(t,e))}canDecreaseNestingLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getNestingLevel())>0}canIncreaseNestingLevel(){var t;const e=this.getBlock();if(e){if(null===(t=mt(e.getLastNestableAttribute()))||void 0===t||!t.listAttribute)return e.getNestingLevel()>0;{const t=this.getPreviousBlock();if(t)return function(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return ot((arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).slice(0,t.length),t)}(t.getListItemAttributes(),e.getListItemAttributes())}}}decreaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.decreaseNestingLevel()))}increaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.increaseNestingLevel()))}canDecreaseBlockAttributeLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getAttributeLevel())>0}decreaseBlockAttributeLevel(){var t;const e=null===(t=this.getBlock())||void 0===t?void 0:t.getLastAttribute();if(e)return this.removeCurrentAttribute(e)}decreaseListLevel(){let[t]=Array.from(this.getSelectedRange());const{index:e}=this.document.locationFromPosition(t);let i=e;const n=this.getBlock().getAttributeLevel();let r=this.document.getBlockAtIndex(i+1);for(;r&&r.isListItem()&&!(r.getAttributeLevel()<=n);)i++,r=this.document.getBlockAtIndex(i+1);t=this.document.positionFromLocation({index:e,offset:0});const o=this.document.positionFromLocation({index:i,offset:0});return this.setDocument(this.document.removeLastListAttributeAtRange([t,o]))}updateCurrentAttributes(){const t=this.getSelectedRange({ignoreLock:!0});if(t){const e=this.document.getCommonAttributesAtRange(t);if(Array.from(gt()).forEach((t=>{e[t]||this.canSetCurrentAttribute(t)||(e[t]=!1)})),!Tt(e,this.currentAttributes))return this.currentAttributes=e,this.notifyDelegateOfCurrentAttributesChange()}}getCurrentAttributes(){return m.call({},this.currentAttributes)}getCurrentTextAttributes(){const t={};for(const e in this.currentAttributes){const i=this.currentAttributes[e];!1!==i&&ft(e)&&(t[e]=i)}return t}freezeSelection(){return this.setCurrentAttribute("frozen",!0)}thawSelection(){return this.removeCurrentAttribute("frozen")}hasFrozenSelection(){return this.hasCurrentAttribute("frozen")}setSelection(t){var e;const i=this.document.locationRangeFromRange(t);return null===(e=this.delegate)||void 0===e?void 0:e.compositionDidRequestChangingSelectionToLocationRange(i)}getSelectedRange(){const t=this.getLocationRange();if(t)return this.document.rangeFromLocationRange(t)}setSelectedRange(t){const e=this.document.locationRangeFromRange(t);return this.getSelectionManager().setLocationRange(e)}getPosition(){const t=this.getLocationRange();if(t)return this.document.positionFromLocation(t[0])}getLocationRange(t){return this.targetLocationRange?this.targetLocationRange:this.getSelectionManager().getLocationRange(t)||wt({index:0,offset:0})}withTargetLocationRange(t,e){let i;this.targetLocationRange=t;try{i=e()}finally{this.targetLocationRange=null}return i}withTargetRange(t,e){const i=this.document.locationRangeFromRange(t);return this.withTargetLocationRange(i,e)}withTargetDOMRange(t,e){const i=this.createLocationRangeFromDOMRange(t,{strict:!1});return this.withTargetLocationRange(i,e)}getExpandedRangeInDirection(t){let{length:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[i,n]=Array.from(this.getSelectedRange());return"backward"===t?e?i-=e:i=this.translateUTF16PositionFromOffset(i,-1):e?n+=e:n=this.translateUTF16PositionFromOffset(n,1),wt([i,n])}shouldManageMovingCursorInDirection(t){if(this.editingAttachment)return!0;const e=this.getExpandedRangeInDirection(t);return null!=this.getAttachmentAtRange(e)}moveCursorInDirection(t){let e,i;if(this.editingAttachment)i=this.document.getRangeOfAttachment(this.editingAttachment);else{const n=this.getSelectedRange();i=this.getExpandedRangeInDirection(t),e=!Dt(n,i)}if("backward"===t?this.setSelectedRange(i[0]):this.setSelectedRange(i[1]),e){const t=this.getAttachmentAtRange(i);if(t)return this.editAttachment(t)}}expandSelectionInDirection(t){let{length:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.getExpandedRangeInDirection(t,{length:e});return this.setSelectedRange(i)}expandSelectionForEditing(){if(this.hasCurrentAttribute("href"))return this.expandSelectionAroundCommonAttribute("href")}expandSelectionAroundCommonAttribute(t){const e=this.getPosition(),i=this.document.getRangeOfCommonAttributeAtPosition(t,e);return this.setSelectedRange(i)}selectionContainsAttachments(){var t;return(null===(t=this.getSelectedAttachments())||void 0===t?void 0:t.length)>0}selectionIsInCursorTarget(){return this.editingAttachment||this.positionIsCursorTarget(this.getPosition())}positionIsCursorTarget(t){const e=this.document.locationFromPosition(t);if(e)return this.locationIsCursorTarget(e)}positionIsBlockBreak(t){var e;return null===(e=this.document.getPieceAtPosition(t))||void 0===e?void 0:e.isBlockBreak()}getSelectedDocument(){const t=this.getSelectedRange();if(t)return this.document.getDocumentAtRange(t)}getSelectedAttachments(){var t;return null===(t=this.getSelectedDocument())||void 0===t?void 0:t.getAttachments()}getAttachments(){return this.attachments.slice(0)}refreshAttachments(){const t=this.document.getAttachments(),{added:e,removed:i}=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const i=[],n=[],r=new Set;t.forEach((t=>{r.add(t)}));const o=new Set;return e.forEach((t=>{o.add(t),r.has(t)||i.push(t)})),t.forEach((t=>{o.has(t)||n.push(t)})),{added:i,removed:n}}(this.attachments,t);return this.attachments=t,Array.from(i).forEach((t=>{var e,i;t.delegate=null,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidRemoveAttachment)||void 0===i||i.call(e,t)})),(()=>{const t=[];return Array.from(e).forEach((e=>{var i,n;e.delegate=this,t.push(null===(i=this.delegate)||void 0===i||null===(n=i.compositionDidAddAttachment)||void 0===n?void 0:n.call(i,e))})),t})()}attachmentDidChangeAttributes(t){var e,i;return this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidEditAttachment)||void 0===i?void 0:i.call(e,t)}attachmentDidChangePreviewURL(t){var e,i;return this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidChangeAttachmentPreviewURL)||void 0===i?void 0:i.call(e,t)}editAttachment(t,e){var i,n;if(t!==this.editingAttachment)return this.stopEditingAttachment(),this.editingAttachment=t,null===(i=this.delegate)||void 0===i||null===(n=i.compositionDidStartEditingAttachment)||void 0===n?void 0:n.call(i,this.editingAttachment,e)}stopEditingAttachment(){var t,e;this.editingAttachment&&(null===(t=this.delegate)||void 0===t||null===(e=t.compositionDidStopEditingAttachment)||void 0===e||e.call(t,this.editingAttachment),this.editingAttachment=null)}updateAttributesForAttachment(t,e){return this.setDocument(this.document.updateAttributesForAttachment(t,e))}removeAttributeForAttachment(t,e){return this.setDocument(this.document.removeAttributeForAttachment(t,e))}breakFormattedBlock(t){let{document:e}=t;const{block:i}=t;let n=t.startPosition,r=[n-1,n];i.getBlockBreakPosition()===t.startLocation.offset?(i.breaksOnReturn()&&"\n"===t.nextCharacter?n+=1:e=e.removeTextAtRange(r),r=[n,n]):"\n"===t.nextCharacter?"\n"===t.previousCharacter?r=[n-1,n+1]:(r=[n,n+1],n+=1):t.startLocation.offset-1!=0&&(n+=1);const o=new an([i.removeLastAttribute().copyWithoutText()]);return this.setDocument(e.insertDocumentAtRange(o,r)),this.setSelection(n)}getPreviousBlock(){const t=this.getLocationRange();if(t){const{index:e}=t[0];if(e>0)return this.document.getBlockAtIndex(e-1)}}getBlock(){const t=this.getLocationRange();if(t)return this.document.getBlockAtIndex(t[0].index)}getAttachmentAtRange(t){const e=this.document.getDocumentAtRange(t);if(e.toString()==="".concat("","\n"))return e.getAttachments()[0]}notifyDelegateOfCurrentAttributesChange(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.compositionDidChangeCurrentAttributes)||void 0===e?void 0:e.call(t,this.currentAttributes)}notifyDelegateOfInsertionAtRange(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidPerformInsertionAtRange)||void 0===i?void 0:i.call(e,t)}translateUTF16PositionFromOffset(t,e){const i=this.document.toUTF16String(),n=i.offsetFromUCS2Offset(t);return i.offsetToUCS2Offset(n+e)}}wn.proxyMethod("getSelectionManager().getPointRange"),wn.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"),wn.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"),wn.proxyMethod("getSelectionManager().locationIsCursorTarget"),wn.proxyMethod("getSelectionManager().selectionIsExpanded"),wn.proxyMethod("delegate?.getSelectionManager");class Ln extends q{constructor(t){super(...arguments),this.composition=t,this.undoEntries=[],this.redoEntries=[]}recordUndoEntry(t){let{context:e,consolidatable:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.undoEntries.slice(-1)[0];if(!i||!Dn(n,t,e)){const i=this.createEntry({description:t,context:e});this.undoEntries.push(i),this.redoEntries=[]}}undo(){const t=this.undoEntries.pop();if(t){const e=this.createEntry(t);return this.redoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}redo(){const t=this.redoEntries.pop();if(t){const e=this.createEntry(t);return this.undoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}canUndo(){return this.undoEntries.length>0}canRedo(){return this.redoEntries.length>0}createEntry(){let{description:t,context:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{description:null==t?void 0:t.toString(),context:JSON.stringify(e),snapshot:this.composition.getSnapshot()}}}const Dn=(t,e,i)=>(null==t?void 0:t.description)===(null==e?void 0:e.toString())&&(null==t?void 0:t.context)===JSON.stringify(i),Nn="attachmentGallery";class In{constructor(t){this.document=t.document,this.selectedRange=t.selectedRange}perform(){return this.removeBlockAttribute(),this.applyBlockAttribute()}getSnapshot(){return{document:this.document,selectedRange:this.selectedRange}}removeBlockAttribute(){return this.findRangesOfBlocks().map((t=>this.document=this.document.removeAttributeAtRange(Nn,t)))}applyBlockAttribute(){let t=0;this.findRangesOfPieces().forEach((e=>{e[1]-e[0]>1&&(e[0]+=t,e[1]+=t,"\n"!==this.document.getCharacterAtPosition(e[1])&&(this.document=this.document.insertBlockBreakAtRange(e[1]),e[1]0&&void 0!==arguments[0]?arguments[0]:"";const e=hn.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(e)}loadJSON(t){let{document:e,selectedRange:i}=t;return e=an.fromJSON(e),this.loadSnapshot({document:e,selectedRange:i})}loadSnapshot(t){return this.undoManager=new Ln(this.composition),this.composition.loadSnapshot(t)}getDocument(){return this.composition.document}getSelectedDocument(){return this.composition.getSelectedDocument()}getSnapshot(){return this.composition.getSnapshot()}toJSON(){return this.getSnapshot()}deleteInDirection(t){return this.composition.deleteInDirection(t)}insertAttachment(t){return this.composition.insertAttachment(t)}insertAttachments(t){return this.composition.insertAttachments(t)}insertDocument(t){return this.composition.insertDocument(t)}insertFile(t){return this.composition.insertFile(t)}insertFiles(t){return this.composition.insertFiles(t)}insertHTML(t){return this.composition.insertHTML(t)}insertString(t){return this.composition.insertString(t)}insertText(t){return this.composition.insertText(t)}insertLineBreak(){return this.composition.insertLineBreak()}getSelectedRange(){return this.composition.getSelectedRange()}getPosition(){return this.composition.getPosition()}getClientRectAtPosition(t){const e=this.getDocument().locationRangeFromRange([t,t+1]);return this.selectionManager.getClientRectAtLocationRange(e)}expandSelectionInDirection(t){return this.composition.expandSelectionInDirection(t)}moveCursorInDirection(t){return this.composition.moveCursorInDirection(t)}setSelectedRange(t){return this.composition.setSelectedRange(t)}activateAttribute(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.composition.setCurrentAttribute(t,e)}attributeIsActive(t){return this.composition.hasCurrentAttribute(t)}canActivateAttribute(t){return this.composition.canSetCurrentAttribute(t)}deactivateAttribute(t){return this.composition.removeCurrentAttribute(t)}setHTMLAtributeAtPosition(t,e,i){this.composition.setHTMLAtributeAtPosition(t,e,i)}canDecreaseNestingLevel(){return this.composition.canDecreaseNestingLevel()}canIncreaseNestingLevel(){return this.composition.canIncreaseNestingLevel()}decreaseNestingLevel(){if(this.canDecreaseNestingLevel())return this.composition.decreaseNestingLevel()}increaseNestingLevel(){if(this.canIncreaseNestingLevel())return this.composition.increaseNestingLevel()}canRedo(){return this.undoManager.canRedo()}canUndo(){return this.undoManager.canUndo()}recordUndoEntry(t){let{context:e,consolidatable:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.undoManager.recordUndoEntry(t,{context:e,consolidatable:i})}redo(){if(this.canRedo())return this.undoManager.redo()}undo(){if(this.canUndo())return this.undoManager.undo()}}class Mn{constructor(t){this.element=t}findLocationFromContainerAndOffset(t,e){let{strict:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},n=0,r=!1;const o={index:0,offset:0},s=this.findAttachmentElementParentForNode(t);s&&(t=s.parentNode,e=E(s));const a=R(this.element,{usingFilter:Wn});for(;a.nextNode();){const s=a.currentNode;if(s===t&&B(t)){F(s)||(o.offset+=e);break}if(s.parentNode===t){if(n++===e)break}else if(!C(t,s)&&n>0)break;N(s,{strict:i})?(r&&o.index++,o.offset=0,r=!0):o.offset+=Bn(s)}return o}findContainerAndOffsetFromLocation(t){let e,i;if(0===t.index&&0===t.offset){for(e=this.element,i=0;e.firstChild;)if(e=e.firstChild,D(e)){i=1;break}return[e,i]}let[n,r]=this.findNodeAndOffsetFromLocation(t);if(n){if(B(n))0===Bn(n)?(e=n.parentNode.parentNode,i=E(n.parentNode),F(n,{name:"right"})&&i++):(e=n,i=t.offset-r);else{if(e=n.parentNode,!N(n.previousSibling)&&!D(e))for(;n===e.lastChild&&(n=e,e=e.parentNode,!D(e)););i=E(n),0!==t.offset&&i++}return[e,i]}}findNodeAndOffsetFromLocation(t){let e,i,n=0;for(const r of this.getSignificantNodesForIndex(t.index)){const o=Bn(r);if(t.offset<=n+o)if(B(r)){if(e=r,i=n,t.offset===i&&F(e))break}else e||(e=r,i=n);if(n+=o,n>t.offset)break}return[e,i]}findAttachmentElementParentForNode(t){for(;t&&t!==this.element;){if(P(t))return t;t=t.parentNode}}getSignificantNodesForIndex(t){const e=[],i=R(this.element,{usingFilter:_n});let n=!1;for(;i.nextNode();){const o=i.currentNode;var r;if(I(o)){if(null!=r?r++:r=0,r===t)n=!0;else if(n)break}else n&&e.push(o)}return e}}const Bn=function(t){return t.nodeType===Node.TEXT_NODE?F(t)?0:t.textContent.length:"br"===k(t)||P(t)?1:0},_n=function(t){return jn(t)===NodeFilter.FILTER_ACCEPT?Wn(t):NodeFilter.FILTER_REJECT},jn=function(t){return M(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},Wn=function(t){return P(t.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT};class Un{createDOMRangeFromPoint(t){let e,{x:i,y:n}=t;if(document.caretPositionFromPoint){const{offsetNode:t,offset:r}=document.caretPositionFromPoint(i,n);return e=document.createRange(),e.setStart(t,r),e}if(document.caretRangeFromPoint)return document.caretRangeFromPoint(i,n);if(document.body.createTextRange){const r=Mt();try{const t=document.body.createTextRange();t.moveToPoint(i,n),t.select()}catch(t){}return e=Mt(),Bt(r),e}}getClientRectsForDOMRange(t){const e=Array.from(t.getClientRects());return[e[0],e[e.length-1]]}}class Vn extends q{constructor(t){super(...arguments),this.didMouseDown=this.didMouseDown.bind(this),this.selectionDidChange=this.selectionDidChange.bind(this),this.element=t,this.locationMapper=new Mn(this.element),this.pointMapper=new Un,this.lockCount=0,b("mousedown",{onElement:this.element,withCallback:this.didMouseDown})}getLocationRange(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!1===t.strict?this.createLocationRangeFromDOMRange(Mt()):t.ignoreLock?this.currentLocationRange:this.lockedLocationRange?this.lockedLocationRange:this.currentLocationRange}setLocationRange(t){if(this.lockedLocationRange)return;t=wt(t);const e=this.createDOMRangeFromLocationRange(t);e&&(Bt(e),this.updateCurrentLocationRange(t))}setLocationRangeFromPointRange(t){t=wt(t);const e=this.getLocationAtPoint(t[0]),i=this.getLocationAtPoint(t[1]);this.setLocationRange([e,i])}getClientRectAtLocationRange(t){const e=this.createDOMRangeFromLocationRange(t);if(e)return this.getClientRectsForDOMRange(e)[1]}locationIsCursorTarget(t){const e=Array.from(this.findNodeAndOffsetFromLocation(t))[0];return F(e)}lock(){0==this.lockCount++&&(this.updateCurrentLocationRange(),this.lockedLocationRange=this.getLocationRange())}unlock(){if(0==--this.lockCount){const{lockedLocationRange:t}=this;if(this.lockedLocationRange=null,null!=t)return this.setLocationRange(t)}}clearSelection(){var t;return null===(t=Pt())||void 0===t?void 0:t.removeAllRanges()}selectionIsCollapsed(){var t;return!0===(null===(t=Mt())||void 0===t?void 0:t.collapsed)}selectionIsExpanded(){return!this.selectionIsCollapsed()}createLocationRangeFromDOMRange(t,e){if(null==t||!this.domRangeWithinElement(t))return;const i=this.findLocationFromContainerAndOffset(t.startContainer,t.startOffset,e);if(!i)return;const n=t.collapsed?void 0:this.findLocationFromContainerAndOffset(t.endContainer,t.endOffset,e);return wt([i,n])}didMouseDown(){return this.pauseTemporarily()}pauseTemporarily(){let t;this.paused=!0;const e=()=>{if(this.paused=!1,clearTimeout(i),Array.from(t).forEach((t=>{t.destroy()})),C(document,this.element))return this.selectionDidChange()},i=setTimeout(e,200);t=["mousemove","keydown"].map((t=>b(t,{onElement:document,withCallback:e})))}selectionDidChange(){if(!this.paused&&!x(this.element))return this.updateCurrentLocationRange()}updateCurrentLocationRange(t){var e,i;if((null!=t?t:t=this.createLocationRangeFromDOMRange(Mt()))&&!Dt(t,this.currentLocationRange))return this.currentLocationRange=t,null===(e=this.delegate)||void 0===e||null===(i=e.locationRangeDidChange)||void 0===i?void 0:i.call(e,this.currentLocationRange.slice(0))}createDOMRangeFromLocationRange(t){const e=this.findContainerAndOffsetFromLocation(t[0]),i=Lt(t)?e:this.findContainerAndOffsetFromLocation(t[1])||e;if(null!=e&&null!=i){const t=document.createRange();return t.setStart(...Array.from(e||[])),t.setEnd(...Array.from(i||[])),t}}getLocationAtPoint(t){const e=this.createDOMRangeFromPoint(t);var i;if(e)return null===(i=this.createLocationRangeFromDOMRange(e))||void 0===i?void 0:i[0]}domRangeWithinElement(t){return t.collapsed?C(this.element,t.startContainer):C(this.element,t.startContainer)&&C(this.element,t.endContainer)}}Vn.proxyMethod("locationMapper.findLocationFromContainerAndOffset"),Vn.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"),Vn.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"),Vn.proxyMethod("pointMapper.createDOMRangeFromPoint"),Vn.proxyMethod("pointMapper.getClientRectsForDOMRange");var qn=Object.freeze({__proto__:null,Attachment:Vi,AttachmentManager:kn,AttachmentPiece:zi,Block:Xi,Composition:wn,Document:an,Editor:Pn,HTMLParser:hn,HTMLSanitizer:di,LineBreakInsertion:Tn,LocationMapper:Mn,ManagedAttachment:Rn,Piece:Wi,PointMapper:Un,SelectionManager:Vn,SplittableList:Hi,StringPiece:qi,Text:Yi,UndoManager:Ln}),Hn=Object.freeze({__proto__:null,ObjectView:ie,AttachmentView:pi,BlockView:Ei,DocumentView:Si,PieceView:Ai,PreviewableAttachmentView:vi,TextView:yi});const{lang:zn,css:Jn,keyNames:Kn}=H,Gn=function(t){return function(){const e=t.apply(this,arguments);e.do(),this.undos||(this.undos=[]),this.undos.push(e.undo)}};class Yn extends q{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(...arguments),Di(this,"makeElementMutable",Gn((()=>({do:()=>{this.element.dataset.trixMutable=!0},undo:()=>delete this.element.dataset.trixMutable})))),Di(this,"addToolbar",Gn((()=>{const t=T({tagName:"div",className:Jn.attachmentToolbar,data:{trixMutable:!0},childNodes:T({tagName:"div",className:"trix-button-row",childNodes:T({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:T({tagName:"button",className:"trix-button trix-button--remove",textContent:zn.remove,attributes:{title:zn.remove},data:{trixAction:"remove"}})})})});return this.attachment.isPreviewable()&&t.appendChild(T({tagName:"div",className:Jn.attachmentMetadataContainer,childNodes:T({tagName:"span",className:Jn.attachmentMetadata,childNodes:[T({tagName:"span",className:Jn.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),T({tagName:"span",className:Jn.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),b("click",{onElement:t,withCallback:this.didClickToolbar}),b("click",{onElement:t,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),v("trix-attachment-before-toolbar",{onElement:this.element,attributes:{toolbar:t,attachment:this.attachment}}),{do:()=>this.element.appendChild(t),undo:()=>S(t)}}))),Di(this,"installCaptionEditor",Gn((()=>{const t=T({tagName:"textarea",className:Jn.attachmentCaptionEditor,attributes:{placeholder:zn.captionPlaceholder},data:{trixMutable:!0}});t.value=this.attachmentPiece.getCaption();const e=t.cloneNode();e.classList.add("trix-autoresize-clone"),e.tabIndex=-1;const i=function(){e.value=t.value,t.style.height=e.scrollHeight+"px"};b("input",{onElement:t,withCallback:i}),b("input",{onElement:t,withCallback:this.didInputCaption}),b("keydown",{onElement:t,withCallback:this.didKeyDownCaption}),b("change",{onElement:t,withCallback:this.didChangeCaption}),b("blur",{onElement:t,withCallback:this.didBlurCaption});const n=this.element.querySelector("figcaption"),r=n.cloneNode();return{do:()=>{if(n.style.display="none",r.appendChild(t),r.appendChild(e),r.classList.add("".concat(Jn.attachmentCaption,"--editing")),n.parentElement.insertBefore(r,n),i(),this.options.editCaption)return Rt((()=>t.focus()))},undo(){S(r),n.style.display=null}}}))),this.didClickToolbar=this.didClickToolbar.bind(this),this.didClickActionButton=this.didClickActionButton.bind(this),this.didKeyDownCaption=this.didKeyDownCaption.bind(this),this.didInputCaption=this.didInputCaption.bind(this),this.didChangeCaption=this.didChangeCaption.bind(this),this.didBlurCaption=this.didBlurCaption.bind(this),this.attachmentPiece=t,this.element=e,this.container=i,this.options=n,this.attachment=this.attachmentPiece.attachment,"a"===k(this.element)&&(this.element=this.element.firstChild),this.install()}install(){this.makeElementMutable(),this.addToolbar(),this.attachment.isPreviewable()&&this.installCaptionEditor()}uninstall(){var t;let e=this.undos.pop();for(this.savePendingCaption();e;)e(),e=this.undos.pop();null===(t=this.delegate)||void 0===t||t.didUninstallAttachmentEditor(this)}savePendingCaption(){if(null!=this.pendingCaption){const r=this.pendingCaption;var t,e,i,n;this.pendingCaption=null,r?null===(t=this.delegate)||void 0===t||null===(e=t.attachmentEditorDidRequestUpdatingAttributesForAttachment)||void 0===e||e.call(t,{caption:r},this.attachment):null===(i=this.delegate)||void 0===i||null===(n=i.attachmentEditorDidRequestRemovingAttributeForAttachment)||void 0===n||n.call(i,"caption",this.attachment)}}didClickToolbar(t){return t.preventDefault(),t.stopPropagation()}didClickActionButton(t){var e;if("remove"===t.target.getAttribute("data-trix-action"))return null===(e=this.delegate)||void 0===e?void 0:e.attachmentEditorDidRequestRemovalOfAttachment(this.attachment)}didKeyDownCaption(t){var e,i;if("return"===Kn[t.keyCode])return t.preventDefault(),this.savePendingCaption(),null===(e=this.delegate)||void 0===e||null===(i=e.attachmentEditorDidRequestDeselectingAttachment)||void 0===i?void 0:i.call(e,this.attachment)}didInputCaption(t){this.pendingCaption=t.target.value.replace(/\s/g," ").trim()}didChangeCaption(t){return this.savePendingCaption()}didBlurCaption(t){return this.savePendingCaption()}}class Xn extends q{constructor(t,i){super(...arguments),this.didFocus=this.didFocus.bind(this),this.didBlur=this.didBlur.bind(this),this.didClickAttachment=this.didClickAttachment.bind(this),this.element=t,this.composition=i,this.documentView=new Si(this.composition.document,{element:this.element}),b("focus",{onElement:this.element,withCallback:this.didFocus}),b("blur",{onElement:this.element,withCallback:this.didBlur}),b("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),b("mousedown",{onElement:this.element,matchingSelector:e,withCallback:this.didClickAttachment}),b("click",{onElement:this.element,matchingSelector:"a".concat(e),preventDefault:!0})}didFocus(t){var e;const i=()=>{var t,e;if(!this.focused)return this.focused=!0,null===(t=this.delegate)||void 0===t||null===(e=t.compositionControllerDidFocus)||void 0===e?void 0:e.call(t)};return(null===(e=this.blurPromise)||void 0===e?void 0:e.then(i))||i()}didBlur(t){this.blurPromise=new Promise((t=>Rt((()=>{var e,i;x(this.element)||(this.focused=null,null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidBlur)||void 0===i||i.call(e));return this.blurPromise=null,t()}))))}didClickAttachment(t,e){var i,n;const r=this.findAttachmentForElement(e),o=!!y(t.target,{matchingSelector:"figcaption"});return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerDidSelectAttachment)||void 0===n?void 0:n.call(i,r,{editCaption:o})}getSerializableElement(){return this.isEditingAttachment()?this.documentView.shadowElement:this.element}render(){var t,e,i,n,r,o;(this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced())&&(null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillSyncDocumentView)||void 0===n||n.call(i),this.documentView.sync(),null===(r=this.delegate)||void 0===r||null===(o=r.compositionControllerDidSyncDocumentView)||void 0===o||o.call(r));return null===(t=this.delegate)||void 0===t||null===(e=t.compositionControllerDidRender)||void 0===e?void 0:e.call(t)}rerenderViewForObject(t){return this.invalidateViewForObject(t),this.render()}invalidateViewForObject(t){return this.documentView.invalidateViewForObject(t)}isViewCachingEnabled(){return this.documentView.isViewCachingEnabled()}enableViewCaching(){return this.documentView.enableViewCaching()}disableViewCaching(){return this.documentView.disableViewCaching()}refreshViewCache(){return this.documentView.garbageCollectCachedViews()}isEditingAttachment(){return!!this.attachmentEditor}installAttachmentEditorForAttachment(t,e){var i;if((null===(i=this.attachmentEditor)||void 0===i?void 0:i.attachment)===t)return;const n=this.documentView.findElementForObject(t);if(!n)return;this.uninstallAttachmentEditor();const r=this.composition.document.getAttachmentPieceForAttachment(t);this.attachmentEditor=new Yn(r,n,this.element,e),this.attachmentEditor.delegate=this}uninstallAttachmentEditor(){var t;return null===(t=this.attachmentEditor)||void 0===t?void 0:t.uninstall()}didUninstallAttachmentEditor(){return this.attachmentEditor=null,this.render()}attachmentEditorDidRequestUpdatingAttributesForAttachment(t,e){var i,n;return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillUpdateAttachment)||void 0===n||n.call(i,e),this.composition.updateAttributesForAttachment(t,e)}attachmentEditorDidRequestRemovingAttributeForAttachment(t,e){var i,n;return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillUpdateAttachment)||void 0===n||n.call(i,e),this.composition.removeAttributeForAttachment(t,e)}attachmentEditorDidRequestRemovalOfAttachment(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidRequestRemovalOfAttachment)||void 0===i?void 0:i.call(e,t)}attachmentEditorDidRequestDeselectingAttachment(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidRequestDeselectingAttachment)||void 0===i?void 0:i.call(e,t)}canSyncDocumentView(){return!this.isEditingAttachment()}findAttachmentForElement(t){return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId,10))}}class $n extends q{}const Zn="data-trix-mutable",Qn="[".concat(Zn,"]"),tr={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0};class er extends q{constructor(t){super(t),this.didMutate=this.didMutate.bind(this),this.element=t,this.observer=new window.MutationObserver(this.didMutate),this.start()}start(){return this.reset(),this.observer.observe(this.element,tr)}stop(){return this.observer.disconnect()}didMutate(t){var e,i;if(this.mutations.push(...Array.from(this.findSignificantMutations(t)||[])),this.mutations.length)return null===(e=this.delegate)||void 0===e||null===(i=e.elementDidMutate)||void 0===i||i.call(e,this.getMutationSummary()),this.reset()}reset(){this.mutations=[]}findSignificantMutations(t){return t.filter((t=>this.mutationIsSignificant(t)))}mutationIsSignificant(t){if(this.nodeIsMutable(t.target))return!1;for(const e of Array.from(this.nodesModifiedByMutation(t)))if(this.nodeIsSignificant(e))return!0;return!1}nodeIsSignificant(t){return t!==this.element&&!this.nodeIsMutable(t)&&!M(t)}nodeIsMutable(t){return y(t,{matchingSelector:Qn})}nodesModifiedByMutation(t){const e=[];switch(t.type){case"attributes":t.attributeName!==Zn&&e.push(t.target);break;case"characterData":e.push(t.target.parentNode),e.push(t.target);break;case"childList":e.push(...Array.from(t.addedNodes||[])),e.push(...Array.from(t.removedNodes||[]))}return e}getMutationSummary(){return this.getTextMutationSummary()}getTextMutationSummary(){const{additions:t,deletions:e}=this.getTextChangesFromCharacterData(),i=this.getTextChangesFromChildList();Array.from(i.additions).forEach((e=>{Array.from(t).includes(e)||t.push(e)})),e.push(...Array.from(i.deletions||[]));const n={},r=t.join("");r&&(n.textAdded=r);const o=e.join("");return o&&(n.textDeleted=o),n}getMutationsByType(t){return Array.from(this.mutations).filter((e=>e.type===t))}getTextChangesFromChildList(){let t,e;const i=[],n=[];Array.from(this.getMutationsByType("childList")).forEach((t=>{i.push(...Array.from(t.addedNodes||[])),n.push(...Array.from(t.removedNodes||[]))}));0===i.length&&1===n.length&&I(n[0])?(t=[],e=["\n"]):(t=ir(i),e=ir(n));const r=t.filter(((t,i)=>t!==e[i])).map(Wt),o=e.filter(((e,i)=>e!==t[i])).map(Wt);return{additions:r,deletions:o}}getTextChangesFromCharacterData(){let t,e;const i=this.getMutationsByType("characterData");if(i.length){const n=i[0],r=i[i.length-1],o=function(t,e){let i,n;return t=$.box(t),(e=$.box(e)).length0&&void 0!==arguments[0]?arguments[0]:[];const e=[];for(const i of Array.from(t))switch(i.nodeType){case Node.TEXT_NODE:e.push(i.data);break;case Node.ELEMENT_NODE:"br"===k(i)?e.push("\n"):e.push(...Array.from(ir(i.childNodes)||[]))}return e};class nr extends ee{constructor(t){super(...arguments),this.file=t}perform(t){const e=new FileReader;return e.onerror=()=>t(!1),e.onload=()=>{e.onerror=null;try{e.abort()}catch(t){}return t(!0,this.file)},e.readAsArrayBuffer(this.file)}}class rr{constructor(t){this.element=t}shouldIgnore(t){return!!a.samsungAndroid&&(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode)}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&or(this.element.innerText,this.event.data)&&(this.buggyMode=!0,this.event.preventDefault())}checkSamsungKeyboardBuggyModeEnd(){this.buggyMode&&"insertText"!==this.event.inputType&&(this.buggyMode=!1)}insertingLongTextAfterUnidentifiedChar(){var t;return this.isBeforeInputInsertText()&&this.previousEventWasUnidentifiedKeydown()&&(null===(t=this.event.data)||void 0===t?void 0:t.length)>50}isBeforeInputInsertText(){return"beforeinput"===this.event.type&&"insertText"===this.event.inputType}previousEventWasUnidentifiedKeydown(){var t,e;return"keydown"===(null===(t=this.previousEvent)||void 0===t?void 0:t.type)&&"Unidentified"===(null===(e=this.previousEvent)||void 0===e?void 0:e.key)}}const or=(t,e)=>ar(t)===ar(e),sr=new RegExp("(".concat("","|").concat(d,"|").concat(g,"|\\s)+"),"g"),ar=t=>t.replace(sr," ").trim();class lr extends q{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new er(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new rr(this.element);for(const t in this.constructor.events)b(t,{onElement:this.element,withCallback:this.handlerFor(t)})}elementDidMutate(t){}editorWillSyncDocumentView(){return this.mutationObserver.stop()}editorDidSyncDocumentView(){return this.mutationObserver.start()}requestRender(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidRequestRender)||void 0===e?void 0:e.call(t)}requestReparse(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidRequestReparse)||void 0===e||e.call(t),this.requestRender()}attachFiles(t){const e=Array.from(t).map((t=>new nr(t)));return Promise.all(e).then((t=>{this.handleInput((function(){var e,i;return null===(e=this.delegate)||void 0===e||e.inputControllerWillAttachFiles(),null===(i=this.responder)||void 0===i||i.insertFiles(t),this.requestRender()}))}))}handlerFor(t){return e=>{e.defaultPrevented||this.handleInput((()=>{if(!x(this.element)){if(this.flakyKeyboardDetector.shouldIgnore(e))return;this.eventName=t,this.constructor.events[t].call(this,e)}}))}}handleInput(t){try{var e;null===(e=this.delegate)||void 0===e||e.inputControllerWillHandleInput(),t.call(this)}finally{var i;null===(i=this.delegate)||void 0===i||i.inputControllerDidHandleInput()}}createLinkHTML(t,e){const i=document.createElement("a");return i.href=t,i.textContent=e||t,i.outerHTML}}var cr;Di(lr,"events",{});const{browser:ur,keyNames:hr}=H;let dr=0;class gr extends lr{constructor(){super(...arguments),this.resetInputSummary()}setInputSummary(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.inputSummary.eventName=this.eventName;for(const e in t){const i=t[e];this.inputSummary[e]=i}return this.inputSummary}resetInputSummary(){this.inputSummary={}}reset(){return this.resetInputSummary(),Ft.reset()}elementDidMutate(t){var e,i;return this.isComposing()?null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidAllowUnhandledInput)||void 0===i?void 0:i.call(e):this.handleInput((function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()}))}mutationIsExpected(t){let{textAdded:e,textDeleted:i}=t;if(this.inputSummary.preferDocument)return!0;const n=null!=e?e===this.inputSummary.textAdded:!this.inputSummary.textAdded,r=null!=i?this.inputSummary.didDelete:!this.inputSummary.didDelete,o=["\n"," \n"].includes(e)&&!n,s="\n"===i&&!r;if(o&&!s||s&&!o){const t=this.getSelectedRange();if(t){var a;const i=o?e.replace(/\n$/,"").length||-1:(null==e?void 0:e.length)||1;if(null!==(a=this.responder)&&void 0!==a&&a.positionIsBlockBreak(t[1]+i))return!0}}return n&&r}mutationIsSignificant(t){var e;const i=Object.keys(t).length>0,n=""===(null===(e=this.compositionInput)||void 0===e?void 0:e.getEndData());return i||!n}getCompositionInput(){if(this.isComposing())return this.compositionInput;this.compositionInput=new vr(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,e){var i;return!1!==(null===(i=this.responder)||void 0===i?void 0:i.deleteInDirection(t))?this.setInputSummary({didDelete:!0}):e?(e.preventDefault(),this.requestRender()):void 0}serializeSelectionToDataTransfer(t){var e;if(!function(t){if(null==t||!t.setData)return!1;for(const e in Ct){const i=Ct[e];try{if(t.setData(e,i),!t.getData(e)===i)return!1}catch(t){return!1}}return!0}(t))return;const i=null===(e=this.responder)||void 0===e?void 0:e.getSelectedDocument().toSerializableDocument();return t.setData("application/x-trix-document",JSON.stringify(i)),t.setData("text/html",Si.render(i).innerHTML),t.setData("text/plain",i.toString().replace(/\n$/,"")),!0}canAcceptDataTransfer(t){const e={};return Array.from((null==t?void 0:t.types)||[]).forEach((t=>{e[t]=!0})),e.Files||e["application/x-trix-document"]||e["text/html"]||e["text/plain"]}getPastedHTMLUsingHiddenElement(t){const e=this.getSelectedRange(),i={position:"absolute",left:"".concat(window.pageXOffset,"px"),top:"".concat(window.pageYOffset,"px"),opacity:0},n=T({style:i,tagName:"div",editable:!0});return document.body.appendChild(n),n.focus(),requestAnimationFrame((()=>{const i=n.innerHTML;return S(n),this.setSelectedRange(e),t(i)}))}}Di(gr,"events",{keydown(t){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;const e=hr[t.keyCode];if(e){var i;let n=this.keys;["ctrl","alt","shift","meta"].forEach((e=>{var i;t["".concat(e,"Key")]&&("ctrl"===e&&(e="control"),n=null===(i=n)||void 0===i?void 0:i[e])})),null!=(null===(i=n)||void 0===i?void 0:i[e])&&(this.setInputSummary({keyName:e}),Ft.reset(),n[e].call(this,t))}if(St(t)){const e=String.fromCharCode(t.keyCode).toLowerCase();if(e){var n;const i=["alt","shift"].map((e=>{if(t["".concat(e,"Key")])return e})).filter((t=>t));i.push(e),null!==(n=this.delegate)&&void 0!==n&&n.inputControllerDidReceiveKeyboardCommand(i)&&t.preventDefault()}}},keypress(t){if(null!=this.inputSummary.eventName)return;if(t.metaKey)return;if(t.ctrlKey&&!t.altKey)return;const e=fr(t);var i,n;return e?(null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformTyping(),null===(n=this.responder)||void 0===n||n.insertString(e),this.setInputSummary({textAdded:e,didDelete:this.selectionIsExpanded()})):void 0},textInput(t){const{data:e}=t,{textAdded:i}=this.inputSummary;if(i&&i!==e&&i.toUpperCase()===e){var n;const t=this.getSelectedRange();return this.setSelectedRange([t[0],t[1]+i.length]),null===(n=this.responder)||void 0===n||n.insertString(e),this.setInputSummary({textAdded:e}),this.setSelectedRange(t)}},dragenter(t){t.preventDefault()},dragstart(t){var e,i;return this.serializeSelectionToDataTransfer(t.dataTransfer),this.draggedRange=this.getSelectedRange(),null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidStartDrag)||void 0===i?void 0:i.call(e)},dragover(t){if(this.draggedRange||this.canAcceptDataTransfer(t.dataTransfer)){t.preventDefault();const n={x:t.clientX,y:t.clientY};var e,i;if(!Tt(n,this.draggingPoint))return this.draggingPoint=n,null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidReceiveDragOverPoint)||void 0===i?void 0:i.call(e,this.draggingPoint)}},dragend(t){var e,i;null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidCancelDrag)||void 0===i||i.call(e),this.draggedRange=null,this.draggingPoint=null},drop(t){var e,i;t.preventDefault();const n=null===(e=t.dataTransfer)||void 0===e?void 0:e.files,r=t.dataTransfer.getData("application/x-trix-document"),o={x:t.clientX,y:t.clientY};if(null===(i=this.responder)||void 0===i||i.setLocationRangeFromPointRange(o),null!=n&&n.length)this.attachFiles(n);else if(this.draggedRange){var s,a;null===(s=this.delegate)||void 0===s||s.inputControllerWillMoveText(),null===(a=this.responder)||void 0===a||a.moveTextFromRange(this.draggedRange),this.draggedRange=null,this.requestRender()}else if(r){var l;const t=an.fromJSONString(r);null===(l=this.responder)||void 0===l||l.insertDocument(t),this.requestRender()}this.draggedRange=null,this.draggingPoint=null},cut(t){var e,i;if(null!==(e=this.responder)&&void 0!==e&&e.selectionIsExpanded()&&(this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault(),null===(i=this.delegate)||void 0===i||i.inputControllerWillCutText(),this.deleteInDirection("backward"),t.defaultPrevented))return this.requestRender()},copy(t){var e;null!==(e=this.responder)&&void 0!==e&&e.selectionIsExpanded()&&this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault()},paste(t){const e=t.clipboardData||t.testClipboardData,i={clipboard:e};if(!e||br(t))return void this.getPastedHTMLUsingHiddenElement((t=>{var e,n,r;return i.type="text/html",i.html=t,null===(e=this.delegate)||void 0===e||e.inputControllerWillPaste(i),null===(n=this.responder)||void 0===n||n.insertHTML(i.html),this.requestRender(),null===(r=this.delegate)||void 0===r?void 0:r.inputControllerDidPaste(i)}));const n=e.getData("URL"),r=e.getData("text/html"),o=e.getData("public.url-name");if(n){var s,a,l;let t;i.type="text/html",t=o?Vt(o).trim():n,i.html=this.createLinkHTML(n,t),null===(s=this.delegate)||void 0===s||s.inputControllerWillPaste(i),this.setInputSummary({textAdded:t,didDelete:this.selectionIsExpanded()}),null===(a=this.responder)||void 0===a||a.insertHTML(i.html),this.requestRender(),null===(l=this.delegate)||void 0===l||l.inputControllerDidPaste(i)}else if(Et(e)){var c,u,h;i.type="text/plain",i.string=e.getData("text/plain"),null===(c=this.delegate)||void 0===c||c.inputControllerWillPaste(i),this.setInputSummary({textAdded:i.string,didDelete:this.selectionIsExpanded()}),null===(u=this.responder)||void 0===u||u.insertString(i.string),this.requestRender(),null===(h=this.delegate)||void 0===h||h.inputControllerDidPaste(i)}else if(r){var d,g,m;i.type="text/html",i.html=r,null===(d=this.delegate)||void 0===d||d.inputControllerWillPaste(i),null===(g=this.responder)||void 0===g||g.insertHTML(i.html),this.requestRender(),null===(m=this.delegate)||void 0===m||m.inputControllerDidPaste(i)}else if(Array.from(e.types).includes("Files")){var p,f;const t=null===(p=e.items)||void 0===p||null===(p=p[0])||void 0===p||null===(f=p.getAsFile)||void 0===f?void 0:f.call(p);if(t){var b,v,A;const e=mr(t);!t.name&&e&&(t.name="pasted-file-".concat(++dr,".").concat(e)),i.type="File",i.file=t,null===(b=this.delegate)||void 0===b||b.inputControllerWillAttachFiles(),null===(v=this.responder)||void 0===v||v.insertFile(i.file),this.requestRender(),null===(A=this.delegate)||void 0===A||A.inputControllerDidPaste(i)}}t.preventDefault()},compositionstart(t){return this.getCompositionInput().start(t.data)},compositionupdate(t){return this.getCompositionInput().update(t.data)},compositionend(t){return this.getCompositionInput().end(t.data)},beforeinput(t){this.inputSummary.didInput=!0},input(t){return this.inputSummary.didInput=!0,t.stopPropagation()}}),Di(gr,"keys",{backspace(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},delete(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},return(t){var e,i;return this.setInputSummary({preferDocument:!0}),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i?void 0:i.insertLineBreak()},tab(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.canIncreaseNestingLevel()&&(null===(i=this.responder)||void 0===i||i.increaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){var e;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("backward")},right(t){var e;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("forward")},control:{d(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},h(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},o(t){var e,i;return t.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.insertString("\n",{updatePosition:!1}),this.requestRender()}},shift:{return(t){var e,i;null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.insertString("\n"),this.requestRender(),t.preventDefault()},tab(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.canDecreaseNestingLevel()&&(null===(i=this.responder)||void 0===i||i.decreaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("backward")},right(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("forward")}},alt:{backspace(t){var e;return this.setInputSummary({preferDocument:!1}),null===(e=this.delegate)||void 0===e?void 0:e.inputControllerWillPerformTyping()}},meta:{backspace(t){var e;return this.setInputSummary({preferDocument:!1}),null===(e=this.delegate)||void 0===e?void 0:e.inputControllerWillPerformTyping()}}}),gr.proxyMethod("responder?.getSelectedRange"),gr.proxyMethod("responder?.setSelectedRange"),gr.proxyMethod("responder?.expandSelectionInDirection"),gr.proxyMethod("responder?.selectionIsInCursorTarget"),gr.proxyMethod("responder?.selectionIsExpanded");const mr=t=>{var e;return null===(e=t.type)||void 0===e||null===(e=e.match(/\/(\w+)$/))||void 0===e?void 0:e[1]},pr=!(null===(cr=" ".codePointAt)||void 0===cr||!cr.call(" ",0)),fr=function(t){if(t.key&&pr&&t.key.codePointAt(0)===t.keyCode)return t.key;{let e;if(null===t.which?e=t.keyCode:0!==t.which&&0!==t.charCode&&(e=t.charCode),null!=e&&"escape"!==hr[e])return $.fromCodepoints([e]).toString()}},br=function(t){const e=t.clipboardData;if(e){if(e.types.includes("text/html")){for(const t of e.types){const i=/^CorePasteboardFlavorType/.test(t),n=/^dyn\./.test(t)&&e.getData(t);if(i||n)return!0}return!1}{const t=e.types.includes("com.apple.webarchive"),i=e.types.includes("com.apple.flat-rtfd");return t||i}}};class vr extends q{constructor(t){super(...arguments),this.inputController=t,this.responder=this.inputController.responder,this.delegate=this.inputController.delegate,this.inputSummary=this.inputController.inputSummary,this.data={}}start(t){if(this.data.start=t,this.isSignificant()){var e,i;"keypress"===this.inputSummary.eventName&&this.inputSummary.textAdded&&(null===(i=this.responder)||void 0===i||i.deleteInDirection("left"));this.selectionIsExpanded()||(this.insertPlaceholder(),this.requestRender()),this.range=null===(e=this.responder)||void 0===e?void 0:e.getSelectedRange()}}update(t){if(this.data.update=t,this.isSignificant()){const t=this.selectPlaceholder();t&&(this.forgetPlaceholder(),this.range=t)}}end(t){return this.data.end=t,this.isSignificant()?(this.forgetPlaceholder(),this.canApplyToDocument()?(this.setInputSummary({preferDocument:!0,didInput:!1}),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.setSelectedRange(this.range),null===(n=this.responder)||void 0===n||n.insertString(this.data.end),null===(r=this.responder)||void 0===r?void 0:r.setSelectedRange(this.range[0]+this.data.end.length)):null!=this.data.start||null!=this.data.update?(this.requestReparse(),this.inputController.reset()):void 0):this.inputController.reset();var e,i,n,r}getEndData(){return this.data.end}isEnded(){return null!=this.getEndData()}isSignificant(){return!ur.composesExistingText||this.inputSummary.didInput}canApplyToDocument(){var t,e;return 0===(null===(t=this.data.start)||void 0===t?void 0:t.length)&&(null===(e=this.data.end)||void 0===e?void 0:e.length)>0&&this.range}}vr.proxyMethod("inputController.setInputSummary"),vr.proxyMethod("inputController.requestRender"),vr.proxyMethod("inputController.requestReparse"),vr.proxyMethod("responder?.selectionIsExpanded"),vr.proxyMethod("responder?.insertPlaceholder"),vr.proxyMethod("responder?.selectPlaceholder"),vr.proxyMethod("responder?.forgetPlaceholder");class Ar extends lr{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){return this.scheduledRender?this.composing?null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidAllowUnhandledInput)||void 0===e?void 0:e.call(t):void 0:this.reparse();var t,e}scheduleRender(){return this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)}render(){var t,e;(cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,this.composing)||null===(e=this.delegate)||void 0===e||e.render();null===(t=this.afterRender)||void 0===t||t.call(this),this.afterRender=null}reparse(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.reparse()}insertString(){var t;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1?arguments[1]:void 0;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(e,i)}))}toggleAttributeIfSupported(t){var e;if(gt().includes(t))return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var e;return null===(e=this.responder)||void 0===e?void 0:e.toggleCurrentAttribute(t)}))}activateAttributeIfSupported(t,e){var i;if(gt().includes(t))return null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var i;return null===(i=this.responder)||void 0===i?void 0:i.setCurrentAttribute(t,e)}))}deleteInDirection(t){let{recordUndoEntry:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{recordUndoEntry:!0};var i;e&&(null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformTyping());const n=()=>{var e;return null===(e=this.responder)||void 0===e?void 0:e.deleteInDirection(t)},r=this.getTargetDOMRange({minLength:this.composing?1:2});return r?this.withTargetDOMRange(r,n):n()}withTargetDOMRange(t,e){var i;return"function"==typeof t&&(e=t,t=this.getTargetDOMRange()),t?null===(i=this.responder)||void 0===i?void 0:i.withTargetDOMRange(t,e.bind(this)):(Ft.reset(),e.call(this))}getTargetDOMRange(){var t,e;let{minLength:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{minLength:0};const n=null===(t=(e=this.event).getTargetRanges)||void 0===t?void 0:t.call(e);if(n&&n.length){const t=yr(n[0]);if(0===i||t.toString().length>=i)return t}}withEvent(t,e){let i;this.event=t;try{i=e.call(this)}finally{this.event=null}return i}}Di(Ar,"events",{keydown(t){if(St(t)){var e;const i=Rr(t);null!==(e=this.delegate)&&void 0!==e&&e.inputControllerDidReceiveKeyboardCommand(i)&&t.preventDefault()}else{let e=t.key;t.altKey&&(e+="+Alt"),t.shiftKey&&(e+="+Shift");const i=this.constructor.keys[e];if(i)return this.withEvent(t,i)}},paste(t){var e;let i;const n=null===(e=t.clipboardData)||void 0===e?void 0:e.getData("URL");return Er(t)?(t.preventDefault(),this.attachFiles(t.clipboardData.files)):Sr(t)?(t.preventDefault(),i={type:"text/plain",string:t.clipboardData.getData("text/plain")},null===(r=this.delegate)||void 0===r||r.inputControllerWillPaste(i),null===(o=this.responder)||void 0===o||o.insertString(i.string),this.render(),null===(s=this.delegate)||void 0===s?void 0:s.inputControllerDidPaste(i)):n?(t.preventDefault(),i={type:"text/html",html:this.createLinkHTML(n)},null===(a=this.delegate)||void 0===a||a.inputControllerWillPaste(i),null===(l=this.responder)||void 0===l||l.insertHTML(i.html),this.render(),null===(c=this.delegate)||void 0===c?void 0:c.inputControllerDidPaste(i)):void 0;var r,o,s,a,l,c},beforeinput(t){const e=this.constructor.inputTypes[t.inputType],i=(n=t,!(!/iPhone|iPad/.test(navigator.userAgent)||n.inputType&&"insertParagraph"!==n.inputType));var n;e&&(this.withEvent(t,e),i||this.scheduleRender()),i&&this.render()},input(t){Ft.reset()},dragstart(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.selectionContainsAttachments()&&(t.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:null===(i=this.responder)||void 0===i?void 0:i.getSelectedRange(),point:kr(t)})},dragenter(t){xr(t)&&t.preventDefault()},dragover(t){if(this.dragging){t.preventDefault();const i=kr(t);var e;if(!Tt(i,this.dragging.point))return this.dragging.point=i,null===(e=this.responder)||void 0===e?void 0:e.setLocationRangeFromPointRange(i)}else xr(t)&&t.preventDefault()},drop(t){var e,i;if(this.dragging)return t.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillMoveText(),null===(i=this.responder)||void 0===i||i.moveTextFromRange(this.dragging.range),this.dragging=null,this.scheduleRender();if(xr(t)){var n;t.preventDefault();const e=kr(t);return null===(n=this.responder)||void 0===n||n.setLocationRangeFromPointRange(e),this.attachFiles(t.dataTransfer.files)}},dragend(){var t;this.dragging&&(null===(t=this.responder)||void 0===t||t.setSelectedRange(this.dragging.range),this.dragging=null)},compositionend(t){this.composing&&(this.composing=!1,a.recentAndroid||this.scheduleRender())}}),Di(Ar,"keys",{ArrowLeft(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("backward"))return this.event.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("backward")},ArrowRight(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("forward"))return this.event.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("forward")},Backspace(){var t,e,i;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageDeletingInDirection("backward"))return this.event.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.deleteInDirection("backward"),this.render()},Tab(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.event.preventDefault(),null===(e=this.responder)||void 0===e||e.increaseNestingLevel(),this.render()},"Tab+Shift"(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.event.preventDefault(),null===(e=this.responder)||void 0===e||e.decreaseNestingLevel(),this.render()}}),Di(Ar,"inputTypes",{deleteByComposition(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteByCut(){return this.deleteInDirection("backward")},deleteByDrag(){return this.event.preventDefault(),this.withTargetDOMRange((function(){var t;this.deleteByDragRange=null===(t=this.responder)||void 0===t?void 0:t.getSelectedRange()}))},deleteCompositionText(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteContent(){return this.deleteInDirection("backward")},deleteContentBackward(){return this.deleteInDirection("backward")},deleteContentForward(){return this.deleteInDirection("forward")},deleteEntireSoftLine(){return this.deleteInDirection("forward")},deleteHardLineBackward(){return this.deleteInDirection("backward")},deleteHardLineForward(){return this.deleteInDirection("forward")},deleteSoftLineBackward(){return this.deleteInDirection("backward")},deleteSoftLineForward(){return this.deleteInDirection("forward")},deleteWordBackward(){return this.deleteInDirection("backward")},deleteWordForward(){return this.deleteInDirection("forward")},formatBackColor(){return this.activateAttributeIfSupported("backgroundColor",this.event.data)},formatBold(){return this.toggleAttributeIfSupported("bold")},formatFontColor(){return this.activateAttributeIfSupported("color",this.event.data)},formatFontName(){return this.activateAttributeIfSupported("font",this.event.data)},formatIndent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.increaseNestingLevel()}))},formatItalic(){return this.toggleAttributeIfSupported("italic")},formatJustifyCenter(){return this.toggleAttributeIfSupported("justifyCenter")},formatJustifyFull(){return this.toggleAttributeIfSupported("justifyFull")},formatJustifyLeft(){return this.toggleAttributeIfSupported("justifyLeft")},formatJustifyRight(){return this.toggleAttributeIfSupported("justifyRight")},formatOutdent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.decreaseNestingLevel()}))},formatRemove(){this.withTargetDOMRange((function(){for(const i in null===(t=this.responder)||void 0===t?void 0:t.getCurrentAttributes()){var t,e;null===(e=this.responder)||void 0===e||e.removeCurrentAttribute(i)}}))},formatSetBlockTextDirection(){return this.activateAttributeIfSupported("blockDir",this.event.data)},formatSetInlineTextDirection(){return this.activateAttributeIfSupported("textDir",this.event.data)},formatStrikeThrough(){return this.toggleAttributeIfSupported("strike")},formatSubscript(){return this.toggleAttributeIfSupported("sub")},formatSuperscript(){return this.toggleAttributeIfSupported("sup")},formatUnderline(){return this.toggleAttributeIfSupported("underline")},historyRedo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformRedo()},historyUndo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformUndo()},insertCompositionText(){return this.composing=!0,this.insertString(this.event.data)},insertFromComposition(){return this.composing=!1,this.insertString(this.event.data)},insertFromDrop(){const t=this.deleteByDragRange;var e;if(t)return this.deleteByDragRange=null,null===(e=this.delegate)||void 0===e||e.inputControllerWillMoveText(),this.withTargetDOMRange((function(){var e;return null===(e=this.responder)||void 0===e?void 0:e.moveTextFromRange(t)}))},insertFromPaste(){const{dataTransfer:t}=this.event,e={dataTransfer:t},i=t.getData("URL"),n=t.getData("text/html");if(i){var r;let n;this.event.preventDefault(),e.type="text/html";const o=t.getData("public.url-name");n=o?Vt(o).trim():i,e.html=this.createLinkHTML(i,n),null===(r=this.delegate)||void 0===r||r.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(e.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(Et(t)){var o;e.type="text/plain",e.string=t.getData("text/plain"),null===(o=this.delegate)||void 0===o||o.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(e.string)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(Cr(this.event)){var s;e.type="File",e.file=t.files[0],null===(s=this.delegate)||void 0===s||s.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertFile(e.file)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(n){var a;this.event.preventDefault(),e.type="text/html",e.html=n,null===(a=this.delegate)||void 0===a||a.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(e.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}},insertFromYank(){return this.insertString(this.event.data)},insertLineBreak(){return this.insertString("\n")},insertLink(){return this.activateAttributeIfSupported("href",this.event.data)},insertOrderedList(){return this.toggleAttributeIfSupported("number")},insertParagraph(){var t;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertLineBreak()}))},insertReplacementText(){const t=this.event.dataTransfer.getData("text/plain"),e=this.event.getTargetRanges()[0];this.withTargetDOMRange(e,(()=>{this.insertString(t,{updatePosition:!1})}))},insertText(){var t;return this.insertString(this.event.data||(null===(t=this.event.dataTransfer)||void 0===t?void 0:t.getData("text/plain")))},insertTranspose(){return this.insertString(this.event.data)},insertUnorderedList(){return this.toggleAttributeIfSupported("bullet")}});const yr=function(t){const e=document.createRange();return e.setStart(t.startContainer,t.startOffset),e.setEnd(t.endContainer,t.endOffset),e},xr=t=>{var e;return Array.from((null===(e=t.dataTransfer)||void 0===e?void 0:e.types)||[]).includes("Files")},Cr=t=>{var e;return(null===(e=t.dataTransfer.files)||void 0===e?void 0:e[0])&&!Er(t)&&!(t=>{let{dataTransfer:e}=t;return e.types.includes("Files")&&e.types.includes("text/html")&&e.getData("text/html").includes("urn:schemas-microsoft-com:office:office")})(t)},Er=function(t){const e=t.clipboardData;if(e)return Array.from(e.types).filter((t=>t.match(/file/i))).length===e.types.length&&e.files.length>=1},Sr=function(t){const e=t.clipboardData;if(e)return e.types.includes("text/plain")&&1===e.types.length},Rr=function(t){const e=[];return t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),e.push(t.key),e},kr=t=>({x:t.clientX,y:t.clientY}),Tr="[data-trix-attribute]",wr="[data-trix-action]",Lr="".concat(Tr,", ").concat(wr),Dr="[data-trix-dialog]",Nr="".concat(Dr,"[data-trix-active]"),Ir="".concat(Dr," [data-trix-method]"),Or="".concat(Dr," [data-trix-input]"),Fr=(t,e)=>(e||(e=Mr(t)),t.querySelector("[data-trix-input][name='".concat(e,"']"))),Pr=t=>t.getAttribute("data-trix-action"),Mr=t=>t.getAttribute("data-trix-attribute")||t.getAttribute("data-trix-dialog-attribute");class Br extends q{constructor(t){super(t),this.didClickActionButton=this.didClickActionButton.bind(this),this.didClickAttributeButton=this.didClickAttributeButton.bind(this),this.didClickDialogButton=this.didClickDialogButton.bind(this),this.didKeyDownDialogInput=this.didKeyDownDialogInput.bind(this),this.element=t,this.attributes={},this.actions={},this.resetDialogInputs(),b("mousedown",{onElement:this.element,matchingSelector:wr,withCallback:this.didClickActionButton}),b("mousedown",{onElement:this.element,matchingSelector:Tr,withCallback:this.didClickAttributeButton}),b("click",{onElement:this.element,matchingSelector:Lr,preventDefault:!0}),b("click",{onElement:this.element,matchingSelector:Ir,withCallback:this.didClickDialogButton}),b("keydown",{onElement:this.element,matchingSelector:Or,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,e){var i;null===(i=this.delegate)||void 0===i||i.toolbarDidClickButton(),t.preventDefault();const n=Pr(e);return this.getDialog(n)?this.toggleDialog(n):null===(r=this.delegate)||void 0===r?void 0:r.toolbarDidInvokeAction(n,e);var r}didClickAttributeButton(t,e){var i;null===(i=this.delegate)||void 0===i||i.toolbarDidClickButton(),t.preventDefault();const n=Mr(e);var r;this.getDialog(n)?this.toggleDialog(n):null===(r=this.delegate)||void 0===r||r.toolbarDidToggleAttribute(n);return this.refreshAttributeButtons()}didClickDialogButton(t,e){const i=y(e,{matchingSelector:Dr});return this[e.getAttribute("data-trix-method")].call(this,i)}didKeyDownDialogInput(t,e){if(13===t.keyCode){t.preventDefault();const i=e.getAttribute("name"),n=this.getDialog(i);this.setAttribute(n)}if(27===t.keyCode)return t.preventDefault(),this.hideDialog()}updateActions(t){return this.actions=t,this.refreshActionButtons()}refreshActionButtons(){return this.eachActionButton(((t,e)=>{t.disabled=!1===this.actions[e]}))}eachActionButton(t){return Array.from(this.element.querySelectorAll(wr)).map((e=>t(e,Pr(e))))}updateAttributes(t){return this.attributes=t,this.refreshAttributeButtons()}refreshAttributeButtons(){return this.eachAttributeButton(((t,e)=>(t.disabled=!1===this.attributes[e],this.attributes[e]||this.dialogIsVisible(e)?(t.setAttribute("data-trix-active",""),t.classList.add("trix-active")):(t.removeAttribute("data-trix-active"),t.classList.remove("trix-active")))))}eachAttributeButton(t){return Array.from(this.element.querySelectorAll(Tr)).map((e=>t(e,Mr(e))))}applyKeyboardCommand(t){const e=JSON.stringify(t.sort());for(const t of Array.from(this.element.querySelectorAll("[data-trix-key]"))){const i=t.getAttribute("data-trix-key").split("+");if(JSON.stringify(i.sort())===e)return v("mousedown",{onElement:t}),!0}return!1}dialogIsVisible(t){const e=this.getDialog(t);if(e)return e.hasAttribute("data-trix-active")}toggleDialog(t){return this.dialogIsVisible(t)?this.hideDialog():this.showDialog(t)}showDialog(t){var e,i;this.hideDialog(),null===(e=this.delegate)||void 0===e||e.toolbarWillShowDialog();const n=this.getDialog(t);n.setAttribute("data-trix-active",""),n.classList.add("trix-active"),Array.from(n.querySelectorAll("input[disabled]")).forEach((t=>{t.removeAttribute("disabled")}));const r=Mr(n);if(r){const e=Fr(n,t);e&&(e.value=this.attributes[r]||"",e.select())}return null===(i=this.delegate)||void 0===i?void 0:i.toolbarDidShowDialog(t)}setAttribute(t){var e;const i=Mr(t),n=Fr(t,i);return!n.willValidate||(n.setCustomValidity(""),n.checkValidity()&&this.isSafeAttribute(n))?(null===(e=this.delegate)||void 0===e||e.toolbarDidUpdateAttribute(i,n.value),this.hideDialog()):(n.setCustomValidity("Invalid value"),n.setAttribute("data-trix-validate",""),n.classList.add("trix-validate"),n.focus())}isSafeAttribute(t){return!t.hasAttribute("data-trix-validate-href")||li.isValidAttribute("a","href",t.value)}removeAttribute(t){var e;const i=Mr(t);return null===(e=this.delegate)||void 0===e||e.toolbarDidRemoveAttribute(i),this.hideDialog()}hideDialog(){const t=this.element.querySelector(Nr);var e;if(t)return t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),null===(e=this.delegate)||void 0===e?void 0:e.toolbarDidHideDialog((t=>t.getAttribute("data-trix-dialog"))(t))}resetDialogInputs(){Array.from(this.element.querySelectorAll(Or)).forEach((t=>{t.setAttribute("disabled","disabled"),t.removeAttribute("data-trix-validate"),t.classList.remove("trix-validate")}))}getDialog(t){return this.element.querySelector("[data-trix-dialog=".concat(t,"]"))}}class _r extends $n{constructor(t){let{editorElement:e,document:i,html:n}=t;super(...arguments),this.editorElement=e,this.selectionManager=new Vn(this.editorElement),this.selectionManager.delegate=this,this.composition=new wn,this.composition.delegate=this,this.attachmentManager=new kn(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=2===_.getLevel()?new Ar(this.editorElement):new gr(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new Xn(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new Br(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new Pn(this.composition,this.selectionManager,this.editorElement),i?this.editor.loadDocument(i):this.editor.loadHTML(n)}registerSelectionManager(){return Ft.registerSelectionManager(this.selectionManager)}unregisterSelectionManager(){return Ft.unregisterSelectionManager(this.selectionManager)}render(){return this.compositionController.render()}reparse(){return this.composition.replaceHTML(this.editorElement.innerHTML)}compositionDidChangeDocument(t){if(this.notifyEditorElement("document-change"),!this.handlingInput)return this.render()}compositionDidChangeCurrentAttributes(t){return this.currentAttributes=t,this.toolbarController.updateAttributes(this.currentAttributes),this.updateCurrentActions(),this.notifyEditorElement("attributes-change",{attributes:this.currentAttributes})}compositionDidPerformInsertionAtRange(t){this.pasting&&(this.pastedRange=t)}compositionShouldAcceptFile(t){return this.notifyEditorElement("file-accept",{file:t})}compositionDidAddAttachment(t){const e=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-add",{attachment:e})}compositionDidEditAttachment(t){this.compositionController.rerenderViewForObject(t);const e=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-edit",{attachment:e}),this.notifyEditorElement("change")}compositionDidChangeAttachmentPreviewURL(t){return this.compositionController.invalidateViewForObject(t),this.notifyEditorElement("change")}compositionDidRemoveAttachment(t){const e=this.attachmentManager.unmanageAttachment(t);return this.notifyEditorElement("attachment-remove",{attachment:e})}compositionDidStartEditingAttachment(t,e){return this.attachmentLocationRange=this.composition.document.getLocationRangeOfAttachment(t),this.compositionController.installAttachmentEditorForAttachment(t,e),this.selectionManager.setLocationRange(this.attachmentLocationRange)}compositionDidStopEditingAttachment(t){this.compositionController.uninstallAttachmentEditor(),this.attachmentLocationRange=null}compositionDidRequestChangingSelectionToLocationRange(t){if(!this.loadingSnapshot||this.isFocused())return this.requestedLocationRange=t,this.compositionRevisionWhenLocationRangeRequested=this.composition.revision,this.handlingInput?void 0:this.render()}compositionWillLoadSnapshot(){this.loadingSnapshot=!0}compositionDidLoadSnapshot(){this.compositionController.refreshViewCache(),this.render(),this.loadingSnapshot=!1}getSelectionManager(){return this.selectionManager}attachmentManagerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}compositionControllerWillSyncDocumentView(){return this.inputController.editorWillSyncDocumentView(),this.selectionManager.lock(),this.selectionManager.clearSelection()}compositionControllerDidSyncDocumentView(){return this.inputController.editorDidSyncDocumentView(),this.selectionManager.unlock(),this.updateCurrentActions(),this.notifyEditorElement("sync")}compositionControllerDidRender(){this.requestedLocationRange&&(this.compositionRevisionWhenLocationRangeRequested===this.composition.revision&&this.selectionManager.setLocationRange(this.requestedLocationRange),this.requestedLocationRange=null,this.compositionRevisionWhenLocationRangeRequested=null),this.renderedCompositionRevision!==this.composition.revision&&(this.runEditorFilters(),this.composition.updateCurrentAttributes(),this.notifyEditorElement("render")),this.renderedCompositionRevision=this.composition.revision}compositionControllerDidFocus(){return this.isFocusedInvisibly()&&this.setLocationRange({index:0,offset:0}),this.toolbarController.hideDialog(),this.notifyEditorElement("focus")}compositionControllerDidBlur(){return this.notifyEditorElement("blur")}compositionControllerDidSelectAttachment(t,e){return this.toolbarController.hideDialog(),this.composition.editAttachment(t,e)}compositionControllerDidRequestDeselectingAttachment(t){const e=this.attachmentLocationRange||this.composition.document.getLocationRangeOfAttachment(t);return this.selectionManager.setLocationRange(e[1])}compositionControllerWillUpdateAttachment(t){return this.editor.recordUndoEntry("Edit Attachment",{context:t.id,consolidatable:!0})}compositionControllerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}inputControllerWillHandleInput(){this.handlingInput=!0,this.requestedRender=!1}inputControllerDidRequestRender(){this.requestedRender=!0}inputControllerDidHandleInput(){if(this.handlingInput=!1,this.requestedRender)return this.requestedRender=!1,this.render()}inputControllerDidAllowUnhandledInput(){return this.notifyEditorElement("change")}inputControllerDidRequestReparse(){return this.reparse()}inputControllerWillPerformTyping(){return this.recordTypingUndoEntry()}inputControllerWillPerformFormatting(t){return this.recordFormattingUndoEntry(t)}inputControllerWillCutText(){return this.editor.recordUndoEntry("Cut")}inputControllerWillPaste(t){return this.editor.recordUndoEntry("Paste"),this.pasting=!0,this.notifyEditorElement("before-paste",{paste:t})}inputControllerDidPaste(t){return t.range=this.pastedRange,this.pastedRange=null,this.pasting=null,this.notifyEditorElement("paste",{paste:t})}inputControllerWillMoveText(){return this.editor.recordUndoEntry("Move")}inputControllerWillAttachFiles(){return this.editor.recordUndoEntry("Drop Files")}inputControllerWillPerformUndo(){return this.editor.undo()}inputControllerWillPerformRedo(){return this.editor.redo()}inputControllerDidReceiveKeyboardCommand(t){return this.toolbarController.applyKeyboardCommand(t)}inputControllerDidStartDrag(){this.locationRangeBeforeDrag=this.selectionManager.getLocationRange()}inputControllerDidReceiveDragOverPoint(t){return this.selectionManager.setLocationRangeFromPointRange(t)}inputControllerDidCancelDrag(){this.selectionManager.setLocationRange(this.locationRangeBeforeDrag),this.locationRangeBeforeDrag=null}locationRangeDidChange(t){return this.composition.updateCurrentAttributes(),this.updateCurrentActions(),this.attachmentLocationRange&&!Dt(this.attachmentLocationRange,t)&&this.composition.stopEditingAttachment(),this.notifyEditorElement("selection-change")}toolbarDidClickButton(){if(!this.getLocationRange())return this.setLocationRange({index:0,offset:0})}toolbarDidInvokeAction(t,e){return this.invokeAction(t,e)}toolbarDidToggleAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.toggleCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidUpdateAttribute(t,e){if(this.recordFormattingUndoEntry(t),this.composition.setCurrentAttribute(t,e),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidRemoveAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.removeCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarWillShowDialog(t){return this.composition.expandSelectionForEditing(),this.freezeSelection()}toolbarDidShowDialog(t){return this.notifyEditorElement("toolbar-dialog-show",{dialogName:t})}toolbarDidHideDialog(t){return this.thawSelection(),this.editorElement.focus(),this.notifyEditorElement("toolbar-dialog-hide",{dialogName:t})}freezeSelection(){if(!this.selectionFrozen)return this.selectionManager.lock(),this.composition.freezeSelection(),this.selectionFrozen=!0,this.render()}thawSelection(){if(this.selectionFrozen)return this.composition.thawSelection(),this.selectionManager.unlock(),this.selectionFrozen=!1,this.render()}canInvokeAction(t){return!!this.actionIsExternal(t)||!(null===(e=this.actions[t])||void 0===e||null===(e=e.test)||void 0===e||!e.call(this));var e}invokeAction(t,e){return this.actionIsExternal(t)?this.notifyEditorElement("action-invoke",{actionName:t,invokingElement:e}):null===(i=this.actions[t])||void 0===i||null===(i=i.perform)||void 0===i?void 0:i.call(this);var i}actionIsExternal(t){return/^x-./.test(t)}getCurrentActions(){const t={};for(const e in this.actions)t[e]=this.canInvokeAction(e);return t}updateCurrentActions(){const t=this.getCurrentActions();if(!Tt(t,this.currentActions))return this.currentActions=t,this.toolbarController.updateActions(this.currentActions),this.notifyEditorElement("actions-change",{actions:this.currentActions})}runEditorFilters(){let t=this.composition.getSnapshot();if(Array.from(this.editor.filters).forEach((e=>{const{document:i,selectedRange:n}=t;t=e.call(this.editor,t)||{},t.document||(t.document=i),t.selectedRange||(t.selectedRange=n)})),e=t,i=this.composition.getSnapshot(),!Dt(e.selectedRange,i.selectedRange)||!e.document.isEqualTo(i.document))return this.composition.loadSnapshot(t);var e,i}updateInputElement(){const t=function(t,e){const i=En[e];if(i)return i(t);throw new Error("unknown content type: ".concat(e))}(this.compositionController.getSerializableElement(),"text/html");return this.editorElement.setFormValue(t)}notifyEditorElement(t,e){switch(t){case"document-change":this.documentChangedSinceLastRender=!0;break;case"render":this.documentChangedSinceLastRender&&(this.documentChangedSinceLastRender=!1,this.notifyEditorElement("change"));break;case"change":case"attachment-add":case"attachment-edit":case"attachment-remove":this.updateInputElement()}return this.editorElement.notify(t,e)}removeAttachment(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()}recordFormattingUndoEntry(t){const e=mt(t),i=this.selectionManager.getLocationRange();if(e||!Lt(i))return this.editor.recordUndoEntry("Formatting",{context:this.getUndoContext(),consolidatable:!0})}recordTypingUndoEntry(){return this.editor.recordUndoEntry("Typing",{context:this.getUndoContext(this.currentAttributes),consolidatable:!0})}getUndoContext(){for(var t=arguments.length,e=new Array(t),i=0;i0?Math.floor((new Date).getTime()/V.interval):0}isFocused(){var t;return this.editorElement===(null===(t=this.editorElement.ownerDocument)||void 0===t?void 0:t.activeElement)}isFocusedInvisibly(){return this.isFocused()&&!this.getLocationRange()}get actions(){return this.constructor.actions}}Di(_r,"actions",{undo:{test(){return this.editor.canUndo()},perform(){return this.editor.undo()}},redo:{test(){return this.editor.canRedo()},perform(){return this.editor.redo()}},link:{test(){return this.editor.canActivateAttribute("href")}},increaseNestingLevel:{test(){return this.editor.canIncreaseNestingLevel()},perform(){return this.editor.increaseNestingLevel()&&this.render()}},decreaseNestingLevel:{test(){return this.editor.canDecreaseNestingLevel()},perform(){return this.editor.decreaseNestingLevel()&&this.render()}},attachFiles:{test:()=>!0,perform(){return _.pickFiles(this.editor.insertFiles)}}}),_r.proxyMethod("getSelectionManager().setLocationRange"),_r.proxyMethod("getSelectionManager().getLocationRange");var jr=Object.freeze({__proto__:null,AttachmentEditorController:Yn,CompositionController:Xn,Controller:$n,EditorController:_r,InputController:lr,Level0InputController:gr,Level2InputController:Ar,ToolbarController:Br}),Wr=Object.freeze({__proto__:null,MutationObserver:er,SelectionChangeObserver:Ot}),Ur=Object.freeze({__proto__:null,FileVerificationOperation:nr,ImagePreloadOperation:Ui});vt("trix-toolbar","%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}");class Vr extends HTMLElement{connectedCallback(){""===this.innerHTML&&(this.innerHTML=U.getDefaultHTML())}}let qr=0;const Hr=function(t){if(!t.hasAttribute("contenteditable"))return t.setAttribute("contenteditable",""),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.times=1,b(t,e)}("focus",{onElement:t,withCallback:()=>zr(t)})},zr=function(t){return Jr(t),Kr(t)},Jr=function(t){var e,i;if(null!==(e=(i=document).queryCommandSupported)&&void 0!==e&&e.call(i,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),b("mscontrolselect",{onElement:t,preventDefault:!0})},Kr=function(t){var e,i;if(null!==(e=(i=document).queryCommandSupported)&&void 0!==e&&e.call(i,"DefaultParagraphSeparator")){const{tagName:t}=n.default;if(["div","p"].includes(t))return document.execCommand("DefaultParagraphSeparator",!1,t)}},Gr=a.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"};vt("trix-editor","%t {\n display: block;\n}\n\n%t:empty::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n white-space: pre-line;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t ".concat(e," figcaption textarea {\n resize: none;\n}\n\n%t ").concat(e," figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t ").concat(e," figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: ").concat(Gr.display," !important;\n width: ").concat(Gr.width," !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}"));var Yr=new WeakMap,Xr=new WeakSet;class $r{constructor(t){var e,i;_i(e=this,i=Xr),i.add(e),ji(this,Yr,{writable:!0,value:void 0}),this.element=t,Oi(this,Yr,t.attachInternals())}connectedCallback(){Bi(this,Xr,Zr).call(this)}disconnectedCallback(){}get labels(){return Ii(this,Yr).labels}get disabled(){var t;return null===(t=this.element.inputElement)||void 0===t?void 0:t.disabled}set disabled(t){this.element.toggleAttribute("disabled",t)}get required(){return this.element.hasAttribute("required")}set required(t){this.element.toggleAttribute("required",t),Bi(this,Xr,Zr).call(this)}get validity(){return Ii(this,Yr).validity}get validationMessage(){return Ii(this,Yr).validationMessage}get willValidate(){return Ii(this,Yr).willValidate}setFormValue(t){Bi(this,Xr,Zr).call(this)}checkValidity(){return Ii(this,Yr).checkValidity()}reportValidity(){return Ii(this,Yr).reportValidity()}setCustomValidity(t){Bi(this,Xr,Zr).call(this,t)}}function Zr(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{required:e,value:i}=this.element,n=e&&!i,r=!!t,o=T("input",{required:e}),s=t||o.validationMessage;Ii(this,Yr).setValidity({valueMissing:n,customError:r},s)}var Qr=new WeakMap,to=new WeakMap,eo=new WeakMap;class io{constructor(t){ji(this,Qr,{writable:!0,value:void 0}),ji(this,to,{writable:!0,value:t=>{t.defaultPrevented||t.target===this.element.form&&this.element.reset()}}),ji(this,eo,{writable:!0,value:t=>{if(t.defaultPrevented)return;if(this.element.contains(t.target))return;const e=y(t.target,{matchingSelector:"label"});e&&Array.from(this.labels).includes(e)&&this.element.focus()}}),this.element=t}connectedCallback(){Oi(this,Qr,function(t){if(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"))return;const e=function(){const e=Array.from(t.labels).map((e=>{if(!e.contains(t))return e.textContent})).filter((t=>t)),i=e.join(" ");return i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label")};return e(),b("focus",{onElement:t,withCallback:e})}(this.element)),window.addEventListener("reset",Ii(this,to),!1),window.addEventListener("click",Ii(this,eo),!1)}disconnectedCallback(){var t;null===(t=Ii(this,Qr))||void 0===t||t.destroy(),window.removeEventListener("reset",Ii(this,to),!1),window.removeEventListener("click",Ii(this,eo),!1)}get labels(){const t=[];this.element.id&&this.element.ownerDocument&&t.push(...Array.from(this.element.ownerDocument.querySelectorAll("label[for='".concat(this.element.id,"']"))||[]));const e=y(this.element,{matchingSelector:"label"});return e&&[this.element,null].includes(e.control)&&t.push(e),t}get disabled(){return console.warn("This browser does not support the [disabled] attribute for trix-editor elements."),!1}set disabled(t){console.warn("This browser does not support the [disabled] attribute for trix-editor elements.")}get required(){return console.warn("This browser does not support the [required] attribute for trix-editor elements."),!1}set required(t){console.warn("This browser does not support the [required] attribute for trix-editor elements.")}get validity(){return console.warn("This browser does not support the validity property for trix-editor elements."),null}get validationMessage(){return console.warn("This browser does not support the validationMessage property for trix-editor elements."),""}get willValidate(){return console.warn("This browser does not support the willValidate property for trix-editor elements."),!1}setFormValue(t){}checkValidity(){return console.warn("This browser does not support checkValidity() for trix-editor elements."),!0}reportValidity(){return console.warn("This browser does not support reportValidity() for trix-editor elements."),!0}setCustomValidity(t){console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements.")}}var no=new WeakMap;class ro extends HTMLElement{constructor(){super(),ji(this,no,{writable:!0,value:void 0}),Oi(this,no,this.constructor.formAssociated?new $r(this):new io(this))}get trixId(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++qr),this.trixId)}get labels(){return Ii(this,no).labels}get disabled(){return Ii(this,no).disabled}set disabled(t){Ii(this,no).disabled=t}get required(){return Ii(this,no).required}set required(t){Ii(this,no).required=t}get validity(){return Ii(this,no).validity}get validationMessage(){return Ii(this,no).validationMessage}get willValidate(){return Ii(this,no).willValidate}get type(){return this.localName}get toolbarElement(){var t;if(this.hasAttribute("toolbar"))return null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("toolbar"));if(this.parentNode){const t="trix-toolbar-".concat(this.trixId);return this.setAttribute("toolbar",t),this.internalToolbar=T("trix-toolbar",{id:t}),this.parentNode.insertBefore(this.internalToolbar,this),this.internalToolbar}}get form(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.form}get inputElement(){var t;if(this.hasAttribute("input"))return null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("input"));if(this.parentNode){const t="trix-input-".concat(this.trixId);this.setAttribute("input",t);const e=T("input",{type:"hidden",id:t});return this.parentNode.insertBefore(e,this.nextElementSibling),e}}get editor(){var t;return null===(t=this.editorController)||void 0===t?void 0:t.editor}get name(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.name}get value(){var t;return null===(t=this.inputElement)||void 0===t?void 0:t.value}set value(t){var e;this.defaultValue=t,null===(e=this.editor)||void 0===e||e.loadHTML(this.defaultValue)}attributeChangedCallback(t,e,i){"connected"===t&&this.isConnected&&null!=e&&e!==i&&requestAnimationFrame((()=>this.reconnect()))}notify(t,e){if(this.editorController)return v("trix-".concat(t),{onElement:this,attributes:e})}setFormValue(t){this.inputElement&&(this.inputElement.value=t,Ii(this,no).setFormValue(t))}connectedCallback(){this.hasAttribute("data-trix-internal")||(Hr(this),function(t){t.hasAttribute("role")||t.setAttribute("role","textbox")}(this),this.editorController||(v("trix-before-initialize",{onElement:this}),this.editorController=new _r({editorElement:this,html:this.defaultValue=this.value}),requestAnimationFrame((()=>v("trix-initialize",{onElement:this})))),this.editorController.registerSelectionManager(),Ii(this,no).connectedCallback(),this.toggleAttribute("connected",!0),function(t){!document.querySelector(":focus")&&t.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===t&&t.focus()}(this))}disconnectedCallback(){var t;null===(t=this.editorController)||void 0===t||t.unregisterSelectionManager(),Ii(this,no).disconnectedCallback(),this.toggleAttribute("connected",!1)}reconnect(){this.removeInternalToolbar(),this.disconnectedCallback(),this.connectedCallback()}removeInternalToolbar(){var t;null===(t=this.internalToolbar)||void 0===t||t.remove(),this.internalToolbar=null}checkValidity(){return Ii(this,no).checkValidity()}reportValidity(){return Ii(this,no).reportValidity()}setCustomValidity(t){Ii(this,no).setCustomValidity(t)}formDisabledCallback(t){this.inputElement&&(this.inputElement.disabled=t),this.toggleAttribute("contenteditable",!t)}formResetCallback(){this.reset()}reset(){this.value=this.defaultValue}}Di(ro,"formAssociated","ElementInternals"in window),Di(ro,"observedAttributes",["connected"]);const oo={VERSION:t,config:H,core:Sn,models:qn,views:Hn,controllers:jr,observers:Wr,operations:Ur,elements:Object.freeze({__proto__:null,TrixEditorElement:ro,TrixToolbarElement:Vr}),filters:Object.freeze({__proto__:null,Filter:In,attachmentGalleryFilter:On})};Object.assign(oo,qn),window.Trix=oo,setTimeout((function(){customElements.get("trix-toolbar")||customElements.define("trix-toolbar",Vr),customElements.get("trix-editor")||customElements.define("trix-editor",ro)}),0);export{oo as default}; +var t="2.1.16";const e="[data-trix-attachment]",i={preview:{presentation:"gallery",caption:{name:!0,size:!0}},file:{caption:{size:!0}}},n={default:{tagName:"div",parse:!1},quote:{tagName:"blockquote",nestable:!0},heading1:{tagName:"h1",terminal:!0,breakOnReturn:!0,group:!1},code:{tagName:"pre",terminal:!0,htmlAttributes:["language"],text:{plaintext:!0}},bulletList:{tagName:"ul",parse:!1},bullet:{tagName:"li",listAttribute:"bulletList",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},numberList:{tagName:"ol",parse:!1},number:{tagName:"li",listAttribute:"numberList",group:!1,nestable:!0,test(t){return r(t.parentNode)===n[this.listAttribute].tagName}},attachmentGallery:{tagName:"div",exclusive:!0,terminal:!0,parse:!1,group:!1}},r=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},o=navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i),s=o&&parseInt(o[1]);var a={composesExistingText:/Android.*Chrome/.test(navigator.userAgent),recentAndroid:s&&s>12,samsungAndroid:s&&navigator.userAgent.match(/Android.*SM-/),forcesObjectResizing:/Trident.*rv:11/.test(navigator.userAgent),supportsInputEvents:"undefined"!=typeof InputEvent&&["data","getTargetRanges","inputType"].every((t=>t in InputEvent.prototype))},l={ADD_ATTR:["language"],SAFE_FOR_XML:!1,RETURN_DOM:!0},c={attachFiles:"Attach Files",bold:"Bold",bullets:"Bullets",byte:"Byte",bytes:"Bytes",captionPlaceholder:"Add a caption…",code:"Code",heading1:"Heading",indent:"Increase Level",italic:"Italic",link:"Link",numbers:"Numbers",outdent:"Decrease Level",quote:"Quote",redo:"Redo",remove:"Remove",strike:"Strikethrough",undo:"Undo",unlink:"Unlink",url:"URL",urlPlaceholder:"Enter a URL…",GB:"GB",KB:"KB",MB:"MB",PB:"PB",TB:"TB"};const u=[c.bytes,c.KB,c.MB,c.GB,c.TB,c.PB];var h={prefix:"IEC",precision:2,formatter(t){switch(t){case 0:return"0 ".concat(c.bytes);case 1:return"1 ".concat(c.byte);default:let e;"SI"===this.prefix?e=1e3:"IEC"===this.prefix&&(e=1024);const i=Math.floor(Math.log(t)/Math.log(e)),n=(t/Math.pow(e,i)).toFixed(this.precision).replace(/0*$/,"").replace(/\.$/,"");return"".concat(n," ").concat(u[i])}}};const d="\ufeff",g=" ",m=function(t){for(const e in t){const i=t[e];this[e]=i}return this},p=document.documentElement,f=p.matches,b=function(t){let{onElement:e,matchingSelector:i,withCallback:n,inPhase:r,preventDefault:o,times:s}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=e||p,l=i,c="capturing"===r,u=function(t){null!=s&&0==--s&&u.destroy();const e=x(t.target,{matchingSelector:l});null!=e&&(null==n||n.call(e,t,e),o&&t.preventDefault())};return u.destroy=()=>a.removeEventListener(t,u,c),a.addEventListener(t,u,c),u},v=function(t){let{bubbles:e,cancelable:i,attributes:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e=!1!==e,i=!1!==i;const r=document.createEvent("Events");return r.initEvent(t,e,i),null!=n&&m.call(r,n),r},A=function(t){let{onElement:e,bubbles:i,cancelable:n,attributes:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=null!=e?e:p,s=v(t,{bubbles:i,cancelable:n,attributes:r});return o.dispatchEvent(s)},y=function(t,e){if(1===(null==t?void 0:t.nodeType))return f.call(t,e)},x=function(t){let{matchingSelector:e,untilNode:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;if(null!=t){if(null==e)return t;if(t.closest&&null==i)return t.closest(e);for(;t&&t!==i;){if(y(t,e))return t;t=t.parentNode}}},C=t=>document.activeElement!==t&&E(t,document.activeElement),E=function(t,e){if(t&&e)for(;e;){if(e===t)return!0;e=e.parentNode}},S=function(t){var e;if(null===(e=t)||void 0===e||!e.parentNode)return;let i=0;for(t=t.previousSibling;t;)i++,t=t.previousSibling;return i},k=t=>{var e;return null==t||null===(e=t.parentNode)||void 0===e?void 0:e.removeChild(t)},R=function(t){let{onlyNodesOfType:e,usingFilter:i,expandEntityReferences:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=(()=>{switch(e){case"element":return NodeFilter.SHOW_ELEMENT;case"text":return NodeFilter.SHOW_TEXT;case"comment":return NodeFilter.SHOW_COMMENT;default:return NodeFilter.SHOW_ALL}})();return document.createTreeWalker(t,r,null!=i?i:null,!0===n)},T=t=>{var e;return null==t||null===(e=t.tagName)||void 0===e?void 0:e.toLowerCase()},w=function(t){let e,i,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};"object"==typeof t?(n=t,t=n.tagName):n={attributes:n};const r=document.createElement(t);if(null!=n.editable&&(null==n.attributes&&(n.attributes={}),n.attributes.contenteditable=n.editable),n.attributes)for(e in n.attributes)i=n.attributes[e],r.setAttribute(e,i);if(n.style)for(e in n.style)i=n.style[e],r.style[e]=i;if(n.data)for(e in n.data)i=n.data[e],r.dataset[e]=i;return n.className&&n.className.split(" ").forEach((t=>{r.classList.add(t)})),n.textContent&&(r.textContent=n.textContent),n.childNodes&&[].concat(n.childNodes).forEach((t=>{r.appendChild(t)})),r};let L;const D=function(){if(null!=L)return L;L=[];for(const t in n){const e=n[t];e.tagName&&L.push(e.tagName)}return L},N=t=>O(null==t?void 0:t.firstChild),I=function(t){let{strict:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{strict:!0};return e?O(t):O(t)||!O(t.firstChild)&&function(t){return D().includes(T(t))&&!D().includes(T(t.firstChild))}(t)},O=t=>F(t)&&"block"===(null==t?void 0:t.data),F=t=>(null==t?void 0:t.nodeType)===Node.COMMENT_NODE,P=function(t){let{name:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(t)return _(t)?t.data===d?!e||t.parentNode.dataset.trixCursorTarget===e:void 0:P(t.firstChild)},M=t=>y(t,e),B=t=>_(t)&&""===(null==t?void 0:t.data),_=t=>(null==t?void 0:t.nodeType)===Node.TEXT_NODE,j={level2Enabled:!0,getLevel(){return this.level2Enabled&&a.supportsInputEvents?2:0},pickFiles(t){const e=w("input",{type:"file",multiple:!0,hidden:!0,id:this.fileInputId});e.addEventListener("change",(()=>{t(e.files),k(e)})),k(document.getElementById(this.fileInputId)),document.body.appendChild(e),e.click()}};var W={removeBlankTableCells:!1,tableCellSeparator:" | ",tableRowSeparator:"\n"},U={bold:{tagName:"strong",inheritable:!0,parser(t){const e=window.getComputedStyle(t);return"bold"===e.fontWeight||e.fontWeight>=600}},italic:{tagName:"em",inheritable:!0,parser:t=>"italic"===window.getComputedStyle(t).fontStyle},href:{groupTagName:"a",parser(t){const i="a:not(".concat(e,")"),n=t.closest(i);if(n)return n.getAttribute("href")}},strike:{tagName:"del",inheritable:!0},frozen:{style:{backgroundColor:"highlight"}}},z={getDefaultHTML:()=>'
\n \n \n \n \n \n \n\n \n \n \n \n \n \n \n \n \n\n \n \n \n\n \n\n \n \n \n \n
\n\n
\n \n
')};const V={interval:5e3};var q=Object.freeze({__proto__:null,attachments:i,blockAttributes:n,browser:a,css:{attachment:"attachment",attachmentCaption:"attachment__caption",attachmentCaptionEditor:"attachment__caption-editor",attachmentMetadata:"attachment__metadata",attachmentMetadataContainer:"attachment__metadata-container",attachmentName:"attachment__name",attachmentProgress:"attachment__progress",attachmentSize:"attachment__size",attachmentToolbar:"attachment__toolbar",attachmentGallery:"attachment-gallery"},dompurify:l,fileSize:h,input:j,keyNames:{8:"backspace",9:"tab",13:"return",27:"escape",37:"left",39:"right",46:"delete",68:"d",72:"h",79:"o"},lang:c,parser:W,textAttributes:U,toolbar:z,undo:V});class H{static proxyMethod(t){const{name:e,toMethod:i,toProperty:n,optional:r}=J(t);this.prototype[e]=function(){let t,o;var s,a;i?o=r?null===(s=this[i])||void 0===s?void 0:s.call(this):this[i]():n&&(o=this[n]);return r?(t=null===(a=o)||void 0===a?void 0:a[e],t?K.call(t,o,arguments):void 0):(t=o[e],K.call(t,o,arguments))}}}const J=function(t){const e=t.match(G);if(!e)throw new Error("can't parse @proxyMethod expression: ".concat(t));const i={name:e[4]};return null!=e[2]?i.toMethod=e[1]:i.toProperty=e[1],null!=e[3]&&(i.optional=!0),i},{apply:K}=Function.prototype,G=new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$");var X,$,Y;class Z extends H{static box(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t instanceof this?t:this.fromUCS2String(null==t?void 0:t.toString())}static fromUCS2String(t){return new this(t,it(t))}static fromCodepoints(t){return new this(nt(t),t)}constructor(t,e){super(...arguments),this.ucs2String=t,this.codepoints=e,this.length=this.codepoints.length,this.ucs2Length=this.ucs2String.length}offsetToUCS2Offset(t){return nt(this.codepoints.slice(0,Math.max(0,t))).length}offsetFromUCS2Offset(t){return it(this.ucs2String.slice(0,Math.max(0,t))).length}slice(){return this.constructor.fromCodepoints(this.codepoints.slice(...arguments))}charAt(t){return this.slice(t,t+1)}isEqualTo(t){return this.constructor.box(t).ucs2String===this.ucs2String}toJSON(){return this.ucs2String}getCacheKey(){return this.ucs2String}toString(){return this.ucs2String}}const Q=1===(null===(X=Array.from)||void 0===X?void 0:X.call(Array,"👼").length),tt=null!=(null===($=" ".codePointAt)||void 0===$?void 0:$.call(" ",0)),et=" 👼"===(null===(Y=String.fromCodePoint)||void 0===Y?void 0:Y.call(String,32,128124));let it,nt;it=Q&&tt?t=>Array.from(t).map((t=>t.codePointAt(0))):function(t){const e=[];let i=0;const{length:n}=t;for(;iString.fromCodePoint(...Array.from(t||[])):function(t){return(()=>{const e=[];return Array.from(t).forEach((t=>{let i="";t>65535&&(t-=65536,i+=String.fromCharCode(t>>>10&1023|55296),t=56320|1023&t),e.push(i+String.fromCharCode(t))})),e})().join("")};let rt=0;class ot extends H{static fromJSONString(t){return this.fromJSON(JSON.parse(t))}constructor(){super(...arguments),this.id=++rt}hasSameConstructorAs(t){return this.constructor===(null==t?void 0:t.constructor)}isEqualTo(t){return this===t}inspect(){const t=[],e=this.contentsForInspection()||{};for(const i in e){const n=e[i];t.push("".concat(i,"=").concat(n))}return"#<".concat(this.constructor.name,":").concat(this.id).concat(t.length?" ".concat(t.join(", ")):"",">")}contentsForInspection(){}toJSONString(){return JSON.stringify(this)}toUTF16String(){return Z.box(this)}getCacheKey(){return this.id.toString()}}const st=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;for(let i=0;i1?i-1:0),r=1;r(ut||(ut=vt().concat(ft())),ut),pt=t=>n[t],ft=()=>(ht||(ht=Object.keys(n)),ht),bt=t=>U[t],vt=()=>(dt||(dt=Object.keys(U)),dt),At=function(t,e){yt(t).textContent=e.replace(/%t/g,t)},yt=function(t){const e=document.createElement("style");e.setAttribute("type","text/css"),e.setAttribute("data-tag-name",t.toLowerCase());const i=xt();return i&&e.setAttribute("nonce",i),document.head.insertBefore(e,document.head.firstChild),e},xt=function(){const t=Ct("trix-csp-nonce")||Ct("csp-nonce");if(t){const{nonce:e,content:i}=t;return""==e?i:e}},Ct=t=>document.head.querySelector("meta[name=".concat(t,"]")),Et={"application/x-trix-feature-detection":"test"},St=function(t){const e=t.getData("text/plain"),i=t.getData("text/html");if(!e||!i)return null==e?void 0:e.length;{const{body:t}=(new DOMParser).parseFromString(i,"text/html");if(t.textContent===e)return!t.querySelector("*")}},kt=/Mac|^iP/.test(navigator.platform)?t=>t.metaKey:t=>t.ctrlKey;const Rt=t=>setTimeout(t,1),Tt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={};for(const i in t){const n=t[i];e[i]=n}return e},wt=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(Object.keys(t).length!==Object.keys(e).length)return!1;for(const i in t)if(t[i]!==e[i])return!1;return!0},Lt=function(t){if(null!=t)return Array.isArray(t)||(t=[t,t]),[It(t[0]),It(null!=t[1]?t[1]:t[0])]},Dt=function(t){if(null==t)return;const[e,i]=Lt(t);return Ot(e,i)},Nt=function(t,e){if(null==t||null==e)return;const[i,n]=Lt(t),[r,o]=Lt(e);return Ot(i,r)&&Ot(n,o)},It=function(t){return"number"==typeof t?t:Tt(t)},Ot=function(t,e){return"number"==typeof t?t===e:wt(t,e)};class Ft extends H{constructor(){super(...arguments),this.update=this.update.bind(this),this.selectionManagers=[]}start(){this.started||(this.started=!0,document.addEventListener("selectionchange",this.update,!0))}stop(){if(this.started)return this.started=!1,document.removeEventListener("selectionchange",this.update,!0)}registerSelectionManager(t){if(!this.selectionManagers.includes(t))return this.selectionManagers.push(t),this.start()}unregisterSelectionManager(t){if(this.selectionManagers=this.selectionManagers.filter((e=>e!==t)),0===this.selectionManagers.length)return this.stop()}notifySelectionManagersOfSelectionChange(){return this.selectionManagers.map((t=>t.selectionDidChange()))}update(){this.notifySelectionManagersOfSelectionChange()}reset(){this.update()}}const Pt=new Ft,Mt=function(){const t=window.getSelection();if(t.rangeCount>0)return t},Bt=function(){var t;const e=null===(t=Mt())||void 0===t?void 0:t.getRangeAt(0);if(e&&!jt(e))return e},_t=function(t){const e=window.getSelection();return e.removeAllRanges(),e.addRange(t),Pt.update()},jt=t=>Wt(t.startContainer)||Wt(t.endContainer),Wt=t=>!Object.getPrototypeOf(t),Ut=t=>t.replace(new RegExp("".concat(d),"g"),"").replace(new RegExp("".concat(g),"g")," "),Ht=new RegExp("[^\\S".concat(g,"]")),zt=t=>t.replace(new RegExp("".concat(Ht.source),"g")," ").replace(/\ {2,}/g," "),Vt=function(t,e){if(t.isEqualTo(e))return["",""];const i=qt(t,e),{length:n}=i.utf16String;let r;if(n){const{offset:o}=i,s=t.codepoints.slice(0,o).concat(t.codepoints.slice(o+n));r=qt(e,Z.fromCodepoints(s))}else r=qt(e,t);return[i.utf16String.toString(),r.utf16String.toString()]},qt=function(t,e){let i=0,n=t.length,r=e.length;for(;ii+1&&t.charAt(n-1).isEqualTo(e.charAt(r-1));)n--,r--;return{utf16String:t.slice(i,n),offset:i}};class Jt extends ot{static fromCommonAttributesOfObjects(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];if(!t.length)return new this;let e=$t(t[0]),i=e.getKeys();return t.slice(1).forEach((t=>{i=e.getKeysCommonToHash($t(t)),e=e.slice(i)})),e}static box(t){return $t(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(...arguments),this.values=Xt(t)}add(t,e){return this.merge(Kt(t,e))}remove(t){return new Jt(Xt(this.values,t))}get(t){return this.values[t]}has(t){return t in this.values}merge(t){return new Jt(Gt(this.values,Yt(t)))}slice(t){const e={};return Array.from(t).forEach((t=>{this.has(t)&&(e[t]=this.values[t])})),new Jt(e)}getKeys(){return Object.keys(this.values)}getKeysCommonToHash(t){return t=$t(t),this.getKeys().filter((e=>this.values[e]===t.values[e]))}isEqualTo(t){return st(this.toArray(),$t(t).toArray())}isEmpty(){return 0===this.getKeys().length}toArray(){if(!this.array){const t=[];for(const e in this.values){const i=this.values[e];t.push(t.push(e,i))}this.array=t.slice(0)}return this.array}toObject(){return Xt(this.values)}toJSON(){return this.toObject()}contentsForInspection(){return{values:JSON.stringify(this.values)}}}const Kt=function(t,e){const i={};return i[t]=e,i},Gt=function(t,e){const i=Xt(t);for(const t in e){const n=e[t];i[t]=n}return i},Xt=function(t,e){const i={};return Object.keys(t).sort().forEach((n=>{n!==e&&(i[n]=t[n])})),i},$t=function(t){return t instanceof Jt?t:new Jt(t)},Yt=function(t){return t instanceof Jt?t.values:t};class Zt{static groupObjects(){let t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:i,asTree:n}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};n&&null==i&&(i=0);const r=[];return Array.from(e).forEach((e=>{var o;if(t){var s,a,l;if(null!==(s=e.canBeGrouped)&&void 0!==s&&s.call(e,i)&&null!==(a=(l=t[t.length-1]).canBeGroupedWith)&&void 0!==a&&a.call(l,e,i))return void t.push(e);r.push(new this(t,{depth:i,asTree:n})),t=null}null!==(o=e.canBeGrouped)&&void 0!==o&&o.call(e,i)?t=[e]:r.push(e)})),t&&r.push(new this(t,{depth:i,asTree:n})),r}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{depth:e,asTree:i}=arguments.length>1?arguments[1]:void 0;this.objects=t,i&&(this.depth=e,this.objects=this.constructor.groupObjects(this.objects,{asTree:i,depth:this.depth+1}))}getObjects(){return this.objects}getDepth(){return this.depth}getCacheKey(){const t=["objectGroup"];return Array.from(this.getObjects()).forEach((e=>{t.push(e.getCacheKey())})),t.join("/")}}class Qt extends H{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects={},Array.from(t).forEach((t=>{const e=JSON.stringify(t);null==this.objects[e]&&(this.objects[e]=t)}))}find(t){const e=JSON.stringify(t);return this.objects[e]}}class te{constructor(t){this.reset(t)}add(t){const e=ee(t);this.elements[e]=t}remove(t){const e=ee(t),i=this.elements[e];if(i)return delete this.elements[e],i}reset(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return this.elements={},Array.from(t).forEach((t=>{this.add(t)})),t}}const ee=t=>t.dataset.trixStoreKey;class ie extends H{isPerforming(){return!0===this.performing}hasPerformed(){return!0===this.performed}hasSucceeded(){return this.performed&&this.succeeded}hasFailed(){return this.performed&&!this.succeeded}getPromise(){return this.promise||(this.promise=new Promise(((t,e)=>(this.performing=!0,this.perform(((i,n)=>{this.succeeded=i,this.performing=!1,this.performed=!0,this.succeeded?t(n):e(n)})))))),this.promise}perform(t){return t(!1)}release(){var t,e;null===(t=this.promise)||void 0===t||null===(e=t.cancel)||void 0===e||e.call(t),this.promise=null,this.performing=null,this.performed=null,this.succeeded=null}}ie.proxyMethod("getPromise().then"),ie.proxyMethod("getPromise().catch");class ne extends H{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.object=t,this.options=e,this.childViews=[],this.rootView=this}getNodes(){return this.nodes||(this.nodes=this.createNodes()),this.nodes.map((t=>t.cloneNode(!0)))}invalidate(){var t;return this.nodes=null,this.childViews=[],null===(t=this.parentView)||void 0===t?void 0:t.invalidate()}invalidateViewForObject(t){var e;return null===(e=this.findViewForObject(t))||void 0===e?void 0:e.invalidate()}findOrCreateCachedChildView(t,e,i){let n=this.getCachedViewForObject(e);return n?this.recordChildView(n):(n=this.createChildView(...arguments),this.cacheViewForObject(n,e)),n}createChildView(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};e instanceof Zt&&(i.viewClass=t,t=re);const n=new t(e,i);return this.recordChildView(n)}recordChildView(t){return t.parentView=this,t.rootView=this.rootView,this.childViews.push(t),t}getAllChildViews(){let t=[];return this.childViews.forEach((e=>{t.push(e),t=t.concat(e.getAllChildViews())})),t}findElement(){return this.findElementForObject(this.object)}findElementForObject(t){const e=null==t?void 0:t.id;if(e)return this.rootView.element.querySelector("[data-trix-id='".concat(e,"']"))}findViewForObject(t){for(const e of this.getAllChildViews())if(e.object===t)return e}getViewCache(){return this.rootView!==this?this.rootView.getViewCache():this.isViewCachingEnabled()?(this.viewCache||(this.viewCache={}),this.viewCache):void 0}isViewCachingEnabled(){return!1!==this.shouldCacheViews}enableViewCaching(){this.shouldCacheViews=!0}disableViewCaching(){this.shouldCacheViews=!1}getCachedViewForObject(t){var e;return null===(e=this.getViewCache())||void 0===e?void 0:e[t.getCacheKey()]}cacheViewForObject(t,e){const i=this.getViewCache();i&&(i[e.getCacheKey()]=t)}garbageCollectCachedViews(){const t=this.getViewCache();if(t){const e=this.getAllChildViews().concat(this).map((t=>t.object.getCacheKey()));for(const i in t)e.includes(i)||delete t[i]}}}class re extends ne{constructor(){super(...arguments),this.objectGroup=this.object,this.viewClass=this.options.viewClass,delete this.options.viewClass}getChildViews(){return this.childViews.length||Array.from(this.objectGroup.getObjects()).forEach((t=>{this.findOrCreateCachedChildView(this.viewClass,t,this.options)})),this.childViews}createNodes(){const t=this.createContainerElement();return this.getChildViews().forEach((e=>{Array.from(e.getNodes()).forEach((e=>{t.appendChild(e)}))})),[t]}createContainerElement(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.objectGroup.getDepth();return this.getChildViews()[0].createContainerElement(t)}} +/*! @license DOMPurify 3.2.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.7/LICENSE */const{entries:oe,setPrototypeOf:se,isFrozen:ae,getPrototypeOf:le,getOwnPropertyDescriptor:ce}=Object;let{freeze:ue,seal:he,create:de}=Object,{apply:ge,construct:me}="undefined"!=typeof Reflect&&Reflect;ue||(ue=function(t){return t}),he||(he=function(t){return t}),ge||(ge=function(t,e){for(var i=arguments.length,n=new Array(i>2?i-2:0),r=2;r1?e-1:0),n=1;n1?i-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:ye;se&&se(t,null);let n=e.length;for(;n--;){let r=e[n];if("string"==typeof r){const t=i(r);t!==r&&(ae(e)||(e[n]=t),r=t)}t[r]=!0}return t}function Ie(t){for(let e=0;e/gm),Ge=he(/\$\{[\w\W]*/gm),Xe=he(/^data-[\-\w.\u00B7-\uFFFF]+$/),$e=he(/^aria-[\-\w]+$/),Ye=he(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ze=he(/^(?:\w+script|data):/i),Qe=he(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ti=he(/^html$/i),ei=he(/^[a-z][.\w]*(-[.\w]+)+$/i);var ii=Object.freeze({__proto__:null,ARIA_ATTR:$e,ATTR_WHITESPACE:Qe,CUSTOM_ELEMENT:ei,DATA_ATTR:Xe,DOCTYPE_NAME:ti,ERB_EXPR:Ke,IS_ALLOWED_URI:Ye,IS_SCRIPT_OR_DATA:Ze,MUSTACHE_EXPR:Je,TMPLIT_EXPR:Ge});const ni=1,ri=3,oi=7,si=8,ai=9,li=function(){return"undefined"==typeof window?null:window};var ci=function t(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:li();const i=e=>t(e);if(i.version="3.2.7",i.removed=[],!e||!e.document||e.document.nodeType!==ai||!e.Element)return i.isSupported=!1,i;let{document:n}=e;const r=n,o=r.currentScript,{DocumentFragment:s,HTMLTemplateElement:a,Node:l,Element:c,NodeFilter:u,NamedNodeMap:h=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:g,trustedTypes:m}=e,p=c.prototype,f=Fe(p,"cloneNode"),b=Fe(p,"remove"),v=Fe(p,"nextSibling"),A=Fe(p,"childNodes"),y=Fe(p,"parentNode");if("function"==typeof a){const t=n.createElement("template");t.content&&t.content.ownerDocument&&(n=t.content.ownerDocument)}let x,C="";const{implementation:E,createNodeIterator:S,createDocumentFragment:k,getElementsByTagName:R}=n,{importNode:T}=r;let w={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};i.isSupported="function"==typeof oe&&"function"==typeof y&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:L,ERB_EXPR:D,TMPLIT_EXPR:N,DATA_ATTR:I,ARIA_ATTR:O,IS_SCRIPT_OR_DATA:F,ATTR_WHITESPACE:P,CUSTOM_ELEMENT:M}=ii;let{IS_ALLOWED_URI:B}=ii,_=null;const j=Ne({},[...Pe,...Me,...Be,...je,...Ue]);let W=null;const U=Ne({},[...He,...ze,...Ve,...qe]);let z=Object.seal(de(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),V=null,q=null,J=!0,K=!0,G=!1,X=!0,$=!1,Y=!0,Q=!1,tt=!1,et=!1,it=!1,nt=!1,rt=!1,st=!0,at=!1,lt=!0,ct=!1,ut={},ht=null;const dt=Ne({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let gt=null;const mt=Ne({},["audio","video","img","source","image","track"]);let pt=null;const ft=Ne({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),bt="http://www.w3.org/1998/Math/MathML",vt="http://www.w3.org/2000/svg",At="http://www.w3.org/1999/xhtml";let yt=At,xt=!1,Ct=null;const Et=Ne({},[bt,vt,At],xe);let St=Ne({},["mi","mo","mn","ms","mtext"]),kt=Ne({},["annotation-xml"]);const Rt=Ne({},["title","style","font","a","script"]);let Tt=null;const wt=["application/xhtml+xml","text/html"];let Lt=null,Dt=null;const Nt=n.createElement("form"),It=function(t){return t instanceof RegExp||t instanceof Function},Ot=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!Dt||Dt!==t){if(t&&"object"==typeof t||(t={}),t=Oe(t),Tt=-1===wt.indexOf(t.PARSER_MEDIA_TYPE)?"text/html":t.PARSER_MEDIA_TYPE,Lt="application/xhtml+xml"===Tt?xe:ye,_=Re(t,"ALLOWED_TAGS")?Ne({},t.ALLOWED_TAGS,Lt):j,W=Re(t,"ALLOWED_ATTR")?Ne({},t.ALLOWED_ATTR,Lt):U,Ct=Re(t,"ALLOWED_NAMESPACES")?Ne({},t.ALLOWED_NAMESPACES,xe):Et,pt=Re(t,"ADD_URI_SAFE_ATTR")?Ne(Oe(ft),t.ADD_URI_SAFE_ATTR,Lt):ft,gt=Re(t,"ADD_DATA_URI_TAGS")?Ne(Oe(mt),t.ADD_DATA_URI_TAGS,Lt):mt,ht=Re(t,"FORBID_CONTENTS")?Ne({},t.FORBID_CONTENTS,Lt):dt,V=Re(t,"FORBID_TAGS")?Ne({},t.FORBID_TAGS,Lt):Oe({}),q=Re(t,"FORBID_ATTR")?Ne({},t.FORBID_ATTR,Lt):Oe({}),ut=!!Re(t,"USE_PROFILES")&&t.USE_PROFILES,J=!1!==t.ALLOW_ARIA_ATTR,K=!1!==t.ALLOW_DATA_ATTR,G=t.ALLOW_UNKNOWN_PROTOCOLS||!1,X=!1!==t.ALLOW_SELF_CLOSE_IN_ATTR,$=t.SAFE_FOR_TEMPLATES||!1,Y=!1!==t.SAFE_FOR_XML,Q=t.WHOLE_DOCUMENT||!1,it=t.RETURN_DOM||!1,nt=t.RETURN_DOM_FRAGMENT||!1,rt=t.RETURN_TRUSTED_TYPE||!1,et=t.FORCE_BODY||!1,st=!1!==t.SANITIZE_DOM,at=t.SANITIZE_NAMED_PROPS||!1,lt=!1!==t.KEEP_CONTENT,ct=t.IN_PLACE||!1,B=t.ALLOWED_URI_REGEXP||Ye,yt=t.NAMESPACE||At,St=t.MATHML_TEXT_INTEGRATION_POINTS||St,kt=t.HTML_INTEGRATION_POINTS||kt,z=t.CUSTOM_ELEMENT_HANDLING||{},t.CUSTOM_ELEMENT_HANDLING&&It(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(z.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&It(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(z.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(z.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),$&&(K=!1),nt&&(it=!0),ut&&(_=Ne({},Ue),W=[],!0===ut.html&&(Ne(_,Pe),Ne(W,He)),!0===ut.svg&&(Ne(_,Me),Ne(W,ze),Ne(W,qe)),!0===ut.svgFilters&&(Ne(_,Be),Ne(W,ze),Ne(W,qe)),!0===ut.mathMl&&(Ne(_,je),Ne(W,Ve),Ne(W,qe))),t.ADD_TAGS&&(_===j&&(_=Oe(_)),Ne(_,t.ADD_TAGS,Lt)),t.ADD_ATTR&&(W===U&&(W=Oe(W)),Ne(W,t.ADD_ATTR,Lt)),t.ADD_URI_SAFE_ATTR&&Ne(pt,t.ADD_URI_SAFE_ATTR,Lt),t.FORBID_CONTENTS&&(ht===dt&&(ht=Oe(ht)),Ne(ht,t.FORBID_CONTENTS,Lt)),lt&&(_["#text"]=!0),Q&&Ne(_,["html","head","body"]),_.table&&(Ne(_,["tbody"]),delete V.tbody),t.TRUSTED_TYPES_POLICY){if("function"!=typeof t.TRUSTED_TYPES_POLICY.createHTML)throw we('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof t.TRUSTED_TYPES_POLICY.createScriptURL)throw we('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');x=t.TRUSTED_TYPES_POLICY,C=x.createHTML("")}else void 0===x&&(x=function(t,e){if("object"!=typeof t||"function"!=typeof t.createPolicy)return null;let i=null;const n="data-tt-policy-suffix";e&&e.hasAttribute(n)&&(i=e.getAttribute(n));const r="dompurify"+(i?"#"+i:"");try{return t.createPolicy(r,{createHTML:t=>t,createScriptURL:t=>t})}catch(t){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(m,o)),null!==x&&"string"==typeof C&&(C=x.createHTML(""));ue&&ue(t),Dt=t}},Pt=Ne({},[...Me,...Be,..._e]),Mt=Ne({},[...je,...We]),Bt=function(t){ve(i.removed,{element:t});try{y(t).removeChild(t)}catch(e){b(t)}},_t=function(t,e){try{ve(i.removed,{attribute:e.getAttributeNode(t),from:e})}catch(t){ve(i.removed,{attribute:null,from:e})}if(e.removeAttribute(t),"is"===t)if(it||nt)try{Bt(e)}catch(t){}else try{e.setAttribute(t,"")}catch(t){}},jt=function(t){let e=null,i=null;if(et)t=""+t;else{const e=Ce(t,/^[\r\n\t ]+/);i=e&&e[0]}"application/xhtml+xml"===Tt&&yt===At&&(t=''+t+"");const r=x?x.createHTML(t):t;if(yt===At)try{e=(new g).parseFromString(r,Tt)}catch(t){}if(!e||!e.documentElement){e=E.createDocument(yt,"template",null);try{e.documentElement.innerHTML=xt?C:r}catch(t){}}const o=e.body||e.documentElement;return t&&i&&o.insertBefore(n.createTextNode(i),o.childNodes[0]||null),yt===At?R.call(e,Q?"html":"body")[0]:Q?e.documentElement:o},Wt=function(t){return S.call(t.ownerDocument||t,t,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Ut=function(t){return t instanceof d&&("string"!=typeof t.nodeName||"string"!=typeof t.textContent||"function"!=typeof t.removeChild||!(t.attributes instanceof h)||"function"!=typeof t.removeAttribute||"function"!=typeof t.setAttribute||"string"!=typeof t.namespaceURI||"function"!=typeof t.insertBefore||"function"!=typeof t.hasChildNodes)},Ht=function(t){return"function"==typeof l&&t instanceof l};function zt(t,e,n){pe(t,(t=>{t.call(i,e,n,Dt)}))}const Vt=function(t){let e=null;if(zt(w.beforeSanitizeElements,t,null),Ut(t))return Bt(t),!0;const n=Lt(t.nodeName);if(zt(w.uponSanitizeElement,t,{tagName:n,allowedTags:_}),Y&&t.hasChildNodes()&&!Ht(t.firstElementChild)&&Te(/<[/\w!]/g,t.innerHTML)&&Te(/<[/\w!]/g,t.textContent))return Bt(t),!0;if(t.nodeType===oi)return Bt(t),!0;if(Y&&t.nodeType===si&&Te(/<[/\w]/g,t.data))return Bt(t),!0;if(!_[n]||V[n]){if(!V[n]&&Kt(n)){if(z.tagNameCheck instanceof RegExp&&Te(z.tagNameCheck,n))return!1;if(z.tagNameCheck instanceof Function&&z.tagNameCheck(n))return!1}if(lt&&!ht[n]){const e=y(t)||t.parentNode,i=A(t)||t.childNodes;if(i&&e)for(let n=i.length-1;n>=0;--n){const r=f(i[n],!0);r.__removalCount=(t.__removalCount||0)+1,e.insertBefore(r,v(t))}}return Bt(t),!0}return t instanceof c&&!function(t){let e=y(t);e&&e.tagName||(e={namespaceURI:yt,tagName:"template"});const i=ye(t.tagName),n=ye(e.tagName);return!!Ct[t.namespaceURI]&&(t.namespaceURI===vt?e.namespaceURI===At?"svg"===i:e.namespaceURI===bt?"svg"===i&&("annotation-xml"===n||St[n]):Boolean(Pt[i]):t.namespaceURI===bt?e.namespaceURI===At?"math"===i:e.namespaceURI===vt?"math"===i&&kt[n]:Boolean(Mt[i]):t.namespaceURI===At?!(e.namespaceURI===vt&&!kt[n])&&!(e.namespaceURI===bt&&!St[n])&&!Mt[i]&&(Rt[i]||!Pt[i]):!("application/xhtml+xml"!==Tt||!Ct[t.namespaceURI]))}(t)?(Bt(t),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!Te(/<\/no(script|embed|frames)/i,t.innerHTML)?($&&t.nodeType===ri&&(e=t.textContent,pe([L,D,N],(t=>{e=Ee(e,t," ")})),t.textContent!==e&&(ve(i.removed,{element:t.cloneNode()}),t.textContent=e)),zt(w.afterSanitizeElements,t,null),!1):(Bt(t),!0)},qt=function(t,e,i){if(st&&("id"===e||"name"===e)&&(i in n||i in Nt))return!1;if(K&&!q[e]&&Te(I,e));else if(J&&Te(O,e));else if(!W[e]||q[e]){if(!(Kt(t)&&(z.tagNameCheck instanceof RegExp&&Te(z.tagNameCheck,t)||z.tagNameCheck instanceof Function&&z.tagNameCheck(t))&&(z.attributeNameCheck instanceof RegExp&&Te(z.attributeNameCheck,e)||z.attributeNameCheck instanceof Function&&z.attributeNameCheck(e,t))||"is"===e&&z.allowCustomizedBuiltInElements&&(z.tagNameCheck instanceof RegExp&&Te(z.tagNameCheck,i)||z.tagNameCheck instanceof Function&&z.tagNameCheck(i))))return!1}else if(pt[e]);else if(Te(B,Ee(i,P,"")));else if("src"!==e&&"xlink:href"!==e&&"href"!==e||"script"===t||0!==Se(i,"data:")||!gt[t])if(G&&!Te(F,Ee(i,P,"")));else if(i)return!1;return!0},Kt=function(t){return"annotation-xml"!==t&&Ce(t,M)},Gt=function(t){zt(w.beforeSanitizeAttributes,t,null);const{attributes:e}=t;if(!e||Ut(t))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:W,forceKeepAttr:void 0};let r=e.length;for(;r--;){const o=e[r],{name:s,namespaceURI:a,value:l}=o,c=Lt(s),u=l;let h="value"===s?u:ke(u);if(n.attrName=c,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,zt(w.uponSanitizeAttribute,t,n),h=n.attrValue,!at||"id"!==c&&"name"!==c||(_t(s,t),h="user-content-"+h),Y&&Te(/((--!?|])>)|<\/(style|title|textarea)/i,h)){_t(s,t);continue}if("attributename"===c&&Ce(h,"href")){_t(s,t);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){_t(s,t);continue}if(!X&&Te(/\/>/i,h)){_t(s,t);continue}$&&pe([L,D,N],(t=>{h=Ee(h,t," ")}));const d=Lt(t.nodeName);if(qt(d,c,h)){if(x&&"object"==typeof m&&"function"==typeof m.getAttributeType)if(a);else switch(m.getAttributeType(d,c)){case"TrustedHTML":h=x.createHTML(h);break;case"TrustedScriptURL":h=x.createScriptURL(h)}if(h!==u)try{a?t.setAttributeNS(a,s,h):t.setAttribute(s,h),Ut(t)?Bt(t):be(i.removed)}catch(e){_t(s,t)}}else _t(s,t)}zt(w.afterSanitizeAttributes,t,null)},Xt=function t(e){let i=null;const n=Wt(e);for(zt(w.beforeSanitizeShadowDOM,e,null);i=n.nextNode();)zt(w.uponSanitizeShadowNode,i,null),Vt(i),Gt(i),i.content instanceof s&&t(i.content);zt(w.afterSanitizeShadowDOM,e,null)};return i.sanitize=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,o=null,a=null,c=null;if(xt=!t,xt&&(t="\x3c!--\x3e"),"string"!=typeof t&&!Ht(t)){if("function"!=typeof t.toString)throw we("toString is not a function");if("string"!=typeof(t=t.toString()))throw we("dirty is not a string, aborting")}if(!i.isSupported)return t;if(tt||Ot(e),i.removed=[],"string"==typeof t&&(ct=!1),ct){if(t.nodeName){const e=Lt(t.nodeName);if(!_[e]||V[e])throw we("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)n=jt("\x3c!----\x3e"),o=n.ownerDocument.importNode(t,!0),o.nodeType===ni&&"BODY"===o.nodeName||"HTML"===o.nodeName?n=o:n.appendChild(o);else{if(!it&&!$&&!Q&&-1===t.indexOf("<"))return x&&rt?x.createHTML(t):t;if(n=jt(t),!n)return it?null:rt?C:""}n&&et&&Bt(n.firstChild);const u=Wt(ct?t:n);for(;a=u.nextNode();)Vt(a),Gt(a),a.content instanceof s&&Xt(a.content);if(ct)return t;if(it){if(nt)for(c=k.call(n.ownerDocument);n.firstChild;)c.appendChild(n.firstChild);else c=n;return(W.shadowroot||W.shadowrootmode)&&(c=T.call(r,c,!0)),c}let h=Q?n.outerHTML:n.innerHTML;return Q&&_["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&Te(ti,n.ownerDocument.doctype.name)&&(h="\n"+h),$&&pe([L,D,N],(t=>{h=Ee(h,t," ")})),x&&rt?x.createHTML(h):h},i.setConfig=function(){Ot(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),tt=!0},i.clearConfig=function(){Dt=null,tt=!1},i.isValidAttribute=function(t,e,i){Dt||Ot({});const n=Lt(t),r=Lt(e);return qt(n,r,i)},i.addHook=function(t,e){"function"==typeof e&&ve(w[t],e)},i.removeHook=function(t,e){if(void 0!==e){const i=fe(w[t],e);return-1===i?void 0:Ae(w[t],i,1)[0]}return be(w[t])},i.removeHooks=function(t){w[t]=[]},i.removeAllHooks=function(){w={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},i}();ci.addHook("uponSanitizeAttribute",(function(t,e){/^data-trix-/.test(e.attrName)&&(e.forceKeepAttr=!0)}));const ui="style href src width height language class".split(" "),hi="javascript:".split(" "),di="script iframe form noscript".split(" ");class gi extends H{static setHTML(t,e,i){const n=new this(e,i).sanitize(),r=n.getHTML?n.getHTML():n.outerHTML;t.innerHTML=r}static sanitize(t,e){const i=new this(t,e);return i.sanitize(),i}constructor(t){let{allowedAttributes:e,forbiddenProtocols:i,forbiddenElements:n,purifyOptions:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.allowedAttributes=e||ui,this.forbiddenProtocols=i||hi,this.forbiddenElements=n||di,this.purifyOptions=r||{},this.body=mi(t)}sanitize(){this.sanitizeElements(),this.normalizeListElementNesting();const t=Object.assign({},l,this.purifyOptions);return ci.setConfig(t),this.body=ci.sanitize(this.body),this.body}getHTML(){return this.body.innerHTML}getBody(){return this.body}sanitizeElements(){const t=R(this.body),e=[];for(;t.nextNode();){const i=t.currentNode;switch(i.nodeType){case Node.ELEMENT_NODE:this.elementIsRemovable(i)?e.push(i):this.sanitizeElement(i);break;case Node.COMMENT_NODE:e.push(i)}}return e.forEach((t=>k(t))),this.body}sanitizeElement(t){return t.hasAttribute("href")&&this.forbiddenProtocols.includes(t.protocol)&&t.removeAttribute("href"),Array.from(t.attributes).forEach((e=>{let{name:i}=e;this.allowedAttributes.includes(i)||0===i.indexOf("data-trix")||t.removeAttribute(i)})),t}normalizeListElementNesting(){return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t=>{const e=t.previousElementSibling;e&&"li"===T(e)&&e.appendChild(t)})),this.body}elementIsRemovable(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE)return this.elementIsForbidden(t)||this.elementIsntSerializable(t)}elementIsForbidden(t){return this.forbiddenElements.includes(T(t))}elementIsntSerializable(t){return"false"===t.getAttribute("data-trix-serialize")&&!M(t)}}const mi=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";t=t.replace(/<\/html[^>]*>[^]*$/i,"");const e=document.implementation.createHTMLDocument("");return e.documentElement.innerHTML=t,Array.from(e.head.querySelectorAll("style")).forEach((t=>{e.body.appendChild(t)})),e.body},{css:pi}=q;class fi extends ne{constructor(){super(...arguments),this.attachment=this.object,this.attachment.uploadProgressDelegate=this,this.attachmentPiece=this.options.piece}createContentNodes(){return[]}createNodes(){let t;const e=t=w({tagName:"figure",className:this.getClassName(),data:this.getData(),editable:!1}),i=this.getHref();return i&&(t=w({tagName:"a",editable:!1,attributes:{href:i,tabindex:-1}}),e.appendChild(t)),this.attachment.hasContent()?gi.setHTML(t,this.attachment.getContent()):this.createContentNodes().forEach((e=>{t.appendChild(e)})),t.appendChild(this.createCaptionElement()),this.attachment.isPending()&&(this.progressElement=w({tagName:"progress",attributes:{class:pi.attachmentProgress,value:this.attachment.getUploadProgress(),max:100},data:{trixMutable:!0,trixStoreKey:["progressElement",this.attachment.id].join("/")}}),e.appendChild(this.progressElement)),[bi("left"),e,bi("right")]}createCaptionElement(){const t=w({tagName:"figcaption",className:pi.attachmentCaption}),e=this.attachmentPiece.getCaption();if(e)t.classList.add("".concat(pi.attachmentCaption,"--edited")),t.textContent=e;else{let e,i;const n=this.getCaptionConfig();if(n.name&&(e=this.attachment.getFilename()),n.size&&(i=this.attachment.getFormattedFilesize()),e){const i=w({tagName:"span",className:pi.attachmentName,textContent:e});t.appendChild(i)}if(i){e&&t.appendChild(document.createTextNode(" "));const n=w({tagName:"span",className:pi.attachmentSize,textContent:i});t.appendChild(n)}}return t}getClassName(){const t=[pi.attachment,"".concat(pi.attachment,"--").concat(this.attachment.getType())],e=this.attachment.getExtension();return e&&t.push("".concat(pi.attachment,"--").concat(e)),t.join(" ")}getData(){const t={trixAttachment:JSON.stringify(this.attachment),trixContentType:this.attachment.getContentType(),trixId:this.attachment.id},{attributes:e}=this.attachmentPiece;return e.isEmpty()||(t.trixAttributes=JSON.stringify(e)),this.attachment.isPending()&&(t.trixSerialize=!1),t}getHref(){if(!vi(this.attachment.getContent(),"a")){const t=this.attachment.getHref();if(t&&ci.isValidAttribute("a","href",t))return t}}getCaptionConfig(){var t;const e=this.attachment.getType(),n=Tt(null===(t=i[e])||void 0===t?void 0:t.caption);return"file"===e&&(n.name=!0),n}findProgressElement(){var t;return null===(t=this.findElement())||void 0===t?void 0:t.querySelector("progress")}attachmentDidChangeUploadProgress(){const t=this.attachment.getUploadProgress(),e=this.findProgressElement();e&&(e.value=t)}}const bi=t=>w({tagName:"span",textContent:d,data:{trixCursorTarget:t,trixSerialize:!1}}),vi=function(t,e){const i=w("div");return gi.setHTML(i,t||""),i.querySelector(e)};class Ai extends fi{constructor(){super(...arguments),this.attachment.previewDelegate=this}createContentNodes(){return this.image=w({tagName:"img",attributes:{src:""},data:{trixMutable:!0}}),this.refresh(this.image),[this.image]}createCaptionElement(){const t=super.createCaptionElement(...arguments);return t.textContent||t.setAttribute("data-trix-placeholder",c.captionPlaceholder),t}refresh(t){var e;t||(t=null===(e=this.findElement())||void 0===e?void 0:e.querySelector("img"));if(t)return this.updateAttributesForImage(t)}updateAttributesForImage(t){const e=this.attachment.getURL(),i=this.attachment.getPreviewURL();if(t.src=i||e,i===e)t.removeAttribute("data-trix-serialized-attributes");else{const i=JSON.stringify({src:e});t.setAttribute("data-trix-serialized-attributes",i)}const n=this.attachment.getWidth(),r=this.attachment.getHeight(),o=this.attachment.getAttribute("alt");null!=n&&(t.width=n),null!=r&&(t.height=r),null!=o&&(t.alt=o);const s=["imageElement",this.attachment.id,t.src,t.width,t.height].join("/");t.dataset.trixStoreKey=s}attachmentDidChangeAttributes(){return this.refresh(this.image),this.refresh()}}class yi extends ne{constructor(){super(...arguments),this.piece=this.object,this.attributes=this.piece.getAttributes(),this.textConfig=this.options.textConfig,this.context=this.options.context,this.piece.attachment?this.attachment=this.piece.attachment:this.string=this.piece.toString()}createNodes(){let t=this.attachment?this.createAttachmentNodes():this.createStringNodes();const e=this.createElement();if(e){const i=function(t){for(;null!==(e=t)&&void 0!==e&&e.firstElementChild;){var e;t=t.firstElementChild}return t}(e);Array.from(t).forEach((t=>{i.appendChild(t)})),t=[e]}return t}createAttachmentNodes(){const t=this.attachment.isPreviewable()?Ai:fi;return this.createChildView(t,this.piece.attachment,{piece:this.piece}).getNodes()}createStringNodes(){var t;if(null!==(t=this.textConfig)&&void 0!==t&&t.plaintext)return[document.createTextNode(this.string)];{const t=[],e=this.string.split("\n");for(let i=0;i0){const e=w("br");t.push(e)}if(n.length){const e=document.createTextNode(this.preserveSpaces(n));t.push(e)}}return t}}createElement(){let t,e,i;const n={};for(e in this.attributes){i=this.attributes[e];const o=bt(e);if(o){if(o.tagName){var r;const e=w(o.tagName);r?(r.appendChild(e),r=e):t=r=e}if(o.styleProperty&&(n[o.styleProperty]=i),o.style)for(e in o.style)i=o.style[e],n[e]=i}}if(Object.keys(n).length)for(e in t||(t=w("span")),n)i=n[e],t.style[e]=i;return t}createContainerElement(){for(const t in this.attributes){const e=this.attributes[t],i=bt(t);if(i&&i.groupTagName){const n={};return n[t]=e,w(i.groupTagName,n)}}}preserveSpaces(t){return this.context.isLast&&(t=t.replace(/\ $/,g)),t=t.replace(/(\S)\ {3}(\S)/g,"$1 ".concat(g," $2")).replace(/\ {2}/g,"".concat(g," ")).replace(/\ {2}/g," ".concat(g)),(this.context.isFirst||this.context.followsWhitespace)&&(t=t.replace(/^\ /,g)),t}}class xi extends ne{constructor(){super(...arguments),this.text=this.object,this.textConfig=this.options.textConfig}createNodes(){const t=[],e=Zt.groupObjects(this.getPieces()),i=e.length-1;for(let r=0;r!t.hasAttribute("blockBreak")))}}const Ci=t=>/\s$/.test(null==t?void 0:t.toString()),{css:Ei}=q;class Si extends ne{constructor(){super(...arguments),this.block=this.object,this.attributes=this.block.getAttributes()}createNodes(){const t=[document.createComment("block")];if(this.block.isEmpty())t.push(w("br"));else{var e;const i=null===(e=pt(this.block.getLastAttribute()))||void 0===e?void 0:e.text,n=this.findOrCreateCachedChildView(xi,this.block.text,{textConfig:i});t.push(...Array.from(n.getNodes()||[])),this.shouldAddExtraNewlineElement()&&t.push(w("br"))}if(this.attributes.length)return t;{let e;const{tagName:i}=n.default;this.block.isRTL()&&(e={dir:"rtl"});const r=w({tagName:i,attributes:e});return t.forEach((t=>r.appendChild(t))),[r]}}createContainerElement(t){const e={};let i;const n=this.attributes[t],{tagName:r,htmlAttributes:o=[]}=pt(n);if(0===t&&this.block.isRTL()&&Object.assign(e,{dir:"rtl"}),"attachmentGallery"===n){const t=this.block.getBlockBreakPosition();i="".concat(Ei.attachmentGallery," ").concat(Ei.attachmentGallery,"--").concat(t)}return Object.entries(this.block.htmlAttributes).forEach((t=>{let[i,n]=t;o.includes(i)&&(e[i]=n)})),w({tagName:r,className:i,attributes:e})}shouldAddExtraNewlineElement(){return/\n\n$/.test(this.block.toString())}}class Ri extends ne{static render(t){const e=w("div"),i=new this(t,{element:e});return i.render(),i.sync(),e}constructor(){super(...arguments),this.element=this.options.element,this.elementStore=new te,this.setDocument(this.object)}setDocument(t){t.isEqualTo(this.document)||(this.document=this.object=t)}render(){if(this.childViews=[],this.shadowElement=w("div"),!this.document.isEmpty()){const t=Zt.groupObjects(this.document.getBlocks(),{asTree:!0});Array.from(t).forEach((t=>{const e=this.findOrCreateCachedChildView(Si,t);Array.from(e.getNodes()).map((t=>this.shadowElement.appendChild(t)))}))}}isSynced(){return Ti(this.shadowElement,this.element)}sync(){const t=v("trix-before-render",{cancelable:!1,attributes:{render:(t,e)=>{for(;t.lastChild;)t.removeChild(t.lastChild);t.appendChild(e)}}});this.element.dispatchEvent(t);const e=this.createDocumentFragmentForSync();return t.render(this.element,e),this.didSync()}didSync(){return this.elementStore.reset(ki(this.element)),Rt((()=>this.garbageCollectCachedViews()))}createDocumentFragmentForSync(){const t=document.createDocumentFragment();return Array.from(this.shadowElement.childNodes).forEach((e=>{t.appendChild(e.cloneNode(!0))})),Array.from(ki(t)).forEach((t=>{const e=this.elementStore.remove(t);e&&t.parentNode.replaceChild(e,t)})),t}}const ki=t=>t.querySelectorAll("[data-trix-store-key]"),Ti=(t,e)=>wi(t.innerHTML)===wi(e.innerHTML),wi=t=>t.replace(/ /g," ");function Li(t){var e,i;function n(e,i){try{var o=t[e](i),s=o.value,a=s instanceof Di;Promise.resolve(a?s.v:s).then((function(i){if(a){var l="return"===e?"return":"next";if(!s.k||i.done)return n(l,i);i=t[l](i).value}r(o.done?"return":"normal",i)}),(function(t){n("throw",t)}))}catch(t){r("throw",t)}}function r(t,r){switch(t){case"return":e.resolve({value:r,done:!0});break;case"throw":e.reject(r);break;default:e.resolve({value:r,done:!1})}(e=e.next)?n(e.key,e.arg):i=null}this._invoke=function(t,r){return new Promise((function(o,s){var a={key:t,arg:r,resolve:o,reject:s,next:null};i?i=i.next=a:(e=i=a,n(t,r))}))},"function"!=typeof t.return&&(this.return=void 0)}function Di(t,e){this.v=t,this.k=e}function Ni(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}function Ii(t,e,i){return(e=Ni(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}Li.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},Li.prototype.next=function(t){return this._invoke("next",t)},Li.prototype.throw=function(t){return this._invoke("throw",t)},Li.prototype.return=function(t){return this._invoke("return",t)};function Oi(t,e){return Mi(t,Pi(t,e,"get"))}function Fi(t,e,i){return Bi(t,Pi(t,e,"set"),i),i}function Pi(t,e,i){if(!e.has(t))throw new TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}function Mi(t,e){return e.get?e.get.call(t):e.value}function Bi(t,e,i){if(e.set)e.set.call(t,i);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=i}}function _i(t,e,i){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return i}function ji(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Wi(t,e,i){ji(t,e),e.set(t,i)}class Ui extends ot{static registerType(t,e){e.type=t,this.types[t]=e}static fromJSON(t){const e=this.types[t.type];if(e)return e.fromJSON(t)}constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.attributes=Jt.box(e)}copyWithAttributes(t){return new this.constructor(this.getValue(),t)}copyWithAdditionalAttributes(t){return this.copyWithAttributes(this.attributes.merge(t))}copyWithoutAttribute(t){return this.copyWithAttributes(this.attributes.remove(t))}copy(){return this.copyWithAttributes(this.attributes)}getAttribute(t){return this.attributes.get(t)}getAttributesHash(){return this.attributes}getAttributes(){return this.attributes.toObject()}hasAttribute(t){return this.attributes.has(t)}hasSameStringValueAsPiece(t){return t&&this.toString()===t.toString()}hasSameAttributesAsPiece(t){return t&&(this.attributes===t.attributes||this.attributes.isEqualTo(t.attributes))}isBlockBreak(){return!1}isEqualTo(t){return super.isEqualTo(...arguments)||this.hasSameConstructorAs(t)&&this.hasSameStringValueAsPiece(t)&&this.hasSameAttributesAsPiece(t)}isEmpty(){return 0===this.length}isSerializable(){return!0}toJSON(){return{type:this.constructor.type,attributes:this.getAttributes()}}contentsForInspection(){return{type:this.constructor.type,attributes:this.attributes.inspect()}}canBeGrouped(){return this.hasAttribute("href")}canBeGroupedWith(t){return this.getAttribute("href")===t.getAttribute("href")}getLength(){return this.length}canBeConsolidatedWith(t){return!1}}Ii(Ui,"types",{});class Vi extends ie{constructor(t){super(...arguments),this.url=t}perform(t){const e=new Image;e.onload=()=>(e.width=this.width=e.naturalWidth,e.height=this.height=e.naturalHeight,t(!0,e)),e.onerror=()=>t(!1),e.src=this.url}}class zi extends ot{static attachmentForFile(t){const e=new this(this.attributesForFile(t));return e.setFile(t),e}static attributesForFile(t){return new Jt({filename:t.name,filesize:t.size,contentType:t.type})}static fromJSON(t){return new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(t),this.releaseFile=this.releaseFile.bind(this),this.attributes=Jt.box(t),this.didChangeAttributes()}setAttribute(t,e){this.setAttributes({[t]:e})}getAttribute(t){return this.attributes.get(t)}hasAttribute(t){return this.attributes.has(t)}getAttributes(){return this.attributes.toObject()}setAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=this.attributes.merge(t);var i,n,r,o;if(!this.attributes.isEqualTo(e))return this.attributes=e,this.didChangeAttributes(),null===(i=this.previewDelegate)||void 0===i||null===(n=i.attachmentDidChangeAttributes)||void 0===n||n.call(i,this),null===(r=this.delegate)||void 0===r||null===(o=r.attachmentDidChangeAttributes)||void 0===o?void 0:o.call(r,this)}didChangeAttributes(){if(this.isPreviewable())return this.preloadURL()}isPending(){return null!=this.file&&!(this.getURL()||this.getHref())}isPreviewable(){return this.attributes.has("previewable")?this.attributes.get("previewable"):zi.previewablePattern.test(this.getContentType())}getType(){return this.hasContent()?"content":this.isPreviewable()?"preview":"file"}getURL(){return this.attributes.get("url")}getHref(){return this.attributes.get("href")}getFilename(){return this.attributes.get("filename")||""}getFilesize(){return this.attributes.get("filesize")}getFormattedFilesize(){const t=this.attributes.get("filesize");return"number"==typeof t?h.formatter(t):""}getExtension(){var t;return null===(t=this.getFilename().match(/\.(\w+)$/))||void 0===t?void 0:t[1].toLowerCase()}getContentType(){return this.attributes.get("contentType")}hasContent(){return this.attributes.has("content")}getContent(){return this.attributes.get("content")}getWidth(){return this.attributes.get("width")}getHeight(){return this.attributes.get("height")}getFile(){return this.file}setFile(t){if(this.file=t,this.isPreviewable())return this.preloadFile()}releaseFile(){this.releasePreloadedFile(),this.file=null}getUploadProgress(){return null!=this.uploadProgress?this.uploadProgress:0}setUploadProgress(t){var e,i;if(this.uploadProgress!==t)return this.uploadProgress=t,null===(e=this.uploadProgressDelegate)||void 0===e||null===(i=e.attachmentDidChangeUploadProgress)||void 0===i?void 0:i.call(e,this)}toJSON(){return this.getAttributes()}getCacheKey(){return[super.getCacheKey(...arguments),this.attributes.getCacheKey(),this.getPreviewURL()].join("/")}getPreviewURL(){return this.previewURL||this.preloadingURL}setPreviewURL(t){var e,i,n,r;if(t!==this.getPreviewURL())return this.previewURL=t,null===(e=this.previewDelegate)||void 0===e||null===(i=e.attachmentDidChangeAttributes)||void 0===i||i.call(e,this),null===(n=this.delegate)||void 0===n||null===(r=n.attachmentDidChangePreviewURL)||void 0===r?void 0:r.call(n,this)}preloadURL(){return this.preload(this.getURL(),this.releaseFile)}preloadFile(){if(this.file)return this.fileObjectURL=URL.createObjectURL(this.file),this.preload(this.fileObjectURL)}releasePreloadedFile(){this.fileObjectURL&&(URL.revokeObjectURL(this.fileObjectURL),this.fileObjectURL=null)}preload(t,e){if(t&&t!==this.getPreviewURL()){this.preloadingURL=t;return new Vi(t).then((i=>{let{width:n,height:r}=i;return this.getWidth()&&this.getHeight()||this.setAttributes({width:n,height:r}),this.preloadingURL=null,this.setPreviewURL(t),null==e?void 0:e()})).catch((()=>(this.preloadingURL=null,null==e?void 0:e())))}}}Ii(zi,"previewablePattern",/^image(\/(gif|png|webp|jpe?g)|$)/);class qi extends Ui{static fromJSON(t){return new this(zi.fromJSON(t.attachment),t.attributes)}constructor(t){super(...arguments),this.attachment=t,this.length=1,this.ensureAttachmentExclusivelyHasAttribute("href"),this.attachment.hasContent()||this.removeProhibitedAttributes()}ensureAttachmentExclusivelyHasAttribute(t){this.hasAttribute(t)&&(this.attachment.hasAttribute(t)||this.attachment.setAttributes(this.attributes.slice([t])),this.attributes=this.attributes.remove(t))}removeProhibitedAttributes(){const t=this.attributes.slice(qi.permittedAttributes);t.isEqualTo(this.attributes)||(this.attributes=t)}getValue(){return this.attachment}isSerializable(){return!this.attachment.isPending()}getCaption(){return this.attributes.get("caption")||""}isEqualTo(t){var e;return super.isEqualTo(t)&&this.attachment.id===(null==t||null===(e=t.attachment)||void 0===e?void 0:e.id)}toString(){return""}toJSON(){const t=super.toJSON(...arguments);return t.attachment=this.attachment,t}getCacheKey(){return[super.getCacheKey(...arguments),this.attachment.getCacheKey()].join("/")}toConsole(){return JSON.stringify(this.toString())}}Ii(qi,"permittedAttributes",["caption","presentation"]),Ui.registerType("attachment",qi);class Hi extends Ui{static fromJSON(t){return new this(t.string,t.attributes)}constructor(t){super(...arguments),this.string=(t=>t.replace(/\r\n?/g,"\n"))(t),this.length=this.string.length}getValue(){return this.string}toString(){return this.string.toString()}isBlockBreak(){return"\n"===this.toString()&&!0===this.getAttribute("blockBreak")}toJSON(){const t=super.toJSON(...arguments);return t.string=this.string,t}canBeConsolidatedWith(t){return t&&this.hasSameConstructorAs(t)&&this.hasSameAttributesAsPiece(t)}consolidateWith(t){return new this.constructor(this.toString()+t.toString(),this.attributes)}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.length?(e=this,i=null):(e=new this.constructor(this.string.slice(0,t),this.attributes),i=new this.constructor(this.string.slice(t),this.attributes)),[e,i]}toConsole(){let{string:t}=this;return t.length>15&&(t=t.slice(0,14)+"…"),JSON.stringify(t.toString())}}Ui.registerType("string",Hi);class Ji extends ot{static box(t){return t instanceof this?t:new this(t)}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.objects=t.slice(0),this.length=this.objects.length}indexOf(t){return this.objects.indexOf(t)}splice(){for(var t=arguments.length,e=new Array(t),i=0;it(e,i)))}insertObjectAtIndex(t,e){return this.splice(e,0,t)}insertSplittableListAtIndex(t,e){return this.splice(e,0,...t.objects)}insertSplittableListAtPosition(t,e){const[i,n]=this.splitObjectAtPosition(e);return new this.constructor(i).insertSplittableListAtIndex(t,n)}editObjectAtIndex(t,e){return this.replaceObjectAtIndex(e(this.objects[t]),t)}replaceObjectAtIndex(t,e){return this.splice(e,1,t)}removeObjectAtIndex(t){return this.splice(t,1)}getObjectAtIndex(t){return this.objects[t]}getSplittableListInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e.slice(i,n+1))}selectSplittableList(t){const e=this.objects.filter((e=>t(e)));return new this.constructor(e)}removeObjectsInRange(t){const[e,i,n]=this.splitObjectsAtRange(t);return new this.constructor(e).splice(i,n-i+1)}transformObjectsInRange(t,e){const[i,n,r]=this.splitObjectsAtRange(t),o=i.map(((t,i)=>n<=i&&i<=r?e(t):t));return new this.constructor(o)}splitObjectsAtRange(t){let e,[i,n,r]=this.splitObjectAtPosition(Gi(t));return[i,e]=new this.constructor(i).splitObjectAtPosition(Yi(t)+r),[i,n,e-1]}getObjectAtPosition(t){const{index:e}=this.findIndexAndOffsetAtPosition(t);return this.objects[e]}splitObjectAtPosition(t){let e,i;const{index:n,offset:r}=this.findIndexAndOffsetAtPosition(t),o=this.objects.slice(0);if(null!=n)if(0===r)e=n,i=0;else{const t=this.getObjectAtIndex(n),[s,a]=t.splitAtOffset(r);o.splice(n,1,s,a),e=n+1,i=s.getLength()-r}else e=o.length,i=0;return[o,e,i]}consolidate(){const t=[];let e=this.objects[0];return this.objects.slice(1).forEach((i=>{var n,r;null!==(n=(r=e).canBeConsolidatedWith)&&void 0!==n&&n.call(r,i)?e=e.consolidateWith(i):(t.push(e),e=i)})),e&&t.push(e),new this.constructor(t)}consolidateFromIndexToIndex(t,e){const i=this.objects.slice(0).slice(t,e+1),n=new this.constructor(i).consolidate().toArray();return this.splice(t,i.length,...n)}findIndexAndOffsetAtPosition(t){let e,i=0;for(e=0;ethis.endPosition+=t.getLength()))),this.endPosition}toString(){return this.objects.join("")}toArray(){return this.objects.slice(0)}toJSON(){return this.toArray()}isEqualTo(t){return super.isEqualTo(...arguments)||Ki(this.objects,null==t?void 0:t.objects)}contentsForInspection(){return{objects:"[".concat(this.objects.map((t=>t.inspect())).join(", "),"]")}}}const Ki=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];if(t.length!==e.length)return!1;let i=!0;for(let n=0;nt[0],Yi=t=>t[1];class Xi extends ot{static textForAttachmentWithAttributes(t,e){return new this([new qi(t,e)])}static textForStringWithAttributes(t,e){return new this([new Hi(t,e)])}static fromJSON(t){return new this(Array.from(t).map((t=>Ui.fromJSON(t))))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments);const e=t.filter((t=>!t.isEmpty()));this.pieceList=new Ji(e)}copy(){return this.copyWithPieceList(this.pieceList)}copyWithPieceList(t){return new this.constructor(t.consolidate().toArray())}copyUsingObjectMap(t){const e=this.getPieces().map((e=>t.find(e)||e));return new this.constructor(e)}appendText(t){return this.insertTextAtPosition(t,this.getLength())}insertTextAtPosition(t,e){return this.copyWithPieceList(this.pieceList.insertSplittableListAtPosition(t.pieceList,e))}removeTextAtRange(t){return this.copyWithPieceList(this.pieceList.removeObjectsInRange(t))}replaceTextAtRange(t,e){return this.removeTextAtRange(e).insertTextAtPosition(t,e[0])}moveTextFromRangeToPosition(t,e){if(t[0]<=e&&e<=t[1])return;const i=this.getTextAtRange(t),n=i.getLength();return t[0]e.copyWithAdditionalAttributes(t))))}removeAttributeAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithoutAttribute(t))))}setAttributesAtRange(t,e){return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e,(e=>e.copyWithAttributes(t))))}getAttributesAtPosition(t){var e;return(null===(e=this.pieceList.getObjectAtPosition(t))||void 0===e?void 0:e.getAttributes())||{}}getCommonAttributes(){const t=Array.from(this.pieceList.toArray()).map((t=>t.getAttributes()));return Jt.fromCommonAttributesOfObjects(t).toObject()}getCommonAttributesAtRange(t){return this.getTextAtRange(t).getCommonAttributes()||{}}getExpandedRangeForAttributeAtOffset(t,e){let i,n=i=e;const r=this.getLength();for(;n>0&&this.getCommonAttributesAtRange([n-1,i])[t];)n--;for(;i!!t.attachment))}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getAttachmentAndPositionById(t){let e=0;for(const n of this.pieceList.toArray()){var i;if((null===(i=n.attachment)||void 0===i?void 0:i.id)===t)return{attachment:n.attachment,position:e};e+=n.length}return{attachment:null,position:null}}getAttachmentById(t){const{attachment:e}=this.getAttachmentAndPositionById(t);return e}getRangeOfAttachment(t){const e=this.getAttachmentAndPositionById(t.id),i=e.position;if(t=e.attachment)return[i,i+1]}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e);return i?this.addAttributesAtRange(t,i):this}getLength(){return this.pieceList.getEndPosition()}isEmpty(){return 0===this.getLength()}isEqualTo(t){var e;return super.isEqualTo(t)||(null==t||null===(e=t.pieceList)||void 0===e?void 0:e.isEqualTo(this.pieceList))}isBlockBreak(){return 1===this.getLength()&&this.pieceList.getObjectAtIndex(0).isBlockBreak()}eachPiece(t){return this.pieceList.eachObject(t)}getPieces(){return this.pieceList.toArray()}getPieceAtPosition(t){return this.pieceList.getObjectAtPosition(t)}contentsForInspection(){return{pieceList:this.pieceList.inspect()}}toSerializableText(){const t=this.pieceList.selectSplittableList((t=>t.isSerializable()));return this.copyWithPieceList(t)}toString(){return this.pieceList.toString()}toJSON(){return this.pieceList.toJSON()}toConsole(){return JSON.stringify(this.pieceList.toArray().map((t=>JSON.parse(t.toConsole()))))}getDirection(){return ct(this.toString())}isRTL(){return"rtl"===this.getDirection()}}class $i extends ot{static fromJSON(t){return new this(Xi.fromJSON(t.text),t.attributes,t.htmlAttributes)}constructor(t,e,i){super(...arguments),this.text=Zi(t||new Xi),this.attributes=e||[],this.htmlAttributes=i||{}}isEmpty(){return this.text.isBlockBreak()}isEqualTo(t){return!!super.isEqualTo(t)||this.text.isEqualTo(null==t?void 0:t.text)&&st(this.attributes,null==t?void 0:t.attributes)&&wt(this.htmlAttributes,null==t?void 0:t.htmlAttributes)}copyWithText(t){return new $i(t,this.attributes,this.htmlAttributes)}copyWithoutText(){return this.copyWithText(null)}copyWithAttributes(t){return new $i(this.text,t,this.htmlAttributes)}copyWithoutAttributes(){return this.copyWithAttributes(null)}copyUsingObjectMap(t){const e=t.find(this.text);return e?this.copyWithText(e):this.copyWithText(this.text.copyUsingObjectMap(t))}addAttribute(t){const e=this.attributes.concat(on(t));return this.copyWithAttributes(e)}addHTMLAttribute(t,e){const i=Object.assign({},this.htmlAttributes,{[t]:e});return new $i(this.text,this.attributes,i)}removeAttribute(t){const{listAttribute:e}=pt(t),i=an(an(this.attributes,t),e);return this.copyWithAttributes(i)}removeLastAttribute(){return this.removeAttribute(this.getLastAttribute())}getLastAttribute(){return sn(this.attributes)}getAttributes(){return this.attributes.slice(0)}getAttributeLevel(){return this.attributes.length}getAttributeAtLevel(t){return this.attributes[t-1]}hasAttribute(t){return this.attributes.includes(t)}hasAttributes(){return this.getAttributeLevel()>0}getLastNestableAttribute(){return sn(this.getNestableAttributes())}getNestableAttributes(){return this.attributes.filter((t=>pt(t).nestable))}getNestingLevel(){return this.getNestableAttributes().length}decreaseNestingLevel(){const t=this.getLastNestableAttribute();return t?this.removeAttribute(t):this}increaseNestingLevel(){const t=this.getLastNestableAttribute();if(t){const e=this.attributes.lastIndexOf(t),i=at(this.attributes,e+1,0,...on(t));return this.copyWithAttributes(i)}return this}getListItemAttributes(){return this.attributes.filter((t=>pt(t).listAttribute))}isListItem(){var t;return null===(t=pt(this.getLastAttribute()))||void 0===t?void 0:t.listAttribute}isTerminalBlock(){var t;return null===(t=pt(this.getLastAttribute()))||void 0===t?void 0:t.terminal}breaksOnReturn(){var t;return null===(t=pt(this.getLastAttribute()))||void 0===t?void 0:t.breakOnReturn}findLineBreakInDirectionFromPosition(t,e){const i=this.toString();let n;switch(t){case"forward":n=i.indexOf("\n",e);break;case"backward":n=i.slice(0,e).lastIndexOf("\n")}if(-1!==n)return n}contentsForInspection(){return{text:this.text.inspect(),attributes:this.attributes}}toString(){return this.text.toString()}toJSON(){return{text:this.text,attributes:this.attributes,htmlAttributes:this.htmlAttributes}}getDirection(){return this.text.getDirection()}isRTL(){return this.text.isRTL()}getLength(){return this.text.getLength()}canBeConsolidatedWith(t){return!this.hasAttributes()&&!t.hasAttributes()&&this.getDirection()===t.getDirection()}consolidateWith(t){const e=Xi.textForStringWithAttributes("\n"),i=this.getTextWithoutBlockBreak().appendText(e);return this.copyWithText(i.appendText(t.text))}splitAtOffset(t){let e,i;return 0===t?(e=null,i=this):t===this.getLength()?(e=this,i=null):(e=this.copyWithText(this.text.getTextAtRange([0,t])),i=this.copyWithText(this.text.getTextAtRange([t,this.getLength()]))),[e,i]}getBlockBreakPosition(){return this.text.getLength()-1}getTextWithoutBlockBreak(){return nn(this.text)?this.text.getTextAtRange([0,this.getBlockBreakPosition()]):this.text.copy()}canBeGrouped(t){return this.attributes[t]}canBeGroupedWith(t,e){const i=t.getAttributes(),r=i[e],o=this.attributes[e];return o===r&&!(!1===pt(o).group&&!(()=>{if(!gt){gt=[];for(const t in n){const{listAttribute:e}=n[t];null!=e&>.push(e)}}return gt})().includes(i[e+1]))&&(this.getDirection()===t.getDirection()||t.isEmpty())}}const Zi=function(t){return t=Qi(t),en(t)},Qi=function(t){let e=!1;const i=t.getPieces();let n=i.slice(0,i.length-1);const r=i[i.length-1];return r?(n=n.map((t=>t.isBlockBreak()?(e=!0,rn(t)):t)),e?new Xi([...n,r]):t):t},tn=Xi.textForStringWithAttributes("\n",{blockBreak:!0}),en=function(t){return nn(t)?t:t.appendText(tn)},nn=function(t){const e=t.getLength();return 0!==e&&t.getTextAtRange([e-1,e]).isBlockBreak()},rn=t=>t.copyWithoutAttribute("blockBreak"),on=function(t){const{listAttribute:e}=pt(t);return e?[e,t]:[t]},sn=t=>t.slice(-1)[0],an=function(t,e){const i=t.lastIndexOf(e);return-1===i?t:at(t,i,1)};class ln extends ot{static fromJSON(t){return new this(Array.from(t).map((t=>$i.fromJSON(t))))}static fromString(t,e){const i=Xi.textForStringWithAttributes(t,e);return new this([new $i(i)])}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),0===t.length&&(t=[new $i]),this.blockList=Ji.box(t)}isEmpty(){const t=this.getBlockAtIndex(0);return 1===this.blockList.length&&t.isEmpty()&&!t.hasAttributes()}copy(){const t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).consolidateBlocks?this.blockList.consolidate().toArray():this.blockList.toArray();return new this.constructor(t)}copyUsingObjectsFromDocument(t){const e=new Qt(t.getObjects());return this.copyUsingObjectMap(e)}copyUsingObjectMap(t){const e=this.getBlocks().map((e=>t.find(e)||e.copyUsingObjectMap(t)));return new this.constructor(e)}copyWithBaseBlockAttributes(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];const e=this.getBlocks().map((e=>{const i=t.concat(e.getAttributes());return e.copyWithAttributes(i)}));return new this.constructor(e)}replaceBlock(t,e){const i=this.blockList.indexOf(t);return-1===i?this:new this.constructor(this.blockList.replaceObjectAtIndex(e,i))}insertDocumentAtRange(t,e){const{blockList:i}=t;e=Lt(e);let[n]=e;const{index:r,offset:o}=this.locationFromPosition(n);let s=this;const a=this.getBlockAtPosition(n);return Dt(e)&&a.isEmpty()&&!a.hasAttributes()?s=new this.constructor(s.blockList.removeObjectAtIndex(r)):a.getBlockBreakPosition()===o&&n++,s=s.removeTextAtRange(e),new this.constructor(s.blockList.insertSplittableListAtPosition(i,n))}mergeDocumentAtRange(t,e){let i,n;e=Lt(e);const[r]=e,o=this.locationFromPosition(r),s=this.getBlockAtIndex(o.index).getAttributes(),a=t.getBaseBlockAttributes(),l=s.slice(-a.length);if(st(a,l)){const e=s.slice(0,-a.length);i=t.copyWithBaseBlockAttributes(e)}else i=t.copy({consolidateBlocks:!0}).copyWithBaseBlockAttributes(s);const c=i.getBlockCount(),u=i.getBlockAtIndex(0);if(st(s,u.getAttributes())){const t=u.getTextWithoutBlockBreak();if(n=this.insertTextAtRange(t,e),c>1){i=new this.constructor(i.getBlocks().slice(1));const e=r+t.getLength();n=n.insertDocumentAtRange(i,e)}}else n=this.insertDocumentAtRange(i,e);return n}insertTextAtRange(t,e){e=Lt(e);const[i]=e,{index:n,offset:r}=this.locationFromPosition(i),o=this.removeTextAtRange(e);return new this.constructor(o.blockList.editObjectAtIndex(n,(e=>e.copyWithText(e.text.insertTextAtPosition(t,r)))))}removeTextAtRange(t){let e;t=Lt(t);const[i,n]=t;if(Dt(t))return this;const[r,o]=Array.from(this.locationRangeFromRange(t)),s=r.index,a=r.offset,l=this.getBlockAtIndex(s),c=o.index,u=o.offset,h=this.getBlockAtIndex(c);if(n-i==1&&l.getBlockBreakPosition()===a&&h.getBlockBreakPosition()!==u&&"\n"===h.text.getStringAtPosition(u))e=this.blockList.editObjectAtIndex(c,(t=>t.copyWithText(t.text.removeTextAtRange([u,u+1]))));else{let t;const i=l.text.getTextAtRange([0,a]),n=h.text.getTextAtRange([u,h.getLength()]),r=i.appendText(n);t=s!==c&&0===a&&l.getAttributeLevel()>=h.getAttributeLevel()?h.copyWithText(r):l.copyWithText(r);const o=c+1-s;e=this.blockList.splice(s,o,t)}return new this.constructor(e)}moveTextFromRangeToPosition(t,e){let i;t=Lt(t);const[n,r]=t;if(n<=e&&e<=r)return this;let o=this.getDocumentAtRange(t),s=this.removeTextAtRange(t);const a=nn=n.editObjectAtIndex(o,(function(){return pt(t)?i.addAttribute(t,e):r[0]===r[1]?i:i.copyWithText(i.text.addAttributeAtRange(t,e,r))})))),new this.constructor(n)}addAttribute(t,e){let{blockList:i}=this;return this.eachBlock(((n,r)=>i=i.editObjectAtIndex(r,(()=>n.addAttribute(t,e))))),new this.constructor(i)}removeAttributeAtRange(t,e){let{blockList:i}=this;return this.eachBlockAtRange(e,(function(e,n,r){pt(t)?i=i.editObjectAtIndex(r,(()=>e.removeAttribute(t))):n[0]!==n[1]&&(i=i.editObjectAtIndex(r,(()=>e.copyWithText(e.text.removeAttributeAtRange(t,n)))))})),new this.constructor(i)}updateAttributesForAttachment(t,e){const i=this.getRangeOfAttachment(e),[n]=Array.from(i),{index:r}=this.locationFromPosition(n),o=this.getTextAtIndex(r);return new this.constructor(this.blockList.editObjectAtIndex(r,(i=>i.copyWithText(o.updateAttributesForAttachment(t,e)))))}removeAttributeForAttachment(t,e){const i=this.getRangeOfAttachment(e);return this.removeAttributeAtRange(t,i)}setHTMLAttributeAtPosition(t,e,i){const n=this.getBlockAtPosition(t),r=n.addHTMLAttribute(e,i);return this.replaceBlock(n,r)}insertBlockBreakAtRange(t){let e;t=Lt(t);const[i]=t,{offset:n}=this.locationFromPosition(i),r=this.removeTextAtRange(t);return 0===n&&(e=[new $i]),new this.constructor(r.blockList.insertSplittableListAtPosition(new Ji(e),i))}applyBlockAttributeAtRange(t,e,i){const n=this.expandRangeToLineBreaksAndSplitBlocks(i);let r=n.document;i=n.range;const o=pt(t);if(o.listAttribute){r=r.removeLastListAttributeAtRange(i,{exceptAttributeName:t});const e=r.convertLineBreaksToBlockBreaksInRange(i);r=e.document,i=e.range}else r=o.exclusive?r.removeBlockAttributesAtRange(i):o.terminal?r.removeLastTerminalAttributeAtRange(i):r.consolidateBlocksAtRange(i);return r.addAttributeAtRange(t,e,i)}removeLastListAttributeAtRange(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{blockList:i}=this;return this.eachBlockAtRange(t,(function(t,n,r){const o=t.getLastAttribute();o&&pt(o).listAttribute&&o!==e.exceptAttributeName&&(i=i.editObjectAtIndex(r,(()=>t.removeAttribute(o))))})),new this.constructor(i)}removeLastTerminalAttributeAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){const r=t.getLastAttribute();r&&pt(r).terminal&&(e=e.editObjectAtIndex(n,(()=>t.removeAttribute(r))))})),new this.constructor(e)}removeBlockAttributesAtRange(t){let{blockList:e}=this;return this.eachBlockAtRange(t,(function(t,i,n){t.hasAttributes()&&(e=e.editObjectAtIndex(n,(()=>t.copyWithoutAttributes())))})),new this.constructor(e)}expandRangeToLineBreaksAndSplitBlocks(t){let e;t=Lt(t);let[i,n]=t;const r=this.locationFromPosition(i),o=this.locationFromPosition(n);let s=this;const a=s.getBlockAtIndex(r.index);if(r.offset=a.findLineBreakInDirectionFromPosition("backward",r.offset),null!=r.offset&&(e=s.positionFromLocation(r),s=s.insertBlockBreakAtRange([e,e+1]),o.index+=1,o.offset-=s.getBlockAtIndex(r.index).getLength(),r.index+=1),r.offset=0,0===o.offset&&o.index>r.index)o.index-=1,o.offset=s.getBlockAtIndex(o.index).getBlockBreakPosition();else{const t=s.getBlockAtIndex(o.index);"\n"===t.text.getStringAtRange([o.offset-1,o.offset])?o.offset-=1:o.offset=t.findLineBreakInDirectionFromPosition("forward",o.offset),o.offset!==t.getBlockBreakPosition()&&(e=s.positionFromLocation(o),s=s.insertBlockBreakAtRange([e,e+1]))}return i=s.positionFromLocation(r),n=s.positionFromLocation(o),{document:s,range:t=Lt([i,n])}}convertLineBreaksToBlockBreaksInRange(t){t=Lt(t);let[e]=t;const i=this.getStringAtRange(t).slice(0,-1);let n=this;return i.replace(/.*?\n/g,(function(t){e+=t.length,n=n.insertBlockBreakAtRange([e-1,e])})),{document:n,range:t}}consolidateBlocksAtRange(t){t=Lt(t);const[e,i]=t,n=this.locationFromPosition(e).index,r=this.locationFromPosition(i).index;return new this.constructor(this.blockList.consolidateFromIndexToIndex(n,r))}getDocumentAtRange(t){t=Lt(t);const e=this.blockList.getSplittableListInRange(t).toArray();return new this.constructor(e)}getStringAtRange(t){let e;const i=t=Lt(t);return i[i.length-1]!==this.getLength()&&(e=-1),this.getDocumentAtRange(t).toString().slice(0,e)}getBlockAtIndex(t){return this.blockList.getObjectAtIndex(t)}getBlockAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getBlockAtIndex(e)}getTextAtIndex(t){var e;return null===(e=this.getBlockAtIndex(t))||void 0===e?void 0:e.text}getTextAtPosition(t){const{index:e}=this.locationFromPosition(t);return this.getTextAtIndex(e)}getPieceAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getPieceAtPosition(i)}getCharacterAtPosition(t){const{index:e,offset:i}=this.locationFromPosition(t);return this.getTextAtIndex(e).getStringAtRange([i,i+1])}getLength(){return this.blockList.getEndPosition()}getBlocks(){return this.blockList.toArray()}getBlockCount(){return this.blockList.length}getEditCount(){return this.editCount}eachBlock(t){return this.blockList.eachObject(t)}eachBlockAtRange(t,e){let i,n;t=Lt(t);const[r,o]=t,s=this.locationFromPosition(r),a=this.locationFromPosition(o);if(s.index===a.index)return i=this.getBlockAtIndex(s.index),n=[s.offset,a.offset],e(i,n,s.index);for(let t=s.index;t<=a.index;t++)if(i=this.getBlockAtIndex(t),i){switch(t){case s.index:n=[s.offset,i.text.getLength()];break;case a.index:n=[0,a.offset];break;default:n=[0,i.text.getLength()]}e(i,n,t)}}getCommonAttributesAtRange(t){t=Lt(t);const[e]=t;if(Dt(t))return this.getCommonAttributesAtPosition(e);{const e=[],i=[];return this.eachBlockAtRange(t,(function(t,n){if(n[0]!==n[1])return e.push(t.text.getCommonAttributesAtRange(n)),i.push(cn(t))})),Jt.fromCommonAttributesOfObjects(e).merge(Jt.fromCommonAttributesOfObjects(i)).toObject()}}getCommonAttributesAtPosition(t){let e,i;const{index:n,offset:r}=this.locationFromPosition(t),o=this.getBlockAtIndex(n);if(!o)return{};const s=cn(o),a=o.text.getAttributesAtPosition(r),l=o.text.getAttributesAtPosition(r-1),c=Object.keys(U).filter((t=>U[t].inheritable));for(e in l)i=l[e],(i===a[e]||c.includes(e))&&(s[e]=i);return s}getRangeOfCommonAttributeAtPosition(t,e){const{index:i,offset:n}=this.locationFromPosition(e),r=this.getTextAtIndex(i),[o,s]=Array.from(r.getExpandedRangeForAttributeAtOffset(t,n)),a=this.positionFromLocation({index:i,offset:o}),l=this.positionFromLocation({index:i,offset:s});return Lt([a,l])}getBaseBlockAttributes(){let t=this.getBlockAtIndex(0).getAttributes();for(let e=1;e{const e=[];for(let r=0;r{let{text:i}=e;return t=t.concat(i.getAttachmentPieces())})),t}getAttachments(){return this.getAttachmentPieces().map((t=>t.attachment))}getRangeOfAttachment(t){let e=0;const i=this.blockList.toArray();for(let n=0;n{const r=n.getLength();n.hasAttribute(t)&&i.push([e,e+r]),e+=r})),i}findRangesForTextAttribute(t){let{withValue:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=0,n=[];const r=[];return this.getPieces().forEach((o=>{const s=o.getLength();(function(i){return e?i.getAttribute(t)===e:i.hasAttribute(t)})(o)&&(n[1]===i?n[1]=i+s:r.push(n=[i,i+s])),i+=s})),r}locationFromPosition(t){const e=this.blockList.findIndexAndOffsetAtPosition(Math.max(0,t));if(null!=e.index)return e;{const t=this.getBlocks();return{index:t.length-1,offset:t[t.length-1].getLength()}}}positionFromLocation(t){return this.blockList.findPositionAtIndexAndOffset(t.index,t.offset)}locationRangeFromPosition(t){return Lt(this.locationFromPosition(t))}locationRangeFromRange(t){if(!(t=Lt(t)))return;const[e,i]=Array.from(t),n=this.locationFromPosition(e),r=this.locationFromPosition(i);return Lt([n,r])}rangeFromLocationRange(t){let e;t=Lt(t);const i=this.positionFromLocation(t[0]);return Dt(t)||(e=this.positionFromLocation(t[1])),Lt([i,e])}isEqualTo(t){return this.blockList.isEqualTo(null==t?void 0:t.blockList)}getTexts(){return this.getBlocks().map((t=>t.text))}getPieces(){const t=[];return Array.from(this.getTexts()).forEach((e=>{t.push(...Array.from(e.getPieces()||[]))})),t}getObjects(){return this.getBlocks().concat(this.getTexts()).concat(this.getPieces())}toSerializableDocument(){const t=[];return this.blockList.eachObject((e=>t.push(e.copyWithText(e.text.toSerializableText())))),new this.constructor(t)}toString(){return this.blockList.toString()}toJSON(){return this.blockList.toJSON()}toConsole(){return JSON.stringify(this.blockList.toArray().map((t=>JSON.parse(t.text.toConsole()))))}}const cn=function(t){const e={},i=t.getLastAttribute();return i&&(e[i]=!0),e},un=function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return{string:t=Ut(t),attributes:e,type:"string"}},hn=(t,e)=>{try{return JSON.parse(t.getAttribute("data-trix-".concat(e)))}catch(t){return{}}};class dn extends H{static parse(t,e){const i=new this(t,e);return i.parse(),i}constructor(t){let{referenceElement:e,purifyOptions:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};super(...arguments),this.html=t,this.referenceElement=e,this.purifyOptions=i,this.blocks=[],this.blockElements=[],this.processedElements=[]}getDocument(){return ln.fromJSON(this.blocks)}parse(){try{this.createHiddenContainer(),gi.setHTML(this.containerElement,this.html,{purifyOptions:this.purifyOptions});const t=R(this.containerElement,{usingFilter:fn});for(;t.nextNode();)this.processNode(t.currentNode);return this.translateBlockElementMarginsToNewlines()}finally{this.removeHiddenContainer()}}createHiddenContainer(){return this.referenceElement?(this.containerElement=this.referenceElement.cloneNode(!1),this.containerElement.removeAttribute("id"),this.containerElement.setAttribute("data-trix-internal",""),this.containerElement.style.display="none",this.referenceElement.parentNode.insertBefore(this.containerElement,this.referenceElement.nextSibling)):(this.containerElement=w({tagName:"div",style:{display:"none"}}),document.body.appendChild(this.containerElement))}removeHiddenContainer(){return k(this.containerElement)}processNode(t){switch(t.nodeType){case Node.TEXT_NODE:if(!this.isInsignificantTextNode(t))return this.appendBlockForTextNode(t),this.processTextNode(t);break;case Node.ELEMENT_NODE:return this.appendBlockForElement(t),this.processElement(t)}}appendBlockForTextNode(t){const e=t.parentNode;if(e===this.currentBlockElement&&this.isBlockElement(t.previousSibling))return this.appendStringWithAttributes("\n");if(e===this.containerElement||this.isBlockElement(e)){var i;const t=this.getBlockAttributes(e),n=this.getBlockHTMLAttributes(e);st(t,null===(i=this.currentBlock)||void 0===i?void 0:i.attributes)||(this.currentBlock=this.appendBlockForAttributesWithElement(t,e,n),this.currentBlockElement=e)}}appendBlockForElement(t){const e=this.isBlockElement(t),i=E(this.currentBlockElement,t);if(e&&!this.isBlockElement(t.firstChild)){if(!this.isInsignificantTextNode(t.firstChild)||!this.isBlockElement(t.firstElementChild)){const e=this.getBlockAttributes(t),n=this.getBlockHTMLAttributes(t);if(t.firstChild){if(i&&st(e,this.currentBlock.attributes))return this.appendStringWithAttributes("\n");this.currentBlock=this.appendBlockForAttributesWithElement(e,t,n),this.currentBlockElement=t}}}else if(this.currentBlockElement&&!i&&!e){const e=this.findParentBlockElement(t);if(e)return this.appendBlockForElement(e);this.currentBlock=this.appendEmptyBlock(),this.currentBlockElement=null}}findParentBlockElement(t){let{parentElement:e}=t;for(;e&&e!==this.containerElement;){if(this.isBlockElement(e)&&this.blockElements.includes(e))return e;e=e.parentElement}return null}processTextNode(t){let e=t.data;var i;gn(t.parentNode)||(e=zt(e),An(null===(i=t.previousSibling)||void 0===i?void 0:i.textContent)&&(e=bn(e)));return this.appendStringWithAttributes(e,this.getTextAttributes(t.parentNode))}processElement(t){let e;if(M(t)){if(e=hn(t,"attachment"),Object.keys(e).length){const i=this.getTextAttributes(t);this.appendAttachmentWithAttributes(e,i),t.innerHTML=""}return this.processedElements.push(t)}switch(T(t)){case"br":return this.isExtraBR(t)||this.isBlockElement(t.nextSibling)||this.appendStringWithAttributes("\n",this.getTextAttributes(t)),this.processedElements.push(t);case"img":e={url:t.getAttribute("src"),contentType:"image"};const i=(t=>{const e=t.getAttribute("width"),i=t.getAttribute("height"),n={};return e&&(n.width=parseInt(e,10)),i&&(n.height=parseInt(i,10)),n})(t);for(const t in i){const n=i[t];e[t]=n}return this.appendAttachmentWithAttributes(e,this.getTextAttributes(t)),this.processedElements.push(t);case"tr":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(W.tableRowSeparator);break;case"td":if(this.needsTableSeparator(t))return this.appendStringWithAttributes(W.tableCellSeparator)}}appendBlockForAttributesWithElement(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.blockElements.push(e);const n=function(){return{text:[],attributes:arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},htmlAttributes:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}}}(t,i);return this.blocks.push(n),n}appendEmptyBlock(){return this.appendBlockForAttributesWithElement([],null)}appendStringWithAttributes(t,e){return this.appendPiece(un(t,e))}appendAttachmentWithAttributes(t,e){return this.appendPiece(function(t){return{attachment:t,attributes:arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},type:"attachment"}}(t,e))}appendPiece(t){return 0===this.blocks.length&&this.appendEmptyBlock(),this.blocks[this.blocks.length-1].text.push(t)}appendStringToTextAtIndex(t,e){const{text:i}=this.blocks[e],n=i[i.length-1];if("string"!==(null==n?void 0:n.type))return i.push(un(t));n.string+=t}prependStringToTextAtIndex(t,e){const{text:i}=this.blocks[e],n=i[0];if("string"!==(null==n?void 0:n.type))return i.unshift(un(t));n.string=t+n.string}getTextAttributes(t){let e;const i={};for(const n in U){const r=U[n];if(r.tagName&&x(t,{matchingSelector:r.tagName,untilNode:this.containerElement}))i[n]=!0;else if(r.parser){if(e=r.parser(t),e){let o=!1;for(const i of this.findBlockElementAncestors(t))if(r.parser(i)===e){o=!0;break}o||(i[n]=e)}}else r.styleProperty&&(e=t.style[r.styleProperty],e&&(i[n]=e))}if(M(t)){const n=hn(t,"attributes");for(const t in n)e=n[t],i[t]=e}return i}getBlockAttributes(t){const e=[];for(;t&&t!==this.containerElement;){for(const r in n){const o=n[r];var i;!1!==o.parse&&T(t)===o.tagName&&(null!==(i=o.test)&&void 0!==i&&i.call(o,t)||!o.test)&&(e.push(r),o.listAttribute&&e.push(o.listAttribute))}t=t.parentNode}return e.reverse()}getBlockHTMLAttributes(t){const e={},i=Object.values(n).find((e=>e.tagName===T(t)));return((null==i?void 0:i.htmlAttributes)||[]).forEach((i=>{t.hasAttribute(i)&&(e[i]=t.getAttribute(i))})),e}findBlockElementAncestors(t){const e=[];for(;t&&t!==this.containerElement;){const i=T(t);D().includes(i)&&e.push(t),t=t.parentNode}return e}isBlockElement(t){if((null==t?void 0:t.nodeType)===Node.ELEMENT_NODE&&!M(t)&&!x(t,{matchingSelector:"td",untilNode:this.containerElement}))return D().includes(T(t))||"block"===window.getComputedStyle(t).display}isInsignificantTextNode(t){if((null==t?void 0:t.nodeType)!==Node.TEXT_NODE)return;if(!vn(t.data))return;const{parentNode:e,previousSibling:i,nextSibling:n}=t;return mn(e.previousSibling)&&!this.isBlockElement(e.previousSibling)||gn(e)?void 0:!i||this.isBlockElement(i)||!n||this.isBlockElement(n)}isExtraBR(t){return"br"===T(t)&&this.isBlockElement(t.parentNode)&&t.parentNode.lastChild===t}needsTableSeparator(t){if(W.removeBlankTableCells){var e;const i=null===(e=t.previousSibling)||void 0===e?void 0:e.textContent;return i&&/\S/.test(i)}return t.previousSibling}translateBlockElementMarginsToNewlines(){const t=this.getMarginOfDefaultBlockElement();for(let e=0;e2*t.top&&this.prependStringToTextAtIndex("\n",e),i.bottom>2*t.bottom&&this.appendStringToTextAtIndex("\n",e))}}getMarginOfBlockElementAtIndex(t){const e=this.blockElements[t];if(e&&e.textContent&&!D().includes(T(e))&&!this.processedElements.includes(e))return pn(e)}getMarginOfDefaultBlockElement(){const t=w(n.default.tagName);return this.containerElement.appendChild(t),pn(t)}}const gn=function(t){const{whiteSpace:e}=window.getComputedStyle(t);return["pre","pre-wrap","pre-line"].includes(e)},mn=t=>t&&!An(t.textContent),pn=function(t){const e=window.getComputedStyle(t);if("block"===e.display)return{top:parseInt(e.marginTop),bottom:parseInt(e.marginBottom)}},fn=function(t){return"style"===T(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},bn=t=>t.replace(new RegExp("^".concat(Ht.source,"+")),""),vn=t=>new RegExp("^".concat(Ht.source,"*$")).test(t),An=t=>/\s$/.test(t),yn=["contenteditable","data-trix-id","data-trix-store-key","data-trix-mutable","data-trix-placeholder","tabindex"],xn="data-trix-serialized-attributes",Cn="[".concat(xn,"]"),En=new RegExp("\x3c!--block--\x3e","g"),Sn={"application/json":function(t){let e;if(t instanceof ln)e=t;else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");e=dn.parse(t.innerHTML).getDocument()}return e.toSerializableDocument().toJSONString()},"text/html":function(t){let e;if(t instanceof ln)e=Ri.render(t);else{if(!(t instanceof HTMLElement))throw new Error("unserializable object");e=t.cloneNode(!0)}return Array.from(e.querySelectorAll("[data-trix-serialize=false]")).forEach((t=>{k(t)})),yn.forEach((t=>{Array.from(e.querySelectorAll("[".concat(t,"]"))).forEach((e=>{e.removeAttribute(t)}))})),Array.from(e.querySelectorAll(Cn)).forEach((t=>{try{const e=JSON.parse(t.getAttribute(xn));t.removeAttribute(xn);for(const i in e){const n=e[i];t.setAttribute(i,n)}}catch(t){}})),e.innerHTML.replace(En,"")}};var Rn=Object.freeze({__proto__:null});class kn extends H{constructor(t,e){super(...arguments),this.attachmentManager=t,this.attachment=e,this.id=this.attachment.id,this.file=this.attachment.file}remove(){return this.attachmentManager.requestRemovalOfAttachment(this.attachment)}}kn.proxyMethod("attachment.getAttribute"),kn.proxyMethod("attachment.hasAttribute"),kn.proxyMethod("attachment.setAttribute"),kn.proxyMethod("attachment.getAttributes"),kn.proxyMethod("attachment.setAttributes"),kn.proxyMethod("attachment.isPending"),kn.proxyMethod("attachment.isPreviewable"),kn.proxyMethod("attachment.getURL"),kn.proxyMethod("attachment.getPreviewURL"),kn.proxyMethod("attachment.setPreviewURL"),kn.proxyMethod("attachment.getHref"),kn.proxyMethod("attachment.getFilename"),kn.proxyMethod("attachment.getFilesize"),kn.proxyMethod("attachment.getFormattedFilesize"),kn.proxyMethod("attachment.getExtension"),kn.proxyMethod("attachment.getContentType"),kn.proxyMethod("attachment.getFile"),kn.proxyMethod("attachment.setFile"),kn.proxyMethod("attachment.releaseFile"),kn.proxyMethod("attachment.getUploadProgress"),kn.proxyMethod("attachment.setUploadProgress");class Tn extends H{constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];super(...arguments),this.managedAttachments={},Array.from(t).forEach((t=>{this.manageAttachment(t)}))}getAttachments(){const t=[];for(const e in this.managedAttachments){const i=this.managedAttachments[e];t.push(i)}return t}manageAttachment(t){return this.managedAttachments[t.id]||(this.managedAttachments[t.id]=new kn(this,t)),this.managedAttachments[t.id]}attachmentIsManaged(t){return t.id in this.managedAttachments}requestRemovalOfAttachment(t){var e,i;if(this.attachmentIsManaged(t))return null===(e=this.delegate)||void 0===e||null===(i=e.attachmentManagerDidRequestRemovalOfAttachment)||void 0===i?void 0:i.call(e,t)}unmanageAttachment(t){const e=this.managedAttachments[t.id];return delete this.managedAttachments[t.id],e}}class wn{constructor(t){this.composition=t,this.document=this.composition.document;const e=this.composition.getSelectedRange();this.startPosition=e[0],this.endPosition=e[1],this.startLocation=this.document.locationFromPosition(this.startPosition),this.endLocation=this.document.locationFromPosition(this.endPosition),this.block=this.document.getBlockAtIndex(this.endLocation.index),this.breaksOnReturn=this.block.breaksOnReturn(),this.previousCharacter=this.block.text.getStringAtPosition(this.endLocation.offset-1),this.nextCharacter=this.block.text.getStringAtPosition(this.endLocation.offset)}shouldInsertBlockBreak(){return this.block.hasAttributes()&&this.block.isListItem()&&!this.block.isEmpty()?0!==this.startLocation.offset:this.breaksOnReturn&&"\n"!==this.nextCharacter}shouldBreakFormattedBlock(){return this.block.hasAttributes()&&!this.block.isListItem()&&(this.breaksOnReturn&&"\n"===this.nextCharacter||"\n"===this.previousCharacter)}shouldDecreaseListLevel(){return this.block.hasAttributes()&&this.block.isListItem()&&this.block.isEmpty()}shouldPrependListItem(){return this.block.isListItem()&&0===this.startLocation.offset&&!this.block.isEmpty()}shouldRemoveLastBlockAttribute(){return this.block.hasAttributes()&&!this.block.isListItem()&&this.block.isEmpty()}}class Ln extends H{constructor(){super(...arguments),this.document=new ln,this.attachments=[],this.currentAttributes={},this.revision=0}setDocument(t){var e,i;if(!t.isEqualTo(this.document))return this.document=t,this.refreshAttachments(),this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidChangeDocument)||void 0===i?void 0:i.call(e,t)}getSnapshot(){return{document:this.document,selectedRange:this.getSelectedRange()}}loadSnapshot(t){var e,i,n,r;let{document:o,selectedRange:s}=t;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionWillLoadSnapshot)||void 0===i||i.call(e),this.setDocument(null!=o?o:new ln),this.setSelection(null!=s?s:[0,0]),null===(n=this.delegate)||void 0===n||null===(r=n.compositionDidLoadSnapshot)||void 0===r?void 0:r.call(n)}insertText(t){let{updatePosition:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{updatePosition:!0};const i=this.getSelectedRange();this.setDocument(this.document.insertTextAtRange(t,i));const n=i[0],r=n+t.getLength();return e&&this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}insertBlock(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new $i;const e=new ln([t]);return this.insertDocument(e)}insertDocument(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new ln;const e=this.getSelectedRange();this.setDocument(this.document.insertDocumentAtRange(t,e));const i=e[0],n=i+t.getLength();return this.setSelection(n),this.notifyDelegateOfInsertionAtRange([i,n])}insertString(t,e){const i=this.getCurrentTextAttributes(),n=Xi.textForStringWithAttributes(t,i);return this.insertText(n,e)}insertBlockBreak(){const t=this.getSelectedRange();this.setDocument(this.document.insertBlockBreakAtRange(t));const e=t[0],i=e+1;return this.setSelection(i),this.notifyDelegateOfInsertionAtRange([e,i])}insertLineBreak(){const t=new wn(this);if(t.shouldDecreaseListLevel())return this.decreaseListLevel(),this.setSelection(t.startPosition);if(t.shouldPrependListItem()){const e=new ln([t.block.copyWithoutText()]);return this.insertDocument(e)}return t.shouldInsertBlockBreak()?this.insertBlockBreak():t.shouldRemoveLastBlockAttribute()?this.removeLastBlockAttribute():t.shouldBreakFormattedBlock()?this.breakFormattedBlock(t):this.insertString("\n")}insertHTML(t){const e=dn.parse(t,{purifyOptions:{SAFE_FOR_XML:!0}}).getDocument(),i=this.getSelectedRange();this.setDocument(this.document.mergeDocumentAtRange(e,i));const n=i[0],r=n+e.getLength()-1;return this.setSelection(r),this.notifyDelegateOfInsertionAtRange([n,r])}replaceHTML(t){const e=dn.parse(t).getDocument().copyUsingObjectsFromDocument(this.document),i=this.getLocationRange({strict:!1}),n=this.document.rangeFromLocationRange(i);return this.setDocument(e),this.setSelection(n)}insertFile(t){return this.insertFiles([t])}insertFiles(t){const e=[];return Array.from(t).forEach((t=>{var i;if(null!==(i=this.delegate)&&void 0!==i&&i.compositionShouldAcceptFile(t)){const i=zi.attachmentForFile(t);e.push(i)}})),this.insertAttachments(e)}insertAttachment(t){return this.insertAttachments([t])}insertAttachments(t){let e=new Xi;return Array.from(t).forEach((t=>{var n;const r=t.getType(),o=null===(n=i[r])||void 0===n?void 0:n.presentation,s=this.getCurrentTextAttributes();o&&(s.presentation=o);const a=Xi.textForAttachmentWithAttributes(t,s);e=e.appendText(a)})),this.insertText(e)}shouldManageDeletingInDirection(t){const e=this.getLocationRange();if(Dt(e)){if("backward"===t&&0===e[0].offset)return!0;if(this.shouldManageMovingCursorInDirection(t))return!0}else if(e[0].index!==e[1].index)return!0;return!1}deleteInDirection(t){let e,i,n,{length:r}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=this.getLocationRange();let s=this.getSelectedRange();const a=Dt(s);if(a?i="backward"===t&&0===o[0].offset:n=o[0].index!==o[1].index,i&&this.canDecreaseBlockAttributeLevel()){const t=this.getBlock();if(t.isListItem()?this.decreaseListLevel():this.decreaseBlockAttributeLevel(),this.setSelection(s[0]),t.isEmpty())return!1}return a&&(s=this.getExpandedRangeInDirection(t,{length:r}),"backward"===t&&(e=this.getAttachmentAtRange(s))),e?(this.editAttachment(e),!1):(this.setDocument(this.document.removeTextAtRange(s)),this.setSelection(s[0]),!i&&!n&&void 0)}moveTextFromRange(t){const[e]=Array.from(this.getSelectedRange());return this.setDocument(this.document.moveTextFromRangeToPosition(t,e)),this.setSelection(e)}removeAttachment(t){const e=this.document.getRangeOfAttachment(t);if(e)return this.stopEditingAttachment(),this.setDocument(this.document.removeTextAtRange(e)),this.setSelection(e[0])}removeLastBlockAttribute(){const[t,e]=Array.from(this.getSelectedRange()),i=this.document.getBlockAtPosition(e);return this.removeCurrentAttribute(i.getLastAttribute()),this.setSelection(t)}insertPlaceholder(){return this.placeholderPosition=this.getPosition(),this.insertString(" ")}selectPlaceholder(){if(null!=this.placeholderPosition)return this.setSelectedRange([this.placeholderPosition,this.placeholderPosition+1]),this.getSelectedRange()}forgetPlaceholder(){this.placeholderPosition=null}hasCurrentAttribute(t){const e=this.currentAttributes[t];return null!=e&&!1!==e}toggleCurrentAttribute(t){const e=!this.currentAttributes[t];return e?this.setCurrentAttribute(t,e):this.removeCurrentAttribute(t)}canSetCurrentAttribute(t){return pt(t)?this.canSetCurrentBlockAttribute(t):this.canSetCurrentTextAttribute(t)}canSetCurrentTextAttribute(t){const e=this.getSelectedDocument();if(e){for(const t of Array.from(e.getAttachments()))if(!t.hasContent())return!1;return!0}}canSetCurrentBlockAttribute(t){const e=this.getBlock();if(e)return!e.isTerminalBlock()}setCurrentAttribute(t,e){return pt(t)?this.setBlockAttribute(t,e):(this.setTextAttribute(t,e),this.currentAttributes[t]=e,this.notifyDelegateOfCurrentAttributesChange())}setHTMLAtributeAtPosition(t,e,i){var n;const r=this.document.getBlockAtPosition(t),o=null===(n=pt(r.getLastAttribute()))||void 0===n?void 0:n.htmlAttributes;if(r&&null!=o&&o.includes(e)){const n=this.document.setHTMLAttributeAtPosition(t,e,i);this.setDocument(n)}}setTextAttribute(t,e){const i=this.getSelectedRange();if(!i)return;const[n,r]=Array.from(i);if(n!==r)return this.setDocument(this.document.addAttributeAtRange(t,e,i));if("href"===t){const t=Xi.textForStringWithAttributes(e,{href:e});return this.insertText(t)}}setBlockAttribute(t,e){const i=this.getSelectedRange();if(this.canSetCurrentAttribute(t))return this.setDocument(this.document.applyBlockAttributeAtRange(t,e,i)),this.setSelection(i)}removeCurrentAttribute(t){return pt(t)?(this.removeBlockAttribute(t),this.updateCurrentAttributes()):(this.removeTextAttribute(t),delete this.currentAttributes[t],this.notifyDelegateOfCurrentAttributesChange())}removeTextAttribute(t){const e=this.getSelectedRange();if(e)return this.setDocument(this.document.removeAttributeAtRange(t,e))}removeBlockAttribute(t){const e=this.getSelectedRange();if(e)return this.setDocument(this.document.removeAttributeAtRange(t,e))}canDecreaseNestingLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getNestingLevel())>0}canIncreaseNestingLevel(){var t;const e=this.getBlock();if(e){if(null===(t=pt(e.getLastNestableAttribute()))||void 0===t||!t.listAttribute)return e.getNestingLevel()>0;{const t=this.getPreviousBlock();if(t)return function(){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return st((arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).slice(0,t.length),t)}(t.getListItemAttributes(),e.getListItemAttributes())}}}decreaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.decreaseNestingLevel()))}increaseNestingLevel(){const t=this.getBlock();if(t)return this.setDocument(this.document.replaceBlock(t,t.increaseNestingLevel()))}canDecreaseBlockAttributeLevel(){var t;return(null===(t=this.getBlock())||void 0===t?void 0:t.getAttributeLevel())>0}decreaseBlockAttributeLevel(){var t;const e=null===(t=this.getBlock())||void 0===t?void 0:t.getLastAttribute();if(e)return this.removeCurrentAttribute(e)}decreaseListLevel(){let[t]=Array.from(this.getSelectedRange());const{index:e}=this.document.locationFromPosition(t);let i=e;const n=this.getBlock().getAttributeLevel();let r=this.document.getBlockAtIndex(i+1);for(;r&&r.isListItem()&&!(r.getAttributeLevel()<=n);)i++,r=this.document.getBlockAtIndex(i+1);t=this.document.positionFromLocation({index:e,offset:0});const o=this.document.positionFromLocation({index:i,offset:0});return this.setDocument(this.document.removeLastListAttributeAtRange([t,o]))}updateCurrentAttributes(){const t=this.getSelectedRange({ignoreLock:!0});if(t){const e=this.document.getCommonAttributesAtRange(t);if(Array.from(mt()).forEach((t=>{e[t]||this.canSetCurrentAttribute(t)||(e[t]=!1)})),!wt(e,this.currentAttributes))return this.currentAttributes=e,this.notifyDelegateOfCurrentAttributesChange()}}getCurrentAttributes(){return m.call({},this.currentAttributes)}getCurrentTextAttributes(){const t={};for(const e in this.currentAttributes){const i=this.currentAttributes[e];!1!==i&&bt(e)&&(t[e]=i)}return t}freezeSelection(){return this.setCurrentAttribute("frozen",!0)}thawSelection(){return this.removeCurrentAttribute("frozen")}hasFrozenSelection(){return this.hasCurrentAttribute("frozen")}setSelection(t){var e;const i=this.document.locationRangeFromRange(t);return null===(e=this.delegate)||void 0===e?void 0:e.compositionDidRequestChangingSelectionToLocationRange(i)}getSelectedRange(){const t=this.getLocationRange();if(t)return this.document.rangeFromLocationRange(t)}setSelectedRange(t){const e=this.document.locationRangeFromRange(t);return this.getSelectionManager().setLocationRange(e)}getPosition(){const t=this.getLocationRange();if(t)return this.document.positionFromLocation(t[0])}getLocationRange(t){return this.targetLocationRange?this.targetLocationRange:this.getSelectionManager().getLocationRange(t)||Lt({index:0,offset:0})}withTargetLocationRange(t,e){let i;this.targetLocationRange=t;try{i=e()}finally{this.targetLocationRange=null}return i}withTargetRange(t,e){const i=this.document.locationRangeFromRange(t);return this.withTargetLocationRange(i,e)}withTargetDOMRange(t,e){const i=this.createLocationRangeFromDOMRange(t,{strict:!1});return this.withTargetLocationRange(i,e)}getExpandedRangeInDirection(t){let{length:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},[i,n]=Array.from(this.getSelectedRange());return"backward"===t?e?i-=e:i=this.translateUTF16PositionFromOffset(i,-1):e?n+=e:n=this.translateUTF16PositionFromOffset(n,1),Lt([i,n])}shouldManageMovingCursorInDirection(t){if(this.editingAttachment)return!0;const e=this.getExpandedRangeInDirection(t);return null!=this.getAttachmentAtRange(e)}moveCursorInDirection(t){let e,i;if(this.editingAttachment)i=this.document.getRangeOfAttachment(this.editingAttachment);else{const n=this.getSelectedRange();i=this.getExpandedRangeInDirection(t),e=!Nt(n,i)}if("backward"===t?this.setSelectedRange(i[0]):this.setSelectedRange(i[1]),e){const t=this.getAttachmentAtRange(i);if(t)return this.editAttachment(t)}}expandSelectionInDirection(t){let{length:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.getExpandedRangeInDirection(t,{length:e});return this.setSelectedRange(i)}expandSelectionForEditing(){if(this.hasCurrentAttribute("href"))return this.expandSelectionAroundCommonAttribute("href")}expandSelectionAroundCommonAttribute(t){const e=this.getPosition(),i=this.document.getRangeOfCommonAttributeAtPosition(t,e);return this.setSelectedRange(i)}selectionContainsAttachments(){var t;return(null===(t=this.getSelectedAttachments())||void 0===t?void 0:t.length)>0}selectionIsInCursorTarget(){return this.editingAttachment||this.positionIsCursorTarget(this.getPosition())}positionIsCursorTarget(t){const e=this.document.locationFromPosition(t);if(e)return this.locationIsCursorTarget(e)}positionIsBlockBreak(t){var e;return null===(e=this.document.getPieceAtPosition(t))||void 0===e?void 0:e.isBlockBreak()}getSelectedDocument(){const t=this.getSelectedRange();if(t)return this.document.getDocumentAtRange(t)}getSelectedAttachments(){var t;return null===(t=this.getSelectedDocument())||void 0===t?void 0:t.getAttachments()}getAttachments(){return this.attachments.slice(0)}refreshAttachments(){const t=this.document.getAttachments(),{added:e,removed:i}=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const i=[],n=[],r=new Set;t.forEach((t=>{r.add(t)}));const o=new Set;return e.forEach((t=>{o.add(t),r.has(t)||i.push(t)})),t.forEach((t=>{o.has(t)||n.push(t)})),{added:i,removed:n}}(this.attachments,t);return this.attachments=t,Array.from(i).forEach((t=>{var e,i;t.delegate=null,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidRemoveAttachment)||void 0===i||i.call(e,t)})),(()=>{const t=[];return Array.from(e).forEach((e=>{var i,n;e.delegate=this,t.push(null===(i=this.delegate)||void 0===i||null===(n=i.compositionDidAddAttachment)||void 0===n?void 0:n.call(i,e))})),t})()}attachmentDidChangeAttributes(t){var e,i;return this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidEditAttachment)||void 0===i?void 0:i.call(e,t)}attachmentDidChangePreviewURL(t){var e,i;return this.revision++,null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidChangeAttachmentPreviewURL)||void 0===i?void 0:i.call(e,t)}editAttachment(t,e){var i,n;if(t!==this.editingAttachment)return this.stopEditingAttachment(),this.editingAttachment=t,null===(i=this.delegate)||void 0===i||null===(n=i.compositionDidStartEditingAttachment)||void 0===n?void 0:n.call(i,this.editingAttachment,e)}stopEditingAttachment(){var t,e;this.editingAttachment&&(null===(t=this.delegate)||void 0===t||null===(e=t.compositionDidStopEditingAttachment)||void 0===e||e.call(t,this.editingAttachment),this.editingAttachment=null)}updateAttributesForAttachment(t,e){return this.setDocument(this.document.updateAttributesForAttachment(t,e))}removeAttributeForAttachment(t,e){return this.setDocument(this.document.removeAttributeForAttachment(t,e))}breakFormattedBlock(t){let{document:e}=t;const{block:i}=t;let n=t.startPosition,r=[n-1,n];i.getBlockBreakPosition()===t.startLocation.offset?(i.breaksOnReturn()&&"\n"===t.nextCharacter?n+=1:e=e.removeTextAtRange(r),r=[n,n]):"\n"===t.nextCharacter?"\n"===t.previousCharacter?r=[n-1,n+1]:(r=[n,n+1],n+=1):t.startLocation.offset-1!=0&&(n+=1);const o=new ln([i.removeLastAttribute().copyWithoutText()]);return this.setDocument(e.insertDocumentAtRange(o,r)),this.setSelection(n)}getPreviousBlock(){const t=this.getLocationRange();if(t){const{index:e}=t[0];if(e>0)return this.document.getBlockAtIndex(e-1)}}getBlock(){const t=this.getLocationRange();if(t)return this.document.getBlockAtIndex(t[0].index)}getAttachmentAtRange(t){const e=this.document.getDocumentAtRange(t);if(e.toString()==="".concat("","\n"))return e.getAttachments()[0]}notifyDelegateOfCurrentAttributesChange(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.compositionDidChangeCurrentAttributes)||void 0===e?void 0:e.call(t,this.currentAttributes)}notifyDelegateOfInsertionAtRange(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionDidPerformInsertionAtRange)||void 0===i?void 0:i.call(e,t)}translateUTF16PositionFromOffset(t,e){const i=this.document.toUTF16String(),n=i.offsetFromUCS2Offset(t);return i.offsetToUCS2Offset(n+e)}}Ln.proxyMethod("getSelectionManager().getPointRange"),Ln.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"),Ln.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"),Ln.proxyMethod("getSelectionManager().locationIsCursorTarget"),Ln.proxyMethod("getSelectionManager().selectionIsExpanded"),Ln.proxyMethod("delegate?.getSelectionManager");class Dn extends H{constructor(t){super(...arguments),this.composition=t,this.undoEntries=[],this.redoEntries=[]}recordUndoEntry(t){let{context:e,consolidatable:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.undoEntries.slice(-1)[0];if(!i||!Nn(n,t,e)){const i=this.createEntry({description:t,context:e});this.undoEntries.push(i),this.redoEntries=[]}}undo(){const t=this.undoEntries.pop();if(t){const e=this.createEntry(t);return this.redoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}redo(){const t=this.redoEntries.pop();if(t){const e=this.createEntry(t);return this.undoEntries.push(e),this.composition.loadSnapshot(t.snapshot)}}canUndo(){return this.undoEntries.length>0}canRedo(){return this.redoEntries.length>0}createEntry(){let{description:t,context:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{description:null==t?void 0:t.toString(),context:JSON.stringify(e),snapshot:this.composition.getSnapshot()}}}const Nn=(t,e,i)=>(null==t?void 0:t.description)===(null==e?void 0:e.toString())&&(null==t?void 0:t.context)===JSON.stringify(i),In="attachmentGallery";class On{constructor(t){this.document=t.document,this.selectedRange=t.selectedRange}perform(){return this.removeBlockAttribute(),this.applyBlockAttribute()}getSnapshot(){return{document:this.document,selectedRange:this.selectedRange}}removeBlockAttribute(){return this.findRangesOfBlocks().map((t=>this.document=this.document.removeAttributeAtRange(In,t)))}applyBlockAttribute(){let t=0;this.findRangesOfPieces().forEach((e=>{e[1]-e[0]>1&&(e[0]+=t,e[1]+=t,"\n"!==this.document.getCharacterAtPosition(e[1])&&(this.document=this.document.insertBlockBreakAtRange(e[1]),e[1]0&&void 0!==arguments[0]?arguments[0]:"";const e=dn.parse(t,{referenceElement:this.element}).getDocument();return this.loadDocument(e)}loadJSON(t){let{document:e,selectedRange:i}=t;return e=ln.fromJSON(e),this.loadSnapshot({document:e,selectedRange:i})}loadSnapshot(t){return this.undoManager=new Dn(this.composition),this.composition.loadSnapshot(t)}getDocument(){return this.composition.document}getSelectedDocument(){return this.composition.getSelectedDocument()}getSnapshot(){return this.composition.getSnapshot()}toJSON(){return this.getSnapshot()}deleteInDirection(t){return this.composition.deleteInDirection(t)}insertAttachment(t){return this.composition.insertAttachment(t)}insertAttachments(t){return this.composition.insertAttachments(t)}insertDocument(t){return this.composition.insertDocument(t)}insertFile(t){return this.composition.insertFile(t)}insertFiles(t){return this.composition.insertFiles(t)}insertHTML(t){return this.composition.insertHTML(t)}insertString(t){return this.composition.insertString(t)}insertText(t){return this.composition.insertText(t)}insertLineBreak(){return this.composition.insertLineBreak()}getSelectedRange(){return this.composition.getSelectedRange()}getPosition(){return this.composition.getPosition()}getClientRectAtPosition(t){const e=this.getDocument().locationRangeFromRange([t,t+1]);return this.selectionManager.getClientRectAtLocationRange(e)}expandSelectionInDirection(t){return this.composition.expandSelectionInDirection(t)}moveCursorInDirection(t){return this.composition.moveCursorInDirection(t)}setSelectedRange(t){return this.composition.setSelectedRange(t)}activateAttribute(t){let e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return this.composition.setCurrentAttribute(t,e)}attributeIsActive(t){return this.composition.hasCurrentAttribute(t)}canActivateAttribute(t){return this.composition.canSetCurrentAttribute(t)}deactivateAttribute(t){return this.composition.removeCurrentAttribute(t)}setHTMLAtributeAtPosition(t,e,i){this.composition.setHTMLAtributeAtPosition(t,e,i)}canDecreaseNestingLevel(){return this.composition.canDecreaseNestingLevel()}canIncreaseNestingLevel(){return this.composition.canIncreaseNestingLevel()}decreaseNestingLevel(){if(this.canDecreaseNestingLevel())return this.composition.decreaseNestingLevel()}increaseNestingLevel(){if(this.canIncreaseNestingLevel())return this.composition.increaseNestingLevel()}canRedo(){return this.undoManager.canRedo()}canUndo(){return this.undoManager.canUndo()}recordUndoEntry(t){let{context:e,consolidatable:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.undoManager.recordUndoEntry(t,{context:e,consolidatable:i})}redo(){if(this.canRedo())return this.undoManager.redo()}undo(){if(this.canUndo())return this.undoManager.undo()}}class Bn{constructor(t){this.element=t}findLocationFromContainerAndOffset(t,e){let{strict:i}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{strict:!0},n=0,r=!1;const o={index:0,offset:0},s=this.findAttachmentElementParentForNode(t);s&&(t=s.parentNode,e=S(s));const a=R(this.element,{usingFilter:Un});for(;a.nextNode();){const s=a.currentNode;if(s===t&&_(t)){P(s)||(o.offset+=e);break}if(s.parentNode===t){if(n++===e)break}else if(!E(t,s)&&n>0)break;I(s,{strict:i})?(r&&o.index++,o.offset=0,r=!0):o.offset+=_n(s)}return o}findContainerAndOffsetFromLocation(t){let e,i;if(0===t.index&&0===t.offset){for(e=this.element,i=0;e.firstChild;)if(e=e.firstChild,N(e)){i=1;break}return[e,i]}let[n,r]=this.findNodeAndOffsetFromLocation(t);if(n){if(_(n))0===_n(n)?(e=n.parentNode.parentNode,i=S(n.parentNode),P(n,{name:"right"})&&i++):(e=n,i=t.offset-r);else{if(e=n.parentNode,!I(n.previousSibling)&&!N(e))for(;n===e.lastChild&&(n=e,e=e.parentNode,!N(e)););i=S(n),0!==t.offset&&i++}return[e,i]}}findNodeAndOffsetFromLocation(t){let e,i,n=0;for(const r of this.getSignificantNodesForIndex(t.index)){const o=_n(r);if(t.offset<=n+o)if(_(r)){if(e=r,i=n,t.offset===i&&P(e))break}else e||(e=r,i=n);if(n+=o,n>t.offset)break}return[e,i]}findAttachmentElementParentForNode(t){for(;t&&t!==this.element;){if(M(t))return t;t=t.parentNode}}getSignificantNodesForIndex(t){const e=[],i=R(this.element,{usingFilter:jn});let n=!1;for(;i.nextNode();){const o=i.currentNode;var r;if(O(o)){if(null!=r?r++:r=0,r===t)n=!0;else if(n)break}else n&&e.push(o)}return e}}const _n=function(t){return t.nodeType===Node.TEXT_NODE?P(t)?0:t.textContent.length:"br"===T(t)||M(t)?1:0},jn=function(t){return Wn(t)===NodeFilter.FILTER_ACCEPT?Un(t):NodeFilter.FILTER_REJECT},Wn=function(t){return B(t)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT},Un=function(t){return M(t.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT};class Vn{createDOMRangeFromPoint(t){let e,{x:i,y:n}=t;if(document.caretPositionFromPoint){const{offsetNode:t,offset:r}=document.caretPositionFromPoint(i,n);return e=document.createRange(),e.setStart(t,r),e}if(document.caretRangeFromPoint)return document.caretRangeFromPoint(i,n);if(document.body.createTextRange){const r=Bt();try{const t=document.body.createTextRange();t.moveToPoint(i,n),t.select()}catch(t){}return e=Bt(),_t(r),e}}getClientRectsForDOMRange(t){const e=Array.from(t.getClientRects());return[e[0],e[e.length-1]]}}class zn extends H{constructor(t){super(...arguments),this.didMouseDown=this.didMouseDown.bind(this),this.selectionDidChange=this.selectionDidChange.bind(this),this.element=t,this.locationMapper=new Bn(this.element),this.pointMapper=new Vn,this.lockCount=0,b("mousedown",{onElement:this.element,withCallback:this.didMouseDown})}getLocationRange(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return!1===t.strict?this.createLocationRangeFromDOMRange(Bt()):t.ignoreLock?this.currentLocationRange:this.lockedLocationRange?this.lockedLocationRange:this.currentLocationRange}setLocationRange(t){if(this.lockedLocationRange)return;t=Lt(t);const e=this.createDOMRangeFromLocationRange(t);e&&(_t(e),this.updateCurrentLocationRange(t))}setLocationRangeFromPointRange(t){t=Lt(t);const e=this.getLocationAtPoint(t[0]),i=this.getLocationAtPoint(t[1]);this.setLocationRange([e,i])}getClientRectAtLocationRange(t){const e=this.createDOMRangeFromLocationRange(t);if(e)return this.getClientRectsForDOMRange(e)[1]}locationIsCursorTarget(t){const e=Array.from(this.findNodeAndOffsetFromLocation(t))[0];return P(e)}lock(){0==this.lockCount++&&(this.updateCurrentLocationRange(),this.lockedLocationRange=this.getLocationRange())}unlock(){if(0==--this.lockCount){const{lockedLocationRange:t}=this;if(this.lockedLocationRange=null,null!=t)return this.setLocationRange(t)}}clearSelection(){var t;return null===(t=Mt())||void 0===t?void 0:t.removeAllRanges()}selectionIsCollapsed(){var t;return!0===(null===(t=Bt())||void 0===t?void 0:t.collapsed)}selectionIsExpanded(){return!this.selectionIsCollapsed()}createLocationRangeFromDOMRange(t,e){if(null==t||!this.domRangeWithinElement(t))return;const i=this.findLocationFromContainerAndOffset(t.startContainer,t.startOffset,e);if(!i)return;const n=t.collapsed?void 0:this.findLocationFromContainerAndOffset(t.endContainer,t.endOffset,e);return Lt([i,n])}didMouseDown(){return this.pauseTemporarily()}pauseTemporarily(){let t;this.paused=!0;const e=()=>{if(this.paused=!1,clearTimeout(i),Array.from(t).forEach((t=>{t.destroy()})),E(document,this.element))return this.selectionDidChange()},i=setTimeout(e,200);t=["mousemove","keydown"].map((t=>b(t,{onElement:document,withCallback:e})))}selectionDidChange(){if(!this.paused&&!C(this.element))return this.updateCurrentLocationRange()}updateCurrentLocationRange(t){var e,i;if((null!=t?t:t=this.createLocationRangeFromDOMRange(Bt()))&&!Nt(t,this.currentLocationRange))return this.currentLocationRange=t,null===(e=this.delegate)||void 0===e||null===(i=e.locationRangeDidChange)||void 0===i?void 0:i.call(e,this.currentLocationRange.slice(0))}createDOMRangeFromLocationRange(t){const e=this.findContainerAndOffsetFromLocation(t[0]),i=Dt(t)?e:this.findContainerAndOffsetFromLocation(t[1])||e;if(null!=e&&null!=i){const t=document.createRange();return t.setStart(...Array.from(e||[])),t.setEnd(...Array.from(i||[])),t}}getLocationAtPoint(t){const e=this.createDOMRangeFromPoint(t);var i;if(e)return null===(i=this.createLocationRangeFromDOMRange(e))||void 0===i?void 0:i[0]}domRangeWithinElement(t){return t.collapsed?E(this.element,t.startContainer):E(this.element,t.startContainer)&&E(this.element,t.endContainer)}}zn.proxyMethod("locationMapper.findLocationFromContainerAndOffset"),zn.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"),zn.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"),zn.proxyMethod("pointMapper.createDOMRangeFromPoint"),zn.proxyMethod("pointMapper.getClientRectsForDOMRange");var Hn=Object.freeze({__proto__:null,Attachment:zi,AttachmentManager:Tn,AttachmentPiece:qi,Block:$i,Composition:Ln,Document:ln,Editor:Mn,HTMLParser:dn,HTMLSanitizer:gi,LineBreakInsertion:wn,LocationMapper:Bn,ManagedAttachment:kn,Piece:Ui,PointMapper:Vn,SelectionManager:zn,SplittableList:Ji,StringPiece:Hi,Text:Xi,UndoManager:Dn}),qn=Object.freeze({__proto__:null,ObjectView:ne,AttachmentView:fi,BlockView:Si,DocumentView:Ri,PieceView:yi,PreviewableAttachmentView:Ai,TextView:xi});const{lang:Jn,css:Kn,keyNames:Gn}=q,Yn=function(t){return function(){const e=t.apply(this,arguments);e.do(),this.undos||(this.undos=[]),this.undos.push(e.undo)}};class Xn extends H{constructor(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};super(...arguments),Ii(this,"makeElementMutable",Yn((()=>({do:()=>{this.element.dataset.trixMutable=!0},undo:()=>delete this.element.dataset.trixMutable})))),Ii(this,"addToolbar",Yn((()=>{const t=w({tagName:"div",className:Kn.attachmentToolbar,data:{trixMutable:!0},childNodes:w({tagName:"div",className:"trix-button-row",childNodes:w({tagName:"span",className:"trix-button-group trix-button-group--actions",childNodes:w({tagName:"button",className:"trix-button trix-button--remove",textContent:Jn.remove,attributes:{title:Jn.remove},data:{trixAction:"remove"}})})})});return this.attachment.isPreviewable()&&t.appendChild(w({tagName:"div",className:Kn.attachmentMetadataContainer,childNodes:w({tagName:"span",className:Kn.attachmentMetadata,childNodes:[w({tagName:"span",className:Kn.attachmentName,textContent:this.attachment.getFilename(),attributes:{title:this.attachment.getFilename()}}),w({tagName:"span",className:Kn.attachmentSize,textContent:this.attachment.getFormattedFilesize()})]})})),b("click",{onElement:t,withCallback:this.didClickToolbar}),b("click",{onElement:t,matchingSelector:"[data-trix-action]",withCallback:this.didClickActionButton}),A("trix-attachment-before-toolbar",{onElement:this.element,attributes:{toolbar:t,attachment:this.attachment}}),{do:()=>this.element.appendChild(t),undo:()=>k(t)}}))),Ii(this,"installCaptionEditor",Yn((()=>{const t=w({tagName:"textarea",className:Kn.attachmentCaptionEditor,attributes:{placeholder:Jn.captionPlaceholder},data:{trixMutable:!0}});t.value=this.attachmentPiece.getCaption();const e=t.cloneNode();e.classList.add("trix-autoresize-clone"),e.tabIndex=-1;const i=function(){e.value=t.value,t.style.height=e.scrollHeight+"px"};b("input",{onElement:t,withCallback:i}),b("input",{onElement:t,withCallback:this.didInputCaption}),b("keydown",{onElement:t,withCallback:this.didKeyDownCaption}),b("change",{onElement:t,withCallback:this.didChangeCaption}),b("blur",{onElement:t,withCallback:this.didBlurCaption});const n=this.element.querySelector("figcaption"),r=n.cloneNode();return{do:()=>{if(n.style.display="none",r.appendChild(t),r.appendChild(e),r.classList.add("".concat(Kn.attachmentCaption,"--editing")),n.parentElement.insertBefore(r,n),i(),this.options.editCaption)return Rt((()=>t.focus()))},undo(){k(r),n.style.display=null}}}))),this.didClickToolbar=this.didClickToolbar.bind(this),this.didClickActionButton=this.didClickActionButton.bind(this),this.didKeyDownCaption=this.didKeyDownCaption.bind(this),this.didInputCaption=this.didInputCaption.bind(this),this.didChangeCaption=this.didChangeCaption.bind(this),this.didBlurCaption=this.didBlurCaption.bind(this),this.attachmentPiece=t,this.element=e,this.container=i,this.options=n,this.attachment=this.attachmentPiece.attachment,"a"===T(this.element)&&(this.element=this.element.firstChild),this.install()}install(){this.makeElementMutable(),this.addToolbar(),this.attachment.isPreviewable()&&this.installCaptionEditor()}uninstall(){var t;let e=this.undos.pop();for(this.savePendingCaption();e;)e(),e=this.undos.pop();null===(t=this.delegate)||void 0===t||t.didUninstallAttachmentEditor(this)}savePendingCaption(){if(null!=this.pendingCaption){const r=this.pendingCaption;var t,e,i,n;this.pendingCaption=null,r?null===(t=this.delegate)||void 0===t||null===(e=t.attachmentEditorDidRequestUpdatingAttributesForAttachment)||void 0===e||e.call(t,{caption:r},this.attachment):null===(i=this.delegate)||void 0===i||null===(n=i.attachmentEditorDidRequestRemovingAttributeForAttachment)||void 0===n||n.call(i,"caption",this.attachment)}}didClickToolbar(t){return t.preventDefault(),t.stopPropagation()}didClickActionButton(t){var e;if("remove"===t.target.getAttribute("data-trix-action"))return null===(e=this.delegate)||void 0===e?void 0:e.attachmentEditorDidRequestRemovalOfAttachment(this.attachment)}didKeyDownCaption(t){var e,i;if("return"===Gn[t.keyCode])return t.preventDefault(),this.savePendingCaption(),null===(e=this.delegate)||void 0===e||null===(i=e.attachmentEditorDidRequestDeselectingAttachment)||void 0===i?void 0:i.call(e,this.attachment)}didInputCaption(t){this.pendingCaption=t.target.value.replace(/\s/g," ").trim()}didChangeCaption(t){return this.savePendingCaption()}didBlurCaption(t){return this.savePendingCaption()}}class $n extends H{constructor(t,i){super(...arguments),this.didFocus=this.didFocus.bind(this),this.didBlur=this.didBlur.bind(this),this.didClickAttachment=this.didClickAttachment.bind(this),this.element=t,this.composition=i,this.documentView=new Ri(this.composition.document,{element:this.element}),b("focus",{onElement:this.element,withCallback:this.didFocus}),b("blur",{onElement:this.element,withCallback:this.didBlur}),b("click",{onElement:this.element,matchingSelector:"a[contenteditable=false]",preventDefault:!0}),b("mousedown",{onElement:this.element,matchingSelector:e,withCallback:this.didClickAttachment}),b("click",{onElement:this.element,matchingSelector:"a".concat(e),preventDefault:!0})}didFocus(t){var e;const i=()=>{var t,e;if(!this.focused)return this.focused=!0,null===(t=this.delegate)||void 0===t||null===(e=t.compositionControllerDidFocus)||void 0===e?void 0:e.call(t)};return(null===(e=this.blurPromise)||void 0===e?void 0:e.then(i))||i()}didBlur(t){this.blurPromise=new Promise((t=>Rt((()=>{var e,i;C(this.element)||(this.focused=null,null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidBlur)||void 0===i||i.call(e));return this.blurPromise=null,t()}))))}didClickAttachment(t,e){var i,n;const r=this.findAttachmentForElement(e),o=!!x(t.target,{matchingSelector:"figcaption"});return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerDidSelectAttachment)||void 0===n?void 0:n.call(i,r,{editCaption:o})}getSerializableElement(){return this.isEditingAttachment()?this.documentView.shadowElement:this.element}render(){var t,e,i,n,r,o;(this.revision!==this.composition.revision&&(this.documentView.setDocument(this.composition.document),this.documentView.render(),this.revision=this.composition.revision),this.canSyncDocumentView()&&!this.documentView.isSynced())&&(null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillSyncDocumentView)||void 0===n||n.call(i),this.documentView.sync(),null===(r=this.delegate)||void 0===r||null===(o=r.compositionControllerDidSyncDocumentView)||void 0===o||o.call(r));return null===(t=this.delegate)||void 0===t||null===(e=t.compositionControllerDidRender)||void 0===e?void 0:e.call(t)}rerenderViewForObject(t){return this.invalidateViewForObject(t),this.render()}invalidateViewForObject(t){return this.documentView.invalidateViewForObject(t)}isViewCachingEnabled(){return this.documentView.isViewCachingEnabled()}enableViewCaching(){return this.documentView.enableViewCaching()}disableViewCaching(){return this.documentView.disableViewCaching()}refreshViewCache(){return this.documentView.garbageCollectCachedViews()}isEditingAttachment(){return!!this.attachmentEditor}installAttachmentEditorForAttachment(t,e){var i;if((null===(i=this.attachmentEditor)||void 0===i?void 0:i.attachment)===t)return;const n=this.documentView.findElementForObject(t);if(!n)return;this.uninstallAttachmentEditor();const r=this.composition.document.getAttachmentPieceForAttachment(t);this.attachmentEditor=new Xn(r,n,this.element,e),this.attachmentEditor.delegate=this}uninstallAttachmentEditor(){var t;return null===(t=this.attachmentEditor)||void 0===t?void 0:t.uninstall()}didUninstallAttachmentEditor(){return this.attachmentEditor=null,this.render()}attachmentEditorDidRequestUpdatingAttributesForAttachment(t,e){var i,n;return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillUpdateAttachment)||void 0===n||n.call(i,e),this.composition.updateAttributesForAttachment(t,e)}attachmentEditorDidRequestRemovingAttributeForAttachment(t,e){var i,n;return null===(i=this.delegate)||void 0===i||null===(n=i.compositionControllerWillUpdateAttachment)||void 0===n||n.call(i,e),this.composition.removeAttributeForAttachment(t,e)}attachmentEditorDidRequestRemovalOfAttachment(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidRequestRemovalOfAttachment)||void 0===i?void 0:i.call(e,t)}attachmentEditorDidRequestDeselectingAttachment(t){var e,i;return null===(e=this.delegate)||void 0===e||null===(i=e.compositionControllerDidRequestDeselectingAttachment)||void 0===i?void 0:i.call(e,t)}canSyncDocumentView(){return!this.isEditingAttachment()}findAttachmentForElement(t){return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId,10))}}class Zn extends H{}const Qn="data-trix-mutable",tr="[".concat(Qn,"]"),er={attributes:!0,childList:!0,characterData:!0,characterDataOldValue:!0,subtree:!0};class ir extends H{constructor(t){super(t),this.didMutate=this.didMutate.bind(this),this.element=t,this.observer=new window.MutationObserver(this.didMutate),this.start()}start(){return this.reset(),this.observer.observe(this.element,er)}stop(){return this.observer.disconnect()}didMutate(t){var e,i;if(this.mutations.push(...Array.from(this.findSignificantMutations(t)||[])),this.mutations.length)return null===(e=this.delegate)||void 0===e||null===(i=e.elementDidMutate)||void 0===i||i.call(e,this.getMutationSummary()),this.reset()}reset(){this.mutations=[]}findSignificantMutations(t){return t.filter((t=>this.mutationIsSignificant(t)))}mutationIsSignificant(t){if(this.nodeIsMutable(t.target))return!1;for(const e of Array.from(this.nodesModifiedByMutation(t)))if(this.nodeIsSignificant(e))return!0;return!1}nodeIsSignificant(t){return t!==this.element&&!this.nodeIsMutable(t)&&!B(t)}nodeIsMutable(t){return x(t,{matchingSelector:tr})}nodesModifiedByMutation(t){const e=[];switch(t.type){case"attributes":t.attributeName!==Qn&&e.push(t.target);break;case"characterData":e.push(t.target.parentNode),e.push(t.target);break;case"childList":e.push(...Array.from(t.addedNodes||[])),e.push(...Array.from(t.removedNodes||[]))}return e}getMutationSummary(){return this.getTextMutationSummary()}getTextMutationSummary(){const{additions:t,deletions:e}=this.getTextChangesFromCharacterData(),i=this.getTextChangesFromChildList();Array.from(i.additions).forEach((e=>{Array.from(t).includes(e)||t.push(e)})),e.push(...Array.from(i.deletions||[]));const n={},r=t.join("");r&&(n.textAdded=r);const o=e.join("");return o&&(n.textDeleted=o),n}getMutationsByType(t){return Array.from(this.mutations).filter((e=>e.type===t))}getTextChangesFromChildList(){let t,e;const i=[],n=[];Array.from(this.getMutationsByType("childList")).forEach((t=>{i.push(...Array.from(t.addedNodes||[])),n.push(...Array.from(t.removedNodes||[]))}));0===i.length&&1===n.length&&O(n[0])?(t=[],e=["\n"]):(t=nr(i),e=nr(n));const r=t.filter(((t,i)=>t!==e[i])).map(Ut),o=e.filter(((e,i)=>e!==t[i])).map(Ut);return{additions:r,deletions:o}}getTextChangesFromCharacterData(){let t,e;const i=this.getMutationsByType("characterData");if(i.length){const n=i[0],r=i[i.length-1],o=function(t,e){let i,n;return t=Z.box(t),(e=Z.box(e)).length0&&void 0!==arguments[0]?arguments[0]:[];const e=[];for(const i of Array.from(t))switch(i.nodeType){case Node.TEXT_NODE:e.push(i.data);break;case Node.ELEMENT_NODE:"br"===T(i)?e.push("\n"):e.push(...Array.from(nr(i.childNodes)||[]))}return e};class rr extends ie{constructor(t){super(...arguments),this.file=t}perform(t){const e=new FileReader;return e.onerror=()=>t(!1),e.onload=()=>{e.onerror=null;try{e.abort()}catch(t){}return t(!0,this.file)},e.readAsArrayBuffer(this.file)}}class or{constructor(t){this.element=t}shouldIgnore(t){return!!a.samsungAndroid&&(this.previousEvent=this.event,this.event=t,this.checkSamsungKeyboardBuggyModeStart(),this.checkSamsungKeyboardBuggyModeEnd(),this.buggyMode)}checkSamsungKeyboardBuggyModeStart(){this.insertingLongTextAfterUnidentifiedChar()&&sr(this.element.innerText,this.event.data)&&(this.buggyMode=!0,this.event.preventDefault())}checkSamsungKeyboardBuggyModeEnd(){this.buggyMode&&"insertText"!==this.event.inputType&&(this.buggyMode=!1)}insertingLongTextAfterUnidentifiedChar(){var t;return this.isBeforeInputInsertText()&&this.previousEventWasUnidentifiedKeydown()&&(null===(t=this.event.data)||void 0===t?void 0:t.length)>50}isBeforeInputInsertText(){return"beforeinput"===this.event.type&&"insertText"===this.event.inputType}previousEventWasUnidentifiedKeydown(){var t,e;return"keydown"===(null===(t=this.previousEvent)||void 0===t?void 0:t.type)&&"Unidentified"===(null===(e=this.previousEvent)||void 0===e?void 0:e.key)}}const sr=(t,e)=>lr(t)===lr(e),ar=new RegExp("(".concat("","|").concat(d,"|").concat(g,"|\\s)+"),"g"),lr=t=>t.replace(ar," ").trim();class cr extends H{constructor(t){super(...arguments),this.element=t,this.mutationObserver=new ir(this.element),this.mutationObserver.delegate=this,this.flakyKeyboardDetector=new or(this.element);for(const t in this.constructor.events)b(t,{onElement:this.element,withCallback:this.handlerFor(t)})}elementDidMutate(t){}editorWillSyncDocumentView(){return this.mutationObserver.stop()}editorDidSyncDocumentView(){return this.mutationObserver.start()}requestRender(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidRequestRender)||void 0===e?void 0:e.call(t)}requestReparse(){var t,e;return null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidRequestReparse)||void 0===e||e.call(t),this.requestRender()}attachFiles(t){const e=Array.from(t).map((t=>new rr(t)));return Promise.all(e).then((t=>{this.handleInput((function(){var e,i;return null===(e=this.delegate)||void 0===e||e.inputControllerWillAttachFiles(),null===(i=this.responder)||void 0===i||i.insertFiles(t),this.requestRender()}))}))}handlerFor(t){return e=>{e.defaultPrevented||this.handleInput((()=>{if(!C(this.element)){if(this.flakyKeyboardDetector.shouldIgnore(e))return;this.eventName=t,this.constructor.events[t].call(this,e)}}))}}handleInput(t){try{var e;null===(e=this.delegate)||void 0===e||e.inputControllerWillHandleInput(),t.call(this)}finally{var i;null===(i=this.delegate)||void 0===i||i.inputControllerDidHandleInput()}}createLinkHTML(t,e){const i=document.createElement("a");return i.href=t,i.textContent=e||t,i.outerHTML}}var ur;Ii(cr,"events",{});const{browser:hr,keyNames:dr}=q;let gr=0;class mr extends cr{constructor(){super(...arguments),this.resetInputSummary()}setInputSummary(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.inputSummary.eventName=this.eventName;for(const e in t){const i=t[e];this.inputSummary[e]=i}return this.inputSummary}resetInputSummary(){this.inputSummary={}}reset(){return this.resetInputSummary(),Pt.reset()}elementDidMutate(t){var e,i;return this.isComposing()?null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidAllowUnhandledInput)||void 0===i?void 0:i.call(e):this.handleInput((function(){return this.mutationIsSignificant(t)&&(this.mutationIsExpected(t)?this.requestRender():this.requestReparse()),this.reset()}))}mutationIsExpected(t){let{textAdded:e,textDeleted:i}=t;if(this.inputSummary.preferDocument)return!0;const n=null!=e?e===this.inputSummary.textAdded:!this.inputSummary.textAdded,r=null!=i?this.inputSummary.didDelete:!this.inputSummary.didDelete,o=["\n"," \n"].includes(e)&&!n,s="\n"===i&&!r;if(o&&!s||s&&!o){const t=this.getSelectedRange();if(t){var a;const i=o?e.replace(/\n$/,"").length||-1:(null==e?void 0:e.length)||1;if(null!==(a=this.responder)&&void 0!==a&&a.positionIsBlockBreak(t[1]+i))return!0}}return n&&r}mutationIsSignificant(t){var e;const i=Object.keys(t).length>0,n=""===(null===(e=this.compositionInput)||void 0===e?void 0:e.getEndData());return i||!n}getCompositionInput(){if(this.isComposing())return this.compositionInput;this.compositionInput=new Ar(this)}isComposing(){return this.compositionInput&&!this.compositionInput.isEnded()}deleteInDirection(t,e){var i;return!1!==(null===(i=this.responder)||void 0===i?void 0:i.deleteInDirection(t))?this.setInputSummary({didDelete:!0}):e?(e.preventDefault(),this.requestRender()):void 0}serializeSelectionToDataTransfer(t){var e;if(!function(t){if(null==t||!t.setData)return!1;for(const e in Et){const i=Et[e];try{if(t.setData(e,i),!t.getData(e)===i)return!1}catch(t){return!1}}return!0}(t))return;const i=null===(e=this.responder)||void 0===e?void 0:e.getSelectedDocument().toSerializableDocument();return t.setData("application/x-trix-document",JSON.stringify(i)),t.setData("text/html",Ri.render(i).innerHTML),t.setData("text/plain",i.toString().replace(/\n$/,"")),!0}canAcceptDataTransfer(t){const e={};return Array.from((null==t?void 0:t.types)||[]).forEach((t=>{e[t]=!0})),e.Files||e["application/x-trix-document"]||e["text/html"]||e["text/plain"]}getPastedHTMLUsingHiddenElement(t){const e=this.getSelectedRange(),i={position:"absolute",left:"".concat(window.pageXOffset,"px"),top:"".concat(window.pageYOffset,"px"),opacity:0},n=w({style:i,tagName:"div",editable:!0});return document.body.appendChild(n),n.focus(),requestAnimationFrame((()=>{const i=n.innerHTML;return k(n),this.setSelectedRange(e),t(i)}))}}Ii(mr,"events",{keydown(t){this.isComposing()||this.resetInputSummary(),this.inputSummary.didInput=!0;const e=dr[t.keyCode];if(e){var i;let n=this.keys;["ctrl","alt","shift","meta"].forEach((e=>{var i;t["".concat(e,"Key")]&&("ctrl"===e&&(e="control"),n=null===(i=n)||void 0===i?void 0:i[e])})),null!=(null===(i=n)||void 0===i?void 0:i[e])&&(this.setInputSummary({keyName:e}),Pt.reset(),n[e].call(this,t))}if(kt(t)){const e=String.fromCharCode(t.keyCode).toLowerCase();if(e){var n;const i=["alt","shift"].map((e=>{if(t["".concat(e,"Key")])return e})).filter((t=>t));i.push(e),null!==(n=this.delegate)&&void 0!==n&&n.inputControllerDidReceiveKeyboardCommand(i)&&t.preventDefault()}}},keypress(t){if(null!=this.inputSummary.eventName)return;if(t.metaKey)return;if(t.ctrlKey&&!t.altKey)return;const e=br(t);var i,n;return e?(null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformTyping(),null===(n=this.responder)||void 0===n||n.insertString(e),this.setInputSummary({textAdded:e,didDelete:this.selectionIsExpanded()})):void 0},textInput(t){const{data:e}=t,{textAdded:i}=this.inputSummary;if(i&&i!==e&&i.toUpperCase()===e){var n;const t=this.getSelectedRange();return this.setSelectedRange([t[0],t[1]+i.length]),null===(n=this.responder)||void 0===n||n.insertString(e),this.setInputSummary({textAdded:e}),this.setSelectedRange(t)}},dragenter(t){t.preventDefault()},dragstart(t){var e,i;return this.serializeSelectionToDataTransfer(t.dataTransfer),this.draggedRange=this.getSelectedRange(),null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidStartDrag)||void 0===i?void 0:i.call(e)},dragover(t){if(this.draggedRange||this.canAcceptDataTransfer(t.dataTransfer)){t.preventDefault();const n={x:t.clientX,y:t.clientY};var e,i;if(!wt(n,this.draggingPoint))return this.draggingPoint=n,null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidReceiveDragOverPoint)||void 0===i?void 0:i.call(e,this.draggingPoint)}},dragend(t){var e,i;null===(e=this.delegate)||void 0===e||null===(i=e.inputControllerDidCancelDrag)||void 0===i||i.call(e),this.draggedRange=null,this.draggingPoint=null},drop(t){var e,i;t.preventDefault();const n=null===(e=t.dataTransfer)||void 0===e?void 0:e.files,r=t.dataTransfer.getData("application/x-trix-document"),o={x:t.clientX,y:t.clientY};if(null===(i=this.responder)||void 0===i||i.setLocationRangeFromPointRange(o),null!=n&&n.length)this.attachFiles(n);else if(this.draggedRange){var s,a;null===(s=this.delegate)||void 0===s||s.inputControllerWillMoveText(),null===(a=this.responder)||void 0===a||a.moveTextFromRange(this.draggedRange),this.draggedRange=null,this.requestRender()}else if(r){var l;const t=ln.fromJSONString(r);null===(l=this.responder)||void 0===l||l.insertDocument(t),this.requestRender()}this.draggedRange=null,this.draggingPoint=null},cut(t){var e,i;if(null!==(e=this.responder)&&void 0!==e&&e.selectionIsExpanded()&&(this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault(),null===(i=this.delegate)||void 0===i||i.inputControllerWillCutText(),this.deleteInDirection("backward"),t.defaultPrevented))return this.requestRender()},copy(t){var e;null!==(e=this.responder)&&void 0!==e&&e.selectionIsExpanded()&&this.serializeSelectionToDataTransfer(t.clipboardData)&&t.preventDefault()},paste(t){const e=t.clipboardData||t.testClipboardData,i={clipboard:e};if(!e||vr(t))return void this.getPastedHTMLUsingHiddenElement((t=>{var e,n,r;return i.type="text/html",i.html=t,null===(e=this.delegate)||void 0===e||e.inputControllerWillPaste(i),null===(n=this.responder)||void 0===n||n.insertHTML(i.html),this.requestRender(),null===(r=this.delegate)||void 0===r?void 0:r.inputControllerDidPaste(i)}));const n=e.getData("URL"),r=e.getData("text/html"),o=e.getData("public.url-name");if(n){var s,a,l;let t;i.type="text/html",t=o?zt(o).trim():n,i.html=this.createLinkHTML(n,t),null===(s=this.delegate)||void 0===s||s.inputControllerWillPaste(i),this.setInputSummary({textAdded:t,didDelete:this.selectionIsExpanded()}),null===(a=this.responder)||void 0===a||a.insertHTML(i.html),this.requestRender(),null===(l=this.delegate)||void 0===l||l.inputControllerDidPaste(i)}else if(St(e)){var c,u,h;i.type="text/plain",i.string=e.getData("text/plain"),null===(c=this.delegate)||void 0===c||c.inputControllerWillPaste(i),this.setInputSummary({textAdded:i.string,didDelete:this.selectionIsExpanded()}),null===(u=this.responder)||void 0===u||u.insertString(i.string),this.requestRender(),null===(h=this.delegate)||void 0===h||h.inputControllerDidPaste(i)}else if(r){var d,g,m;i.type="text/html",i.html=r,null===(d=this.delegate)||void 0===d||d.inputControllerWillPaste(i),null===(g=this.responder)||void 0===g||g.insertHTML(i.html),this.requestRender(),null===(m=this.delegate)||void 0===m||m.inputControllerDidPaste(i)}else if(Array.from(e.types).includes("Files")){var p,f;const t=null===(p=e.items)||void 0===p||null===(p=p[0])||void 0===p||null===(f=p.getAsFile)||void 0===f?void 0:f.call(p);if(t){var b,v,A;const e=pr(t);!t.name&&e&&(t.name="pasted-file-".concat(++gr,".").concat(e)),i.type="File",i.file=t,null===(b=this.delegate)||void 0===b||b.inputControllerWillAttachFiles(),null===(v=this.responder)||void 0===v||v.insertFile(i.file),this.requestRender(),null===(A=this.delegate)||void 0===A||A.inputControllerDidPaste(i)}}t.preventDefault()},compositionstart(t){return this.getCompositionInput().start(t.data)},compositionupdate(t){return this.getCompositionInput().update(t.data)},compositionend(t){return this.getCompositionInput().end(t.data)},beforeinput(t){this.inputSummary.didInput=!0},input(t){return this.inputSummary.didInput=!0,t.stopPropagation()}}),Ii(mr,"keys",{backspace(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},delete(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},return(t){var e,i;return this.setInputSummary({preferDocument:!0}),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i?void 0:i.insertLineBreak()},tab(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.canIncreaseNestingLevel()&&(null===(i=this.responder)||void 0===i||i.increaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){var e;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("backward")},right(t){var e;if(this.selectionIsInCursorTarget())return t.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("forward")},control:{d(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("forward",t)},h(t){var e;return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),this.deleteInDirection("backward",t)},o(t){var e,i;return t.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.insertString("\n",{updatePosition:!1}),this.requestRender()}},shift:{return(t){var e,i;null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.insertString("\n"),this.requestRender(),t.preventDefault()},tab(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.canDecreaseNestingLevel()&&(null===(i=this.responder)||void 0===i||i.decreaseNestingLevel(),this.requestRender(),t.preventDefault())},left(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("backward")},right(t){if(this.selectionIsInCursorTarget())return t.preventDefault(),this.expandSelectionInDirection("forward")}},alt:{backspace(t){var e;return this.setInputSummary({preferDocument:!1}),null===(e=this.delegate)||void 0===e?void 0:e.inputControllerWillPerformTyping()}},meta:{backspace(t){var e;return this.setInputSummary({preferDocument:!1}),null===(e=this.delegate)||void 0===e?void 0:e.inputControllerWillPerformTyping()}}}),mr.proxyMethod("responder?.getSelectedRange"),mr.proxyMethod("responder?.setSelectedRange"),mr.proxyMethod("responder?.expandSelectionInDirection"),mr.proxyMethod("responder?.selectionIsInCursorTarget"),mr.proxyMethod("responder?.selectionIsExpanded");const pr=t=>{var e;return null===(e=t.type)||void 0===e||null===(e=e.match(/\/(\w+)$/))||void 0===e?void 0:e[1]},fr=!(null===(ur=" ".codePointAt)||void 0===ur||!ur.call(" ",0)),br=function(t){if(t.key&&fr&&t.key.codePointAt(0)===t.keyCode)return t.key;{let e;if(null===t.which?e=t.keyCode:0!==t.which&&0!==t.charCode&&(e=t.charCode),null!=e&&"escape"!==dr[e])return Z.fromCodepoints([e]).toString()}},vr=function(t){const e=t.clipboardData;if(e){if(e.types.includes("text/html")){for(const t of e.types){const i=/^CorePasteboardFlavorType/.test(t),n=/^dyn\./.test(t)&&e.getData(t);if(i||n)return!0}return!1}{const t=e.types.includes("com.apple.webarchive"),i=e.types.includes("com.apple.flat-rtfd");return t||i}}};class Ar extends H{constructor(t){super(...arguments),this.inputController=t,this.responder=this.inputController.responder,this.delegate=this.inputController.delegate,this.inputSummary=this.inputController.inputSummary,this.data={}}start(t){if(this.data.start=t,this.isSignificant()){var e,i;"keypress"===this.inputSummary.eventName&&this.inputSummary.textAdded&&(null===(i=this.responder)||void 0===i||i.deleteInDirection("left"));this.selectionIsExpanded()||(this.insertPlaceholder(),this.requestRender()),this.range=null===(e=this.responder)||void 0===e?void 0:e.getSelectedRange()}}update(t){if(this.data.update=t,this.isSignificant()){const t=this.selectPlaceholder();t&&(this.forgetPlaceholder(),this.range=t)}}end(t){return this.data.end=t,this.isSignificant()?(this.forgetPlaceholder(),this.canApplyToDocument()?(this.setInputSummary({preferDocument:!0,didInput:!1}),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.setSelectedRange(this.range),null===(n=this.responder)||void 0===n||n.insertString(this.data.end),null===(r=this.responder)||void 0===r?void 0:r.setSelectedRange(this.range[0]+this.data.end.length)):null!=this.data.start||null!=this.data.update?(this.requestReparse(),this.inputController.reset()):void 0):this.inputController.reset();var e,i,n,r}getEndData(){return this.data.end}isEnded(){return null!=this.getEndData()}isSignificant(){return!hr.composesExistingText||this.inputSummary.didInput}canApplyToDocument(){var t,e;return 0===(null===(t=this.data.start)||void 0===t?void 0:t.length)&&(null===(e=this.data.end)||void 0===e?void 0:e.length)>0&&this.range}}Ar.proxyMethod("inputController.setInputSummary"),Ar.proxyMethod("inputController.requestRender"),Ar.proxyMethod("inputController.requestReparse"),Ar.proxyMethod("responder?.selectionIsExpanded"),Ar.proxyMethod("responder?.insertPlaceholder"),Ar.proxyMethod("responder?.selectPlaceholder"),Ar.proxyMethod("responder?.forgetPlaceholder");class yr extends cr{constructor(){super(...arguments),this.render=this.render.bind(this)}elementDidMutate(){return this.scheduledRender?this.composing?null===(t=this.delegate)||void 0===t||null===(e=t.inputControllerDidAllowUnhandledInput)||void 0===e?void 0:e.call(t):void 0:this.reparse();var t,e}scheduleRender(){return this.scheduledRender?this.scheduledRender:this.scheduledRender=requestAnimationFrame(this.render)}render(){var t,e;(cancelAnimationFrame(this.scheduledRender),this.scheduledRender=null,this.composing)||null===(e=this.delegate)||void 0===e||e.render();null===(t=this.afterRender)||void 0===t||t.call(this),this.afterRender=null}reparse(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.reparse()}insertString(){var t;let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",i=arguments.length>1?arguments[1]:void 0;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(e,i)}))}toggleAttributeIfSupported(t){var e;if(mt().includes(t))return null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var e;return null===(e=this.responder)||void 0===e?void 0:e.toggleCurrentAttribute(t)}))}activateAttributeIfSupported(t,e){var i;if(mt().includes(t))return null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformFormatting(t),this.withTargetDOMRange((function(){var i;return null===(i=this.responder)||void 0===i?void 0:i.setCurrentAttribute(t,e)}))}deleteInDirection(t){let{recordUndoEntry:e}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{recordUndoEntry:!0};var i;e&&(null===(i=this.delegate)||void 0===i||i.inputControllerWillPerformTyping());const n=()=>{var e;return null===(e=this.responder)||void 0===e?void 0:e.deleteInDirection(t)},r=this.getTargetDOMRange({minLength:this.composing?1:2});return r?this.withTargetDOMRange(r,n):n()}withTargetDOMRange(t,e){var i;return"function"==typeof t&&(e=t,t=this.getTargetDOMRange()),t?null===(i=this.responder)||void 0===i?void 0:i.withTargetDOMRange(t,e.bind(this)):(Pt.reset(),e.call(this))}getTargetDOMRange(){var t,e;let{minLength:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{minLength:0};const n=null===(t=(e=this.event).getTargetRanges)||void 0===t?void 0:t.call(e);if(n&&n.length){const t=xr(n[0]);if(0===i||t.toString().length>=i)return t}}withEvent(t,e){let i;this.event=t;try{i=e.call(this)}finally{this.event=null}return i}}Ii(yr,"events",{keydown(t){if(kt(t)){var e;const i=Rr(t);null!==(e=this.delegate)&&void 0!==e&&e.inputControllerDidReceiveKeyboardCommand(i)&&t.preventDefault()}else{let e=t.key;t.altKey&&(e+="+Alt"),t.shiftKey&&(e+="+Shift");const i=this.constructor.keys[e];if(i)return this.withEvent(t,i)}},paste(t){var e;let i;const n=null===(e=t.clipboardData)||void 0===e?void 0:e.getData("URL");return Sr(t)?(t.preventDefault(),this.attachFiles(t.clipboardData.files)):kr(t)?(t.preventDefault(),i={type:"text/plain",string:t.clipboardData.getData("text/plain")},null===(r=this.delegate)||void 0===r||r.inputControllerWillPaste(i),null===(o=this.responder)||void 0===o||o.insertString(i.string),this.render(),null===(s=this.delegate)||void 0===s?void 0:s.inputControllerDidPaste(i)):n?(t.preventDefault(),i={type:"text/html",html:this.createLinkHTML(n)},null===(a=this.delegate)||void 0===a||a.inputControllerWillPaste(i),null===(l=this.responder)||void 0===l||l.insertHTML(i.html),this.render(),null===(c=this.delegate)||void 0===c?void 0:c.inputControllerDidPaste(i)):void 0;var r,o,s,a,l,c},beforeinput(t){const e=this.constructor.inputTypes[t.inputType],i=(n=t,!(!/iPhone|iPad/.test(navigator.userAgent)||n.inputType&&"insertParagraph"!==n.inputType));var n;e&&(this.withEvent(t,e),i||this.scheduleRender()),i&&this.render()},input(t){Pt.reset()},dragstart(t){var e,i;null!==(e=this.responder)&&void 0!==e&&e.selectionContainsAttachments()&&(t.dataTransfer.setData("application/x-trix-dragging",!0),this.dragging={range:null===(i=this.responder)||void 0===i?void 0:i.getSelectedRange(),point:Tr(t)})},dragenter(t){Cr(t)&&t.preventDefault()},dragover(t){if(this.dragging){t.preventDefault();const i=Tr(t);var e;if(!wt(i,this.dragging.point))return this.dragging.point=i,null===(e=this.responder)||void 0===e?void 0:e.setLocationRangeFromPointRange(i)}else Cr(t)&&t.preventDefault()},drop(t){var e,i;if(this.dragging)return t.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillMoveText(),null===(i=this.responder)||void 0===i||i.moveTextFromRange(this.dragging.range),this.dragging=null,this.scheduleRender();if(Cr(t)){var n;t.preventDefault();const e=Tr(t);return null===(n=this.responder)||void 0===n||n.setLocationRangeFromPointRange(e),this.attachFiles(t.dataTransfer.files)}},dragend(){var t;this.dragging&&(null===(t=this.responder)||void 0===t||t.setSelectedRange(this.dragging.range),this.dragging=null)},compositionend(t){this.composing&&(this.composing=!1,a.recentAndroid||this.scheduleRender())}}),Ii(yr,"keys",{ArrowLeft(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("backward"))return this.event.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("backward")},ArrowRight(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageMovingCursorInDirection("forward"))return this.event.preventDefault(),null===(e=this.responder)||void 0===e?void 0:e.moveCursorInDirection("forward")},Backspace(){var t,e,i;if(null!==(t=this.responder)&&void 0!==t&&t.shouldManageDeletingInDirection("backward"))return this.event.preventDefault(),null===(e=this.delegate)||void 0===e||e.inputControllerWillPerformTyping(),null===(i=this.responder)||void 0===i||i.deleteInDirection("backward"),this.render()},Tab(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.event.preventDefault(),null===(e=this.responder)||void 0===e||e.increaseNestingLevel(),this.render()},"Tab+Shift"(){var t,e;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.event.preventDefault(),null===(e=this.responder)||void 0===e||e.decreaseNestingLevel(),this.render()}}),Ii(yr,"inputTypes",{deleteByComposition(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteByCut(){return this.deleteInDirection("backward")},deleteByDrag(){return this.event.preventDefault(),this.withTargetDOMRange((function(){var t;this.deleteByDragRange=null===(t=this.responder)||void 0===t?void 0:t.getSelectedRange()}))},deleteCompositionText(){return this.deleteInDirection("backward",{recordUndoEntry:!1})},deleteContent(){return this.deleteInDirection("backward")},deleteContentBackward(){return this.deleteInDirection("backward")},deleteContentForward(){return this.deleteInDirection("forward")},deleteEntireSoftLine(){return this.deleteInDirection("forward")},deleteHardLineBackward(){return this.deleteInDirection("backward")},deleteHardLineForward(){return this.deleteInDirection("forward")},deleteSoftLineBackward(){return this.deleteInDirection("backward")},deleteSoftLineForward(){return this.deleteInDirection("forward")},deleteWordBackward(){return this.deleteInDirection("backward")},deleteWordForward(){return this.deleteInDirection("forward")},formatBackColor(){return this.activateAttributeIfSupported("backgroundColor",this.event.data)},formatBold(){return this.toggleAttributeIfSupported("bold")},formatFontColor(){return this.activateAttributeIfSupported("color",this.event.data)},formatFontName(){return this.activateAttributeIfSupported("font",this.event.data)},formatIndent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canIncreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.increaseNestingLevel()}))},formatItalic(){return this.toggleAttributeIfSupported("italic")},formatJustifyCenter(){return this.toggleAttributeIfSupported("justifyCenter")},formatJustifyFull(){return this.toggleAttributeIfSupported("justifyFull")},formatJustifyLeft(){return this.toggleAttributeIfSupported("justifyLeft")},formatJustifyRight(){return this.toggleAttributeIfSupported("justifyRight")},formatOutdent(){var t;if(null!==(t=this.responder)&&void 0!==t&&t.canDecreaseNestingLevel())return this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.decreaseNestingLevel()}))},formatRemove(){this.withTargetDOMRange((function(){for(const i in null===(t=this.responder)||void 0===t?void 0:t.getCurrentAttributes()){var t,e;null===(e=this.responder)||void 0===e||e.removeCurrentAttribute(i)}}))},formatSetBlockTextDirection(){return this.activateAttributeIfSupported("blockDir",this.event.data)},formatSetInlineTextDirection(){return this.activateAttributeIfSupported("textDir",this.event.data)},formatStrikeThrough(){return this.toggleAttributeIfSupported("strike")},formatSubscript(){return this.toggleAttributeIfSupported("sub")},formatSuperscript(){return this.toggleAttributeIfSupported("sup")},formatUnderline(){return this.toggleAttributeIfSupported("underline")},historyRedo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformRedo()},historyUndo(){var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerWillPerformUndo()},insertCompositionText(){return this.composing=!0,this.insertString(this.event.data)},insertFromComposition(){return this.composing=!1,this.insertString(this.event.data)},insertFromDrop(){const t=this.deleteByDragRange;var e;if(t)return this.deleteByDragRange=null,null===(e=this.delegate)||void 0===e||e.inputControllerWillMoveText(),this.withTargetDOMRange((function(){var e;return null===(e=this.responder)||void 0===e?void 0:e.moveTextFromRange(t)}))},insertFromPaste(){const{dataTransfer:t}=this.event,e={dataTransfer:t},i=t.getData("URL"),n=t.getData("text/html");if(i){var r;let n;this.event.preventDefault(),e.type="text/html";const o=t.getData("public.url-name");n=o?zt(o).trim():i,e.html=this.createLinkHTML(i,n),null===(r=this.delegate)||void 0===r||r.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(e.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(St(t)){var o;e.type="text/plain",e.string=t.getData("text/plain"),null===(o=this.delegate)||void 0===o||o.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertString(e.string)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(Er(this.event)){var s;e.type="File",e.file=t.files[0],null===(s=this.delegate)||void 0===s||s.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertFile(e.file)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}else if(n){var a;this.event.preventDefault(),e.type="text/html",e.html=n,null===(a=this.delegate)||void 0===a||a.inputControllerWillPaste(e),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertHTML(e.html)})),this.afterRender=()=>{var t;return null===(t=this.delegate)||void 0===t?void 0:t.inputControllerDidPaste(e)}}},insertFromYank(){return this.insertString(this.event.data)},insertLineBreak(){return this.insertString("\n")},insertLink(){return this.activateAttributeIfSupported("href",this.event.data)},insertOrderedList(){return this.toggleAttributeIfSupported("number")},insertParagraph(){var t;return null===(t=this.delegate)||void 0===t||t.inputControllerWillPerformTyping(),this.withTargetDOMRange((function(){var t;return null===(t=this.responder)||void 0===t?void 0:t.insertLineBreak()}))},insertReplacementText(){const t=this.event.dataTransfer.getData("text/plain"),e=this.event.getTargetRanges()[0];this.withTargetDOMRange(e,(()=>{this.insertString(t,{updatePosition:!1})}))},insertText(){var t;return this.insertString(this.event.data||(null===(t=this.event.dataTransfer)||void 0===t?void 0:t.getData("text/plain")))},insertTranspose(){return this.insertString(this.event.data)},insertUnorderedList(){return this.toggleAttributeIfSupported("bullet")}});const xr=function(t){const e=document.createRange();return e.setStart(t.startContainer,t.startOffset),e.setEnd(t.endContainer,t.endOffset),e},Cr=t=>{var e;return Array.from((null===(e=t.dataTransfer)||void 0===e?void 0:e.types)||[]).includes("Files")},Er=t=>{var e;return(null===(e=t.dataTransfer.files)||void 0===e?void 0:e[0])&&!Sr(t)&&!(t=>{let{dataTransfer:e}=t;return e.types.includes("Files")&&e.types.includes("text/html")&&e.getData("text/html").includes("urn:schemas-microsoft-com:office:office")})(t)},Sr=function(t){const e=t.clipboardData;if(e)return Array.from(e.types).filter((t=>t.match(/file/i))).length===e.types.length&&e.files.length>=1},kr=function(t){const e=t.clipboardData;if(e)return e.types.includes("text/plain")&&1===e.types.length},Rr=function(t){const e=[];return t.altKey&&e.push("alt"),t.shiftKey&&e.push("shift"),e.push(t.key),e},Tr=t=>({x:t.clientX,y:t.clientY}),wr="[data-trix-attribute]",Lr="[data-trix-action]",Dr="".concat(wr,", ").concat(Lr),Nr="[data-trix-dialog]",Ir="".concat(Nr,"[data-trix-active]"),Or="".concat(Nr," [data-trix-method]"),Fr="".concat(Nr," [data-trix-input]"),Pr=(t,e)=>(e||(e=Br(t)),t.querySelector("[data-trix-input][name='".concat(e,"']"))),Mr=t=>t.getAttribute("data-trix-action"),Br=t=>t.getAttribute("data-trix-attribute")||t.getAttribute("data-trix-dialog-attribute");class _r extends H{constructor(t){super(t),this.didClickActionButton=this.didClickActionButton.bind(this),this.didClickAttributeButton=this.didClickAttributeButton.bind(this),this.didClickDialogButton=this.didClickDialogButton.bind(this),this.didKeyDownDialogInput=this.didKeyDownDialogInput.bind(this),this.element=t,this.attributes={},this.actions={},this.resetDialogInputs(),b("mousedown",{onElement:this.element,matchingSelector:Lr,withCallback:this.didClickActionButton}),b("mousedown",{onElement:this.element,matchingSelector:wr,withCallback:this.didClickAttributeButton}),b("click",{onElement:this.element,matchingSelector:Dr,preventDefault:!0}),b("click",{onElement:this.element,matchingSelector:Or,withCallback:this.didClickDialogButton}),b("keydown",{onElement:this.element,matchingSelector:Fr,withCallback:this.didKeyDownDialogInput})}didClickActionButton(t,e){var i;null===(i=this.delegate)||void 0===i||i.toolbarDidClickButton(),t.preventDefault();const n=Mr(e);return this.getDialog(n)?this.toggleDialog(n):null===(r=this.delegate)||void 0===r?void 0:r.toolbarDidInvokeAction(n,e);var r}didClickAttributeButton(t,e){var i;null===(i=this.delegate)||void 0===i||i.toolbarDidClickButton(),t.preventDefault();const n=Br(e);var r;this.getDialog(n)?this.toggleDialog(n):null===(r=this.delegate)||void 0===r||r.toolbarDidToggleAttribute(n);return this.refreshAttributeButtons()}didClickDialogButton(t,e){const i=x(e,{matchingSelector:Nr});return this[e.getAttribute("data-trix-method")].call(this,i)}didKeyDownDialogInput(t,e){if(13===t.keyCode){t.preventDefault();const i=e.getAttribute("name"),n=this.getDialog(i);this.setAttribute(n)}if(27===t.keyCode)return t.preventDefault(),this.hideDialog()}updateActions(t){return this.actions=t,this.refreshActionButtons()}refreshActionButtons(){return this.eachActionButton(((t,e)=>{t.disabled=!1===this.actions[e]}))}eachActionButton(t){return Array.from(this.element.querySelectorAll(Lr)).map((e=>t(e,Mr(e))))}updateAttributes(t){return this.attributes=t,this.refreshAttributeButtons()}refreshAttributeButtons(){return this.eachAttributeButton(((t,e)=>(t.disabled=!1===this.attributes[e],this.attributes[e]||this.dialogIsVisible(e)?(t.setAttribute("data-trix-active",""),t.classList.add("trix-active")):(t.removeAttribute("data-trix-active"),t.classList.remove("trix-active")))))}eachAttributeButton(t){return Array.from(this.element.querySelectorAll(wr)).map((e=>t(e,Br(e))))}applyKeyboardCommand(t){const e=JSON.stringify(t.sort());for(const t of Array.from(this.element.querySelectorAll("[data-trix-key]"))){const i=t.getAttribute("data-trix-key").split("+");if(JSON.stringify(i.sort())===e)return A("mousedown",{onElement:t}),!0}return!1}dialogIsVisible(t){const e=this.getDialog(t);if(e)return e.hasAttribute("data-trix-active")}toggleDialog(t){return this.dialogIsVisible(t)?this.hideDialog():this.showDialog(t)}showDialog(t){var e,i;this.hideDialog(),null===(e=this.delegate)||void 0===e||e.toolbarWillShowDialog();const n=this.getDialog(t);n.setAttribute("data-trix-active",""),n.classList.add("trix-active"),Array.from(n.querySelectorAll("input[disabled]")).forEach((t=>{t.removeAttribute("disabled")}));const r=Br(n);if(r){const e=Pr(n,t);e&&(e.value=this.attributes[r]||"",e.select())}return null===(i=this.delegate)||void 0===i?void 0:i.toolbarDidShowDialog(t)}setAttribute(t){var e;const i=Br(t),n=Pr(t,i);return!n.willValidate||(n.setCustomValidity(""),n.checkValidity()&&this.isSafeAttribute(n))?(null===(e=this.delegate)||void 0===e||e.toolbarDidUpdateAttribute(i,n.value),this.hideDialog()):(n.setCustomValidity("Invalid value"),n.setAttribute("data-trix-validate",""),n.classList.add("trix-validate"),n.focus())}isSafeAttribute(t){return!t.hasAttribute("data-trix-validate-href")||ci.isValidAttribute("a","href",t.value)}removeAttribute(t){var e;const i=Br(t);return null===(e=this.delegate)||void 0===e||e.toolbarDidRemoveAttribute(i),this.hideDialog()}hideDialog(){const t=this.element.querySelector(Ir);var e;if(t)return t.removeAttribute("data-trix-active"),t.classList.remove("trix-active"),this.resetDialogInputs(),null===(e=this.delegate)||void 0===e?void 0:e.toolbarDidHideDialog((t=>t.getAttribute("data-trix-dialog"))(t))}resetDialogInputs(){Array.from(this.element.querySelectorAll(Fr)).forEach((t=>{t.setAttribute("disabled","disabled"),t.removeAttribute("data-trix-validate"),t.classList.remove("trix-validate")}))}getDialog(t){return this.element.querySelector("[data-trix-dialog=".concat(t,"]"))}}class jr extends Zn{constructor(t){let{editorElement:e,document:i,html:n}=t;super(...arguments),this.editorElement=e,this.selectionManager=new zn(this.editorElement),this.selectionManager.delegate=this,this.composition=new Ln,this.composition.delegate=this,this.attachmentManager=new Tn(this.composition.getAttachments()),this.attachmentManager.delegate=this,this.inputController=2===j.getLevel()?new yr(this.editorElement):new mr(this.editorElement),this.inputController.delegate=this,this.inputController.responder=this.composition,this.compositionController=new $n(this.editorElement,this.composition),this.compositionController.delegate=this,this.toolbarController=new _r(this.editorElement.toolbarElement),this.toolbarController.delegate=this,this.editor=new Mn(this.composition,this.selectionManager,this.editorElement),i?this.editor.loadDocument(i):this.editor.loadHTML(n)}registerSelectionManager(){return Pt.registerSelectionManager(this.selectionManager)}unregisterSelectionManager(){return Pt.unregisterSelectionManager(this.selectionManager)}render(){return this.compositionController.render()}reparse(){return this.composition.replaceHTML(this.editorElement.innerHTML)}compositionDidChangeDocument(t){if(this.notifyEditorElement("document-change"),!this.handlingInput)return this.render()}compositionDidChangeCurrentAttributes(t){return this.currentAttributes=t,this.toolbarController.updateAttributes(this.currentAttributes),this.updateCurrentActions(),this.notifyEditorElement("attributes-change",{attributes:this.currentAttributes})}compositionDidPerformInsertionAtRange(t){this.pasting&&(this.pastedRange=t)}compositionShouldAcceptFile(t){return this.notifyEditorElement("file-accept",{file:t})}compositionDidAddAttachment(t){const e=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-add",{attachment:e})}compositionDidEditAttachment(t){this.compositionController.rerenderViewForObject(t);const e=this.attachmentManager.manageAttachment(t);return this.notifyEditorElement("attachment-edit",{attachment:e}),this.notifyEditorElement("change")}compositionDidChangeAttachmentPreviewURL(t){return this.compositionController.invalidateViewForObject(t),this.notifyEditorElement("change")}compositionDidRemoveAttachment(t){const e=this.attachmentManager.unmanageAttachment(t);return this.notifyEditorElement("attachment-remove",{attachment:e})}compositionDidStartEditingAttachment(t,e){return this.attachmentLocationRange=this.composition.document.getLocationRangeOfAttachment(t),this.compositionController.installAttachmentEditorForAttachment(t,e),this.selectionManager.setLocationRange(this.attachmentLocationRange)}compositionDidStopEditingAttachment(t){this.compositionController.uninstallAttachmentEditor(),this.attachmentLocationRange=null}compositionDidRequestChangingSelectionToLocationRange(t){if(!this.loadingSnapshot||this.isFocused())return this.requestedLocationRange=t,this.compositionRevisionWhenLocationRangeRequested=this.composition.revision,this.handlingInput?void 0:this.render()}compositionWillLoadSnapshot(){this.loadingSnapshot=!0}compositionDidLoadSnapshot(){this.compositionController.refreshViewCache(),this.render(),this.loadingSnapshot=!1}getSelectionManager(){return this.selectionManager}attachmentManagerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}compositionControllerWillSyncDocumentView(){return this.inputController.editorWillSyncDocumentView(),this.selectionManager.lock(),this.selectionManager.clearSelection()}compositionControllerDidSyncDocumentView(){return this.inputController.editorDidSyncDocumentView(),this.selectionManager.unlock(),this.updateCurrentActions(),this.notifyEditorElement("sync")}compositionControllerDidRender(){this.requestedLocationRange&&(this.compositionRevisionWhenLocationRangeRequested===this.composition.revision&&this.selectionManager.setLocationRange(this.requestedLocationRange),this.requestedLocationRange=null,this.compositionRevisionWhenLocationRangeRequested=null),this.renderedCompositionRevision!==this.composition.revision&&(this.runEditorFilters(),this.composition.updateCurrentAttributes(),this.notifyEditorElement("render")),this.renderedCompositionRevision=this.composition.revision}compositionControllerDidFocus(){return this.isFocusedInvisibly()&&this.setLocationRange({index:0,offset:0}),this.toolbarController.hideDialog(),this.notifyEditorElement("focus")}compositionControllerDidBlur(){return this.notifyEditorElement("blur")}compositionControllerDidSelectAttachment(t,e){return this.toolbarController.hideDialog(),this.composition.editAttachment(t,e)}compositionControllerDidRequestDeselectingAttachment(t){const e=this.attachmentLocationRange||this.composition.document.getLocationRangeOfAttachment(t);return this.selectionManager.setLocationRange(e[1])}compositionControllerWillUpdateAttachment(t){return this.editor.recordUndoEntry("Edit Attachment",{context:t.id,consolidatable:!0})}compositionControllerDidRequestRemovalOfAttachment(t){return this.removeAttachment(t)}inputControllerWillHandleInput(){this.handlingInput=!0,this.requestedRender=!1}inputControllerDidRequestRender(){this.requestedRender=!0}inputControllerDidHandleInput(){if(this.handlingInput=!1,this.requestedRender)return this.requestedRender=!1,this.render()}inputControllerDidAllowUnhandledInput(){return this.notifyEditorElement("change")}inputControllerDidRequestReparse(){return this.reparse()}inputControllerWillPerformTyping(){return this.recordTypingUndoEntry()}inputControllerWillPerformFormatting(t){return this.recordFormattingUndoEntry(t)}inputControllerWillCutText(){return this.editor.recordUndoEntry("Cut")}inputControllerWillPaste(t){return this.editor.recordUndoEntry("Paste"),this.pasting=!0,this.notifyEditorElement("before-paste",{paste:t})}inputControllerDidPaste(t){return t.range=this.pastedRange,this.pastedRange=null,this.pasting=null,this.notifyEditorElement("paste",{paste:t})}inputControllerWillMoveText(){return this.editor.recordUndoEntry("Move")}inputControllerWillAttachFiles(){return this.editor.recordUndoEntry("Drop Files")}inputControllerWillPerformUndo(){return this.editor.undo()}inputControllerWillPerformRedo(){return this.editor.redo()}inputControllerDidReceiveKeyboardCommand(t){return this.toolbarController.applyKeyboardCommand(t)}inputControllerDidStartDrag(){this.locationRangeBeforeDrag=this.selectionManager.getLocationRange()}inputControllerDidReceiveDragOverPoint(t){return this.selectionManager.setLocationRangeFromPointRange(t)}inputControllerDidCancelDrag(){this.selectionManager.setLocationRange(this.locationRangeBeforeDrag),this.locationRangeBeforeDrag=null}locationRangeDidChange(t){return this.composition.updateCurrentAttributes(),this.updateCurrentActions(),this.attachmentLocationRange&&!Nt(this.attachmentLocationRange,t)&&this.composition.stopEditingAttachment(),this.notifyEditorElement("selection-change")}toolbarDidClickButton(){if(!this.getLocationRange())return this.setLocationRange({index:0,offset:0})}toolbarDidInvokeAction(t,e){return this.invokeAction(t,e)}toolbarDidToggleAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.toggleCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidUpdateAttribute(t,e){if(this.recordFormattingUndoEntry(t),this.composition.setCurrentAttribute(t,e),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarDidRemoveAttribute(t){if(this.recordFormattingUndoEntry(t),this.composition.removeCurrentAttribute(t),this.render(),!this.selectionFrozen)return this.editorElement.focus()}toolbarWillShowDialog(t){return this.composition.expandSelectionForEditing(),this.freezeSelection()}toolbarDidShowDialog(t){return this.notifyEditorElement("toolbar-dialog-show",{dialogName:t})}toolbarDidHideDialog(t){return this.thawSelection(),this.editorElement.focus(),this.notifyEditorElement("toolbar-dialog-hide",{dialogName:t})}freezeSelection(){if(!this.selectionFrozen)return this.selectionManager.lock(),this.composition.freezeSelection(),this.selectionFrozen=!0,this.render()}thawSelection(){if(this.selectionFrozen)return this.composition.thawSelection(),this.selectionManager.unlock(),this.selectionFrozen=!1,this.render()}canInvokeAction(t){return!!this.actionIsExternal(t)||!(null===(e=this.actions[t])||void 0===e||null===(e=e.test)||void 0===e||!e.call(this));var e}invokeAction(t,e){return this.actionIsExternal(t)?this.notifyEditorElement("action-invoke",{actionName:t,invokingElement:e}):null===(i=this.actions[t])||void 0===i||null===(i=i.perform)||void 0===i?void 0:i.call(this);var i}actionIsExternal(t){return/^x-./.test(t)}getCurrentActions(){const t={};for(const e in this.actions)t[e]=this.canInvokeAction(e);return t}updateCurrentActions(){const t=this.getCurrentActions();if(!wt(t,this.currentActions))return this.currentActions=t,this.toolbarController.updateActions(this.currentActions),this.notifyEditorElement("actions-change",{actions:this.currentActions})}runEditorFilters(){let t=this.composition.getSnapshot();if(Array.from(this.editor.filters).forEach((e=>{const{document:i,selectedRange:n}=t;t=e.call(this.editor,t)||{},t.document||(t.document=i),t.selectedRange||(t.selectedRange=n)})),e=t,i=this.composition.getSnapshot(),!Nt(e.selectedRange,i.selectedRange)||!e.document.isEqualTo(i.document))return this.composition.loadSnapshot(t);var e,i}updateInputElement(){const t=function(t,e){const i=Sn[e];if(i)return i(t);throw new Error("unknown content type: ".concat(e))}(this.compositionController.getSerializableElement(),"text/html");return this.editorElement.setFormValue(t)}notifyEditorElement(t,e){switch(t){case"document-change":this.documentChangedSinceLastRender=!0;break;case"render":this.documentChangedSinceLastRender&&(this.documentChangedSinceLastRender=!1,this.notifyEditorElement("change"));break;case"change":case"attachment-add":case"attachment-edit":case"attachment-remove":this.updateInputElement()}return this.editorElement.notify(t,e)}removeAttachment(t){return this.editor.recordUndoEntry("Delete Attachment"),this.composition.removeAttachment(t),this.render()}recordFormattingUndoEntry(t){const e=pt(t),i=this.selectionManager.getLocationRange();if(e||!Dt(i))return this.editor.recordUndoEntry("Formatting",{context:this.getUndoContext(),consolidatable:!0})}recordTypingUndoEntry(){return this.editor.recordUndoEntry("Typing",{context:this.getUndoContext(this.currentAttributes),consolidatable:!0})}getUndoContext(){for(var t=arguments.length,e=new Array(t),i=0;i0?Math.floor((new Date).getTime()/V.interval):0}isFocused(){var t;return this.editorElement===(null===(t=this.editorElement.ownerDocument)||void 0===t?void 0:t.activeElement)}isFocusedInvisibly(){return this.isFocused()&&!this.getLocationRange()}get actions(){return this.constructor.actions}}Ii(jr,"actions",{undo:{test(){return this.editor.canUndo()},perform(){return this.editor.undo()}},redo:{test(){return this.editor.canRedo()},perform(){return this.editor.redo()}},link:{test(){return this.editor.canActivateAttribute("href")}},increaseNestingLevel:{test(){return this.editor.canIncreaseNestingLevel()},perform(){return this.editor.increaseNestingLevel()&&this.render()}},decreaseNestingLevel:{test(){return this.editor.canDecreaseNestingLevel()},perform(){return this.editor.decreaseNestingLevel()&&this.render()}},attachFiles:{test:()=>!0,perform(){return j.pickFiles(this.editor.insertFiles)}}}),jr.proxyMethod("getSelectionManager().setLocationRange"),jr.proxyMethod("getSelectionManager().getLocationRange");var Wr=Object.freeze({__proto__:null,AttachmentEditorController:Xn,CompositionController:$n,Controller:Zn,EditorController:jr,InputController:cr,Level0InputController:mr,Level2InputController:yr,ToolbarController:_r}),Ur=Object.freeze({__proto__:null,MutationObserver:ir,SelectionChangeObserver:Ft}),Hr=Object.freeze({__proto__:null,FileVerificationOperation:rr,ImagePreloadOperation:Vi});At("trix-toolbar","%t {\n display: block;\n}\n\n%t {\n white-space: nowrap;\n}\n\n%t [data-trix-dialog] {\n display: none;\n}\n\n%t [data-trix-dialog][data-trix-active] {\n display: block;\n}\n\n%t [data-trix-dialog] [data-trix-validate]:invalid {\n background-color: #ffdddd;\n}");class zr extends HTMLElement{connectedCallback(){""===this.innerHTML&&(this.innerHTML=z.getDefaultHTML())}get editorElements(){if(this.id){var t;const e=null===(t=this.ownerDocument)||void 0===t?void 0:t.querySelectorAll('trix-editor[toolbar="'.concat(this.id,'"]'));return Array.from(e)}return[]}get editorElement(){const[t]=this.editorElements;return t}}let Vr=0;const qr=function(t){if(!t.hasAttribute("contenteditable"))return t.toggleAttribute("contenteditable",!t.disabled),function(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return e.times=1,b(t,e)}("focus",{onElement:t,withCallback:()=>Jr(t)})},Jr=function(t){return Kr(t),Gr(t)},Kr=function(t){var e,i;if(null!==(e=(i=document).queryCommandSupported)&&void 0!==e&&e.call(i,"enableObjectResizing"))return document.execCommand("enableObjectResizing",!1,!1),b("mscontrolselect",{onElement:t,preventDefault:!0})},Gr=function(t){var e,i;if(null!==(e=(i=document).queryCommandSupported)&&void 0!==e&&e.call(i,"DefaultParagraphSeparator")){const{tagName:t}=n.default;if(["div","p"].includes(t))return document.execCommand("DefaultParagraphSeparator",!1,t)}},Xr=a.forcesObjectResizing?{display:"inline",width:"auto"}:{display:"inline-block",width:"1px"};At("trix-editor","%t {\n display: block;\n}\n\n%t:empty::before {\n content: attr(placeholder);\n color: graytext;\n cursor: text;\n pointer-events: none;\n white-space: pre-line;\n}\n\n%t a[contenteditable=false] {\n cursor: text;\n}\n\n%t img {\n max-width: 100%;\n height: auto;\n}\n\n%t ".concat(e," figcaption textarea {\n resize: none;\n}\n\n%t ").concat(e," figcaption textarea.trix-autoresize-clone {\n position: absolute;\n left: -9999px;\n max-height: 0px;\n}\n\n%t ").concat(e," figcaption[data-trix-placeholder]:empty::before {\n content: attr(data-trix-placeholder);\n color: graytext;\n}\n\n%t [data-trix-cursor-target] {\n display: ").concat(Xr.display," !important;\n width: ").concat(Xr.width," !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n}\n\n%t [data-trix-cursor-target=left] {\n vertical-align: top !important;\n margin-left: -1px !important;\n}\n\n%t [data-trix-cursor-target=right] {\n vertical-align: bottom !important;\n margin-right: -1px !important;\n}"));var $r=new WeakMap,Yr=new WeakMap,Zr=new WeakSet;class Qr{constructor(t){var e,i;ji(e=this,i=Zr),i.add(e),Ii(this,"value",""),Wi(this,$r,{writable:!0,value:void 0}),Wi(this,Yr,{writable:!0,value:void 0}),this.element=t,Fi(this,$r,t.attachInternals()),Fi(this,Yr,!1)}connectedCallback(){_i(this,Zr,to).call(this)}disconnectedCallback(){}get form(){return Oi(this,$r).form}get name(){return this.element.getAttribute("name")}set name(t){this.element.setAttribute("name",t)}get labels(){return Oi(this,$r).labels}get disabled(){return Oi(this,Yr)||this.element.hasAttribute("disabled")}set disabled(t){this.element.toggleAttribute("disabled",t)}get required(){return this.element.hasAttribute("required")}set required(t){this.element.toggleAttribute("required",t),_i(this,Zr,to).call(this)}get validity(){return Oi(this,$r).validity}get validationMessage(){return Oi(this,$r).validationMessage}get willValidate(){return Oi(this,$r).willValidate}formDisabledCallback(t){Fi(this,Yr,t)}setFormValue(t){this.value=t,_i(this,Zr,to).call(this),Oi(this,$r).setFormValue(this.element.disabled?void 0:this.value)}checkValidity(){return Oi(this,$r).checkValidity()}reportValidity(){return Oi(this,$r).reportValidity()}setCustomValidity(t){_i(this,Zr,to).call(this,t)}}function to(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";const{required:e,value:i}=this.element,n=e&&!i,r=!!t,o=w("input",{required:e}),s=t||o.validationMessage;Oi(this,$r).setValidity({valueMissing:n,customError:r},s)}var eo=new WeakMap,io=new WeakMap,no=new WeakMap;class ro{constructor(t){Wi(this,eo,{writable:!0,value:void 0}),Wi(this,io,{writable:!0,value:t=>{t.defaultPrevented||t.target===this.element.form&&this.element.reset()}}),Wi(this,no,{writable:!0,value:t=>{if(t.defaultPrevented)return;if(this.element.contains(t.target))return;const e=x(t.target,{matchingSelector:"label"});e&&Array.from(this.labels).includes(e)&&this.element.focus()}}),this.element=t}connectedCallback(){Fi(this,eo,function(t){if(t.hasAttribute("aria-label")||t.hasAttribute("aria-labelledby"))return;const e=function(){const e=Array.from(t.labels).map((e=>{if(!e.contains(t))return e.textContent})).filter((t=>t)),i=e.join(" ");return i?t.setAttribute("aria-label",i):t.removeAttribute("aria-label")};return e(),b("focus",{onElement:t,withCallback:e})}(this.element)),window.addEventListener("reset",Oi(this,io),!1),window.addEventListener("click",Oi(this,no),!1)}disconnectedCallback(){var t;null===(t=Oi(this,eo))||void 0===t||t.destroy(),window.removeEventListener("reset",Oi(this,io),!1),window.removeEventListener("click",Oi(this,no),!1)}get labels(){const t=[];this.element.id&&this.element.ownerDocument&&t.push(...Array.from(this.element.ownerDocument.querySelectorAll("label[for='".concat(this.element.id,"']"))||[]));const e=x(this.element,{matchingSelector:"label"});return e&&[this.element,null].includes(e.control)&&t.push(e),t}get form(){return console.warn("This browser does not support the .form property for trix-editor elements."),null}get name(){return console.warn("This browser does not support the .name property for trix-editor elements."),null}set name(t){console.warn("This browser does not support the .name property for trix-editor elements.")}get disabled(){return console.warn("This browser does not support the [disabled] attribute for trix-editor elements."),!1}set disabled(t){console.warn("This browser does not support the [disabled] attribute for trix-editor elements.")}get required(){return console.warn("This browser does not support the [required] attribute for trix-editor elements."),!1}set required(t){console.warn("This browser does not support the [required] attribute for trix-editor elements.")}get validity(){return console.warn("This browser does not support the validity property for trix-editor elements."),null}get validationMessage(){return console.warn("This browser does not support the validationMessage property for trix-editor elements."),""}get willValidate(){return console.warn("This browser does not support the willValidate property for trix-editor elements."),!1}formDisabledCallback(t){}setFormValue(t){}checkValidity(){return console.warn("This browser does not support checkValidity() for trix-editor elements."),!0}reportValidity(){return console.warn("This browser does not support reportValidity() for trix-editor elements."),!0}setCustomValidity(t){console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements.")}}var oo=new WeakMap;class so extends HTMLElement{constructor(){super(),Wi(this,oo,{writable:!0,value:void 0}),this.willCreateInput=!0,Fi(this,oo,this.constructor.formAssociated?new Qr(this):new ro(this))}get trixId(){return this.hasAttribute("trix-id")?this.getAttribute("trix-id"):(this.setAttribute("trix-id",++Vr),this.trixId)}get labels(){return Oi(this,oo).labels}get disabled(){const{inputElement:t}=this;return t?t.disabled:Oi(this,oo).disabled}set disabled(t){const{inputElement:e}=this;e&&(e.disabled=t),Oi(this,oo).disabled=t}get required(){return Oi(this,oo).required}set required(t){Oi(this,oo).required=t}get validity(){return Oi(this,oo).validity}get validationMessage(){return Oi(this,oo).validationMessage}get willValidate(){return Oi(this,oo).willValidate}get type(){return this.localName}get toolbarElement(){var t;if(this.hasAttribute("toolbar"))return null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("toolbar"));if(this.parentNode){const t="trix-toolbar-".concat(this.trixId);return this.setAttribute("toolbar",t),this.internalToolbar=w("trix-toolbar",{id:t}),this.parentNode.insertBefore(this.internalToolbar,this),this.internalToolbar}}get form(){const{inputElement:t}=this;return t?t.form:Oi(this,oo).form}get inputElement(){var t;return this.hasAttribute("input")?null===(t=this.ownerDocument)||void 0===t?void 0:t.getElementById(this.getAttribute("input")):void 0}get editor(){var t;return null===(t=this.editorController)||void 0===t?void 0:t.editor}get name(){const{inputElement:t}=this;return t?t.name:Oi(this,oo).name}set name(t){const{inputElement:e}=this;e?e.name=t:Oi(this,oo).name=t}get value(){const{inputElement:t}=this;return t?t.value:Oi(this,oo).value}set value(t){var e;this.defaultValue=t,null===(e=this.editor)||void 0===e||e.loadHTML(this.defaultValue)}attributeChangedCallback(t,e,i){"connected"===t&&this.isConnected&&null!=e&&e!==i&&requestAnimationFrame((()=>this.reconnect()))}notify(t,e){if(this.editorController)return A("trix-".concat(t),{onElement:this,attributes:e})}setFormValue(t){const{inputElement:e}=this;e&&(e.value=t),Oi(this,oo).setFormValue(t)}connectedCallback(){if(!this.hasAttribute("data-trix-internal")){if(qr(this),function(t){t.hasAttribute("role")||t.setAttribute("role","textbox")}(this),!this.editorController){if(A("trix-before-initialize",{onElement:this}),this.defaultValue=this.inputElement?this.inputElement.value:this.innerHTML,!this.hasAttribute("input")&&this.parentNode&&this.willCreateInput){const t="trix-input-".concat(this.trixId);this.setAttribute("input",t);const e=w("input",{type:"hidden",id:t});this.parentNode.insertBefore(e,this.nextElementSibling)}this.editorController=new jr({editorElement:this,html:this.defaultValue}),requestAnimationFrame((()=>A("trix-initialize",{onElement:this})))}this.editorController.registerSelectionManager(),Oi(this,oo).connectedCallback(),this.toggleAttribute("connected",!0),function(t){!document.querySelector(":focus")&&t.hasAttribute("autofocus")&&document.querySelector("[autofocus]")===t&&t.focus()}(this)}}disconnectedCallback(){var t;null===(t=this.editorController)||void 0===t||t.unregisterSelectionManager(),Oi(this,oo).disconnectedCallback(),this.toggleAttribute("connected",!1)}reconnect(){this.removeInternalToolbar(),this.disconnectedCallback(),this.connectedCallback()}removeInternalToolbar(){var t;null===(t=this.internalToolbar)||void 0===t||t.remove(),this.internalToolbar=null}checkValidity(){return Oi(this,oo).checkValidity()}reportValidity(){return Oi(this,oo).reportValidity()}setCustomValidity(t){Oi(this,oo).setCustomValidity(t)}formDisabledCallback(t){const{inputElement:e}=this;e&&(e.disabled=t),this.toggleAttribute("contenteditable",!t),Oi(this,oo).formDisabledCallback(t)}formResetCallback(){this.reset()}reset(){this.value=this.defaultValue}}Ii(so,"formAssociated","ElementInternals"in window),Ii(so,"observedAttributes",["connected"]);const ao={VERSION:t,config:q,core:Rn,models:Hn,views:qn,controllers:Wr,observers:Ur,operations:Hr,elements:Object.freeze({__proto__:null,TrixEditorElement:so,TrixToolbarElement:zr}),filters:Object.freeze({__proto__:null,Filter:On,attachmentGalleryFilter:Fn})};Object.assign(ao,Hn),window.Trix=ao,setTimeout((function(){customElements.get("trix-toolbar")||customElements.define("trix-toolbar",zr),customElements.get("trix-editor")||customElements.define("trix-editor",so)}),0);export{ao as default};