(()=>{var fe=Object.defineProperty;var ge=(s,e,t)=>e in s?fe(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var b=(s,e,t)=>(ge(s,typeof e!="symbol"?e+"":e,t),t);var v=(s,e,t)=>new Promise((r,n)=>{var i=c=>{try{a(t.next(c))}catch(l){n(l)}},o=c=>{try{a(t.throw(c))}catch(l){n(l)}},a=c=>c.done?r(c.value):Promise.resolve(c.value).then(i,o);a((t=t.apply(s,e)).next())});var I=class{constructor(e,t,r){this.eventTarget=e,this.eventName=t,this.eventOptions=r,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=pe(e);for(let r of this.bindings){if(t.immediatePropagationStopped)break;r.handleEvent(t)}}hasBindings(){return this.unorderedBindings.size>0}get bindings(){return Array.from(this.unorderedBindings).sort((e,t)=>{let r=e.index,n=t.index;return rn?1:0})}};function pe(s){if("immediatePropagationStopped"in s)return s;{let{stopImmediatePropagation:e}=s;return Object.assign(s,{immediatePropagationStopped:!1,stopImmediatePropagation(){this.immediatePropagationStopped=!0,e.call(this)}})}}var K=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,r={}){this.application.handleError(e,`Error ${t}`,r)}clearEventListenersForBinding(e){let t=this.fetchEventListenerForBinding(e);t.hasBindings()||(t.disconnect(),this.removeMappedEventListenerFor(e))}removeMappedEventListenerFor(e){let{eventTarget:t,eventName:r,eventOptions:n}=e,i=this.fetchEventListenerMapForEventTarget(t),o=this.cacheKey(r,n);i.delete(o),i.size==0&&this.eventListenerMaps.delete(t)}fetchEventListenerForBinding(e){let{eventTarget:t,eventName:r,eventOptions:n}=e;return this.fetchEventListener(t,r,n)}fetchEventListener(e,t,r){let n=this.fetchEventListenerMapForEventTarget(e),i=this.cacheKey(t,r),o=n.get(i);return o||(o=this.createEventListener(e,t,r),n.set(i,o)),o}createEventListener(e,t,r){let n=new I(e,t,r);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 r=[e];return Object.keys(t).sort().forEach(n=>{r.push(`${t[n]?"":"!"}${n}`)}),r.join(":")}},me={stop({event:s,value:e}){return e&&s.stopPropagation(),!0},prevent({event:s,value:e}){return e&&s.preventDefault(),!0},self({event:s,value:e,element:t}){return e?t===s.target:!0}},ye=/^(?:(.+?)(?:\.(.+?))?(?:@(window|document))?->)?(.+?)(?:#([^:]+?))(?::(.+))?$/;function be(s){let t=s.trim().match(ye)||[],r=t[1],n=t[2];return n&&!["keydown","keyup","keypress"].includes(r)&&(r+=`.${n}`,n=""),{eventTarget:ve(t[3]),eventName:r,eventOptions:t[6]?Oe(t[6]):{},identifier:t[4],methodName:t[5],keyFilter:n}}function ve(s){if(s=="window")return window;if(s=="document")return document}function Oe(s){return s.split(":").reduce((e,t)=>Object.assign(e,{[t.replace(/^!/,"")]:!/^!/.test(t)}),{})}function Ae(s){if(s==window)return"window";if(s==document)return"document"}function M(s){return s.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function E(s){return M(s.replace(/--/g,"-").replace(/__/g,"_"))}function g(s){return s.charAt(0).toUpperCase()+s.slice(1)}function P(s){return s.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function Ee(s){return s.match(/[^\s]+/g)||[]}var R=class{constructor(e,t,r,n){this.element=e,this.index=t,this.eventTarget=r.eventTarget||e,this.eventName=r.eventName||we(e)||O("missing event name"),this.eventOptions=r.eventOptions||{},this.identifier=r.identifier||O("missing identifier"),this.methodName=r.methodName||O("missing method name"),this.keyFilter=r.keyFilter||"",this.schema=n}static forToken(e,t){return new this(e.element,e.index,be(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("+"),r=["meta","ctrl","alt","shift"],[n,i,o,a]=r.map(l=>t.includes(l));if(e.metaKey!==n||e.ctrlKey!==i||e.altKey!==o||e.shiftKey!==a)return!0;let c=t.filter(l=>!r.includes(l))[0];return c?(Object.prototype.hasOwnProperty.call(this.keyMappings,c)||O(`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:r,value:n}of Array.from(this.element.attributes)){let i=r.match(t),o=i&&i[1];o&&(e[M(o)]=Me(n))}return e}get eventTargetName(){return Ae(this.eventTarget)}get keyMappings(){return this.schema.keyMappings}},x={a:()=>"click",button:()=>"click",form:()=>"submit",details:()=>"toggle",input:s=>s.getAttribute("type")=="submit"?"click":"input",select:()=>"change",textarea:()=>"input"};function we(s){let e=s.tagName.toLowerCase();if(e in x)return x[e](s)}function O(s){throw new Error(s)}function Me(s){try{return JSON.parse(s)}catch{return s}}var U=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:r}=this.context.application,n=!0;for(let[i,o]of Object.entries(this.eventOptions))if(i in r){let a=r[i];n=n&&a({name:i,value:o,event:e,element:t})}else continue;return n}invokeWithEvent(e){let{target:t,currentTarget:r}=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:r,action:this.methodName})}catch(n){let{identifier:i,controller:o,element:a,index:c}=this,l={identifier:i,controller:o,element:a,index:c,event:e};this.context.handleError(n,`invoking action "${this.action}"`,l)}}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}},T=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(r=>this.processMutations(r))}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 r=e;this.elements.has(r)?this.delegate.elementAttributeChanged&&this.matchElement(r)?this.delegate.elementAttributeChanged(r,t):this.removeElement(r):this.matchElement(r)&&this.addElement(r)}processRemovedNodes(e){for(let t of Array.from(e)){let r=this.elementFromNode(t);r&&this.processTree(r,this.removeElement)}}processAddedNodes(e){for(let t of Array.from(e)){let r=this.elementFromNode(t);r&&this.elementIsActive(r)&&this.processTree(r,this.addElement)}}matchElement(e){return this.delegate.matchElement(e)}matchElementsInTree(e=this.element){return this.delegate.matchElementsInTree(e)}processTree(e,t){for(let r of this.matchElementsInTree(e))t.call(this,r)}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))}},_=class{constructor(e,t,r){this.attributeName=t,this.delegate=r,this.elementObserver=new T(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]:[],r=Array.from(e.querySelectorAll(this.selector));return t.concat(r)}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 Te(s,e,t){z(s,e).add(t)}function Ce(s,e,t){z(s,e).delete(t),Fe(s,e)}function z(s,e){let t=s.get(e);return t||(t=new Set,s.set(e,t)),t}function Fe(s,e){let t=s.get(e);t!=null&&t.size==0&&s.delete(e)}var h=class{constructor(){this.valuesByKey=new Map}get keys(){return Array.from(this.valuesByKey.keys())}get values(){return Array.from(this.valuesByKey.values()).reduce((t,r)=>t.concat(Array.from(r)),[])}get size(){return Array.from(this.valuesByKey.values()).reduce((t,r)=>t+r.size,0)}add(e,t){Te(this.valuesByKey,e,t)}delete(e,t){Ce(this.valuesByKey,e,t)}has(e,t){let r=this.valuesByKey.get(e);return r!=null&&r.has(t)}hasKey(e){return this.valuesByKey.has(e)}hasValue(e){return Array.from(this.valuesByKey.values()).some(r=>r.has(e))}getValuesForKey(e){let t=this.valuesByKey.get(e);return t?Array.from(t):[]}getKeysForValue(e){return Array.from(this.valuesByKey).filter(([t,r])=>r.has(e)).map(([t,r])=>t)}};var W=class{constructor(e,t,r,n={}){this.selector=t,this.details=n,this.elementObserver=new T(e,this),this.delegate=r,this.matchesByElement=new h}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]:[],r=Array.from(e.querySelectorAll(this.selector)).filter(n=>this.matchElement(n));return t.concat(r)}elementMatched(e){this.selectorMatched(e)}elementUnmatched(e){this.selectorUnmatched(e)}elementAttributeChanged(e,t){let r=this.matchElement(e),n=this.matchesByElement.has(this.selector,e);!r&&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)}},q=class{constructor(e,t){this.element=e,this.delegate=t,this.started=!1,this.stringMap=new Map,this.mutationObserver=new MutationObserver(r=>this.processMutations(r))}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 r=this.delegate.getStringMapKeyForAttribute(e);if(r!=null){this.stringMap.has(e)||this.stringMapKeyAdded(r,e);let n=this.element.getAttribute(e);if(this.stringMap.get(e)!=n&&this.stringMapValueChanged(n,r,t),n==null){let i=this.stringMap.get(e);this.stringMap.delete(e),i&&this.stringMapKeyRemoved(r,e,i)}else this.stringMap.set(e,n)}}stringMapKeyAdded(e,t){this.delegate.stringMapKeyAdded&&this.delegate.stringMapKeyAdded(e,t)}stringMapValueChanged(e,t,r){this.delegate.stringMapValueChanged&&this.delegate.stringMapValueChanged(e,t,r)}stringMapKeyRemoved(e,t,r){this.delegate.stringMapKeyRemoved&&this.delegate.stringMapKeyRemoved(e,t,r)}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())}},C=class{constructor(e,t,r){this.attributeObserver=new _(e,t,this),this.delegate=r,this.tokensByElement=new h}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,r]=this.refreshTokensForElement(e);this.tokensUnmatched(t),this.tokensMatched(r)}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),r=this.readTokensForElement(e),n=ke(t,r).findIndex(([i,o])=>!Se(i,o));return n==-1?[[],[]]:[t.slice(n),r.slice(n)]}readTokensForElement(e){let t=this.attributeName,r=e.getAttribute(t)||"";return Be(r,e,t)}};function Be(s,e,t){return s.trim().split(/\s+/).filter(r=>r.length).map((r,n)=>({element:e,attributeName:t,content:r,index:n}))}function ke(s,e){let t=Math.max(s.length,e.length);return Array.from({length:t},(r,n)=>[s[n],e[n]])}function Se(s,e){return s&&e&&s.index==e.index&&s.content==e.content}var F=class{constructor(e,t,r){this.tokenListObserver=new C(e,t,this),this.delegate=r,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:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).set(e,r),this.delegate.elementMatchedValue(t,r))}tokenUnmatched(e){let{element:t}=e,{value:r}=this.fetchParseResultForToken(e);r&&(this.fetchValuesByTokenForElement(t).delete(e),this.delegate.elementUnmatchedValue(t,r))}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}}}},J=class{constructor(e,t){this.context=e,this.delegate=t,this.bindingsByAction=new Map}start(){this.valueListObserver||(this.valueListObserver=new F(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 U(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=R.forToken(e,this.schema);if(t.identifier==this.identifier)return t}elementMatchedValue(e,t){this.connectAction(t)}elementUnmatchedValue(e,t){this.disconnectAction(t)}},H=class{constructor(e,t){this.context=e,this.receiver=t,this.stringMapObserver=new q(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 r=this.valueDescriptorMap[t];this.hasValue(e)||this.invokeChangedCallback(e,r.writer(this.receiver[e]),r.writer(r.defaultValue))}stringMapValueChanged(e,t,r){let n=this.valueDescriptorNameMap[t];e!==null&&(r===null&&(r=n.writer(n.defaultValue)),this.invokeChangedCallback(t,e,r))}stringMapKeyRemoved(e,t,r){let n=this.valueDescriptorNameMap[e];this.hasValue(e)?this.invokeChangedCallback(e,n.writer(this.receiver[e]),r):this.invokeChangedCallback(e,n.writer(n.defaultValue),r)}invokeChangedCallbacksForDefaultValues(){for(let{key:e,name:t,defaultValue:r,writer:n}of this.valueDescriptors)r!=null&&!this.controller.data.has(e)&&this.invokeChangedCallback(t,n(r),void 0)}invokeChangedCallback(e,t,r){let n=`${e}Changed`,i=this.receiver[n];if(typeof i=="function"){let o=this.valueDescriptorNameMap[e];try{let a=o.reader(t),c=r;r&&(c=o.reader(r)),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 r=this.valueDescriptorMap[t];e[r.name]=r}),e}hasValue(e){let t=this.valueDescriptorNameMap[e],r=`has${g(t.name)}`;return this.receiver[r]}},Z=class{constructor(e,t){this.context=e,this.delegate=t,this.targetsByName=new h}start(){this.tokenListObserver||(this.tokenListObserver=new C(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 r;this.targetsByName.has(t,e)||(this.targetsByName.add(t,e),(r=this.tokenListObserver)===null||r===void 0||r.pause(()=>this.delegate.targetConnected(e,t)))}disconnectTarget(e,t){var r;this.targetsByName.has(t,e)&&(this.targetsByName.delete(t,e),(r=this.tokenListObserver)===null||r===void 0||r.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(s,e){let t=G(s);return Array.from(t.reduce((r,n)=>(De(n,e).forEach(i=>r.add(i)),r),new Set))}function $e(s,e){return G(s).reduce((r,n)=>(r.push(...Ne(n,e)),r),[])}function G(s){let e=[];for(;s;)e.push(s),s=Object.getPrototypeOf(s);return e.reverse()}function De(s,e){let t=s[e];return Array.isArray(t)?t:[]}function Ne(s,e){let t=s[e];return t?Object.keys(t).map(r=>[r,t[r]]):[]}var Q=class{constructor(e,t){this.context=e,this.delegate=t,this.outletsByName=new h,this.outletElementsByName=new h,this.selectorObserverMap=new Map}start(){this.selectorObserverMap.size===0&&(this.outletDefinitions.forEach(e=>{let t=this.selector(e),r={outletName:e};t&&this.selectorObserverMap.set(e,new W(document.body,t,this,r))}),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:r}){let n=this.getOutlet(e,r);n&&this.connectOutlet(n,e,r)}selectorUnmatched(e,t,{outletName:r}){let n=this.getOutletFromMap(e,r);n&&this.disconnectOutlet(n,e,r)}selectorMatchElement(e,{outletName:t}){return this.hasOutlet(e,t)&&e.matches(`[${this.context.application.schema.controllerAttribute}~=${t}]`)}connectOutlet(e,t,r){var n;this.outletElementsByName.has(r,t)||(this.outletsByName.add(r,e),this.outletElementsByName.add(r,t),(n=this.selectorObserverMap.get(r))===null||n===void 0||n.pause(()=>this.delegate.outletConnected(e,t,r)))}disconnectOutlet(e,t,r){var n;this.outletElementsByName.has(r,t)&&(this.outletsByName.delete(r,e),this.outletElementsByName.delete(r,t),(n=this.selectorObserverMap.get(r))===null||n===void 0||n.pause(()=>this.delegate.outletDisconnected(e,t,r)))}disconnectAllOutlets(){for(let e of this.outletElementsByName.keys)for(let t of this.outletElementsByName.getValuesForKey(e))for(let r of this.outletsByName.getValuesForKey(e))this.disconnectOutlet(r,t,e)}selector(e){return this.scope.outlets.getSelectorForOutletName(e)}get outletDependencies(){let e=new h;return this.router.modules.forEach(t=>{let r=t.definition.controllerConstructor;p(r,"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(r=>r.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}},X=class{constructor(e,t){this.logDebugActivity=(r,n={})=>{let{identifier:i,controller:o,element:a}=this;n=Object.assign({identifier:i,controller:o,element:a},n),this.application.logDebugActivity(this.identifier,r,n)},this.module=e,this.scope=t,this.controller=new e.controllerConstructor(this),this.bindingObserver=new J(this,this.dispatcher),this.valueObserver=new H(this,this.controller),this.targetObserver=new Z(this,this),this.outletObserver=new Q(this,this);try{this.controller.initialize(),this.logDebugActivity("initialize")}catch(r){this.handleError(r,"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,r={}){let{identifier:n,controller:i,element:o}=this;r=Object.assign({identifier:n,controller:i,element:o},r),this.application.handleError(e,`Error ${t}`,r)}targetConnected(e,t){this.invokeControllerMethod(`${t}TargetConnected`,e)}targetDisconnected(e,t){this.invokeControllerMethod(`${t}TargetDisconnected`,e)}outletConnected(e,t,r){this.invokeControllerMethod(`${E(r)}OutletConnected`,e,t)}outletDisconnected(e,t,r){this.invokeControllerMethod(`${E(r)}OutletDisconnected`,e,t)}invokeControllerMethod(e,...t){let r=this.controller;typeof r[e]=="function"&&r[e](...t)}};function xe(s){return Ve(s,Le(s))}function Ve(s,e){let t=Pe(s),r=je(s.prototype,e);return Object.defineProperties(t.prototype,r),t}function Le(s){return p(s,"blessings").reduce((t,r)=>{let n=r(s);for(let i in n){let o=t[i]||{};t[i]=Object.assign(o,n[i])}return t},{})}function je(s,e){return Ke(e).reduce((t,r)=>{let n=Ie(s,e,r);return n&&Object.assign(t,{[r]:n}),t},{})}function Ie(s,e,t){let r=Object.getOwnPropertyDescriptor(s,t);if(!(r&&"value"in r)){let i=Object.getOwnPropertyDescriptor(e,t).value;return r&&(i.get=r.get||i.get,i.set=r.set||i.set),i}}var Ke=(()=>typeof Object.getOwnPropertySymbols=="function"?s=>[...Object.getOwnPropertyNames(s),...Object.getOwnPropertySymbols(s)]:Object.getOwnPropertyNames)(),Pe=(()=>{function s(t){function r(){return Reflect.construct(t,arguments,new.target)}return r.prototype=Object.create(t.prototype,{constructor:{value:r}}),Reflect.setPrototypeOf(r,t),r}function e(){let r=s(function(){this.a.call(this)});return r.prototype.a=function(){},new r}try{return e(),s}catch{return r=>class extends r{}}})();function Re(s){return{identifier:s.identifier,controllerConstructor:xe(s.controllerConstructor)}}var Y=class{constructor(e,t){this.application=e,this.definition=Re(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 X(this,e),this.contextsByScope.set(e,t)),t}},ee=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 Ee(t)}getAttributeName(e){return this.data.getAttributeNameForKey(this.getDataKey(e))}getDataKey(e){return`${e}-class`}get data(){return this.scope.data}},te=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 r=this.getAttributeNameForKey(e);return this.element.setAttribute(r,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}-${P(e)}`}},re=class{constructor(e){this.warnedKeysByObject=new WeakMap,this.logger=e}warn(e,t,r){let n=this.warnedKeysByObject.get(e);n||(n=new Set,this.warnedKeysByObject.set(e,n)),n.has(t)||(n.add(t),this.logger.warn(r,e))}};function w(s,e){return`[${s}~="${e}"]`}var se=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,r)=>t||this.findTarget(r)||this.findLegacyTarget(r),void 0)}findAll(...e){return e.reduce((t,r)=>[...t,...this.findAllTargets(r),...this.findAllLegacyTargets(r)],[])}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 w(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(r=>this.deprecate(r,e))}getLegacySelectorForTargetName(e){let t=`${this.identifier}.${e}`;return w(this.schema.targetAttribute,t)}deprecate(e,t){if(e){let{identifier:r}=this,n=this.schema.targetAttribute,i=this.schema.targetAttributeForScope(r);this.guide.warn(e,`target:${t}`,`Please replace ${n}="${r}.${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}},ne=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,r)=>t||this.findOutlet(r),void 0)}findAll(...e){return e.reduce((t,r)=>[...t,...this.findAllOutlets(r)],[])}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,r){let n=e.getAttribute(this.scope.schema.controllerAttribute)||"";return e.matches(t)&&n.split(" ").includes(r)}},A=class{constructor(e,t,r,n){this.targets=new se(this),this.classes=new ee(this),this.data=new te(this),this.containsElement=i=>i.closest(this.controllerSelector)===this.element,this.schema=e,this.element=t,this.identifier=r,this.guide=new re(n),this.outlets=new ne(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 w(this.schema.controllerAttribute,this.identifier)}get isDocumentScope(){return this.element===document.documentElement}get documentScope(){return this.isDocumentScope?this:new A(this.schema,document.documentElement,this.identifier,this.guide.logger)}},ie=class{constructor(e,t,r){this.element=e,this.schema=t,this.delegate=r,this.valueListObserver=new F(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:r}=e,n=this.fetchScopesByIdentifierForElement(t),i=n.get(r);return i||(i=this.delegate.createScopeForElementAndIdentifier(t,r),n.set(r,i)),i}elementMatchedValue(e,t){let r=(this.scopeReferenceCounts.get(t)||0)+1;this.scopeReferenceCounts.set(t,r),r==1&&this.delegate.scopeConnected(t)}elementUnmatchedValue(e,t){let r=this.scopeReferenceCounts.get(t);r&&(this.scopeReferenceCounts.set(t,r-1),r==1&&this.delegate.scopeDisconnected(t))}fetchScopesByIdentifierForElement(e){let t=this.scopesByIdentifierByElement.get(e);return t||(t=new Map,this.scopesByIdentifierByElement.set(e,t)),t}},oe=class{constructor(e){this.application=e,this.scopeObserver=new ie(this.element,this.schema,this),this.scopesByIdentifier=new h,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 Y(this.application,e);this.connectModule(t);let r=e.controllerConstructor.afterLoad;r&&r(e.identifier,this.application)}unloadIdentifier(e){let t=this.modulesByIdentifier.get(e);t&&this.disconnectModule(t)}getContextForElementAndIdentifier(e,t){let r=this.modulesByIdentifier.get(t);if(r)return r.contexts.find(n=>n.element==e)}handleError(e,t,r){this.application.handleError(e,t,r)}createScopeForElementAndIdentifier(e,t){return new A(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(r=>e.connectContextForScope(r))}disconnectModule(e){this.modulesByIdentifier.delete(e.identifier),this.scopesByIdentifier.getValuesForKey(e.identifier).forEach(r=>e.disconnectContextForScope(r))}},Ue={controllerAttribute:"data-controller",actionAttribute:"data-action",targetAttribute:"data-target",targetAttributeForScope:s=>`data-${s}-target`,outletAttributeForScope:(s,e)=>`data-${s}-${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"},V("abcdefghijklmnopqrstuvwxyz".split("").map(s=>[s,s]))),V("0123456789".split("").map(s=>[s,s])))};function V(s){return s.reduce((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:r}),{})}var B=class{constructor(e=document.documentElement,t=Ue){this.logger=console,this.debug=!1,this.logDebugActivity=(r,n,i={})=>{this.debug&&this.logFormattedMessage(r,n,i)},this.element=e,this.schema=t,this.dispatcher=new K(this),this.router=new oe(this),this.actionDescriptorFilters=Object.assign({},me)}static start(e,t){let r=new this(e,t);return r.start(),r}async start(){await _e(),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 r=this.router.getContextForElementAndIdentifier(e,t);return r?r.controller:null}handleError(e,t,r){var n;this.logger.error(`%s %o %o`,t,e,r),(n=window.onerror)===null||n===void 0||n.call(window,t,"",0,0,e)}logFormattedMessage(e,t,r={}){r=Object.assign({application:this},r),this.logger.groupCollapsed(`${e} #${t}`),this.logger.log("details:",Object.assign({},r)),this.logger.groupEnd()}};function _e(){return new Promise(s=>{document.readyState=="loading"?document.addEventListener("DOMContentLoaded",()=>s()):s()})}function ze(s){return p(s,"classes").reduce((t,r)=>Object.assign(t,We(r)),{})}function We(s){return{[`${s}Class`]:{get(){let{classes:e}=this;if(e.has(s))return e.get(s);{let t=e.getAttributeName(s);throw new Error(`Missing attribute "${t}"`)}}},[`${s}Classes`]:{get(){return this.classes.getAll(s)}},[`has${g(s)}Class`]:{get(){return this.classes.has(s)}}}}function qe(s){return p(s,"outlets").reduce((t,r)=>Object.assign(t,Je(r)),{})}function Je(s){let e=E(s);return{[`${e}Outlet`]:{get(){let t=this.outlets.find(s);if(t){let r=this.application.getControllerForElementAndIdentifier(t,s);if(r)return r;throw new Error(`Missing "data-controller=${s}" attribute on outlet element for "${this.identifier}" controller`)}throw new Error(`Missing outlet element "${s}" for "${this.identifier}" controller`)}},[`${e}Outlets`]:{get(){let t=this.outlets.findAll(s);return t.length>0?t.map(r=>{let n=this.application.getControllerForElementAndIdentifier(r,s);if(n)return n;console.warn(`The provided outlet element is missing the outlet controller "${s}" for "${this.identifier}"`,r)}).filter(r=>r):[]}},[`${e}OutletElement`]:{get(){let t=this.outlets.find(s);if(t)return t;throw new Error(`Missing outlet element "${s}" for "${this.identifier}" controller`)}},[`${e}OutletElements`]:{get(){return this.outlets.findAll(s)}},[`has${g(e)}Outlet`]:{get(){return this.outlets.has(s)}}}}function He(s){return p(s,"targets").reduce((t,r)=>Object.assign(t,Ze(r)),{})}function Ze(s){return{[`${s}Target`]:{get(){let e=this.targets.find(s);if(e)return e;throw new Error(`Missing target element "${s}" for "${this.identifier}" controller`)}},[`${s}Targets`]:{get(){return this.targets.findAll(s)}},[`has${g(s)}Target`]:{get(){return this.targets.has(s)}}}}function Ge(s){let e=$e(s,"values"),t={valueDescriptorMap:{get(){return e.reduce((r,n)=>{let i=ae(n,this.identifier),o=this.data.getAttributeNameForKey(i.key);return Object.assign(r,{[o]:i})},{})}}};return e.reduce((r,n)=>Object.assign(r,Qe(n)),t)}function Qe(s,e){let t=ae(s,e),{key:r,name:n,reader:i,writer:o}=t;return{[n]:{get(){let a=this.data.get(r);return a!==null?i(a):t.defaultValue},set(a){a===void 0?this.data.delete(r):this.data.set(r,o(a))}},[`has${g(n)}`]:{get(){return this.data.has(r)||t.hasCustomDefaultValue}}}}function ae([s,e],t){return tt({controller:t,token:s,typeDefinition:e})}function k(s){switch(s){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function f(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(s))return"array";if(Object.prototype.toString.call(s)==="[object Object]")return"object"}function Xe(s){let e=k(s.typeObject.type);if(!e)return;let t=f(s.typeObject.default);if(e!==t){let r=s.controller?`${s.controller}.${s.token}`:s.token;throw new Error(`The specified default value for the Stimulus Value "${r}" must match the defined type "${e}". The provided default value of "${s.typeObject.default}" is of type "${t}".`)}return e}function Ye(s){let e=Xe({controller:s.controller,token:s.token,typeObject:s.typeDefinition}),t=f(s.typeDefinition),r=k(s.typeDefinition),n=e||t||r;if(n)return n;let i=s.controller?`${s.controller}.${s.typeDefinition}`:s.token;throw new Error(`Unknown value type "${i}" for "${s.token}" value`)}function et(s){let e=k(s);if(e)return rt[e];let t=s.default;return t!==void 0?t:s}function tt(s){let e=`${P(s.token)}-value`,t=Ye(s);return{type:t,key:e,name:M(e),get defaultValue(){return et(s.typeDefinition)},get hasCustomDefaultValue(){return f(s.typeDefinition)!==void 0},reader:st[t],writer:L[t]||L.default}}var rt={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},st={array(s){let e=JSON.parse(s);if(!Array.isArray(e))throw new TypeError(`expected value of type "array" but instead got value "${s}" of type "${f(e)}"`);return e},boolean(s){return!(s=="0"||String(s).toLowerCase()=="false")},number(s){return Number(s)},object(s){let e=JSON.parse(s);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`expected value of type "object" but instead got value "${s}" of type "${f(e)}"`);return e},string(s){return s}},L={default:nt,array:j,object:j};function j(s){return JSON.stringify(s)}function nt(s){return`${s}`}var u=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:r={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){let a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:r,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}};u.blessings=[ze,He,Ge,qe];u.targets=[];u.outlets=[];u.values={};var it="absolute bg-gray-100 opacity-10 w-full h-full",d=class extends u{get placeholder(){return this.citySelectInputTarget.ariaPlaceholder}set loading(s){if(s){let e=document.createElement("div");e.className=it,e.dataset.target="city-loader",this.citySelectWrapperTarget.prepend(e),this.citySelectWrapperTarget.classList.add("opacity-50")}else this.citySelectWrapperTarget.querySelector('[data-target="city-loader"]').remove(),this.citySelectWrapperTarget.classList.remove("opacity-50")}connect(){return v(this,null,function*(){["edit","new"].includes(this.viewValue)&&(this.captureTheInitialValue(),yield this.onCountryChange())})}onCountryChange(){return v(this,null,function*(){if(this.hasCountrySelectInputTarget&&this.countrySelectInputTarget){let s=this.countrySelectInputTarget.value,e=yield this.fetchCitiesForCountry(s);Object.keys(this.citySelectInputTarget.options).forEach(()=>{this.citySelectInputTarget.options.remove(0)}),this.citySelectInputTarget.add(new Option(this.placeholder)),e.forEach(r=>{this.citySelectInputTarget.add(new Option(r,r))}),Array.from(this.citySelectInputTarget.options).map(r=>r.value).includes(this.initialValue)?this.citySelectInputTarget.value=this.initialValue:this.citySelectInputTarget.value=this.citySelectInputTarget.options[0].value}})}captureTheInitialValue(){this.initialValue=this.citySelectInputTarget.value}fetchCitiesForCountry(s){return v(this,null,function*(){if(!s)return[];this.loading=!0;let t=yield(yield fetch(`${window.Avo.configuration.root_path}/resources/courses/cities?country=${s}`)).json();return this.loading=!1,t})}};b(d,"targets",["countrySelectInput","citySelectInput","citySelectWrapper"]),b(d,"values",{view:String}),b(d,"initialValue");function ot(s){return s.replace(/(?:[_-])([a-z0-9])/g,(e,t)=>t.toUpperCase())}function S(s){return s.charAt(0).toUpperCase()+s.slice(1)}function at(s){return s.replace(/([A-Z])/g,(e,t)=>`-${t.toLowerCase()}`)}function he(s,e){let t=ue(s);return Array.from(t.reduce((r,n)=>(lt(n,e).forEach(i=>r.add(i)),r),new Set))}function ct(s,e){return ue(s).reduce((r,n)=>(r.push(...ht(n,e)),r),[])}function ue(s){let e=[];for(;s;)e.push(s),s=Object.getPrototypeOf(s);return e.reverse()}function lt(s,e){let t=s[e];return Array.isArray(t)?t:[]}function ht(s,e){let t=s[e];return t?Object.keys(t).map(r=>[r,t[r]]):[]}(()=>{function s(t){function r(){return Reflect.construct(t,arguments,new.target)}return r.prototype=Object.create(t.prototype,{constructor:{value:r}}),Reflect.setPrototypeOf(r,t),r}function e(){let r=s(function(){this.a.call(this)});return r.prototype.a=function(){},new r}try{return e(),s}catch{return r=>class extends r{}}})();function ut(s){return he(s,"classes").reduce((t,r)=>Object.assign(t,dt(r)),{})}function dt(s){return{[`${s}Class`]:{get(){let{classes:e}=this;if(e.has(s))return e.get(s);{let t=e.getAttributeName(s);throw new Error(`Missing attribute "${t}"`)}}},[`${s}Classes`]:{get(){return this.classes.getAll(s)}},[`has${S(s)}Class`]:{get(){return this.classes.has(s)}}}}function ft(s){return he(s,"targets").reduce((t,r)=>Object.assign(t,gt(r)),{})}function gt(s){return{[`${s}Target`]:{get(){let e=this.targets.find(s);if(e)return e;throw new Error(`Missing target element "${s}" for "${this.identifier}" controller`)}},[`${s}Targets`]:{get(){return this.targets.findAll(s)}},[`has${S(s)}Target`]:{get(){return this.targets.has(s)}}}}function pt(s){let e=ct(s,"values"),t={valueDescriptorMap:{get(){return e.reduce((r,n)=>{let i=de(n),o=this.data.getAttributeNameForKey(i.key);return Object.assign(r,{[o]:i})},{})}}};return e.reduce((r,n)=>Object.assign(r,mt(n)),t)}function mt(s){let e=de(s),{key:t,name:r,reader:n,writer:i}=e;return{[r]:{get(){let o=this.data.get(t);return o!==null?n(o):e.defaultValue},set(o){o===void 0?this.data.delete(t):this.data.set(t,i(o))}},[`has${S(r)}`]:{get(){return this.data.has(t)||e.hasCustomDefaultValue}}}}function de([s,e]){return Ot(s,e)}function $(s){switch(s){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function D(s){switch(typeof s){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(s))return"array";if(Object.prototype.toString.call(s)==="[object Object]")return"object"}function yt(s){let e=$(s.type);if(e){let t=D(s.default);if(e!==t)throw new Error(`Type "${e}" must match the type of the default value. Given default value: "${s.default}" as "${t}"`);return e}}function bt(s){let e=yt(s),t=D(s),r=$(s),n=e||t||r;if(n)return n;throw new Error(`Unknown value type "${s}"`)}function vt(s){let e=$(s);if(e)return At[e];let t=s.default;return t!==void 0?t:s}function Ot(s,e){let t=`${at(s)}-value`,r=bt(e);return{type:r,key:t,name:ot(t),get defaultValue(){return vt(e)},get hasCustomDefaultValue(){return D(e)!==void 0},reader:Et[r],writer:ce[r]||ce.default}}var At={get array(){return[]},boolean:!1,number:0,get object(){return{}},string:""},Et={array(s){let e=JSON.parse(s);if(!Array.isArray(e))throw new TypeError("Expected array");return e},boolean(s){return!(s=="0"||s=="false")},number(s){return Number(s)},object(s){let e=JSON.parse(s);if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("Expected object");return e},string(s){return s}},ce={default:wt,array:le,object:le};function le(s){return JSON.stringify(s)}function wt(s){return`${s}`}var m=class{constructor(e){this.context=e}static get shouldLoad(){return!0}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 classes(){return this.scope.classes}get data(){return this.scope.data}initialize(){}connect(){}disconnect(){}dispatch(e,{target:t=this.element,detail:r={},prefix:n=this.identifier,bubbles:i=!0,cancelable:o=!0}={}){let a=n?`${n}:${e}`:e,c=new CustomEvent(a,{detail:r,bubbles:i,cancelable:o});return t.dispatchEvent(c),c}};m.blessings=[ut,ft,pt];m.targets=[];m.values={};var y=class extends m{add(e){e.preventDefault();let t=this.templateTarget.innerHTML.replace(/NEW_RECORD/g,new Date().getTime().toString());this.targetTarget.insertAdjacentHTML("beforebegin",t)}remove(e){e.preventDefault();let t=e.target.closest(this.wrapperSelectorValue);if(t.dataset.newRecord==="true")t.remove();else{t.style.display="none";let r=t.querySelector("input[name*='_destroy']");r.value="1"}}};y.targets=["target","template"];y.values={wrapperSelector:{type:String,default:".nested-form-wrapper"}};var N=B.start();N.debug=window==null?void 0:window.localStorage.getItem("avo.debug");N.register("course-resource",d);N.register("nested-form",y);console.log("Hi from Avo custom JS \u{1F44B}");})(); //# sourceMappingURL=avo.custom.js.map