diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index 83610cf..0000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,12 +0,0 @@ -version: 2 -updates: -- package-ecosystem: bundler - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 10 -- package-ecosystem: github-actions - directory: "/" - schedule: - interval: weekly - open-pull-requests-limit: 10 diff --git a/Gemfile b/Gemfile index 82fbb48..e2cf0d4 100644 --- a/Gemfile +++ b/Gemfile @@ -41,6 +41,8 @@ gem "kamal", require: false # Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/] gem "thruster", require: false +gem "chartkick" + # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] gem "image_processing", "~> 1.2" diff --git a/Gemfile.lock b/Gemfile.lock index 223645a..3d3fe7b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,31 +1,31 @@ GEM remote: https://rubygems.org/ specs: - action_text-trix (2.1.15) + action_text-trix (2.1.16) railties - actioncable (8.1.1) - actionpack (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) - actionpack (= 8.1.1) - activejob (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) - actionpack (= 8.1.1) - actionview (= 8.1.1) - activejob (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) - actionview (= 8.1.1) - activesupport (= 8.1.1) + 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) @@ -33,36 +33,36 @@ GEM rails-dom-testing (~> 2.2) rails-html-sanitizer (~> 1.6) useragent (~> 0.16) - actiontext (8.1.1) + actiontext (8.1.2) action_text-trix (~> 2.1.15) - actionpack (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) - activesupport (= 8.1.1) + 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.1.1) - activesupport (= 8.1.1) + activejob (8.1.2) + activesupport (= 8.1.2) globalid (>= 0.3.6) - activemodel (8.1.1) - activesupport (= 8.1.1) - activerecord (8.1.1) - activemodel (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) - actionpack (= 8.1.1) - activejob (= 8.1.1) - activerecord (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) + activesupport (8.1.2) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -77,11 +77,11 @@ GEM uri (>= 0.13.1) ast (2.4.3) base64 (0.3.0) - bcrypt (3.1.20) + bcrypt (3.1.21) bcrypt_pbkdf (1.1.2) bigdecimal (4.0.1) bindex (0.8.1) - bootsnap (1.20.0) + bootsnap (1.21.1) msgpack (~> 1.2) brakeman (7.1.2) racc @@ -92,6 +92,7 @@ GEM bundler-audit (0.9.3) bundler (>= 1.2.0) thor (~> 1.0) + chartkick (5.2.1) concurrent-ruby (1.3.6) connection_pool (3.0.2) crass (1.0.6) @@ -119,9 +120,9 @@ GEM factory_bot_rails (6.5.1) factory_bot (~> 6.5) railties (>= 6.1.0) - faker (3.5.3) + faker (3.6.0) i18n (>= 1.8.11, < 2) - ffi (1.17.2-x86_64-linux-gnu) + ffi (1.17.3-x86_64-linux-gnu) fugit (1.12.1) et-orbi (~> 1.4) raabro (~> 1.4) @@ -132,7 +133,7 @@ GEM 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) @@ -172,7 +173,7 @@ GEM mini_magick (5.3.1) logger mini_mime (1.1.5) - minitest (6.0.0) + minitest (6.0.1) prism (~> 1.5) msgpack (1.8.0) net-imap (0.6.2) @@ -190,19 +191,19 @@ GEM net-protocol net-ssh (7.3.0) nio4r (2.7.5) - nokogiri (1.18.10-x86_64-linux-gnu) + nokogiri (1.19.0-x86_64-linux-gnu) racc (~> 1.4) orm_adapter (0.5.0) ostruct (0.6.3) parallel (1.27.0) - parser (3.3.10.0) + parser (3.3.10.1) ast (~> 2.4.1) racc - pg (1.6.2-x86_64-linux) + pg (1.6.3-x86_64-linux) pp (0.6.3) prettyprint prettyprint (0.2.0) - prism (1.7.0) + prism (1.8.0) propshaft (1.3.1) actionpack (>= 7.0.0) activesupport (>= 7.0.0) @@ -210,7 +211,7 @@ GEM psych (5.3.1) date stringio - puma (7.1.0) + puma (7.2.0) nio4r (~> 2.0) raabro (1.4.0) racc (1.8.1) @@ -222,20 +223,20 @@ GEM rack (>= 1.3) rackup (2.3.1) rack (>= 3) - rails (8.1.1) - actioncable (= 8.1.1) - actionmailbox (= 8.1.1) - actionmailer (= 8.1.1) - actionpack (= 8.1.1) - actiontext (= 8.1.1) - actionview (= 8.1.1) - activejob (= 8.1.1) - activemodel (= 8.1.1) - activerecord (= 8.1.1) - activestorage (= 8.1.1) - activesupport (= 8.1.1) + 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.1.1) + railties (= 8.1.2) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -243,9 +244,9 @@ GEM rails-html-sanitizer (1.6.2) loofah (~> 2.21) 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.1.1) - actionpack (= 8.1.1) - activesupport (= 8.1.1) + railties (8.1.2) + actionpack (= 8.1.2) + activesupport (= 8.1.2) irb (~> 1.13) rackup (>= 1.0.0) rake (>= 12.2) @@ -254,9 +255,9 @@ GEM zeitwerk (~> 2.6) rainbow (3.1.1) rake (13.3.1) - rbs (3.10.0) + rbs (3.10.2) logger - rdoc (7.0.3) + rdoc (7.1.0) erb psych (>= 4.0.0) tsort @@ -294,14 +295,14 @@ GEM rubocop-ast (>= 1.48.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 4.0) - rubocop-ast (1.48.0) + rubocop-ast (1.49.0) parser (>= 3.3.7.2) - prism (~> 1.4) + 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.2) + rubocop-rails (2.34.3) activesupport (>= 4.2.0) lint_roller (~> 1.1) rack (>= 1.1) @@ -311,10 +312,10 @@ GEM rubocop (>= 1.72) rubocop-performance (>= 1.24) rubocop-rails (>= 2.30) - rubocop-rspec (3.8.0) + rubocop-rspec (3.9.0) lint_roller (~> 1.1) rubocop (~> 1.81) - ruby-lsp (0.26.4) + ruby-lsp (0.26.5) language_server-protocol (~> 3.17.0) prism (>= 1.2, < 2.0) rbs (>= 3, < 5) @@ -340,7 +341,7 @@ GEM activejob (>= 7.2) activerecord (>= 7.2) railties (>= 7.2) - solid_queue (1.2.4) + solid_queue (1.3.1) activejob (>= 7.1) activerecord (>= 7.1) concurrent-ruby (>= 1.3.1) @@ -361,11 +362,11 @@ GEM railties (>= 7.0.0) tailwindcss-ruby (~> 3.0) tailwindcss-ruby (3.4.19-x86_64-linux) - thor (1.4.0) + thor (1.5.0) thruster (0.1.17-x86_64-linux) timeout (0.6.0) tsort (0.2.0) - turbo-rails (2.0.20) + turbo-rails (2.0.21) actionpack (>= 7.1.0) railties (>= 7.1.0) tzinfo (2.0.6) @@ -397,6 +398,7 @@ DEPENDENCIES brakeman bullet (~> 8.0, >= 8.0.8) bundler-audit + chartkick debug devise (~> 4.9) factory_bot_rails (~> 6.4, >= 6.4.4) diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index 016af88..9e471ad 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,5 +1,89 @@ - class DashboardController < ApplicationController def index + @wallets = current_user.wallets.includes(:holdings, :transactions, :strategy) + + @total_wallets = @wallets.count + @active_wallets = @wallets.active.count + @inactive_wallets = @wallets.inactive.count + + @wallet_summaries = @wallets.map do |wallet| + { + wallet: wallet, + total_invested: calculate_total_invested(wallet), + current_value: calculate_current_value(wallet), + holdings_count: wallet.holdings.count, + transactions_count: wallet.transactions.count, + has_strategy: wallet.strategy.present? + } + end + + @total_invested = @wallet_summaries.sum { |ws| ws[:total_invested] } + @total_current_value = @wallet_summaries.sum { |ws| ws[:current_value] } + @total_profit_loss = @total_current_value - @total_invested + @total_profit_loss_percentage = @total_invested.zero? ? 0 : ((@total_profit_loss / @total_invested) * 100) + + @recent_transactions = current_user.wallets + .joins(:transactions) + .includes(transactions: :instrument) + .merge(Transaction.order(occurred_at: :desc)) + .limit(10) + .flat_map(&:transactions) + .first(10) + + + @wallet_distribution = @wallet_summaries.map do |summary| + [summary[:wallet].name, summary[:current_value].to_f] + end.to_h + + transactions_last_6_months = current_user.wallets + .joins(:transactions) + .where("transactions.occurred_at >= ?", 6.months.ago) + .pluck("transactions.occurred_at") + + @transactions_by_month = transactions_last_6_months + .compact + .group_by { |date| date.beginning_of_month.strftime("%b %Y") } + .transform_values(&:count) + .sort_by { |month, _| Date.parse("01 #{month}") } + .to_h + + @buy_vs_sell = { + "Buys" => current_user.wallets.joins(:transactions).merge(Transaction.buy).count, + "Sells" => current_user.wallets.joins(:transactions).merge(Transaction.sell).count + } + + holdings_with_instruments = current_user.wallets + .joins(holdings: :instrument) + .select("instruments.ticker, holdings.average_price, holdings.quantity") + + @top_instruments = holdings_with_instruments + .group_by(&:ticker) + .map { |ticker, holdings| + total = holdings.sum { |h| (h.average_price || 0) * (h.quantity || 0) } + [ticker, total.to_f] + } + .sort_by { |_, value| -value } + .first(5) + .to_h + + @wallet_comparison_data = @wallet_summaries.map do |summary| + [ + summary[:wallet].name, + { + "Invested" => summary[:total_invested].to_f, + "Current" => summary[:current_value].to_f + } + ] + end.to_h end -end + + private + + def calculate_total_invested(wallet) + wallet.transactions.buy.sum('price * quantity') + end + + def calculate_current_value(wallet) + wallet.holdings.sum('average_price * quantity') + end +end \ No newline at end of file diff --git a/app/javascript/application.js b/app/javascript/application.js index 0d7b494..3b51970 100644 --- a/app/javascript/application.js +++ b/app/javascript/application.js @@ -1,3 +1,4 @@ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails import "@hotwired/turbo-rails" import "controllers" +import "chartkick/chart.js" diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 464f78b..391f798 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -1 +1,327 @@ -

Dashboard

+
+ +
+ +
+
+
+ + + +
+
+

Wallets

+
+
+

<%= @total_wallets %>

+
+ <%= @active_wallets %> active + <%= @inactive_wallets %> inactive +
+
+ + +
+
+
+ + + +
+
+

Invested

+
+
+

+ <%= number_to_currency(@total_invested, unit: "R$ ", separator: ",", delimiter: ".") %> +

+

Allocated capital

+
+ + +
+
+
+ + + +
+
+

Portfolio

+
+
+

+ <%= number_to_currency(@total_current_value, unit: "R$ ", separator: ",", delimiter: ".") %> +

+

Market value

+
+ + +
+
+
+ + + +
+
+

Return

+
+
+

+ <%= number_to_currency(@total_profit_loss, unit: "R$ ", separator: ",", delimiter: ".") %> +

+ + <%= @total_profit_loss >= 0 ? "↑" : "↓" %> + <%= number_to_percentage(@total_profit_loss_percentage.abs, precision: 2, separator: ",", delimiter: ".") %> + +
+
+ + + <% if @wallets.any? %> +
+ +
+

+
+ + + +
+ Portfolio Distribution +

+
+ <% max_value = @wallet_distribution.values.max.to_f %> + <% colors = ["#EAB308", "#84CC16", "#06B6D4", "#8B5CF6", "#EC4899"] %> + <% @wallet_distribution.each_with_index do |(name, value), index| %> + <% percentage = max_value > 0 ? (value / max_value * 100) : 0 %> +
+
+ <%= name %> + <%= number_to_currency(value, unit: "R$ ", separator: ",", delimiter: ".") %> +
+
+
+
+
+ <% end %> +
+
+ + +
+

+
+ + + +
+ Invested vs Current +

+
+ <% max_comparison = @wallet_comparison_data.values.flat_map(&:values).max.to_f %> + <% @wallet_comparison_data.each do |name, data| %> +
+
<%= name %>
+
+ <% data.each do |label, value| %> + <% percentage = max_comparison > 0 ? (value / max_comparison * 100) : 0 %> +
+ <%= label == 'Investido' ? 'Invested' : 'Current' %> +
+
+
+ <%= number_to_currency(value, unit: "R$ ", separator: ",", delimiter: ".", precision: 0) %> +
+ <% end %> +
+
+ <% end %> +
+
+ + +
+

+
+ + + +
+ Trading Volume +

+
+ <% total_ops = @buy_vs_sell.values.sum.to_f %> + <% buy_percentage = total_ops > 0 ? (@buy_vs_sell["Buys"] / total_ops * 100) : 50 %> + <% sell_percentage = 100 - buy_percentage %> + +
+ +
+
+
+ <%= total_ops.to_i %> +
+
+
+
+
+
+
+
+
+ Buys +
+
+ <%= @buy_vs_sell["Buys"] %> + (<%= number_to_percentage(buy_percentage, precision: 1) %>) +
+
+
+
+
+ Sells +
+
+ <%= @buy_vs_sell["Sells"] %> + (<%= number_to_percentage(sell_percentage, precision: 1) %>) +
+
+
+
+ + +
+

+
+ + + +
+ Top 5 Assets by Value +

+
+ <% max_instrument_value = @top_instruments.values.max.to_f %> + <% @top_instruments.each_with_index do |(ticker, value), index| %> + <% percentage = max_instrument_value > 0 ? (value / max_instrument_value * 100) : 0 %> +
+
+
+ + <%= index + 1 %> + + <%= ticker %> +
+ <%= number_to_currency(value, unit: "R$ ", separator: ",", delimiter: ".") %> +
+
+
+
+
+ <% end %> +
+
+
+ <% end %> + + +
+ + <% if @wallets.any? %> +
+ + + + + + + + + + + + + + + <% @wallet_summaries.each do |summary| %> + <% wallet = summary[:wallet] %> + <% profit_loss = summary[:current_value] - summary[:total_invested] %> + <% profit_percentage = summary[:total_invested].zero? ? 0 : ((profit_loss / summary[:total_invested]) * 100) %> + + + + + + + + + + + <% end %> + +
NameStatusHoldingsTransactionsInvestedCurrent ValueStrategyActions
+
+
+ <%= wallet.name[0].upcase %> +
+
<%= wallet.name %>
+
+
+ + <%= wallet.status.titleize %> + + + <%= summary[:holdings_count] %> + + <%= summary[:transactions_count] %> + + <%= number_to_currency(summary[:total_invested], unit: "R$ ", separator: ",", delimiter: ".") %> + +
+ <%= number_to_currency(summary[:current_value], unit: "R$ ", separator: ",", delimiter: ".") %> +
+ <% if profit_loss != 0 %> +
+ <%= profit_loss >= 0 ? "+" : "" %><%= number_to_percentage(profit_percentage, precision: 1) %> +
+ <% end %> +
+ <% if summary[:has_strategy] %> + + ✓ Yes + + <% else %> + + ✗ No + + <% end %> + + <%= link_to wallet_path(wallet), class: "inline-flex items-center gap-1 bg-yellow-500 hover:bg-yellow-600 text-white text-xs font-bold py-2 px-4 rounded-lg shadow hover:shadow-lg transition-all duration-200" do %> + + + + + View + <% end %> +
+
+ <% else %> +
+
+ + + +
+

You don't have any wallets yet

+

Get started by creating your first investment portfolio!

