rails_accordion 1.0.2 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4bfa0f128b5f7a07becf2938b2e6ab2ab30be152eecd15967b0a09ff08f2ed3
4
- data.tar.gz: c905d38999ab2d5e7ece8a82a319af597f116c241deb6ce1bc0d529c0c6757f6
3
+ metadata.gz: c5ea98000e2c670591c9b93fa2b9c21f1501b3ddb700bdbfe0816fabb6d3c345
4
+ data.tar.gz: 60b0c32d127152f8339c440c6533d2c26f1c1939b4c00533bb577fa11c93febb
5
5
  SHA512:
6
- metadata.gz: 51b624b4cbc11f354cda95330fb4f80d519d9db7fc00a455560919e92b9cdefd934889f57e03397d7dca9202f91cfc24413df1513f7fe790c06e08f9920f9171
7
- data.tar.gz: 244ee69d1dc5965145ce1961def630fc1b374a6b4bfbadcd1681f28bde92082e7ab1c49494e7fb3c515c111a65ae2e79a9884d30b3e9c3eca5634618aabdb1f5
6
+ metadata.gz: 9a8778db18c7c37322fe8d7a86af0016ab46d75cd94f46313906e940a21d5f88a10980c1f71dbd244102cf991ed78e9133cbf7e20a7e4084313943c53720cffc
7
+ data.tar.gz: 24d1599e528809393d397263661c62fd39644e0fa53b589486632c44e5036bdcb41cfb3643647f33f46644ba7f2a159838ed3258026b35a4802fee49aed5b832
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_accordion (1.0.0)
4
+ rails_accordion (1.0.4)
5
5
  stimulus-rails (~> 1.2)
6
6
  view_component (~> 2.52)
7
7
  zeitwerk (~> 2.6)
data/README.md CHANGED
@@ -1,65 +1,105 @@
1
1
  # RailsAccordion
2
2
 
3
- rails_accordion is a Ruby gem that provides an easy-to-use accordion component for use in Rails web applications. With this gem, developers can create collapsible sections of content that can be expanded or collapsed with a single click. The accordion is a great way to improve the user experience of your web application, by providing a clean and intuitive way to display complex information.
3
+ RailsAccordion is a Ruby gem that provides an easy-to-use accordion component for Rails web applications. This gem allows developers to create collapsible sections of content that can be expanded or collapsed with a single click. The accordion is a powerful tool to enhance the user experience of your web application by providing a clean and intuitive way to display complex information.
4
4
 
5
5
  ## Installation
6
6
 
7
- ```rb
7
+ To install RailsAccordion, add the following line to your application's Gemfile:
8
+
9
+ ```ruby
8
10
  gem 'rails_accordion'
9
11
  ```
10
12
 
13
+ Then, execute the following command to install the gem:
14
+
11
15
  ```shell
12
16
  bundle install
13
17
  ```
14
18
 
19
+ Next, run the generator to generate the necessary files:
20
+
15
21
  ```shell
16
22
  rails generate rails_accordion:install
17
23
  ```
18
24
 
19
- In `application.html.erb`, add:
25
+ In your `application.html.erb` layout file, add the following line:
20
26
 
21
27
  ```erb
22
28
  <%= rails_accordion_assets %>
23
29
  ```
24
30
 
25
- In `application_helper.rb`, add:
26
-
27
- ```rb
28
- include RailsAccordion::ApplicationHelper
29
- ```
30
-
31
-
32
31
  ## Usage
33
32
 
33
+ To use RailsAccordion, you can follow the example below:
34
+
34
35
  ```erb
35
36
  <%= accordion class: "bg-white rounded-xl overflow-auto" do %>
36
- <%= accordion_item do |item| %>
37
- <% item.header do %>
38
- Hello world
39
- <% end %>
40
- <% item.body do %>
41
- Hello accordion body
42
- <% end %>
37
+ <%= accordion_item do |item| %>
38
+ <% item.header do %>
39
+ Hello world
40
+ <% end %>
41
+ <% item.body do %>
42
+ Hello accordion body
43
43
  <% end %>
44
+ <% end %>
44
45
  <% end %>
45
46
  ```
46
47
 
47
48
  ### Options
48
49
 
49
- multiple_open: [true, false]
50
- default_state: 1. all_closed: All items are closed on page load. 2. all_opened: All items are opened. 3. first_opened: First item is opened by default
50
+ The RailsAccordion component accepts the following options:
51
51
 
52
+ - `multiple_open`: Determines whether multiple accordion items can be open at the same time. Accepted values are `true` or `false`.
53
+ - `default_state`: Sets the default state of the accordion items on page load. Accepted values are:
54
+ - `all_closed`: All items are closed on page load.
55
+ - `all_opened`: All items are opened on page load.
56
+ - `first_opened`: The first item is opened by default.
57
+
58
+ Example usage:
59
+
60
+ ```erb
52
61
  <%= accordion class: "bg-white rounded-xl overflow-auto", default_state: :all_opened do %>
