lightning_ui_kit 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/app/assets/builds/{lightning_ui.css → lightning_ui_kit.css} +422 -100
- data/app/assets/builds/lightning_ui_kit.js +6 -0
- data/app/assets/builds/{lightning_ui.js.map → lightning_ui_kit.js.map} +4 -4
- data/app/components/{lightning_ui → lightning_ui_kit}/alert_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/avatar_component.rb +1 -1
- data/app/components/lightning_ui_kit/badge_component.rb +68 -0
- data/app/components/{lightning_ui → lightning_ui_kit}/banner_component.rb +2 -2
- data/app/components/{lightning_ui → lightning_ui_kit}/base_component.rb +2 -2
- data/app/components/{lightning_ui → lightning_ui_kit}/button_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/checkbox_component.html.erb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/checkbox_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/description_list/item_component.rb +1 -1
- data/app/components/lightning_ui_kit/description_list_component.rb +5 -0
- data/app/components/lightning_ui_kit/dropdown/item_component.rb +5 -0
- data/app/components/{lightning_ui → lightning_ui_kit}/dropdown_component.rb +1 -1
- data/app/components/lightning_ui_kit/dropzone_component.html.erb +82 -0
- data/app/components/lightning_ui_kit/dropzone_component.rb +61 -0
- data/app/components/lightning_ui_kit/errors.rb +34 -0
- data/app/components/lightning_ui_kit/file_input_component.html.erb +50 -0
- data/app/components/lightning_ui_kit/file_input_component.rb +62 -0
- data/app/components/{lightning_ui → lightning_ui_kit}/input_component.html.erb +21 -14
- data/app/components/{lightning_ui → lightning_ui_kit}/input_component.rb +18 -3
- data/app/components/{lightning_ui → lightning_ui_kit}/link_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/modal_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/pagination_component.rb +1 -1
- data/app/components/lightning_ui_kit/select_component.html.erb +40 -0
- data/app/components/lightning_ui_kit/select_component.rb +55 -0
- data/app/components/lightning_ui_kit/sidebar_component.rb +4 -0
- data/app/components/{lightning_ui → lightning_ui_kit}/skeleton_component.rb +1 -1
- data/app/components/lightning_ui_kit/spinner_component.rb +4 -0
- data/app/components/{lightning_ui → lightning_ui_kit}/switch_component.html.erb +8 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/switch_component.rb +13 -2
- data/app/components/{lightning_ui → lightning_ui_kit}/table/action_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/table/column_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/table_component.rb +3 -3
- data/app/components/{lightning_ui → lightning_ui_kit}/text_component.rb +1 -1
- data/app/components/{lightning_ui → lightning_ui_kit}/textarea_component.html.erb +15 -8
- data/app/components/{lightning_ui → lightning_ui_kit}/textarea_component.rb +18 -3
- data/app/helpers/lightning_ui_kit/application_helper.rb +7 -0
- data/app/helpers/{lightning_ui → lightning_ui_kit}/heroicon_helper.rb +1 -1
- data/app/javascript/lightning_ui_kit/controllers/dropzone_controller.js +76 -0
- data/app/javascript/{lightning_ui → lightning_ui_kit}/index.js +5 -0
- data/config/locales/en.yml +3 -0
- data/lib/{lightning_ui → lightning_ui_kit}/engine.rb +5 -6
- data/lib/lightning_ui_kit/version.rb +3 -0
- data/lib/lightning_ui_kit.rb +6 -0
- metadata +78 -72
- data/app/assets/builds/lightning_ui.js +0 -6
- data/app/components/lightning_ui/badge_component.rb +0 -43
- data/app/components/lightning_ui/description_list_component.rb +0 -5
- data/app/components/lightning_ui/dropdown/item_component.rb +0 -5
- data/app/components/lightning_ui/select_component.html.erb +0 -20
- data/app/components/lightning_ui/select_component.rb +0 -25
- data/app/components/lightning_ui/sidebar_component.rb +0 -4
- data/app/components/lightning_ui/spinner_component.rb +0 -4
- data/app/helpers/lightning_ui/application_helper.rb +0 -7
- data/lib/lightning_ui/version.rb +0 -3
- data/lib/lightning_ui.rb +0 -6
- data/lib/tasks/lightning_ui_tasks.rake +0 -4
- /data/app/assets/stylesheets/{lightning_ui → lightning_ui_kit}/application.css +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/alert_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/avatar_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/badge_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/banner_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/button_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/description_list/item_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/description_list_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/dropdown_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/link_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/modal_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/pagination_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/sidebar_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/skeleton_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/spinner_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/table_component.html.erb +0 -0
- /data/app/components/{lightning_ui → lightning_ui_kit}/text_component.html.erb +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/accordion_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/banner_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/checkbox_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/clipboard_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/dropdown_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/main_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/modal_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/reveal_controller.js +0 -0
- /data/app/javascript/{lightning_ui → lightning_ui_kit}/controllers/switch_controller.js +0 -0
@@ -0,0 +1,6 @@
|
|
1
|
+
(()=>{var ht=Object.defineProperty;var ut=(r,e,t)=>e in r?ht(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>(ut(r,typeof e!="symbol"?e+"":e,t),t);var M=(r,e,t)=>new Promise((s,o)=>{var h=g=>{try{f(t.next(g))}catch(v){o(v)}},d=g=>{try{f(t.throw(g))}catch(v){o(v)}},f=g=>g.done?s(g.value):Promise.resolve(g.value).then(h,d);f((t=t.apply(r,e)).next())});var ae=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=dt(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,o=t.index;return s<o?-1:s>o?1:0})}};function dt(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 ce=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:o}=e,h=this.fetchEventListenerMapForEventTarget(t),d=this.cacheKey(s,o);h.delete(d),h.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:s,eventOptions:o}=e;return this.fetchEventListener(t,s,o)}fetchEventListener(e,t,s){let o=this.fetchEventListenerMapForEventTarget(e),h=this.cacheKey(t,s),d=o.get(h);return d||(d=this.createEventListener(e,t,s),o.set(h,d)),d}createEventListener(e,t,s){let o=new ae(e,t,s);return this.started&&o.connect(),o}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(o=>{s.push(`${t[o]?"":"!"}${o}`)}),s.join(":")}},ft={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}},gt=/^(?:(?:([^.]+?)\+)?(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function mt(r){let t=r.trim().match(gt)||[],s=t[2],o=t[3];return o&&!["keydown","keyup","keypress"].includes(s)&&(s+=`.${o}`,o=""),{eventTarget:pt(t[4]),eventName:s,eventOptions:t[7]?bt(t[7]):{},identifier:t[5],methodName:t[6],keyFilter:t[1]||o}}function pt(r){if(r=="window")return window;if(r=="document")return document}function bt(r){return r.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function vt(r){if(r==window)return"window";if(r==document)return"document"}function Se(r){return r.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function le(r){return Se(r.replace(/--/g,"-").replace(/__/g,"_"))}function q(r){return r.charAt(0).toUpperCase()+r.slice(1)}function Xe(r){return r.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function yt(r){return r.match(/[^\s]+/g)||[]}function Pe(r){return r!=null}function he(r,e){return Object.prototype.hasOwnProperty.call(r,e)}var Ue=["meta","ctrl","alt","shift"],ue=class{constructor(e,t,s,o){this.element=e,this.index=t,this.eventTarget=s.eventTarget||e,this.eventName=s.eventName||Et(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=o}static forToken(e,t){return new this(e.element,e.index,mt(e.content),t)}toString(){let e=this.keyFilter?`.${this.keyFilter}`:"",t=this.eventTargetName?`@${this.eventTargetName}`:"";return`${this.eventName}${e}${t}->${this.identifier}#${this.methodName}`}shouldIgnoreKeyboardEvent(e){if(!this.keyFilter)return!1;let t=this.keyFilter.split("+");if(this.keyFilterDissatisfied(e,t))return!0;let s=t.filter(o=>!Ue.includes(o))[0];return s?(he(this.keyMappings,s)||Y(`contains unknown key filter: ${this.keyFilter}`),this.keyMappings[s].toLowerCase()!==e.key.toLowerCase()):!1}shouldIgnoreMouseEvent(e){if(!this.keyFilter)return!1;let t=[this.keyFilter];return!!this.keyFilterDissatisfied(e,t)}get params(){let e={},t=new RegExp(`^data-${this.identifier}-(.+)-param$`,"i");for(let{name:s,value:o}of Array.from(this.element.attributes)){let h=s.match(t),d=h&&h[1];d&&(e[Se(d)]=At(o))}return e}get eventTargetName(){return vt(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}keyFilterDissatisfied(e,t){let[s,o,h,d]=Ue.map(f=>t.includes(f));return e.metaKey!==s||e.ctrlKey!==o||e.altKey!==h||e.shiftKey!==d}},qe={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:r=>r.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function Et(r){let e=r.tagName.toLowerCase();if(e in qe)return qe[e](r)}function Y(r){throw new Error(r)}function At(r){try{return JSON.parse(r)}catch(e){return r}}var de=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){let t=this.prepareActionEvent(e);this.willBeInvokedByEvent(e)&&this.applyEventModifiers(t)&&this.invokeWithEvent(t)}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,{controller:o}=this.context,h=!0;for(let[d,f]of Object.entries(this.eventOptions))if(d in s){let g=s[d];h=h&&g({name:d,value:f,event:e,element:t,controller:o})}else continue;return h}prepareActionEvent(e){return Object.assign(e,{params:this.action.params})}invokeWithEvent(e){let{target:t,currentTarget:s}=e;try{this.method.call(this.controller,e),this.context.logDebugActivity(this.methodName,{event:e,target:t,currentTarget:s,action:this.methodName})}catch(o){let{identifier:h,controller:d,element:f,index:g}=this,v={identifier:h,controller:d,element:f,index:g,event:e};this.context.handleError(o,`invoking action "${this.action}"`,v)}}willBeInvokedByEvent(e){let t=e.target;return e instanceof KeyboardEvent&&this.action.shouldIgnoreKeyboardEvent(e)||e instanceof MouseEvent&&this.action.shouldIgnoreMouseEvent(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}},Z=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){this.elements.has(e)?this.delegate.elementAttributeChanged&&this.matchElement(e)?this.delegate.elementAttributeChanged(e,t):this.removeElement(e):this.matchElement(e)&&this.addElement(e)}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))}},ee=class{constructor(e,t,s){this.attributeName=t,this.delegate=s,this.elementObserver=new Z(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 Ot(r,e,t){Qe(r,e).add(t)}function wt(r,e,t){Qe(r,e).delete(t),xt(r,e)}function Qe(r,e){let t=r.get(e);return t||(t=new Set,r.set(e,t)),t}function xt(r,e){let t=r.get(e);t!=null&&t.size==0&&r.delete(e)}var C=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){Ot(this.valuesByKey,e,t)}delete(e,t){wt(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 fe=class{constructor(e,t,s,o){this._selector=t,this.details=o,this.elementObserver=new Z(e,this),this.delegate=s,this.matchesByElement=new C}get started(){return this.elementObserver.started}get selector(){return this._selector}set selector(e){this._selector=e,this.refresh()}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{selector:t}=this;if(t){let s=e.matches(t);return this.delegate.selectorMatchElement?s&&this.delegate.selectorMatchElement(e,this.details):s}else return!1}matchElementsInTree(e){let{selector:t}=this;if(t){let s=this.matchElement(e)?[e]:[],o=Array.from(e.querySelectorAll(t)).filter(h=>this.matchElement(h));return s.concat(o)}else return[]}elementMatched(e){let{selector:t}=this;t&&this.selectorMatched(e,t)}elementUnmatched(e){let t=this.matchesByElement.getKeysForValue(e);for(let s of t)this.selectorUnmatched(e,s)}elementAttributeChanged(e,t){let{selector:s}=this;if(s){let o=this.matchElement(e),h=this.matchesByElement.has(s,e);o&&!h?this.selectorMatched(e,s):!o&&h&&this.selectorUnmatched(e,s)}}selectorMatched(e,t){this.delegate.selectorMatched(e,t,this.details),this.matchesByElement.add(t,e)}selectorUnmatched(e,t){this.delegate.selectorUnmatched(e,t,this.details),this.matchesByElement.delete(t,e)}},ge=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 o=this.element.getAttribute(e);if(this.stringMap.get(e)!=o&&this.stringMapValueChanged(o,s,t),o==null){let h=this.stringMap.get(e);this.stringMap.delete(e),h&&this.stringMapKeyRemoved(s,e,h)}else this.stringMap.set(e,o)}}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())}},te=class{constructor(e,t,s){this.attributeObserver=new ee(e,t,this),this.delegate=s,this.tokensByElement=new C}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),o=Ft(t,s).findIndex(([h,d])=>!Ct(h,d));return o==-1?[[],[]]:[t.slice(o),s.slice(o)]}readTokensForElement(e){let t=this.attributeName,s=e.getAttribute(t)||"";return Tt(s,e,t)}};function Tt(r,e,t){return r.trim().split(/\s+/).filter(s=>s.length).map((s,o)=>({element:e,attributeName:t,content:s,index:o}))}function Ft(r,e){let t=Math.max(r.length,e.length);return Array.from({length:t},(s,o)=>[r[o],e[o]])}function Ct(r,e){return r&&e&&r.index==e.index&&r.content==e.content}var se=class{constructor(e,t,s){this.tokenListObserver=new te(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}}}},me=class{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new se(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 de(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=ue.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}},pe=class{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new ge(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 o=this.valueDescriptorNameMap[t];e!==null&&(s===null&&(s=o.writer(o.defaultValue)),this.invokeChangedCallback(t,e,s))}stringMapKeyRemoved(e,t,s){let o=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,o.writer(this.receiver[e]),s):this.invokeChangedCallback(e,o.writer(o.defaultValue),s)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:s,writer:o}of this.valueDescriptors)s!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,o(s),void 0)}invokeChangedCallback(e,t,s){let o=`${e}Changed`,h=this.receiver[o];if(typeof h=="function"){let d=this.valueDescriptorNameMap[e];try{let f=d.reader(t),g=s;s&&(g=d.reader(s)),h.call(this.receiver,f,g)}catch(f){throw f instanceof TypeError&&(f.message=`Stimulus Value "${this.context.identifier}.${d.name}" - ${f.message}`),f}}}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${q(t.name)}`;return this.receiver[s]}},be=class{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new C}start(){this.tokenListObserver||(this.tokenListObserver=new te(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 R(r,e){let t=Ge(r);return Array.from(t.reduce((s,o)=>(St(o,e).forEach(h=>s.add(h)),s),new Set))}function Mt(r,e){return Ge(r).reduce((s,o)=>(s.push(...Bt(o,e)),s),[])}function Ge(r){let e=[];for(;r;)e.push(r),r=Object.getPrototypeOf(r);return e.reverse()}function St(r,e){let t=r[e];return Array.isArray(t)?t:[]}function Bt(r,e){let t=r[e];return t?Object.keys(t).map(s=>[s,t[s]]):[]}var ve=class{constructor(e,t){this.started=!1,this.context=e,this.delegate=t,this.outletsByName=new C,this.outletElementsByName=new C,this.selectorObserverMap=new Map,this.attributeObserverMap=new Map}start(){this.started||(this.outletDefinitions.forEach(e=>{this.setupSelectorObserverForOutlet(e),this.setupAttributeObserverForOutlet(e)}),this.started=!0,this.dependentContexts.forEach(e=>e.refresh()))}refresh(){this.selectorObserverMap.forEach(e=>e.refresh()),this.attributeObserverMap.forEach(e=>e.refresh())}stop(){this.started&&(this.started=!1,this.disconnectAllOutlets(),this.stopSelectorObservers(),this.stopAttributeObservers())}stopSelectorObservers(){this.selectorObserverMap.size>0&&(this.selectorObserverMap.forEach(e=>e.stop()),this.selectorObserverMap.clear())}stopAttributeObservers(){this.attributeObserverMap.size>0&&(this.attributeObserverMap.forEach(e=>e.stop()),this.attributeObserverMap.clear())}selectorMatched(e,t,{outletName:s}){let o=this.getOutlet(e,s);o&&this.connectOutlet(o,e,s)}selectorUnmatched(e,t,{outletName:s}){let o=this.getOutletFromMap(e,s);o&&this.disconnectOutlet(o,e,s)}selectorMatchElement(e,{outletName:t}){let s=this.selector(t),o=this.hasOutlet(e,t),h=e.matches(`[${this.schema.controllerAttribute}~=${t}]`);return s?o&&h&&e.matches(s):!1}elementMatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementAttributeValueChanged(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}elementUnmatchedAttribute(e,t){let s=this.getOutletNameFromOutletAttributeName(t);s&&this.updateSelectorObserverForOutlet(s)}connectOutlet(e,t,s){var o;this.outletElementsByName.has(s,t)||(this.outletsByName.add(s,e),this.outletElementsByName.add(s,t),(o=this.selectorObserverMap.get(s))===null||o===void 0||o.pause(()=>this.delegate.outletConnected(e,t,s)))}disconnectOutlet(e,t,s){var o;this.outletElementsByName.has(s,t)&&(this.outletsByName.delete(s,e),this.outletElementsByName.delete(s,t),(o=this.selectorObserverMap.get(s))===null||o===void 0||o.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)}updateSelectorObserverForOutlet(e){let t=this.selectorObserverMap.get(e);t&&(t.selector=this.selector(e))}setupSelectorObserverForOutlet(e){let t=this.selector(e),s=new fe(document.body,t,this,{outletName:e});this.selectorObserverMap.set(e,s),s.start()}setupAttributeObserverForOutlet(e){let t=this.attributeNameForOutletName(e),s=new ee(this.scope.element,t,this);this.attributeObserverMap.set(e,s),s.start()}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}attributeNameForOutletName(e){return this.scope.schema.outletAttributeForScope(this.identifier,e)}getOutletNameFromOutletAttributeName(e){return this.outletDefinitions.find(t=>this.attributeNameForOutletName(t)===e)}get outletDependencies(){let e=new C;return this.router.modules.forEach(t=>{let s=t.definition.controllerConstructor;R(s,"outlets").forEach(h=>e.add(h,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 schema(){return this.context.schema}get identifier(){return this.context.identifier}get application(){return this.context.application}get router(){return this.application.router}},ye=class{constructor(e,t){this.logDebugActivity=(s,o={})=>{let{identifier:h,controller:d,element:f}=this;o=Object.assign({identifier:h,controller:d,element:f},o),this.application.logDebugActivity(this.identifier,s,o)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new me(this,this.dispatcher),this.valueObserver=new pe(this,this.controller),this.targetObserver=new be(this,this),this.outletObserver=new ve(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:o,controller:h,element:d}=this;s=Object.assign({identifier:o,controller:h,element:d},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(`${le(s)}OutletConnected`,e,t)}outletDisconnected(e,t,s){this.invokeControllerMethod(`${le(s)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let s=this.controller;typeof s[e]=="function"&&s[e](...t)}};function Nt(r){return Lt(r,$t(r))}function Lt(r,e){let t=It(r),s=Dt(r.prototype,e);return Object.defineProperties(t.prototype,s),t}function $t(r){return R(r,"blessings").reduce((t,s)=>{let o=s(r);for(let h in o){let d=t[h]||{};t[h]=Object.assign(d,o[h])}return t},{})}function Dt(r,e){return jt(e).reduce((t,s)=>{let o=kt(r,e,s);return o&&Object.assign(t,{[s]:o}),t},{})}function kt(r,e,t){let s=Object.getOwnPropertyDescriptor(r,t);if(!(s&&"value"in s)){let h=Object.getOwnPropertyDescriptor(e,t).value;return s&&(h.get=s.get||h.get,h.set=s.set||h.set),h}}var jt=(()=>typeof Object.getOwnPropertySymbols=="function"?r=>[...Object.getOwnPropertyNames(r),...Object.getOwnPropertySymbols(r)]:Object.getOwnPropertyNames)(),It=(()=>{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(t){return s=>class extends s{}}})();function Vt(r){return{identifier:r.identifier,controllerConstructor:Nt(r.controllerConstructor)}}var Ee=class{constructor(e,t){this.application=e,this.definition=Vt(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 ye(this,e),this.contextsByScope.set(e,t)),t}},Ae=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 yt(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}},Oe=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}-${Xe(e)}`}},we=class{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,s){let o=this.warnedKeysByObject.get(e);o||(o=new Set,this.warnedKeysByObject.set(e,o)),o.has(t)||(o.add(t),this.logger.warn(s,e))}};function xe(r,e){return`[${r}~="${e}"]`}var Te=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 xe(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 xe(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:s}=this,o=this.schema.targetAttribute,h=this.schema.targetAttributeForScope(s);this.guide.warn(e,`target:${t}`,`Please replace ${o}="${s}.${t}" with ${h}="${t}". The ${o} attribute is deprecated and will be removed in a future version of Stimulus.`)}return e}get guide(){return this.scope.guide}},Fe=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(o=>this.matchesElement(o,e,t))[0]}findAllElements(e,t){return this.scope.queryElements(e).filter(o=>this.matchesElement(o,e,t))}matchesElement(e,t,s){let o=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&o.split(" ").includes(s)}},P=class{constructor(e,t,s,o){this.targets=new Te(this),this.classes=new Ae(this),this.data=new Oe(this),this.containsElement=h=>h.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=s,this.guide=new we(o),this.outlets=new Fe(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 xe(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new P(this.schema,document.documentElement,this.identifier,this.guide.logger)}},Ce=class{constructor(e,t,s){this.element=e,this.schema=t,this.delegate=s,this.valueListObserver=new se(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;return this.parseValueForElementAndIdentifier(t,s)}parseValueForElementAndIdentifier(e,t){let s=this.fetchScopesByIdentifierForElement(e),o=s.get(t);return o||(o=this.delegate.createScopeForElementAndIdentifier(e,t),s.set(t,o)),o}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}},Me=class{constructor(e){this.application=e,this.scopeObserver=new Ce(this.element,this.schema,this),this.scopesByIdentifier=new C,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 Ee(this.application,e);this.connectModule(t);let s=e.controllerConstructor.afterLoad;s&&s.call(e.controllerConstructor,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(o=>o.element==e)}proposeToConnectScopeForElementAndIdentifier(e,t){let s=this.scopeObserver.parseValueForElementAndIdentifier(e,t);s?this.scopeObserver.elementMatchedValue(s.element,s):console.error(`Couldn't find or create scope for identifier: "${t}" and element:`,e)}handleError(e,t,s){this.application.handleError(e,t,s)}createScopeForElementAndIdentifier(e,t){return new P(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))}},_t={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",page_up:"PageUp",page_down:"PageDown"},Re("abcdefghijklmnopqrstuvwxyz".split("").map(r=>[r,r]))),Re("0123456789".split("").map(r=>[r,r])))};function Re(r){return r.reduce((e,[t,s])=>Object.assign(Object.assign({},e),{[t]:s}),{})}var re=class{constructor(e=document.documentElement,t=_t){this.logger=console,this.debug=!1,this.logDebugActivity=(s,o,h={})=>{this.debug&&this.logFormattedMessage(s,o,h)},this.element=e,this.schema=t,this.dispatcher=new ce(this),this.router=new Me(this),this.actionDescriptorFilters=Object.assign({},ft)}static start(e,t){let s=new this(e,t);return s.start(),s}start(){return M(this,null,function*(){yield Pt(),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(o=>{o.controllerConstructor.shouldLoad&&this.router.loadDefinition(o)})}unload(e,...t){(Array.isArray(e)?e:[e,...t]).forEach(o=>this.router.unloadIdentifier(o))}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 o;this.logger.error(`%s
|
2
|
+
|
3
|
+
%o
|
4
|
+
|
5
|
+
%o`,t,e,s),(o=window.onerror)===null||o===void 0||o.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 Pt(){return new Promise(r=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>r()):r()})}function Ut(r){return R(r,"classes").reduce((t,s)=>Object.assign(t,qt(s)),{})}function qt(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${q(r)}Class`]:{get(){return this.classes.has(r)}}}}function Rt(r){return R(r,"outlets").reduce((t,s)=>Object.assign(t,Kt(s)),{})}function Ke(r,e,t){return r.application.getControllerForElementAndIdentifier(e,t)}function ze(r,e,t){let s=Ke(r,e,t);if(s||(r.application.router.proposeToConnectScopeForElementAndIdentifier(e,t),s=Ke(r,e,t),s))return s}function Kt(r){let e=le(r);return{[`${e}Outlet`]:{get(){let t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t){let o=ze(this,t,r);if(o)return o;throw new Error(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`)}throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}Outlets`]:{get(){let t=this.outlets.findAll(r);return t.length>0?t.map(s=>{let o=ze(this,s,r);if(o)return o;console.warn(`The provided outlet element is missing an outlet controller "${r}" instance for host controller "${this.identifier}"`,s)}).filter(s=>s):[]}},[`${e}OutletElement`]:{get(){let t=this.outlets.find(r),s=this.outlets.getSelectorForOutletName(r);if(t)return t;throw new Error(`Missing outlet element "${r}" for host controller "${this.identifier}". Stimulus couldn't find a matching outlet element using selector "${s}".`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(r)}},[`has${q(e)}Outlet`]:{get(){return this.outlets.has(r)}}}}function zt(r){return R(r,"targets").reduce((t,s)=>Object.assign(t,Wt(s)),{})}function Wt(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${q(r)}Target`]:{get(){return this.targets.has(r)}}}}function Ht(r){let e=Mt(r,"values"),t={valueDescriptorMap:{get(){return e.reduce((s,o)=>{let h=Ye(o,this.identifier),d=this.data.getAttributeNameForKey(h.key);return Object.assign(s,{[d]:h})},{})}}};return e.reduce((s,o)=>Object.assign(s,Jt(o)),t)}function Jt(r,e){let t=Ye(r,e),{key:s,name:o,reader:h,writer:d}=t;return{[o]:{get(){let f=this.data.get(s);return f!==null?h(f):t.defaultValue},set(f){f===void 0?this.data.delete(s):this.data.set(s,d(f))}},[`has${q(o)}`]:{get(){return this.data.has(s)||t.hasCustomDefaultValue}}}}function Ye([r,e],t){return Yt({controller:t,token:r,typeDefinition:e})}function ne(r){switch(r){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function U(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 Xt(r){let{controller:e,token:t,typeObject:s}=r,o=Pe(s.type),h=Pe(s.default),d=o&&h,f=o&&!h,g=!o&&h,v=ne(s.type),w=U(r.typeObject.default);if(f)return v;if(g)return w;if(v!==w){let B=e?`${e}.${t}`:t;throw new Error(`The specified default value for the Stimulus Value "${B}" must match the defined type "${v}". The provided default value of "${s.default}" is of type "${w}".`)}if(d)return v}function Qt(r){let{controller:e,token:t,typeDefinition:s}=r,h=Xt({controller:e,token:t,typeObject:s}),d=U(s),f=ne(s),g=h||d||f;if(g)return g;let v=e?`${e}.${s}`:t;throw new Error(`Unknown value type "${v}" for "${t}" value`)}function Gt(r){let e=ne(r);if(e)return We[e];let t=he(r,"default"),s=he(r,"type"),o=r;if(t)return o.default;if(s){let{type:h}=o,d=ne(h);if(d)return We[d]}return r}function Yt(r){let{token:e,typeDefinition:t}=r,s=`${Xe(e)}-value`,o=Qt(r);return{type:o,key:s,name:Se(s),get defaultValue(){return Gt(t)},get hasCustomDefaultValue(){return U(t)!==void 0},reader:Zt[o],writer:He[o]||He.default}}var We={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Zt={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 "${U(e)}"`);return e},boolean(r){return!(r=="0"||String(r).toLowerCase()=="false")},number(r){return Number(r.replace(/_/g,""))},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 "${U(e)}"`);return e},string(r){return r}},He={default:es,array:Je,object:Je};function Je(r){return JSON.stringify(r)}function es(r){return`${r}`}var p=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:o=this.identifier,bubbles:h=!0,cancelable:d=!0}={}){let f=o?`${o}:${e}`:e,g=new CustomEvent(f,{detail:s,bubbles:h,cancelable:d});return t.dispatchEvent(g),g}};p.blessings=[Ut,zt,Ht,Rt];p.targets=[];p.outlets=[];p.values={};var tt={exports:{}};(function(r,e){(function(t){r.exports=t()})(function(t){var s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];function o(u,l){var i=u[0],n=u[1],c=u[2],a=u[3];i+=(n&c|~n&a)+l[0]-680876936|0,i=(i<<7|i>>>25)+n|0,a+=(i&n|~i&c)+l[1]-389564586|0,a=(a<<12|a>>>20)+i|0,c+=(a&i|~a&n)+l[2]+606105819|0,c=(c<<17|c>>>15)+a|0,n+=(c&a|~c&i)+l[3]-1044525330|0,n=(n<<22|n>>>10)+c|0,i+=(n&c|~n&a)+l[4]-176418897|0,i=(i<<7|i>>>25)+n|0,a+=(i&n|~i&c)+l[5]+1200080426|0,a=(a<<12|a>>>20)+i|0,c+=(a&i|~a&n)+l[6]-1473231341|0,c=(c<<17|c>>>15)+a|0,n+=(c&a|~c&i)+l[7]-45705983|0,n=(n<<22|n>>>10)+c|0,i+=(n&c|~n&a)+l[8]+1770035416|0,i=(i<<7|i>>>25)+n|0,a+=(i&n|~i&c)+l[9]-1958414417|0,a=(a<<12|a>>>20)+i|0,c+=(a&i|~a&n)+l[10]-42063|0,c=(c<<17|c>>>15)+a|0,n+=(c&a|~c&i)+l[11]-1990404162|0,n=(n<<22|n>>>10)+c|0,i+=(n&c|~n&a)+l[12]+1804603682|0,i=(i<<7|i>>>25)+n|0,a+=(i&n|~i&c)+l[13]-40341101|0,a=(a<<12|a>>>20)+i|0,c+=(a&i|~a&n)+l[14]-1502002290|0,c=(c<<17|c>>>15)+a|0,n+=(c&a|~c&i)+l[15]+1236535329|0,n=(n<<22|n>>>10)+c|0,i+=(n&a|c&~a)+l[1]-165796510|0,i=(i<<5|i>>>27)+n|0,a+=(i&c|n&~c)+l[6]-1069501632|0,a=(a<<9|a>>>23)+i|0,c+=(a&n|i&~n)+l[11]+643717713|0,c=(c<<14|c>>>18)+a|0,n+=(c&i|a&~i)+l[0]-373897302|0,n=(n<<20|n>>>12)+c|0,i+=(n&a|c&~a)+l[5]-701558691|0,i=(i<<5|i>>>27)+n|0,a+=(i&c|n&~c)+l[10]+38016083|0,a=(a<<9|a>>>23)+i|0,c+=(a&n|i&~n)+l[15]-660478335|0,c=(c<<14|c>>>18)+a|0,n+=(c&i|a&~i)+l[4]-405537848|0,n=(n<<20|n>>>12)+c|0,i+=(n&a|c&~a)+l[9]+568446438|0,i=(i<<5|i>>>27)+n|0,a+=(i&c|n&~c)+l[14]-1019803690|0,a=(a<<9|a>>>23)+i|0,c+=(a&n|i&~n)+l[3]-187363961|0,c=(c<<14|c>>>18)+a|0,n+=(c&i|a&~i)+l[8]+1163531501|0,n=(n<<20|n>>>12)+c|0,i+=(n&a|c&~a)+l[13]-1444681467|0,i=(i<<5|i>>>27)+n|0,a+=(i&c|n&~c)+l[2]-51403784|0,a=(a<<9|a>>>23)+i|0,c+=(a&n|i&~n)+l[7]+1735328473|0,c=(c<<14|c>>>18)+a|0,n+=(c&i|a&~i)+l[12]-1926607734|0,n=(n<<20|n>>>12)+c|0,i+=(n^c^a)+l[5]-378558|0,i=(i<<4|i>>>28)+n|0,a+=(i^n^c)+l[8]-2022574463|0,a=(a<<11|a>>>21)+i|0,c+=(a^i^n)+l[11]+1839030562|0,c=(c<<16|c>>>16)+a|0,n+=(c^a^i)+l[14]-35309556|0,n=(n<<23|n>>>9)+c|0,i+=(n^c^a)+l[1]-1530992060|0,i=(i<<4|i>>>28)+n|0,a+=(i^n^c)+l[4]+1272893353|0,a=(a<<11|a>>>21)+i|0,c+=(a^i^n)+l[7]-155497632|0,c=(c<<16|c>>>16)+a|0,n+=(c^a^i)+l[10]-1094730640|0,n=(n<<23|n>>>9)+c|0,i+=(n^c^a)+l[13]+681279174|0,i=(i<<4|i>>>28)+n|0,a+=(i^n^c)+l[0]-358537222|0,a=(a<<11|a>>>21)+i|0,c+=(a^i^n)+l[3]-722521979|0,c=(c<<16|c>>>16)+a|0,n+=(c^a^i)+l[6]+76029189|0,n=(n<<23|n>>>9)+c|0,i+=(n^c^a)+l[9]-640364487|0,i=(i<<4|i>>>28)+n|0,a+=(i^n^c)+l[12]-421815835|0,a=(a<<11|a>>>21)+i|0,c+=(a^i^n)+l[15]+530742520|0,c=(c<<16|c>>>16)+a|0,n+=(c^a^i)+l[2]-995338651|0,n=(n<<23|n>>>9)+c|0,i+=(c^(n|~a))+l[0]-198630844|0,i=(i<<6|i>>>26)+n|0,a+=(n^(i|~c))+l[7]+1126891415|0,a=(a<<10|a>>>22)+i|0,c+=(i^(a|~n))+l[14]-1416354905|0,c=(c<<15|c>>>17)+a|0,n+=(a^(c|~i))+l[5]-57434055|0,n=(n<<21|n>>>11)+c|0,i+=(c^(n|~a))+l[12]+1700485571|0,i=(i<<6|i>>>26)+n|0,a+=(n^(i|~c))+l[3]-1894986606|0,a=(a<<10|a>>>22)+i|0,c+=(i^(a|~n))+l[10]-1051523|0,c=(c<<15|c>>>17)+a|0,n+=(a^(c|~i))+l[1]-2054922799|0,n=(n<<21|n>>>11)+c|0,i+=(c^(n|~a))+l[8]+1873313359|0,i=(i<<6|i>>>26)+n|0,a+=(n^(i|~c))+l[15]-30611744|0,a=(a<<10|a>>>22)+i|0,c+=(i^(a|~n))+l[6]-1560198380|0,c=(c<<15|c>>>17)+a|0,n+=(a^(c|~i))+l[13]+1309151649|0,n=(n<<21|n>>>11)+c|0,i+=(c^(n|~a))+l[4]-145523070|0,i=(i<<6|i>>>26)+n|0,a+=(n^(i|~c))+l[11]-1120210379|0,a=(a<<10|a>>>22)+i|0,c+=(i^(a|~n))+l[2]+718787259|0,c=(c<<15|c>>>17)+a|0,n+=(a^(c|~i))+l[9]-343485551|0,n=(n<<21|n>>>11)+c|0,u[0]=i+u[0]|0,u[1]=n+u[1]|0,u[2]=c+u[2]|0,u[3]=a+u[3]|0}function h(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u.charCodeAt(i)+(u.charCodeAt(i+1)<<8)+(u.charCodeAt(i+2)<<16)+(u.charCodeAt(i+3)<<24);return l}function d(u){var l=[],i;for(i=0;i<64;i+=4)l[i>>2]=u[i]+(u[i+1]<<8)+(u[i+2]<<16)+(u[i+3]<<24);return l}function f(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,c,a,y,A,m;for(n=64;n<=l;n+=64)o(i,h(u.substring(n-64,n)));for(u=u.substring(n-64),c=u.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)a[n>>2]|=u.charCodeAt(n)<<(n%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55)for(o(i,a),n=0;n<16;n+=1)a[n]=0;return y=l*8,y=y.toString(16).match(/(.*?)(.{0,8})$/),A=parseInt(y[2],16),m=parseInt(y[1],16)||0,a[14]=A,a[15]=m,o(i,a),i}function g(u){var l=u.length,i=[1732584193,-271733879,-1732584194,271733878],n,c,a,y,A,m;for(n=64;n<=l;n+=64)o(i,d(u.subarray(n-64,n)));for(u=n-64<l?u.subarray(n-64):new Uint8Array(0),c=u.length,a=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],n=0;n<c;n+=1)a[n>>2]|=u[n]<<(n%4<<3);if(a[n>>2]|=128<<(n%4<<3),n>55)for(o(i,a),n=0;n<16;n+=1)a[n]=0;return y=l*8,y=y.toString(16).match(/(.*?)(.{0,8})$/),A=parseInt(y[2],16),m=parseInt(y[1],16)||0,a[14]=A,a[15]=m,o(i,a),i}function v(u){var l="",i;for(i=0;i<4;i+=1)l+=s[u>>i*8+4&15]+s[u>>i*8&15];return l}function w(u){var l;for(l=0;l<u.length;l+=1)u[l]=v(u[l]);return u.join("")}w(f("hello")),typeof ArrayBuffer!="undefined"&&!ArrayBuffer.prototype.slice&&function(){function u(l,i){return l=l|0||0,l<0?Math.max(l+i,0):Math.min(l,i)}ArrayBuffer.prototype.slice=function(l,i){var n=this.byteLength,c=u(l,n),a=n,y,A,m,O;return i!==t&&(a=u(i,n)),c>a?new ArrayBuffer(0):(y=a-c,A=new ArrayBuffer(y),m=new Uint8Array(A),O=new Uint8Array(this,c,y),m.set(O),A)}}();function B(u){return/[\u0080-\uFFFF]/.test(u)&&(u=unescape(encodeURIComponent(u))),u}function x(u,l){var i=u.length,n=new ArrayBuffer(i),c=new Uint8Array(n),a;for(a=0;a<i;a+=1)c[a]=u.charCodeAt(a);return l?c:n}function G(u){return String.fromCharCode.apply(null,new Uint8Array(u))}function k(u,l,i){var n=new Uint8Array(u.byteLength+l.byteLength);return n.set(new Uint8Array(u)),n.set(new Uint8Array(l),u.byteLength),i?n:n.buffer}function N(u){var l=[],i=u.length,n;for(n=0;n<i-1;n+=2)l.push(parseInt(u.substr(n,2),16));return String.fromCharCode.apply(String,l)}function b(){this.reset()}return b.prototype.append=function(u){return this.appendBinary(B(u)),this},b.prototype.appendBinary=function(u){this._buff+=u,this._length+=u.length;var l=this._buff.length,i;for(i=64;i<=l;i+=64)o(this._hash,h(this._buff.substring(i-64,i)));return this._buff=this._buff.substring(i-64),this},b.prototype.end=function(u){var l=this._buff,i=l.length,n,c=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a;for(n=0;n<i;n+=1)c[n>>2]|=l.charCodeAt(n)<<(n%4<<3);return this._finish(c,i),a=w(this._hash),u&&(a=N(a)),this.reset(),a},b.prototype.reset=function(){return this._buff="",this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.prototype.getState=function(){return{buff:this._buff,length:this._length,hash:this._hash.slice()}},b.prototype.setState=function(u){return this._buff=u.buff,this._length=u.length,this._hash=u.hash,this},b.prototype.destroy=function(){delete this._hash,delete this._buff,delete this._length},b.prototype._finish=function(u,l){var i=l,n,c,a;if(u[i>>2]|=128<<(i%4<<3),i>55)for(o(this._hash,u),i=0;i<16;i+=1)u[i]=0;n=this._length*8,n=n.toString(16).match(/(.*?)(.{0,8})$/),c=parseInt(n[2],16),a=parseInt(n[1],16)||0,u[14]=c,u[15]=a,o(this._hash,u)},b.hash=function(u,l){return b.hashBinary(B(u),l)},b.hashBinary=function(u,l){var i=f(u),n=w(i);return l?N(n):n},b.ArrayBuffer=function(){this.reset()},b.ArrayBuffer.prototype.append=function(u){var l=k(this._buff.buffer,u,!0),i=l.length,n;for(this._length+=u.byteLength,n=64;n<=i;n+=64)o(this._hash,d(l.subarray(n-64,n)));return this._buff=n-64<i?new Uint8Array(l.buffer.slice(n-64)):new Uint8Array(0),this},b.ArrayBuffer.prototype.end=function(u){var l=this._buff,i=l.length,n=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],c,a;for(c=0;c<i;c+=1)n[c>>2]|=l[c]<<(c%4<<3);return this._finish(n,i),a=w(this._hash),u&&(a=N(a)),this.reset(),a},b.ArrayBuffer.prototype.reset=function(){return this._buff=new Uint8Array(0),this._length=0,this._hash=[1732584193,-271733879,-1732584194,271733878],this},b.ArrayBuffer.prototype.getState=function(){var u=b.prototype.getState.call(this);return u.buff=G(u.buff),u},b.ArrayBuffer.prototype.setState=function(u){return u.buff=x(u.buff,!0),b.prototype.setState.call(this,u)},b.ArrayBuffer.prototype.destroy=b.prototype.destroy,b.ArrayBuffer.prototype._finish=b.prototype._finish,b.ArrayBuffer.hash=function(u,l){var i=g(new Uint8Array(u)),n=w(i);return l?N(n):n},b})})(tt);var ts=tt.exports,ss=File.prototype.slice||File.prototype.mozSlice||File.prototype.webkitSlice,K=class{static create(e,t){new K(e).create(t)}constructor(e){this.file=e,this.chunkSize=2097152,this.chunkCount=Math.ceil(this.file.size/this.chunkSize),this.chunkIndex=0}create(e){this.callback=e,this.md5Buffer=new ts.ArrayBuffer,this.fileReader=new FileReader,this.fileReader.addEventListener("load",t=>this.fileReaderDidLoad(t)),this.fileReader.addEventListener("error",t=>this.fileReaderDidError(t)),this.readNextChunk()}fileReaderDidLoad(e){if(this.md5Buffer.append(e.target.result),!this.readNextChunk()){let t=this.md5Buffer.end(!0),s=btoa(t);this.callback(null,s)}}fileReaderDidError(e){this.callback(`Error reading ${this.file.name}`)}readNextChunk(){if(this.chunkIndex<this.chunkCount||this.chunkIndex==0&&this.chunkCount==0){let e=this.chunkIndex*this.chunkSize,t=Math.min(e+this.chunkSize,this.file.size),s=ss.call(this.file,e,t);return this.fileReader.readAsArrayBuffer(s),this.chunkIndex++,!0}else return!1}};function rs(r){let e=st(document.head,`meta[name="${r}"]`);if(e)return e.getAttribute("content")}function ns(r,e){typeof r=="string"&&(e=r,r=document);let t=r.querySelectorAll(e);return nt(t)}function st(r,e){return typeof r=="string"&&(e=r,r=document),r.querySelector(e)}function rt(r,e,t={}){let{disabled:s}=r,{bubbles:o,cancelable:h,detail:d}=t,f=document.createEvent("Event");f.initEvent(e,o||!0,h||!0),f.detail=d||{};try{r.disabled=!1,r.dispatchEvent(f)}finally{r.disabled=s}return f}function nt(r){return Array.isArray(r)?r:Array.from?Array.from(r):[].slice.call(r)}var Ne=class{constructor(e,t,s,o={}){this.file=e,this.attributes={filename:e.name,content_type:e.type||"application/octet-stream",byte_size:e.size,checksum:t},this.xhr=new XMLHttpRequest,this.xhr.open("POST",s,!0),this.xhr.responseType="json",this.xhr.setRequestHeader("Content-Type","application/json"),this.xhr.setRequestHeader("Accept","application/json"),this.xhr.setRequestHeader("X-Requested-With","XMLHttpRequest"),Object.keys(o).forEach(d=>{this.xhr.setRequestHeader(d,o[d])});let h=rs("csrf-token");h!=null&&this.xhr.setRequestHeader("X-CSRF-Token",h),this.xhr.addEventListener("load",d=>this.requestDidLoad(d)),this.xhr.addEventListener("error",d=>this.requestDidError(d))}get status(){return this.xhr.status}get response(){let{responseType:e,response:t}=this.xhr;return e=="json"?t:JSON.parse(t)}create(e){this.callback=e,this.xhr.send(JSON.stringify({blob:this.attributes}))}requestDidLoad(e){if(this.status>=200&&this.status<300){let{response:t}=this,{direct_upload:s}=t;delete t.direct_upload,this.attributes=t,this.directUploadData=s,this.callback(null,this.toJSON())}else this.requestDidError(e)}requestDidError(e){this.callback(`Error creating Blob for "${this.file.name}". Status: ${this.status}`)}toJSON(){let e={};for(let t in this.attributes)e[t]=this.attributes[t];return e}},Le=class{constructor(e){this.blob=e,this.file=e.file;let{url:t,headers:s}=e.directUploadData;this.xhr=new XMLHttpRequest,this.xhr.open("PUT",t,!0),this.xhr.responseType="text";for(let o in s)this.xhr.setRequestHeader(o,s[o]);this.xhr.addEventListener("load",o=>this.requestDidLoad(o)),this.xhr.addEventListener("error",o=>this.requestDidError(o))}create(e){this.callback=e,this.xhr.send(this.file.slice())}requestDidLoad(e){let{status:t,response:s}=this.xhr;t>=200&&t<300?this.callback(null,s):this.requestDidError(e)}requestDidError(e){this.callback(`Error storing "${this.file.name}". Status: ${this.xhr.status}`)}},is=0,z=class{constructor(e,t,s,o={}){this.id=++is,this.file=e,this.url=t,this.delegate=s,this.customHeaders=o}create(e){K.create(this.file,(t,s)=>{if(t){e(t);return}let o=new Ne(this.file,s,this.url,this.customHeaders);Ze(this.delegate,"directUploadWillCreateBlobWithXHR",o.xhr),o.create(h=>{if(h)e(h);else{let d=new Le(o);Ze(this.delegate,"directUploadWillStoreFileWithXHR",d.xhr),d.create(f=>{f?e(f):e(null,o.toJSON())})}})})}};function Ze(r,e,...t){if(r&&typeof r[e]=="function")return r[e](...t)}var $e=class{constructor(e,t){this.input=e,this.file=t,this.directUpload=new z(this.file,this.url,this),this.dispatch("initialize")}start(e){let t=document.createElement("input");t.type="hidden",t.name=this.input.name,this.input.insertAdjacentElement("beforebegin",t),this.dispatch("start"),this.directUpload.create((s,o)=>{s?(t.parentNode.removeChild(t),this.dispatchError(s)):t.value=o.signed_id,this.dispatch("end"),e(s)})}uploadRequestDidProgress(e){let t=e.loaded/e.total*100;t&&this.dispatch("progress",{progress:t})}get url(){return this.input.getAttribute("data-direct-upload-url")}dispatch(e,t={}){return t.file=this.file,t.id=this.directUpload.id,rt(this.input,`direct-upload:${e}`,{detail:t})}dispatchError(e){this.dispatch("error",{error:e}).defaultPrevented||alert(e)}directUploadWillCreateBlobWithXHR(e){this.dispatch("before-blob-request",{xhr:e})}directUploadWillStoreFileWithXHR(e){this.dispatch("before-storage-request",{xhr:e}),e.upload.addEventListener("progress",t=>this.uploadRequestDidProgress(t))}},os="input[type=file][data-direct-upload-url]:not([disabled])",De=class{constructor(e){this.form=e,this.inputs=ns(e,os).filter(t=>t.files.length)}start(e){let t=this.createDirectUploadControllers(),s=()=>{let o=t.shift();o?o.start(h=>{h?(e(h),this.dispatch("end")):s()}):(e(),this.dispatch("end"))};this.dispatch("start"),s()}createDirectUploadControllers(){let e=[];return this.inputs.forEach(t=>{nt(t.files).forEach(s=>{let o=new $e(t,s);e.push(o)})}),e}dispatch(e,t={}){return rt(this.form,`direct-uploads:${e}`,{detail:t})}},Be="data-direct-uploads-processing",ke=new WeakMap,et=!1;function je(){et||(et=!0,document.addEventListener("click",as,!0),document.addEventListener("submit",cs,!0),document.addEventListener("ajax:before",ls))}function as(r){let e=r.target.closest("button, input");e&&e.type==="submit"&&e.form&&ke.set(e.form,e)}function cs(r){it(r)}function ls(r){r.target.tagName=="FORM"&&it(r)}function it(r){let e=r.target;if(e.hasAttribute(Be)){r.preventDefault();return}let t=new De(e),{inputs:s}=t;s.length&&(r.preventDefault(),e.setAttribute(Be,""),s.forEach(us),t.start(o=>{e.removeAttribute(Be),o?s.forEach(ds):hs(e)}))}function hs(r){let e=ke.get(r)||st(r,"input[type=submit], button[type=submit]");if(e){let{disabled:t}=e;e.disabled=!1,e.focus(),e.click(),e.disabled=t}else e=document.createElement("input"),e.type="submit",e.style.display="none",r.appendChild(e),e.click(),r.removeChild(e);ke.delete(r)}function us(r){r.disabled=!0}function ds(r){r.disabled=!1}function fs(){window.ActiveStorage&&je()}setTimeout(fs,1);var W=class extends p{connect(){this.hasInputTarget&&(this.inputTarget.disabled=!0)}copy(r){if(r.preventDefault(),!this.hasInputTarget)return;let e=this.inputTarget.innerHTML||this.inputTarget.value;navigator.clipboard.writeText(e)}};E(W,"targets",["input"]);var H=class extends p{toggle(r){r.preventDefault();let e=this.controlTarget;e.dataset.checked?(this.fieldTarget.value=!1,delete e.dataset.checked):(this.fieldTarget.value=!0,e.dataset.checked=!0)}};E(H,"targets",["field","control"]);var ie=class extends p{close(){this.element.classList.remove("opacity-100"),this.element.classList.add("opacity-0"),setTimeout(()=>{this.element.classList.add("hidden")},300)}};var oe=class extends p{openModal(){this.findElement("lui-modal").open()}closeModal(){this.findElement("lui-modal").close()}findElement(r){let e=this.element.dataset.target.replace("#",""),t=document.getElementById(e);return this.application.getControllerForElementAndIdentifier(t,r)}};var J=class extends p{connect(){this.openItem(this.itemTargets[0])}toggle(r){r.preventDefault(),this.itemTargets.forEach(e=>{e.contains(r.target)?this.isOpen(e)?this.closeItem(e):this.openItem(e):this.closeItem(e)})}openItem(r){let e=r.querySelector("[data-accordion-target=content]");e.classList.remove("grid-rows-[0fr]"),e.classList.add("grid-rows-[1fr]"),e.classList.remove("opacity-0"),e.classList.add("opacity-100"),r.querySelector("[data-accordion-target=arrow]").classList.add("rotate-180")}closeItem(r){let e=r.querySelector("[data-accordion-target=content]");e.classList.remove("grid-rows-[1fr]"),e.classList.add("grid-rows-[0fr]"),e.classList.remove("opacity-100"),e.classList.add("opacity-0"),r.querySelector("[data-accordion-target=arrow]").classList.remove("rotate-180")}isOpen(r){return r.querySelector("[data-accordion-target=content]").classList.contains("grid-rows-[1fr]")}};E(J,"targets",["content","item"]);var j=class extends p{connect(){this.dialogTarget.addEventListener("click",this.onClick.bind(this)),this.openValue&&this.open()}disconnect(){this.dialogTarget.removeEventListener("click",this.onClick.bind(this))}open(){this.dialogTarget.showModal()}close(){this.dialogTarget.setAttribute("closing",""),Promise.all(this.dialogTarget.getAnimations().map(r=>r.finished)).then(()=>{this.dialogTarget.removeAttribute("closing"),this.dialogTarget.close()})}onClick(r){r.target===this.dialogTarget&&this.dialogTarget.close()}submitForm(){this.dialogTarget.querySelector("form").requestSubmit()}};E(j,"targets",["dialog"]),E(j,"values",{open:Boolean});var I=class extends p{connect(){this.initialShowValue||this.itemTargets.forEach(r=>{r.classList.add("hidden")})}toggle(r){r.preventDefault(),this.itemTargets.forEach(e=>{e.classList.toggle("hidden")})}};E(I,"targets",["item"]),E(I,"values",{initialShow:Boolean});var X=class extends p{toggle(r){r.preventDefault();let e=r.target;e.dataset.checked?(this.fieldTarget.value=!1,delete e.dataset.checked):(this.fieldTarget.value=!0,e.dataset.checked=!0)}};E(X,"targets",["field"]);var Ie=class extends p{};Ie.debounces=[];var Ve=class extends p{};Ve.throttles=[];var ms={enterFromClass:"enter",enterActiveClass:"enterStart",enterToClass:"enterEnd",leaveFromClass:"leave",leaveActiveClass:"leaveStart",leaveToClass:"leaveEnd"},ps={transitioned:!1,hiddenClass:"hidden",preserveOriginalClass:!0,removeToClasses:!0},ot=(r,e={})=>{var t,s,o;let h=r,d=h.element.dataset.transitionTarget,f;d&&(f=h[`${d}Target`]);let g=(e==null?void 0:e.element)||f||h.element;if(!(g instanceof HTMLElement||g instanceof SVGElement))return;let v=g.dataset,w=parseInt(v.leaveAfter||"")||e.leaveAfter||0,{transitioned:B,hiddenClass:x,preserveOriginalClass:G,removeToClasses:k}=Object.assign({},ps,e),N=(t=h.enter)===null||t===void 0?void 0:t.bind(h),b=(s=h.leave)===null||s===void 0?void 0:s.bind(h),u=(o=h.toggleTransition)===null||o===void 0?void 0:o.bind(h);function l(m){return M(this,null,function*(){if(h.transitioned)return;h.transitioned=!0,N&&N(m);let O=S("enterFrom",e,v),L=S("enterActive",e,v),$=S("enterTo",e,v),D=S("leaveTo",e,v);x&&g.classList.remove(x),k||A(g,D),yield c(g,O,L,$,x,G,k),w>0&&setTimeout(()=>{i(m)},w)})}function i(m){return M(this,null,function*(){if(!h.transitioned)return;h.transitioned=!1,b&&b(m);let O=S("leaveFrom",e,v),L=S("leaveActive",e,v),$=S("leaveTo",e,v),D=S("enterTo",e,v);k||A(g,D),yield c(g,O,L,$,x,G,k),x&&g.classList.add(x)})}function n(m){u&&u(m),h.transitioned?i():l()}function c(m,O,L,$,D,ct,lt){return M(this,null,function*(){let _=[];ct&&(O.forEach(T=>m.classList.contains(T)&&T!==D&&_.push(T)),L.forEach(T=>m.classList.contains(T)&&T!==D&&_.push(T)),$.forEach(T=>m.classList.contains(T)&&T!==D&&_.push(T))),y(m,O),A(m,_),y(m,L),yield vs(),A(m,O),y(m,$),yield bs(m),A(m,L),lt&&A(m,$),y(m,_)})}function a(){h.transitioned=B,B?(x&&g.classList.remove(x),l()):(x&&g.classList.add(x),i())}function y(m,O){O.length>0&&m.classList.add(...O)}function A(m,O){O.length>0&&m.classList.remove(...O)}return a(),Object.assign(h,{enter:l,leave:i,toggleTransition:n}),[l,i,n]};function S(r,e,t){let s=`transition${r[0].toUpperCase()}${r.substr(1)}`,o=ms[r],h=e[r]||t[s]||t[o]||" ";return ys(h)?[]:h.split(" ")}function bs(r){return M(this,null,function*(){return new Promise(e=>{let t=Number(getComputedStyle(r).transitionDuration.split(",")[0].replace("s",""))*1e3;setTimeout(()=>{e(t)},t)})})}function vs(){return M(this,null,function*(){return new Promise(r=>{requestAnimationFrame(()=>{requestAnimationFrame(r)})})})}function ys(r){return r.length===0||!r.trim()}var V=class extends p{connect(){ot(this,{element:this.menuTarget})}toggle(){this.toggleTransition()}hide(e){!this.element.contains(e.target)&&!this.menuTarget.classList.contains("hidden")&&this.leave()}};E(V,"targets",["menu"]);var _e=class{constructor(e,t){this.controller=t,this.file=e,this.directUpload=new z(e,this.controller.inputTarget.dataset.directUploadUrl,this)}process(){this.insertUpload(),this.directUpload.create((e,t)=>{if(e){let o=this.controller.filesTarget.querySelector(`#upload_${this.directUpload.id}`).querySelector("[data-lui-dropzone-target='status']");o.textContent="Failed. "+e,o.classList.add("text-red-500")}else{let s=document.createElement("input");s.setAttribute("type","hidden"),s.setAttribute("value",t.signed_id),s.name=this.controller.inputTarget.name,this.controller.filesTarget.querySelector(`#upload_${this.directUpload.id}`).appendChild(s)}})}insertUpload(){let e=this.controller.templateTarget.content.cloneNode(!0);e.querySelector("#\\#NEW_FILE").id=`upload_${this.directUpload.id}`,e.querySelector("[data-lui-dropzone-target='filename']").textContent=this.file.name,e.querySelector("[data-lui-dropzone-target='status']").textContent="Uploading...",this.controller.filesTarget.appendChild(e)}directUploadWillStoreFileWithXHR(e){e.upload.addEventListener("progress",t=>this.updateProgress(t))}updateProgress(e){let t=(e.loaded/e.total*100).toFixed(0),s=t==100?"Uploaded":"Uploading...",o=this.controller.filesTarget.querySelector(`#upload_${this.directUpload.id}`);o.querySelector("[data-lui-dropzone-target='status']").textContent=s,o.querySelector("[data-lui-dropzone-target='progressbar']").style.width=`${t}%`,o.querySelector("[data-lui-dropzone-target='percentage-progress']").textContent=`${t}%`}},Q=class extends p{selectFiles(r){this.inputTarget.click()}uploadFiles(r){r.preventDefault(),[...r.dataTransfer?r.dataTransfer.files:r.target.files].forEach(t=>new _e(t,this).process())}activate(r){r.preventDefault()}removeFile(r){r.preventDefault(),r.target.closest("[data-lui-dropzone-target='file']").remove()}};E(Q,"targets",["input","template","files"]);var F="lui";je();var at=re.start();window.Stimulus=at;function Es(r){r.register(`${F}-clipboard`,W),r.register(`${F}-checkbox`,H),r.register(`${F}-banner`,ie),r.register(`${F}-main`,oe),r.register(`${F}-accordion`,J),r.register(`${F}-modal`,j),r.register(`${F}-reveal`,I),r.register(`${F}-switch`,X),r.register(`${F}-dropdown`,V),r.register(`${F}-dropzone`,Q)}Es(at);})();
|
6
|
+
//# sourceMappingURL=lightning_ui_kit.js.map
|