+ <%= link_to new_wallet_path, class: "inline-flex items-center gap-2 bg-yellow-500 hover:bg-yellow-600 text-white font-bold py-3 px-6 rounded-lg shadow-lg hover:shadow-xl transition-all duration-200" do %> + + + + Create first wallet + <% end %> +
+ <% end %> +
+
\ No newline at end of file diff --git a/config/importmap.rb b/config/importmap.rb index 909dfc5..0a2def6 100644 --- a/config/importmap.rb +++ b/config/importmap.rb @@ -4,4 +4,8 @@ pin "@hotwired/turbo-rails", to: "turbo.min.js" pin "@hotwired/stimulus", to: "stimulus.min.js" pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" +pin "chartkick" # @5.0.1 +pin "Chart.bundle", to: "Chart.bundle.js" pin_all_from "app/javascript/controllers", under: "controllers" +pin "chart.js" # @4.5.1 +pin "@kurkle/color", to: "@kurkle--color.js" # @0.3.4 diff --git a/vendor/javascript/@kurkle--color.js b/vendor/javascript/@kurkle--color.js new file mode 100644 index 0000000..fc3487b --- /dev/null +++ b/vendor/javascript/@kurkle--color.js @@ -0,0 +1,4 @@ +// @kurkle/color@0.3.4 downloaded from https://ga.jspm.io/npm:@kurkle/color@0.3.4/dist/color.esm.js + +function round(n){return n+.5|0}const lim=(n,e,t)=>Math.max(Math.min(n,t),e);function p2b(n){return lim(round(n*2.55),0,255)}function b2p(n){return lim(round(n/2.55),0,100)}function n2b(n){return lim(round(n*255),0,255)}function b2n(n){return lim(round(n/2.55)/100,0,1)}function n2p(n){return lim(round(n*100),0,100)}const n={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15};const e=[..."0123456789ABCDEF"];const h1=n=>e[n&15];const h2=n=>e[(n&240)>>4]+e[n&15];const eq=n=>(n&240)>>4===(n&15);const isShort=n=>eq(n.r)&&eq(n.g)&&eq(n.b)&&eq(n.a);function hexParse(e){var t=e.length;var r;e[0]==="#"&&(t===4||t===5?r={r:255&n[e[1]]*17,g:255&n[e[2]]*17,b:255&n[e[3]]*17,a:t===5?n[e[4]]*17:255}:t!==7&&t!==9||(r={r:n[e[1]]<<4|n[e[2]],g:n[e[3]]<<4|n[e[4]],b:n[e[5]]<<4|n[e[6]],a:t===9?n[e[7]]<<4|n[e[8]]:255}));return r}const alpha=(n,e)=>n<255?e(n):"";function hexString(n){var e=isShort(n)?h1:h2;return n?"#"+e(n.r)+e(n.g)+e(n.b)+alpha(n.a,e):void 0}const t=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function hsl2rgbn(n,e,t){const r=e*Math.min(t,1-t);const f=(e,a=(e+n/30)%12)=>t-r*Math.max(Math.min(a-3,9-a,1),-1);return[f(0),f(8),f(4)]}function hsv2rgbn(n,e,t){const f=(r,a=(r+n/60)%6)=>t-t*e*Math.max(Math.min(a,4-a,1),0);return[f(5),f(3),f(1)]}function hwb2rgbn(n,e,t){const r=hsl2rgbn(n,1,.5);let a;if(e+t>1){a=1/(e+t);e*=a;t*=a}for(a=0;a<3;a++){r[a]*=1-e-t;r[a]+=e}return r}function hueValue(n,e,t,r,a){return n===a?(e-t)/r+(e.5?g/(2-s-b):g/(s+b);o=hueValue(t,r,a,g,s);o=o*60+.5}return[o|0,i||0,c]}function calln(n,e,t,r){return(Array.isArray(e)?n(e[0],e[1],e[2]):n(e,t,r)).map(n2b)}function hsl2rgb(n,e,t){return calln(hsl2rgbn,n,e,t)}function hwb2rgb(n,e,t){return calln(hwb2rgbn,n,e,t)}function hsv2rgb(n,e,t){return calln(hsv2rgbn,n,e,t)}function hue(n){return(n%360+360)%360}function hueParse(n){const e=t.exec(n);let r=255;let a;if(!e)return;e[5]!==a&&(r=e[6]?p2b(+e[5]):n2b(+e[5]));const s=hue(+e[2]);const b=+e[3]/100;const c=+e[4]/100;a=e[1]==="hwb"?hwb2rgb(s,b,c):e[1]==="hsv"?hsv2rgb(s,b,c):hsl2rgb(s,b,c);return{r:a[0],g:a[1],b:a[2],a:r}}function rotate(n,e){var t=rgb2hsl(n);t[0]=hue(t[0]+e);t=hsl2rgb(t);n.r=t[0];n.g=t[1];n.b=t[2]}function hslString(n){if(!n)return;const e=rgb2hsl(n);const t=e[0];const r=n2p(e[1]);const a=n2p(e[2]);return n.a<255?`hsla(${t}, ${r}%, ${a}%, ${b2n(n.a)})`:`hsl(${t}, ${r}%, ${a}%)`}const r={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"};const a={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function unpack(){const n={};const e=Object.keys(a);const t=Object.keys(r);let s,b,c,o,i;for(s=0;s>16&255,c>>8&255,c&255]}return n}let s;function nameParse(n){if(!s){s=unpack();s.transparent=[0,0,0,0]}const e=s[n.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:e.length===4?e[3]:255}}const b=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function rgbParse(n){const e=b.exec(n);let t=255;let r,a,s;if(e){if(e[7]!==r){const n=+e[7];t=e[8]?p2b(n):lim(n*255,0,255)}r=+e[1];a=+e[3];s=+e[5];r=255&(e[2]?p2b(r):lim(r,0,255));a=255&(e[4]?p2b(a):lim(a,0,255));s=255&(e[6]?p2b(s):lim(s,0,255));return{r:r,g:a,b:s,a:t}}}function rgbString(n){return n&&(n.a<255?`rgba(${n.r}, ${n.g}, ${n.b}, ${b2n(n.a)})`:`rgb(${n.r}, ${n.g}, ${n.b})`)}const to=n=>n<=.0031308?n*12.92:Math.pow(n,1/2.4)*1.055-.055;const from=n=>n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4);function interpolate(n,e,t){const r=from(b2n(n.r));const a=from(b2n(n.g));const s=from(b2n(n.b));return{r:n2b(to(r+t*(from(b2n(e.r))-r))),g:n2b(to(a+t*(from(b2n(e.g))-a))),b:n2b(to(s+t*(from(b2n(e.b))-s))),a:n.a+t*(e.a-n.a)}}function modHSL(n,e,t){if(n){let r=rgb2hsl(n);r[e]=Math.max(0,Math.min(r[e]+r[e]*t,e===0?360:1));r=hsl2rgb(r);n.r=r[0];n.g=r[1];n.b=r[2]}}function clone(n,e){return n?Object.assign(e||{},n):n}function fromObject(n){var e={r:0,g:0,b:0,a:255};if(Array.isArray(n)){if(n.length>=3){e={r:n[0],g:n[1],b:n[2],a:255};n.length>3&&(e.a=n2b(n[3]))}}else{e=clone(n,{r:0,g:0,b:0,a:1});e.a=n2b(e.a)}return e}function functionParse(n){return n.charAt(0)==="r"?rgbParse(n):hueParse(n)}class Color{constructor(n){if(n instanceof Color)return n;const e=typeof n;let t;e==="object"?t=fromObject(n):e==="string"&&(t=hexParse(n)||nameParse(n)||functionParse(n));this._rgb=t;this._valid=!!t}get valid(){return this._valid}get rgb(){var n=clone(this._rgb);n&&(n.a=b2n(n.a));return n}set rgb(n){this._rgb=fromObject(n)}rgbString(){return this._valid?rgbString(this._rgb):void 0}hexString(){return this._valid?hexString(this._rgb):void 0}hslString(){return this._valid?hslString(this._rgb):void 0}mix(n,e){if(n){const t=this.rgb;const r=n.rgb;let a;const s=e===a?.5:e;const b=2*s-1;const c=t.a-r.a;const o=((b*c===-1?b:(b+c)/(1+b*c))+1)/2;a=1-o;t.r=255&o*t.r+a*r.r+.5;t.g=255&o*t.g+a*r.g+.5;t.b=255&o*t.b+a*r.b+.5;t.a=s*t.a+(1-s)*r.a;this.rgb=t}return this}interpolate(n,e){n&&(this._rgb=interpolate(this._rgb,n._rgb,e));return this}clone(){return new Color(this.rgb)}alpha(n){this._rgb.a=n2b(n);return this}clearer(n){const e=this._rgb;e.a*=1-n;return this}greyscale(){const n=this._rgb;const e=round(n.r*.3+n.g*.59+n.b*.11);n.r=n.g=n.b=e;return this}opaquer(n){const e=this._rgb;e.a*=1+n;return this}negate(){const n=this._rgb;n.r=255-n.r;n.g=255-n.g;n.b=255-n.b;return this}lighten(n){modHSL(this._rgb,2,n);return this}darken(n){modHSL(this._rgb,2,-n);return this}saturate(n){modHSL(this._rgb,1,n);return this}desaturate(n){modHSL(this._rgb,1,-n);return this}rotate(n){rotate(this._rgb,n);return this}}function index_esm(n){return new Color(n)}export{Color,b2n,b2p,index_esm as default,hexParse,hexString,hsl2rgb,hslString,hsv2rgb,hueParse,hwb2rgb,lim,n2b,n2p,nameParse,p2b,rgb2hsl,rgbParse,rgbString,rotate,round}; + diff --git a/vendor/javascript/chart.js.js b/vendor/javascript/chart.js.js new file mode 100644 index 0000000..5b4b015 --- /dev/null +++ b/vendor/javascript/chart.js.js @@ -0,0 +1,12 @@ +// chart.js@4.5.1 downloaded from https://ga.jspm.io/npm:chart.js@4.5.1/dist/chart.js + +import{r as t,c as e,a as s,e as i,i as n,d as o,b as a,f as r,s as l,g as c,v as h,u as d,l as u,h as f,j as g,_ as p,k as m,m as x,n as b,H as _,P as y,t as v,o as M,p as w,q as k,w as S,x as D,y as P,z as C,A,B as L,C as E,D as T,E as O,F as R,G as I,I as z,J as F,K as V,L as B,M as N,N as W,O as H,Q as j,R as $,S as U,U as Y,V as X,W as G,X as K,Y as J,Z as q,$ as Z,a0 as Q,a1 as tt,a2 as et,a3 as st,a4 as it,a5 as nt,a6 as ot,a7 as at,a8 as rt,a9 as lt,aa as ct,ab as ht,ac as dt,ad as ut,ae as ft,af as gt,ag as pt,ah as mt,ai as xt,aj as bt,ak as _t,al as yt,am as vt,an as Mt,ao as wt,ap as kt,aq as St,ar as Dt,as as Pt,at as Ct,au as At,av as Lt,aw as Et,ax as Tt,ay as Ot,az as Rt,aA as It,aB as zt,aC as Ft,aD as Vt,aE as Bt,aF as Nt,aG as Wt,aH as Ht,aI as jt,aJ as $t,aK as Ut,aL as Yt,aM as Xt,T as Gt,aN as Kt,aO as Jt,aP as qt,aQ as Zt}from"../_/MwoWUuIu.js";import"@kurkle/color";class Animator{constructor(){this._request=null;this._charts=new Map;this._running=false;this._lastDate=void 0}_notify(t,e,s,i){const n=e.listeners[i];const o=e.duration;n.forEach((i=>i({chart:t,initial:e.initial,numSteps:o,currentStep:Math.min(s-e.start,o)})))}_refresh(){if(!this._request){this._running=true;this._request=t.call(window,(()=>{this._update();this._request=null;this._running&&this._refresh()}))}}_update(t=Date.now()){let e=0;this._charts.forEach(((s,i)=>{if(!s.running||!s.items.length)return;const n=s.items;let o=n.length-1;let a=false;let r;for(;o>=0;--o){r=n[o];if(r._active){r._total>s.duration&&(s.duration=r._total);r.tick(t);a=true}else{n[o]=n[n.length-1];n.pop()}}if(a){i.draw();this._notify(i,s,t,"progress")}if(!n.length){s.running=false;this._notify(i,s,t,"complete");s.initial=false}e+=n.length}));this._lastDate=t;e===0&&(this._running=false)}_getAnims(t){const e=this._charts;let s=e.get(t);if(!s){s={running:false,initial:true,items:[],listeners:{complete:[],progress:[]}};e.set(t,s)}return s}listen(t,e,s){this._getAnims(t).listeners[e].push(s)}add(t,e){e&&e.length&&this._getAnims(t).items.push(...e)}has(t){return this._getAnims(t).items.length>0}start(t){const e=this._charts.get(t);if(e){e.running=true;e.start=Date.now();e.duration=e.items.reduce(((t,e)=>Math.max(t,e._duration)),0);this._refresh()}}running(t){if(!this._running)return false;const e=this._charts.get(t);return!!(e&&e.running&&e.items.length)}stop(t){const e=this._charts.get(t);if(!e||!e.items.length)return;const s=e.items;let i=s.length-1;for(;i>=0;--i)s[i].cancel();e.items=[];this._notify(t,e,Date.now(),"complete")}remove(t){return this._charts.delete(t)}}var Qt=new Animator;const te="transparent";const ee={boolean(t,e,s){return s>.5?e:t},color(t,s,i){const n=e(t||te);const o=n.valid&&e(s||te);return o&&o.valid?o.mix(n,i).hexString():s},number(t,e,s){return t+(e-t)*s}};class Animation{constructor(t,e,n,o){const a=e[n];o=s([t.to,o,a,t.from]);const r=s([t.from,a,o]);this._active=true;this._fn=t.fn||ee[t.type||typeof r];this._easing=i[t.easing]||i.linear;this._start=Math.floor(Date.now()+(t.delay||0));this._duration=this._total=Math.floor(t.duration);this._loop=!!t.loop;this._target=e;this._prop=n;this._from=r;this._to=o;this._promises=void 0}active(){return this._active}update(t,e,i){if(this._active){this._notify(false);const n=this._target[this._prop];const o=i-this._start;const a=this._duration-o;this._start=i;this._duration=Math.floor(Math.max(a,t.duration));this._total+=o;this._loop=!!t.loop;this._to=s([t.to,e,n,t.from]);this._from=s([t.from,n,e])}}cancel(){if(this._active){this.tick(Date.now());this._active=false;this._notify(false)}}tick(t){const e=t-this._start;const s=this._duration;const i=this._prop;const n=this._from;const o=this._loop;const a=this._to;let r;this._active=n!==a&&(o||e1?2-r:r;r=this._easing(Math.min(1,Math.max(0,r)));this._target[i]=this._fn(n,a,r)}else{this._target[i]=a;this._notify(true)}}wait(){const t=this._promises||(this._promises=[]);return new Promise(((e,s)=>{t.push({res:e,rej:s})}))}_notify(t){const e=t?"res":"rej";const s=this._promises||[];for(let t=0;t{const o=t[i];if(!n(o))return;const r={};for(const t of e)r[t]=o[t];(a(o.properties)&&o.properties||[i]).forEach((t=>{t!==i&&s.has(t)||s.set(t,r)}))}))}_animateOptions(t,e){const s=e.options;const i=ie(t,s);if(!i)return[];const n=this._createAnimations(i,s);s.$shared&&se(t.options.$animations,s).then((()=>{t.options=s}),(()=>{}));return n}_createAnimations(t,e){const s=this._properties;const i=[];const n=t.$animations||(t.$animations={});const o=Object.keys(e);const a=Date.now();let r;for(r=o.length-1;r>=0;--r){const l=o[r];if(l.charAt(0)==="$")continue;if(l==="options"){i.push(...this._animateOptions(t,e));continue}const c=e[l];let h=n[l];const d=s.get(l);if(h){if(d&&h.active()){h.update(d,c,a);continue}h.cancel()}if(d&&d.duration){n[l]=h=new Animation(d,t,l,c);i.push(h)}else t[l]=c}return i}update(t,e){if(this._properties.size===0){Object.assign(t,e);return}const s=this._createAnimations(t,e);if(s.length){Qt.add(this._chart,s);return true}}}function se(t,e){const s=[];const i=Object.keys(e);for(let e=0;e0||!s&&e<0)return n.index}return null}function pe(t,e){const{chart:s,_cachedMeta:i}=t;const n=s._stacks||(s._stacks={});const{iScale:o,vScale:a,index:r}=i;const l=o.axis;const c=a.axis;const h=de(o,a,i);const d=e.length;let u;for(let t=0;ts[t].axis===e)).shift()}function xe(t,e){return c(t,{active:false,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function be(t,e,s){return c(t,{active:false,dataIndex:e,parsed:void 0,raw:void 0,element:s,index:e,mode:"default",type:"data"})}function _e(t,e){const s=t.controller.index;const i=t.vScale&&t.vScale.axis;if(i){e=e||t._parsed;for(const t of e){const e=t._stacks;if(!e||e[i]===void 0||e[i][s]===void 0)return;delete e[i][s];e[i]._visualValues!==void 0&&e[i]._visualValues[s]!==void 0&&delete e[i]._visualValues[s]}}}const ye=t=>t==="reset"||t==="none";const ve=(t,e)=>e?t:Object.assign({},t);const Me=(t,e,s)=>t&&!e.hidden&&e._stacked&&{keys:re(s,true),values:null};class DatasetController{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(t,e){this.chart=t;this._ctx=t.ctx;this.index=e;this._cachedDataOpts={};this._cachedMeta=this.getMeta();this._type=this._cachedMeta.type;this.options=void 0;this._parsing=false;this._data=void 0;this._objectData=void 0;this._sharedOptions=void 0;this._drawStart=void 0;this._drawCount=void 0;this.enableOptionSharing=false;this.supportsDecimation=false;this.$context=void 0;this._syncList=[];this.datasetElementType=new.target.datasetElementType;this.dataElementType=new.target.dataElementType;this.initialize()}initialize(){const t=this._cachedMeta;this.configure();this.linkScales();t._stacked=he(t.vScale,t);this.addElements();this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(t){this.index!==t&&_e(this._cachedMeta);this.index=t}linkScales(){const t=this.chart;const e=this._cachedMeta;const s=this.getDataset();const i=(t,e,s,i)=>t==="x"?e:t==="r"?i:s;const n=e.xAxisID=h(s.xAxisID,me(t,"x"));const o=e.yAxisID=h(s.yAxisID,me(t,"y"));const a=e.rAxisID=h(s.rAxisID,me(t,"r"));const r=e.indexAxis;const l=e.iAxisID=i(r,n,o,a);const c=e.vAxisID=i(r,o,n,a);e.xScale=this.getScaleForId(n);e.yScale=this.getScaleForId(o);e.rScale=this.getScaleForId(a);e.iScale=this.getScaleForId(l);e.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(t){return this.chart.scales[t]}_getOtherScale(t){const e=this._cachedMeta;return t===e.iScale?e.vScale:e.iScale}reset(){this._update("reset")}_destroy(){const t=this._cachedMeta;this._data&&d(this._data,this);t._stacked&&_e(t)}_dataCheck(){const t=this.getDataset();const e=t.data||(t.data=[]);const s=this._data;if(n(e)){const t=this._cachedMeta;this._data=ce(e,t)}else if(s!==e){if(s){d(s,this);const t=this._cachedMeta;_e(t);t._parsed=[]}e&&Object.isExtensible(e)&&u(e,this);this._syncList=[];this._data=e}}addElements(){const t=this._cachedMeta;this._dataCheck();this.datasetElementType&&(t.dataset=new this.datasetElementType)}buildOrUpdateElements(t){const e=this._cachedMeta;const s=this.getDataset();let i=false;this._dataCheck();const n=e._stacked;e._stacked=he(e.vScale,e);if(e.stack!==s.stack){i=true;_e(e);e.stack=s.stack}this._resyncElements(t);if(i||n!==e._stacked){pe(this,e._parsed);e._stacked=he(e.vScale,e)}}configure(){const t=this.chart.config;const e=t.datasetScopeKeys(this._type);const s=t.getOptionScopes(this.getDataset(),e,true);this.options=t.createResolver(s,this.getContext());this._parsing=this.options.parsing;this._cachedDataOpts={}}parse(t,e){const{_cachedMeta:s,_data:i}=this;const{iScale:o,_stacked:r}=s;const l=o.axis;let c=t===0&&e===i.length||s._sorted;let h=t>0&&s._parsed[t-1];let d,u,f;if(this._parsing===false){s._parsed=i;s._sorted=true;f=i}else{f=a(i[t])?this.parseArrayData(s,i,t,e):n(i[t])?this.parseObjectData(s,i,t,e):this.parsePrimitiveData(s,i,t,e);const o=()=>u[l]===null||h&&u[l]e||d=0;--u)if(!g()){this.updateRangeFromParsed(c,t,f,l);break}return c}getAllParsedValues(t){const e=this._cachedMeta._parsed;const s=[];let i,n,o;for(i=0,n=e.length;i=0&&tthis.getContext(s,i,e);const m=c.resolveNamedOptions(u,f,p,d);if(m.$shared){m.$shared=l;n[a]=Object.freeze(ve(m,l))}return m}_resolveAnimations(t,e,s){const i=this.chart;const n=this._cachedDataOpts;const o=`animation-${e}`;const a=n[o];if(a)return a;let r;if(i.options.animation!==false){const i=this.chart.config;const n=i.datasetAnimationScopeKeys(this._type,e);const o=i.getOptionScopes(this.getDataset(),n);r=i.createResolver(o,this.getContext(t,s,e))}const l=new Animations(i,r&&r.animations);r&&r._cacheable&&(n[o]=Object.freeze(l));return l}getSharedOptions(t){if(t.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},t))}includeOptions(t,e){return!e||ye(t)||this.chart._animationsDisabled}_getSharedOptions(t,e){const s=this.resolveDataElementOptions(t,e);const i=this._sharedOptions;const n=this.getSharedOptions(s);const o=this.includeOptions(e,n)||n!==i;this.updateSharedOptions(n,e,s);return{sharedOptions:n,includeOptions:o}}updateElement(t,e,s,i){ye(i)?Object.assign(t,s):this._resolveAnimations(e,i).update(t,s)}updateSharedOptions(t,e,s){t&&!ye(e)&&this._resolveAnimations(void 0,e).update(t,s)}_setStyle(t,e,s,i){t.active=i;const n=this.getStyle(e,i);this._resolveAnimations(e,s,i).update(t,{options:!i&&this.getSharedOptions(n)||n})}removeHoverStyle(t,e,s){this._setStyle(t,s,"active",false)}setHoverStyle(t,e,s){this._setStyle(t,s,"active",true)}_removeDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",false)}_setDatasetHoverStyle(){const t=this._cachedMeta.dataset;t&&this._setStyle(t,void 0,"active",true)}_resyncElements(t){const e=this._data;const s=this._cachedMeta.data;for(const[t,e,s]of this._syncList)this[t](e,s);this._syncList=[];const i=s.length;const n=e.length;const o=Math.min(n,i);o&&this.parse(0,o);n>i?this._insertElements(i,n-i,t):n{t.length+=e;for(a=t.length-1;a>=o;a--)t[a]=t[a-e]};r(n);for(a=t;at-e)))}return t._cache.$bar}function ke(t){const e=t.iScale;const s=we(e,t.type);let i=e._length;let n,o,a,r;const l=()=>{if(a!==32767&&a!==-32768){g(r)&&(i=Math.min(i,Math.abs(a-r)||i));r=a}};for(n=0,o=s.length;n0?n[t-1]:null;let r=tMath.abs(r)){l=r;c=a}e[s.axis]=c;e._custom={barStart:l,barEnd:c,start:n,end:o,min:a,max:r}}function Ce(t,e,s,i){a(t)?Pe(t,e,s,i):e[s.axis]=s.parse(t,i);return e}function Ae(t,e,s,i){const n=t.iScale;const o=t.vScale;const a=n.getLabels();const r=n===o;const l=[];let c,h,d,u;for(c=s,h=s+i;c=s?1:-1)}function Te(t){let e,s,i,n,o;if(t.horizontal){e=t.base>t.x;s="left";i="right"}else{e=t.baset.controller.options.grouped));const n=s.options.stacked;const o=[];const a=this._cachedMeta.controller.getParsed(e);const r=a&&a[s.axis];const l=t=>{const e=t._parsed.find((t=>t[s.axis]===r));const i=e&&e[t.vScale.axis];if(m(i)||isNaN(i))return true};for(const s of i)if(e===void 0||!l(s)){(n===false||o.indexOf(s.stack)===-1||n===void 0&&s.stack===void 0)&&o.push(s.stack);if(s.index===t)break}o.length||o.push(void 0);return o}_getStackCount(t){return this._getStacks(void 0,t).length}_getAxisCount(){return this._getAxis().length}getFirstScaleIdForIndexAxis(){const t=this.chart.scales;const e=this.chart.options.indexAxis;return Object.keys(t).filter((s=>t[s].axis===e)).shift()}_getAxis(){const t={};const e=this.getFirstScaleIdForIndexAxis();for(const s of this.chart.data.datasets)t[h(this.chart.options.indexAxis==="x"?s.xAxisID:s.yAxisID,e)]=true;return Object.keys(t)}_getStackIndex(t,e,s){const i=this._getStacks(t,s);const n=e!==void 0?i.indexOf(e):-1;return n===-1?i.length-1:n}_getRuler(){const t=this.options;const e=this._cachedMeta;const s=e.iScale;const i=[];let n,o;for(n=0,o=e.data.length;n=0;--s)e=Math.max(e,t[s].size(this.resolveDataElementOptions(s))/2);return e>0&&e}getLabelAndValue(t){const e=this._cachedMeta;const s=this.chart.data.labels||[];const{xScale:i,yScale:n}=e;const o=this.getParsed(t);const a=i.getLabelForValue(o.x);const r=n.getLabelForValue(o.y);const l=o._custom;return{label:s[t]||"",value:"("+a+", "+r+(l?", "+l:"")+")"}}update(t){const e=this._cachedMeta.data;this.updateElements(e,0,e.length,t)}updateElements(t,e,s,i){const n=i==="reset";const{iScale:o,vScale:a}=this._cachedMeta;const{sharedOptions:r,includeOptions:l}=this._getSharedOptions(e,i);const c=o.axis;const h=a.axis;for(let d=e;db(t,r,l,true)?1:Math.max(e,e*s,i,i*s);const g=(t,e,i)=>b(t,r,l,true)?-1:Math.min(e,e*s,i,i*s);const p=f(0,c,d);const m=f(_,h,u);const x=g(y,c,d);const v=g(y+_,h,u);i=(p-x)/2;n=(m-v)/2;o=-(p+x)/2;a=-(m+v)/2}return{ratioX:i,ratioY:n,offsetX:o,offsetY:a}}class DoughnutController extends DatasetController{static id="doughnut";static defaults={datasetElementType:false,dataElementType:"arc",animation:{animateRotate:true,animateScale:false},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:t=>t!=="spacing",_indexable:t=>t!=="spacing"&&!t.startsWith("borderDash")&&!t.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;const{labels:{pointStyle:s,textAlign:i,color:n,useBorderRadius:o,borderRadius:a}}=t.legend.options;return e.labels.length&&e.datasets.length?e.labels.map(((e,r)=>{const l=t.getDatasetMeta(0);const c=l.controller.getStyle(r);return{text:e,fillStyle:c.backgroundColor,fontColor:n,hidden:!t.getDataVisibility(r),lineDash:c.borderDash,lineDashOffset:c.borderDashOffset,lineJoin:c.borderJoinStyle,lineWidth:c.borderWidth,strokeStyle:c.borderColor,textAlign:i,pointStyle:s,borderRadius:o&&(a||c.borderRadius),index:r}})):[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index);s.chart.update()}}}};constructor(t,e){super(t,e);this.enableOptionSharing=true;this.innerRadius=void 0;this.outerRadius=void 0;this.offsetX=void 0;this.offsetY=void 0}linkScales(){}parse(t,e){const s=this.getDataset().data;const i=this._cachedMeta;if(this._parsing===false)i._parsed=s;else{let o=t=>+s[t];if(n(s[t])){const{key:t="value"}=this._parsing;o=e=>+f(s[e],t)}let a,r;for(a=t,r=t+e;a0&&!isNaN(t)?x*(Math.abs(t)/e):0}getLabelAndValue(t){const e=this._cachedMeta;const s=this.chart;const i=s.data.labels||[];const n=k(e._parsed[t],s.options.locale);return{label:i[t]||"",value:n}}getMaxBorderWidth(t){let e=0;const s=this.chart;let i,n,o,a,r;if(!t)for(i=0,n=s.data.datasets.length;i0&&this.getParsed(e-1);for(let s=0;s<_;++s){const f=t[s];const _=x?f:{};if(s=b){_.skip=true;continue}const v=this.getParsed(s);const M=m(v[u]);const w=_[d]=o.getPixelForValue(v[d],s);const k=_[u]=n||M?a.getBasePixel():a.getPixelForValue(r?this.applyStack(a,v,r):v[u],s);_.skip=isNaN(w)||isNaN(k)||M;_.stop=s>0&&Math.abs(v[d]-y[d])>p;if(g){_.parsed=v;_.raw=l.data[s]}h&&(_.options=c||this.resolveDataElementOptions(s,f.active?"active":i));x||this.updateElement(f,s,_,i);y=v}}getMaxOverflow(){const t=this._cachedMeta;const e=t.dataset;const s=e.options&&e.options.borderWidth||0;const i=t.data||[];if(!i.length)return s;const n=i[0].size(this.resolveDataElementOptions(0));const o=i[i.length-1].size(this.resolveDataElementOptions(i.length-1));return Math.max(s,n,o)/2}draw(){const t=this._cachedMeta;t.dataset.updateControlPoints(this.chart.chartArea,t.iScale.axis);super.draw()}}class PolarAreaController extends DatasetController{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:true,animateScale:true},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(t){const e=t.data;if(e.labels.length&&e.datasets.length){const{labels:{pointStyle:s,color:i}}=t.legend.options;return e.labels.map(((e,n)=>{const o=t.getDatasetMeta(0);const a=o.controller.getStyle(n);return{text:e,fillStyle:a.backgroundColor,strokeStyle:a.borderColor,fontColor:i,lineWidth:a.borderWidth,pointStyle:s,hidden:!t.getDataVisibility(n),index:n}}))}return[]}},onClick(t,e,s){s.chart.toggleDataVisibility(e.index);s.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:false},beginAtZero:true,grid:{circular:true},pointLabels:{display:false},startAngle:0}}};constructor(t,e){super(t,e);this.innerRadius=void 0;this.outerRadius=void 0}getLabelAndValue(t){const e=this._cachedMeta;const s=this.chart;const i=s.data.labels||[];const n=k(e._parsed[t].r,s.options.locale);return{label:i[t]||"",value:n}}parseObjectData(t,e,s,i){return C.bind(this)(t,e,s,i)}update(t){const e=this._cachedMeta.data;this._updateRadius();this.updateElements(e,0,e.length,t)}getMinMax(){const t=this._cachedMeta;const e={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};t.data.forEach(((t,s)=>{const i=this.getParsed(s).r;if(!isNaN(i)&&this.chart.getDataVisibility(s)){ie.max&&(e.max=i)}}));return e}_updateRadius(){const t=this.chart;const e=t.chartArea;const s=t.options;const i=Math.min(e.right-e.left,e.bottom-e.top);const n=Math.max(i/2,0);const o=Math.max(s.cutoutPercentage?n/100*s.cutoutPercentage:1,0);const a=(n-o)/t.getVisibleDatasetCount();this.outerRadius=n-a*this.index;this.innerRadius=this.outerRadius-a}updateElements(t,e,s,i){const n=i==="reset";const o=this.chart;const a=o.options;const r=a.animation;const l=this._cachedMeta.rScale;const c=l.xCenter;const h=l.yCenter;const d=l.getIndexAngle(0)-.5*y;let u=d;let f;const g=360/this.countVisibleElements();for(f=0;f{!isNaN(this.getParsed(s).r)&&this.chart.getDataVisibility(s)&&e++}));return e}_computeAngle(t,e,s){return this.chart.getDataVisibility(t)?v(this.resolveDataElementOptions(t,e).angle||s):0}}class PieController extends DoughnutController{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class RadarController extends DatasetController{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:true,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(t){const e=this._cachedMeta.vScale;const s=this.getParsed(t);return{label:e.getLabels()[t],value:""+e.getLabelForValue(s[e.axis])}}parseObjectData(t,e,s,i){return C.bind(this)(t,e,s,i)}update(t){const e=this._cachedMeta;const s=e.dataset;const i=e.data||[];const n=e.iScale.getLabels();s.points=i;if(t!=="resize"){const e=this.resolveDatasetElementOptions(t);this.options.showLine||(e.borderWidth=0);const o={_loop:true,_fullLoop:n.length===i.length,options:e};this.updateElement(s,void 0,o,t)}this.updateElements(i,0,i.length,t)}updateElements(t,e,s,i){const n=this._cachedMeta.rScale;const o=i==="reset";for(let a=e;a0&&this.getParsed(e-1);for(let c=e;c0&&Math.abs(s[u]-_[u])>x;if(p){g.parsed=s;g.raw=l.data[c]}d&&(g.options=h||this.resolveDataElementOptions(c,e.active?"active":i));b||this.updateElement(e,c,g,i);_=s}this.updateSharedOptions(h,i,c)}getMaxOverflow(){const t=this._cachedMeta;const e=t.data||[];if(!this.options.showLine){let t=0;for(let s=e.length-1;s>=0;--s)t=Math.max(t,e[s].size(this.resolveDataElementOptions(s))/2);return t>0&&t}const s=t.dataset;const i=s.options&&s.options.borderWidth||0;if(!e.length)return i;const n=e[0].size(this.resolveDataElementOptions(0));const o=e[e.length-1].size(this.resolveDataElementOptions(e.length-1));return Math.max(i,n,o)/2}}var Be=Object.freeze({__proto__:null,BarController:BarController,BubbleController:BubbleController,DoughnutController:DoughnutController,LineController:LineController,PieController:PieController,PolarAreaController:PolarAreaController,RadarController:RadarController,ScatterController:ScatterController});function Ne(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{static override(t){Object.assign(DateAdapterBase.prototype,t)}options;constructor(t){this.options=t||{}}init(){}formats(){return Ne()}parse(){return Ne()}format(){return Ne()}add(){return Ne()}diff(){return Ne()}startOf(){return Ne()}endOf(){return Ne()}}var We={_date:DateAdapterBase};function He(t,e,s,i){const{controller:n,data:o,_sorted:a}=t;const r=n._cachedMeta.iScale;const l=t.dataset&&t.dataset.options?t.dataset.options.spanGaps:null;if(r&&e===r.axis&&e!=="r"&&a&&o.length){const a=r._reversePixels?A:L;if(!i){const i=a(o,e,s);if(l){const{vScale:e}=n._cachedMeta;const{_parsed:s}=t;const o=s.slice(0,i.lo+1).reverse().findIndex((t=>!m(t[e.axis])));i.lo-=Math.max(0,o);const a=s.slice(i.hi).findIndex((t=>!m(t[e.axis])));i.hi+=Math.max(0,a)}return i}if(n._sharedOptions){const t=o[0];const i=typeof t.getRange==="function"&&t.getRange(e);if(i){const t=a(o,e,s-i);const n=a(o,e,s+i);return{lo:t.lo,hi:n.hi}}}}return{lo:0,hi:o.length-1}}function je(t,e,s,i,n){const o=t.getSortedVisibleDatasetMetas();const a=s[e];for(let t=0,s=o.length;t{if(t[a]&&t[a](e[s],n)){o.push({element:t,datasetIndex:i,index:l});r=r||t.inRange(e.x,e.y,n)}}));return i&&!r?[]:o}var Je={evaluateInteractionItems:je,modes:{index(t,e,s,i){const n=O(e,t);const o=s.axis||"x";const a=s.includeInvisible||false;const r=s.intersect?Ue(t,n,o,i,a):Ge(t,n,o,false,i,a);const l=[];if(!r.length)return[];t.getSortedVisibleDatasetMetas().forEach((t=>{const e=r[0].index;const s=t.data[e];s&&!s.skip&&l.push({element:s,datasetIndex:t.index,index:e})}));return l},dataset(t,e,s,i){const n=O(e,t);const o=s.axis||"xy";const a=s.includeInvisible||false;let r=s.intersect?Ue(t,n,o,i,a):Ge(t,n,o,false,i,a);if(r.length>0){const e=r[0].datasetIndex;const s=t.getDatasetMeta(e).data;r=[];for(let t=0;tt.pos===e))}function Qe(t,e){return t.filter((t=>qe.indexOf(t.pos)===-1&&t.box.axis===e))}function ts(t,e){return t.sort(((t,s)=>{const i=e?s:t;const n=e?t:s;return i.weight===n.weight?i.index-n.index:i.weight-n.weight}))}function es(t){const e=[];let s,i,n,o,a,r;for(s=0,i=(t||[]).length;st.box.fullSize)),true);const i=ts(Ze(e,"left"),true);const n=ts(Ze(e,"right"));const o=ts(Ze(e,"top"),true);const a=ts(Ze(e,"bottom"));const r=Qe(e,"x");const l=Qe(e,"y");return{fullSize:s,leftAndTop:i.concat(o),rightAndBottom:n.concat(l).concat(a).concat(r),chartArea:Ze(e,"chartArea"),vertical:i.concat(n).concat(l),horizontal:o.concat(a).concat(r)}}function os(t,e,s,i){return Math.max(t[s],e[s])+Math.max(t[i],e[i])}function as(t,e){t.top=Math.max(t.top,e.top);t.left=Math.max(t.left,e.left);t.bottom=Math.max(t.bottom,e.bottom);t.right=Math.max(t.right,e.right)}function rs(t,e,s,i){const{pos:o,box:a}=s;const r=t.maxPadding;if(!n(o)){s.size&&(t[o]-=s.size);const e=i[s.stack]||{size:0,count:1};e.size=Math.max(e.size,s.horizontal?a.height:a.width);s.size=e.size/e.count;t[o]+=s.size}a.getPadding&&as(r,a.getPadding());const l=Math.max(0,e.outerWidth-os(r,t,"left","right"));const c=Math.max(0,e.outerHeight-os(r,t,"top","bottom"));const h=l!==t.w;const d=c!==t.h;t.w=l;t.h=c;return s.horizontal?{same:h,other:d}:{same:d,other:h}}function ls(t){const e=t.maxPadding;function s(s){const i=Math.max(e[s]-t[s],0);t[s]+=i;return i}t.y+=s("top");t.x+=s("left");s("right");s("bottom")}function cs(t,e){const s=e.maxPadding;function i(t){const i={left:0,top:0,right:0,bottom:0};t.forEach((t=>{i[t]=Math.max(e[t],s[t])}));return i}return i(t?["left","right"]:["top","bottom"])}function hs(t,e,s,i){const n=[];let o,a,r,l,c,h;for(o=0,a=t.length,c=0;o{typeof t.beforeLayout==="function"&&t.beforeLayout()}));const h=l.reduce(((t,e)=>e.box.options&&e.box.options.display===false?t:t+1),0)||1;const d=Object.freeze({outerWidth:e,outerHeight:s,padding:n,availableWidth:o,availableHeight:a,vBoxMaxWidth:o/2/h,hBoxMaxHeight:a/2});const u=Object.assign({},n);as(u,R(i));const f=Object.assign({maxPadding:u,w:o,h:a,x:n.left,y:n.top},n);const g=is(l.concat(c),d);hs(r.fullSize,f,d,g);hs(l,f,d,g);hs(c,f,d,g)&&hs(l,f,d,g);ls(f);us(r.leftAndTop,f,d,g);f.x+=f.w;f.y+=f.h;us(r.rightAndBottom,f,d,g);t.chartArea={left:f.left,top:f.top,right:f.left+f.w,bottom:f.top+f.h,height:f.h,width:f.w};I(r.chartArea,(e=>{const s=e.box;Object.assign(s,t.chartArea);s.update(f.w,f.h,{left:0,top:0,right:0,bottom:0})}))}};class BasePlatform{acquireContext(t,e){}releaseContext(t){return false}addEventListener(t,e,s){}removeEventListener(t,e,s){}getDevicePixelRatio(){return 1}getMaximumSize(t,e,s,i){e=Math.max(0,e||t.width);s=s||t.height;return{width:e,height:Math.max(0,i?Math.floor(e/i):s)}}isAttached(t){return true}updateConfig(t){}}class BasicPlatform extends BasePlatform{acquireContext(t){return t&&t.getContext&&t.getContext("2d")||null}updateConfig(t){t.options.animation=false}}const gs="$chartjs";const ps={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};const ms=t=>t===null||t==="";function xs(t,e){const s=t.style;const i=t.getAttribute("height");const n=t.getAttribute("width");t[gs]={initial:{height:i,width:n,style:{display:s.display,height:s.height,width:s.width}}};s.display=s.display||"block";s.boxSizing=s.boxSizing||"border-box";if(ms(n)){const e=z(t,"width");e!==void 0&&(t.width=e)}if(ms(i))if(t.style.height==="")t.height=t.width/(e||2);else{const e=z(t,"height");e!==void 0&&(t.height=e)}return t}const bs=!!F&&{passive:true};function _s(t,e,s){t&&t.addEventListener(e,s,bs)}function ys(t,e,s){t&&t.canvas&&t.canvas.removeEventListener(e,s,bs)}function vs(t,e){const s=ps[t.type]||t.type;const{x:i,y:n}=O(t,e);return{type:s,chart:e,native:t,x:i!==void 0?i:null,y:n!==void 0?n:null}}function Ms(t,e){for(const s of t)if(s===e||s.contains(e))return true}function ws(t,e,s){const i=t.canvas;const n=new MutationObserver((t=>{let e=false;for(const s of t){e=e||Ms(s.addedNodes,i);e=e&&!Ms(s.removedNodes,i)}e&&s()}));n.observe(document,{childList:true,subtree:true});return n}function ks(t,e,s){const i=t.canvas;const n=new MutationObserver((t=>{let e=false;for(const s of t){e=e||Ms(s.removedNodes,i);e=e&&!Ms(s.addedNodes,i)}e&&s()}));n.observe(document,{childList:true,subtree:true});return n}const Ss=new Map;let Ds=0;function Ps(){const t=window.devicePixelRatio;if(t!==Ds){Ds=t;Ss.forEach(((e,s)=>{s.currentDevicePixelRatio!==t&&e()}))}}function Cs(t,e){Ss.size||window.addEventListener("resize",Ps);Ss.set(t,e)}function As(t){Ss.delete(t);Ss.size||window.removeEventListener("resize",Ps)}function Ls(t,e,s){const i=t.canvas;const n=i&&V(i);if(!n)return;const o=B(((t,e)=>{const i=n.clientWidth;s(t,e);i{const e=t[0];const s=e.contentRect.width;const i=e.contentRect.height;s===0&&i===0||o(s,i)}));a.observe(n);Cs(t,o);return a}function Es(t,e,s){s&&s.disconnect();e==="resize"&&As(t)}function Ts(t,e,s){const i=t.canvas;const n=B((e=>{t.ctx!==null&&s(vs(e,t))}),t);_s(i,e,n);return n}class DomPlatform extends BasePlatform{acquireContext(t,e){const s=t&&t.getContext&&t.getContext("2d");if(s&&s.canvas===t){xs(t,e);return s}return null}releaseContext(t){const e=t.canvas;if(!e[gs])return false;const s=e[gs].initial;["height","width"].forEach((t=>{const i=s[t];m(i)?e.removeAttribute(t):e.setAttribute(t,i)}));const i=s.style||{};Object.keys(i).forEach((t=>{e.style[t]=i[t]}));e.width=e.width;delete e[gs];return true}addEventListener(t,e,s){this.removeEventListener(t,e);const i=t.$proxies||(t.$proxies={});const n={attach:ws,detach:ks,resize:Ls};const o=n[e]||Ts;i[e]=o(t,e,s)}removeEventListener(t,e){const s=t.$proxies||(t.$proxies={});const i=s[e];if(!i)return;const n={attach:Es,detach:Es,resize:Es};const o=n[e]||ys;o(t,e,i);s[e]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(t,e,s,i){return N(t,e,s,i)}isAttached(t){const e=t&&V(t);return!!(e&&e.isConnected)}}function Os(t){return!W()||typeof OffscreenCanvas!=="undefined"&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}class Element{static defaults={};static defaultRoutes=void 0;x;y;active=false;options;$animations;tooltipPosition(t){const{x:e,y:s}=this.getProps(["x","y"],t);return{x:e,y:s}}hasValue(){return P(this.x)&&P(this.y)}getProps(t,e){const s=this.$animations;if(!e||!s)return this;const i={};t.forEach((t=>{i[t]=s[t]&&s[t].active()?s[t]._to:this[t]}));return i}}function Rs(t,e){const s=t.options.ticks;const i=Is(t);const n=Math.min(s.maxTicksLimit||i,i);const o=s.major.enabled?Fs(e):[];const a=o.length;const r=o[0];const l=o[a-1];const c=[];if(a>n){Vs(e,c,o,a/n);return c}const h=zs(o,e,n);if(a>0){let t,s;const i=a>1?Math.round((l-r)/(a-1)):null;Bs(e,c,h,m(i)?0:r-i,r);for(t=0,s=a-1;tn)return e}return Math.max(n,1)}function Fs(t){const e=[];let s,i;for(s=0,i=t.length;st==="left"?"right":t==="right"?"left":t;const Hs=(t,e,s)=>e==="top"||e==="left"?t[e]+s:t[e]-s;const js=(t,e)=>Math.min(e||t,t);function $s(t,e){const s=[];const i=t.length/e;const n=t.length;let o=0;for(;oa+r)return}return l}function Ys(t,e){I(t,(t=>{const s=t.gc;const i=s.length/2;let n;if(i>e){for(n=0;ns?s:e;s=i&&e>s?e:s;return{min:Y(e,Y(s,e)),max:Y(s,Y(e,s))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const t=this.chart.data;return this.options.labels||(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels||[]}getLabelItems(t=this.chart.chartArea){const e=this._labelItems||(this._labelItems=this._computeLabelItems(t));return e}beforeLayout(){this._cache={};this._dataLimitsCached=false}beforeUpdate(){X(this.options.beforeUpdate,[this])}update(t,e,s){const{beginAtZero:i,grace:n,ticks:o}=this.options;const a=o.sampleSize;this.beforeUpdate();this.maxWidth=t;this.maxHeight=e;this._margins=s=Object.assign({left:0,right:0,top:0,bottom:0},s);this.ticks=null;this._labelSizes=null;this._gridLineItems=null;this._labelItems=null;this.beforeSetDimensions();this.setDimensions();this.afterSetDimensions();this._maxLength=this.isHorizontal()?this.width+s.left+s.right:this.height+s.top+s.bottom;if(!this._dataLimitsCached){this.beforeDataLimits();this.determineDataLimits();this.afterDataLimits();this._range=G(this,n,i);this._dataLimitsCached=true}this.beforeBuildTicks();this.ticks=this.buildTicks()||[];this.afterBuildTicks();const r=a=n||s<=1||!this.isHorizontal()){this.labelRotation=i;return}const c=this._getLabelSizes();const h=c.widest.width;const d=c.highest.height;const u=K(this.chart.width-h,0,this.maxWidth);a=t.offset?this.maxWidth/s:u/(s-1);if(h+6>a){a=u/(s-(t.offset?.5:1));r=this.maxHeight-Xs(t.grid)-e.padding-Gs(t.title,this.chart.options.font);l=Math.sqrt(h*h+d*d);o=J(Math.min(Math.asin(K((c.highest.height+6)/a,-1,1)),Math.asin(K(r/l,-1,1))-Math.asin(K(d/l,-1,1))));o=Math.max(i,Math.min(n,o))}this.labelRotation=o}afterCalculateLabelRotation(){X(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){X(this.options.beforeFit,[this])}fit(){const t={width:0,height:0};const{chart:e,options:{ticks:s,title:i,grid:n}}=this;const o=this._isVisible();const a=this.isHorizontal();if(o){const o=Gs(i,e.options.font);if(a){t.width=this.maxWidth;t.height=Xs(n)+o}else{t.height=this.maxHeight;t.width=Xs(n)+o}if(s.display&&this.ticks.length){const{first:e,last:i,widest:n,highest:o}=this._getLabelSizes();const r=s.padding*2;const l=v(this.labelRotation);const c=Math.cos(l);const h=Math.sin(l);if(a){const e=s.mirror?0:h*n.width+c*o.height;t.height=Math.min(this.maxHeight,t.height+e+r)}else{const e=s.mirror?0:c*n.width+h*o.height;t.width=Math.min(this.maxWidth,t.width+e+r)}this._calculatePadding(e,i,h,c)}}this._handleMargins();if(a){this.width=this._length=e.width-this._margins.left-this._margins.right;this.height=t.height}else{this.width=t.width;this.height=this._length=e.height-this._margins.top-this._margins.bottom}}_calculatePadding(t,e,s,i){const{ticks:{align:n,padding:o},position:a}=this.options;const r=this.labelRotation!==0;const l=a!=="top"&&this.axis==="x";if(this.isHorizontal()){const a=this.getPixelForTick(0)-this.left;const c=this.right-this.getPixelForTick(this.ticks.length-1);let h=0;let d=0;if(r)if(l){h=i*t.width;d=s*e.height}else{h=s*t.height;d=i*e.width}else if(n==="start")d=e.width;else if(n==="end")h=t.width;else if(n!=="inner"){h=t.width/2;d=e.width/2}this.paddingLeft=Math.max((h-a+o)*this.width/(this.width-a),0);this.paddingRight=Math.max((d-c+o)*this.width/(this.width-c),0)}else{let s=e.height/2;let i=t.height/2;if(n==="start"){s=0;i=t.height}else if(n==="end"){s=e.height;i=0}this.paddingTop=s+o;this.paddingBottom=i+o}}_handleMargins(){if(this._margins){this._margins.left=Math.max(this.paddingLeft,this._margins.left);this._margins.top=Math.max(this.paddingTop,this._margins.top);this._margins.right=Math.max(this.paddingRight,this._margins.right);this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom)}}afterFit(){X(this.options.afterFit,[this])}isHorizontal(){const{axis:t,position:e}=this.options;return e==="top"||e==="bottom"||t==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(t){this.beforeTickToLabelConversion();this.generateTickLabels(t);let e,s;for(e=0,s=t.length;e({width:o[t]||0,height:r[t]||0});return{first:S(0),last:S(e-1),widest:S(w),highest:S(k),widths:o,heights:r}}getLabelForValue(t){return t}getPixelForValue(t,e){return NaN}getValueForPixel(t){}getPixelForTick(t){const e=this.ticks;return t<0||t>e.length-1?null:this.getPixelForValue(e[t].value)}getPixelForDecimal(t){this._reversePixels&&(t=1-t);const e=this._startPixel+t*this._length;return Z(this._alignToPixels?Q(this.chart,e,0):e)}getDecimalForPixel(t){const e=(t-this._startPixel)/this._length;return this._reversePixels?1-e:e}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:t,max:e}=this;return t<0&&e<0?e:t>0&&e>0?t:0}getContext(t){const e=this.ticks||[];if(t>=0&&ta*i?a/s:r/i:r*i0}_computeGridLineItems(t){const e=this.axis;const s=this.chart;const i=this.options;const{grid:o,position:a,border:r}=i;const l=o.offset;const c=this.isHorizontal();const d=this.ticks;const u=d.length+(l?1:0);const f=Xs(o);const g=[];const p=r.setContext(this.getContext());const m=p.display?p.width:0;const x=m/2;const b=function(t){return Q(s,t,m)};let _,y,v,M;let w,k,S,D,P,C,A,L;if(a==="top"){_=b(this.bottom);k=this.bottom-f;D=_-x;C=b(t.top)+x;L=t.bottom}else if(a==="bottom"){_=b(this.top);C=t.top;L=b(t.bottom)-x;k=_+x;D=this.top+f}else if(a==="left"){_=b(this.right);w=this.right-f;S=_-x;P=b(t.left)+x;A=t.right}else if(a==="right"){_=b(this.left);P=t.left;A=b(t.right)-x;w=_+x;S=this.left+f}else if(e==="x"){if(a==="center")_=b((t.top+t.bottom)/2+.5);else if(n(a)){const t=Object.keys(a)[0];const e=a[t];_=b(this.chart.scales[t].getPixelForValue(e))}C=t.top;L=t.bottom;k=_+x;D=k+f}else if(e==="y"){if(a==="center")_=b((t.left+t.right)/2);else if(n(a)){const t=Object.keys(a)[0];const e=a[t];_=b(this.chart.scales[t].getPixelForValue(e))}w=_-x;S=w-f;P=t.left;A=t.right}const E=h(i.ticks.maxTicksLimit,u);const T=Math.max(1,Math.ceil(u/E));for(y=0;y0&&(o-=i/2);break}f={left:o,top:n,width:i+e.width,height:s+e.height,color:t.backdropColor}}x.push({label:M,font:P,textOffset:L,options:{rotation:m,color:s,strokeColor:n,strokeWidth:c,textAlign:d,textBaseline:E,translation:[w,k],backdrop:f}})}return x}_getXAxisLabelAlignment(){const{position:t,ticks:e}=this.options;const s=-v(this.labelRotation);if(s)return t==="top"?"left":"right";let i="center";e.align==="start"?i="left":e.align==="end"?i="right":e.align==="inner"&&(i="inner");return i}_getYAxisLabelAlignment(t){const{position:e,ticks:{crossAlign:s,mirror:i,padding:n}}=this.options;const o=this._getLabelSizes();const a=t+n;const r=o.widest.width;let l;let c;if(e==="left")if(i){c=this.right+n;if(s==="near")l="left";else if(s==="center"){l="center";c+=r/2}else{l="right";c+=r}}else{c=this.right-a;if(s==="near")l="right";else if(s==="center"){l="center";c-=r/2}else{l="left";c=this.left}}else if(e==="right")if(i){c=this.left+n;if(s==="near")l="right";else if(s==="center"){l="center";c-=r/2}else{l="left";c-=r}}else{c=this.left+a;if(s==="near")l="left";else if(s==="center"){l="center";c+=r/2}else{l="right";c=this.right}}else l="right";return{textAlign:l,x:c}}_computeLabelArea(){if(this.options.ticks.mirror)return;const t=this.chart;const e=this.options.position;return e==="left"||e==="right"?{top:0,left:this.left,bottom:t.height,right:this.right}:e==="top"||e==="bottom"?{top:this.top,left:0,bottom:this.bottom,right:t.width}:void 0}drawBackground(){const{ctx:t,options:{backgroundColor:e},left:s,top:i,width:n,height:o}=this;if(e){t.save();t.fillStyle=e;t.fillRect(s,i,n,o);t.restore()}}getLineWidthForValue(t){const e=this.options.grid;if(!this._isVisible()||!e.display)return 0;const s=this.ticks;const i=s.findIndex((e=>e.value===t));if(i>=0){const t=e.setContext(this.getContext(i));return t.lineWidth}return 0}drawGrid(t){const e=this.options.grid;const s=this.ctx;const i=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(t));let n,o;const a=(t,e,i)=>{if(i.width&&i.color){s.save();s.lineWidth=i.width;s.strokeStyle=i.color;s.setLineDash(i.borderDash||[]);s.lineDashOffset=i.borderDashOffset;s.beginPath();s.moveTo(t.x,t.y);s.lineTo(e.x,e.y);s.stroke();s.restore()}};if(e.display)for(n=0,o=i.length;n{this.drawBackground();this.drawGrid(t);this.drawTitle()}},{z:i,draw:()=>{this.drawBorder()}},{z:e,draw:t=>{this.drawLabels(t)}}]:[{z:e,draw:t=>{this.draw(t)}}]}getMatchingVisibleMetas(t){const e=this.chart.getSortedVisibleDatasetMetas();const s=this.axis+"AxisID";const i=[];let n,o;for(n=0,o=e.length;n{const i=s.split(".");const n=i.pop();const a=[t].concat(i).join(".");const r=e[s].split(".");const l=r.pop();const c=r.join(".");o.route(a,n,c,l)}))}function ei(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",true);this.elements=new TypedRegistry(Element,"elements");this.plugins=new TypedRegistry(Object,"plugins");this.scales=new TypedRegistry(Scale,"scales");this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...t){this._each("register",t)}remove(...t){this._each("unregister",t)}addControllers(...t){this._each("register",t,this.controllers)}addElements(...t){this._each("register",t,this.elements)}addPlugins(...t){this._each("register",t,this.plugins)}addScales(...t){this._each("register",t,this.scales)}getController(t){return this._get(t,this.controllers,"controller")}getElement(t){return this._get(t,this.elements,"element")}getPlugin(t){return this._get(t,this.plugins,"plugin")}getScale(t){return this._get(t,this.scales,"scale")}removeControllers(...t){this._each("unregister",t,this.controllers)}removeElements(...t){this._each("unregister",t,this.elements)}removePlugins(...t){this._each("unregister",t,this.plugins)}removeScales(...t){this._each("unregister",t,this.scales)}_each(t,e,s){[...e].forEach((e=>{const i=s||this._getRegistryForType(e);s||i.isForType(e)||i===this.plugins&&e.id?this._exec(t,i,e):I(e,(e=>{const i=s||this._getRegistryForType(e);this._exec(t,i,e)}))}))}_exec(t,e,s){const i=ot(t);X(s["before"+i],[],s);e[t](s);X(s["after"+i],[],s)}_getRegistryForType(t){for(let e=0;et.filter((t=>!e.some((e=>t.plugin.id===e.plugin.id))));this._notify(i(e,s),t,"stop");this._notify(i(s,e),t,"start")}}function ii(t){const e={};const s=[];const i=Object.keys(si.plugins.items);for(let t=0;t1&&hi(t[0].toLowerCase());if(e)return e}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function fi(t,e,s){if(s[e+"AxisID"]===t)return{axis:e}}function gi(t,e){if(e.data&&e.data.datasets){const s=e.data.datasets.filter((e=>e.xAxisID===t||e.yAxisID===t));if(s.length)return fi(t,"x",s[0])||fi(t,"y",s[0])}return{}}function pi(t,e){const s=it[t.type]||{scales:{}};const i=e.scales||{};const a=ri(t.type,e);const r=Object.create(null);Object.keys(i).forEach((e=>{const l=i[e];if(!n(l))return console.error(`Invalid scale configuration for scale: ${e}`);if(l._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${e}`);const c=ui(e,l,gi(e,t),o.scales[l.type]);const h=ci(c,a);const d=s.scales||{};r[e]=at(Object.create(null),[{axis:c},l,d[c],d[h]])}));t.data.datasets.forEach((s=>{const n=s.type||t.type;const o=s.indexAxis||ri(n,e);const a=it[n]||{};const l=a.scales||{};Object.keys(l).forEach((t=>{const e=li(t,o);const n=s[e+"AxisID"]||e;r[n]=r[n]||Object.create(null);at(r[n],[{axis:e},i[n],l[t]])}))}));Object.keys(r).forEach((t=>{const e=r[t];at(e,[o.scales[e.type],o.scale])}));return r}function mi(t){const e=t.options||(t.options={});e.plugins=h(e.plugins,{});e.scales=pi(t,e)}function xi(t){t=t||{};t.datasets=t.datasets||[];t.labels=t.labels||[];return t}function bi(t){t=t||{};t.data=xi(t.data);mi(t);return t}const _i=new Map;const yi=new Set;function vi(t,e){let s=_i.get(t);if(!s){s=e();_i.set(t,s);yi.add(s)}return s}const Mi=(t,e,s)=>{const i=f(e,s);i!==void 0&&t.add(i)};class Config{constructor(t){this._config=bi(t);this._scopeCache=new Map;this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(t){this._config.type=t}get data(){return this._config.data}set data(t){this._config.data=xi(t)}get options(){return this._config.options}set options(t){this._config.options=t}get plugins(){return this._config.plugins}update(){const t=this._config;this.clearCache();mi(t)}clearCache(){this._scopeCache.clear();this._resolverCache.clear()}datasetScopeKeys(t){return vi(t,(()=>[[`datasets.${t}`,""]]))}datasetAnimationScopeKeys(t,e){return vi(`${t}.transition.${e}`,(()=>[[`datasets.${t}.transitions.${e}`,`transitions.${e}`],[`datasets.${t}`,""]]))}datasetElementScopeKeys(t,e){return vi(`${t}-${e}`,(()=>[[`datasets.${t}.elements.${e}`,`datasets.${t}`,`elements.${e}`,""]]))}pluginScopeKeys(t){const e=t.id;const s=this.type;return vi(`${s}-plugin-${e}`,(()=>[[`plugins.${e}`,...t.additionalOptionScopes||[]]]))}_cachedScopes(t,e){const s=this._scopeCache;let i=s.get(t);if(!i||e){i=new Map;s.set(t,i)}return i}getOptionScopes(t,e,s){const{options:i,type:n}=this;const a=this._cachedScopes(t,s);const r=a.get(e);if(r)return r;const l=new Set;e.forEach((e=>{if(t){l.add(t);e.forEach((e=>Mi(l,t,e)))}e.forEach((t=>Mi(l,i,t)));e.forEach((t=>Mi(l,it[n]||{},t)));e.forEach((t=>Mi(l,o,t)));e.forEach((t=>Mi(l,rt,t)))}));const c=Array.from(l);c.length===0&&c.push(Object.create(null));yi.has(e)&&a.set(e,c);return c}chartOptionScopes(){const{options:t,type:e}=this;return[t,it[e]||{},o.datasets[e]||{},{type:e},o,rt]}resolveNamedOptions(t,e,s,i=[""]){const n={$shared:true};const{resolver:o,subPrefixes:a}=wi(this._resolverCache,t,i);let r=o;if(Si(o,e)){n.$shared=false;s=lt(s)?s():s;const e=this.createResolver(t,s,a);r=ct(o,s,e)}for(const t of e)n[t]=r[t];return n}createResolver(t,e,s=[""],i){const{resolver:o}=wi(this._resolverCache,t,s);return n(e)?ct(o,e,void 0,i):o}}function wi(t,e,s){let i=t.get(e);if(!i){i=new Map;t.set(e,i)}const n=s.join();let o=i.get(n);if(!o){const t=ht(e,s);o={resolver:t,subPrefixes:s.filter((t=>!t.toLowerCase().includes("hover")))};i.set(n,o)}return o}const ki=t=>n(t)&&Object.getOwnPropertyNames(t).some((e=>lt(t[e])));function Si(t,e){const{isScriptable:s,isIndexable:i}=dt(t);for(const n of e){const e=s(n);const o=i(n);const r=(o||e)&&t[n];if(e&&(lt(r)||ki(r))||o&&a(r))return true}return false}var Di="4.5.1";const Pi=["top","bottom","left","right","chartArea"];function Ci(t,e){return t==="top"||t==="bottom"||Pi.indexOf(t)===-1&&e==="x"}function Ai(t,e){return function(s,i){return s[t]===i[t]?s[e]-i[e]:s[t]-i[t]}}function Li(t){const e=t.chart;const s=e.options.animation;e.notifyPlugins("afterRender");X(s&&s.onComplete,[t],e)}function Ei(t){const e=t.chart;const s=e.options.animation;X(s&&s.onProgress,[t],e)}function Ti(t){W()&&typeof t==="string"?t=document.getElementById(t):t&&t.length&&(t=t[0]);t&&t.canvas&&(t=t.canvas);return t}const Oi={};const Ri=t=>{const e=Ti(t);return Object.values(Oi).filter((t=>t.canvas===e)).pop()};function Ii(t,e,s){const i=Object.keys(t);for(const n of i){const i=+n;if(i>=e){const o=t[n];delete t[n];(s>0||i>e)&&(t[i+s]=o)}}}function zi(t,e,s,i){return s&&t.type!=="mouseout"?i?e:t:null}class Chart{static defaults=o;static instances=Oi;static overrides=it;static registry=si;static version=Di;static getChart=Ri;static register(...t){si.add(...t);Fi()}static unregister(...t){si.remove(...t);Fi()}constructor(t,e){const s=this.config=new Config(e);const i=Ti(t);const n=Ri(i);if(n)throw new Error("Canvas is already in use. Chart with ID '"+n.id+"' must be destroyed before the canvas with ID '"+n.canvas.id+"' can be reused.");const o=s.createResolver(s.chartOptionScopes(),this.getContext());this.platform=new(s.platform||Os(i));this.platform.updateConfig(s);const a=this.platform.acquireContext(i,o.aspectRatio);const r=a&&a.canvas;const l=r&&r.height;const c=r&&r.width;this.id=ut();this.ctx=a;this.canvas=r;this.width=c;this.height=l;this._options=o;this._aspectRatio=this.aspectRatio;this._layers=[];this._metasets=[];this._stacks=void 0;this.boxes=[];this.currentDevicePixelRatio=void 0;this.chartArea=void 0;this._active=[];this._lastEvent=void 0;this._listeners={};this._responsiveListeners=void 0;this._sortedMetasets=[];this.scales={};this._plugins=new PluginService;this.$proxies={};this._hiddenIndices={};this.attached=false;this._animationsDisabled=void 0;this.$context=void 0;this._doResize=ft((t=>this.update(t)),o.resizeDelay||0);this._dataChanges=[];Oi[this.id]=this;if(a&&r){Qt.listen(this,"complete",Li);Qt.listen(this,"progress",Ei);this._initialize();this.attached&&this.update()}else console.error("Failed to create chart: can't acquire context from the given item")}get aspectRatio(){const{options:{aspectRatio:t,maintainAspectRatio:e},width:s,height:i,_aspectRatio:n}=this;return m(t)?e&&n?n:i?s/i:null:t}get data(){return this.config.data}set data(t){this.config.data=t}get options(){return this._options}set options(t){this.config.options=t}get registry(){return si}_initialize(){this.notifyPlugins("beforeInit");this.options.responsive?this.resize():gt(this,this.options.devicePixelRatio);this.bindEvents();this.notifyPlugins("afterInit");return this}clear(){pt(this.canvas,this.ctx);return this}stop(){Qt.stop(this);return this}resize(t,e){Qt.running(this)?this._resizeBeforeDraw={width:t,height:e}:this._resize(t,e)}_resize(t,e){const s=this.options;const i=this.canvas;const n=s.maintainAspectRatio&&this.aspectRatio;const o=this.platform.getMaximumSize(i,t,e,n);const a=s.devicePixelRatio||this.platform.getDevicePixelRatio();const r=this.width?"resize":"attach";this.width=o.width;this.height=o.height;this._aspectRatio=this.aspectRatio;if(gt(this,a,true)){this.notifyPlugins("resize",{size:o});X(s.onResize,[this,o],this);this.attached&&this._doResize(r)&&this.render()}}ensureScalesHaveIDs(){const t=this.options;const e=t.scales||{};I(e,((t,e)=>{t.id=e}))}buildOrUpdateScales(){const t=this.options;const e=t.scales;const s=this.scales;const i=Object.keys(s).reduce(((t,e)=>{t[e]=false;return t}),{});let n=[];e&&(n=n.concat(Object.keys(e).map((t=>{const s=e[t];const i=ui(t,s);const n=i==="r";const o=i==="x";return{options:s,dposition:n?"chartArea":o?"bottom":"left",dtype:n?"radialLinear":o?"category":"linear"}}))));I(n,(e=>{const n=e.options;const o=n.id;const a=ui(o,n);const r=h(n.type,e.dtype);n.position!==void 0&&Ci(n.position,a)===Ci(e.dposition)||(n.position=e.dposition);i[o]=true;let l=null;if(o in s&&s[o].type===r)l=s[o];else{const t=si.getScale(r);l=new t({id:o,type:r,ctx:this.ctx,chart:this});s[l.id]=l}l.init(n,t)}));I(i,((t,e)=>{t||delete s[e]}));I(s,(t=>{fs.configure(this,t,t.options);fs.addBox(this,t)}))}_updateMetasets(){const t=this._metasets;const e=this.data.datasets.length;const s=t.length;t.sort(((t,e)=>t.index-e.index));if(s>e){for(let t=e;te.length&&delete this._stacks;t.forEach(((t,s)=>{e.filter((e=>e===t._dataset)).length===0&&this._destroyDatasetMeta(s)}))}buildOrUpdateControllers(){const t=[];const e=this.data.datasets;let s,i;this._removeUnreferencedMetasets();for(s=0,i=e.length;s{this.getDatasetMeta(e).controller.reset()}),this)}reset(){this._resetElements();this.notifyPlugins("reset")}update(t){const e=this.config;e.update();const s=this._options=e.createResolver(e.chartOptionScopes(),this.getContext());const i=this._animationsDisabled=!s.animation;this._updateScales();this._checkEventBindings();this._updateHiddenIndices();this._plugins.invalidate();if(this.notifyPlugins("beforeUpdate",{mode:t,cancelable:true})===false)return;const n=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let t=0,e=this.data.datasets.length;t{t.reset()}));this._updateDatasets(t);this.notifyPlugins("afterUpdate",{mode:t});this._layers.sort(Ai("z","_idx"));const{_active:a,_lastEvent:r}=this;r?this._eventHandler(r,true):a.length&&this._updateHoverStyles(a,a,true);this.render()}_updateScales(){I(this.scales,(t=>{fs.removeBox(this,t)}));this.ensureScalesHaveIDs();this.buildOrUpdateScales()}_checkEventBindings(){const t=this.options;const e=new Set(Object.keys(this._listeners));const s=new Set(t.events);if(!mt(e,s)||!!this._responsiveListeners!==t.responsive){this.unbindEvents();this.bindEvents()}}_updateHiddenIndices(){const{_hiddenIndices:t}=this;const e=this._getUniformDataChanges()||[];for(const{method:s,start:i,count:n}of e){const e=s==="_removeElements"?-n:n;Ii(t,i,e)}}_getUniformDataChanges(){const t=this._dataChanges;if(!t||!t.length)return;this._dataChanges=[];const e=this.data.datasets.length;const s=e=>new Set(t.filter((t=>t[0]===e)).map(((t,e)=>e+","+t.splice(1).join(","))));const i=s(0);for(let t=1;tt.split(","))).map((t=>({method:t[1],start:+t[2],count:+t[3]})))}_updateLayout(t){if(this.notifyPlugins("beforeLayout",{cancelable:true})===false)return;fs.update(this,this.width,this.height,t);const e=this.chartArea;const s=e.width<=0||e.height<=0;this._layers=[];I(this.boxes,(t=>{if(!s||t.position!=="chartArea"){t.configure&&t.configure();this._layers.push(...t._layers())}}),this);this._layers.forEach(((t,e)=>{t._idx=e}));this.notifyPlugins("afterLayout")}_updateDatasets(t){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:t,cancelable:true})!==false){for(let t=0,e=this.data.datasets.length;t=0;--e)this._drawDataset(t[e]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(t){const e=this.ctx;const s={meta:t,index:t.index,cancelable:true};const i=xt(this,t);if(this.notifyPlugins("beforeDatasetDraw",s)!==false){i&&tt(e,i);t.controller.draw();i&&st(e);s.cancelable=false;this.notifyPlugins("afterDatasetDraw",s)}}isPointInArea(t){return E(t,this.chartArea,this._minPadding)}getElementsAtEventForMode(t,e,s,i){const n=Je.modes[e];return typeof n==="function"?n(this,t,s,i):[]}getDatasetMeta(t){const e=this.data.datasets[t];const s=this._metasets;let i=s.filter((t=>t&&t._dataset===e)).pop();if(!i){i={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:e&&e.order||0,index:t,_dataset:e,_parsed:[],_sorted:false};s.push(i)}return i}getContext(){return this.$context||(this.$context=c(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(t){const e=this.data.datasets[t];if(!e)return false;const s=this.getDatasetMeta(t);return typeof s.hidden==="boolean"?!s.hidden:!e.hidden}setDatasetVisibility(t,e){const s=this.getDatasetMeta(t);s.hidden=!e}toggleDataVisibility(t){this._hiddenIndices[t]=!this._hiddenIndices[t]}getDataVisibility(t){return!this._hiddenIndices[t]}_updateVisibility(t,e,s){const i=s?"show":"hide";const n=this.getDatasetMeta(t);const o=n.controller._resolveAnimations(void 0,i);if(g(e)){n.data[e].hidden=!s;this.update()}else{this.setDatasetVisibility(t,s);o.update(n,{visible:s});this.update((e=>e.datasetIndex===t?i:void 0))}}hide(t,e){this._updateVisibility(t,e,false)}show(t,e){this._updateVisibility(t,e,true)}_destroyDatasetMeta(t){const e=this._metasets[t];e&&e.controller&&e.controller._destroy();delete this._metasets[t]}_stop(){let t,e;this.stop();Qt.remove(this);for(t=0,e=this.data.datasets.length;t{e.addEventListener(this,s,i);t[s]=i};const i=(t,e,s)=>{t.offsetX=e;t.offsetY=s;this._eventHandler(t)};I(this.options.events,(t=>s(t,i)))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const t=this._responsiveListeners;const e=this.platform;const s=(s,i)=>{e.addEventListener(this,s,i);t[s]=i};const i=(s,i)=>{if(t[s]){e.removeEventListener(this,s,i);delete t[s]}};const n=(t,e)=>{this.canvas&&this.resize(t,e)};let o;const a=()=>{i("attach",a);this.attached=true;this.resize();s("resize",n);s("detach",o)};o=()=>{this.attached=false;i("resize",n);this._stop();this._resize(0,0);s("attach",a)};e.isAttached(this.canvas)?a():o()}unbindEvents(){I(this._listeners,((t,e)=>{this.platform.removeEventListener(this,e,t)}));this._listeners={};I(this._responsiveListeners,((t,e)=>{this.platform.removeEventListener(this,e,t)}));this._responsiveListeners=void 0}updateHoverStyle(t,e,s){const i=s?"set":"remove";let n,o,a,r;if(e==="dataset"){n=this.getDatasetMeta(t[0].datasetIndex);n.controller["_"+i+"DatasetHoverStyle"]()}for(a=0,r=t.length;a{const s=this.getDatasetMeta(t);if(!s)throw new Error("No dataset found at index "+t);return{datasetIndex:t,element:s.data[e],index:e}}));const i=!bt(s,e);if(i){this._active=s;this._lastEvent=null;this._updateHoverStyles(s,e)}}notifyPlugins(t,e,s){return this._plugins.notify(this,t,e,s)}isPluginEnabled(t){return this._plugins._cache.filter((e=>e.plugin.id===t)).length===1}_updateHoverStyles(t,e,s){const i=this.options.hover;const n=(t,e)=>t.filter((t=>!e.some((e=>t.datasetIndex===e.datasetIndex&&t.index===e.index))));const o=n(e,t);const a=s?t:n(t,e);o.length&&this.updateHoverStyle(o,i.mode,false);a.length&&i.mode&&this.updateHoverStyle(a,i.mode,true)}_eventHandler(t,e){const s={event:t,replay:e,cancelable:true,inChartArea:this.isPointInArea(t)};const i=e=>(e.options.events||this.options.events).includes(t.native.type);if(this.notifyPlugins("beforeEvent",s,i)===false)return;const n=this._handleEvent(t,e,s.inChartArea);s.cancelable=false;this.notifyPlugins("afterEvent",s,i);(n||s.changed)&&this.render();return this}_handleEvent(t,e,s){const{_active:i=[],options:n}=this;const o=e;const a=this._getActiveElements(t,i,s,o);const r=_t(t);const l=zi(t,this._lastEvent,s,r);if(s){this._lastEvent=null;X(n.onHover,[t,a,this],this);r&&X(n.onClick,[t,a,this],this)}const c=!bt(a,i);if(c||e){this._active=a;this._updateHoverStyles(a,i,e)}this._lastEvent=l;return c}_getActiveElements(t,e,s,i){if(t.type==="mouseout")return[];if(!s)return e;const n=this.options.hover;return this.getElementsAtEventForMode(t,n.mode,n,i)}}function Fi(){return I(Chart.instances,(t=>t._plugins.invalidate()))}function Vi(t,e,s){const{startAngle:i,x:n,y:o,outerRadius:a,innerRadius:r,options:l}=e;const{borderWidth:c,borderJoinStyle:h}=l;const d=Math.min(c/a,yt(i-s));t.beginPath();t.arc(n,o,a-c/2,i+d/2,s-d/2);if(r>0){const e=Math.min(c/r,yt(i-s));t.arc(n,o,r+c/2,s-e/2,i+e/2,true)}else{const e=Math.min(c/2,a*yt(i-s));if(h==="round")t.arc(n,o,e,s-y/2,i+y/2,true);else if(h==="bevel"){const a=2*e*e;const r=-a*Math.cos(s+y/2)+n;const l=-a*Math.sin(s+y/2)+o;const c=a*Math.cos(i+y/2)+n;const h=a*Math.sin(i+y/2)+o;t.lineTo(r,l);t.lineTo(c,h)}}t.closePath();t.moveTo(0,0);t.rect(0,0,t.canvas.width,t.canvas.height);t.clip("evenodd")}function Bi(t,e,s){const{startAngle:i,pixelMargin:n,x:o,y:a,outerRadius:r,innerRadius:l}=e;let c=n/r;t.beginPath();t.arc(o,a,r,i-c,s+c);if(l>n){c=n/l;t.arc(o,a,l,s+c,i-c,true)}else t.arc(o,a,n,s+_,i-_);t.closePath();t.clip()}function Ni(t){return vt(t,["outerStart","outerEnd","innerStart","innerEnd"])}function Wi(t,e,s,i){const n=Ni(t.options.borderRadius);const o=(s-e)/2;const a=Math.min(o,i*e/2);const r=t=>{const e=(s-Math.min(o,t))*i/2;return K(t,0,Math.min(o,e))};return{outerStart:r(n.outerStart),outerEnd:r(n.outerEnd),innerStart:K(n.innerStart,0,a),innerEnd:K(n.innerEnd,0,a)}}function Hi(t,e,s,i){return{x:s+t*Math.cos(e),y:i+t*Math.sin(e)}}function ji(t,e,s,i,n,o){const{x:a,y:r,startAngle:l,pixelMargin:c,innerRadius:h}=e;const d=Math.max(e.outerRadius+i+s-c,0);const u=h>0?h+i+s+c:0;let f=0;const g=n-l;if(i){const t=h>0?h-i:0;const e=d>0?d-i:0;const s=(t+e)/2;const n=s!==0?g*s/(s+i):g;f=(g-n)/2}const p=Math.max(.001,g*d-s/y)/d;const m=(g-p)/2;const x=l+m+f;const b=n-m-f;const{outerStart:v,outerEnd:M,innerStart:w,innerEnd:k}=Wi(e,u,d,b-x);const S=d-v;const D=d-M;const P=x+v/S;const C=b-M/D;const A=u+w;const L=u+k;const E=x+w/A;const T=b-k/L;t.beginPath();if(o){const e=(P+C)/2;t.arc(a,r,d,P,e);t.arc(a,r,d,e,C);if(M>0){const e=Hi(D,C,a,r);t.arc(e.x,e.y,M,C,b+_)}const s=Hi(L,b,a,r);t.lineTo(s.x,s.y);if(k>0){const e=Hi(L,T,a,r);t.arc(e.x,e.y,k,b+_,T+Math.PI)}const i=(b-k/u+(x+w/u))/2;t.arc(a,r,u,b-k/u,i,true);t.arc(a,r,u,i,x+w/u,true);if(w>0){const e=Hi(A,E,a,r);t.arc(e.x,e.y,w,E+Math.PI,x-_)}const n=Hi(S,x,a,r);t.lineTo(n.x,n.y);if(v>0){const e=Hi(S,P,a,r);t.arc(e.x,e.y,v,x-_,P)}}else{t.moveTo(a,r);const e=Math.cos(P)*d+a;const s=Math.sin(P)*d+r;t.lineTo(e,s);const i=Math.cos(C)*d+a;const n=Math.sin(C)*d+r;t.lineTo(i,n)}t.closePath()}function $i(t,e,s,i,n){const{fullCircles:o,startAngle:a,circumference:r}=e;let l=e.endAngle;if(o){ji(t,e,s,i,l,n);for(let e=0;e=y&&f===0&&h!=="miter"&&Vi(t,e,p);if(!o){ji(t,e,s,i,p,n);t.stroke()}}class ArcElement extends Element{static id="arc";static defaults={borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:true,selfJoin:false};static defaultRoutes={backgroundColor:"backgroundColor"};static descriptors={_scriptable:true,_indexable:t=>t!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(t){super();this.options=void 0;this.circumference=void 0;this.startAngle=void 0;this.endAngle=void 0;this.innerRadius=void 0;this.outerRadius=void 0;this.pixelMargin=0;this.fullCircles=0;t&&Object.assign(this,t)}inRange(t,e,s){const i=this.getProps(["x","y"],s);const{angle:n,distance:o}=T(i,{x:t,y:e});const{startAngle:a,endAngle:r,innerRadius:l,outerRadius:c,circumference:d}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],s);const u=(this.options.spacing+this.options.borderWidth)/2;const f=h(d,r-a);const g=b(n,a,r)&&a!==r;const p=f>=x||g;const m=Mt(o,l+u,c+u);return p&&m}getCenterPoint(t){const{x:e,y:s,startAngle:i,endAngle:n,innerRadius:o,outerRadius:a}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],t);const{offset:r,spacing:l}=this.options;const c=(i+n)/2;const h=(o+a+l+r)/2;return{x:e+Math.cos(c)*h,y:s+Math.sin(c)*h}}tooltipPosition(t){return this.getCenterPoint(t)}draw(t){const{options:e,circumference:s}=this;const i=(e.offset||0)/4;const n=(e.spacing||0)/2;const o=e.circular;this.pixelMargin=e.borderAlign==="inner"?.33:0;this.fullCircles=s>x?Math.floor(s/x):0;if(s===0||this.innerRadius<0||this.outerRadius<0)return;t.save();const a=(this.startAngle+this.endAngle)/2;t.translate(Math.cos(a)*i,Math.sin(a)*i);const r=1-Math.sin(Math.min(y,s||0));const l=i*r;t.fillStyle=e.backgroundColor;t.strokeStyle=e.borderColor;$i(t,this,l,n,o);Ui(t,this,l,n,o);t.restore()}}function Yi(t,e,s=e){t.lineCap=h(s.borderCapStyle,e.borderCapStyle);t.setLineDash(h(s.borderDash,e.borderDash));t.lineDashOffset=h(s.borderDashOffset,e.borderDashOffset);t.lineJoin=h(s.borderJoinStyle,e.borderJoinStyle);t.lineWidth=h(s.borderWidth,e.borderWidth);t.strokeStyle=h(s.borderColor,e.borderColor)}function Xi(t,e,s){t.lineTo(s.x,s.y)}function Gi(t){return t.stepped?wt:t.tension||t.cubicInterpolationMode==="monotone"?kt:Xi}function Ki(t,e,s={}){const i=t.length;const{start:n=0,end:o=i-1}=s;const{start:a,end:r}=e;const l=Math.max(n,a);const c=Math.min(o,r);const h=nr&&o>r;return{count:i,start:l,loop:e.loop,ilen:c(a+(c?r-t:t))%o;const _=()=>{if(p!==m){t.lineTo(h,m);t.lineTo(h,p);t.lineTo(h,x)}};if(l){f=n[b(0)];t.moveTo(f.x,f.y)}for(u=0;u<=r;++u){f=n[b(u)];if(f.skip)continue;const e=f.x;const s=f.y;const i=e|0;if(i===g){sm&&(m=s);h=(d*h+e)/++d}else{_();t.lineTo(e,s);g=i;d=0;p=m=s}x=s}_()}function Zi(t){const e=t.options;const s=e.borderDash&&e.borderDash.length;const i=!t._decimated&&!t._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!s;return i?qi:Ji}function Qi(t){return t.stepped?St:t.tension||t.cubicInterpolationMode==="monotone"?Dt:Pt}function tn(t,e,s,i){let n=e._path;if(!n){n=e._path=new Path2D;e.path(n,s,i)&&n.closePath()}Yi(t,e.options);t.stroke(n)}function en(t,e,s,i){const{segments:n,options:o}=e;const a=Zi(e);for(const r of n){Yi(t,o,r.style);t.beginPath();a(t,e,r,{start:s,end:s+i-1})&&t.closePath();t.stroke()}}const sn=typeof Path2D==="function";function nn(t,e,s,i){sn&&!e.options.segment?tn(t,e,s,i):en(t,e,s,i)}class LineElement extends Element{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:true,cubicInterpolationMode:"default",fill:false,spanGaps:false,stepped:false,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:true,_indexable:t=>t!=="borderDash"&&t!=="fill"};constructor(t){super();this.animated=true;this.options=void 0;this._chart=void 0;this._loop=void 0;this._fullLoop=void 0;this._path=void 0;this._points=void 0;this._segments=void 0;this._decimated=false;this._pointsUpdated=false;this._datasetIndex=void 0;t&&Object.assign(this,t)}updateControlPoints(t,e){const s=this.options;if((s.tension||s.cubicInterpolationMode==="monotone")&&!s.stepped&&!this._pointsUpdated){const i=s.spanGaps?this._loop:this._fullLoop;Ct(this._points,s,t,i,e);this._pointsUpdated=true}}set points(t){this._points=t;delete this._segments;delete this._path;this._pointsUpdated=false}get points(){return this._points}get segments(){return this._segments||(this._segments=At(this,this.options.segment))}first(){const t=this.segments;const e=this.points;return t.length&&e[t[0].start]}last(){const t=this.segments;const e=this.points;const s=t.length;return s&&e[t[s-1].end]}interpolate(t,e){const s=this.options;const i=t[e];const n=this.points;const o=Lt(this,{property:e,start:i,end:i});if(!o.length)return;const a=[];const r=Qi(s);let l,c;for(l=0,c=o.length;lt.replace("rgb(","rgba(").replace(")",", 0.5)")));function bn(t){return mn[t%mn.length]}function _n(t){return xn[t%xn.length]}function yn(t,e){t.borderColor=bn(e);t.backgroundColor=_n(e);return++e}function vn(t,e){t.backgroundColor=t.data.map((()=>bn(e++)));return e}function Mn(t,e){t.backgroundColor=t.data.map((()=>_n(e++)));return e}function wn(t){let e=0;return(s,i)=>{const n=t.getDatasetMeta(i).controller;n instanceof DoughnutController?e=vn(s,e):n instanceof PolarAreaController?e=Mn(s,e):n&&(e=yn(s,e))}}function kn(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return true;return false}function Sn(t){return t&&(t.borderColor||t.backgroundColor)}function Dn(){return o.borderColor!=="rgba(0,0,0,0.1)"||o.backgroundColor!=="rgba(0,0,0,0.1)"}var Pn={id:"colors",defaults:{enabled:true,forceOverride:false},beforeLayout(t,e,s){if(!s.enabled)return;const{data:{datasets:i},options:n}=t.config;const{elements:o}=n;const a=kn(i)||Sn(n)||o&&kn(o)||Dn();if(!s.forceOverride&&a)return;const r=wn(t);i.forEach(r)}};function Cn(t,e,s,i,n){const o=n.samples||i;if(o>=s)return t.slice(e,e+s);const a=[];const r=(s-2)/(o-2);let l=0;const c=e+s-1;let h=e;let d,u,f,g,p;a[l++]=t[h];for(d=0;df){f=g;u=t[o];p=o}}a[l++]=u;h=p}a[l++]=t[c];return a}function An(t,e,s,i){let n=0;let o=0;let a,r,l,c,h,d,u,f,g,p;const x=[];const b=e+s-1;const _=t[e].x;const y=t[b].x;const v=y-_;for(a=e;ap){p=c;u=a}n=(o*n+r.x)/++o}else{const s=a-1;if(!m(d)&&!m(u)){const e=Math.min(d,u);const i=Math.max(d,u);e!==f&&e!==s&&x.push({...t[e],x:n});i!==f&&i!==s&&x.push({...t[i],x:n})}a>0&&s!==f&&x.push(t[s]);x.push(r);h=e;o=0;g=p=c;d=u=f=a}}return x}function Ln(t){if(t._decimated){const e=t._data;delete t._decimated;delete t._data;Object.defineProperty(t,"data",{configurable:true,enumerable:true,writable:true,value:e})}}function En(t){t.data.datasets.forEach((t=>{Ln(t)}))}function Tn(t,e){const s=e.length;let i=0;let n;const{iScale:o}=t;const{min:a,max:r,minDefined:l,maxDefined:c}=o.getUserBounds();l&&(i=K(L(e,o.axis,a).lo,0,s-1));n=c?K(L(e,o.axis,r).hi+1,i,s)-i:s-i;return{start:i,count:n}}var On={id:"decimation",defaults:{algorithm:"min-max",enabled:false},beforeElementsUpdate:(t,e,i)=>{if(!i.enabled){En(t);return}const n=t.width;t.data.datasets.forEach(((e,o)=>{const{_data:a,indexAxis:r}=e;const l=t.getDatasetMeta(o);const c=a||e.data;if(s([r,t.options.indexAxis])==="y")return;if(!l.controller.supportsDecimation)return;const h=t.scales[l.xAxisID];if(h.type!=="linear"&&h.type!=="time")return;if(t.options.parsing)return;let{start:d,count:u}=Tn(l,c);const f=i.threshold||4*n;if(u<=f){Ln(e);return}if(m(a)){e._data=c;delete e.data;Object.defineProperty(e,"data",{configurable:true,enumerable:true,get:function(){return this._decimated},set:function(t){this._data=t}})}let g;switch(i.algorithm){case"lttb":g=Cn(c,d,u,n,i);break;case"min-max":g=An(c,d,u,n);break;default:throw new Error(`Unsupported decimation algorithm '${i.algorithm}'`)}e._decimated=g}))},destroy(t){En(t)}};function Rn(t,e,s){const i=t.segments;const n=t.points;const o=e.points;const a=[];for(const t of i){let{start:i,end:r}=t;r=Fn(i,r,n);const l=In(s,n[i],n[r],t.loop);if(!e.segments){a.push({source:t,target:l,start:n[i],end:n[r]});continue}const c=Lt(e,l);for(const e of c){const i=In(s,o[e.start],o[e.end],e.loop);const r=It(t,n,i);for(const t of r)a.push({source:t,target:e,start:{[s]:Vn(l,i,"start",Math.max)},end:{[s]:Vn(l,i,"end",Math.min)}})}}return a}function In(t,e,s,i){if(i)return;let n=e[t];let o=s[t];if(t==="angle"){n=yt(n);o=yt(o)}return{property:t,start:n,end:o}}function zn(t,e){const{x:s=null,y:i=null}=t||{};const n=e.points;const o=[];e.segments.forEach((({start:t,end:e})=>{e=Fn(t,e,n);const a=n[t];const r=n[e];if(i!==null){o.push({x:a.x,y:i});o.push({x:r.x,y:i})}else if(s!==null){o.push({x:s,y:a.y});o.push({x:s,y:r.y})}}));return o}function Fn(t,e,s){for(;e>t;e--){const t=s[e];if(!isNaN(t.x)&&!isNaN(t.y))break}return e}function Vn(t,e,s,i){return t&&e?i(t[s],e[s]):t?t[s]:e?e[s]:0}function Bn(t,e){let s=[];let i=false;if(a(t)){i=true;s=t}else s=zn(t,e);return s.length?new LineElement({points:s,options:{tension:0},_loop:i,_fullLoop:i}):null}function Nn(t){return t&&t.fill!==false}function Wn(t,e,s){const i=t[e];let n=i.fill;const o=[e];let a;if(!s)return n;while(n!==false&&o.indexOf(n)===-1){if(!r(n))return n;a=t[n];if(!a)return false;if(a.visible)return n;o.push(n);n=a.fill}return false}function Hn(t,e,s){const i=Yn(t);if(n(i))return!isNaN(i.value)&&i;let o=parseFloat(i);return r(o)&&Math.floor(o)===o?jn(i[0],e,o,s):["origin","start","end","stack","shape"].indexOf(i)>=0&&i}function jn(t,e,s,i){t!=="-"&&t!=="+"||(s=e+s);return!(s===e||s<0||s>=i)&&s}function $n(t,e){let s=null;t==="start"?s=e.bottom:t==="end"?s=e.top:n(t)?s=e.getPixelForValue(t.value):e.getBasePixel&&(s=e.getBasePixel());return s}function Un(t,e,s){let i;i=t==="start"?s:t==="end"?e.options.reverse?e.min:e.max:n(t)?t.value:e.getBaseValue();return i}function Yn(t){const e=t.options;const s=e.fill;let i=h(s&&s.target,s);i===void 0&&(i=!!e.backgroundColor);return i!==false&&i!==null&&(i===true?"origin":i)}function Xn(t){const{scale:e,index:s,line:i}=t;const n=[];const o=i.segments;const a=i.points;const r=Gn(e,s);r.push(Bn({x:null,y:e.bottom},i));for(let t=0;t=0;--e){const s=n[e].$filler;if(s){s.line.updateControlPoints(o,s.axis);i&&s.fill&&so(t.ctx,s,o)}}},beforeDatasetsDraw(t,e,s){if(s.drawTime!=="beforeDatasetsDraw")return;const i=t.getSortedVisibleDatasetMetas();for(let e=i.length-1;e>=0;--e){const s=i[e].$filler;Nn(s)&&so(t.ctx,s,t.chartArea)}},beforeDatasetDraw(t,e,s){const i=e.meta.$filler;Nn(i)&&s.drawTime==="beforeDatasetDraw"&&so(t.ctx,i,t.chartArea)},defaults:{propagate:true,drawTime:"beforeDatasetDraw"}};const ho=(t,e)=>{let{boxHeight:s=e,boxWidth:i=e}=t;if(t.usePointStyle){s=Math.min(s,e);i=t.pointStyleWidth||Math.min(i,e)}return{boxWidth:i,boxHeight:s,itemHeight:Math.max(e,s)}};const uo=(t,e)=>t!==null&&e!==null&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element{constructor(t){super();this._added=false;this.legendHitBoxes=[];this._hoveredItem=null;this.doughnutMode=false;this.chart=t.chart;this.options=t.options;this.ctx=t.ctx;this.legendItems=void 0;this.columnSizes=void 0;this.lineWidths=void 0;this.maxHeight=void 0;this.maxWidth=void 0;this.top=void 0;this.bottom=void 0;this.left=void 0;this.right=void 0;this.height=void 0;this.width=void 0;this._margins=void 0;this.position=void 0;this.weight=void 0;this.fullSize=void 0}update(t,e,s){this.maxWidth=t;this.maxHeight=e;this._margins=s;this.setDimensions();this.buildLabels();this.fit()}setDimensions(){if(this.isHorizontal()){this.width=this.maxWidth;this.left=this._margins.left;this.right=this.width}else{this.height=this.maxHeight;this.top=this._margins.top;this.bottom=this.height}}buildLabels(){const t=this.options.labels||{};let e=X(t.generateLabels,[this.chart],this)||[];t.filter&&(e=e.filter((e=>t.filter(e,this.chart.data))));t.sort&&(e=e.sort(((e,s)=>t.sort(e,s,this.chart.data))));this.options.reverse&&e.reverse();this.legendItems=e}fit(){const{options:t,ctx:e}=this;if(!t.display){this.width=this.height=0;return}const s=t.labels;const i=j(s.font);const n=i.size;const o=this._computeTitleHeight();const{boxWidth:a,itemHeight:r}=ho(s,n);let l,c;e.font=i.string;if(this.isHorizontal()){l=this.maxWidth;c=this._fitRows(o,n,a,r)+10}else{c=this.maxHeight;l=this._fitCols(o,i,a,r)+10}this.width=Math.min(l,t.maxWidth||this.maxWidth);this.height=Math.min(c,t.maxHeight||this.maxHeight)}_fitRows(t,e,s,i){const{ctx:n,maxWidth:o,options:{labels:{padding:a}}}=this;const r=this.legendHitBoxes=[];const l=this.lineWidths=[0];const c=i+a;let h=t;n.textAlign="left";n.textBaseline="middle";let d=-1;let u=-c;this.legendItems.forEach(((t,f)=>{const g=s+e/2+n.measureText(t.text).width;if(f===0||l[l.length-1]+g+2*a>o){h+=c;l[l.length-(f>0?0:1)]=0;u+=c;d++}r[f]={left:0,top:u,row:d,width:g,height:i};l[l.length-1]+=g+a}));return h}_fitCols(t,e,s,i){const{ctx:n,maxHeight:o,options:{labels:{padding:a}}}=this;const r=this.legendHitBoxes=[];const l=this.columnSizes=[];const c=o-t;let h=a;let d=0;let u=0;let f=0;let g=0;this.legendItems.forEach(((t,o)=>{const{itemWidth:p,itemHeight:m}=fo(s,e,n,t,i);if(o>0&&u+m+2*a>c){h+=d+a;l.push({width:d,height:u});f+=d+a;g++;d=u=0}r[o]={left:f,top:u,col:g,width:p,height:m};d=Math.max(d,p);u+=m+a}));h+=d;l.push({width:d,height:u});return h}adjustHitBoxes(){if(!this.options.display)return;const t=this._computeTitleHeight();const{legendHitBoxes:e,options:{align:s,labels:{padding:i},rtl:n}}=this;const o=zt(n,this.left,this.width);if(this.isHorizontal()){let n=0;let a=U(s,this.left+i,this.right-this.lineWidths[n]);for(const r of e){if(n!==r.row){n=r.row;a=U(s,this.left+i,this.right-this.lineWidths[n])}r.top+=this.top+t+i;r.left=o.leftForLtr(o.x(a),r.width);a+=r.width+i}}else{let n=0;let a=U(s,this.top+t+i,this.bottom-this.columnSizes[n].height);for(const r of e){if(r.col!==n){n=r.col;a=U(s,this.top+t+i,this.bottom-this.columnSizes[n].height)}r.top=a;r.left+=this.left+i;r.left=o.leftForLtr(o.x(r.left),r.width);a+=r.height+i}}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const t=this.ctx;tt(t,this);this._draw();st(t)}}_draw(){const{options:t,columnSizes:e,lineWidths:s,ctx:i}=this;const{align:n,labels:a}=t;const r=o.color;const l=zt(t.rtl,this.left,this.width);const c=j(a.font);const{padding:d}=a;const u=c.size;const f=u/2;let g;this.drawTitle();i.textAlign=l.textAlign("left");i.textBaseline="middle";i.lineWidth=.5;i.font=c.string;const{boxWidth:p,boxHeight:m,itemHeight:x}=ho(a,u);const b=function(t,e,s){if(isNaN(p)||p<=0||isNaN(m)||m<0)return;i.save();const n=h(s.lineWidth,1);i.fillStyle=h(s.fillStyle,r);i.lineCap=h(s.lineCap,"butt");i.lineDashOffset=h(s.lineDashOffset,0);i.lineJoin=h(s.lineJoin,"miter");i.lineWidth=n;i.strokeStyle=h(s.strokeStyle,r);i.setLineDash(h(s.lineDash,[]));if(a.usePointStyle){const o={radius:m*Math.SQRT2/2,pointStyle:s.pointStyle,rotation:s.rotation,borderWidth:n};const r=l.xPlus(t,p/2);const c=e+f;Ft(i,o,r,c,a.pointStyleWidth&&p)}else{const o=e+Math.max((u-m)/2,0);const a=l.leftForLtr(t,p);const r=Ot(s.borderRadius);i.beginPath();Object.values(r).some((t=>t!==0))?Rt(i,{x:a,y:o,w:p,h:m,radius:r}):i.rect(a,o,p,m);i.fill();n!==0&&i.stroke()}i.restore()};const _=function(t,e,s){et(i,s.text,t,e+x/2,c,{strikethrough:s.hidden,textAlign:l.textAlign(s.textAlign)})};const y=this.isHorizontal();const v=this._computeTitleHeight();g=y?{x:U(n,this.left+d,this.right-s[0]),y:this.top+d+v,line:0}:{x:this.left+d,y:U(n,this.top+v+d,this.bottom-e[0].height),line:0};Vt(this.ctx,t.textDirection);const M=x+d;this.legendItems.forEach(((o,r)=>{i.strokeStyle=o.fontColor;i.fillStyle=o.fontColor;const h=i.measureText(o.text).width;const u=l.textAlign(o.textAlign||(o.textAlign=a.textAlign));const m=p+f+h;let x=g.x;let w=g.y;l.setWidth(this.width);if(y){if(r>0&&x+m+d>this.right){w=g.y+=M;g.line++;x=g.x=U(n,this.left+d,this.right-s[g.line])}}else if(r>0&&w+M>this.bottom){x=g.x=x+e[g.line].width+d;g.line++;w=g.y=U(n,this.top+v+d,this.bottom-e[g.line].height)}const k=l.x(x);b(k,w,o);x=Bt(u,x+p+f,y?x+m:this.right,t.rtl);_(l.x(x),w,o);if(y)g.x+=m+d;else if(typeof o.text!=="string"){const t=c.lineHeight;g.y+=mo(o,t)+d}else g.y+=M}));Nt(this.ctx,t.textDirection)}drawTitle(){const t=this.options;const e=t.title;const s=j(e.font);const i=R(e.padding);if(!e.display)return;const n=zt(t.rtl,this.left,this.width);const o=this.ctx;const a=e.position;const r=s.size/2;const l=i.top+r;let c;let h=this.left;let d=this.width;if(this.isHorizontal()){d=Math.max(...this.lineWidths);c=this.top+l;h=U(t.align,h,this.right-d)}else{const e=this.columnSizes.reduce(((t,e)=>Math.max(t,e.height)),0);c=l+U(t.align,this.top,this.bottom-e-t.labels.padding-this._computeTitleHeight())}const u=U(a,h,h+d);o.textAlign=n.textAlign($(a));o.textBaseline="middle";o.strokeStyle=e.color;o.fillStyle=e.color;o.font=s.string;et(o,e.text,u,c,s)}_computeTitleHeight(){const t=this.options.title;const e=j(t.font);const s=R(t.padding);return t.display?e.lineHeight+s.height:0}_getLegendItemAt(t,e){let s,i,n;if(Mt(t,this.left,this.right)&&Mt(e,this.top,this.bottom)){n=this.legendHitBoxes;for(s=0;st.length>e.length?t:e)));return e+s.size/2+i.measureText(n).width}function po(t,e,s){let i=t;typeof e.text!=="string"&&(i=mo(e,s));return i}function mo(t,e){const s=t.text?t.text.length:0;return e*s}function xo(t,e){return!(t!=="mousemove"&&t!=="mouseout"||!e.onHover&&!e.onLeave)||!(!e.onClick||t!=="click"&&t!=="mouseup")}var bo={id:"legend",_element:Legend,start(t,e,s){const i=t.legend=new Legend({ctx:t.ctx,options:s,chart:t});fs.configure(t,i,s);fs.addBox(t,i)},stop(t){fs.removeBox(t,t.legend);delete t.legend},beforeUpdate(t,e,s){const i=t.legend;fs.configure(t,i,s);i.options=s},afterUpdate(t){const e=t.legend;e.buildLabels();e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:true,position:"top",align:"center",fullSize:true,reverse:false,weight:1e3,onClick(t,e,s){const i=e.datasetIndex;const n=s.chart;if(n.isDatasetVisible(i)){n.hide(i);e.hidden=true}else{n.show(i);e.hidden=false}},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets;const{labels:{usePointStyle:s,pointStyle:i,textAlign:n,color:o,useBorderRadius:a,borderRadius:r}}=t.legend.options;return t._getSortedDatasetMetas().map((t=>{const l=t.controller.getStyle(s?0:void 0);const c=R(l.borderWidth);return{text:e[t.index].label,fillStyle:l.backgroundColor,fontColor:o,hidden:!t.visible,lineCap:l.borderCapStyle,lineDash:l.borderDash,lineDashOffset:l.borderDashOffset,lineJoin:l.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:l.borderColor,pointStyle:i||l.pointStyle,rotation:l.rotation,textAlign:n||l.textAlign,borderRadius:a&&(r||l.borderRadius),datasetIndex:t.index}}),this)}},title:{color:t=>t.chart.options.color,display:false,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};class Title extends Element{constructor(t){super();this.chart=t.chart;this.options=t.options;this.ctx=t.ctx;this._padding=void 0;this.top=void 0;this.bottom=void 0;this.left=void 0;this.right=void 0;this.width=void 0;this.height=void 0;this.position=void 0;this.weight=void 0;this.fullSize=void 0}update(t,e){const s=this.options;this.left=0;this.top=0;if(!s.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=t;this.height=this.bottom=e;const i=a(s.text)?s.text.length:1;this._padding=R(s.padding);const n=i*j(s.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=n:this.width=n}isHorizontal(){const t=this.options.position;return t==="top"||t==="bottom"}_drawArgs(t){const{top:e,left:s,bottom:i,right:n,options:o}=this;const a=o.align;let r=0;let l,c,h;if(this.isHorizontal()){c=U(a,s,n);h=e+t;l=n-s}else{if(o.position==="left"){c=s+t;h=U(a,i,e);r=y*-.5}else{c=n-t;h=U(a,e,i);r=y*.5}l=i-e}return{titleX:c,titleY:h,maxWidth:l,rotation:r}}draw(){const t=this.ctx;const e=this.options;if(!e.display)return;const s=j(e.font);const i=s.lineHeight;const n=i/2+this._padding.top;const{titleX:o,titleY:a,maxWidth:r,rotation:l}=this._drawArgs(n);et(t,e.text,0,0,s,{color:e.color,maxWidth:r,rotation:l,textAlign:$(e.align),textBaseline:"middle",translation:[o,a]})}}function _o(t,e){const s=new Title({ctx:t.ctx,options:e,chart:t});fs.configure(t,s,e);fs.addBox(t,s);t.titleBlock=s}var yo={id:"title",_element:Title,start(t,e,s){_o(t,s)},stop(t){const e=t.titleBlock;fs.removeBox(t,e);delete t.titleBlock},beforeUpdate(t,e,s){const i=t.titleBlock;fs.configure(t,i,s);i.options=s},defaults:{align:"center",display:false,font:{weight:"bold"},fullSize:true,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:true,_indexable:false}};const vo=new WeakMap;var Mo={id:"subtitle",start(t,e,s){const i=new Title({ctx:t.ctx,options:s,chart:t});fs.configure(t,i,s);fs.addBox(t,i);vo.set(t,i)},stop(t){fs.removeBox(t,vo.get(t));vo.delete(t)},beforeUpdate(t,e,s){const i=vo.get(t);fs.configure(t,i,s);i.options=s},defaults:{align:"center",display:false,font:{weight:"normal"},fullSize:true,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:true,_indexable:false}};const wo={average(t){if(!t.length)return false;let e,s;let i=new Set;let n=0;let o=0;for(e=0,s=t.length;et+e))/i.size;return{x:a,y:n/o}},nearest(t,e){if(!t.length)return false;let s=e.x;let i=e.y;let n=Number.POSITIVE_INFINITY;let o,a,r;for(o=0,a=t.length;o-1?t.split("\n"):t}function Do(t,e){const{element:s,datasetIndex:i,index:n}=e;const o=t.getDatasetMeta(i).controller;const{label:a,value:r}=o.getLabelAndValue(n);return{chart:t,label:a,parsed:o.getParsed(n),raw:t.data.datasets[i].data[n],formattedValue:r,dataset:o.getDataset(),dataIndex:n,datasetIndex:i,element:s}}function Po(t,e){const s=t.chart.ctx;const{body:i,footer:n,title:o}=t;const{boxWidth:a,boxHeight:r}=e;const l=j(e.bodyFont);const c=j(e.titleFont);const h=j(e.footerFont);const d=o.length;const u=n.length;const f=i.length;const g=R(e.padding);let p=g.height;let m=0;let x=i.reduce(((t,e)=>t+e.before.length+e.lines.length+e.after.length),0);x+=t.beforeBody.length+t.afterBody.length;d&&(p+=d*c.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom);if(x){const t=e.displayColors?Math.max(r,l.lineHeight):l.lineHeight;p+=f*t+(x-f)*l.lineHeight+(x-1)*e.bodySpacing}u&&(p+=e.footerMarginTop+u*h.lineHeight+(u-1)*e.footerSpacing);let b=0;const _=function(t){m=Math.max(m,s.measureText(t).width+b)};s.save();s.font=c.string;I(t.title,_);s.font=l.string;I(t.beforeBody.concat(t.afterBody),_);b=e.displayColors?a+2+e.boxPadding:0;I(i,(t=>{I(t.before,_);I(t.lines,_);I(t.after,_)}));b=0;s.font=h.string;I(t.footer,_);s.restore();m+=g.width;return{width:m,height:p}}function Co(t,e){const{y:s,height:i}=e;return st.height-i/2?"bottom":"center"}function Ao(t,e,s,i){const{x:n,width:o}=i;const a=s.caretSize+s.caretPadding;return t==="left"&&n+o+a>e.width||(t==="right"&&n-o-a<0||void 0)}function Lo(t,e,s,i){const{x:n,width:o}=s;const{width:a,chartArea:{left:r,right:l}}=t;let c="center";i==="center"?c=n<=(r+l)/2?"left":"right":n<=o/2?c="left":n>=a-o/2&&(c="right");Ao(c,t,e,s)&&(c="center");return c}function Eo(t,e,s){const i=s.yAlign||e.yAlign||Co(t,s);return{xAlign:s.xAlign||e.xAlign||Lo(t,e,s,i),yAlign:i}}function To(t,e){let{x:s,width:i}=t;e==="right"?s-=i:e==="center"&&(s-=i/2);return s}function Oo(t,e,s){let{y:i,height:n}=t;e==="top"?i+=s:i-=e==="bottom"?n+s:n/2;return i}function Ro(t,e,s,i){const{caretSize:n,caretPadding:o,cornerRadius:a}=t;const{xAlign:r,yAlign:l}=s;const c=n+o;const{topLeft:h,topRight:d,bottomLeft:u,bottomRight:f}=Ot(a);let g=To(e,r);const p=Oo(e,l,c);l==="center"?r==="left"?g+=c:r==="right"&&(g-=c):r==="left"?g-=Math.max(h,u)+n:r==="right"&&(g+=Math.max(d,f)+n);return{x:K(g,0,i.width-e.width),y:K(p,0,i.height-e.height)}}function Io(t,e,s){const i=R(s.padding);return e==="center"?t.x+t.width/2:e==="right"?t.x+t.width-i.right:t.x+i.left}function zo(t){return ko([],So(t))}function Fo(t,e,s){return c(t,{tooltip:e,tooltipItems:s,type:"tooltip"})}function Vo(t,e){const s=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return s?t.override(s):t}const Bo={beforeTitle:Ht,title(t){if(t.length>0){const e=t[0];const s=e.chart.data.labels;const i=s?s.length:0;if(this&&this.options&&this.options.mode==="dataset")return e.dataset.label||"";if(e.label)return e.label;if(i>0&&e.dataIndex{const e={before:[],lines:[],after:[]};const n=Vo(s,t);ko(e.before,So(No(n,"beforeLabel",this,t)));ko(e.lines,No(n,"label",this,t));ko(e.after,So(No(n,"afterLabel",this,t)));i.push(e)}));return i}getAfterBody(t,e){return zo(No(e.callbacks,"afterBody",this,t))}getFooter(t,e){const{callbacks:s}=e;const i=No(s,"beforeFooter",this,t);const n=No(s,"footer",this,t);const o=No(s,"afterFooter",this,t);let a=[];a=ko(a,So(i));a=ko(a,So(n));a=ko(a,So(o));return a}_createItems(t){const e=this._active;const s=this.chart.data;const i=[];const n=[];const o=[];let a=[];let r,l;for(r=0,l=e.length;rt.filter(e,i,n,s))));t.itemSort&&(a=a.sort(((e,i)=>t.itemSort(e,i,s))));I(a,(e=>{const s=Vo(t.callbacks,e);i.push(No(s,"labelColor",this,e));n.push(No(s,"labelPointStyle",this,e));o.push(No(s,"labelTextColor",this,e))}));this.labelColors=i;this.labelPointStyles=n;this.labelTextColors=o;this.dataPoints=a;return a}update(t,e){const s=this.options.setContext(this.getContext());const i=this._active;let n;let o=[];if(i.length){const t=wo[s.position].call(this,i,this._eventPosition);o=this._createItems(s);this.title=this.getTitle(o,s);this.beforeBody=this.getBeforeBody(o,s);this.body=this.getBody(o,s);this.afterBody=this.getAfterBody(o,s);this.footer=this.getFooter(o,s);const e=this._size=Po(this,s);const a=Object.assign({},t,e);const r=Eo(this.chart,s,a);const l=Ro(s,a,r,this.chart);this.xAlign=r.xAlign;this.yAlign=r.yAlign;n={opacity:1,x:l.x,y:l.y,width:e.width,height:e.height,caretX:t.x,caretY:t.y}}else this.opacity!==0&&(n={opacity:0});this._tooltipItems=o;this.$context=void 0;n&&this._resolveAnimations().update(this,n);t&&s.external&&s.external.call(this,{chart:this.chart,tooltip:this,replay:e})}drawCaret(t,e,s,i){const n=this.getCaretPosition(t,s,i);e.lineTo(n.x1,n.y1);e.lineTo(n.x2,n.y2);e.lineTo(n.x3,n.y3)}getCaretPosition(t,e,s){const{xAlign:i,yAlign:n}=this;const{caretSize:o,cornerRadius:a}=s;const{topLeft:r,topRight:l,bottomLeft:c,bottomRight:h}=Ot(a);const{x:d,y:u}=t;const{width:f,height:g}=e;let p,m,x,b,_,y;if(n==="center"){_=u+g/2;if(i==="left"){p=d;m=p-o;b=_+o;y=_-o}else{p=d+f;m=p+o;b=_-o;y=_+o}x=p}else{m=i==="left"?d+Math.max(r,c)+o:i==="right"?d+f-Math.max(l,h)-o:this.caretX;if(n==="top"){b=u;_=b-o;p=m-o;x=m+o}else{b=u+g;_=b+o;p=m+o;x=m-o}y=b}return{x1:p,x2:m,x3:x,y1:b,y2:_,y3:y}}drawTitle(t,e,s){const i=this.title;const n=i.length;let o,a,r;if(n){const l=zt(s.rtl,this.x,this.width);t.x=Io(this,s.titleAlign,s);e.textAlign=l.textAlign(s.titleAlign);e.textBaseline="middle";o=j(s.titleFont);a=s.titleSpacing;e.fillStyle=s.titleColor;e.font=o.string;for(r=0;rt!==0))){t.beginPath();t.fillStyle=o.multiKeyBackground;Rt(t,{x:e,y:g,w:c,h:l,radius:r});t.fill();t.stroke();t.fillStyle=a.backgroundColor;t.beginPath();Rt(t,{x:s,y:g+1,w:c-2,h:l-2,radius:r});t.fill()}else{t.fillStyle=o.multiKeyBackground;t.fillRect(e,g,c,l);t.strokeRect(e,g,c,l);t.fillStyle=a.backgroundColor;t.fillRect(s,g+1,c-2,l-2)}}t.fillStyle=this.labelTextColors[s]}drawBody(t,e,s){const{body:i}=this;const{bodySpacing:n,bodyAlign:o,displayColors:a,boxHeight:r,boxWidth:l,boxPadding:c}=s;const h=j(s.bodyFont);let d=h.lineHeight;let u=0;const f=zt(s.rtl,this.x,this.width);const g=function(s){e.fillText(s,f.x(t.x+u),t.y+d/2);t.y+=d+n};const p=f.textAlign(o);let m,x,b,_,y,v,M;e.textAlign=o;e.textBaseline="middle";e.font=h.string;t.x=Io(this,p,s);e.fillStyle=s.bodyColor;I(this.beforeBody,g);u=a&&p!=="right"?o==="center"?l/2+c:l+2+c:0;for(_=0,v=i.length;_0&&e.stroke()}_updateAnimationTarget(t){const e=this.chart;const s=this.$animations;const i=s&&s.x;const n=s&&s.y;if(i||n){const s=wo[t.position].call(this,this._active,this._eventPosition);if(!s)return;const o=this._size=Po(this,t);const a=Object.assign({},s,this._size);const r=Eo(e,t,a);const l=Ro(t,a,r,e);if(i._to!==l.x||n._to!==l.y){this.xAlign=r.xAlign;this.yAlign=r.yAlign;this.width=o.width;this.height=o.height;this.caretX=s.x;this.caretY=s.y;this._resolveAnimations().update(this,l)}}}_willRender(){return!!this.opacity}draw(t){const e=this.options.setContext(this.getContext());let s=this.opacity;if(!s)return;this._updateAnimationTarget(e);const i={width:this.width,height:this.height};const n={x:this.x,y:this.y};s=Math.abs(s)<.001?0:s;const o=R(e.padding);const a=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;if(e.enabled&&a){t.save();t.globalAlpha=s;this.drawBackground(n,t,i,e);Vt(t,e.textDirection);n.y+=o.top;this.drawTitle(n,t,e);this.drawBody(n,t,e);this.drawFooter(n,t,e);Nt(t,e.textDirection);t.restore()}}getActiveElements(){return this._active||[]}setActiveElements(t,e){const s=this._active;const i=t.map((({datasetIndex:t,index:e})=>{const s=this.chart.getDatasetMeta(t);if(!s)throw new Error("Cannot find a dataset at index "+t);return{datasetIndex:t,element:s.data[e],index:e}}));const n=!bt(s,i);const o=this._positionChanged(i,e);if(n||o){this._active=i;this._eventPosition=e;this._ignoreReplayEvents=true;this.update(true)}}handleEvent(t,e,s=true){if(e&&this._ignoreReplayEvents)return false;this._ignoreReplayEvents=false;const i=this.options;const n=this._active||[];const o=this._getActiveElements(t,n,e,s);const a=this._positionChanged(o,t);const r=e||!bt(o,n)||a;if(r){this._active=o;if(i.enabled||i.external){this._eventPosition={x:t.x,y:t.y};this.update(true,e)}}return r}_getActiveElements(t,e,s,i){const n=this.options;if(t.type==="mouseout")return[];if(!i)return e.filter((t=>this.chart.data.datasets[t.datasetIndex]&&this.chart.getDatasetMeta(t.datasetIndex).controller.getParsed(t.index)!==void 0));const o=this.chart.getElementsAtEventForMode(t,n.mode,n,s);n.reverse&&o.reverse();return o}_positionChanged(t,e){const{caretX:s,caretY:i,options:n}=this;const o=wo[n.position].call(this,t,e);return o!==false&&(s!==o.x||i!==o.y)}}var Wo={id:"tooltip",_element:Tooltip,positioners:wo,afterInit(t,e,s){s&&(t.tooltip=new Tooltip({chart:t,options:s}))},beforeUpdate(t,e,s){t.tooltip&&t.tooltip.initialize(s)},reset(t,e,s){t.tooltip&&t.tooltip.initialize(s)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const s={tooltip:e};if(t.notifyPlugins("beforeTooltipDraw",{...s,cancelable:true})===false)return;e.draw(t.ctx);t.notifyPlugins("afterTooltipDraw",s)}},afterEvent(t,e){if(t.tooltip){const s=e.replay;t.tooltip.handleEvent(e.event,s,e.inChartArea)&&(e.changed=true)}},defaults:{enabled:true,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:true,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:Bo},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:t=>t!=="filter"&&t!=="itemSort"&&t!=="external",_indexable:false,callbacks:{_scriptable:false,_indexable:false},animation:{_fallback:false},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};var Ho=Object.freeze({__proto__:null,Colors:Pn,Decimation:On,Filler:co,Legend:bo,SubTitle:Mo,Title:yo,Tooltip:Wo});const jo=(t,e,s,i)=>{if(typeof e==="string"){s=t.push(e)-1;i.unshift({index:s,label:e})}else isNaN(e)&&(s=null);return s};function $o(t,e,s,i){const n=t.indexOf(e);if(n===-1)return jo(t,e,s,i);const o=t.lastIndexOf(e);return n!==o?s:n}const Uo=(t,e)=>t===null?null:K(Math.round(t),0,e);function Yo(t){const e=this.getLabels();return t>=0&&te.length-1?null:this.getPixelForValue(e[t].value)}getValueForPixel(t){return Math.round(this._startValue+this.getDecimalForPixel(t)*this._valueRange)}getBasePixel(){return this.bottom}}function Xo(t,e){const s=[];const i=1e-14;const{bounds:n,step:o,min:a,max:r,precision:l,count:c,maxTicks:h,maxDigits:d,includeBounds:u}=t;const f=o||1;const g=h-1;const{min:p,max:x}=e;const b=!m(a);const _=!m(r);const y=!m(c);const v=(x-p)/(d+1);let M=jt((x-p)/g/f)*f;let w,k,S,D;if(Mg&&(M=jt(D*M/g/f)*f);if(!m(l)){w=Math.pow(10,l);M=Math.ceil(M*w)/w}if(n==="ticks"){k=Math.floor(p/M)*M;S=Math.ceil(x/M)*M}else{k=p;S=x}if(b&&_&&o&&$t((r-a)/o,M/1e3)){D=Math.round(Math.min((r-a)/M,h));M=(r-a)/D;k=a;S=r}else if(y){k=b?a:k;S=_?r:S;D=c-1;M=(S-k)/D}else{D=(S-k)/M;D=Ut(D,Math.round(D),M/1e3)?Math.round(D):Math.ceil(D)}const P=Math.max(Yt(M),Yt(k));w=Math.pow(10,m(l)?P:l);k=Math.round(k*w)/w;S=Math.round(S*w)/w;let C=0;if(b)if(u&&k!==a){s.push({value:a});kr)break;s.push({value:t})}_&&u&&S!==r?s.length&&Ut(s[s.length-1].value,r,Go(r,v,t))?s[s.length-1].value=r:s.push({value:r}):_&&S!==r||s.push({value:S});return s}function Go(t,e,{horizontal:s,minRotation:i}){const n=v(i);const o=(s?Math.sin(n):Math.cos(n))||.001;const a=.75*e*(""+t).length;return Math.min(e/o,a)}class LinearScaleBase extends Scale{constructor(t){super(t);this.start=void 0;this.end=void 0;this._startValue=void 0;this._endValue=void 0;this._valueRange=0}parse(t,e){return m(t)||(typeof t==="number"||t instanceof Number)&&!isFinite(+t)?null:+t}handleTickRangeOptions(){const{beginAtZero:t}=this.options;const{minDefined:e,maxDefined:s}=this.getUserBounds();let{min:i,max:n}=this;const o=t=>i=e?i:t;const a=t=>n=s?n:t;if(t){const t=l(i);const e=l(n);t<0&&e<0?a(0):t>0&&e>0&&o(0)}if(i===n){let e=n===0?1:Math.abs(n*.05);a(n+e);t||o(i-e)}this.min=i;this.max=n}getTickLimit(){const t=this.options.ticks;let{maxTicksLimit:e,stepSize:s}=t;let i;if(s){i=Math.ceil(this.max/s)-Math.floor(this.min/s)+1;if(i>1e3){console.warn(`scales.${this.id}.ticks.stepSize: ${s} would result generating up to ${i} ticks. Limiting to 1000.`);i=1e3}}else{i=this.computeTickLimit();e=e||11}e&&(i=Math.min(e,i));return i}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const t=this.options;const e=t.ticks;let s=this.getTickLimit();s=Math.max(2,s);const i={maxTicks:s,bounds:t.bounds,min:t.min,max:t.max,precision:e.precision,step:e.stepSize,count:e.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:e.minRotation||0,includeBounds:e.includeBounds!==false};const n=this._range||this;const o=Xo(i,n);t.bounds==="ticks"&&Xt(o,this,"value");if(t.reverse){o.reverse();this.start=this.max;this.end=this.min}else{this.start=this.min;this.end=this.max}return o}configure(){const t=this.ticks;let e=this.min;let s=this.max;super.configure();if(this.options.offset&&t.length){const i=(s-e)/Math.max(t.length-1,1)/2;e-=i;s+=i}this._startValue=e;this._endValue=s;this._valueRange=s-e}getLabelForValue(t){return k(t,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{static id="linear";static defaults={ticks:{callback:Gt.formatters.numeric}};determineDataLimits(){const{min:t,max:e}=this.getMinMax(true);this.min=r(t)?t:0;this.max=r(e)?e:1;this.handleTickRangeOptions()}computeTickLimit(){const t=this.isHorizontal();const e=t?this.width:this.height;const s=v(this.options.ticks.minRotation);const i=(t?Math.sin(s):Math.cos(s))||.001;const n=this._resolveTickFontOptions(0);return Math.ceil(e/Math.min(40,n.lineHeight/i))}getPixelForValue(t){return t===null?NaN:this.getPixelForDecimal((t-this._startValue)/this._valueRange)}getValueForPixel(t){return this._startValue+this.getDecimalForPixel(t)*this._valueRange}}const Ko=t=>Math.floor(Kt(t));const Jo=(t,e)=>Math.pow(10,Ko(t)+e);function qo(t){const e=t/Math.pow(10,Ko(t));return e===1}function Zo(t,e,s){const i=Math.pow(10,s);const n=Math.floor(t/i);const o=Math.ceil(e/i);return o-n}function Qo(t,e){const s=e-t;let i=Ko(s);while(Zo(t,e,i)>10)i++;while(Zo(t,e,i)<10)i--;return Math.min(i,Ko(t))}function ta(t,{min:e,max:s}){e=Y(t.min,e);const i=[];const n=Ko(e);let o=Qo(e,s);let a=o<0?Math.pow(10,Math.abs(o)):1;const r=Math.pow(10,o);const l=n>o?Math.pow(10,n):0;const c=Math.round((e-l)*a)/a;const h=Math.floor((e-l)/r/10)*r*10;let d=Math.floor((c-h)/Math.pow(10,o));let u=Y(t.min,Math.round((l+h+d*Math.pow(10,o))*a)/a);while(u=10?d=d<15?15:20:d++;if(d>=20){o++;d=2;a=o>=0?1:a}u=Math.round((l+h+d*Math.pow(10,o))*a)/a}const f=Y(t.max,u);i.push({value:f,major:qo(f),significand:d});return i}class LogarithmicScale extends Scale{static id="logarithmic";static defaults={ticks:{callback:Gt.formatters.logarithmic,major:{enabled:true}}};constructor(t){super(t);this.start=void 0;this.end=void 0;this._startValue=void 0;this._valueRange=0}parse(t,e){const s=LinearScaleBase.prototype.parse.apply(this,[t,e]);if(s!==0)return r(s)&&s>0?s:null;this._zero=true}determineDataLimits(){const{min:t,max:e}=this.getMinMax(true);this.min=r(t)?Math.max(0,t):null;this.max=r(e)?Math.max(0,e):null;this.options.beginAtZero&&(this._zero=true);this._zero&&this.min!==this._suggestedMin&&!r(this._userMin)&&(this.min=t===Jo(this.min,0)?Jo(this.min,-1):Jo(this.min,0));this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:t,maxDefined:e}=this.getUserBounds();let s=this.min;let i=this.max;const n=e=>s=t?s:e;const o=t=>i=e?i:t;if(s===i)if(s<=0){n(1);o(10)}else{n(Jo(s,-1));o(Jo(i,1))}s<=0&&n(Jo(i,-1));i<=0&&o(Jo(s,1));this.min=s;this.max=i}buildTicks(){const t=this.options;const e={min:this._userMin,max:this._userMax};const s=ta(e,this);t.bounds==="ticks"&&Xt(s,this,"value");if(t.reverse){s.reverse();this.start=this.max;this.end=this.min}else{this.start=this.min;this.end=this.max}return s}getLabelForValue(t){return t===void 0?"0":k(t,this.chart.options.locale,this.options.ticks.format)}configure(){const t=this.min;super.configure();this._startValue=Kt(t);this._valueRange=Kt(this.max)-Kt(t)}getPixelForValue(t){t!==void 0&&t!==0||(t=this.min);return t===null||isNaN(t)?NaN:this.getPixelForDecimal(t===this.min?0:(Kt(t)-this._startValue)/this._valueRange)}getValueForPixel(t){const e=this.getDecimalForPixel(t);return Math.pow(10,this._startValue+e*this._valueRange)}}function ea(t){const e=t.ticks;if(e.display&&t.display){const t=R(e.backdropPadding);return h(e.font&&e.font.size,o.font.size)+t.height}return 0}function sa(t,e,s){s=a(s)?s:[s];return{w:Jt(t,e.string,s),h:s.length*e.lineHeight}}function ia(t,e,s,i,n){return t===i||t===n?{start:e-s/2,end:e+s/2}:tn?{start:e-s,end:e}:{start:e,end:e+s}}function na(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom};const s=Object.assign({},e);const i=[];const n=[];const o=t._pointLabels.length;const a=t.options.pointLabels;const r=a.centerPointLabels?y/o:0;for(let l=0;le.r){r=(i.end-e.r)/o;t.r=Math.max(t.r,e.r+r)}if(n.starte.b){l=(n.end-e.b)/a;t.b=Math.max(t.b,e.b+l)}}function aa(t,e,s){const i=t.drawingArea;const{extra:n,additionalAngle:o,padding:a,size:r}=s;const l=t.getPointPosition(e,i+n+a,o);const c=Math.round(J(yt(l.angle+_)));const h=da(l.y,r.h,c);const d=ca(c);const u=ha(l.x,r.w,d);return{visible:true,x:l.x,y:h,textAlign:d,left:u,top:h,right:u+r.w,bottom:h+r.h}}function ra(t,e){if(!e)return true;const{left:s,top:i,right:n,bottom:o}=t;const a=E({x:s,y:i},e)||E({x:s,y:o},e)||E({x:n,y:i},e)||E({x:n,y:o},e);return!a}function la(t,e,s){const i=[];const n=t._pointLabels.length;const o=t.options;const{centerPointLabels:a,display:r}=o.pointLabels;const l={extra:ea(o)/2,additionalAngle:a?y/n:0};let c;for(let o=0;o270||s<90)&&(t-=e);return t}function ua(t,e,s){const{left:i,top:n,right:o,bottom:a}=s;const{backdropColor:r}=e;if(!m(r)){const s=Ot(e.borderRadius);const l=R(e.backdropPadding);t.fillStyle=r;const c=i-l.left;const h=n-l.top;const d=o-i+l.width;const u=a-n+l.height;if(Object.values(s).some((t=>t!==0))){t.beginPath();Rt(t,{x:c,y:h,w:d,h:u,radius:s});t.fill()}else t.fillRect(c,h,d,u)}}function fa(t,e){const{ctx:s,options:{pointLabels:i}}=t;for(let n=e-1;n>=0;n--){const e=t._pointLabelItems[n];if(!e.visible)continue;const o=i.setContext(t.getPointLabelContext(n));ua(s,o,e);const a=j(o.font);const{x:r,y:l,textAlign:c}=e;et(s,t._pointLabels[n],r,l+a.lineHeight/2,a,{color:o.color,textAlign:c,textBaseline:"middle"})}}function ga(t,e,s,i){const{ctx:n}=t;if(s)n.arc(t.xCenter,t.yCenter,e,0,x);else{let s=t.getPointPosition(0,e);n.moveTo(s.x,s.y);for(let o=1;o{const s=X(this.options.pointLabels.callback,[t,e],this);return s||s===0?s:""})).filter(((t,e)=>this.chart.getDataVisibility(e)))}fit(){const t=this.options;t.display&&t.pointLabels.display?na(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(t,e,s,i){this.xCenter+=Math.floor((t-e)/2);this.yCenter+=Math.floor((s-i)/2);this.drawingArea-=Math.min(this.drawingArea/2,Math.max(t,e,s,i))}getIndexAngle(t){const e=x/(this._pointLabels.length||1);const s=this.options.startAngle||0;return yt(t*e+v(s))}getDistanceFromCenterForValue(t){if(m(t))return NaN;const e=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-t)*e:(t-this.min)*e}getValueForDistanceFromCenter(t){if(m(t))return NaN;const e=t/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-e:this.min+e}getPointLabelContext(t){const e=this._pointLabels||[];if(t>=0&&t{if(e!==0||e===0&&this.min<0){r=this.getDistanceFromCenterForValue(t.value);const s=this.getContext(e);const a=i.setContext(s);const l=n.setContext(s);pa(this,a,r,o,l)}}));if(s.display){t.save();for(a=o-1;a>=0;a--){const i=s.setContext(this.getPointLabelContext(a));const{color:n,lineWidth:o}=i;if(o&&n){t.lineWidth=o;t.strokeStyle=n;t.setLineDash(i.borderDash);t.lineDashOffset=i.borderDashOffset;r=this.getDistanceFromCenterForValue(e.reverse?this.min:this.max);l=this.getPointPosition(a,r);t.beginPath();t.moveTo(this.xCenter,this.yCenter);t.lineTo(l.x,l.y);t.stroke()}}t.restore()}}drawBorder(){}drawLabels(){const t=this.ctx;const e=this.options;const s=e.ticks;if(!s.display)return;const i=this.getIndexAngle(0);let n,o;t.save();t.translate(this.xCenter,this.yCenter);t.rotate(i);t.textAlign="center";t.textBaseline="middle";this.ticks.forEach(((i,a)=>{if(a===0&&this.min>=0&&!e.reverse)return;const r=s.setContext(this.getContext(a));const l=j(r.font);n=this.getDistanceFromCenterForValue(this.ticks[a].value);if(r.showLabelBackdrop){t.font=l.string;o=t.measureText(i.label).width;t.fillStyle=r.backdropColor;const e=R(r.backdropPadding);t.fillRect(-o/2-e.left,-n-l.size/2-e.top,o+e.width,l.size+e.height)}et(t,i.label,0,-n,l,{color:r.color,strokeColor:r.textStrokeColor,strokeWidth:r.textStrokeWidth})}));t.restore()}drawTitle(){}}const xa={millisecond:{common:true,size:1,steps:1e3},second:{common:true,size:1e3,steps:60},minute:{common:true,size:6e4,steps:60},hour:{common:true,size:36e5,steps:24},day:{common:true,size:864e5,steps:30},week:{common:false,size:6048e5,steps:4},month:{common:true,size:2628e6,steps:12},quarter:{common:false,size:7884e6,steps:4},year:{common:true,size:3154e7}};const ba=Object.keys(xa);function _a(t,e){return t-e}function ya(t,e){if(m(e))return null;const s=t._adapter;const{parser:i,round:n,isoWeekday:o}=t._parseOpts;let a=e;typeof i==="function"&&(a=i(a));r(a)||(a=typeof i==="string"?s.parse(a,i):s.parse(a));if(a===null)return null;n&&(a=n!=="week"||!P(o)&&o!==true?s.startOf(a,n):s.startOf(a,"isoWeek",o));return+a}function va(t,e,s,i){const n=ba.length;for(let o=ba.indexOf(t);o=ba.indexOf(s);o--){const s=ba[o];if(xa[s].common&&t._adapter.diff(n,i,s)>=e-1)return s}return ba[s?ba.indexOf(s):0]}function wa(t){for(let e=ba.indexOf(t)+1,s=ba.length;e=e?s[i]:s[n];t[o]=true}}else t[e]=true}function Sa(t,e,s,i){const n=t._adapter;const o=+n.startOf(e[0].value,i);const a=e[e.length-1].value;let r,l;for(r=o;r<=a;r=+n.add(r,1,i)){l=s[r];l>=0&&(e[l].major=true)}return e}function Da(t,e,s){const i=[];const n={};const o=e.length;let a,r;for(a=0;a+t.value)))}initOffsets(t=[]){let e=0;let s=0;let i,n;if(this.options.offset&&t.length){i=this.getDecimalForValue(t[0]);e=t.length===1?1-i:(this.getDecimalForValue(t[1])-i)/2;n=this.getDecimalForValue(t[t.length-1]);s=t.length===1?n:(n-this.getDecimalForValue(t[t.length-2]))/2}const o=t.length<3?.5:.25;e=K(e,0,o);s=K(s,0,o);this._offsets={start:e,end:s,factor:1/(e+1+s)}}_generate(){const t=this._adapter;const e=this.min;const s=this.max;const i=this.options;const n=i.time;const o=n.unit||va(n.minUnit,e,s,this._getLabelCapacity(e));const a=h(i.ticks.stepSize,1);const r=o==="week"&&n.isoWeekday;const l=P(r)||r===true;const c={};let d=e;let u,f;l&&(d=+t.startOf(d,"isoWeek",r));d=+t.startOf(d,l?"day":o);if(t.diff(s,e,o)>1e5*a)throw new Error(e+" and "+s+" are too far apart with stepSize of "+a+" "+o);const g=i.ticks.source==="data"&&this.getDataTimestamps();for(u=d,f=0;u+t))}getLabelForValue(t){const e=this._adapter;const s=this.options.time;return s.tooltipFormat?e.format(t,s.tooltipFormat):e.format(t,s.displayFormats.datetime)}format(t,e){const s=this.options;const i=s.time.displayFormats;const n=this._unit;const o=e||i[n];return this._adapter.format(t,o)}_tickFormatFunction(t,e,s,i){const n=this.options;const o=n.ticks.callback;if(o)return X(o,[t,e,s],this);const a=n.time.displayFormats;const r=this._unit;const l=this._majorUnit;const c=r&&a[r];const h=l&&a[l];const d=s[e];const u=l&&h&&d&&d.major;return this._adapter.format(t,i||(u?h:c))}generateTickLabels(t){let e,s,i;for(e=0,s=t.length;e0?a:1}getDataTimestamps(){let t=this._cache.data||[];let e,s;if(t.length)return t;const i=this.getMatchingVisibleMetas();if(this._normalized&&i.length)return this._cache.data=i[0].controller.getAllParsedValues(this);for(e=0,s=i.length;e=t[i].pos&&e<=t[n].pos&&({lo:i,hi:n}=L(t,"pos",e));({pos:o,time:r}=t[i]);({pos:a,time:l}=t[n])}else{e>=t[i].time&&e<=t[n].time&&({lo:i,hi:n}=L(t,"time",e));({time:o,pos:r}=t[i]);({time:a,pos:l}=t[n])}const c=a-o;return c?r+(l-r)*(e-o)/c:r}class TimeSeriesScale extends TimeScale{static id="timeseries";static defaults=TimeScale.defaults;constructor(t){super(t);this._table=[];this._minPos=void 0;this._tableRange=void 0}initOffsets(){const t=this._getTimestampsForTable();const e=this._table=this.buildLookupTable(t);this._minPos=Pa(e,this.min);this._tableRange=Pa(e,this.max)-this._minPos;super.initOffsets(t)}buildLookupTable(t){const{min:e,max:s}=this;const i=[];const n=[];let o,a,r,l,c;for(o=0,a=t.length;o=e&&l<=s&&i.push(l)}if(i.length<2)return[{time:e,pos:0},{time:s,pos:1}];for(o=0,a=i.length;ot-e))}_getTimestampsForTable(){let t=this._cache.all||[];if(t.length)return t;const e=this.getDataTimestamps();const s=this.getLabelTimestamps();t=e.length&&s.length?this.normalize(e.concat(s)):e.length?e:s;t=this._cache.all=t;return t}getDecimalForValue(t){return(Pa(this._table,t)-this._minPos)/this._tableRange}getValueForPixel(t){const e=this._offsets;const s=this.getDecimalForPixel(t)/e.factor-e.end;return Pa(this._table,s*this._tableRange+this._minPos,true)}}var Ca=Object.freeze({__proto__:null,CategoryScale:CategoryScale,LinearScale:LinearScale,LogarithmicScale:LogarithmicScale,RadialLinearScale:RadialLinearScale,TimeScale:TimeScale,TimeSeriesScale:TimeSeriesScale});const Aa=[Be,pn,Ho,Ca];export{Animation,Animations,ArcElement,BarController,BarElement,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,Pn as Colors,DatasetController,On as Decimation,DomPlatform,DoughnutController,Element,co as Filler,Je as Interaction,bo as Legend,LineController,LineElement,LinearScale,LogarithmicScale,PieController,PointElement,PolarAreaController,RadarController,RadialLinearScale,Scale,ScatterController,Mo as SubTitle,Gt as Ticks,TimeScale,TimeSeriesScale,yo as Title,Wo as Tooltip,We as _adapters,Os as _detectPlatform,Qt as animator,Be as controllers,o as defaults,pn as elements,fs as layouts,Ho as plugins,Aa as registerables,si as registry,Ca as scales}; + diff --git a/vendor/javascript/chartkick.js b/vendor/javascript/chartkick.js new file mode 100644 index 0000000..fc487cd --- /dev/null +++ b/vendor/javascript/chartkick.js @@ -0,0 +1,4 @@ +// chartkick@5.0.1 downloaded from https://ga.jspm.io/npm:chartkick@5.0.1/dist/chartkick.esm.js + +function isArray(t){return"[object Array]"===Object.prototype.toString.call(t)}function isFunction(t){return t instanceof Function}function isPlainObject(t){return"[object Object]"===Object.prototype.toString.call(t)&&!isFunction(t)&&t instanceof Object}function extend(t,e){for(var r in e)if("__proto__"!==r)if(isPlainObject(e[r])||isArray(e[r])){isPlainObject(e[r])&&!isPlainObject(t[r])&&(t[r]={});isArray(e[r])&&!isArray(t[r])&&(t[r]=[]);extend(t[r],e[r])}else void 0!==e[r]&&(t[r]=e[r])}function merge(t,e){var r={};extend(r,t);extend(r,e);return r}var t=/^(\d\d\d\d)(?:-)?(\d\d)(?:-)?(\d\d)$/i;function negativeValues(t){for(var e=0;e=6}function isNumber(t){return"number"===typeof t}var e=["bytes","KB","MB","GB","TB","PB","EB"];function formatValue(t,r,a,o){t=t||"";if(a.prefix){if(r<0){r*=-1;t+="-"}t+=a.prefix}var n=a.suffix||"";var i=a.precision;var s=a.round;if(a.byteScale){var l=r>=0;l||(r*=-1);var c=o?a.byteScale:r;var u;if(c>=0x1000000000000000){r/=0x1000000000000000;u=6}else if(c>=0x4000000000000){r/=0x4000000000000;u=5}else if(c>=1099511627776){r/=1099511627776;u=4}else if(c>=1073741824){r/=1073741824;u=3}else if(c>=1048576){r/=1048576;u=2}else if(c>=1024){r/=1024;u=1}else u=0;if(void 0===i&&void 0===s){if(r>=1023.5&&u=1e3?4:3}n=" "+e[u];l||(r*=-1)}if(void 0!==i&&void 0!==s)throw Error("Use either round or precision, not both");if(!o){if(void 0!==i){r=r.toPrecision(i);a.zeros||(r=parseFloat(r))}if(void 0!==s)if(s<0){var p=Math.pow(10,-1*s);r=parseInt((1*r/p).toFixed(0))*p}else{r=r.toFixed(s);a.zeros||(r=parseFloat(r))}}if(a.thousands||a.decimal){r=toStr(r);var h=r.split(".");r=h[0];a.thousands&&(r=r.replace(/\B(?=(\d{3})+(?!\d))/g,a.thousands));h.length>1&&(r+=(a.decimal||".")+h[1])}return t+r+n}function seriesOption(t,e,r){return r in e?e[r]:r in t.options?t.options[r]:null}var r={maintainAspectRatio:false,animation:false,plugins:{legend:{},tooltip:{displayColors:false,callbacks:{}},title:{font:{size:20},color:"#333"}},interaction:{}};var a={scales:{y:{ticks:{maxTicksLimit:4},title:{font:{size:16},color:"#333"},grid:{}},x:{grid:{drawOnChartArea:false},title:{font:{size:16},color:"#333"},time:{},ticks:{}}}};var o=["#3366CC","#DC3912","#FF9900","#109618","#990099","#3B3EAC","#0099C6","#DD4477","#66AA00","#B82E2E","#316395","#994499","#22AA99","#AAAA11","#6633CC","#E67300","#8B0707","#329262","#5574A6","#651067"];function hideLegend$2(t,e,r){if(void 0!==e){t.plugins.legend.display=!!e;e&&true!==e&&(t.plugins.legend.position=e)}else r&&(t.plugins.legend.display=false)}function setTitle$2(t,e){t.plugins.title.display=true;t.plugins.title.text=e}function setMin$2(t,e){null!==e&&(t.scales.y.min=toFloat(e))}function setMax$2(t,e){t.scales.y.max=toFloat(e)}function setBarMin$1(t,e){null!==e&&(t.scales.x.min=toFloat(e))}function setBarMax$1(t,e){t.scales.x.max=toFloat(e)}function setStacked$2(t,e){t.scales.x.stacked=!!e;t.scales.y.stacked=!!e}function setXtitle$2(t,e){t.scales.x.title.display=true;t.scales.x.title.text=e}function setYtitle$2(t,e){t.scales.y.title.display=true;t.scales.y.title.text=e}function addOpacity(t,e){var r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return r?"rgba("+parseInt(r[1],16)+", "+parseInt(r[2],16)+", "+parseInt(r[3],16)+", "+e+")":t}function notnull(t){return null!==t&&void 0!==t}function setLabelSize(t,e,r){var a=Math.ceil(t.element.offsetWidth/4/e.labels.length);a>25?a=25:a<10&&(a=10);r.scales.x.ticks.callback||(r.scales.x.ticks.callback=function(t){t=toStr(this.getLabelForValue(t));return t.length>a?t.substring(0,a-2)+"...":t})}function calculateScale(t){var e=1;var r=maxAbsY(t);while(r>=1024){e*=1024;r/=1024}return e}function setFormatOptions$1(t,e,r){var a={thousands:t.options.thousands,decimal:t.options.decimal};var o=merge({prefix:t.options.prefix,suffix:t.options.suffix,precision:t.options.precision,round:t.options.round,zeros:t.options.zeros},a);if(t.options.bytes){var n=t.data;"pie"===r&&(n=[{data:n}]);o.byteScale=calculateScale(n)}if("pie"!==r){var i=e.scales.y;"bar"===r&&(i=e.scales.x);if(o.byteScale){i.ticks.stepSize||(i.ticks.stepSize=o.byteScale/2);i.ticks.maxTicksLimit||(i.ticks.maxTicksLimit=4)}i.ticks.callback||(i.ticks.callback=function(t){return formatValue("",t,o,true)});"scatter"!==r&&"bubble"!==r||e.scales.x.ticks.callback||(e.scales.x.ticks.callback=function(t){return formatValue("",t,a,true)})}if(!e.plugins.tooltip.callbacks.label)if("scatter"===r)e.plugins.tooltip.callbacks.label=function(t){var e=t.dataset.label||"";e&&(e+=": ");var r=t.parsed;return e+"("+formatValue("",r.x,a)+", "+formatValue("",r.y,o)+")"};else if("bubble"===r)e.plugins.tooltip.callbacks.label=function(t){var e=t.dataset.label||"";e&&(e+=": ");var r=t.raw;return e+"("+formatValue("",r.x,a)+", "+formatValue("",r.y,o)+", "+formatValue("",r.v,a)+")"};else if("pie"===r)e.plugins.tooltip.callbacks.label=function(t){return formatValue("",t.parsed,o)};else{var s="bar"===r?"x":"y";e.plugins.tooltip.callbacks.label=function(t){if(null!==t.parsed[s]){var e=t.dataset.label||"";e&&(e+=": ");return formatValue(e,t.parsed[s],o)}}}if(("line"===r||"area"===r)&&"number"===t.xtype){e.scales.x.ticks.callback||(e.scales.x.ticks.callback=function(t){return toStr(t)});e.plugins.tooltip.callbacks.title||(e.plugins.tooltip.callbacks.title=function(t){return toStr(t[0].parsed.x)})}}function maxAbsY(t){var e=0;for(var r=0;re&&(e=n)}}return e}function maxR(t){var e=0;for(var r=0;re&&(e=n)}}return e}var n=jsOptionsFunc(merge(r,a),hideLegend$2,setTitle$2,setMin$2,setMax$2,setStacked$2,setXtitle$2,setYtitle$2);function prepareDefaultData(t){var e=t.data;var r={};var a=[];var o=[];var n=[];for(var i=0;i0){var w=(notnull(b)?toDate(b):n[0]).getTime();var _=(notnull(C)?toDate(C):n[0]).getTime();for(var S=1;S_&&(_=A)}var D=(_-w)/864e5;if(!e.scales.x.time.unit){var k;if("year"===x||D>3650){e.scales.x.time.unit="year";k=365}else if("month"===x||D>300){e.scales.x.time.unit="month";k=30}else if("week"===x||"day"===x||D>10){e.scales.x.time.unit="day";k=1}else if("hour"===x||D>.5){e.scales.x.time.displayFormats={hour:"MMM d, h a"};e.scales.x.time.unit="hour";k=1/24}else if("minute"===x){e.scales.x.time.displayFormats={minute:"h:mm a"};e.scales.x.time.unit="minute";k=1/24/60}if(k&&D>0){var T=t.element.offsetWidth;if(T>0){var O=Math.ceil(D/k/(T/100));"week"===x&&1===k&&(O=7*Math.ceil(O/7));e.scales.x.ticks.stepSize=O}}}e.scales.x.time.tooltipFormat||("year"===x?e.scales.x.time.tooltipFormat="yyyy":"month"===x?e.scales.x.time.tooltipFormat="MMM yyyy":"week"===x||"day"===x?e.scales.x.time.tooltipFormat="PP":"hour"===x?e.scales.x.time.tooltipFormat="MMM d, h a":"minute"===x&&(e.scales.x.time.tooltipFormat="h:mm a"))}}return{labels:n,datasets:l}}var i=function defaultExport(t){this.name="chartjs";this.library=t};i.prototype.renderLineChart=function renderLineChart(t,e){e||(e="line");var r={};var a=n(t,merge(r,t.options));setFormatOptions$1(t,a,e);var o=createDataTable(t,a,e);if("number"===t.xtype){a.scales.x.type=a.scales.x.type||"linear";a.scales.x.position=a.scales.x.position||"bottom"}else a.scales.x.type="string"===t.xtype?"category":"time";this.drawChart(t,"line",o,a)};i.prototype.renderPieChart=function renderPieChart(t){var e=merge({},r);t.options.donut&&(e.cutout="50%");"legend"in t.options&&hideLegend$2(e,t.options.legend);t.options.title&&setTitle$2(e,t.options.title);e=merge(e,t.options.library||{});setFormatOptions$1(t,e,"pie");var a=[];var n=[];for(var i=0;i● '+formatValue(this.series.name+": ",this.y,a)+"
"})}var c=function defaultExport(t){this.name="highcharts";this.library=t};c.prototype.renderLineChart=function renderLineChart(t,e){e=e||"spline";var r={};"areaspline"===e&&(r={plotOptions:{areaspline:{stacking:"normal"},area:{stacking:"normal"},series:{marker:{enabled:false}}}});false===t.options.curve&&("areaspline"===e?e="area":"spline"===e&&(e="line"));var a=l(t,t.options,r);"number"===t.xtype?a.xAxis.type=a.xAxis.type||"linear":a.xAxis.type="string"===t.xtype?"category":"datetime";a.chart.type||(a.chart.type=e);setFormatOptions(t,a,e);var o=t.data;for(var n=0;n0?new Error("No charting library found for "+t):new Error("No charting libraries found - be sure to include one before your charts")}var m={charts:{},configure:function(t){for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&(m.config[e]=t[e])},setDefaultOptions:function(t){m.options=t},eachChart:function(t){for(var e in m.charts)Object.prototype.hasOwnProperty.call(m.charts,e)&&t(m.charts[e])},destroyAll:function(){for(var t in m.charts)if(Object.prototype.hasOwnProperty.call(m.charts,t)){m.charts[t].destroy();delete m.charts[t]}},config:{},options:{},adapters:v,addAdapter:addAdapter,use:function(t){addAdapter(t);return m}};function formatSeriesBubble(t){var e=[];for(var r=0;r0)return false;return true}function addDownloadButton(t){var e=t.options.download;true===e?e={}:"string"===typeof e&&(e={filename:e});var r=document.createElement("a");r.download=e.filename||"chart.png";r.style.position="absolute";r.style.top="20px";r.style.right="20px";r.style.zIndex=1e3;r.style.lineHeight="20px";r.target="_blank";var a=document.createElement("img");var o='\x3c!--! Font Awesome Free 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2022 Fonticons, Inc. --\x3e';a.src="data:image/svg+xml;utf8,"+encodeURIComponent(o);a.alt="Download";a.style.width="20px";a.style.height="20px";a.style.border="none";r.appendChild(a);var n=t.element;n.style.position="relative";t.__downloadAttached=true;t.__enterEvent=n.addEventListener("mouseover",(function(a){var o=a.relatedTarget;if((!o||o!==this&&!this.contains(o))&&t.options.download){r.href=t.toImage(e);n.appendChild(r)}}));t.__leaveEvent=n.addEventListener("mouseout",(function(t){var e=t.relatedTarget;e&&(e===this||this.contains(e))||r.parentNode&&r.parentNode.removeChild(r)}))}var y=[];var g=0;var b=4;function pushRequest(t,e,r){y.push([t,e,r]);runNext()}function runNext(){if(g