62
+ <!-- accordion items -->
63
+ <% end %>
64
+ ```
53
65
 
54
66
  ## Development
55
67
 
56
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
68
+ After checking out the repository, run the following command to install the dependencies:
69
+
70
+ ```shell
71
+ bin/setup
72
+ ```
73
+
74
+ You can run the tests using the following command:
75
+
76
+ ```shell
77
+ rake spec
78
+ ```
79
+
80
+ For an interactive prompt to experiment with the gem, you can use the following command:
81
+
82
+ ```shell
83
+ bin/console
84
+ ```
85
+
86
+ To install the gem locally, run the following command:
87
+
88
+ ```shell
89
+ bundle exec rake install
90
+ ```
91
+
92
+ To release a new version, update the version number in `version.rb`, and then run the following command:
93
+
94
+ ```shell
95
+ bundle exec rake release
96
+ ```
57
97
 
58
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
98
+ This command will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
59
99
 
60
100
  ## Contributing
61
101
 
62
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/rails_accordion. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Tajbrains/rails_accordion/blob/master/CODE_OF_CONDUCT.md).
102
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/Tajbrains/rails_accordion](https://github.com/Tajbrains/rails_accordion). We strive to provide a safe and welcoming space for collaboration, and we expect contributors to adhere to the [code of conduct](https://github.com/Tajbrains/rails_accordion/blob/master/CODE_OF_CONDUCT.md).
63
103
 
64
104
  ## License
65
105
 
@@ -67,4 +107,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
67
107
 
68
108
  ## Code of Conduct
69
109
 
70
- Everyone interacting in the RailsAccordion project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rails_accordion/blob/master/CODE_OF_CONDUCT.md).
110
+ Everyone interacting in the RailsAccordion project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the [code of conduct](https://github.com/Tajbrains/rails_accordion/blob/master/CODE_OF_CONDUCT.md).
@@ -1,4 +1,3 @@
1
- import 'mapkick/bundle'
2
1
  import AccordionController from './controllers/accordion_controller'
3
2
  import { Application } from '@hotwired/stimulus'
4
3
 
@@ -7,5 +6,3 @@ const application = Application.start()
7
6
  window.Stimulus = application
8
7
 
9
8
  application.register('accordion', AccordionController)
10
-
11
- export { application }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsAccordion
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.4"
5
5
  end
@@ -7,9 +7,37 @@ loader.ignore("#{__dir__}/generators")
7
7
  loader.setup
8
8
 
9
9
  module RailsAccordion
10
+ class Railtie < Rails::Railtie
11
+ ActiveSupport.on_load :action_view do
12
+ include RailsAccordion
13
+ end
14
+ end
15
+
16
+ class Engine < ::Rails::Engine
17
+ isolate_namespace RailsAccordion
18
+
19
+ config.app_middleware.use(
20
+ Rack::Static,
21
+ urls: ["/rails_accordion_assets"],
22
+ root: RailsAccordion::Engine.root.join("public")
23
+ )
24
+ end
25
+
10
26
  def self.root
11
27
  RailsAccordion::Engine.routes.find_script_name({})
12
28
  end
29
+
30
+ def accordion(**args, &block)
31
+ render AccordionComponent.new(**args), &block
32
+ end
33
+
34
+ def accordion_item(**args, &block)
35
+ render ItemComponent.new(**args), &block
36
+ end
37
+
38
+ def rails_accordion_assets
39
+ render "rails_accordion/assets"
40
+ end
13
41
  end
14
42
 
15
43
  loader.eager_load
@@ -1,7 +1,4 @@
1
- namespace :rails_accordion do
2
- desc "Build for release"
3
- task :build do
4
- `yarn build`
5
- `cp -r ./app/assets/builds/* ./public/rails_accordion_assets`
6
- end
1
+ desc "Build for release"
2
+ task :build do
3
+ `yarn build`
7
4
  end
@@ -0,0 +1 @@
1
+ /*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/*,:after,:before{box-sizing:border-box;border:0 solid #e5e7eb}:after,:before{--tw-content:""}html{line-height:1.5;-webkit-text-size-adjust:100%;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,pre,samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button;background-color:initial;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:initial}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dd,dl,figure,h1,h2,h3,h4,h5,h6,hr,p,pre{margin:0}fieldset{margin:0}fieldset,legend{padding:0}menu,ol,ul{list-style:none;margin:0;padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}[role=button],button{cursor:pointer}:disabled{cursor:default}audio,canvas,embed,iframe,img,object,svg,video{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,::backdrop,:after,:before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.accordion_content{height:0;width:100%;overflow:hidden;transition-property:all;transition-duration:.15s;transition-timing-function:cubic-bezier(.4,0,.2,1)}.accordion_toggle{cursor:pointer}.accordion_content-container{height:max-content}
@@ -0,0 +1,6 @@
1
+ (()=>{var se=Object.defineProperty;var re=(r,e,t)=>e in r?se(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var O=(r,e,t)=>(re(r,typeof e!="symbol"?e+"":e,t),t);var w=class{constructor(e,t,s){this.eventTarget=e,this.eventName=t,this.eventOptions=s,this.unorderedBindings=new Set}connect(){this.eventTarget.addEventListener(this.eventName,this,this.eventOptions)}disconnect(){this.eventTarget.removeEventListener(this.eventName,this,this.eventOptions)}bindingConnected(e){this.unorderedBindings.add(e)}bindingDisconnected(e){this.unorderedBindings.delete(e)}handleEvent(e){let t=ne(e);for(let s of this.bindings){if(t.immediatePropagationStopped)break;s.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let s=e.index,n=t.index;return s<n?-1:s>n?1:0})}};function ne(r){if("immediatePropagationStopped"in r)return r;{let{stopImmediatePropagation:e}=r;return Object.assign(r,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}var M=class{constructor(e){this.application=e,this.eventListenerMaps=new Map,this.started=!1}start(){this.started||(this.started=!0,this.eventListeners.forEach(e=>e.connect()))}stop(){this.started&&(this.started=!1,this.eventListeners.forEach(e=>e.disconnect()))}get eventListeners(){return Array.from(this.eventListenerMaps.values()).reduce((e,t)=>e.concat(Array.from(t.values())),[])}bindingConnected(e){this.fetchEventListenerForBinding(e).bindingConnected(e)}bindingDisconnected(e,t=!1){this.fetchEventListenerForBinding(e).bindingDisconnected(e),t&&this.clearEventListenersForBinding(e)}handleError(e,t,s={}){this.application.handleError(e,`Error ${t}`,s)}clearEventListenersForBinding(e){let t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:s,eventOptions:n}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(s,n);i.delete(o),i.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:s,eventOptions:n}=e;return this.fetchEventListener(t,s,n)}fetchEventListener(e,t,s){let n=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,s),o=n.get(i);return o||(o=this.createEventListener(e,t,s),n.set(i,o)),o}createEventListener(e,t,s){let n=new w(e,t,s);return this.started&&n.connect(),n}fetchEventListenerMapForEventTarget(e){let t=this.eventListenerMaps.get(e);return t||(t=new Map,this.eventListenerMaps.set(e,t)),t}cacheKey(e,t){let s=[e];return Object.keys(t).sort().forEach(n=>{s.push(`${t[n]?"":"!"}${n}`)}),s.join(":")}},ie={stop({event:r,value:e}){return e&&r.stopPropagation(),!0},prevent({event:r,value:e}){return e&&r.preventDefault(),!0},self({event:r,value:e,element:t}){return e?t===r.target:!0}},oe=/^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function ae(r){let t=r.trim().match(oe)||[],s=t[1],n=t[2];return n&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${n}`,n=""),{eventTarget:ce(t[3]),eventName:s,eventOptions:t[6]?le(t[6]):{},identifier:t[4],methodName:t[5],keyFilter:n}}function ce(r){if(r=="window")return window;if(r=="document")return document}function le(r){return r.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function he(r){if(r==window)return"window";if(r==document)return"document"}function q(r){return r.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function k(r){return q(r.replace(/--/g,"-").replace(/__/g,"_"))}function m(r){return r.charAt(0).toUpperCase()+r.slice(1)}function X(r){return r.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function ue(r){return r.match(/[^\s]+/g)||[]}var B=class{constructor(e,t,s,n){this.element=e,this.index=t,this.eventTarget=s.eventTarget||e,this.eventName=s.eventName||de(e)||y("missing event name"),this.eventOptions=s.eventOptions||{},this.identifier=s.identifier||y("missing identifier"),this.methodName=s.methodName||y("missing method name"),this.keyFilter=s.keyFilter||"",this.schema=n}static forToken(e,t){return new this(e.element,e.index,ae(e.content),t)}toString(){let e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}isFilterTarget(e){if(!this.keyFilter)return!1;let t=this.keyFilter.split("+"),s=["meta","ctrl","alt","shift"],[n,i,o,a]=s.map(d=>t.includes(d));if(e.metaKey!==n||e.ctrlKey!==i||e.altKey!==o||e.shiftKey!==a)return!0;let c=t.filter(d=>!s.includes(d))[0];return c?(Object.prototype.hasOwnProperty.call(this.keyMappings,c)||y(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[c].toLowerCase()!==e.key.toLowerCase()):!1}get params(){let e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:s,value:n}of Array.from(this.element.attributes)){let i=s.match(t),o=i&&i[1];o&&(e[q(o)]=fe(n))}return e}get eventTargetName(){return he(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}},J={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:r=>r.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function de(r){let e=r.tagName.toLowerCase();if(e in J)return J[e](r)}function y(r){throw new Error(r)}function fe(r){try{return JSON.parse(r)}catch{return r}}var F=class{constructor(e,t){this.context=e,this.action=t}get index(){return this.action.index}get eventTarget(){return this.action.eventTarget}get eventOptions(){return this.action.eventOptions}get identifier(){return this.context.identifier}handleEvent(e){this.willBeInvokedByEvent(e)&&this.applyEventModifiers(e)&&this.invokeWithEvent(e)}get eventName(){return this.action.eventName}get method(){let e=this.controller[this.methodName];if(typeof e=="function")return e;throw new Error(`Action "${this.action}" references undefined method "${this.methodName}"`)}applyEventModifiers(e){let{element:t}=this.action,{actionDescriptorFilters:s}=this.context.application,n=!0;for(let[i,o]of Object.entries(this.eventOptions))if(i in s){let a=s[i];n=n&&a({name:i,value:o,event:e,element:t})}else continue;return n}invokeWithEvent(e){let{target:t,currentTarget:s}=e;try{let{params:n}=this.action,i=Object.assign(e,{params:n});this.method.call(this.controller,i),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:s,action:this.methodName})}catch(n){let{identifier:i,controller:o,element:a,index:c}=this,d={identifier:i,controller:o,element:a,index:c,event:e};this.context.handleError(n,`invoking action "${this.action}"`,d)}}willBeInvokedByEvent(e){let t=e.target;return e instanceof KeyboardEvent&&this.action.isFilterTarget(e)?!1:this.element===t?!0:t instanceof Element&&this.element.contains(t)?this.scope.containsElement(t):this.scope.containsElement(this.action.element)}get controller(){return this.context.controller}get methodName(){return this.action.methodName}get element(){return this.scope.element}get scope(){return this.context.scope}},b=class{constructor(e,t){this.mutationObserverInit={attributes:!0,childList:!0,subtree:!0},this.element=e,this.started=!1,this.delegate=t,this.elements=new Set,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,this.mutationObserverInit),this.refresh())}pause(e){this.started&&(this.mutationObserver.disconnect(),this.started=!1),e(),this.started||(this.mutationObserver.observe(this.element,this.mutationObserverInit),this.started=!0)}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started){let e=new Set(this.matchElementsInTree());for(let t of Array.from(this.elements))e.has(t)||this.removeElement(t);for(let t of Array.from(e))this.addElement(t)}}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){e.type=="attributes"?this.processAttributeChange(e.target,e.attributeName):e.type=="childList"&&(this.processRemovedNodes(e.removedNodes),this.processAddedNodes(e.addedNodes))}processAttributeChange(e,t){let s=e;this.elements.has(s)?this.delegate.elementAttributeChanged&&this.matchElement(s)?this.delegate.elementAttributeChanged(s,t):this.removeElement(s):this.matchElement(s)&&this.addElement(s)}processRemovedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);s&&this.processTree(s,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let s=this.elementFromNode(t);s&&this.elementIsActive(s)&&this.processTree(s,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(let s of this.matchElementsInTree(e))t.call(this,s)}elementFromNode(e){if(e.nodeType==Node.ELEMENT_NODE)return e}elementIsActive(e){return e.isConnected!=this.element.isConnected?!1:this.element.contains(e)}addElement(e){this.elements.has(e)||this.elementIsActive(e)&&(this.elements.add(e),this.delegate.elementMatched&&this.delegate.elementMatched(e))}removeElement(e){this.elements.has(e)&&(this.elements.delete(e),this.delegate.elementUnmatched&&this.delegate.elementUnmatched(e))}},C=class{constructor(e,t,s){this.attributeName=t,this.delegate=s,this.elementObserver=new b(e,this)}get element(){return this.elementObserver.element}get selector(){return`[${this.attributeName}]`}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get started(){return this.elementObserver.started}matchElement(e){return e.hasAttribute(this.attributeName)}matchElementsInTree(e){let t=this.matchElement(e)?[e]:[],s=Array.from(e.querySelectorAll(this.selector));return t.concat(s)}elementMatched(e){this.delegate.elementMatchedAttribute&&this.delegate.elementMatchedAttribute(e,this.attributeName)}elementUnmatched(e){this.delegate.elementUnmatchedAttribute&&this.delegate.elementUnmatchedAttribute(e,this.attributeName)}elementAttributeChanged(e,t){this.delegate.elementAttributeValueChanged&&this.attributeName==t&&this.delegate.elementAttributeValueChanged(e,t)}};function ge(r,e,t){Y(r,e).add(t)}function me(r,e,t){Y(r,e).delete(t),pe(r,e)}function Y(r,e){let t=r.get(e);return t||(t=new Set,r.set(e,t)),t}function pe(r,e){let t=r.get(e);t!=null&&t.size==0&&r.delete(e)}var l=class{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t.concat(Array.from(s)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((t,s)=>t+s.size,0)}add(e,t){ge(this.valuesByKey,e,t)}delete(e,t){me(this.valuesByKey,e,t)}has(e,t){let s=this.valuesByKey.get(e);return s!=null&&s.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(s=>s.has(e))}getValuesForKey(e){let t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,s])=>s.has(e)).map(([t,s])=>t)}};var T=class{constructor(e,t,s,n={}){this.selector=t,this.details=n,this.elementObserver=new b(e,this),this.delegate=s,this.matchesByElement=new l}get started(){return this.elementObserver.started}start(){this.elementObserver.start()}pause(e){this.elementObserver.pause(e)}stop(){this.elementObserver.stop()}refresh(){this.elementObserver.refresh()}get element(){return this.elementObserver.element}matchElement(e){let t=e.matches(this.selector);return this.delegate.selectorMatchElement?t&&this.delegate.selectorMatchElement(e,this.details):t}matchElementsInTree(e){let t=this.matchElement(e)?[e]:[],s=Array.from(e.querySelectorAll(this.selector)).filter(n=>this.matchElement(n));return t.concat(s)}elementMatched(e){this.selectorMatched(e)}elementUnmatched(e){this.selectorUnmatched(e)}elementAttributeChanged(e,t){let s=this.matchElement(e),n=this.matchesByElement.has(this.selector,e);!s&&n&&this.selectorUnmatched(e)}selectorMatched(e){this.delegate.selectorMatched&&(this.delegate.selectorMatched(e,this.selector,this.details),this.matchesByElement.add(this.selector,e))}selectorUnmatched(e){this.delegate.selectorUnmatched(e,this.selector,this.details),this.matchesByElement.delete(this.selector,e)}},$=class{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(s=>this.processMutations(s))}start(){this.started||(this.started=!0,this.mutationObserver.observe(this.element,{attributes:!0,attributeOldValue:!0}),this.refresh())}stop(){this.started&&(this.mutationObserver.takeRecords(),this.mutationObserver.disconnect(),this.started=!1)}refresh(){if(this.started)for(let e of this.knownAttributeNames)this.refreshAttribute(e,null)}processMutations(e){if(this.started)for(let t of e)this.processMutation(t)}processMutation(e){let t=e.attributeName;t&&this.refreshAttribute(t,e.oldValue)}refreshAttribute(e,t){let s=this.delegate.getStringMapKeyForAttribute(e);if(s!=null){this.stringMap.has(e)||this.stringMapKeyAdded(s,e);let n=this.element.getAttribute(e);if(this.stringMap.get(e)!=n&&this.stringMapValueChanged(n,s,t),n==null){let i=this.stringMap.get(e);this.stringMap.delete(e),i&&this.stringMapKeyRemoved(s,e,i)}else this.stringMap.set(e,n)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,s){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,s)}stringMapKeyRemoved(e,t,s){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,s)}get knownAttributeNames(){return Array.from(new Set(this.currentAttributeNames.concat(this.recordedAttributeNames)))}get currentAttributeNames(){return Array.from(this.element.attributes).map(e=>e.name)}get recordedAttributeNames(){return Array.from(this.stringMap.keys())}},v=class{constructor(e,t,s){this.attributeObserver=new C(e,t,this),this.delegate=s,this.tokensByElement=new l}get started(){return this.attributeObserver.started}start(){this.attributeObserver.start()}pause(e){this.attributeObserver.pause(e)}stop(){this.attributeObserver.stop()}refresh(){this.attributeObserver.refresh()}get element(){return this.attributeObserver.element}get attributeName(){return this.attributeObserver.attributeName}elementMatchedAttribute(e){this.tokensMatched(this.readTokensForElement(e))}elementAttributeValueChanged(e){let[t,s]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(s)}elementUnmatchedAttribute(e){this.tokensUnmatched(this.tokensByElement.getValuesForKey(e))}tokensMatched(e){e.forEach(t=>this.tokenMatched(t))}tokensUnmatched(e){e.forEach(t=>this.tokenUnmatched(t))}tokenMatched(e){this.delegate.tokenMatched(e),this.tokensByElement.add(e.element,e)}tokenUnmatched(e){this.delegate.tokenUnmatched(e),this.tokensByElement.delete(e.element,e)}refreshTokensForElement(e){let t=this.tokensByElement.getValuesForKey(e),s=this.readTokensForElement(e),n=be(t,s).findIndex(([i,o])=>!ve(i,o));return n==-1?[[],[]]:[t.slice(n),s.slice(n)]}readTokensForElement(e){let t=this.attributeName,s=e.getAttribute(t)||"";return ye(s,e,t)}};function ye(r,e,t){return r.trim().split(/\s+/).filter(s=>s.length).map((s,n)=>({element:e,attributeName:t,content:s,index:n}))}function be(r,e){let t=Math.max(r.length,e.length);return Array.from({length:t},(s,n)=>[r[n],e[n]])}function ve(r,e){return r&&e&&r.index==e.index&&r.content==e.content}var E=class{constructor(e,t,s){this.tokenListObserver=new v(e,t,this),this.delegate=s,this.parseResultsByToken=new WeakMap,this.valuesByTokenByElement=new WeakMap}get started(){return this.tokenListObserver.started}start(){this.tokenListObserver.start()}stop(){this.tokenListObserver.stop()}refresh(){this.tokenListObserver.refresh()}get element(){return this.tokenListObserver.element}get attributeName(){return this.tokenListObserver.attributeName}tokenMatched(e){let{element:t}=e,{value:s}=this.fetchParseResultForToken(e);s&&(this.fetchValuesByTokenForElement(t).set(e,s),this.delegate.elementMatchedValue(t,s))}tokenUnmatched(e){let{element:t}=e,{value:s}=this.fetchParseResultForToken(e);s&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,s))}fetchParseResultForToken(e){let t=this.parseResultsByToken.get(e);return t||(t=this.parseToken(e),this.parseResultsByToken.set(e,t)),t}fetchValuesByTokenForElement(e){let t=this.valuesByTokenByElement.get(e);return t||(t=new Map,this.valuesByTokenByElement.set(e,t)),t}parseToken(e){try{return{value:this.delegate.parseValueForToken(e)}}catch(t){return{error:t}}}},N=class{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new E(this.element,this.actionAttribute,this),this.valueListObserver.start())}stop(){this.valueListObserver&&(this.valueListObserver.stop(),delete this.valueListObserver,this.disconnectAllActions())}get element(){return this.context.element}get identifier(){return this.context.identifier}get actionAttribute(){return this.schema.actionAttribute}get schema(){return this.context.schema}get bindings(){return Array.from(this.bindingsByAction.values())}connectAction(e){let t=new F(this.context,e);this.bindingsByAction.set(e,t),this.delegate.bindingConnected(t)}disconnectAction(e){let t=this.bindingsByAction.get(e);t&&(this.bindingsByAction.delete(e),this.delegate.bindingDisconnected(t))}disconnectAllActions(){this.bindings.forEach(e=>this.delegate.bindingDisconnected(e,!0)),this.bindingsByAction.clear()}parseValueForToken(e){let t=B.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}},D=class{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new $(this.element,this),this.valueDescriptorMap=this.controller.valueDescriptorMap}start(){this.stringMapObserver.start(),this.invokeChangedCallbacksForDefaultValues()}stop(){this.stringMapObserver.stop()}get element(){return this.context.element}get controller(){return this.context.controller}getStringMapKeyForAttribute(e){if(e in this.valueDescriptorMap)return this.valueDescriptorMap[e].name}stringMapKeyAdded(e,t){let s=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,s.writer(this.receiver[e]),s.writer(s.defaultValue))}stringMapValueChanged(e,t,s){let n=this.valueDescriptorNameMap[t];e!==null&&(s===null&&(s=n.writer(n.defaultValue)),this.invokeChangedCallback(t,e,s))}stringMapKeyRemoved(e,t,s){let n=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,n.writer(this.receiver[e]),s):this.invokeChangedCallback(e,n.writer(n.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:s,writer:n}of this.valueDescriptors)s!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,n(s),void 0)}invokeChangedCallback(e,t,s){let n=`${e}Changed`,i=this.receiver[n];if(typeof i=="function"){let o=this.valueDescriptorNameMap[e];try{let a=o.reader(t),c=s;s&&(c=o.reader(s)),i.call(this.receiver,a,c)}catch(a){throw a instanceof TypeError&&(a.message=`Stimulus Value "${this.context.identifier}.${o.name}" - ${a.message}`),a}}}get valueDescriptors(){let{valueDescriptorMap:e}=this;return Object.keys(e).map(t=>e[t])}get valueDescriptorNameMap(){let e={};return Object.keys(this.valueDescriptorMap).forEach(t=>{let s=this.valueDescriptorMap[t];e[s.name]=s}),e}hasValue(e){let t=this.valueDescriptorNameMap[e],s=`has${m(t.name)}`;return this.receiver[s]}},x=class{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new l}start(){this.tokenListObserver||(this.tokenListObserver=new v(this.element,this.attributeName,this),this.tokenListObserver.start())}stop(){this.tokenListObserver&&(this.disconnectAllTargets(),this.tokenListObserver.stop(),delete this.tokenListObserver)}tokenMatched({element:e,content:t}){this.scope.containsElement(e)&&this.connectTarget(e,t)}tokenUnmatched({element:e,content:t}){this.disconnectTarget(e,t)}connectTarget(e,t){var s;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var s;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),(s=this.tokenListObserver)===null||s===void 0||s.pause(()=>this.delegate.targetDisconnected(e,t)))}disconnectAllTargets(){for(let e of this.targetsByName.keys)for(let t of this.targetsByName.getValuesForKey(e))this.disconnectTarget(t,e)}get attributeName(){return`data-${this.context.identifier}-target`}get element(){return this.context.element}get scope(){return this.context.scope}};function p(r,e){let t=G(r);return Array.from(t.reduce((s,n)=>(Ae(n,e).forEach(i=>s.add(i)),s),new Set))}function Ee(r,e){return G(r).reduce((s,n)=>(s.push(...Oe(n,e)),s),[])}function G(r){let e=[];for(;r;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function Ae(r,e){let t=r[e];return Array.isArray(t)?t:[]}function Oe(r,e){let t=r[e];return t?Object.keys(t).map(s=>[s,t[s]]):[]}var S=class{constructor(e,t){this.context=e,this.delegate=t,this.outletsByName=new l,this.outletElementsByName=new l,this.selectorObserverMap=new Map}start(){this.selectorObserverMap.size===0&&(this.outletDefinitions.forEach(e=>{let t=this.selector(e),s={outletName:e};t&&this.selectorObserverMap.set(e,new T(document.body,t,this,s))}),this.selectorObserverMap.forEach(e=>e.start())),this.dependentContexts.forEach(e=>e.refresh())}stop(){this.selectorObserverMap.size>0&&(this.disconnectAllOutlets(),this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}refresh(){this.selectorObserverMap.forEach(e=>e.refresh())}selectorMatched(e,t,{outletName:s}){let n=this.getOutlet(e,s);n&&this.connectOutlet(n,e,s)}selectorUnmatched(e,t,{outletName:s}){let n=this.getOutletFromMap(e,s);n&&this.disconnectOutlet(n,e,s)}selectorMatchElement(e,{outletName:t}){return this.hasOutlet(e,t)&&e.matches(`[${this.context.application.schema.controllerAttribute}~=${t}]`)}connectOutlet(e,t,s){var n;this.outletElementsByName.has(s,t)||(this.outletsByName.add(s,e),this.outletElementsByName.add(s,t),(n=this.selectorObserverMap.get(s))===null||n===void 0||n.pause(()=>this.delegate.outletConnected(e,t,s)))}disconnectOutlet(e,t,s){var n;this.outletElementsByName.has(s,t)&&(this.outletsByName.delete(s,e),this.outletElementsByName.delete(s,t),(n=this.selectorObserverMap.get(s))===null||n===void 0||n.pause(()=>this.delegate.outletDisconnected(e,t,s)))}disconnectAllOutlets(){for(let e of this.outletElementsByName.keys)for(let t of this.outletElementsByName.getValuesForKey(e))for(let s of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(s,t,e)}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}get outletDependencies(){let e=new l;return this.router.modules.forEach(t=>{let s=t.definition.controllerConstructor;p(s,"outlets").forEach(i=>e.add(i,t.identifier))}),e}get outletDefinitions(){return this.outletDependencies.getKeysForValue(this.identifier)}get dependentControllerIdentifiers(){return this.outletDependencies.getValuesForKey(this.identifier)}get dependentContexts(){let e=this.dependentControllerIdentifiers;return this.router.contexts.filter(t=>e.includes(t.identifier))}hasOutlet(e,t){return!!this.getOutlet(e,t)||!!this.getOutletFromMap(e,t)}getOutlet(e,t){return this.application.getControllerForElementAndIdentifier(e,t)}getOutletFromMap(e,t){return this.outletsByName.getValuesForKey(t).find(s=>s.element===e)}get scope(){return this.context.scope}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}},L=class{constructor(e,t){this.logDebugActivity=(s,n={})=>{let{identifier:i,controller:o,element:a}=this;n=Object.assign({identifier:i,controller:o,element:a},n),this.application.logDebugActivity(this.identifier,s,n)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new N(this,this.dispatcher),this.valueObserver=new D(this,this.controller),this.targetObserver=new x(this,this),this.outletObserver=new S(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(s){this.handleError(s,"initializing controller")}}connect(){this.bindingObserver.start(),this.valueObserver.start(),this.targetObserver.start(),this.outletObserver.start();try{this.controller.connect(),this.logDebugActivity("connect")}catch(e){this.handleError(e,"connecting controller")}}refresh(){this.outletObserver.refresh()}disconnect(){try{this.controller.disconnect(),this.logDebugActivity("disconnect")}catch(e){this.handleError(e,"disconnecting controller")}this.outletObserver.stop(),this.targetObserver.stop(),this.valueObserver.stop(),this.bindingObserver.stop()}get application(){return this.module.application}get identifier(){return this.module.identifier}get schema(){return this.application.schema}get dispatcher(){return this.application.dispatcher}get element(){return this.scope.element}get parentElement(){return this.element.parentElement}handleError(e,t,s={}){let{identifier:n,controller:i,element:o}=this;s=Object.assign({identifier:n,controller:i,element:o},s),this.application.handleError(e,`Error ${t}`,s)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,s){this.invokeControllerMethod(`${k(s)}OutletConnected`,e,t)}outletDisconnected(e,t,s){this.invokeControllerMethod(`${k(s)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let s=this.controller;typeof s[e]=="function"&&s[e](...t)}};function we(r){return Me(r,ke(r))}function Me(r,e){let t=Te(r),s=Be(r.prototype,e);return Object.defineProperties(t.prototype,s),t}function ke(r){return p(r,"blessings").reduce((t,s)=>{let n=s(r);for(let i in n){let o=t[i]||{};t[i]=Object.assign(o,n[i])}return t},{})}function Be(r,e){return Ce(e).reduce((t,s)=>{let n=Fe(r,e,s);return n&&Object.assign(t,{[s]:n}),t},{})}function Fe(r,e,t){let s=Object.getOwnPropertyDescriptor(r,t);if(!(s&&"value"in s)){let i=Object.getOwnPropertyDescriptor(e,t).value;return s&&(i.get=s.get||i.get,i.set=s.set||i.set),i}}var Ce=(()=>typeof Object.getOwnPropertySymbols=="function"?r=>[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]:Object.getOwnPropertyNames)(),Te=(()=>{function r(t){function s(){return Reflect.construct(t,arguments,new.target)}return s.prototype=Object.create(t.prototype,{constructor:{value:s}}),Reflect.setPrototypeOf(s,t),s}function e(){let s=r(function(){this.a.call(this)});return s.prototype.a=function(){},new s}try{return e(),r}catch{return s=>class extends s{}}})();function $e(r){return{identifier:r.identifier,controllerConstructor:we(r.controllerConstructor)}}var V=class{constructor(e,t){this.application=e,this.definition=$e(t),this.contextsByScope=new WeakMap,this.connectedContexts=new Set}get identifier(){return this.definition.identifier}get controllerConstructor(){return this.definition.controllerConstructor}get contexts(){return Array.from(this.connectedContexts)}connectContextForScope(e){let t=this.fetchContextForScope(e);this.connectedContexts.add(t),t.connect()}disconnectContextForScope(e){let t=this.contextsByScope.get(e);t&&(this.connectedContexts.delete(t),t.disconnect())}fetchContextForScope(e){let t=this.contextsByScope.get(e);return t||(t=new L(this,e),this.contextsByScope.set(e,t)),t}},K=class{constructor(e){this.scope=e}has(e){return this.data.has(this.getDataKey(e))}get(e){return this.getAll(e)[0]}getAll(e){let t=this.data.get(this.getDataKey(e))||"";return ue(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}},j=class{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get(e){let t=this.getAttributeNameForKey(e);return this.element.getAttribute(t)}set(e,t){let s=this.getAttributeNameForKey(e);return this.element.setAttribute(s,t),this.get(e)}has(e){let t=this.getAttributeNameForKey(e);return this.element.hasAttribute(t)}delete(e){if(this.has(e)){let t=this.getAttributeNameForKey(e);return this.element.removeAttribute(t),!0}else return!1}getAttributeNameForKey(e){return`data-${this.identifier}-${X(e)}`}},I=class{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,s){let n=this.warnedKeysByObject.get(e);n||(n=new Set,this.warnedKeysByObject.set(e,n)),n.has(t)||(n.add(t),this.logger.warn(s,e))}};function P(r,e){return`[${r}~="${e}"]`}var _=class{constructor(e){this.scope=e}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findTarget(s)||this.findLegacyTarget(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllTargets(s),...this.findAllLegacyTargets(s)],[])}findTarget(e){let t=this.getSelectorForTargetName(e);return this.scope.findElement(t)}findAllTargets(e){let t=this.getSelectorForTargetName(e);return this.scope.findAllElements(t)}getSelectorForTargetName(e){let t=this.schema.targetAttributeForScope(this.identifier);return P(t,e)}findLegacyTarget(e){let t=this.getLegacySelectorForTargetName(e);return this.deprecate(this.scope.findElement(t),e)}findAllLegacyTargets(e){let t=this.getLegacySelectorForTargetName(e);return this.scope.findAllElements(t).map(s=>this.deprecate(s,e))}getLegacySelectorForTargetName(e){let t=`${this.identifier}.${e}`;return P(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:s}=this,n=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(s);this.guide.warn(e,`target:${t}`,`Please replace ${n}="${s}.${t}" with ${i}="${t}". The ${n} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}},R=class{constructor(e,t){this.scope=e,this.controllerElement=t}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get schema(){return this.scope.schema}has(e){return this.find(e)!=null}find(...e){return e.reduce((t,s)=>t||this.findOutlet(s),void 0)}findAll(...e){return e.reduce((t,s)=>[...t,...this.findAllOutlets(s)],[])}getSelectorForOutletName(e){let t=this.schema.outletAttributeForScope(this.identifier,e);return this.controllerElement.getAttribute(t)}findOutlet(e){let t=this.getSelectorForOutletName(e);if(t)return this.findElement(t,e)}findAllOutlets(e){let t=this.getSelectorForOutletName(e);return t?this.findAllElements(t,e):[]}findElement(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(n=>this.matchesElement(n,e,t))}matchesElement(e,t,s){let n=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&n.split(" ").includes(s)}},f=class{constructor(e,t,s,n){this.targets=new _(this),this.classes=new K(this),this.data=new j(this),this.containsElement=i=>i.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=s,this.guide=new I(n),this.outlets=new R(this.documentScope,t)}findElement(e){return this.element.matches(e)?this.element:this.queryElements(e).find(this.containsElement)}findAllElements(e){return[...this.element.matches(e)?[this.element]:[],...this.queryElements(e).filter(this.containsElement)]}queryElements(e){return Array.from(this.element.querySelectorAll(e))}get controllerSelector(){return P(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new f(this.schema,document.documentElement,this.identifier,this.guide.logger)}},U=class{constructor(e,t,s){this.element=e,this.schema=t,this.delegate=s,this.valueListObserver=new E(this.element,this.controllerAttribute,this),this.scopesByIdentifierByElement=new WeakMap,this.scopeReferenceCounts=new WeakMap}start(){this.valueListObserver.start()}stop(){this.valueListObserver.stop()}get controllerAttribute(){return this.schema.controllerAttribute}parseValueForToken(e){let{element:t,content:s}=e,n=this.fetchScopesByIdentifierForElement(t),i=n.get(s);return i||(i=this.delegate.createScopeForElementAndIdentifier(t,s),n.set(s,i)),i}elementMatchedValue(e,t){let s=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,s),s==1&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let s=this.scopeReferenceCounts.get(t);s&&(this.scopeReferenceCounts.set(t,s-1),s==1&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}},z=class{constructor(e){this.application=e,this.scopeObserver=new U(this.element,this.schema,this),this.scopesByIdentifier=new l,this.modulesByIdentifier=new Map}get element(){return this.application.element}get schema(){return this.application.schema}get logger(){return this.application.logger}get controllerAttribute(){return this.schema.controllerAttribute}get modules(){return Array.from(this.modulesByIdentifier.values())}get contexts(){return this.modules.reduce((e,t)=>e.concat(t.contexts),[])}start(){this.scopeObserver.start()}stop(){this.scopeObserver.stop()}loadDefinition(e){this.unloadIdentifier(e.identifier);let t=new V(this.application,e);this.connectModule(t);let s=e.controllerConstructor.afterLoad;s&&s(e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let s=this.modulesByIdentifier.get(t);if(s)return s.contexts.find(n=>n.element==e)}handleError(e,t,s){this.application.handleError(e,t,s)}createScopeForElementAndIdentifier(e,t){return new f(this.schema,e,t,this.logger)}scopeConnected(e){this.scopesByIdentifier.add(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.connectContextForScope(e)}scopeDisconnected(e){this.scopesByIdentifier.delete(e.identifier,e);let t=this.modulesByIdentifier.get(e.identifier);t&&t.disconnectContextForScope(e)}connectModule(e){this.modulesByIdentifier.set(e.identifier,e),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(s=>e.connectContextForScope(s))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(s=>e.disconnectContextForScope(s))}},Ne={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:r=>`data-${r}-target`,outletAttributeForScope:(r,e)=>`data-${r}-${e}-outlet`,keyMappings:Object.assign(Object.assign({enter:"Enter",tab:"Tab",esc:"Escape",space:" ",up:"ArrowUp",down:"ArrowDown",left:"ArrowLeft",right:"ArrowRight",home:"Home",end:"End"},H("abcdefghijklmnopqrstuvwxyz".split("").map(r=>[r,r]))),H("0123456789".split("").map(r=>[r,r])))};function H(r){return r.reduce((e,[t,s])=>Object.assign(Object.assign({},e),{[t]:s}),{})}var A=class{constructor(e=document.documentElement,t=Ne){this.logger=console,this.debug=!1,this.logDebugActivity=(s,n,i={})=>{this.debug&&this.logFormattedMessage(s,n,i)},this.element=e,this.schema=t,this.dispatcher=new M(this),this.router=new z(this),this.actionDescriptorFilters=Object.assign({},ie)}static start(e,t){let s=new this(e,t);return s.start(),s}async start(){await De(),this.logDebugActivity("application","starting"),this.dispatcher.start(),this.router.start(),this.logDebugActivity("application","start")}stop(){this.logDebugActivity("application","stopping"),this.dispatcher.stop(),this.router.stop(),this.logDebugActivity("application","stop")}register(e,t){this.load({identifier:e,controllerConstructor:t})}registerActionOption(e,t){this.actionDescriptorFilters[e]=t}load(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>{n.controllerConstructor.shouldLoad&&this.router.loadDefinition(n)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(n=>this.router.unloadIdentifier(n))}get controllers(){return this.router.contexts.map(e=>e.controller)}getControllerForElementAndIdentifier(e,t){let s=this.router.getContextForElementAndIdentifier(e,t);return s?s.controller:null}handleError(e,t,s){var n;this.logger.error(`%s
2
+
3
+ %o
4
+
5
+ %o`,t,e,s),(n=window.onerror)===null||n===void 0||n.call(window,t,"",0,0,e)}logFormattedMessage(e,t,s={}){s=Object.assign({application:this},s),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},s)),this.logger.groupEnd()}};function De(){return new Promise(r=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>r()):r()})}function xe(r){return p(r,"classes").reduce((t,s)=>Object.assign(t,Se(s)),{})}function Se(r){return{[`${r}Class`]:{get(){let{classes:e}=this;if(e.has(r))return e.get(r);{let t=e.getAttributeName(r);throw new Error(`Missing attribute "${t}"`)}}},[`${r}Classes`]:{get(){return this.classes.getAll(r)}},[`has${m(r)}Class`]:{get(){return this.classes.has(r)}}}}function Le(r){return p(r,"outlets").reduce((t,s)=>Object.assign(t,Ve(s)),{})}function Ve(r){let e=k(r);return{[`${e}Outlet`]:{get(){let t=this.outlets.find(r);if(t){let s=this.application.getControllerForElementAndIdentifier(t,r);if(s)return s;throw new Error(`Missing "data-controller=${r}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${r}" for "${this.identifier}" controller`)}},[`${e}Outlets`]:{get(){let t=this.outlets.findAll(r);return t.length>0?t.map(s=>{let n=this.application.getControllerForElementAndIdentifier(s,r);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${r}" for "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${e}OutletElement`]:{get(){let t=this.outlets.find(r);if(t)return t;throw new Error(`Missing outlet element "${r}" for "${this.identifier}" controller`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(r)}},[`has${m(e)}Outlet`]:{get(){return this.outlets.has(r)}}}}function Ke(r){return p(r,"targets").reduce((t,s)=>Object.assign(t,je(s)),{})}function je(r){return{[`${r}Target`]:{get(){let e=this.targets.find(r);if(e)return e;throw new Error(`Missing target element "${r}" for "${this.identifier}" controller`)}},[`${r}Targets`]:{get(){return this.targets.findAll(r)}},[`has${m(r)}Target`]:{get(){return this.targets.has(r)}}}}function Ie(r){let e=Ee(r,"values"),t={valueDescriptorMap:{get(){return e.reduce((s,n)=>{let i=ee(n,this.identifier),o=this.data.getAttributeNameForKey(i.key);return Object.assign(s,{[o]:i})},{})}}};return e.reduce((s,n)=>Object.assign(s,Pe(n)),t)}function Pe(r,e){let t=ee(r,e),{key:s,name:n,reader:i,writer:o}=t;return{[n]:{get(){let a=this.data.get(s);return a!==null?i(a):t.defaultValue},set(a){a===void 0?this.data.delete(s):this.data.set(s,o(a))}},[`has${m(n)}`]:{get(){return this.data.has(s)||t.hasCustomDefaultValue}}}}function ee([r,e],t){return ze({controller:t,token:r,typeDefinition:e})}function W(r){switch(r){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function g(r){switch(typeof r){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(r))return"array";if(Object.prototype.toString.call(r)==="[object Object]")return"object"}function _e(r){let e=W(r.typeObject.type);if(!e)return;let t=g(r.typeObject.default);if(e!==t){let s=r.controller?`${r.controller}.${r.token}`:r.token;throw new Error(`The specified default value for the Stimulus Value "${s}" must match the defined type "${e}". The provided default value of "${r.typeObject.default}" is of type "${t}".`)}return e}function Re(r){let e=_e({controller:r.controller,token:r.token,typeObject:r.typeDefinition}),t=g(r.typeDefinition),s=W(r.typeDefinition),n=e||t||s;if(n)return n;let i=r.controller?`${r.controller}.${r.typeDefinition}`:r.token;throw new Error(`Unknown value type "${i}" for "${r.token}" value`)}function Ue(r){let e=W(r);if(e)return qe[e];let t=r.default;return t!==void 0?t:r}function ze(r){let e=`${X(r.token)}-value`,t=Re(r);return{type:t,key:e,name:q(e),get defaultValue(){return Ue(r.typeDefinition)},get hasCustomDefaultValue(){return g(r.typeDefinition)!==void 0},reader:We[t],writer:Z[t]||Z.default}}var qe={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},We={array(r){let e=JSON.parse(r);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${r}" of type "${g(e)}"`);return e},boolean(r){return!(r=="0"||String(r).toLowerCase()=="false")},number(r){return Number(r)},object(r){let e=JSON.parse(r);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${r}" of type "${g(e)}"`);return e},string(r){return r}},Z={default:Je,array:Q,object:Q};function Q(r){return JSON.stringify(r)}function Je(r){return`${r}`}var h=class{constructor(e){this.context=e}static get shouldLoad(){return!0}static afterLoad(e,t){}get application(){return this.context.application}get scope(){return this.context.scope}get element(){return this.scope.element}get identifier(){return this.scope.identifier}get targets(){return this.scope.targets}get outlets(){return this.scope.outlets}get classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:s={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){let a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:s,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}};h.blessings=[xe,Ke,Ie,Le];h.targets=[];h.outlets=[];h.values={};var u=class extends h{connect(){switch(this.defaultStateValue){case"all_closed":this.hideAll(this.itemTargets);break;case"all_opened":this.showAll(this.itemTargets);break;case"first_opened":this.hideAll(this.itemTargets),this.open(this.itemTargets[0].querySelector(".accordion_content"))}}toggle(r){let e=r.currentTarget.parentNode.querySelector(".accordion_content");e.classList.contains("accordion_active")?this.hide(e):(this.multipleOpenValue||this.hideAll(this.itemTargets),this.open(e))}hideAll(r){r.forEach(e=>this.hide(e.querySelector(".accordion_content")))}showAll(r){r.forEach(e=>this.open(e.querySelector(".accordion_content")))}hide(r){r.classList.remove("accordion_active"),r.style.height=0}open(r){r.classList.add("accordion_active"),r.style.height=r.scrollHeight+"px",r.querySelectorAll(".accordion_content").forEach(function(e){new ResizeObserver(function(){r.style.height=r.scrollHeight+"px"}).observe(e)})}};O(u,"targets",["item"]),O(u,"values",{multipleOpen:Boolean,defaultState:String});var te=A.start();window.Stimulus=te;te.register("accordion",u);})();
6
+ //# sourceMappingURL=rails_accordion.js.map